LRAUV  revA
LoadControl.h
Go to the documentation of this file.
1 
10 #ifndef LOADCONTROL_H_
11 #define LOADCONTROL_H_
12 
13 #include "data/Slate.h"
14 #include "io/DeviceIOStream.h"
15 
16 class Component;
17 
25 {
26 public:
28  LoadControl( const ConfigURI& loadControlCfg, bool useHardware, Logger& logger, Component* component );
29 
30  virtual ~LoadControl();
31 
33  bool powerUp();
34 
36  bool powerDown();
37 
39  bool isolateLoad();
40 
42  bool deisolateLoad();
43 
45  bool discreteOn();
46 
48  bool discreteOff();
49 
52 
54  void requestFaults();
55 
57  void readFaults();
58 
60  /*
61  // MSB
62  7: 1 (end-of-transmission indicator)
63  6: spare
64  5: spare
65  4: Current Limiter Activated (1 if true)
66  3: Software overcurrent detection (1 if true)
67  2: Load power shutoff due to current limiter (1 if shutoff)
68  1: Invalid command error (1 if error)
69  0: WDT reset (1 if reset)
70  LSB
71  */
72  typedef enum { OK = 0,
73  WDT_RESET = 0x01,
74  INVALID_CMD = 0x02,
77  CL_ACTIVATED = 0x10
78  } LCBError;
79 
80  enum PowerState // Correspondence to Component...
81  {
83  POWER_UP, // ::STARTING & maybe ::RESETTING
84  ON, // ::RUNNABLE
86  POWER_DOWN, // ::PAUSING & ::SHUTTING_DOWN & maybe ::RESETTING
87  OFF, // ::SHUTDOWN & maybe PAUSED
88  };
89 
90  typedef enum
91  {
92  REQUESTVOLTAGE, // Send request
93  PARSEVOLTAGE, // Read response
94  REQUESTCURRENT, // Send request
95  PARSECURRENT, // Read response
96  DONE, // Ready to run
97  } LCBData;
98 
100  {
101  return powerState_;
102  }
103 
104 
106  {
107  if( powerState_ == POWER_UP )
108  {
109  powerState_ = ON;
110  return true;
111  }
112  else
113  return false;
114  }
115 
116 
118  {
119  if( powerState_ == POWER_DOWN )
120  {
121  powerState_ = OFF;
122  return true;
123  }
124  else
125  {
126  return false;
127  }
128  }
129 
130  bool hasError()
131  {
132  if( errorStatus_ & 0x1F )
133  {
134  return true;
135  }
136  else
137  {
138  return false;
139  }
140  }
141 
142  Str errorString();
143 
144 private:
145  // Note that the copy constructor below is private and not given a body.
146  // Any attempt to call it will return a compiler error.
147  LoadControl( const LoadControl& old ); // disallow copy constructor};
148 
150  void initialize();
151 
152  unsigned short extractCount( char * convertCount, int pos );
153 
155 
157 
159 
161 
164 
165  // The errors reported by the LCB
167 
169 
170 
171 
172 };
173 
174 #endif /* LOADCONTROL_H_ */
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
Definition: LoadControl.h:75
Definition: LoadControl.h:95
void initialize()
Initializes power switching to the load control backplane.
Definition: LoadControl.cpp:35
bool isolateLoad()
Turns off and isolates device.
Definition: LoadControl.cpp:110
virtual ~LoadControl()
Definition: LoadControl.cpp:32
bool initialized_
Definition: LoadControl.h:160
void readFaults()
Reads back the fault byte. To be called after requestFaults.
Definition: LoadControl.cpp:307
LCBError
LCB Fault Byte.
Definition: LoadControl.h:72
Definition: LoadControl.h:85
int errorStatus_
Definition: LoadControl.h:166
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
bool discreteOff()
Turns off discrete;.
Definition: LoadControl.cpp:183
Definition: LoadControl.h:82
PowerState
Definition: LoadControl.h:80
Definition: LoadControl.h:84
Definition: LoadControl.h:94
Definition: ElementURI.h:166
Definition: LoadControl.h:77
Definition: LoadControl.h:72
DeviceIOStream io_
Definition: LoadControl.h:156
Component * component_
Definition: LoadControl.h:168
Str errorString()
Definition: LoadControl.cpp:321
unsigned short extractCount(char *convertCount, int pos)
Definition: LoadControl.cpp:355
Timespan requestTimeout_
Definition: LoadControl.h:162
bool hasError()
Definition: LoadControl.h:130
bool discreteOn()
Turns on discrete;.
Definition: LoadControl.cpp:161
Replacement for standard template class string.
Definition: Str.h:12
bool powerUp()
Turns on the device.
Definition: LoadControl.cpp:51
void requestFaults()
Requests the fault byte.
Definition: LoadControl.cpp:297
This class allows one to control loads on a load controller channel.
Definition: LoadControl.h:24
Abstract Base class for software components.
Definition: Component.h:53
Definition: LoadControl.h:92
PowerState powerState_
Definition: LoadControl.h:158
Definition: LoadControl.h:87
bool setPowerStateOn()
Definition: LoadControl.h:105
Definition: LoadControl.h:96
Definition: LoadControl.h:74
LoadControl(const ConfigURI &loadControlCfg, bool useHardware, Logger &logger, Component *component)
Constructor.
Definition: LoadControl.cpp:17
PowerState getPowerState()
Definition: LoadControl.h:99
void requestVoltageAndCurrent()
Requests voltage information from LCB and writes it to component writers.
Definition: LoadControl.cpp:204
Definition: LoadControl.h:86
Definition: LoadControl.h:83
Definition: LoadControl.h:73
bool deisolateLoad()
Turns off and de-isolates device (i.e. closes relay)
Definition: LoadControl.cpp:135
Definition: LoadControl.h:93
Timestamp startTime_
Definition: LoadControl.h:163
bool setPowerStateOff()
Definition: LoadControl.h:117
LCBData
Definition: LoadControl.h:90
Wraps a linux device with an IOStream class.
Definition: DeviceIOStream.h:23
bool powerDown()
Turns off the device.
Definition: LoadControl.cpp:78
Definition: LoadControl.h:76
Represents absolute times.
Definition: Timestamp.h:31
LCBData dataState_
Definition: LoadControl.h:154
Contains the DeviceIOStream class declaration.
Contains the Slate class definition.