Controller.h
Go to the documentation of this file.
00001 /*
00002 * Controller.h is a header file for the diagnosis board controller.
00003 *
00004 * Copyright (c).2012. OWNER: Institute for Software Technology, TU Graz Austria.
00005 * Authors: Safdar Zaman, Gerald Steinbauer. (szaman@ist.tugraz.at, steinbauer@ist.tugraz.at)
00006 * All rights reserved.
00007 *    This program is free software: you can redistribute it and/or modify
00008 *    it under the terms of the GNU General Public License as published by
00009 *    the Free Software Foundation, either version 3 of the License, or
00010 *    (at your option) any later version.
00011 *
00012 *    This program is distributed in the hope that it will be useful,
00013 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 *    GNU General Public License for more details.
00016 *
00017 *    You should have received a copy of the GNU General Public License
00018 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #include <ros/ros.h>
00022 #include <sys/socket.h>
00023 #include <sys/types.h>
00024 #include <netinet/in.h>
00025 #include <netdb.h>
00026 #include <stdio.h>
00027 #include <string.h>
00028 #include <stdlib.h>
00029 #include <unistd.h>
00030 #include <errno.h>
00031 #include <pthread.h>
00032 #include <vector>
00033 #include <queue>
00034 #include <map>
00035 #include "Message.h"
00036 #include <tug_ist_diagnosis_msgs/DBoardMeasurments.h>
00037 #include <tug_ist_diagnosis_msgs/Channel.h>
00038 
00039 using namespace std;
00040 typedef queue<Message> MSGQUEUE;
00041 struct d
00042      {
00043       int id;
00044       float cur;
00045       float vol;
00046      };
00047 
00048 class Controller
00049 {
00050 public:
00051    Controller();
00052    Controller(unsigned char, string, int);
00053    ~Controller();
00054    friend void* run_recv_Thread(void*);
00055    void recv_Thread();
00056    void initController();
00057    void CallMessageBroadCasting(unsigned char);
00058    void CallMessageRequest();
00059    void CallMessageChannelOnOff(char,char);
00060    void processBuffer(unsigned char *,char);
00061    void chnl2dev_mapping();
00062    char get_chnl_from_map(string);
00063 
00064       
00065 private:
00066    void create_threads();
00067    ros::NodeHandle n_;
00068    ros::Publisher pub_board_msr_;
00069    tug_ist_diagnosis_msgs::DBoardMeasurments board_msr;
00070    int sock, bytes_recieved;  
00071    unsigned char send_data[255],recv_data[255];
00072    unsigned char buffer[255];
00073    unsigned char * p; 
00074    struct hostent *host;
00075    struct sockaddr_in server_addr;
00076    Message *msg;
00077    MSGQUEUE rcvQueue;            
00078    unsigned char initFrq;
00079    map<char,string> chnl2dev_map;
00080    
00081 };


tug_ist_diagnosis_board
Author(s): Safdar Zaman, Gerald Steinbauer
autogenerated on Mon Jan 6 2014 11:51:23