chiark / gitweb /
new embryonic program "safety"
authorian <ian>
Tue, 18 Jan 2005 23:57:59 +0000 (23:57 +0000)
committerian <ian>
Tue, 18 Jan 2005 23:57:59 +0000 (23:57 +0000)
hostside/.cvsignore
hostside/Makefile
hostside/layoutinfo.h [new file with mode: 0644]
hostside/safety.c [new file with mode: 0644]
hostside/safety.h [new file with mode: 0644]

index e8f16d8d905c5712d341333dcda7c3ffe8022298..92602c04b022abb7a633c3e7c8bbcc1f1dec9567 100644 (file)
@@ -1,2 +1,3 @@
 hostside
+safety
 t
index 462818a37e9b7eb173541f054cb4aca4f3ae8788..bee9442bce9ca413f28683b9d92a9d5049947d17 100644 (file)
@@ -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 (file)
index 0000000..60424e8
--- /dev/null
@@ -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 (file)
index 0000000..b0a2db0
--- /dev/null
@@ -0,0 +1,10 @@
+/**/
+
+#include <stdio.h>
+
+#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 (file)
index 0000000..3eb460b
--- /dev/null
@@ -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*/