Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

polld.h

Go to the documentation of this file.
00001 /*
00002  * MAX : polld.h, Sam Dez 29 20:03:10 CET 2001 -sg
00003  *
00004  * polling deamon main programm header file
00005  *
00006  * This file is part of Max data acquisition software
00007  * Copyright (C) 1998 Christian Rosen
00008  *
00009  * Max is free software; you can redistribute it and/or modify it
00010  * under the terms of the version 2 of GNU General Public License as
00011  * published by the Free Software Foundation.
00012  *
00013  * Max is distributed in the hope that it will be useful, but WITHOUT
00014  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016  * for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * (see the file COPYING) in this directory; if not, write to the
00020  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021  */
00022 
00023 //connectDevices_putvar routine with siognal to stack packet
00024 #ifndef _POLLD_H_
00025 #define _POLLD_H_
00026 
00027 #include "definitions.h"
00028 //#include "qtincludes.h"
00029 #include "packet.h"
00030 #include "network.h"
00031 #include "list.hh"
00032 #include "sched.hh"
00033 #include "priority.h"
00034 //qt includes
00035 
00036 #include <qapp.h>
00037 #include <qlist.h>
00038 #include <qstring.h>
00039 #include <qsocketnotifier.h>
00040 
00041 //solaris includes
00042 //#include <sys/filio.h>
00043 #include <unistd.h>
00044 #include <netdb.h>
00045 #include <netinet/in.h>
00046 
00047 //main class for polling deamon
00048 class Polld : public QApplication
00049 {
00050     friend class Scheduler;
00051     Q_OBJECT;
00052 public :
00053     Polld(int argc,char* argv[]);
00054     ~Polld();
00055 protected:
00056   int socketConnect(char * ); //Connect all Sockets
00057   void stackData();
00058   void initialize(void);        //reset and clear all variables and databases
00059   void emptyDevDataQueue(void); //add received devData top database
00060   void sendDevData(void );      //send device Parameters back to max GUI
00061   devDataPacket * makeDevPacket (char *,char *,int   );
00062   devDataPacket * makeDevPacket (char *,char *,double);
00063 signals :
00064 //  void  Sig_Error(char *,char *);
00065   void  start();
00066   void Timeout();
00067 protected slots :
00068   int  sendCommand(char ,char *,int ,char *);
00069   void sendParameters(); //send act. int and channel number to GUI
00070   //void sendDevParameter(*devDataPacket); //send one set of device parameters
00071   void sendData();
00072   void commandReceived();
00073   void dataReceived();
00074   void startMeasurement();
00075   void TriggerTimerEvent(); //measurement routine trigered internally
00076   void SendError( char * ); //send Error message to max
00077 private:
00078   /* first, the network stuff */
00079   //     Queues for stacking the data in between two send intervalls
00080   QList<        devDataPacket> *DevSQueue; //device packet queue for sending
00081   QList<devDataPacket> *DevRQueue; //device packet queue for receiving
00082 
00083   devDataPacket      *d_packet;   
00084   command_packet     c_packet;   
00085   devDataPacket      *r_d_packet; 
00086   dataPacket         dat_packet; 
00087   QSocketNotifier    *CommandNotifier;
00088   QSocketNotifier    *DataReceivedNotifier;
00089   int                sockD;
00090   int                data_sfd;      //socket-filedescriptor for data socket
00091   int                send_data_sfd;  //  "         "      for sending DevData
00092   int                cmd_sfd;       // "         "          for command sockets
00093   int                cmdr_sfd;      //command receive socket filedescriptor
00094   int                par_sfd;       // "         "        for device parameters
00095   int                mdata_sfd;    //send measured data socket
00096   struct hostent     *hp;
00097   struct hostent     *host,hostBackup;
00098   struct sockaddr_in server;        //polldeamon is the server
00099   struct sockaddr_in server_max;    //structure to identify max as server
00100   struct sockaddr_in client;        //data recieved from max
00101   struct sockaddr_in client_pd;     //client structure for polld-client
00102   struct sockaddr_in cmdClient_max; //client who receives commands
00103   struct sockaddr_in cmdClient_pd;  //cleint who sends commands
00104   struct sockaddr_in cmdServer_max;
00105   struct sockaddr_in cmdServer_pd;
00106   struct sockaddr_in dataServer;    // polld is only server for maxeasured data
00107   struct sockaddr_in dataClient;   //structure for receiver of dataClient
00108   struct sockaddr    name;
00109   int                sockd;
00110   int                flag;
00111   int                a_sfd; //port
00112   int                b_sfd; //port+1
00113   int                c_sfd; //port+2
00114   int                d_sfd; //port+3
00115   int                e_sfd; //port+4
00116   unsigned int       server_len;
00117   unsigned int       client_len;
00118   unsigned int       client_pd_len;
00119   unsigned int       cmdClient_max_len; //length of received command packet
00120   unsigned int       cmdClient_pd_len;
00121   unsigned int       cmdServer_max_len; //length of com.packets send
00122   unsigned int       dataServer_max_len;      //length of send Data structure
00123 
00124   sockaddr_in  server_addr; //adress of the server
00125   sockaddr_in  data_send;   //adress structure for data send connection
00126   sockaddr_in  cmd_client_addr;
00127   sockaddr_in  cmd_server_addr;
00128   sockaddr_in  cmd_send;   //adress strucutre for command send connection
00129   sockaddr_in  cmd_receive;//adress structure for command receive connection
00130   sockaddr_in  par_send;   //adress structure for device parameters send connection
00131   sockaddr_in  par_receive;//adress structure for device parameters receive connection
00132   sockaddr_in  par_server_max_addr;
00133   sockaddr_in  par_server_pd_addr;
00134   sockaddr_in  par_client_max_addr;
00135   sockaddr_in  par_client_pd_addr;
00136   sockaddr_in  cmd_server_pd_addr;
00137   sockaddr_in  cmd_client_pd_addr;
00138   sockaddr_in  cmd_server_max_addr;
00139   sockaddr_in  cmd_client_max_addr;
00140   unsigned int data_send_len;
00141   unsigned int cmd_server_addr_len;
00142   unsigned int cmd_server_max_addr_len;
00143   unsigned int cmd_server_pd_addr_len;
00144   unsigned int cmd_client_max_addr_len;
00145   unsigned int cmd_client_pd_addr_len;
00146   unsigned int par_server_pd_addr_len;
00147   unsigned int par_client_max_addr_len;
00148   unsigned int par_server_max_addr_len;
00149   unsigned int par_client_pd_addr_len;
00150 
00151   int     main_sfd     ;     //main socket file descriptor
00152   int     cmd_main_sfd ;
00153   int     cmd_main_sfd2;
00154   int     par_main_sfd ;
00155   int   par_main_sfd2  ;
00156 
00157 
00158   /*end of network variables*/
00159   int               orig_sfd,orig_sfd1,orig_sfd2,o_sfd1,o_sfd2;
00160   List               *Devices;      //class for device database
00161   Pr_list            Priority;     //list of priorities
00162   Scheduler          *Schedule;     //scheduler class for routines
00163   /* flags that control the measurement */
00164   int                data_send_interval;
00165   int                stopflag;          // If TRUE Measurement stops
00166   int                pause_flag;         // if TRUE   " measurement pauses   "
00167   int                save_flag;         //TRUE : database holds unsaved data
00168   int                m_running;         // TRUE == Measurement runs
00169   int                continue_flag;     //to enable continue button
00170   int                n;
00171   int                triggermode; // 1 = external, 0 = internal
00172   int                monitor;
00173   int                trigger_period;
00174   int                act_channel,max_channels;
00175   int                act_int,max_integrations;
00176   int                send_period;  //intervall for sending data (chan numbers)
00177   bool               readytosend;  //SendDatatimer has run out-> sendData
00178   int                wait;
00179   int                cmdvalue;     //value of command sequence parameter
00180   bool               suspend;
00181   char               cmdname[MAX_NAME_LENGTH]; //text of command sequence
00182   char *buf[BUFSIZE];
00183   /* QT related stuff */
00184   QTimer             *intTrigger;
00185   QTimer             *sendMData;
00186   QTimer             *send1;
00187   QString            *str;  //a string to convert the data to char
00188 };
00189 
00190 #endif
00191 

Generated at Mon Sep 2 18:21:04 2002 for MAX by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001