mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
client gives now 3d positions of detector to be configured in udp header, only in jungfrau firmware till now
This commit is contained in:
parent
5a8f30fee8
commit
663fd557ff
Binary file not shown.
BIN
slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.9
Executable file
BIN
slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.9
Executable file
Binary file not shown.
@ -1043,7 +1043,25 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
}
|
||||
|
||||
|
||||
int setDetectorPosition(int pos[]) {
|
||||
int ret = OK;
|
||||
|
||||
bus_w(COORD_0, bus_r(COORD_0) | ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK));
|
||||
if ((bus_r(COORD_0) & COORD_0_X_MSK) != ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK))
|
||||
ret = FAIL;
|
||||
|
||||
bus_w(COORD_0, bus_r(COORD_0) | ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK));
|
||||
if ((bus_r(COORD_0) & COORD_0_Y_MSK) != ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK))
|
||||
ret = FAIL;
|
||||
|
||||
bus_w(COORD_1, bus_r(COORD_1) | ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK));
|
||||
if ((bus_r(COORD_1) & COORD_0_Z_MSK) != ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK))
|
||||
ret = FAIL;
|
||||
|
||||
if (ret == OK)
|
||||
printf("Position set to [%d, %d, %d]\n", pos[0], pos[1], pos[2]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -116,6 +116,8 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
thisMultiDetector->onlineFlag = ONLINE_FLAG;
|
||||
thisMultiDetector->receiverOnlineFlag = OFFLINE_FLAG;
|
||||
thisMultiDetector->numberOfDetectors=0;
|
||||
thisMultiDetector->numberOfDetector[X]=0;
|
||||
thisMultiDetector->numberOfDetector[Y]=0;
|
||||
for (int id=0; id<MAXDET; ++id) {
|
||||
thisMultiDetector->detectorIds[id]=-1;
|
||||
thisMultiDetector->offsetX[id]=0;
|
||||
@ -433,6 +435,8 @@ void multiSlsDetector::updateOffsets(){//cannot paralllize due to slsdetector ca
|
||||
thisMultiDetector->numberOfChannel[Y] = 0;
|
||||
thisMultiDetector->maxNumberOfChannel[X] = 0;
|
||||
thisMultiDetector->maxNumberOfChannel[Y] = 0;
|
||||
thisMultiDetector->numberOfDetector[X] = 0;
|
||||
thisMultiDetector->numberOfDetector[Y] = 0;
|
||||
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
|
||||
@ -455,6 +459,8 @@ void multiSlsDetector::updateOffsets(){//cannot paralllize due to slsdetector ca
|
||||
numY += detectors[i]->getTotalNumberOfChannels(Y);
|
||||
maxX += detectors[i]->getMaxNumberOfChannels(X);
|
||||
maxY += detectors[i]->getMaxNumberOfChannels(Y);
|
||||
++thisMultiDetector->numberOfDetector[X];
|
||||
++thisMultiDetector->numberOfDetector[Y];
|
||||
#ifdef VERBOSE
|
||||
cout<<"incrementing in both direction"<<endl;
|
||||
#endif
|
||||
@ -466,6 +472,7 @@ void multiSlsDetector::updateOffsets(){//cannot paralllize due to slsdetector ca
|
||||
prevChanY = detectors[i]->getTotalNumberOfChannels(Y);
|
||||
numY += detectors[i]->getTotalNumberOfChannels(Y);
|
||||
maxY += detectors[i]->getMaxNumberOfChannels(Y);
|
||||
++thisMultiDetector->numberOfDetector[Y];
|
||||
#ifdef VERBOSE
|
||||
cout<<"incrementing in y direction"<<endl;
|
||||
#endif
|
||||
@ -483,6 +490,7 @@ void multiSlsDetector::updateOffsets(){//cannot paralllize due to slsdetector ca
|
||||
prevChanX = detectors[i]->getTotalNumberOfChannels(X);
|
||||
numX += detectors[i]->getTotalNumberOfChannels(X);
|
||||
maxX += detectors[i]->getMaxNumberOfChannels(X);
|
||||
++thisMultiDetector->numberOfDetector[X];
|
||||
#ifdef VERBOSE
|
||||
cout<<"incrementing in x direction"<<endl;
|
||||
#endif
|
||||
@ -791,24 +799,6 @@ int multiSlsDetector::addSlsDetector(detectorType t, int pos) {
|
||||
|
||||
|
||||
|
||||
void multiSlsDetector::getNumberOfDetectors(int& nx, int& ny) {
|
||||
nx = 0; ny = 0;
|
||||
|
||||
int offsetx = -1, offsety = -1;
|
||||
for (int i = 0; i < thisMultiDetector->numberOfDetectors; ++i) {
|
||||
if (thisMultiDetector->offsetX[i] > offsetx) {
|
||||
++nx;
|
||||
offsetx = thisMultiDetector->offsetX[i];
|
||||
}
|
||||
if (thisMultiDetector->offsetY[i] > offsety) {
|
||||
++ny;
|
||||
offsety = thisMultiDetector->offsetY[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::getDetectorOffset(int pos, int &ox, int &oy) {
|
||||
ox=-1;
|
||||
|
@ -67,6 +67,9 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
/** Number of detectors operated at once */
|
||||
int numberOfDetectors;
|
||||
|
||||
/** Number of detectors operated at once */
|
||||
int numberOfDetector[2];
|
||||
|
||||
/** Ids of the detectors to be operated at once */
|
||||
int detectorIds[MAXDET];
|
||||
|
||||
@ -329,11 +332,17 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
\returns number of detectors */
|
||||
int getNumberOfDetectors() {return thisMultiDetector->numberOfDetectors;};
|
||||
|
||||
/**returns number of detectors in dimension d
|
||||
* \param d dimension d
|
||||
* \returns number of detectors in dimension d
|
||||
*/
|
||||
int getNumberOfDetectors(dimension d) {return thisMultiDetector->numberOfDetector[d];};
|
||||
|
||||
/** returns the number of detectors in each direction
|
||||
\param nx number of detectors in x direction
|
||||
\param ny number of detectors in y direction
|
||||
*/
|
||||
void getNumberOfDetectors(int& nx, int& ny);
|
||||
void getNumberOfDetectors(int& nx, int& ny){nx=thisMultiDetector->numberOfDetector[X];ny=thisMultiDetector->numberOfDetector[Y];};
|
||||
|
||||
int getMaxMods();
|
||||
int getNMods();
|
||||
|
@ -6407,9 +6407,25 @@ int slsDetector::configureMAC(){
|
||||
int ret=FAIL;
|
||||
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
char arg[6][50]={"","","","","",""};
|
||||
char arg[6][50];memset(arg,0,sizeof(char)*6*50);
|
||||
int retval=-1;
|
||||
|
||||
// to send 3d positions to detector
|
||||
bool sendpos = 0;
|
||||
int pos[3]={0,0,0};
|
||||
|
||||
// only jungfrau send x, y and z in detector udp header
|
||||
if (thisDetector->myDetectorType == JUNGFRAU) {
|
||||
sendpos = true;
|
||||
int max = parentDet->getNumberOfDetectors(X);
|
||||
if(!posId) {
|
||||
pos[0] = 0;
|
||||
pos[1] = 0;
|
||||
} else {
|
||||
pos[0] = posId / max;
|
||||
pos[1] = posId % max;
|
||||
}
|
||||
}
|
||||
|
||||
//if udpip wasnt initialized in config file
|
||||
if(!(strcmp(thisDetector->receiverUDPIP,"none"))){
|
||||
@ -6434,12 +6450,12 @@ int slsDetector::configureMAC(){
|
||||
strcpy(arg[3],thisDetector->detectorMAC);
|
||||
strcpy(arg[4],thisDetector->detectorIP);
|
||||
sprintf(arg[5],"%x",thisDetector->receiverUDPPort2);
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Configuring MAC"<< std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
for(i=0;i<2;++i){
|
||||
if(!strcmp(arg[i],"none")){
|
||||
std::cout<< "Configure MAC Error. IP/MAC Addresses not set"<< std::endl;
|
||||
@ -6529,6 +6545,8 @@ int slsDetector::configureMAC(){
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(arg,sizeof(arg));
|
||||
if(sendpos)
|
||||
controlSocket->SendDataOnly(pos,sizeof(pos));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL){
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
|
@ -152,6 +152,9 @@ long int calcChecksum(int sourceip, int destip);
|
||||
#ifndef MYTHEND
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival);
|
||||
#endif
|
||||
#ifdef JUNGFRAUD
|
||||
int setDetectorPosition(int pos[]);
|
||||
#endif
|
||||
|
||||
|
||||
// very detector specific
|
||||
|
@ -3408,6 +3408,10 @@ int configure_mac(int file_des) {
|
||||
char arg[6][50];
|
||||
memset(arg,0,sizeof(arg));
|
||||
n = receiveData(file_des,arg,sizeof(arg),OTHER);
|
||||
#ifdef JUNGFRAUD
|
||||
int pos[3]={0,0,0};
|
||||
n = receiveData(file_des,pos,sizeof(pos),INT32);
|
||||
#endif
|
||||
if (n < 0) return printSocketReadError();
|
||||
|
||||
uint32_t ipad;
|
||||
@ -3456,6 +3460,10 @@ int configure_mac(int file_des) {
|
||||
printf("udp port2:0x%x\n",udpport2);
|
||||
printf("\n");
|
||||
printf("Configuring MAC of module %d at port %x\n", imod, udpport);
|
||||
|
||||
#ifdef JUNGFRAUD
|
||||
printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]);
|
||||
#endif
|
||||
#endif
|
||||
if(getRunStatus() == RUNNING){
|
||||
ret = stopStateMachine();
|
||||
@ -3471,8 +3479,16 @@ int configure_mac(int file_des) {
|
||||
sprintf(mess,"Configure Mac failed\n");
|
||||
cprintf(RED, "Warning: %s", mess);
|
||||
}
|
||||
else
|
||||
else {
|
||||
printf("Configure MAC successful\n");
|
||||
#ifdef JUNGFRAUD
|
||||
ret = setDetectorPosition(pos);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess,"could not set detector position\n");
|
||||
cprintf(RED, "Warning: %s", mess);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Configured MAC with retval %d\n", retval);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user