133 lines
3.2 KiB
C
133 lines
3.2 KiB
C
|
|
#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;
|
|
}
|