diff --git a/MonitorUtils/SEHMonitor.cc b/MonitorUtils/SEHMonitor.cc index 8e42674b5b9800b3f138be5235feb1f323763a39..b62232e6a5133778c72591b9667f99d0f2965c8e 100644 --- a/MonitorUtils/SEHMonitor.cc +++ b/MonitorUtils/SEHMonitor.cc @@ -5,6 +5,7 @@ #include "Utils/ContainerFactory.h" #include "Utils/Utilities.h" #include "Utils/ValueAndTime.h" +#include <boost/algorithm/string.hpp> #ifdef __USE_ROOT__ #include "TFile.h" @@ -96,17 +97,29 @@ void SEHMonitor::runLpGBTRegisterMonitor(const std::string& registerName) void SEHMonitor::runPowerSupplyMonitor(const std::string& registerName) { - // LOG(INFO) << BOLDMAGENTA << "We pretend to be a measurement " << registerName<< RESET; - std::string buffer = fPowerSupplyClient->sendAndReceivePacket("GetStatus"); - LOG(INFO) << BOLDMAGENTA << buffer << RESET; - // while(!(buffer.find("TimeStamp") != std::string::npos)) - // { - // buffer = fPowerSupplyClient->sendAndReceivePacket("GetStatus"); - // LOG(INFO) << BOLDMAGENTA << buffer << RESET; - // } - float cValue = std::stof(getVariableValue(registerName, buffer)); - LOG(INFO) << BOLDMAGENTA << cValue << " " << registerName << RESET; - if((registerName.find("HV") != std::string::npos) & (registerName.find("Current") != std::string::npos)) { cValue *= 1e9; } + std::vector<std::string> seglist; + boost::split(seglist, registerName, boost::is_any_of("_")); + float cValue; + + if((registerName.find("HV") != std::string::npos) & (registerName.find("Current") != std::string::npos)) + { + std::string message = "GetCurrent,PowerSupplyId:" + seglist[0] + ",ChannelId:" + seglist[1] + "_" + seglist[2]; + LOG(INFO) << BOLDMAGENTA << message << RESET; + std::string current = fPowerSupplyClient->sendAndReceivePacket(message); + + cValue = std::stof(current); + LOG(INFO) << BOLDMAGENTA << registerName << " " << cValue << RESET; + + cValue *= 1e9; + } + else + { + std::string message = "GetVoltage,PowerSupplyId:" + seglist[0] + ",ChannelId:" + seglist[1] + "_" + seglist[2]; + LOG(INFO) << BOLDMAGENTA << message << RESET; + std::string voltage = fPowerSupplyClient->sendAndReceivePacket(message); + cValue = std::stof(voltage); + LOG(INFO) << BOLDMAGENTA << registerName << " " << cValue << RESET; + } DetectorDataContainer thePowerSupplyContainer; ContainerFactory::copyAndInitDetector<ValueAndTime<float>>(*fTheSystemController->fDetectorContainer, thePowerSupplyContainer); thePowerSupplyContainer.getSummary<ValueAndTime<float>>() = ValueAndTime<float>(cValue, getTimeStamp()); diff --git a/tools/SEHTester.cc b/tools/SEHTester.cc index 3847bb5367903fe5e8146d66556365e2052f9ff6..8a8643f4e8d3adbcbab42530291a58c380dc083e 100644 --- a/tools/SEHTester.cc +++ b/tools/SEHTester.cc @@ -63,8 +63,11 @@ bool SEHTester::CheckShort(std::string powerSupplyId, std::string channelId) LOG(ERROR) << BOLDRED << "Not connected to the power supply!!!" << RESET; throw std::runtime_error("Not connected to the power supply!!!"); } - std::string buffer = fPowerSupplyClient->sendAndReceivePacket("GetStatus"); - float LvMea = std::stof(getVariableValue(powerSupplyId + "_" + channelId + "_Voltage", buffer)); + std::string message = "GetVoltage,PowerSupplyId:" + powerSupplyId + ",ChannelId:" + channelId + ","; + std::string buffer = fPowerSupplyClient->sendAndReceivePacket(message); + LOG(INFO) << BOLDRED << message << buffer << RESET; + + float LvMea = std::stof(buffer); if(LvMea == 0) { LOG(ERROR) << BOLDRED << "No output voltage at power supply, possible short detected!" << RESET; @@ -322,9 +325,13 @@ void SEHTester::ExternalTestLeakageCurrent(uint16_t pHvSet, double measurementTi float IMea = 0; clock_gettime(CLOCK_MONOTONIC, &timer); - std::string buffer = fPowerSupplyClient->sendAndReceivePacket("GetStatus"); - HvMea = std::stof(getVariableValue(powerSupplyId + "_" + channelId + "_Voltage", buffer)); - IMea = 1e9 * std::stof(getVariableValue(powerSupplyId + "_" + channelId + "_Current", buffer)); + std::string message = "GetVoltage,PowerSupplyId:" + powerSupplyId + ",ChannelId:" + channelId + ","; + std::string buffer = fPowerSupplyClient->sendAndReceivePacket(message); + + message = "GetCurrent,PowerSupplyId:" + powerSupplyId + ",ChannelId:" + channelId + ","; + std::string current = fPowerSupplyClient->sendAndReceivePacket(message); + HvMea = std::stof(buffer); + IMea = 1e9 * std::stof(current); // fTC_2SSEH->read_hvmon(fTC_2SSEH->Mon, UMon); std::this_thread::sleep_for(std::chrono::milliseconds(100)); fTC_2SSEH->read_hvmon(fTC_2SSEH->HV_meas, ILeak); @@ -431,8 +438,9 @@ void SEHTester::ExternalTestBiasVoltage(std::string powerSupplyId, std::string c setVoltageMessage = "SetVoltage,PowerSupplyId:" + powerSupplyId + ",ChannelId:" + channelId + ",Voltage:" + std::to_string(-1 * cHvSet) + ","; fPowerSupplyClient->sendAndReceivePacket(setVoltageMessage); std::this_thread::sleep_for(std::chrono::milliseconds(4500)); - std::string buffer = fPowerSupplyClient->sendAndReceivePacket("GetStatus"); - cHvMea = std::stof(getVariableValue(powerSupplyId + "_" + channelId + "_Voltage", buffer)); + std::string message = "GetVoltage,PowerSupplyId:" + powerSupplyId + ",ChannelId:" + channelId + ","; + std::string buffer = fPowerSupplyClient->sendAndReceivePacket(message); + cHvMea = std::stof(buffer); // fTC_2SSEH->read_hvmon(fTC_2SSEH->Mon, cUMon); fTC_2SSEH->read_hvmon(fTC_2SSEH->VHVJ7, cVHVJ7); fTC_2SSEH->read_hvmon(fTC_2SSEH->VHVJ8, cVHVJ8);