QuadroCopter  0.1.4
analogBase.h
Go to the documentation of this file.
1 //
2 // Created by Michael Brookes on 20/05/2016.
3 /*
4 Copyright (C) 2017 Michael Brookes
5 
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef ANALOGDEVICE_ANALOGDEVICE_H
21 #define ANALOGDEVICE_ANALOGDEVICE_H
22 
23 #include "Exceptions/analogSetupException.h"
24 #include "Exceptions/analogRuntimeException.h"
25 
26 #include "../Interfaces/IDevice.h"
27 #include "overlays/analogOverlay.h"
28 
29 #include <unistd.h>
30 #include <fstream>
31 #include <string>
32 
33 namespace quadro { //<! Main Quadro Namespace
34 
35  namespace analog {
36 
41  class analogBase : public IDevice {
42 
43  public:
47  ~analogBase();
48 
53  analogBase();
54 
58  enum analogPort {
59  PORT0 = 0,
60  PORT1 = 1,
61  PORT2 = 2,
62  PORT3 = 3,
63  PORT4 = 4,
64  PORT5 = 5,
65  PORT6 = 6
66  };
67 
72  int getCurrentReading();
73 
78  void setDevicePort( analogPort _AP );
79 
80  private:
81 
82  analogOverlay _analogOverlay;
83 
84  analogPort devicePort;
85 
86  ifstream deviceFile;
87 
88  string deviceFilePath;
89 
90  string currentReading;
91 
97  short readDevice( size_t _bufferSize );
98 
103  void initDevice() throw( analogSetupException& );
104 
108  void setDeviceFilePath();
109 
115  int connectToDevice() throw( analogSetupException& ) { return 1; }
116 
122  int writeToDevice( size_t _bufferSize ) throw( analogSetupException& ) { return 1; }
123 
129  int openDevice() throw( analogSetupException& );
130 
131  };
132 
133  }
134 
135 }
136 #endif //ANALOGDEVICE_ANALOGDEVICE_H
analogBase()
Definition: analogBase.cpp:22
Analog Port 0 (P9, Pin 39)
Definition: analogBase.h:59
Definition: analogSetupException.h:40
Definition: analogBase.h:41
analogPort
Definition: analogBase.h:58
Analog Port 6 (P9, Pin 35)
Definition: analogBase.h:65
int getCurrentReading()
Definition: analogBase.cpp:49
Definition: aeronautics.h:23
void setDevicePort(analogPort _AP)
Definition: analogBase.cpp:90
Analog Port 3 (P9, Pin 38)
Definition: analogBase.h:62
Definition: IDevice.h:27
Definition: analogOverlay.h:42
Analog Port 4 (P9, Pin 33)
Definition: analogBase.h:63
Analog Port 5 (P9, Pin 36)
Definition: analogBase.h:64
~analogBase()
Definition: analogBase.cpp:37
Analog Port 1 (P9, Pin 40)
Definition: analogBase.h:60
Analog Port 2 (P9, Pin 37)
Definition: analogBase.h:61