mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 13:57:13 +02:00
WIP
This commit is contained in:
@ -998,11 +998,15 @@ int Feb_Control_StartAcquisition() {
|
|||||||
|
|
||||||
int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); }
|
int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); }
|
||||||
|
|
||||||
int Feb_Control_GetExposureStatus(int *rising, int *falling, int *exposure) {
|
int Feb_Control_GetExposureStatus(int left, int *rising, int *falling,
|
||||||
|
int *exposure) {
|
||||||
|
|
||||||
|
unsigned int addr =
|
||||||
|
(left == 1 ? Feb_Control_leftAddress : Feb_Control_rightAddress);
|
||||||
unsigned int value = 0;
|
unsigned int value = 0;
|
||||||
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(), FEB_REG_STATUS,
|
if (!Feb_Interface_ReadRegister(addr, FEB_REG_STATUS, &value)) {
|
||||||
&value)) {
|
LOG(logERROR, ("Could not read %s FEB_REG_STATUS reg\n",
|
||||||
LOG(logERROR, ("Could not read FEB_REG_STATUS reg\n"));
|
(left == 1 ? "left" : "right")));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
LOG(logINFORED, ("febregstatus:0x%x\n", value));
|
LOG(logINFORED, ("febregstatus:0x%x\n", value));
|
||||||
@ -1046,60 +1050,77 @@ int Feb_Control_SendSoftwareTrigger() {
|
|||||||
int Feb_Control_SoftwareTrigger(int block) {
|
int Feb_Control_SoftwareTrigger(int block) {
|
||||||
if (Feb_Control_activated) {
|
if (Feb_Control_activated) {
|
||||||
|
|
||||||
int rising = 0, falling = 0, exposure = 0;
|
int rising[2] = {0, 0}, falling[2] = {0, 0}, exposure[2] = {0, 0},
|
||||||
if (!Feb_Control_GetExposureStatus(&rising, &falling, &exposure)) {
|
prev_toggle[2] = {0, 0};
|
||||||
|
for (int i = 0; i < 1; ++i) {
|
||||||
|
if (!Feb_Control_GetExposureStatus(i, &rising[i], &falling[i],
|
||||||
|
&exposure[i])) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exposure) {
|
if (exposure[i]) {
|
||||||
LOG(logERROR, ("Software trigger failed. Still exposing.\n"));
|
LOG(logERROR,
|
||||||
|
("Software trigger failed. %s FPGA still exposing.\n",
|
||||||
|
i == 1 ? "left" : "right"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remember previous rising toggle
|
// remember previous rising toggle
|
||||||
int prev_toggle = rising;
|
prev_toggle[i] = rising[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// send trigger to both fpgas
|
||||||
Feb_Control_SendSoftwareTrigger();
|
Feb_Control_SendSoftwareTrigger();
|
||||||
|
|
||||||
// will need to wait if delay after trigger introduced
|
// will need to wait if delay after trigger introduced
|
||||||
// usleep(0);
|
// usleep(0);
|
||||||
|
|
||||||
|
for (int i = 0; i < 1; ++i) {
|
||||||
// get current toggle value
|
// get current toggle value
|
||||||
if (!Feb_Control_GetExposureStatus(&rising, &falling, &exposure)) {
|
if (!Feb_Control_GetExposureStatus(i, &rising[i], &falling[i],
|
||||||
|
&exposure[i])) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no toggle error
|
// no toggle error
|
||||||
if (rising == prev_toggle) {
|
if (rising[i] == prev_toggle[i]) {
|
||||||
LOG(logERROR, ("Software trigger failed. No exposure toggle "
|
LOG(logERROR, ("Software trigger failed. No exposure toggle "
|
||||||
"detected.\n"));
|
"detected on %s fpga.\n",
|
||||||
|
i == 1 ? "left" : "right"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no exposure
|
// no exposure
|
||||||
if (!exposure) {
|
if (!exposure[i]) {
|
||||||
LOG(logERROR, ("Software trigger failed. No exposure detected.\n"));
|
LOG(logERROR, ("Software trigger failed. No exposure detected "
|
||||||
|
"on %s fpga.\n",
|
||||||
|
i == 1 ? "left" : "right"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// wait for exposure to be done
|
// wait for exposure to be done
|
||||||
if (block) {
|
if (block) {
|
||||||
prev_toggle = falling;
|
for (int i = 0; i < 1; ++i) {
|
||||||
while (prev_toggle == falling) {
|
prev_toggle[i] = falling[i];
|
||||||
|
while (prev_toggle[i] == falling[i]) {
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
if (!Feb_Control_GetExposureStatus(&rising, &falling,
|
if (!Feb_Control_GetExposureStatus(
|
||||||
&exposure)) {
|
i, &rising[i], &falling[i], &exposure[i])) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// exposure low
|
// exposure low
|
||||||
if (exposure) {
|
if (exposure[i]) {
|
||||||
LOG(logERROR, ("Software trigger failed. Still exposing after "
|
LOG(logERROR,
|
||||||
"exposure finished toggled.\n"));
|
("Software trigger failed. Still exposing after "
|
||||||
|
"exposure finished toggled in %s fpga.\n",
|
||||||
|
i == 1 ? "left" : "right"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ int Feb_Control_PrepareForAcquisition();
|
|||||||
void Feb_Control_PrintAcquisitionSetup();
|
void Feb_Control_PrintAcquisitionSetup();
|
||||||
int Feb_Control_StartAcquisition();
|
int Feb_Control_StartAcquisition();
|
||||||
int Feb_Control_StopAcquisition();
|
int Feb_Control_StopAcquisition();
|
||||||
int Feb_Control_GetExposureStatus(int *rising, int *falling, int *exposure);
|
int Feb_Control_GetExposureStatus(int left, int *rising, int *falling,
|
||||||
|
int *exposure);
|
||||||
int Feb_Control_SendSoftwareTrigger();
|
int Feb_Control_SendSoftwareTrigger();
|
||||||
int Feb_Control_SoftwareTrigger(int block);
|
int Feb_Control_SoftwareTrigger(int block);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user