integrate Dingo Camera Server stuffs
This commit is contained in:
@@ -14,10 +14,11 @@
|
|||||||
#include <countdriv.h>
|
#include <countdriv.h>
|
||||||
#include <nwatch.h>
|
#include <nwatch.h>
|
||||||
#include <asyncqueue.h>
|
#include <asyncqueue.h>
|
||||||
|
#include <math.h>
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
|
|
||||||
#define ERRLEN 256
|
#define ERRLEN 256
|
||||||
#define MSGLEN 256
|
#define MSGLEN 512
|
||||||
|
|
||||||
enum camstates {idle, acquiring, processing, saving};
|
enum camstates {idle, acquiring, processing, saving};
|
||||||
#define CAMDRIV_ERRTABLE \
|
#define CAMDRIV_ERRTABLE \
|
||||||
@@ -106,6 +107,15 @@ typedef struct {
|
|||||||
int updatecfg;
|
int updatecfg;
|
||||||
} camcfg_t;
|
} camcfg_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char path[MSGLEN];
|
||||||
|
char basename[MSGLEN];
|
||||||
|
int startnumber;
|
||||||
|
char imageformat[MSGLEN];
|
||||||
|
char experimentdetail[MSGLEN];
|
||||||
|
int updatecfg;
|
||||||
|
} filecfg_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int debug;
|
int debug;
|
||||||
char *asynq;
|
char *asynq;
|
||||||
@@ -229,6 +239,7 @@ int sendcfg(CamObj *self) {
|
|||||||
char cfgCmd[MSGLEN+1];
|
char cfgCmd[MSGLEN+1];
|
||||||
float clock = self->camera.clockMHz;
|
float clock = self->camera.clockMHz;
|
||||||
|
|
||||||
|
if(self->camera.updatecfg) {
|
||||||
sprintf(cfgCmd,
|
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",
|
"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,
|
clock>=1 ? 0 : 1, clock, (int)self->camera.bin, (int)self->camera.size,
|
||||||
@@ -246,12 +257,34 @@ int sendcfg(CamObj *self) {
|
|||||||
if (strncmp("OK", reply, 2) == 0)
|
if (strncmp("OK", reply, 2) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
else {
|
else {
|
||||||
snprintf(logmsg, MSGLEN, "CAM:(sendcfg) reply=%s", reply);
|
snprintf(logmsg, MSGLEN, "CAM:(sendcfg) set camera reply=%s", reply);
|
||||||
SICSLogWrite(logmsg, eLogError);
|
SICSLogWrite(logmsg, eLogError);
|
||||||
return 0;
|
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
|
/* Called by the scan command and via the count and countnb subcommands of a
|
||||||
* counter object. Will update the configuration if necessary.
|
* counter object. Will update the configuration if necessary.
|
||||||
*/
|
*/
|
||||||
@@ -568,7 +601,11 @@ static int CamSend(CounterDriver *cntrData, char *pText, char *pReply, int iRepl
|
|||||||
|
|
||||||
self = cntrData->pData;
|
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);
|
status = AsyncUnitTransact(self->asyncUnit, pText, strlen(pText), pReply, &iReplyLen);
|
||||||
|
//free(pBuf);
|
||||||
if (status <= 0)
|
if (status <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
@@ -696,8 +733,12 @@ static int cb_getstate(pAsyncTxn txn) {
|
|||||||
NetWatchRemoveTimer(self->state_timer);
|
NetWatchRemoveTimer(self->state_timer);
|
||||||
self->state_timer=0;
|
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);
|
NetWatchRegisterTimer(&self->state_timer, 500, cb_state_timer, self);
|
||||||
|
snprintf(logmsg, MSGLEN,"CAM:(cb_getstate) Leaving NetWatchRegisterTimer");
|
||||||
|
SICSLogWrite(logmsg, eLog);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user