CARMA C++
PhaseMonitorDevice.h
1 #ifndef CARMA_PHASEMONITORDEVICE_H
2 #define CARMA_PHASEMONITORDEVICE_H
3 /*
4  * $Id: PhaseMonitorDevice.h,v 1.23 2013/02/06 20:07:29 abeard Exp $
5  */
6 #include <fstream>
7 #include <iosfwd>
8 #include <string>
9 
10 namespace log4cpp {
11  class Category;
12 }
13 
14 namespace carma
15 {
16  namespace phasemonitor
17  {
18  class PhaseMonitorDevice
19  {
20  public:
21  PhaseMonitorDevice( const ::std::string & device,
22  bool emulate,
23  const ::std::string & record,
24  bool testBadVolts = false,
25  const ::std::string replay = "" );
26 
27  ::std::string getDeviceFileName();
28  bool isEmulating();
29  void devopen( const ::std::string & device );
30  void AtoDSetup();
31  void command( const ::std::string & command );
32  ::std::string inquire( const std::string & question );
33 
34  bool testBadVolts() { return _testBadVolts; };
35  void setTestBadVolts( bool t ) { _testBadVolts = t; };
36 
37  void queryVoltages( float *voltages );
38  float queryTemperatureC();
39 
40  bool isReplay() { return _replay; };
41 
42  void stopReplay( );
43 
44  void testSleepSomeNanos();
45  bool testBadStartOfReply();
46 
47  float convertStringToFloat( const ::std::string & value,
48  const ::std::string & context );
49  ::std::string getRecordName() { return _recordName; };
50 
51  private:
52  ::std::string replay();
53  std::string::size_type startOfReply( const ::std::string & reply );
54 
55  log4cpp::Category & _log;
56  const bool _logQuestionsAndReplies;
57  int _devFD;
58  ::std::string _devFileName;
59  ::std::string _replayFileName;
60  bool _emulate;
61  bool _testBadVolts;
62  bool _replay;
63  ::std::ifstream _replayFile;
64  bool _useRstream;
65  ::std::string _recordName;
66  ::std::ofstream _rstream;
67  char *_slavePTName;
68  int _masterPTfd, _slavePTfd;
69  };
70  } // phasemonitor
71 } // carma
72 
73 ::std::ostream& operator<<( ::std::ostream& os,
74  ::carma::phasemonitor::PhaseMonitorDevice &dev );
75 
76 #endif // CARMA_PHASEMONITORDEVICE_H
std::ostream & operator<<(::std::ostream &os, const carma::dbms::Table &table)