Show last authors
1 The Communication is handled by a WebProvider, wich is a central server in a star pattern. This server waits for clients and applies theire changes and distributes these changes to all interested clients.
2
3 The provided WebProvider listens on port 8089 and is accesed by the Controller which does a protocoll-upgrade to enable full block data-writeing and PHP-instances which provide data for a webside or ServerSendEvents(SSE)
4
5 The communication protocoll is a use-case limmited binary protocol which sends a one byte command followed by a one byte datatype byte followed by a specific number of data bytes specified by the command and datatype.
6
7 === Commands: ===
8
9 (% class="wrapped" %)
10 |=(((
11 Byte
12 )))|=(((
13 Name
14 )))|=(((
15 Usage
16 )))|=(% colspan="1" %)(% colspan="1" %)
17 (((
18 Data Content
19 )))
20 |(((
21 0x01
22 )))|(((
23 Set Data
24 )))|(((
25 sets a part of specified data or all if in blockmode
26 )))|(% colspan="1" %)(% colspan="1" %)
27 (((
28 2 bytes, index and value (or all values and no index if only one index exists or blockmode is on)
29 )))
30 |(((
31 0x02
32 )))|(((
33 Request Data
34 )))|(((
35 requests specified data
36 )))|(% colspan="1" %)(% colspan="1" %)
37 (((
38 no data
39 )))
40 |(((
41 0x03
42 )))|(((
43 Enable Stream
44 )))|(((
45 request to get updates of specified data
46 )))|(% colspan="1" %)(% colspan="1" %)
47 (((
48 no data
49 )))
50 |(((
51 0x04
52 )))|(((
53 Disable Stream
54 )))|(((
55 request to stop geting updates of specified data
56 )))|(% colspan="1" %)(% colspan="1" %)
57 (((
58 no data
59 )))
60 |(((
61 0x05
62 )))|(((
63 Response Data
64 )))|(((
65 response of a data request
66 )))|(% colspan="1" %)(% colspan="1" %)
67 (((
68 full dataset of given datatype
69 )))
70 |(((
71 0x06
72 )))|(((
73 Stream Data
74 )))|(((
75 update notification of given datatype
76 )))|(% colspan="1" %)(% colspan="1" %)
77 (((
78 full dataset of given datatype
79 )))
80 |(% colspan="1" %)(% colspan="1" %)
81 (((
82 0x07
83 )))|(% colspan="1" %)(% colspan="1" %)
84 (((
85 Switch to 'Block' protocoll
86 )))|(% colspan="1" %)(% colspan="1" %)
87 (((
88 switch to blockmode, datatype has to have the same value as validation
89 )))|(% colspan="1" %)(% colspan="1" %)
90 (((
91 no data
92 )))
93
94 === Datatypes: ===
95
96 (% class="wrapped" %)
97 |=(((
98 Byte
99 )))|=(((
100 Name
101 )))|=(((
102 number of bytes
103 )))
104 |(((
105 0x01
106 )))|(((
107 Position
108 )))|(((
109 NUM_TRAINS = 11
110 )))
111 |(((
112 0x02
113 )))|(((
114 Destination
115 )))|(((
116 NUM_TRAINS = 11
117 )))
118 |(((
119 0x03
120 )))|(((
121 Cleanup
122 )))|(((
123 1
124 )))
125 |(((
126 0x04
127 )))|(((
128 Randommode
129 )))|(((
130 1
131 )))
132 |(((
133 0x05
134 )))|(((
135 Lamps
136 )))|(((
137 NUM_LAMPS = 24
138 )))
139 |(((
140 0x06
141 )))|(((
142 Schedule(actually Station)
143 )))|(((
144 NUM_TRAINS = 11
145 )))
146 |(((
147 0x07
148 )))|(((
149 Substation
150 )))|(((
151 NUM_TRAINS = 11
152 )))
153
154 === Running the WebProvider: ===
155
156 go into code/interface
157
158 run 'make web'
159
160 run './web'
161
162 = Ideas for a new version: =
163
164 (% style="list-style-type: square;" %)
165 * Don't use fixed datatypes, instead add a command to create a datatype by name and bytesize, which returns a datatypenumber, uniqe for each name, disconnects if size doesn't match with existing.
166 * Just use a different command to set the full dataset
167 * don't send updates to a client if the only change was caused by this client (just skip the current client on setting the dirty flag)
168 * Maybe add a minimum time between updates (prevents SSE and others from being flodded and the website actually crashing by a JavaScript DOS)
169
170 \\