Skip to content
Snippets Groups Projects
Commit 55ee699d authored by Marco Filho's avatar Marco Filho
Browse files

Add missing ADC parameters

All parameters that share the same ADC are now added: Pulser, Threshold,
Temperature and Bandgap.

All except temperature are showing weird values though, so that needs to
be investigated. I suspect something to do with configHybrid or configFE
or configVmm, but I am not sure.
parent afec971d
No related branches found
No related tags found
1 merge request!7Major refactor
...@@ -65,9 +65,9 @@ record(ai, "$(P)$(R)$(HYB)$(VMM)$(C)ADCVal-R"){ ...@@ -65,9 +65,9 @@ record(ai, "$(P)$(R)$(HYB)$(VMM)$(C)ADCVal-R"){
record(fanout, "$(P)$(R)$(HYB)$(VMM)$(C)#ADCParams") { record(fanout, "$(P)$(R)$(HYB)$(VMM)$(C)#ADCParams") {
field(LNK1, "$(P)$(R)$(HYB)$(VMM)$(C)Temp-R") field(LNK1, "$(P)$(R)$(HYB)$(VMM)$(C)Temp-R")
#Pulser... field(LNK2, "$(P)$(R)$(HYB)$(VMM)$(C)Bdg-R")
#Bandgap... field(LNK3, "$(P)$(R)$(HYB)$(VMM)$(C)Thresh-R")
#Threshold... field(LNK4, "$(P)$(R)$(HYB)$(VMM)$(C)Pulser-R")
} }
# Is updated only when AnalogMon = 67 and ADCVal is read # Is updated only when AnalogMon = 67 and ADCVal is read
...@@ -87,4 +87,61 @@ record(waveform, "$(P)$(R)$(HYB)$(VMM)$(C)TempTmstp-R") { ...@@ -87,4 +87,61 @@ record(waveform, "$(P)$(R)$(HYB)$(VMM)$(C)TempTmstp-R") {
field(FTVL, "CHAR") field(FTVL, "CHAR")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_TMP_TMSTP") field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_TMP_TMSTP")
field(SCAN, "Passive") field(SCAN, "Passive")
}
# Is updated only when AnalogMon = 66 and ADCVal is read
record(ai, "$(P)$(R)$(HYB)$(VMM)$(C)Bdg-R"){
field(DESC, "Last read Bandgap")
field(DTYP, "asynInt32")
field(PINI, "YES")
field(SCAN, "Passive")
field(FLNK, "$(P)$(R)$(HYB)$(VMM)$(C)BdgTmstp-R")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_BDG")
}
record(waveform, "$(P)$(R)$(HYB)$(VMM)$(C)BdgTmstp-R") {
field(DESC, "Timestamp from last bandgap read")
field(DTYP, "asynOctetRead")
field(NELM, "256")
field(FTVL, "CHAR")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_BDG_TMSTP")
field(SCAN, "Passive")
}
# Is updated only when AnalogMon = 65 and ADCVal is read
record(ai, "$(P)$(R)$(HYB)$(VMM)$(C)Thresh-R"){
field(DESC, "Last read Threshold")
field(DTYP, "asynInt32")
field(PINI, "YES")
field(SCAN, "Passive")
field(FLNK, "$(P)$(R)$(HYB)$(VMM)$(C)ThreshTmstp-R")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_THR")
}
record(waveform, "$(P)$(R)$(HYB)$(VMM)$(C)ThreshTmstp-R") {
field(DESC, "Timestamp from last threshold read")
field(DTYP, "asynOctetRead")
field(NELM, "256")
field(FTVL, "CHAR")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_THR_TMSTP")
field(SCAN, "Passive")
}
# Is updated only when AnalogMon = 64 and ADCVal is read
record(ai, "$(P)$(R)$(HYB)$(VMM)$(C)Pulser-R"){
field(DESC, "Last read Pulser ADC")
field(DTYP, "asynInt32")
field(PINI, "YES")
field(SCAN, "Passive")
field(FLNK, "$(P)$(R)$(HYB)$(VMM)$(C)PulserTmstp-R")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_PLS")
}
record(waveform, "$(P)$(R)$(HYB)$(VMM)$(C)PulserTmstp-R") {
field(DESC, "Timestamp from last pulser ADC read")
field(DTYP, "asynOctetRead")
field(NELM, "256")
field(FTVL, "CHAR")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))HYB_$(HYB)_$(VMM)_PLS_TMSTP")
field(SCAN, "Passive")
} }
\ No newline at end of file
...@@ -58,4 +58,17 @@ int VecUtils::getIndex(std::vector<std::vector<int>>& vec, int function, int& hy ...@@ -58,4 +58,17 @@ int VecUtils::getIndex(std::vector<std::vector<int>>& vec, int function, int& hy
} }
return 0; // Found exactly once return 0; // Found exactly once
}
/**
* @brief Converts a timestamp to a string.
*/
std::string TimeUtils::timeToStr(std::chrono::time_point<std::chrono::system_clock> timestamp){
std::time_t time_t_value = std::chrono::system_clock::to_time_t(timestamp);
std::tm tm_value = *std::localtime(&time_t_value);
std::ostringstream oss;
oss << std::put_time(&tm_value, "%Y-%m-%d %H:%M:%S");
return oss.str();
} }
\ No newline at end of file
// Generic utilities for the module // Generic utilities for the module
#include <vector> #include <vector>
#include <string>
#include <chrono>
namespace VecUtils { namespace VecUtils {
int getIndex(std::vector<int> &, int function); int getIndex(std::vector<int> &, int function);
int getIndex(std::vector<std::vector<int>> &, int function, int &hyb_index, int &vmm_index); int getIndex(std::vector<std::vector<int>> &, int function, int &hyb_index, int &vmm_index);
} // namespace VecUtils } // namespace VecUtils
\ No newline at end of file
namespace TimeUtils {
std::string timeToStr(std::chrono::time_point<std::chrono::system_clock> timestamp);
}
\ No newline at end of file
...@@ -85,6 +85,30 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) { ...@@ -85,6 +85,30 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
goto endOfReadInt32; goto endOfReadInt32;
} }
param_index = VecUtils::getIndex(vmmBdg_, function, hyb_index, vmm_index);
if (param_index == 0) {
GenericParameter param_value;
result = this->pVmmAPI->getBandgap(hyb_index, vmm_index, param_value);
*value = param_value.value_int;
goto endOfReadInt32;
}
param_index = VecUtils::getIndex(vmmThr_, function, hyb_index, vmm_index);
if (param_index == 0) {
GenericParameter param_value;
result = this->pVmmAPI->getThresholdADC(hyb_index, vmm_index, param_value);
*value = param_value.value_int;
goto endOfReadInt32;
}
param_index = VecUtils::getIndex(vmmPls_, function, hyb_index, vmm_index);
if (param_index == 0) {
GenericParameter param_value;
result = this->pVmmAPI->getPulserADC(hyb_index, vmm_index, param_value);
*value = param_value.value_int;
goto endOfReadInt32;
}
endOfReadInt32: endOfReadInt32:
if (param_index < 0) { if (param_index < 0) {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: Failed to find parameter %d.\n", driverName, __FUNCTION__, asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: Failed to find parameter %d.\n", driverName, __FUNCTION__,
...@@ -177,13 +201,31 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value, size_t nChars, si ...@@ -177,13 +201,31 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value, size_t nChars, si
if (param_index >= 0) { if (param_index >= 0) {
GenericParameter val; GenericParameter val;
result = this->pVmmAPI->getTemperature(hyb_index, vmm_index, val); result = this->pVmmAPI->getTemperature(hyb_index, vmm_index, val);
read = TimeUtils::timeToStr(val.timestamp);
goto endOfReadOctet;
}
param_index = VecUtils::getIndex(vmmBdgTmstp_, function, hyb_index, vmm_index);
if (param_index >= 0) {
GenericParameter val;
result = this->pVmmAPI->getBandgap(hyb_index, vmm_index, val);
read = TimeUtils::timeToStr(val.timestamp);
goto endOfReadOctet;
}
// Converting timestamp to string param_index = VecUtils::getIndex(vmmThrTmstp_, function, hyb_index, vmm_index);
std::time_t time_t_value = std::chrono::system_clock::to_time_t(val.timestamp); if (param_index >= 0) {
std::tm tm_value = *std::localtime(&time_t_value); GenericParameter val;
std::ostringstream oss; result = this->pVmmAPI->getThresholdADC(hyb_index, vmm_index, val);
oss << std::put_time(&tm_value, "%Y-%m-%d %H:%M:%S"); read = TimeUtils::timeToStr(val.timestamp);
read = oss.str(); goto endOfReadOctet;
}
param_index = VecUtils::getIndex(vmmPlsTmstp_, function, hyb_index, vmm_index);
if (param_index >= 0) {
GenericParameter val;
result = this->pVmmAPI->getPulserADC(hyb_index, vmm_index, val);
read = TimeUtils::timeToStr(val.timestamp);
goto endOfReadOctet; goto endOfReadOctet;
} }
...@@ -247,7 +289,8 @@ asynStatus VMMTbl::createEpicsParams() { ...@@ -247,7 +289,8 @@ asynStatus VMMTbl::createEpicsParams() {
createParamAndStoreInVector("HYB_" + std::to_string(hyb) + key, typ, vec); createParamAndStoreInVector("HYB_" + std::to_string(hyb) + key, typ, vec);
} }
std::vector<int> SC, SL, ST, STH, SM, SD, SMX, ADCIDX, ADCVAL, TEMP, TEMPTMSTP; std::vector<int> SC, SL, ST, STH, SM, SD, SMX, ADCIDX, ADCVAL;
std::vector<int> TEMP, TEMPTMSTP, BDG, BDGTMPSTP, THR, THRTMPSTP, PLS, PLSTMPSTP;
for (int vmm = 0; vmm < VMMS_PER_HYBRID; vmm++) { for (int vmm = 0; vmm < VMMS_PER_HYBRID; vmm++) {
param_name.str(""); param_name.str("");
...@@ -293,6 +336,30 @@ asynStatus VMMTbl::createEpicsParams() { ...@@ -293,6 +336,30 @@ asynStatus VMMTbl::createEpicsParams() {
param_name.str(""); param_name.str("");
param_name << "HYB_" << hyb << "_" << vmm << "_TMP_TMSTP"; param_name << "HYB_" << hyb << "_" << vmm << "_TMP_TMSTP";
createParamAndStoreInVector(param_name.str(), asynParamOctet, &TEMPTMSTP); createParamAndStoreInVector(param_name.str(), asynParamOctet, &TEMPTMSTP);
param_name.str("");
param_name << "HYB_" << hyb << "_" << vmm << "_BDG";
createParamAndStoreInVector(param_name.str(), asynParamInt32, &BDG);
param_name.str("");
param_name << "HYB_" << hyb << "_" << vmm << "_BDG_TMSTP";
createParamAndStoreInVector(param_name.str(), asynParamOctet, &BDGTMPSTP);
param_name.str("");
param_name << "HYB_" << hyb << "_" << vmm << "_THR";
createParamAndStoreInVector(param_name.str(), asynParamInt32, &THR);
param_name.str("");
param_name << "HYB_" << hyb << "_" << vmm << "_THR_TMSTP";
createParamAndStoreInVector(param_name.str(), asynParamOctet, &THRTMPSTP);
param_name.str("");
param_name << "HYB_" << hyb << "_" << vmm << "_PLS";
createParamAndStoreInVector(param_name.str(), asynParamInt32, &PLS);
param_name.str("");
param_name << "HYB_" << hyb << "_" << vmm << "_PLS_TMSTP";
createParamAndStoreInVector(param_name.str(), asynParamOctet, &PLSTMPSTP);
} }
this->vmmSC_.push_back(SC); this->vmmSC_.push_back(SC);
...@@ -306,6 +373,12 @@ asynStatus VMMTbl::createEpicsParams() { ...@@ -306,6 +373,12 @@ asynStatus VMMTbl::createEpicsParams() {
this->vmmADCVAL_.push_back(ADCVAL); this->vmmADCVAL_.push_back(ADCVAL);
this->vmmTemp_.push_back(TEMP); this->vmmTemp_.push_back(TEMP);
this->vmmTempTmstp_.push_back(TEMPTMSTP); this->vmmTempTmstp_.push_back(TEMPTMSTP);
this->vmmBdg_.push_back(BDG);
this->vmmBdgTmstp_.push_back(BDGTMPSTP);
this->vmmThr_.push_back(THR);
this->vmmThrTmstp_.push_back(THRTMPSTP);
this->vmmPls_.push_back(PLS);
this->vmmPlsTmstp_.push_back(PLSTMPSTP);
} }
return asynSuccess; return asynSuccess;
......
...@@ -55,6 +55,12 @@ class VMMTbl : public asynPortDriver { ...@@ -55,6 +55,12 @@ class VMMTbl : public asynPortDriver {
std::vector<std::vector<int>> vmmADCVAL_; std::vector<std::vector<int>> vmmADCVAL_;
std::vector<std::vector<int>> vmmTemp_; std::vector<std::vector<int>> vmmTemp_;
std::vector<std::vector<int>> vmmTempTmstp_; std::vector<std::vector<int>> vmmTempTmstp_;
std::vector<std::vector<int>> vmmBdg_;
std::vector<std::vector<int>> vmmBdgTmstp_;
std::vector<std::vector<int>> vmmThr_;
std::vector<std::vector<int>> vmmThrTmstp_;
std::vector<std::vector<int>> vmmPls_;
std::vector<std::vector<int>> vmmPlsTmstp_;
private: private:
static constexpr const char *driverName = "VMMTbl"; static constexpr const char *driverName = "VMMTbl";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment