mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +02:00
configuremac after starting receiver, also telling the server to send packets to receiver or cpu with receiver start and receiver stop
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@290 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
e5a7d834db
commit
29a540818f
@ -705,6 +705,33 @@ int setContinousReadOut(int d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int startReceiver(int start) {
|
||||||
|
u_int32_t addr=CONFIG_REG;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
if(start)
|
||||||
|
printf("Setting up detector to send to Receiver\n");
|
||||||
|
else
|
||||||
|
printf("Setting up detector to send to CPU\n");
|
||||||
|
#endif
|
||||||
|
int reg=bus_r(addr);
|
||||||
|
//for start recever, write 0 and for stop, write 1
|
||||||
|
if (!start)
|
||||||
|
bus_w(CONFIG_REG,reg|CPU_OR_RECEIVER_BIT);
|
||||||
|
else
|
||||||
|
bus_w(CONFIG_REG,reg&(~CPU_OR_RECEIVER_BIT));
|
||||||
|
|
||||||
|
reg=bus_r(addr);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Config Reg %x\n", reg);
|
||||||
|
#endif
|
||||||
|
if (start && (!(reg&CPU_OR_RECEIVER_BIT)))
|
||||||
|
return OK;
|
||||||
|
if(!start && (reg&CPU_OR_RECEIVER_BIT))
|
||||||
|
return OK;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int64_t getDetectorNumber() {
|
u_int64_t getDetectorNumber() {
|
||||||
char output[255],mac[255]="";
|
char output[255],mac[255]="";
|
||||||
u_int64_t res=0;
|
u_int64_t res=0;
|
||||||
|
@ -53,6 +53,7 @@ int setTiming(int t);
|
|||||||
int setConfigurationRegister(int d);
|
int setConfigurationRegister(int d);
|
||||||
int setToT(int d);
|
int setToT(int d);
|
||||||
int setContinousReadOut(int d);
|
int setContinousReadOut(int d);
|
||||||
|
int startReceiver(int d);
|
||||||
|
|
||||||
int setDACRegister(int idac, int val, int imod);
|
int setDACRegister(int idac, int val, int imod);
|
||||||
|
|
||||||
|
@ -181,7 +181,8 @@
|
|||||||
/* for config register *///not really used yet
|
/* for config register *///not really used yet
|
||||||
#define TOT_ENABLE_BIT 0x00000002
|
#define TOT_ENABLE_BIT 0x00000002
|
||||||
#define TIMED_GATE_BIT 0x00000004
|
#define TIMED_GATE_BIT 0x00000004
|
||||||
#define CONT_RO_ENABLE_BIT 0x00080000
|
#define CONT_RO_ENABLE_BIT 0x00080000
|
||||||
|
#define CPU_OR_RECEIVER_BIT 0x00001000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,8 @@ int function_table() {
|
|||||||
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
|
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
|
||||||
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
|
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
|
||||||
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
|
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
|
||||||
|
flist[F_START_RECEIVER]=&start_receiver;
|
||||||
|
flist[F_STOP_RECEIVER]=&stop_receiver;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2788,18 +2790,19 @@ int configure_mac(int file_des) {
|
|||||||
if (imod<0)
|
if (imod<0)
|
||||||
imod=ALLMOD;
|
imod=ALLMOD;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("Configuring MAC of module %d\n", imod);
|
printf("Configuring MAC of module %d\n", imod);
|
||||||
#endif
|
//#endif
|
||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);
|
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);
|
||||||
if(retval==-1) ret=FAIL;
|
if(retval==-1)
|
||||||
|
ret=FAIL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("Configured MAC with retval %d\n", retval);
|
printf("Configured MAC with retval %d\n", retval);
|
||||||
#endif
|
//#endif
|
||||||
if (ret==FAIL) {
|
if (ret==FAIL) {
|
||||||
printf("configuring MAC of mod %d failed\n", imod);
|
printf("configuring MAC of mod %d failed\n", imod);
|
||||||
}
|
}
|
||||||
@ -3081,3 +3084,72 @@ int reset_counter_block(int file_des) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int start_receiver(int file_des) {
|
||||||
|
int ret=OK;
|
||||||
|
int n=0;
|
||||||
|
strcpy(mess,"Could not start receiver\n");
|
||||||
|
|
||||||
|
/* execute action if the arguments correctly arrived*/
|
||||||
|
#ifdef MCB_FUNCS
|
||||||
|
if (lockStatus==1 && differentClients==1){//necessary???
|
||||||
|
sprintf(mess,"Receiver locked by %s\n", lastClientIP);
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = startReceiver(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
if(ret==OK && differentClients){
|
||||||
|
printf("Force update\n");
|
||||||
|
ret=FORCE_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send answer */
|
||||||
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
|
if(ret==FAIL)
|
||||||
|
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
/*return ok/fail*/
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int stop_receiver(int file_des) {
|
||||||
|
int ret=OK;
|
||||||
|
int n=0;
|
||||||
|
|
||||||
|
strcpy(mess,"Could not stop receiver\n");
|
||||||
|
|
||||||
|
/* execute action if the arguments correctly arrived*/
|
||||||
|
#ifdef MCB_FUNCS
|
||||||
|
if (lockStatus==1 && differentClients==1){//necessary???
|
||||||
|
sprintf(mess,"Receiver locked by %s\n", lastClientIP);
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret=startReceiver(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
if(ret==OK && differentClients){
|
||||||
|
printf("Force update\n");
|
||||||
|
ret=FORCE_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send answer */
|
||||||
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
|
if(ret==FAIL)
|
||||||
|
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
/*return ok/fail*/
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,4 +81,7 @@ int load_image(int);
|
|||||||
int read_counter_block(int);
|
int read_counter_block(int);
|
||||||
int reset_counter_block(int);
|
int reset_counter_block(int);
|
||||||
|
|
||||||
|
int start_receiver(int);
|
||||||
|
int stop_receiver(int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5543,10 +5543,35 @@ int slsDetector::startReceiver(){
|
|||||||
}
|
}
|
||||||
dataSocket->Disconnect();
|
dataSocket->Disconnect();
|
||||||
if (ret==FORCE_UPDATE)
|
if (ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
ret=updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//configuremac for gotthard
|
||||||
|
if(ret==OK)
|
||||||
|
if(thisDetector->myDetectorType==GOTTHARD)
|
||||||
|
ret=configureMAC();
|
||||||
|
|
||||||
|
//tell the server to send to receiver and not CPU
|
||||||
|
if(ret==OK){
|
||||||
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
|
if (controlSocket) {
|
||||||
|
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)
|
||||||
|
ret=updateDetector();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5574,10 +5599,30 @@ int slsDetector::stopReceiver(){
|
|||||||
|
|
||||||
dataSocket->Disconnect();
|
dataSocket->Disconnect();
|
||||||
if (ret==FORCE_UPDATE)
|
if (ret==FORCE_UPDATE)
|
||||||
updateReceiver();
|
ret=updateReceiver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//tell the server to NOT send to receiver and instead to CPU
|
||||||
|
if(ret==OK){
|
||||||
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
|
if (controlSocket) {
|
||||||
|
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)
|
||||||
|
ret=updateDetector();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3566,19 +3566,26 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
|
|||||||
if(cmd=="receiver"){
|
if(cmd=="receiver"){
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
if(!strcasecmp(args[1],"start")){
|
if(!strcasecmp(args[1],"start")){
|
||||||
//update receiver index
|
if(myDet->getReceiverStatus()==IDLE){
|
||||||
if(myDet->setReceiverFileIndex(myDet->getFileIndex())==-1)
|
//update receiver index
|
||||||
return string("could not set receiver file index");
|
if(myDet->setReceiverFileIndex(myDet->getFileIndex())==-1)
|
||||||
myDet->startReceiver();
|
return string("could not set receiver file index");
|
||||||
|
//to configure the server
|
||||||
|
myDet->setOnline(ONLINE_FLAG);
|
||||||
|
myDet->startReceiver();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(!strcasecmp(args[1],"stop")){
|
else if(!strcasecmp(args[1],"stop")){
|
||||||
if(myDet->stopReceiver()!=FAIL){
|
if(myDet->getReceiverStatus()==RUNNING){
|
||||||
//update index
|
myDet->setOnline(ONLINE_FLAG);
|
||||||
int index = myDet->setReceiverFileIndex();
|
if(myDet->stopReceiver()!=FAIL){
|
||||||
if(index==-1)
|
//update index
|
||||||
return string("could not get receiver file index");
|
int index = myDet->setReceiverFileIndex();
|
||||||
myDet->setFileIndex(index);
|
if(index==-1)
|
||||||
|
return string("could not get receiver file index");
|
||||||
|
myDet->setFileIndex(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
return helpReceiver(narg, args, action);
|
return helpReceiver(narg, args, action);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user