qrailway 0.9

cSeriell.h

gehe zur Dokumentation dieser Datei
00001 #ifndef CSERIELL_H
00002 #define CSERIELL_H
00003 
00004 #include "cConstants.h"
00005 #include <qdatetime.h>
00006 #include <qthread.h>
00007 #include <qcoreapplication.h>
00008 #include <QEvent>
00009 #include <QSettings>
00010 
00011 // fuer serielle Kommunikation
00012 #include <stdio.h>   
00013 #include <termios.h>
00014 #include <sys/ioctl.h>
00015 
00017 
00020 class cSeriellEvent : public QEvent
00021 {
00022 public:
00024   cSeriellEvent(int kartetmp,int befehltmp, int statustmp, QDateTime zeittmp) : QEvent((QEvent::Type)(QEvent::User+100)) { karteint=kartetmp;befehlint=befehltmp;statusint=statustmp; zeitdate=zeittmp; }
00026   int karte(void) { return(karteint); };
00028   int befehl(void) { return(befehlint); };
00030   int status(void) { return(statusint); };
00032   QDateTime zeit(void) { return(zeitdate); };
00033 private:
00035   int karteint;
00037   int befehlint;
00039   int statusint;
00041   QDateTime zeitdate;
00042 };
00043 
00045 
00046 class cAuftragdef {
00047 public:
00049         int status;  
00051         char befehl[8];
00053         char antwort[8];
00055         int fehler;
00057         int count,countmax;
00059         QDateTime zeitdate;
00060 };
00061 
00063 
00064 class cSeriell : public QThread
00065 {
00066 
00067 public:
00069   cSeriell(QObject * nachrichtenzieltmp);
00071   ~cSeriell(void);
00073   void cDebug(int prioritaet, const QString & meldung);
00075   void run(void);
00077   void initialisiereSeriellenPort(void);
00079   int sendeBefehl(char* befehl,int prioritaet=1);
00081   int sendeDauerBefehl(char* befehl,int wieoft=1);
00083   void getAntwort(int karte,int nummer,char* antwort);
00085   void setNotaus(bool notausantmp) { notausan=notausantmp; };
00086 private:
00088   bool notausan;
00090   FILE * serialport;
00092   struct termios serialconfig;
00094   cAuftragdef auftrag[128][absmaxauftraege];
00096   int momentanerauftrag[128];
00098   int genutztebefehle[128];
00100   int momentanekarte;
00102   bool raushier;
00104   QObject * nachrichtenziel;
00106   unsigned long int anzahlfehlera[128],anzahlfehlerb[128],anzahlfehlerc[128],anzahlnachrichten[128];
00108   int befehlsoffset;
00110   int maxauftraege;
00112   int maxseriellefehler;
00114   int baudrate;
00116   int timetowrite,timetoread,timetowait;
00118   int hardwareaktiv;
00120   int statusmeldung1[128];
00122   int statusmeldung2[128];
00123 };
00124 
00125 #endif // CSERIELL_H