exposing socket name in settings

This commit is contained in:
2026-05-01 10:51:33 +02:00
parent 5ec5df0a56
commit 95cb1ea246
4 changed files with 47 additions and 1 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ target_include_directories(
target_link_libraries(
ePowerSwitchFrontend
PRIVATE
ePowerSwitchEquipment
ePowerSwitchEquipment
midas::mfe
m_epics_ca
${LIBS}
+37
View File
@@ -16,6 +16,15 @@ std::string format(std::string str, int value) {
return ss.str();
}
std::string getDefaultSocketName(int socketId) {
std::string res = std::string(EPOWERSWITCH_DEFAULT_SOCKET_NAME)
.append(std::to_string(socketId));
printf("get default %s\n", res.c_str());
return res;
}
ePowerSwitchEquipment::ePowerSwitchEquipment(std::string equipmentName,
const char *equipmentFileName)
: TMFeEquipment(equipmentName.c_str(), equipmentFileName),
@@ -35,9 +44,11 @@ ePowerSwitchEquipment::ePowerSwitchEquipment(std::string equipmentName,
void ePowerSwitchEquipment::HandlePeriodic() {
updateSocketNumber();
refreshAllSockets();
updateSocketNames();
}
void ePowerSwitchEquipment::refreshSocket(int socketId) {
std::string requestedVarname =
format("Socket ", socketId) + std::string(" requested");
std::string currentVarname =
@@ -131,6 +142,8 @@ void ePowerSwitchEquipment::updateSocketNumber() {
this->outletGetRecords.push_back(
std::make_unique<mEpicsCa<std::string>>(
epicsGetRecordName.c_str()));
this->socketNames.push_back(getDefaultSocketName(i));
}
if (this->numberOfOutlet > epicsOutletNumber)
@@ -157,7 +170,31 @@ void ePowerSwitchEquipment::updateSocketNumber() {
this->outletSetRecords.pop_back();
this->outletGetRecords.pop_back();
this->socketNames.pop_back();
}
this->numberOfOutlet = epicsOutletNumber;
}
void ePowerSwitchEquipment::updateSocketNames() {
std::string varname = EPOWERSWITCH_SOCKET_NAME_SETTINGS;
varname.reserve(varname.length() + 1);
MVOdbError ovbError;
for (int i = 0; i < this->numberOfOutlet; i++) {
std::string socketName = getDefaultSocketName(i);
varname[7] = '0' + i;
fOdbEqSettings->RS(varname.c_str(), &socketName, true,
socketName.length() + 1, &ovbError);
if (ovbError.fError)
fMfe->Msg(MERROR, __FUNCTION__, ovbError.fErrorString);
printf("%s as the name %s\n", varname.c_str(), socketName.c_str());
if (this->socketNames.at(i) != socketName) {
printf("new name %s\n", socketName.c_str());
this->socketNames.at(i) = socketName;
}
}
}
+6
View File
@@ -25,6 +25,7 @@ class ePowerSwitchEquipment : public TMFeEquipment {
private:
std::vector<std::unique_ptr<mEpicsCa<std::string>>> outletSetRecords;
std::vector<std::unique_ptr<mEpicsCa<std::string>>> outletGetRecords;
std::vector<std::string> socketNames;
mEpicsCa<int> outletNumberRecord;
int numberOfOutlet;
@@ -44,6 +45,11 @@ class ePowerSwitchEquipment : public TMFeEquipment {
* @brief detect and modify the current socket pool in case of change
*/
void updateSocketNumber();
/**
* @brief update socketNames by reading settings ODB
*/
void updateSocketNames();
};
#endif
+3
View File
@@ -5,4 +5,7 @@
#define EPOWERSWITCH_SOCKET_GET_PREFIX "ePowerSwitch_get_outlet_"
#define EPOWERSWITCH_SOCKETNUMBER_INFO_PREFIX "ePowerSwitch_config_maxOutlet"
#define EPOWERSWITCH_DEFAULT_SOCKET_NAME "Socket "
#define EPOWERSWITCH_SOCKET_NAME_SETTINGS "Socket n name"
#endif