Qol
This commit is contained in:
@@ -36,7 +36,7 @@ void powerSwitch::HandlePeriodic() {
|
||||
for (int i = 0; i < this->numberOfOutlet; i++) {
|
||||
Outlet *outlet = &this->outlets.at(i);
|
||||
|
||||
if (outlet->commandHasChange()) {
|
||||
if (outlet->hasGetRecordChanged()) {
|
||||
o[COMMAND_PATH.c_str()][i] = outlet->readSetRecord();
|
||||
}
|
||||
o[READBACK_PATH.c_str()][i] = outlet->readGetRecord();
|
||||
|
||||
@@ -11,8 +11,8 @@ Outlet::Outlet(int index, std::string inputRecordName,
|
||||
this->index = index;
|
||||
this->innerState = State::UNKNOWN;
|
||||
|
||||
this->isOutputConnected = true;
|
||||
this->isInputConnected = true;
|
||||
this->wasOutputConnected = true;
|
||||
this->wasInputConnected = true;
|
||||
this->gracePeriod = 3;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ std::string Outlet::stateToString(State state) {
|
||||
|
||||
Outlet::State Outlet::_getCommand() {
|
||||
if (this->isInputConnected())
|
||||
return stringToState(this->lastCommand);
|
||||
return this->lastCommand;
|
||||
std::string value;
|
||||
int returnCode = this->output.get(&value);
|
||||
if (returnCode != CM_SUCCESS)
|
||||
@@ -189,24 +189,26 @@ Outlet::State Outlet::_getCommand() {
|
||||
bool Outlet::isOutputConnected() {
|
||||
bool outputConnected = this->output.connected();
|
||||
|
||||
if (!outputConnected && this->isOutputConnected) {
|
||||
if (!outputConnected && this->wasOutputConnected) {
|
||||
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
|
||||
"Outlet %d : Output channel disconnected",
|
||||
this->index);
|
||||
}
|
||||
|
||||
this->isOutputConnected = outputConnected;
|
||||
this->wasOutputConnected = outputConnected;
|
||||
return outputConnected;
|
||||
}
|
||||
|
||||
bool Outlet::isInputConnected() {
|
||||
bool inputConnected = this->input.connected();
|
||||
|
||||
if (!inputConnected && this->isInputConnected) {
|
||||
if (!inputConnected && this->wasInputConnected) {
|
||||
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
|
||||
"Outlet %d : Input channel disconnected",
|
||||
this->index);
|
||||
}
|
||||
|
||||
this->isInputConnected = inputConnected;
|
||||
this->wasInputConnected = inputConnected;
|
||||
|
||||
return inputConnected;
|
||||
}
|
||||
|
||||
+5
-2
@@ -40,8 +40,8 @@ class Outlet {
|
||||
mEpicsCa<std::string> input;
|
||||
mEpicsCa<std::string> output;
|
||||
|
||||
bool isInputConnected;
|
||||
bool isOutputConnected;
|
||||
bool wasInputConnected;
|
||||
bool wasOutputConnected;
|
||||
|
||||
int gracePeriod;
|
||||
|
||||
@@ -57,6 +57,9 @@ class Outlet {
|
||||
std::string stateToString(State state);
|
||||
State _getCommand();
|
||||
State lastCommand;
|
||||
|
||||
bool isInputConnected();
|
||||
bool isOutputConnected();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user