direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
circuit.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #ifndef CIRCUIT_H
22 #define CIRCUIT_H
23 
24 //-------------------------------------------------------------------
25 #include "interfaceAvr.h"
26 #include <QMutex>
27 //-------------------------------------------------------------------
28 
35 class Circuit : public QObject
36 {
37  Q_OBJECT
38 
39  public:
40  Circuit(InterfaceAvr *i, QMutex *m);
41  ~Circuit();
42 
46  bool isConnected();
47 
51  bool compassConnected();
52 
53 
54  public slots:
59  bool initCircuit();
60 
65  bool sleep();
66 
71  bool initCompass();
72 
79  void setRobotState(bool state);
80 
81 
82  signals:
87  void robotState(bool state);
88 
94  void compassState(bool state);
95 
100  void message(QString text);
101 
102 
103  private:
104  QString className;
105 
106  mutable QMutex *mutex; // make this class thread-safe
108 
109  QString atmelCommand;
110  QString atmelAnswer;
112 
115  QString commandSleep;
116 
117  static const unsigned char INIT = 64;
118  static const unsigned char INITANSWER = 64;
119  bool circuitState; // stores the robot state within this class
121  bool compassCircuitState; // stores the state of the compass module within this class
122 
123  static const bool ON = true;
124  static const bool OFF = false;
125 
130  static const char starter = 42;
131  static const char terminator = 35;
132  static const char divider = 61;
133 };
134 
135 #endif