mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 09:10:01 +02:00
still in the process of interfacing det and client
This commit is contained in:
parent
86fb843021
commit
dfad145e14
@ -548,13 +548,13 @@ int Server_VerifyLock() {
|
|||||||
|
|
||||||
void Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) {
|
void Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) {
|
||||||
|
|
||||||
// update if different clients
|
// update if different clients (ret can be ok or acquisition finished), not fail to not overwrite e message
|
||||||
if (update && ret == OK && differentClients)
|
if (update && ret != FAIL && differentClients)
|
||||||
ret = FORCE_UPDATE;
|
ret = FORCE_UPDATE;
|
||||||
|
|
||||||
// send success of operation
|
// send success of operation
|
||||||
int ret1 = ret;
|
int ret1 = ret;
|
||||||
sendData(fileDes, &ret1,sizeof(ret1), INT32);
|
sendData(fileDes, &ret1,sizeof(ret1), INT32);/* if < 0, return , socket crash*/
|
||||||
if(ret == FAIL) {
|
if(ret == FAIL) {
|
||||||
// send error message
|
// send error message
|
||||||
if (strlen(mess))
|
if (strlen(mess))
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,8 @@ int decode_function(int);
|
|||||||
const char* getFunctionName(enum detFuncs func);
|
const char* getFunctionName(enum detFuncs func);
|
||||||
void function_table();
|
void function_table();
|
||||||
void functionNotImplemented();
|
void functionNotImplemented();
|
||||||
|
void modeNotImplemented(char* modename, int mode);
|
||||||
|
void validate(int arg, int retval, char* modename, int hex);
|
||||||
int M_nofunc(int);
|
int M_nofunc(int);
|
||||||
int M_nofuncMode(int);
|
int M_nofuncMode(int);
|
||||||
|
|
||||||
|
@ -870,9 +870,11 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, b
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static function
|
// static function
|
||||||
slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int cport) {
|
slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int cport) {
|
||||||
int fnum = F_GET_DETECTOR_TYPE;
|
int fnum = F_GET_DETECTOR_TYPE;
|
||||||
|
int ret = FAIL;
|
||||||
detectorType retval = GENERIC;
|
detectorType retval = GENERIC;
|
||||||
MySocketTCP* mySocket = 0;
|
MySocketTCP* mySocket = 0;
|
||||||
|
|
||||||
@ -883,17 +885,19 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Getting detector type ";
|
FILE_LOG(logDEBUG5) << "Getting detector type ";
|
||||||
if (mySocket->Connect() >= 0) {
|
if (mySocket->Connect() >= 0) {
|
||||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
int ret = FAIL; // not needed but is in protocol from server
|
|
||||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
FILE_LOG(logDEBUG5) << "Detector type is " << retval;
|
|
||||||
mySocket->Disconnect();
|
mySocket->Disconnect();
|
||||||
} else {
|
} else {
|
||||||
FILE_LOG(logERROR) << "Cannot connect to server " << name << " over port " << cport;
|
FILE_LOG(logERROR) << "Cannot connect to server " << name << " over port " << cport;
|
||||||
}
|
}
|
||||||
|
if (ret != FAIL) {
|
||||||
|
FILE_LOG(logDEBUG5) << "Detector type is " << retval;
|
||||||
|
}
|
||||||
|
|
||||||
delete mySocket;
|
delete mySocket;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -1558,10 +1562,11 @@ int slsDetector::execCommand(std::string cmd) {
|
|||||||
// handle ret
|
// handle ret
|
||||||
if (ret == FAIL)
|
if (ret == FAIL)
|
||||||
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
|
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
|
||||||
else
|
|
||||||
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ret != FAIL) {
|
||||||
|
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2953,58 +2958,31 @@ int slsDetector::getDataBytesInclGapPixels() {
|
|||||||
|
|
||||||
int slsDetector::setDAC(int val, dacIndex index, int mV) {
|
int slsDetector::setDAC(int val, dacIndex index, int mV) {
|
||||||
|
|
||||||
|
if ((index == HV_NEW) && (thisDetector->myDetectorType == GOTTHARD))
|
||||||
|
index = HV_POT;
|
||||||
|
|
||||||
int retval[2];
|
int fnum = F_SET_DAC;
|
||||||
retval[0] = -1;
|
int ret = FAIL;
|
||||||
retval[1] = -1;
|
int args[3] = {(int)index, mV, val};
|
||||||
int fnum=F_SET_DAC;
|
int retval[2] = {-1, -1};
|
||||||
int ret=FAIL;
|
|
||||||
char mess[MAX_STR_LENGTH]="";
|
|
||||||
int arg[2];
|
|
||||||
|
|
||||||
|
FILE_LOG(logDEBUG5) << "Setting DAC "<< index << " to " << val << (mV ? "mV" : "dac units");
|
||||||
|
|
||||||
if ( (index==HV_NEW) &&(thisDetector->myDetectorType == GOTTHARD))
|
|
||||||
index=HV_POT;
|
|
||||||
|
|
||||||
arg[0]=index;
|
|
||||||
arg[1]=mV;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout<< std::endl;
|
|
||||||
std::cout<< "Setting DAC "<< index << " to " << val << std::endl;
|
|
||||||
#endif
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
ret = thisDetectorControl->Client_Send(fnum,
|
||||||
controlSocket->SendDataOnly(arg,sizeof(arg));
|
args, sizeof(args), retval, sizeof(retval));
|
||||||
controlSocket->SendDataOnly(&val,sizeof(val));
|
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret!=FAIL) {
|
|
||||||
controlSocket->ReceiveDataOnly(retval,sizeof(retval));
|
|
||||||
if (index < thisDetector->nDacs){
|
|
||||||
|
|
||||||
if (dacs) {
|
|
||||||
*(dacs+index)=retval[0];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
disconnectControl();
|
disconnectControl();
|
||||||
if (ret==FORCE_UPDATE)
|
// handle ret
|
||||||
|
if (ret == FAIL)
|
||||||
|
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
|
||||||
|
else if (ret == FORCE_UPDATE)
|
||||||
updateDetector();
|
updateDetector();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
if (ret != FAIL) {
|
||||||
std::cout<< "Dac set to "<< retval[0] << " dac units (" << retval[1] << "mV)"
|
FILE_LOG(logDEBUG5) << "Dac index " << index << ": "
|
||||||
<< std::endl;
|
<< retval[0] << " dac units (" << retval[1] << "mV)";
|
||||||
#endif
|
|
||||||
if (ret==FAIL) {
|
|
||||||
std::cout<< "Set dac " << index << " to " << val << " failed." << std::endl;
|
|
||||||
}
|
}
|
||||||
if(mV)
|
if(mV)
|
||||||
return retval[1];
|
return retval[1];
|
||||||
@ -3016,42 +2994,30 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) {
|
|||||||
|
|
||||||
|
|
||||||
int slsDetector::getADC(dacIndex index) {
|
int slsDetector::getADC(dacIndex index) {
|
||||||
|
int fnum = F_GET_ADC;
|
||||||
|
int ret = FAIL;
|
||||||
|
int arg = (int)index;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int fnum=F_GET_ADC;
|
|
||||||
int ret=FAIL;
|
|
||||||
int arg = index;
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
FILE_LOG(logDEBUG5) << "Getting ADC "<< index;
|
||||||
std::cout<< std::endl;
|
|
||||||
std::cout<< "Getting ADC "<< index << std::endl;
|
|
||||||
#endif
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectStop() == OK){
|
if (connectControl() == OK){
|
||||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
ret = thisDetectorControl->Client_Send(fnum,
|
||||||
stopSocket->SendDataOnly(&arg,sizeof(arg));
|
&arg, sizeof(arg), &retval, sizeof(retval));
|
||||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
disconnectControl();
|
||||||
if (ret!=FAIL) {
|
// handle ret
|
||||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
if (ret == FAIL)
|
||||||
if (adcs) {
|
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
|
||||||
*(adcs+index)=retval;
|
/*commented out to allow adc read during acquire
|
||||||
}
|
else if (ret == FORCE_UPDATE)
|
||||||
} else {
|
updateDetector();*/
|
||||||
char mess[MAX_STR_LENGTH]="";
|
|
||||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
disconnectStop();
|
|
||||||
/*commented out to allow adc read during acquire, also not required
|
|
||||||
if (ret==FORCE_UPDATE)
|
|
||||||
updateDetector();*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
if (ret != FAIL) {
|
||||||
std::cout<< "ADC returned "<< retval << std::endl;
|
FILE_LOG(logDEBUG5) << "ADC (" << index << "): " << retval;
|
||||||
#endif
|
|
||||||
if (ret==FAIL) {
|
|
||||||
std::cout<< "Get ADC failed " << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3077,6 +3043,9 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication
|
|||||||
updateDetector();
|
updateDetector();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ret != FAIL) {
|
||||||
|
FILE_LOG(logDEBUG5) << "Timing Mode: " << retval;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3102,6 +3071,9 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(
|
|||||||
updateDetector();
|
updateDetector();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ret != FAIL) {
|
||||||
|
FILE_LOG(logDEBUG5) << "Ext Signal (" << signalindex << "): " << retval;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4029,43 +4001,30 @@ int slsDetector::setUDPConnection() {
|
|||||||
|
|
||||||
|
|
||||||
int slsDetector::digitalTest( digitalTestMode mode, int ival) {
|
int slsDetector::digitalTest( digitalTestMode mode, int ival) {
|
||||||
int retval = -1;
|
|
||||||
int fnum = F_DIGITAL_TEST;
|
int fnum = F_DIGITAL_TEST;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
|
int args[2] = {mode, ival};
|
||||||
#ifdef VERBOSE
|
int retval = -1;
|
||||||
std::cout<< std::endl;
|
|
||||||
std::cout<< "Getting id of "<< mode << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
FILE_LOG(logDEBUG5) << "Sending digital test of mode " << mode << ", ival " << ival;
|
||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
ret = thisDetectorControl->Client_Send(fnum,
|
||||||
controlSocket->SendDataOnly(&mode,sizeof(mode));
|
args, sizeof(args), &retval, sizeof(retval));
|
||||||
controlSocket->SendDataOnly(&ival,sizeof(ival));
|
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret!=FAIL)
|
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
|
||||||
else {
|
|
||||||
char mess[MAX_STR_LENGTH]="";
|
|
||||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
disconnectControl();
|
disconnectControl();
|
||||||
if (ret==FORCE_UPDATE)
|
// handle ret
|
||||||
|
if (ret == FAIL)
|
||||||
|
setErrorMask((getErrorMask())|(OTHER_ERROR_CODE));
|
||||||
|
else if (ret == FORCE_UPDATE)
|
||||||
updateDetector();
|
updateDetector();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ret=FAIL;
|
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
if (ret != FAIL && mode == DIGITAL_BIT_TEST) {
|
||||||
std::cout<< "Id "<< mode <<" is " << retval << std::endl;
|
FILE_LOG(logDEBUG5) << "Digital test bit: " << retval;
|
||||||
#endif
|
}
|
||||||
if (ret==FAIL) {
|
|
||||||
std::cout<< "Get id failed " << std::endl;
|
return retval;
|
||||||
return ret;
|
|
||||||
} else
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4352,19 +4311,29 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update roi in receiver
|
// update roi in receiver
|
||||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
if(ret == OK && thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||||
int fnum=F_RECEIVER_SET_ROI;
|
int fnum = F_RECEIVER_SET_ROI;
|
||||||
|
ret = FAIL;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl;
|
std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (connectData() == OK){
|
if (connectData() == OK){
|
||||||
ret=thisReceiver->Client_Send(fnum,
|
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
&thisDetector->nROI, sizeof(thisDetector->nROI),
|
dataSocket->SendDataOnly(&thisDetector->nROI, sizeof(thisDetector->nROI));
|
||||||
thisDetector->roiLimits, thisDetector->nROI * sizeof(ROI));
|
for(int i = 0; i < thisDetector->nROI; ++i){
|
||||||
|
dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmin, sizeof(int));
|
||||||
|
dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmax, sizeof(int));
|
||||||
|
dataSocket->SendDataOnly(&thisDetector->roiLimits[i].ymin, sizeof(int));
|
||||||
|
dataSocket->SendDataOnly(&thisDetector->roiLimits[i].ymax, sizeof(int));
|
||||||
|
}
|
||||||
|
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
|
if (ret == FAIL) {
|
||||||
|
dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH);
|
||||||
|
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
||||||
|
cprintf(RED, "Receiver %d returned error: %s", detId, mess);
|
||||||
|
}
|
||||||
disconnectData();
|
disconnectData();
|
||||||
}
|
}
|
||||||
if(ret==FAIL)
|
|
||||||
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,6 +143,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
|
/*! \page test
|
||||||
|
- <b>firmwaretest</b> performs the firmware test. Cannot set! Jungfrau only. Only get!
|
||||||
|
*/
|
||||||
|
descrToFuncMap[i].m_pFuncName="firmwaretest"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
|
||||||
|
++i;
|
||||||
|
|
||||||
/*! \page test
|
/*! \page test
|
||||||
- <b>reg [addr] [val]</b> ??? writes to an register \c addr with \c value in hexadecimal format.
|
- <b>reg [addr] [val]</b> ??? writes to an register \c addr with \c value in hexadecimal format.
|
||||||
*/
|
*/
|
||||||
@ -3706,7 +3713,14 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int d
|
|||||||
if (cmd=="bustest"){
|
if (cmd=="bustest"){
|
||||||
if (action==PUT_ACTION)
|
if (action==PUT_ACTION)
|
||||||
return string("cannot set ")+cmd;
|
return string("cannot set ")+cmd;
|
||||||
sprintf(answer,"0x%x",myDet->digitalTest(DETECTOR_BUS_TEST));
|
sprintf(answer,"%d",myDet->digitalTest(DETECTOR_BUS_TEST));
|
||||||
|
return string(answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (cmd=="firmwaretest"){
|
||||||
|
if (action==PUT_ACTION)
|
||||||
|
return string("cannot set ")+cmd;
|
||||||
|
sprintf(answer,"%d",myDet->digitalTest(DETECTOR_FIRMWARE_TEST));
|
||||||
return string(answer);
|
return string(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3716,7 +3730,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int d
|
|||||||
int ival=-1;
|
int ival=-1;
|
||||||
if (sscanf(args[1],"%d",&ival)) {
|
if (sscanf(args[1],"%d",&ival)) {
|
||||||
if((ival==0)||(ival==1)){
|
if((ival==0)||(ival==1)){
|
||||||
sprintf(answer,"0x%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival, detPos));
|
sprintf(answer,"%d",myDet->digitalTest(DIGITAL_BIT_TEST,ival, detPos));
|
||||||
return string(answer);
|
return string(answer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3737,6 +3751,7 @@ string slsDetectorCommand::helpDigiTest(int action) {
|
|||||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||||
os << "digibittest:i \t performs digital test of the module i. Returns 0 if succeeded, otherwise error mask.Gotthard only."<< std::endl;
|
os << "digibittest:i \t performs digital test of the module i. Returns 0 if succeeded, otherwise error mask.Gotthard only."<< std::endl;
|
||||||
os << "bustest \t performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes. Jungfrau only."<< std::endl;
|
os << "bustest \t performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes. Jungfrau only."<< std::endl;
|
||||||
|
os << "firmwaretest \t performs the firmware test. Jungfrau only." << std::endl;
|
||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
@ -365,8 +365,6 @@ public:
|
|||||||
detector IDs/versions
|
detector IDs/versions
|
||||||
*/
|
*/
|
||||||
enum idMode{
|
enum idMode{
|
||||||
MODULE_SERIAL_NUMBER, /**<return module serial number */
|
|
||||||
MODULE_FIRMWARE_VERSION, /**<return module firmware */
|
|
||||||
DETECTOR_SERIAL_NUMBER, /**<return detector system serial number */
|
DETECTOR_SERIAL_NUMBER, /**<return detector system serial number */
|
||||||
DETECTOR_FIRMWARE_VERSION, /**<return detector system firmware version */
|
DETECTOR_FIRMWARE_VERSION, /**<return detector system firmware version */
|
||||||
DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */
|
DETECTOR_SOFTWARE_VERSION, /**<return detector system software version */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user