#include "safety.h"
+
+void safety_notify_detection(State *s, SegmentIx seg) {
+ if (s->seg[seg].detectable_now) return;
+ if (!s->seg[seg].detectable_future)
+ panic(NONE, seg, "unexpected detection");
+
+
+
int main(void) {
printf("%d\n",(int)sizeof(State));
return 0;
typedef unsigned short TrainIx;
typedef unsigned short SegmentIx;
+typedef unsigned char Speed; /* non-negative, units of 4mm/s */
typedef struct {
SegmentIx foremost;
unsigned justarrived:1, reverse:1;
- unsigned char speed; /* non-negative, units of 4mm/s */
-} Train;
+ Speed speed;
+} TrainState;
typedef struct {
unsigned present_now:1, present_future:1,
- detectable_now:1, detectable_future:1;
+ detectable_now:1, detectable_future:1,
+ sideways:1;
TrainIx owner;
/*polarity?*/
-} Segment;
+} SegmentState;
-#include "layoutinfo.h"
typedef struct {
- Train trains[NUM_TRAINS];
- Segment segments[NUM_SEGMENTS];
+ unsigned next_rev:1;
+ SegmentIx next;
+
+} SegmentLink;
+
+typedef struct {
+ SegmentIx backwards, forwards, sideways;
+} SegmentInfo;
+
+typedef struct {
+ Speed maxspeed;
+
+} TrainInfo;
+
+
+typedef struct {
+ TrainState traNUM_TRAINS];
+ SegmentState seg[NUM_SEGMENTS];
} State;
#endif /*SAFETY_H*/