Dingo camera driver
This commit is contained in:
5
site_ansto/TESTS/dingo_camera/Makefile
Normal file
5
site_ansto/TESTS/dingo_camera/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
# vim: ft=make: ts=8: sw=8: noet: cindent:
|
||||
|
||||
all: camera_test.c ../../camera.c ../../camera.h
|
||||
gcc -g -Wall -Wextra -std=c99 -pedantic -I../../ -o camera_test camera_test.c ../../camera.c
|
||||
|
||||
BIN
site_ansto/TESTS/dingo_camera/camera_test
Executable file
BIN
site_ansto/TESTS/dingo_camera/camera_test
Executable file
Binary file not shown.
132
site_ansto/TESTS/dingo_camera/camera_test.c
Normal file
132
site_ansto/TESTS/dingo_camera/camera_test.c
Normal file
@@ -0,0 +1,132 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "camera.h"
|
||||
|
||||
|
||||
void print_state(state_t s) {
|
||||
char *cl, *cm, *dr;
|
||||
cm = SCM_NAMES[s.cm];
|
||||
cl = SCL_NAMES[s.cl];
|
||||
dr = SDR_NAMES[s.dr];
|
||||
printf("%s,%s,%s", cm, cl, dr);
|
||||
}
|
||||
|
||||
void print_event(event_t E) {
|
||||
char *ca, *cm, *cd, *dr;
|
||||
ca = event_names[E.ca];
|
||||
cm = event_names[E.cm];
|
||||
cd = event_names[E.cd];
|
||||
dr = event_names[E.dr];
|
||||
printf("%s,%s,%s,%s", ca, cm, cd, dr);
|
||||
}
|
||||
|
||||
event_t output(state_t Sc, int Ei) {
|
||||
int i;
|
||||
trans_t tr;
|
||||
event_t Eo;
|
||||
|
||||
for (i=0; tr=TRANS_TABLE[i], tr.Sc.dr!= END_TABLE; i++) {
|
||||
if (Ei==tr.Ei && INSYS(Sc,tr.Sc)) {
|
||||
EVset(&Eo,tr.Eo);
|
||||
}
|
||||
}
|
||||
return Eo;
|
||||
}
|
||||
|
||||
int test_camrep2sym(void) {
|
||||
int i, ca_sym, cm_sym, time_rem, time_tot;
|
||||
char *camrep[] = {
|
||||
"StartTime Remaining= 3907 ms, Total Time=3686 ms,",
|
||||
"Open ShutrTime Remaining= 539454 ms, Total Time=3686 ms,",
|
||||
"Acq ImageTime Remaining= 109 ms, Total Time=3686 ms,",
|
||||
"Close ShutrTime Remaining= 218 ms, Total Time=3686 ms,",
|
||||
"Read ImageTime Remaining= 328 ms, Total Time=3686 ms,",
|
||||
"Read ImageTime Remaining= 328 ms, Total Time=3686 ms,",
|
||||
"Read ImageTime Remaining= 328 ms, Total Time=3686 ms,",
|
||||
"Idle",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (i=0; camrep[i] != NULL; i++) {
|
||||
if ( cam_parse_status(camrep[i], &ca_sym, &time_rem, &time_tot) == -1)
|
||||
exit(1);
|
||||
else {
|
||||
cm_sym = camera_model(ca_sym);
|
||||
if (ECA_IDLE==ca_sym)
|
||||
printf("%s(%s) <- %s\n", event_names[cm_sym], event_names[ca_sym], camrep[i] );
|
||||
else
|
||||
printf("%s(%s): time remaining = %d, total time = %d\n",event_names[cm_sym], event_names[ca_sym], time_rem, time_tot);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int test_trans_fn(void) {
|
||||
int i;
|
||||
event_t Eo={0,0,0,0};
|
||||
|
||||
|
||||
state_t Sc = {.cl=SCL_RDY, .cm=SCM_IDLE, .dr=SDR_IDLE};
|
||||
int input[] = {
|
||||
ECM_IDLE, ECD_TK_SHOT, ECM_IDLE, ECM_IDLE, ECM_ACQ, ECD_TK_SHOT,
|
||||
ECM_PROC, ECD_TK_SHOT, ECM_PROC, ECM_IDLE, ECM_ACQ,
|
||||
ECM_PROC, ECM_IDLE, 0
|
||||
};
|
||||
|
||||
printf("INPUT,\tCURR SCM,CURR SCL,CURR SDR,\tCA OUT,CM OUT,CD OUT,DR OUT\n");
|
||||
for (i=0; input[i]; i++) {
|
||||
EVclr(&Eo);
|
||||
printf("%s,\t",event_names[input[i]]);
|
||||
print_state(Sc);
|
||||
cam_trans_fn(Sc, input[i], &Sc, &Eo);
|
||||
printf(",\t");
|
||||
print_event(Eo);
|
||||
printf("\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int camdriv_out(event_t Eo) {
|
||||
if (Eo.ca) {
|
||||
/* send command to camera */
|
||||
printf("camdriv_out: ev=%s, output=%s\n", event_names[Eo.ca], event_signatures[Eo.ca]);
|
||||
}
|
||||
if (Eo.cm) {
|
||||
printf("camdriv_out: ev=%s, output=%s\n", event_names[Eo.cm], event_signatures[Eo.cm]);
|
||||
}
|
||||
if (Eo.cd) {
|
||||
printf("camdriv_out: ev=%s, output=%s\n", event_names[Eo.cd], event_signatures[Eo.cd]);
|
||||
}
|
||||
if (Eo.dr) {
|
||||
/* send msg to SICS */
|
||||
printf("camdriv_out: ev=%s, output=%s\n", event_names[Eo.dr], event_signatures[Eo.dr]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int test_camdriv_input(void) {
|
||||
int Ein=ECD_TK_SHOT;
|
||||
camdriv_t cdinfo = {
|
||||
.Sc = {.cl=SCL_RDY, .cm=SCM_IDLE, .dr=SDR_IDLE},
|
||||
.Eo = {.ca=0},
|
||||
.multi = 0,
|
||||
.output_fn = camdriv_out,
|
||||
};
|
||||
|
||||
camdriv_input(&cdinfo, Ein);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
|
||||
ret = test_camrep2sym();
|
||||
ret = test_trans_fn();
|
||||
ret = test_camdriv_input();
|
||||
|
||||
if (ret)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
22
site_ansto/TESTS/dingo_camera/expect.txt
Normal file
22
site_ansto/TESTS/dingo_camera/expect.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
ECM_ACQ(ECA_START): time remaining = 3907, total time = 3686
|
||||
ECM_ACQ(ECA_OPEN_SHUTR): time remaining = 539454, total time = 3686
|
||||
ECM_ACQ(ECA_ACQ_IMAGE): time remaining = 109, total time = 3686
|
||||
ECM_PROC(ECA_CLOSE_SHUTR): time remaining = 218, total time = 3686
|
||||
ECM_PROC(ECA_READ_IMAGE): time remaining = 328, total time = 3686
|
||||
ECM_PROC(ECA_READ_IMAGE): time remaining = 328, total time = 3686
|
||||
ECM_PROC(ECA_READ_IMAGE): time remaining = 328, total time = 3686
|
||||
ECM_IDLE(ECA_IDLE) <- Idle
|
||||
INPUT, CURR SCM,CURR SCL,CURR SDR, CA OUT,CM OUT,CD OUT,DR OUT
|
||||
ECM_IDLE, SCM_IDLE,SCL_RDY,SDR_IDLE, 0,0,0,0
|
||||
ECD_TK_SHOT, SCM_IDLE,SCL_RDY,SDR_IDLE, 0,0,0,EDR_BUSY
|
||||
ECM_IDLE, SCM_IDLE,SCL_TK_SHOT,SDR_BUSY, ECA_TK_SHOT,0,0,0
|
||||
ECM_IDLE, SCM_IDLE,SCL_WT_ACQ,SDR_BUSY, 0,0,0,0
|
||||
ECM_ACQ, SCM_IDLE,SCL_RDY,SDR_BUSY, 0,0,0,0
|
||||
ECD_TK_SHOT, SCM_ACQ,SCL_RDY,SDR_BUSY, 0,0,0,0
|
||||
ECM_PROC, SCM_ACQ,SCL_RDY,SDR_BUSY, 0,0,0,EDR_IDLE
|
||||
ECD_TK_SHOT, SCM_PROC,SCL_RDY,SDR_IDLE, 0,0,0,EDR_BUSY
|
||||
ECM_PROC, SCM_PROC,SCL_TK_SHOT,SDR_BUSY, 0,0,0,0
|
||||
ECM_IDLE, SCM_PROC,SCL_TK_SHOT,SDR_BUSY, ECA_TK_SHOT,0,0,0
|
||||
ECM_ACQ, SCM_IDLE,SCL_WT_ACQ,SDR_BUSY, 0,0,0,0
|
||||
ECM_PROC, SCM_ACQ,SCL_RDY,SDR_BUSY, 0,0,0,EDR_IDLE
|
||||
ECM_IDLE, SCM_PROC,SCL_RDY,SDR_IDLE, 0,0,0,0
|
||||
22
site_ansto/TESTS/dingo_camera/test.txt
Normal file
22
site_ansto/TESTS/dingo_camera/test.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
ECM_ACQ(ECA_START): time remaining = 3907, total time = 3686
|
||||
ECM_ACQ(ECA_OPEN_SHUTR): time remaining = 539454, total time = 3686
|
||||
ECM_ACQ(ECA_ACQ_IMAGE): time remaining = 109, total time = 3686
|
||||
ECM_PROC(ECA_CLOSE_SHUTR): time remaining = 218, total time = 3686
|
||||
ECM_PROC(ECA_READ_IMAGE): time remaining = 328, total time = 3686
|
||||
ECM_PROC(ECA_READ_IMAGE): time remaining = 328, total time = 3686
|
||||
ECM_PROC(ECA_READ_IMAGE): time remaining = 328, total time = 3686
|
||||
ECM_IDLE(ECA_IDLE) <- Idle
|
||||
INPUT, CURR SCM,CURR SCL,CURR SDR, CA OUT,CM OUT,CD OUT,DR OUT
|
||||
ECM_IDLE, SCM_IDLE,SCL_RDY,SDR_IDLE, 0,0,0,0
|
||||
ECD_TK_SHOT, SCM_IDLE,SCL_RDY,SDR_IDLE, 0,0,0,EDR_BUSY
|
||||
ECM_IDLE, SCM_IDLE,SCL_TK_SHOT,SDR_BUSY, ECA_TK_SHOT,0,0,0
|
||||
ECM_IDLE, SCM_IDLE,SCL_WT_ACQ,SDR_BUSY, 0,0,0,0
|
||||
ECM_ACQ, SCM_IDLE,SCL_RDY,SDR_BUSY, 0,0,0,0
|
||||
ECD_TK_SHOT, SCM_ACQ,SCL_RDY,SDR_BUSY, 0,0,0,0
|
||||
ECM_PROC, SCM_ACQ,SCL_RDY,SDR_BUSY, 0,0,0,EDR_IDLE
|
||||
ECD_TK_SHOT, SCM_PROC,SCL_RDY,SDR_IDLE, 0,0,0,EDR_BUSY
|
||||
ECM_PROC, SCM_PROC,SCL_TK_SHOT,SDR_BUSY, 0,0,0,0
|
||||
ECM_IDLE, SCM_PROC,SCL_TK_SHOT,SDR_BUSY, ECA_TK_SHOT,0,0,0
|
||||
ECM_ACQ, SCM_IDLE,SCL_WT_ACQ,SDR_BUSY, 0,0,0,0
|
||||
ECM_PROC, SCM_ACQ,SCL_RDY,SDR_BUSY, 0,0,0,EDR_IDLE
|
||||
ECM_IDLE, SCM_PROC,SCL_RDY,SDR_IDLE, 0,0,0,0
|
||||
Reference in New Issue
Block a user