From: ian Date: Tue, 18 Jan 2005 23:57:59 +0000 (+0000) Subject: new embryonic program "safety" X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=1faeb453191a380159db0150d5f4f96a65cd6c7d;p=trains.git new embryonic program "safety" --- diff --git a/hostside/.cvsignore b/hostside/.cvsignore index e8f16d8..92602c0 100644 --- a/hostside/.cvsignore +++ b/hostside/.cvsignore @@ -1,2 +1,3 @@ hostside +safety t diff --git a/hostside/Makefile b/hostside/Makefile index 462818a..bee9442 100644 --- a/hostside/Makefile +++ b/hostside/Makefile @@ -1,6 +1,6 @@ # -TARGETS= hostside +TARGETS= hostside safety CFLAGS= -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes \ -Wpointer-arith -Wwrite-strings -g $(OPTIMISE) OPTIMISE= -O2 @@ -14,5 +14,7 @@ encode.o: nmra-packets.h main.o: nmra-packets.h %.c: hostside.h +safety.o: safety.h layoutinfo.h + clean: rm -f *.o $(TARGETS) diff --git a/hostside/layoutinfo.h b/hostside/layoutinfo.h new file mode 100644 index 0000000..60424e8 --- /dev/null +++ b/hostside/layoutinfo.h @@ -0,0 +1,4 @@ +/* will be autogenerated at some point */ + +#define NUM_TRAINS 2 +#define NUM_SEGMENTS 100 diff --git a/hostside/safety.c b/hostside/safety.c new file mode 100644 index 0000000..b0a2db0 --- /dev/null +++ b/hostside/safety.c @@ -0,0 +1,10 @@ +/**/ + +#include + +#include "safety.h" + +int main(void) { + printf("%d\n",(int)sizeof(State)); + return 0; +} diff --git a/hostside/safety.h b/hostside/safety.h new file mode 100644 index 0000000..3eb460b --- /dev/null +++ b/hostside/safety.h @@ -0,0 +1,29 @@ +/**/ + +#ifndef SAFETY_H +#define SAFETY_H + +typedef unsigned short TrainIx; +typedef unsigned short SegmentIx; + +typedef struct { + SegmentIx foremost; + unsigned justarrived:1, reverse:1; + unsigned char speed; /* non-negative, units of 4mm/s */ +} Train; + +typedef struct { + unsigned present_now:1, present_future:1, + detectable_now:1, detectable_future:1; + TrainIx owner; + /*polarity?*/ +} Segment; + +#include "layoutinfo.h" + +typedef struct { + Train trains[NUM_TRAINS]; + Segment segments[NUM_SEGMENTS]; +} State; + +#endif /*SAFETY_H*/