mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
separated slsReceiverInterface from slsDetector
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@313 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
b52f9a8569
commit
4dcad48ecb
@ -3,13 +3,12 @@ CFLAGS= -DC_ONLY -fPIC
|
|||||||
|
|
||||||
DFLAGS= -DDACS_INT
|
DFLAGS= -DDACS_INT
|
||||||
|
|
||||||
INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis
|
INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface
|
||||||
|
|
||||||
#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
||||||
CC=g++
|
CC=g++
|
||||||
|
|
||||||
|
|
||||||
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp
|
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp
|
||||||
|
|
||||||
OBJS = $(SRC_CLNT:.cpp=.o)
|
OBJS = $(SRC_CLNT:.cpp=.o)
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("dacs %d of size %d sent\n",myMod->module, ts);
|
printf("dacs %d of size %d sent\n",myMod->module, ts);
|
||||||
for (idac=0; idac< nDacs; idac++)
|
for (idac=0; idac< nDacs; idac++)
|
||||||
printf("dac %d is %d\n",idac,myMod->dacs[idac]);
|
printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]);
|
||||||
#endif
|
#endif
|
||||||
ts+= sendDataOnly(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs);
|
ts+= sendDataOnly(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -482,7 +482,7 @@ int receiveModule(int file_des, sls_detector_module* myMod) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("dacs received\n");
|
printf("dacs received\n");
|
||||||
for (id=0; id<nDacs; id++)
|
for (id=0; id<nDacs; id++)
|
||||||
printf("dac %d val %d\n",id, myMod->dacs[id]);
|
printf("dac %d val %d\n",id, (int)myMod->dacs[id]);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -123,7 +123,8 @@ slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(),
|
|||||||
dacs(NULL),
|
dacs(NULL),
|
||||||
adcs(NULL),
|
adcs(NULL),
|
||||||
chipregs(NULL),
|
chipregs(NULL),
|
||||||
chanregs(NULL)
|
chanregs(NULL),
|
||||||
|
thisReceiver(NULL)
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -172,7 +173,8 @@ slsDetector::slsDetector(detectorType type, int id,multiSlsDetector *p): slsDete
|
|||||||
dacs(NULL),
|
dacs(NULL),
|
||||||
adcs(NULL),
|
adcs(NULL),
|
||||||
chipregs(NULL),
|
chipregs(NULL),
|
||||||
chanregs(NULL)
|
chanregs(NULL),
|
||||||
|
thisReceiver(NULL)
|
||||||
{
|
{
|
||||||
while (shmId<0) {
|
while (shmId<0) {
|
||||||
/**Initlializes shared memory \sa initSharedMemory
|
/**Initlializes shared memory \sa initSharedMemory
|
||||||
@ -224,7 +226,8 @@ slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : sl
|
|||||||
dacs(NULL),
|
dacs(NULL),
|
||||||
adcs(NULL),
|
adcs(NULL),
|
||||||
chipregs(NULL),
|
chipregs(NULL),
|
||||||
chanregs(NULL)
|
chanregs(NULL),
|
||||||
|
thisReceiver(NULL)
|
||||||
|
|
||||||
{
|
{
|
||||||
detectorType type=(detectorType)getDetectorType(name, cport);
|
detectorType type=(detectorType)getDetectorType(name, cport);
|
||||||
@ -672,6 +675,7 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
fileName=parentDet->fileName;
|
fileName=parentDet->fileName;
|
||||||
fileIndex=parentDet->fileIndex;
|
fileIndex=parentDet->fileIndex;
|
||||||
|
|
||||||
|
thisReceiver = new receiverInterface(dataSocket);
|
||||||
|
|
||||||
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
|
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
|
||||||
|
|
||||||
@ -5284,17 +5288,20 @@ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchroniza
|
|||||||
|
|
||||||
/*receiver*/
|
/*receiver*/
|
||||||
int slsDetector::setReceiverOnline(int off) {
|
int slsDetector::setReceiverOnline(int off) {
|
||||||
|
int prev = thisDetector->receiverOnlineFlag;
|
||||||
if (off!=GET_ONLINE_FLAG) {
|
if (off!=GET_ONLINE_FLAG) {
|
||||||
if(strcmp(thisDetector->receiverIP,"none")){
|
if(strcmp(thisDetector->receiverIP,"none")){
|
||||||
thisDetector->receiverOnlineFlag=off;
|
thisDetector->receiverOnlineFlag=off;
|
||||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG)
|
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||||
setReceiverTCPSocket();
|
setReceiverTCPSocket();
|
||||||
|
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG)
|
||||||
|
std::cout << "cannot connect to receiver" << endl;
|
||||||
}
|
}
|
||||||
//Since flag becomes offline if receiver not online.
|
|
||||||
//This ensures server to NOT send to receiver in the next command line comment
|
|
||||||
if((off==ONLINE_FLAG)&&(thisDetector->receiverOnlineFlag!=ONLINE_FLAG))
|
|
||||||
DetectorStopReceiver();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//To ensure detector knows, if receiver suddenly went down
|
||||||
|
if((prev==ONLINE_FLAG)&&(thisDetector->receiverOnlineFlag==OFFLINE_FLAG))
|
||||||
|
detectorSendToReceiver(false);
|
||||||
return thisDetector->receiverOnlineFlag;
|
return thisDetector->receiverOnlineFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5336,14 +5343,7 @@ string slsDetector::checkReceiverOnline() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
configure the socket communication and check that the receiver exists
|
|
||||||
enum communicationProtocol{
|
|
||||||
TCP,
|
|
||||||
UDP
|
|
||||||
}{};
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
int slsDetector::setReceiverTCPSocket(string const name, int const data_port){
|
int slsDetector::setReceiverTCPSocket(string const name, int const data_port){
|
||||||
|
|
||||||
@ -5405,6 +5405,7 @@ int slsDetector::setReceiverTCPSocket(string const name, int const data_port){
|
|||||||
std::cout<< "offline!" << std::endl;
|
std::cout<< "offline!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
thisReceiver->setSocket(dataSocket);
|
||||||
return retval;
|
return retval;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5416,7 +5417,6 @@ int slsDetector::setReceiverTCPSocket(string const name, int const data_port){
|
|||||||
string slsDetector::setFilePath(string s) {
|
string slsDetector::setFilePath(string s) {
|
||||||
int fnum = F_SET_FILE_PATH;
|
int fnum = F_SET_FILE_PATH;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char mess[100];
|
|
||||||
char arg[MAX_STR_LENGTH];
|
char arg[MAX_STR_LENGTH];
|
||||||
char retval[MAX_STR_LENGTH] = "";
|
char retval[MAX_STR_LENGTH] = "";
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -5430,30 +5430,17 @@ string slsDetector::setFilePath(string s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
strcpy(arg,s.c_str());
|
strcpy(arg,s.c_str());
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Sending file path to receiver " << arg << std::endl;
|
std::cout << "Sending file path to receiver " << arg << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->sendString(fnum,retval,arg);
|
||||||
if (dataSocket->Connect()>=0) {
|
if(ret!=FAIL)
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
fileIO::setFilePath(string(retval));
|
||||||
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret==FAIL){
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
|
||||||
fileIO::setFilePath(s);
|
|
||||||
}
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
updateReceiver();
|
||||||
}
|
}
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
|
|
||||||
return fileIO::getFilePath();
|
return fileIO::getFilePath();
|
||||||
}
|
}
|
||||||
@ -5463,7 +5450,6 @@ string slsDetector::setFilePath(string s) {
|
|||||||
string slsDetector::setFileName(string s) {
|
string slsDetector::setFileName(string s) {
|
||||||
int fnum=F_SET_FILE_NAME;
|
int fnum=F_SET_FILE_NAME;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char mess[100];
|
|
||||||
char arg[MAX_STR_LENGTH];
|
char arg[MAX_STR_LENGTH];
|
||||||
char retval[MAX_STR_LENGTH]="";
|
char retval[MAX_STR_LENGTH]="";
|
||||||
|
|
||||||
@ -5474,33 +5460,21 @@ string slsDetector::setFileName(string s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||||
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
|
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
strcpy(arg,s.c_str());
|
strcpy(arg,s.c_str());
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Sending file name to receiver " << arg << std::endl;
|
std::cout << "Sending file name to receiver " << arg << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->sendString(fnum,retval,arg);
|
||||||
if (dataSocket->Connect()>=0) {
|
if(ret!=FAIL){
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret==FAIL){
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
dataSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH);
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Complete file prefix from receiver: " << retval << std::endl;
|
std::cout << "Complete file prefix from receiver: " << retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
fileIO::setFileName(parentDet->getNameFromReceiverFilePrefix(string(retval)));
|
fileIO::setFileName(parentDet->getNameFromReceiverFilePrefix(string(retval)));
|
||||||
}
|
}
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
updateReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileIO::getFileName();
|
return fileIO::getFileName();
|
||||||
@ -5510,47 +5484,28 @@ string slsDetector::setFileName(string s) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::setFileIndex(int i) {
|
int slsDetector::setFileIndex(int i) {
|
||||||
int fnum=F_SET_FILE_INDEX;
|
int fnum=F_SET_FILE_INDEX;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int retval=-1;
|
int retval=-1;
|
||||||
int arg = i;
|
int arg = i;
|
||||||
char mess[100];
|
|
||||||
|
|
||||||
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
||||||
if(i>=0)
|
if(i>=0)
|
||||||
fileIO::setFileIndex(i);
|
fileIO::setFileIndex(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Sending file dir to receiver " << arg << std::endl;
|
std::cout << "Sending file index to receiver " << arg << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||||
if (dataSocket->Connect()>=0) {
|
if(ret!=FAIL)
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
dataSocket->SendDataOnly(&arg,sizeof(arg));
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret==FAIL){
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
|
||||||
fileIO::setFileIndex(retval);
|
fileIO::setFileIndex(retval);
|
||||||
}
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
updateReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
|
|
||||||
return fileIO::getFileIndex();
|
return fileIO::getFileIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5560,55 +5515,49 @@ int slsDetector::setFileIndex(int i) {
|
|||||||
int slsDetector::startReceiver(){
|
int slsDetector::startReceiver(){
|
||||||
int fnum=F_START_RECEIVER;
|
int fnum=F_START_RECEIVER;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char mess[100];
|
|
||||||
|
|
||||||
|
|
||||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Starting Receiver " << std::endl;
|
std::cout << "Starting Receiver " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->executeFunction(fnum);
|
||||||
if (dataSocket->Connect()>=0) {
|
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret==FAIL){
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
ret=updateReceiver();
|
ret=updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
|
|
||||||
|
|
||||||
//configuremac for gotthard
|
//configuremac for gotthard
|
||||||
if(ret==OK)
|
if(ret==OK)
|
||||||
if(thisDetector->myDetectorType==GOTTHARD)
|
if(thisDetector->myDetectorType==GOTTHARD)
|
||||||
ret=configureMAC();
|
ret=configureMAC();
|
||||||
|
|
||||||
if(ret==OK){
|
if(ret==OK)
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
ret=detectorSendToReceiver(true);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::stopReceiver(){
|
||||||
|
int fnum=F_STOP_RECEIVER;
|
||||||
|
int ret = FAIL;
|
||||||
|
|
||||||
|
detectorSendToReceiver(false);
|
||||||
|
|
||||||
|
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Setting detector to send packets via receiver " << std::endl;
|
std::cout << "Stopping Receiver " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (controlSocket) {
|
ret=thisReceiver->executeFunction(fnum);
|
||||||
if (controlSocket->Connect()>=0) {
|
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret==FAIL){
|
|
||||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
controlSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
ret=updateDetector();
|
ret=updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else
|
//increment file index
|
||||||
std::cout << "cannot connect to detector" << endl;
|
if(ret==OK){
|
||||||
|
fileIO::setFileIndex(fileIO::getFileIndex()+1);
|
||||||
|
setFileIndex(fileIO::getFileIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -5616,10 +5565,13 @@ int slsDetector::startReceiver(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::DetectorStopReceiver(){
|
int slsDetector::detectorSendToReceiver(bool set){
|
||||||
int fnum=F_STOP_RECEIVER;
|
int fnum;
|
||||||
|
if(set) fnum=F_START_RECEIVER;
|
||||||
|
else fnum=F_STOP_RECEIVER;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char mess[100];
|
char mess[100];
|
||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Setting detector to send packets via client " << std::endl;
|
std::cout << "Setting detector to send packets via client " << std::endl;
|
||||||
@ -5645,42 +5597,6 @@ int slsDetector::DetectorStopReceiver(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::stopReceiver(){
|
|
||||||
int fnum=F_STOP_RECEIVER;
|
|
||||||
int ret = FAIL;
|
|
||||||
char mess[100];
|
|
||||||
|
|
||||||
DetectorStopReceiver();
|
|
||||||
|
|
||||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "Stopping Receiver " << std::endl;
|
|
||||||
#endif
|
|
||||||
if (dataSocket) {
|
|
||||||
if (dataSocket->Connect()>=0) {
|
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret==FAIL){
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if (ret==FORCE_UPDATE)
|
|
||||||
ret=updateReceiver();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
|
|
||||||
//increment file index
|
|
||||||
if(ret==OK){
|
|
||||||
fileIO::setFileIndex(fileIO::getFileIndex()+1);
|
|
||||||
setFileIndex(fileIO::getFileIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -5688,31 +5604,21 @@ int slsDetector::stopReceiver(){
|
|||||||
slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){
|
slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){
|
||||||
int fnum=F_GET_RECEIVER_STATUS;
|
int fnum=F_GET_RECEIVER_STATUS;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char mess[100];
|
int retval=-1;
|
||||||
runStatus retval=ERROR;
|
runStatus s=ERROR;
|
||||||
|
|
||||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Getting Receiver Status" << std::endl;
|
std::cout << "Getting Receiver Status" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->getInt(fnum,retval);
|
||||||
if (dataSocket->Connect()>=0) {
|
if(retval!=-1)
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
s=(runStatus)retval;
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret==FAIL){
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}else
|
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
|
||||||
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
ret=updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else
|
return s;
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5721,30 +5627,17 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){
|
|||||||
int slsDetector::getFramesCaughtByReciver(){
|
int slsDetector::getFramesCaughtByReciver(){
|
||||||
int fnum=F_GET_FRAMES_CAUGHT;
|
int fnum=F_GET_FRAMES_CAUGHT;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char mess[100];
|
|
||||||
int retval=-1;
|
int retval=-1;
|
||||||
|
|
||||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Getting Frames Caught by Receiver " << std::endl;
|
std::cout << "Getting Frames Caught by Receiver " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->getInt(fnum,retval);
|
||||||
if (dataSocket->Connect()>=0) {
|
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret!=FAIL)
|
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
|
||||||
else{
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
ret=updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5755,7 +5648,6 @@ int slsDetector::lockReceiver(int lock){
|
|||||||
int fnum=F_LOCK_RECEIVER;
|
int fnum=F_LOCK_RECEIVER;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int retval=-1;
|
int retval=-1;
|
||||||
char mess[100];
|
|
||||||
int arg=lock;
|
int arg=lock;
|
||||||
|
|
||||||
|
|
||||||
@ -5763,25 +5655,10 @@ int slsDetector::lockReceiver(int lock){
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Locking or Unlocking Receiver " << std::endl;
|
std::cout << "Locking or Unlocking Receiver " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||||
if (dataSocket->Connect()>=0) {
|
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
dataSocket->SendDataOnly(&arg,sizeof(arg));
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret!=FAIL)
|
|
||||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
|
||||||
else{
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -5795,30 +5672,15 @@ string slsDetector::getReceiverLastClientIP(){
|
|||||||
int fnum=F_GET_LAST_CLIENT_IP;
|
int fnum=F_GET_LAST_CLIENT_IP;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char retval[INET_ADDRSTRLEN]="";
|
char retval[INET_ADDRSTRLEN]="";
|
||||||
char mess[100];
|
|
||||||
|
|
||||||
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
|
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "Geting Last Client IP connected to Receiver " << std::endl;
|
std::cout << "Geting Last Client IP connected to Receiver " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (dataSocket) {
|
ret=thisReceiver->getLastClientIP(fnum,retval);
|
||||||
if (dataSocket->Connect()>=0) {
|
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
|
||||||
if (ret!=FAIL)
|
|
||||||
dataSocket->ReceiveDataOnly(retval,sizeof(retval));
|
|
||||||
else{
|
|
||||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
|
||||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSocket->Disconnect();
|
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else
|
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
|
||||||
|
|
||||||
return string(retval);
|
return string(retval);
|
||||||
}
|
}
|
||||||
@ -5837,7 +5699,6 @@ int slsDetector::updateReceiverNoWait() {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Updating receiver last modified by " << lastClientIP << std::endl;
|
cout << "Updating receiver last modified by " << lastClientIP << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
|
n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
|
||||||
fileIO::setFileIndex(ind);
|
fileIO::setFileIndex(ind);
|
||||||
n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
|
n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include "angleConversionConstant.h";
|
#include "angleConversionConstant.h";
|
||||||
|
|
||||||
|
#include "receiverInterface.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1437,7 +1439,10 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
*/
|
*/
|
||||||
int stopReceiver();
|
int stopReceiver();
|
||||||
|
|
||||||
int DetectorStopReceiver();
|
/** Sets(false) or Resets(true) the CPU bit in detector
|
||||||
|
\returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int detectorSendToReceiver(bool set);
|
||||||
|
|
||||||
/** gets the status of the listening mode of receiver
|
/** gets the status of the listening mode of receiver
|
||||||
\returns status
|
\returns status
|
||||||
@ -1488,7 +1493,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* parent multi detector
|
||||||
* */
|
* */
|
||||||
|
|
||||||
multiSlsDetector *parentDet;
|
multiSlsDetector *parentDet;
|
||||||
@ -1534,6 +1539,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
/** pointer to channal registers */
|
/** pointer to channal registers */
|
||||||
int *chanregs;
|
int *chanregs;
|
||||||
|
|
||||||
|
receiverInterface *thisReceiver;
|
||||||
|
|
||||||
/** Initializes the shared memory
|
/** Initializes the shared memory
|
||||||
\param type is needed to define the size of the shared memory
|
\param type is needed to define the size of the shared memory
|
||||||
\param id is the detector id needed to define the shared memory id
|
\param id is the detector id needed to define the shared memory id
|
||||||
|
@ -774,7 +774,7 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
|
|||||||
|
|
||||||
|
|
||||||
myDet->setOnline(ONLINE_FLAG);
|
myDet->setOnline(ONLINE_FLAG);
|
||||||
bool receiver=myDet->setReceiverOnline();
|
bool receiver=(myDet->setReceiverOnline()==ONLINE_FLAG);
|
||||||
|
|
||||||
if(receiver)
|
if(receiver)
|
||||||
if(myDet->startReceiver()==OK)
|
if(myDet->startReceiver()==OK)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user