integrate Dingo Camera Server stuffs
This commit is contained in:
@@ -14,10 +14,11 @@
|
||||
#include <countdriv.h>
|
||||
#include <nwatch.h>
|
||||
#include <asyncqueue.h>
|
||||
#include <math.h>
|
||||
#include "camera.h"
|
||||
|
||||
#define ERRLEN 256
|
||||
#define MSGLEN 256
|
||||
#define MSGLEN 512
|
||||
|
||||
enum camstates {idle, acquiring, processing, saving};
|
||||
#define CAMDRIV_ERRTABLE \
|
||||
@@ -106,6 +107,15 @@ typedef struct {
|
||||
int updatecfg;
|
||||
} camcfg_t;
|
||||
|
||||
typedef struct {
|
||||
char path[MSGLEN];
|
||||
char basename[MSGLEN];
|
||||
int startnumber;
|
||||
char imageformat[MSGLEN];
|
||||
char experimentdetail[MSGLEN];
|
||||
int updatecfg;
|
||||
} filecfg_t;
|
||||
|
||||
typedef struct {
|
||||
int debug;
|
||||
char *asynq;
|
||||
@@ -229,27 +239,50 @@ int sendcfg(CamObj *self) {
|
||||
char cfgCmd[MSGLEN+1];
|
||||
float clock = self->camera.clockMHz;
|
||||
|
||||
sprintf(cfgCmd,
|
||||
"set camera,clock=%.*fmhz,bin=%dx,size=%d,gain=%dxhs,flip=%s,xstart=%d,ystart=%d,xend=%d,yend=%d,exposure=%f,temperature=%f,threshold=%d,shutteropentime=%d,shutterclosetime=%d",
|
||||
clock>=1 ? 0 : 1, clock, (int)self->camera.bin, (int)self->camera.size,
|
||||
(int)self->camera.gain, flipcmdstr[self->camera.flip],
|
||||
(int)self->camera.xstart, (int)self->camera.ystart,
|
||||
(int)self->camera.xend, (int)self->camera.yend, self->camera.exposure,
|
||||
self->camera.temp, (int)self->camera.thresh, (int)self->camera.shopt,
|
||||
(int)self->camera.shclt
|
||||
);
|
||||
if(self->camera.updatecfg) {
|
||||
sprintf(cfgCmd,
|
||||
"set camera,clock=%.*fmhz,bin=%dx,size=%d,gain=%dxhs,flip=%s,xstart=%d,ystart=%d,xend=%d,yend=%d,exposure=%f,temperature=%f,threshold=%d,shutteropentime=%d,shutterclosetime=%d",
|
||||
clock>=1 ? 0 : 1, clock, (int)self->camera.bin, (int)self->camera.size,
|
||||
(int)self->camera.gain, flipcmdstr[self->camera.flip],
|
||||
(int)self->camera.xstart, (int)self->camera.ystart,
|
||||
(int)self->camera.xend, (int)self->camera.yend, self->camera.exposure,
|
||||
self->camera.temp, (int)self->camera.thresh, (int)self->camera.shopt,
|
||||
(int)self->camera.shclt
|
||||
);
|
||||
|
||||
status = AsyncUnitTransact(self->asyncUnit, cfgCmd, strlen(cfgCmd), reply, &replen);
|
||||
if (status <= 0)
|
||||
return 0;
|
||||
else
|
||||
if (strncmp("OK", reply, 2) == 0)
|
||||
return 1;
|
||||
else {
|
||||
snprintf(logmsg, MSGLEN, "CAM:(sendcfg) reply=%s", reply);
|
||||
SICSLogWrite(logmsg, eLogError);
|
||||
status = AsyncUnitTransact(self->asyncUnit, cfgCmd, strlen(cfgCmd), reply, &replen);
|
||||
if (status <= 0)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (strncmp("OK", reply, 2) == 0)
|
||||
return 1;
|
||||
else {
|
||||
snprintf(logmsg, MSGLEN, "CAM:(sendcfg) set camera reply=%s", reply);
|
||||
SICSLogWrite(logmsg, eLogError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* TBD, other fields to be set
|
||||
if(self->file.updatecfg) {
|
||||
sprintf(cfgCmd, "set camera, path=%s,basename=%s,startnumber=%d,imageformat=%s,experimentdetail=%s",
|
||||
self->file.path,
|
||||
self->file.basename,
|
||||
self->file.startnumber,
|
||||
self->file.imageformat, self->file.experimentdetail);
|
||||
status = AsyncUnitTransact(self->asyncUnit, cfgCmd, strlen(cfgCmd), reply, &replen);
|
||||
if (status <= 0)
|
||||
return 0;
|
||||
else
|
||||
if (strncmp("OK", reply, 2) == 0)
|
||||
return 1;
|
||||
else {
|
||||
snprintf(logmsg, MSGLEN, "CAM:(sendcfg) set file reply=%s", reply);
|
||||
SICSLogWrite(logmsg, eLogError);
|
||||
return 0;
|
||||
}
|
||||
} */
|
||||
|
||||
}
|
||||
|
||||
/* Called by the scan command and via the count and countnb subcommands of a
|
||||
@@ -568,7 +601,11 @@ static int CamSend(CounterDriver *cntrData, char *pText, char *pReply, int iRepl
|
||||
|
||||
self = cntrData->pData;
|
||||
|
||||
//char *pBuf = (char *)calloc(strlen(pText)+10, sizeof(char));
|
||||
//sprintf(pBuf, "set meta, %s", pText);
|
||||
//status = AsyncUnitTransact(self->asyncUnit, pBuf, strlen(pBuf), pReply, &iReplyLen);
|
||||
status = AsyncUnitTransact(self->asyncUnit, pText, strlen(pText), pReply, &iReplyLen);
|
||||
//free(pBuf);
|
||||
if (status <= 0)
|
||||
return 0;
|
||||
else
|
||||
@@ -696,8 +733,12 @@ static int cb_getstate(pAsyncTxn txn) {
|
||||
NetWatchRemoveTimer(self->state_timer);
|
||||
self->state_timer=0;
|
||||
}
|
||||
char logmsg[MSGLEN+1]="";
|
||||
snprintf(logmsg, MSGLEN,"CAM:(cb_getstate) Entering NetWatchRegisterTimer");
|
||||
SICSLogWrite(logmsg, eLog);
|
||||
NetWatchRegisterTimer(&self->state_timer, 500, cb_state_timer, self);
|
||||
|
||||
snprintf(logmsg, MSGLEN,"CAM:(cb_getstate) Leaving NetWatchRegisterTimer");
|
||||
SICSLogWrite(logmsg, eLog);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user