Merge branch 'developer' into gappixels

This commit is contained in:
maliakal_d 2017-10-12 14:58:41 +02:00
commit 4f2af046d3
11 changed files with 101 additions and 55 deletions

View File

@ -18,6 +18,7 @@
#include "FebRegisterDefs.h"
#include "FebControl.h"
#include "Beb.h"
#include "slsDetectorServer_defs.h"
@ -906,7 +907,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
return 0;
}
if(!Feb_Control_Reset()) cprintf(RED,"Warning could not reset DAQ.\n");
if(Feb_Control_Reset() == STATUS_ERROR) cprintf(RED,"Warning could not reset DAQ.\n");
int l_r; //printf("222\n");
for(l_r=0;l_r<2;l_r++){ // l_r loop
//printf("\nl_r:%d\t\t",l_r);
@ -914,7 +915,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
if(Feb_Control_activated){
if(!(Feb_Interface_WriteRegister(0xfff,DAQ_REG_STATIC_BITS,disable_chip_mask|DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_M8,0,0)
&&Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT)
&&Feb_Control_StartDAQOnlyNWaitForFinish(5000))){
&&(Feb_Control_StartDAQOnlyNWaitForFinish(5000) == STATUS_IDLE))){
printf("Could not select chips\n");
return 0;
}
@ -980,7 +981,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
//if(!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)||
// !Feb_Interface_WriteMemory(Module_GetTopRightAddress(&modules[0]),0,0,1023,trimbits_to_load_l)||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
printf(" some errror!\n");
return 0;
}
@ -991,7 +992,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
//if(!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)||
// !Feb_Interface_WriteMemory(Module_GetTopRightAddress(&modules[0]),0,0,1023,trimbits_to_load_l)||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
printf(" some errror!\n");
return 0;
}
@ -1073,29 +1074,29 @@ int Feb_Control_AcquisitionInProgress(){
//deactivated should return end of acquisition
if(!Feb_Control_activated)
return 0;
return STATUS_IDLE;
int ind = Feb_Control_current_index;
if(Module_BottomAddressIsValid(&modules[ind])){
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r)))
{cprintf(RED,"Error: Trouble reading Status register. bottom right address\n");return 0;}
{cprintf(RED,"Error: Trouble reading Status register. bottom right address\n");return STATUS_ERROR;}
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l)))
{cprintf(RED,"Error: Trouble reading Status register. bottom left address\n");return 0;}
{cprintf(RED,"Error: Trouble reading Status register. bottom left address\n");return STATUS_ERROR;}
}else{
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r)))
{cprintf(RED,"Error: Trouble reading Status register. top right address\n");return 0;}
{cprintf(RED,"Error: Trouble reading Status register. top right address\n");return STATUS_ERROR;}
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l)))
{cprintf(RED,"Error: Trouble reading Status register. top left address\n");return 0;}
{cprintf(RED,"Error: Trouble reading Status register. top left address\n");return STATUS_ERROR;}
}
//running
if((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING) {/*printf("**runningggg\n");*/
return 1;
return STATUS_RUNNING;
}
//idle
return 0;
return STATUS_IDLE;
}
@ -1132,16 +1133,25 @@ int Feb_Control_AcquisitionStartedBit(){
int Feb_Control_WaitForFinishedFlag(int sleep_time_us){
int is_running = Feb_Control_AcquisitionInProgress();
while(is_running){
int check_error = 0;
// it will break out if it is idle or if check_error is more than 5 times
while(is_running != STATUS_IDLE){
usleep(sleep_time_us);
is_running = Feb_Control_AcquisitionInProgress();
}
if(is_running!=0){
printf("\n\nWarning WaitForFinishedFlag comunication problem..\n\n");
return 0; //communication problem
// check error only 5 times (ensuring it is not something that happens sometimes)
if (is_running == STATUS_ERROR) {
if (check_error == 5)
break;
check_error++;
}// reset check_error for next time
else check_error = 0;
}
return 1;
return is_running;
}
@ -1151,6 +1161,10 @@ int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag){
if(!Feb_Control_activated)
return 1;
//did not start
if(prev_flag == -1)
return 0;
int value = prev_flag;
while(value == prev_flag){
usleep(sleep_time_us);
@ -1183,7 +1197,9 @@ int Feb_Control_Reset(){
int Feb_Control_SetStaticBits(){
if(Feb_Control_activated){
//program=1,m4=2,m8=4,test=8,rotest=16,cs_bar_left=32,cs_bar_right=64
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_STATIC_BITS,Feb_Control_staticBits,0,0) || !Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_STATIC_BITS,Feb_Control_staticBits,0,0) ||
!Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT) ||
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: Could not set static bits\n");
return 0;
}
@ -1390,7 +1406,7 @@ unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec){
}
int Feb_Control_ResetChipCompletely(){
if(!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
if(!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: could not ResetChipCompletely() with 0x%x.\n",DAQ_RESET_COMPLETELY);
return 0;
}
@ -1401,13 +1417,13 @@ int Feb_Control_ResetChipCompletely(){
int Feb_Control_ResetChipPartially(){
if(!Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
if(!Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: could not ResetChipPartially with periphery\n");
return 0;
}
printf("Chip reset periphery 0x%x\n",DAQ_RESET_PERIPHERY);
if(!Feb_Control_SetCommandRegister(DAQ_RESET_COLUMN_SELECT) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
if(!Feb_Control_SetCommandRegister(DAQ_RESET_COLUMN_SELECT) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: could not ResetChipPartially with column select\n");
return 0;
}
@ -1456,7 +1472,7 @@ int Feb_Control_PrepareForAcquisition(){//return 1;
Feb_Control_PrintAcquisitionSetup();
// if(!Reset()||!ResetDataStream()){
if(!Feb_Control_Reset()){
if(Feb_Control_Reset() == STATUS_ERROR){
printf("Trouble reseting daq or data stream...\n");;
return 0;
}
@ -1580,7 +1596,10 @@ int Feb_Control_Pulse_Pixel(int npulses, int x, int y){
Feb_Control_SetInTestModeVariable(1); //on
Feb_Control_SetStaticBits();
Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY|DAQ_RESET_COLUMN_SELECT);
Feb_Control_StartDAQOnlyNWaitForFinish(5000);
if (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE) {
cprintf(RED,"Warning: could not pulse pixel as status not idle\n");
return 0;
}
unsigned int serial_in = 8<<(4*(7-x%8));
if(!Feb_Control_Shift32InSerialIn(serial_in)){
@ -1610,7 +1629,7 @@ int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos){
if(Feb_Control_activated){
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_SEND_N_TESTPULSES,npulses,0,0) ||
!Feb_Control_SetCommandRegister(c) ||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: could not PulsePixelNMove(...).\n");
return 0;
}
@ -1624,7 +1643,7 @@ int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in){
if(Feb_Control_activated){
if(!Feb_Control_SetCommandRegister(DAQ_SERIALIN_SHIFT_IN_32) ||
!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_SHIFT_IN_32,value_to_shift_in,0,0) ||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: could not shift in 32.\n");
return 0;
}
@ -1634,7 +1653,7 @@ int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in){
int Feb_Control_SendTokenIn(){
if(!Feb_Control_SetCommandRegister(DAQ_SEND_A_TOKEN_IN) ||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: could not SendTokenIn().\n");
return 0;
}
@ -1650,7 +1669,7 @@ int Feb_Control_ClockRowClock(unsigned int ntimes){
if(Feb_Control_activated){
if(!Feb_Control_SetCommandRegister(DAQ_CLK_ROW_CLK_NTIMES) ||
!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CLK_ROW_CLK_NTIMES,ntimes,0,0) ||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(RED,"Warning: could not clock row clock.\n");
return 0;
}
@ -1680,7 +1699,7 @@ int Feb_Control_PulseChip(int npulses){
for(i=0;i<npulses;i++){
if(!Feb_Control_SetCommandRegister(DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED|DAQ_RESET_PERIPHERY|DAQ_RESET_COLUMN_SELECT))
cprintf(RED,"some set command register error\n");
if(!Feb_Control_StartDAQOnlyNWaitForFinish(5000))
if((Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE))
cprintf(RED,"some wait error\n");
}
Feb_Control_SetExternalEnableMode(on,1);
@ -1849,7 +1868,7 @@ int Feb_Control_SetRateCorrectionTable(unsigned int *table){
if(Feb_Control_activated){
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(BG_RED,"Error in Top Writing to Memory ::Feb_Control_SetRateCorrectionTable\n");
return 0;
}
@ -1858,7 +1877,7 @@ int Feb_Control_SetRateCorrectionTable(unsigned int *table){
if(Feb_Control_activated){
if(!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
(Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){
cprintf(BG_RED,"Error in Bottom Writing to Memory ::Feb_Control_SetRateCorrectionTable\n");
return 0;
}

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 1701b20218363d885a7dc62f92591c7e1f4e2f1c
Revision: 304
Repsitory UUID: 77d9fda91fa82c2b4259d64ca9d4d6b4fa4b647c
Revision: 313
Branch: developer
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 1589
Last Changed Date: 2017-09-26 09:25:28.000000002 +0200 ./Beb.c
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 1607
Last Changed Date: 2017-10-12 14:50:11.000000002 +0200 ./FebRegisterDefs.h

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUID "1701b20218363d885a7dc62f92591c7e1f4e2f1c"
//#define SVNREV 0x1589
#define SVNREPUUID "77d9fda91fa82c2b4259d64ca9d4d6b4fa4b647c"
//#define SVNREV 0x1607
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x1589
#define SVNDATE 0x20170926
#define SVNAUTH "Dhanya_Thattil"
#define SVNREV 0x1607
#define SVNDATE 0x20171012
//

View File

@ -1146,8 +1146,8 @@ int startStateMachine(){
//wait for acquisition start
if(ret == OK){
if(!Feb_Control_WaitForStartedFlag(5000, prev_flag)){
cprintf(RED,"Error: Acquisition did no start or trouble reading register\n");
ret = FAIL;
cprintf(RED,"Error: Acquisition did not start or trouble reading register\n");
return FAIL;
}
cprintf(GREEN,"***Acquisition started\n");
}
@ -1160,7 +1160,7 @@ int startStateMachine(){
int stopStateMachine(){
cprintf(BG_RED,"Going to stop acquisition\n");
if(Feb_Control_StopAcquisition() & Beb_StopAcquisition())
if((Feb_Control_StopAcquisition() == STATUS_IDLE) & Beb_StopAcquisition())
return OK;
cprintf(BG_RED,"failed to stop acquisition\n");
return FAIL;
@ -1194,16 +1194,19 @@ int startReadOut(){
enum runStatus getRunStatus(){
//if(trialMasterMode == IS_MASTER){
int i = Feb_Control_AcquisitionInProgress();
if(i== 0){
switch (i) {
case STATUS_ERROR:
printf("Status: ERROR reading status register\n");
return ERROR;
case STATUS_IDLE:
printf("Status: IDLE\n");
return IDLE;
}else{
default:
printf("Status: RUNNING...\n");
return RUNNING;
}
//}else printf("***** not master*** \n");
return IDLE;
}
@ -1211,8 +1214,11 @@ enum runStatus getRunStatus(){
void readFrame(int *ret, char *mess){
if(!Feb_Control_WaitForFinishedFlag(5000))
if(Feb_Control_WaitForFinishedFlag(5000) == STATUS_ERROR) {
cprintf(RED,"Error: Waiting for finished flag\n");
*ret = FAIL;
return;
}
cprintf(GREEN,"Acquisition finished***\n");
if(eiger_storeinmem){

View File

@ -15,6 +15,10 @@
#define REQUIRED_FIRMWARE_VERSION (21)
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
#define STATUS_IDLE 0
#define STATUS_RUNNING 1
#define STATUS_ERROR 2
/* Enums */
enum CLK_SPEED_INDEX {FULL_SPEED, HALF_SPEED, QUARTER_SPEED};
enum DACINDEX {SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS,VTHRESHOLD};

View File

@ -1163,7 +1163,7 @@ string multiSlsDetector::checkOnline() {
int multiSlsDetector::activate(int const enable){
int i;
int64_t ret1=-100, ret;
int ret1=-100, ret;
for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
if (detectors[i]) {
@ -1944,8 +1944,9 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() {
s1=detectors[i]->getRunStatus();
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i));
if (s1==ERROR)
s=ERROR;
if (s1==ERROR) {
return ERROR;
}
if (s1!=IDLE)
s = s1;
// if (s1==IDLE && s!=IDLE)
@ -2010,7 +2011,7 @@ void multiSlsDetector::resetFinalDataQueue() {
*/
int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){
int ret=-100;
int64_t ret=-100;
if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl;
@ -2086,7 +2087,7 @@ int64_t multiSlsDetector::getTimeLeft(timerIndex index){
int multiSlsDetector::setSpeed(speedVariable index, int value){
int i;
int64_t ret1=-100, ret;
int ret1=-100, ret;

View File

@ -346,6 +346,11 @@ int slsDetectorUsers::startAcquisition() {
return myDetector->startAcquisition();
}
int slsDetectorUsers::stopAcquisition() {
return myDetector->stopAcquisition();
}
int slsDetectorUsers::setReceiverSilentMode(int i) {
return myDetector->setReceiverSilentMode(i);
}

View File

@ -598,11 +598,19 @@ class slsDetectorUsers
int stopReceiver();
/**
start detector acquisition in non blocking mode
start detector real time acquisition in non blocking mode
does not include scans, scripts, incrementing file index, s
tarting/stopping receiver, resetting frames caught in receiver
\returns OK if all detectors are properly started, FAIL otherwise
*/
int startAcquisition();
/**
stop detector real time acquisition
\returns OK if all detectors are properly started, FAIL otherwise
*/
int stopAcquisition();
/**
* set receiver in silent mode
* @param i 1 sets, 0 unsets (-1 gets)

View File

@ -163,7 +163,7 @@ int receiverInterface::getLastClientIP(int fnum, char retval[]){
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
dataSocket->ReceiveDataOnly(retval,sizeof(retval));
dataSocket->ReceiveDataOnly(retval,INET_ADDRSTRLEN);
return ret;
}