switching to newer mepicsca version and adding readback

This commit is contained in:
2026-04-29 16:35:27 +02:00
parent c5cac7beeb
commit ce45de8087
6 changed files with 43 additions and 25 deletions
@@ -0,0 +1,8 @@
# CMake generated Testfile for
# Source directory: /home/ponsin_h/midas_frontends/ePowerSwitch_frontend/submodule/mepicsca
# Build directory: /home/ponsin_h/midas_frontends/ePowerSwitch_frontend/build/submodule/mepicsca
#
# This file includes the relevant testing commands required for
# testing this directory and lists subdirectories to be tested as well.
add_test(m_epics_ca_test "/home/ponsin_h/midas_frontends/ePowerSwitch_frontend/submodule/mepicsca/run_test.sh" "/home/ponsin_h/midas_frontends/ePowerSwitch_frontend/build/submodule/mepicsca/m_epics_ca_test")
set_tests_properties(m_epics_ca_test PROPERTIES RUN_SERIAL "TRUE" WORKING_DIRECTORY "/home/ponsin_h/midas_frontends/ePowerSwitch_frontend/submodule/mepicsca" _BACKTRACE_TRIPLES "/home/ponsin_h/midas_frontends/ePowerSwitch_frontend/submodule/mepicsca/CMakeLists.txt;113;add_test;/home/ponsin_h/midas_frontends/ePowerSwitch_frontend/submodule/mepicsca/CMakeLists.txt;0;")
Binary file not shown.
+2 -1
View File
@@ -1,7 +1,8 @@
#ifndef EPOWERSWITCH_CONFIG_H
#define EPOWERSWITCH_CONFIG_H
#define EPOWERSWITCH_SOCKET_COMMAND_PREFIX "ePowerSwitch_command_outlet_"
#define EPOWERSWITCH_SOCKET_SET_PREFIX "ePowerSwitch_set_outlet_"
#define EPOWERSWITCH_SOCKET_GET_PREFIX "ePowerSwitch_get_outlet_"
#define EPOWERSWITCH_SOCKETNUMBER_INFO_PREFIX "ePowerSwitch_config_maxOutlet"
#define DEFAULT_FRONTEND_NAME "ePowerSwitch"
+2 -2
View File
@@ -23,8 +23,8 @@ class ePowerSwitchEquipment : public TMFeEquipment {
void HandlePeriodic();
private:
std::vector<mEpicsCa<int> *> outletCommandRecords;
std::vector<int> outletLastState;
std::vector<mEpicsCa<std::string> *> outletSetRecords;
std::vector<mEpicsCa<std::string> *> outletGetRecords;
mEpicsCa<int> outletNumberRecord;
int numberOfOutlet;
+30 -21
View File
@@ -77,21 +77,24 @@ void ePowerSwitchEquipment::HandlePeriodic() {
}
void ePowerSwitchEquipment::refreshSocket(int socketId) {
std::string varname = format("Socket ", socketId);
std::string requestedVarname =
format("Socket ", socketId) + std::string(" requested");
std::string currentVarname =
format("Socket ", socketId) + std::string(" current");
int midasSocketState = 0; // default => turn off
fOdbEqVariables->RI(varname.c_str(), &midasSocketState, true);
std::string midasRequestedSocketState = std::string("Off");
fOdbEqVariables->RS(requestedVarname.c_str(), &midasRequestedSocketState,
true, midasRequestedSocketState.length() + 1);
if (midasSocketState != this->outletLastState.at(socketId)) {
int errorCode =
this->outletCommandRecords.at(socketId)->put(&midasSocketState);
if (errorCode < 0) {
fMfe->Msg(MERROR, __FUNCTION__,
"Couldn't put new value into socket n° %d", socketId);
} else {
this->outletLastState.at(socketId) = midasSocketState;
}
std::string epicsCurrentSocketState;
this->outletGetRecords.at(socketId)->get(&epicsCurrentSocketState);
if (epicsCurrentSocketState != midasRequestedSocketState) {
this->outletSetRecords.at(socketId)->put(&midasRequestedSocketState);
}
fOdbEqVariables->WS(currentVarname.c_str(), epicsCurrentSocketState.c_str(),
epicsCurrentSocketState.length() + 1);
}
void ePowerSwitchEquipment::refreshAllSockets() {
@@ -124,12 +127,16 @@ void ePowerSwitchEquipment::updateSocketNumber() {
epicsOutletNumber - this->numberOfOutlet);
for (int i = this->numberOfOutlet; i < epicsOutletNumber; i++) {
std::string epicsRecordName =
format(EPOWERSWITCH_SOCKET_COMMAND_PREFIX, i);
std::string epicsSetRecordName =
format(EPOWERSWITCH_SOCKET_SET_PREFIX, i);
this->outletCommandRecords.push_back(
new mEpicsCa<int>(epicsRecordName.c_str(), true));
this->outletLastState.push_back(0);
this->outletSetRecords.push_back(
new mEpicsCa<std::string>(epicsSetRecordName.c_str()));
std::string epicsGetRecordName =
format(EPOWERSWITCH_SOCKET_GET_PREFIX, i);
this->outletGetRecords.push_back(
new mEpicsCa<std::string>(epicsGetRecordName.c_str()));
}
if (this->numberOfOutlet > epicsOutletNumber)
@@ -138,11 +145,13 @@ void ePowerSwitchEquipment::updateSocketNumber() {
this->numberOfOutlet - epicsOutletNumber);
for (int i = epicsOutletNumber; i < this->numberOfOutlet; i++) {
mEpicsCa<int> *ptr = this->outletCommandRecords.back();
delete ptr;
mEpicsCa<std::string> *setRecord = this->outletSetRecords.back();
delete setRecord;
mEpicsCa<std::string> *getRecord = this->outletGetRecords.back();
delete getRecord;
this->outletCommandRecords.pop_back();
this->outletLastState.pop_back();
this->outletSetRecords.pop_back();
this->outletGetRecords.pop_back();
}
this->numberOfOutlet = epicsOutletNumber;