chiark / gitweb /
working on safety thing
authorian <ian>
Fri, 4 Feb 2005 23:45:51 +0000 (23:45 +0000)
committerian <ian>
Fri, 4 Feb 2005 23:45:51 +0000 (23:45 +0000)
hostside/safety.c
hostside/safety.h

index b0a2db06dcc6f09bf3e6a2cd2e1aea166ac50a6f..cbd5c280175cd30ab787d6c3af4e9e65d93aa8a4 100644 (file)
@@ -4,6 +4,14 @@
 
 #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;
index 3eb460b1c0d13f8a4991fbc8ff932eb15b8ced22..7e7100eecd342ede55ebee4e4736d44111b63d1f 100644 (file)
@@ -5,25 +5,42 @@
 
 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*/