150 const uint16_t status = (answer[0]>>7)&1;
151 const uint16_t wrap = (answer[0]>>4)&7;
152 const uint16_t ddd = ((uint16_t(answer[0])&0xf)<<8) | answer[1];
153 const uint16_t error = (answer[2]>>4)&0xf;
154 const uint16_t board = answer[2]&0xf;
174 msg <<
"Corrupted answer (id=" <<
id <<
"): received wrap counter " << wrap <<
" doesn't match last one " <<
fWrapCounter <<
" ";
186 msg << hex << setfill(
'0');
187 msg <<
"Initial answer received: 0x";
188 msg << setw(2) << (int)answer[2];
189 msg << setw(2) << (int)answer[1];
190 msg << setw(2) << (int)answer[0];
193 if (status!=0 || ddd!=0 || error!=0 || board!=0)
195 Warn(
"Initial answer doesn't seem to be a reset as naively expected.");
206 msg <<
"Setting fSendCounter to " << wrap;
214 Message(
"Reset button on crate pressed!");
221 if (status==0 && ddd==0 && error==0 && board==0)
223 Message(
"Reset successfully executed.");
227 Warn(
"Answer to 'reset' command contains unexpected data.");
233 if (status==0 && ddd==0 && error==0 && board==0)
243 Warn(
"Answer to 'global set' command contains unexpected data.");
250 const int cmd = command&3;
263 if (error==0x7 || error==0xf)
273 fCurrent[
id] = status ? -(ddd==0?1:ddd) : ddd;
280 Warn(
"OverCurrent detected.");
286 Warn(
"Emergency limit exceeded.");
292 Error(
"Emergency ramp down initiated.");
vector< int16_t > fCurrent
bool RampAllDacs(uint16_t dac)
int Error(const std::string &str)
void SendCommandNB(const std::string &command)
int Warn(const std::string &str)
int Info(const std::string &str)
int Message(const std::string &str)
vector< uint16_t > fDacActual
vector< uint16_t > fDacCommand