mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 01:50:40 +02:00
deactivate for eiger
This commit is contained in:
parent
ffaf62176f
commit
c0db1a89a8
@ -32,6 +32,7 @@ using namespace std;
|
||||
#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL
|
||||
#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0020000000000000ULL
|
||||
#define DETECTOR_TEN_GIGA 0x0010000000000000ULL
|
||||
#define DETECTOR_ACTIVATE 0x0008000000000000ULL
|
||||
|
||||
// 0xFFFFFFFF00000000ULL
|
||||
|
||||
@ -113,6 +114,10 @@ public:
|
||||
if(slsErrorMask&DETECTOR_TEN_GIGA)
|
||||
retval.append("Could not enable/disable 10GbE in the detector.\n");
|
||||
|
||||
if(slsErrorMask&DETECTOR_ACTIVATE)
|
||||
retval.append("Could not activate/deactivate detector\n");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
//#include <stdint.h>
|
||||
#include "sls_receiver_defs.h"
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION 14
|
||||
|
||||
/** default maximum string length */
|
||||
#define MAX_SCAN_STEPS 2000
|
||||
/** maxmimum number of modules per controller*/
|
||||
|
@ -103,6 +103,8 @@ enum {
|
||||
F_SET_RATE_CORRECT, /** < set/reset rate correction tau */
|
||||
F_GET_RATE_CORRECT, /** < get rate correction tau */
|
||||
|
||||
F_ACTIVATE /** < activate/deactivate readout */
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
};
|
||||
|
@ -169,6 +169,128 @@ void Beb_GetModuleCopnfiguration(int* master, int* top){
|
||||
}
|
||||
}
|
||||
|
||||
/* do not work at the moment */
|
||||
int Beb_SetMasterViaSoftware(){
|
||||
//mapping new memory
|
||||
u_int32_t baseaddr, value = 0, ret = 1;
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(XPAR_PLB_GPIO_SYS_BASEADDR,&baseaddr);
|
||||
if(fd < 0)
|
||||
cprintf(BG_RED,"Set Master FAIL\n");
|
||||
else{
|
||||
value = Beb_Read32(baseaddr, MASTERCONFIG_OFFSET);
|
||||
value|=MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(baseaddr, MASTERCONFIG_OFFSET,value);
|
||||
if(newval!=value)
|
||||
cprintf(BG_RED,"Could not set Master via Software\n");
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
//close file pointer
|
||||
if(fd > 0)
|
||||
Beb_close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* do not work at the moment */
|
||||
int Beb_SetSlaveViaSoftware(){
|
||||
//mapping new memory
|
||||
u_int32_t baseaddr, value = 0, ret = 1;
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(XPAR_PLB_GPIO_SYS_BASEADDR,&baseaddr);
|
||||
if(fd < 0)
|
||||
cprintf(BG_RED,"Set Slave FAIL\n");
|
||||
else{
|
||||
value = Beb_Read32(baseaddr, MASTERCONFIG_OFFSET);
|
||||
value&=~MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(baseaddr, MASTERCONFIG_OFFSET,value);
|
||||
if(newval!=value)
|
||||
cprintf(BG_RED,"Could not set Slave via Software\n");
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
//close file pointer
|
||||
if(fd > 0)
|
||||
Beb_close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Beb_Activate(int enable){
|
||||
//mapping new memory
|
||||
u_int32_t baseaddr, value = 0, ret = -1;
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(XPAR_PLB_GPIO_SYS_BASEADDR,&baseaddr);
|
||||
if(fd < 0)
|
||||
cprintf(BG_RED,"Deactivate FAIL\n");
|
||||
else{
|
||||
if(enable > -1){
|
||||
value = Beb_Read32(baseaddr, MASTERCONFIG_OFFSET);
|
||||
printf("Deactivate register value before:%d\n",value);
|
||||
if(enable)
|
||||
value&=~DEACTIVATE_BIT;
|
||||
else
|
||||
value|=DEACTIVATE_BIT;
|
||||
|
||||
int newval = Beb_Write32(baseaddr, MASTERCONFIG_OFFSET,value);
|
||||
if(newval!=value){
|
||||
if(enable)
|
||||
cprintf(BG_RED,"Could not activate via Software\n");
|
||||
else
|
||||
cprintf(BG_RED,"Could not deactivate via Software\n");
|
||||
}
|
||||
}
|
||||
|
||||
value = Beb_Read32(baseaddr, MASTERCONFIG_OFFSET);
|
||||
if(value&DEACTIVATE_BIT) ret = 0;
|
||||
else ret = 1;
|
||||
if(enable == -1){
|
||||
if(ret)
|
||||
cprintf(BLUE,"Detector is active. Register value:%d\n", value);
|
||||
else
|
||||
cprintf(BG_RED,"Detector is deactivated! Register value:%d\n", value);
|
||||
}
|
||||
|
||||
}
|
||||
//close file pointer
|
||||
if(fd > 0)
|
||||
Beb_close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Beb_ResetToHardwareSettings(){
|
||||
//mapping new memory
|
||||
u_int32_t baseaddr, value = 0, ret = 1;
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(XPAR_PLB_GPIO_SYS_BASEADDR,&baseaddr);
|
||||
if(fd < 0)
|
||||
cprintf(BG_RED,"Reset to Hardware Settings FAIL\n");
|
||||
else{
|
||||
value = Beb_Write32(baseaddr, MASTERCONFIG_OFFSET,0);
|
||||
if(value)
|
||||
cprintf(BG_RED,"Could not reset to hardware settings\n");
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
//close file pointer
|
||||
if(fd > 0)
|
||||
Beb_close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
u_int32_t Beb_GetFirmwareRevision(){
|
||||
//mapping new memory
|
||||
@ -199,7 +321,7 @@ u_int32_t Beb_GetFirmwareSoftwareAPIVersion(){
|
||||
//open file pointer
|
||||
int fd = Beb_open(XPAR_VERSION,&baseaddr);
|
||||
if(fd < 0)
|
||||
cprintf(BG_RED,"Firmware Revision Read FAIL\n");
|
||||
cprintf(BG_RED,"Firmware Software API Version Read FAIL\n");
|
||||
else{
|
||||
value = Beb_Read32(baseaddr, FIRMWARESOFTWARE_API_OFFSET);
|
||||
if(!value)
|
||||
|
@ -48,6 +48,10 @@ struct BebInfo{
|
||||
|
||||
|
||||
void Beb_GetModuleCopnfiguration(int* master, int* top);
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
int Beb_Activate(int enable);
|
||||
int Beb_ResetToHardwareSettings();
|
||||
u_int32_t Beb_GetFirmwareRevision();
|
||||
u_int32_t Beb_GetFirmwareSoftwareAPIVersion();
|
||||
void Beb_ResetFrameNumber();
|
||||
|
@ -116,6 +116,11 @@
|
||||
#define MASTER_BIT_MASK 0x200
|
||||
// Master Slave Top Bottom Definition
|
||||
#define MODULE_CONFIGURATION_MASK 0x84
|
||||
//Software Configuration
|
||||
#define MASTERCONFIG_OFFSET 0x160 //0x20 * 11 (P11)
|
||||
#define MASTER_BIT 0x1
|
||||
#define OVERWRITE_HARDWARE_BIT 0x2
|
||||
#define DEACTIVATE_BIT 0x4
|
||||
|
||||
//command memory
|
||||
#define LEFT_OFFSET 0x0
|
||||
|
@ -175,6 +175,7 @@ int initDetector(){
|
||||
printf("mac read from detector: %llx\n",getDetectorMAC());
|
||||
printf("ip read from detector: %x\n",getDetectorIP());
|
||||
|
||||
|
||||
printf("\n");
|
||||
return 1;
|
||||
}
|
||||
@ -1306,4 +1307,10 @@ int getBebFPGATemp()
|
||||
return Beb_GetBebFPGATemp();
|
||||
}
|
||||
|
||||
|
||||
int activate(int enable){
|
||||
return Beb_Activate(enable);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define FEB_PORT 43210
|
||||
#define BEB_PORT 43212
|
||||
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION 14
|
||||
|
||||
#define FIRMWAREREV 0xcaba //temporary should be in firmware
|
||||
|
||||
|
@ -1064,6 +1064,25 @@ string multiSlsDetector::checkOnline() {
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::activate(int const enable){
|
||||
int i;
|
||||
int64_t ret1=-100, ret;
|
||||
|
||||
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->activate(enable);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::exists() {
|
||||
|
@ -394,6 +394,11 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
string checkOnline();
|
||||
|
||||
/** @short activates the detector (detector specific)
|
||||
\param enable can be: -1 returns wether the detector is in active (1) or inactive (0) state
|
||||
\returns 0 (inactive) or 1 (active)
|
||||
*/
|
||||
int activate(int const enable=GET_ONLINE_FLAG);
|
||||
|
||||
/**
|
||||
\returns 1 if the detector structure has already be initlialized with the given id and belongs to this multiDetector instance, 0 otherwise */
|
||||
|
@ -1257,6 +1257,48 @@ string slsDetector::checkOnline() {
|
||||
|
||||
|
||||
|
||||
int slsDetector::activate(int const enable){
|
||||
int fnum = F_ACTIVATE;
|
||||
int retval = -1;
|
||||
int arg = enable;
|
||||
char mess[1000]="";
|
||||
int ret = OK;
|
||||
#ifdef VERBOSE
|
||||
if(!enable)
|
||||
std::cout<< "Deactivating Detector" << std::endl;
|
||||
else if(enable == -1)
|
||||
std::cout<< "Getting Detector activate mode" << std::endl;
|
||||
else
|
||||
std::cout<< "Activating Detector" << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
|
||||
} else {
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
}
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if(retval)
|
||||
std::cout << "Detector Activated" << std::endl;
|
||||
else
|
||||
std::cout << "Detector Deactivated" << std::endl;
|
||||
#endif
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
configure the socket communication and check that the server exists
|
||||
enum communicationProtocol{
|
||||
|
@ -318,6 +318,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
|
||||
string checkOnline();
|
||||
|
||||
/** @short activates the detector (detector specific)
|
||||
\param enable can be: -1 returns wether the detector is in active (1) or inactive (0) state
|
||||
\returns 0 (inactive) or 1 (active)
|
||||
*/
|
||||
int activate(int const enable=GET_ONLINE_FLAG);
|
||||
|
||||
|
||||
/** returns if the detector already existed
|
||||
\returns 1 if the detector structure has already be initlialized, 0 otherwise */
|
||||
int exists() {return thisDetector->alreadyExisting;};
|
||||
|
@ -394,6 +394,14 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
\returns 0 (offline) or 1 (online)
|
||||
*/
|
||||
virtual int setOnline(int const online=-1)=0;
|
||||
|
||||
/** @short activates the detector (detector specific)
|
||||
\param enable can be: -1 returns wether the detector is in active (1) or inactive (0) state
|
||||
\returns 0 (inactive) or 1 (active)
|
||||
*/
|
||||
virtual int activate(int const enable=GET_ONLINE_FLAG)=0;
|
||||
|
||||
|
||||
/**
|
||||
@short set detector settings
|
||||
\param isettings settings index (-1 gets)
|
||||
|
@ -207,6 +207,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="activate"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="enablefwrite"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite;
|
||||
i++;
|
||||
@ -2885,6 +2889,17 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
|
||||
else
|
||||
strcat(ans," :Not online");
|
||||
}
|
||||
else if(cmd=="activate"){
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
if (action==PUT_ACTION) {
|
||||
if (!sscanf(args[1],"%d",&ival))
|
||||
return string("Could not scan activate mode ")+string(args[1]);
|
||||
/* if(dynamic_cast<slsDetector*>(myDet) != NULL)
|
||||
return string("Can only set it from the multiDetector mode");*/
|
||||
myDet->activate(ival);
|
||||
}
|
||||
sprintf(ans,"%d",myDet->activate());
|
||||
}
|
||||
else if(cmd=="r_online"){
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&ival))
|
||||
|
@ -153,6 +153,7 @@ void setExternalGating(int enable[]);
|
||||
void setAllTrimbits(int val);
|
||||
int getAllTrimbits();
|
||||
int getBebFPGATemp();
|
||||
int activate(int enable);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -204,6 +204,7 @@ int function_table() {
|
||||
flist[F_PULSE_CHIP]=&pulse_chip;
|
||||
flist[F_SET_RATE_CORRECT]=&set_rate_correct;
|
||||
flist[F_GET_RATE_CORRECT]=&get_rate_correct;
|
||||
flist[F_ACTIVATE]=&set_activate;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -4021,3 +4022,63 @@ int get_rate_correct(int file_des) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int set_activate(int file_des) {
|
||||
|
||||
int arg, n;
|
||||
int ret=OK,ret1=OK;
|
||||
int retval;
|
||||
|
||||
sprintf(mess,"can't activate/deactivate detector\n");
|
||||
|
||||
n = receiveData(file_des,&arg,sizeof(arg),INT32);
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Setting activate mode of detector to %d\n",arg);
|
||||
#endif
|
||||
if (ret==OK) {
|
||||
|
||||
if (differentClients==1 && lockStatus==1 && arg>=0) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else {
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
#ifdef EIGERD
|
||||
retval=activate(arg);
|
||||
#else
|
||||
sprintf(mess,"Deactivate/Activate Not implemented for this detector\n");
|
||||
ret=FAIL;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
if (ret==OK){
|
||||
if ((retval!=arg) && (arg!=-1)) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Could not set activate mode to %d, is set to %d\n",arg, retval);
|
||||
}else if (differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ret could be swapped during sendData
|
||||
ret1 = ret;
|
||||
n = sendData(file_des,&ret1,sizeof(ret),INT32);
|
||||
if (ret==FAIL) {
|
||||
n = sendData(file_des,mess,sizeof(mess),OTHER);
|
||||
} else {
|
||||
n = sendData(file_des,&retval,sizeof(retval),INT32);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -89,5 +89,6 @@ int pulse_pixel_and_move(int);
|
||||
int pulse_chip(int);
|
||||
int set_rate_correct(int);
|
||||
int get_rate_correct(int);
|
||||
int set_activate(int);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user