2 * declarations for realtime daemon
9 #include "auproto-pic.h"
22 #include <sys/types.h>
32 #include "../layout/layout-data.h"
34 typedef struct Segment Segment;
35 typedef struct Train Train;
37 /*---------- from retransmit.c ----------*/
39 typedef struct RetransmitRelaxedNode RetransmitRelaxedNode;
40 typedef union RetransmitUrgentNode RetransmitUrgentNode;
41 typedef unsigned Retransmit__Time;
43 /* Contents of the retransmission nodes is generally all for use by
44 * retransmit.c only; as a special exception, caller may edit pi
45 * directly. Normally, though, pi is set by supplying an NMRA
46 * command to one of the _queue functions; iff the Nmra* is
47 * non-null, _queue will add an NMRA checksum and update pi.
49 struct RetransmitRelaxedNode {
51 DLIST_NODE(RetransmitRelaxedNode) rr;
53 union RetransmitUrgentNode {
56 RetransmitRelaxedNode relaxed;
58 Retransmit__Time when;
59 DLIST_NODE(RetransmitUrgentNode) queue;
63 void retransmit_start(void);
64 void retransmit_something(void);
66 void retransmit_relaxed_queue(RetransmitRelaxedNode *rn, Nmra *n);
67 void retransmit_relaxed_requeue(RetransmitRelaxedNode *rn, Nmra *n);
68 void retransmit_relaxed_cancel(RetransmitRelaxedNode *rn);
70 void retransmit_urgent_queue(RetransmitUrgentNode *rn, Nmra *n);
71 void retransmit_urgent_queue_relaxed(RetransmitUrgentNode *urg, Nmra *n);
72 void retransmit_urgent_requeue(RetransmitUrgentNode *rn, Nmra *n);
73 void retransmit_urgent_cancel(RetransmitUrgentNode *rn);
75 /* ... NB: these are NOT idempotent. Use _requeue it's queued;
76 * _requeue is just _cancel followed by queue. */
78 /*---------- features, filled in by record, used by features.c ----------*/
80 #define FEATURESADDR_TRANSMITS 4
81 /* 0..2 are func0to4 func5to8 func9to12 and speed cmd
82 * pi.l is 0 if not transmitting */
84 typedef struct FeaturesAddr {
85 struct FeaturesAddr *next;
87 RetransmitRelaxedNode rn[FEATURESADDR_TRANSMITS];
92 int bitval; /* may have no or several bits set */
93 int speedstep; /* -ve means backwards; 0 means not to use motor for feat */
96 typedef struct FeaturesTarget {
97 struct FeaturesTarget *next;
99 char *featchs; /* null-terminated */
100 FeaturesFeature **feats; /* same order as featchs */
104 extern Train *trains;
105 extern Segment *segments;
107 extern FeaturesTarget *feattargs;
108 extern FeaturesAddr *feataddrs;
110 /*---------- global variables, in realtime.c ----------*/
112 extern CommandInput cmdi;
113 extern int picio_send_noise;
115 #define UPO (&(cmdi.out))
117 /*---------- from/for startup.c ----------*/
119 #include "stastate.h"
121 void sta_startup(void);
122 void sta_finalising_done(void);
123 void serial_moredata(PicInsn *buf);
125 extern StartupState sta_state;
126 extern const char *const stastatelist[];
128 void resolve_begin(void); /* from resolve.c */
129 int resolve_complete(void);
130 void resolve_motioncheck(void);
132 /*---------- from/for record.c and persist.c ----------*/
134 void records_parse(const char **argv);
135 void persist_entrails_interpret(void);
136 void persist_entrails_run_converter(void);
137 void persist_install(void);
139 extern const char *persist_fn;
140 extern char *persist_record_converted;
142 void persist_map_veryearly(void);
144 /*---------- from/for realtime.c ----------*/
146 void oupicio(const char *dirn, const PicInsnInfo *pii, int objnum);
147 void ouhex(const char *word, const Byte *command, int length);
149 void serial_transmit(const PicInsn *pi);
151 /*---------- from actual.c ----------*/
153 int picinsn_polarity_testbit(const PicInsn *pi, const SegmentInfo *segi);
154 /* this belongs in {au,skel}proto-pic.[ch] really but it's
155 * more convenient here. */
157 /*---------- from movpos.c ----------*/
159 void points_turning_on(void);
160 void points_all_abandon(void);
162 /*---------- tbi ----------*/
164 void choreographers_all_abandon(void);
169 #define PERSIST_CONVERT_OPTION "--persist-convert-entrails"
173 #define CTYPE(isfoobar,ch) (isfoobar((unsigned char)(ch)))
175 #endif /*REALTIME_H*/