32 mbs::MonitorSlowControl(name,
"Epics", cmd),
36 fEzcaAutoError(false),
53 fNameSepar = Cfg(
"NamesSepar", cmd).AsStr(fNameSepar);
54 fTopFolder = Cfg(
"TopFolder", cmd).AsStr(fTopFolder);
57 fLongValues.resize(fLongRecords.size(), 0);
58 fLongRes.resize(fLongRecords.size(),
false);
61 fDoubleValues.resize(fDoubleRecords.size());
62 fDoubleRes.resize(fDoubleRecords.size(),
false);
64 fWorkerHierarchy.Create(
"EZCA");
68 for (
unsigned ix = 0; ix < fLongRecords.size(); ++ix) {
70 DOUT0(
"Name = %s item %p", GetItemName(fLongRecords[ix]).c_str(), item());
75 for (
unsigned ix = 0; ix < fDoubleRecords.size(); ++ix) {
81 if (fTimeout<=0.001) fTimeout = 0.001;
83 CreateTimer(
"EpicsRead", fTimeout);
85 if (fTopFolder.empty())
86 Publish(fWorkerHierarchy,
"EZCA");
88 Publish(fWorkerHierarchy, std::string(
"EZCA/") + fTopFolder);
93 std::string res = ezcaname;
98 while ((pos = res.find_first_of(
fNameSepar, pos)) != std::string::npos)
104 if (res.find(
fTopFolder)!=0)
return std::string();
116 if (fEzcaTimeout>0) ezcaSetTimeout(fEzcaTimeout);
118 if (fEzcaRetryCnt>0) ezcaSetRetryCount(fEzcaRetryCnt);
120 if (fEzcaDebug) ezcaDebugOn();
123 if (fEzcaAutoError) ezcaAutoErrorMessageOn();
124 else ezcaAutoErrorMessageOff();
126 fLastSendTime.GetNow();
131 if (TimerName(timer) ==
"EpicsRead") {
132 if (!DoEpicsReadout())
return;
134 for (
unsigned ix = 0; ix < fLongRecords.size(); ++ix)
136 fWorkerHierarchy.GetHChild(GetItemName(fLongRecords[ix])).SetField(
"value", fLongValues[ix]);
138 for (
unsigned ix = 0; ix < fDoubleRecords.size(); ++ix)
140 fWorkerHierarchy.GetHChild(GetItemName(fDoubleRecords[ix])).SetField(
"value", fDoubleValues[ix]);
142 fWorkerHierarchy.MarkChangedItems();
153 for (
unsigned ix = 0; ix < fLongRecords.size(); ++ix)
154 if (fLongRes[ix]) fRec.AddLong(fLongRecords[ix], fLongValues[ix]);
156 for (
unsigned ix = 0; ix < fDoubleRecords.size(); ++ix)
157 if (fDoubleRes[ix]) fRec.AddDouble(fDoubleRecords[ix], fDoubleValues[ix]);
159 return fRec.GetRawSize();
164 if ((fLongRecords.size()==0) && (fDoubleRecords.size()==0))
return false;
173 for (
unsigned ix = 0; ix < fLongRecords.size(); ix++) {
176 int ret = CA_GetLong(fLongRecords[ix], fLongValues[ix]);
177 if (ret==EZCA_OK)
continue;
178 EOUT(
"Request long %s Ret = %s", fLongRecords[ix].c_str(), CA_RetCode(ret));
182 for (
unsigned ix = 0; ix < fDoubleRecords.size(); ix++) {
183 fDoubleValues[ix] = 0;
184 fDoubleRes[ix] =
true;
185 int ret = CA_GetDouble(fDoubleRecords[ix], fDoubleValues[ix]);
186 if (ret==EZCA_OK)
continue;
187 EOUT(
"Request double %s Ret = %s", fDoubleRecords[ix].c_str(), CA_RetCode(ret));
192 int *rcs(0), nrcs(0);
194 if (ezcaEndGroupWithReport(&rcs, &nrcs) != EZCA_OK) {
196 EOUT(
"EZCA error %s", CA_ErrorString().c_str());
197 for (
unsigned i=0; i< (unsigned) nrcs; i++)
198 if (i<fLongRecords.size()) {
200 fLongRes[ix] = (rcs[i]==EZCA_OK);
202 EOUT(
"Problem getting long %s ret %s", fLongRecords[ix].c_str(), CA_RetCode(rcs[i]));
204 unsigned ix = i - fLongRecords.size();
205 fDoubleRes[ix] = (rcs[i]==EZCA_OK);
207 EOUT(
"Problem getting double %s ret %s", fDoubleRecords[ix].c_str(), CA_RetCode(rcs[i]));
221 int rev = ezcaGet((
char*) name.c_str(), ezcaLong, 1, &val);
223 EOUT(
"%s", CA_ErrorString().c_str());
225 DOUT3(
"EpicsInput::CA_GetLong(%s) = %d",name.c_str(),val);
231 int rev=ezcaGet((
char*) name.c_str(), ezcaDouble, 1, &val);
233 EOUT(
"%s", CA_ErrorString().c_str());
235 DOUT3(
"EpicsInput::CA_GetDouble(%s) = %f",name.c_str(),val);
243 char *error_msg_buff(0);
244 ezcaGetErrorString(NULL, &error_msg_buff);
245 if (error_msg_buff!=0) res = error_msg_buff;
246 ezcaFree(error_msg_buff);
254 case EZCA_OK:
return "EZCA_OK";
255 case EZCA_INVALIDARG:
return "EZCA_INVALIDARG";
256 case EZCA_FAILEDMALLOC:
return "EZCA_FAILEDMALLOC";
257 case EZCA_CAFAILURE:
return "EZCA_CAFAILURE";
258 case EZCA_UDFREQ:
return "EZCA_UDFREQ";
259 case EZCA_NOTCONNECTED:
return "EZCA_NOTCONNECTED";
260 case EZCA_NOTIMELYRESPONSE:
return "EZCA_NOTIMELYRESPONSE";
261 case EZCA_INGROUP:
return "EZCA_INGROUP";
262 case EZCA_NOTINGROUP:
return "EZCA_NOTINGROUP";
263 case EZCA_ABORTED:
return "EZCA_ABORTED";
Represents command with its arguments.
Represents objects hierarchy of remote (or local) DABC process.
Hierarchy CreateHChild(const std::string &name, bool allowslahes=false, bool sortorder=false)
Create child item in hierarchy with specified name If allowslahes enabled, instead of subfolders item...
void EnableHistory(unsigned length=100, bool withchilds=false)
Activate history production for selected element and its childs.
virtual void OnThreadAssigned()
bool SetField(const std::string &name, const RecordField &v)
virtual void OnThreadAssigned()
Initialize some EZCA settings, do it from worker thread.
virtual void ProcessTimerEvent(unsigned timer)
Method called by framework when timer event is produced.
int CA_GetDouble(const std::string &name, double &val)
virtual unsigned GetRecRawSize()
std::string fTopFolder
name of top folder, which should exists also in every variable
std::string CA_ErrorString()
Return error string with error description.
int CA_GetLong(const std::string &name, long &val)
Monitor(const std::string &name, dabc::Command cmd=nullptr)
std::string fNameSepar
separator symbol(s), which defines subfolder in epcis names
const char * CA_RetCode(int ret)
bool DoEpicsReadout()
Perform readout of all variables.
std::string GetItemName(const std::string &ezcaname)
virtual void ProcessTimerEvent(unsigned timer)
Method called by framework when timer event is produced.
const char * xmlEzcaAutoError
indicates if error should be automatically printed
const char * xmlNameLongRecords
const char * xmlEzcaDebug
retry counter for ezca operation
const char * xmlEzcaTimeout
timeout for ezca operation
const char * xmlEzcaRetryCount
retry counter for ezca operation
const char * xmlNameDoubleRecords
Support for MBS - standard GSI DAQ.
Class for acquiring and holding timestamps.
double SpentTillNow() const
Method return time in second, spent from the time kept in TimeStamp instance If time was not set befo...