Page tree
Skip to end of metadata
Go to start of metadata

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.

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)

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.

Commands:

ByteNameUsageData Content
0x01Set Datasets a part of specified data or all if in blockmode2 bytes, index and value (or all values and no index if only one index exists or blockmode is on)
0x02Request Datarequests specified datano data
0x03Enable Streamrequest to get updates of specified datano data
0x04Disable Streamrequest to stop geting updates of specified datano data
0x05Response Dataresponse of a data requestfull dataset of given datatype
0x06Stream Dataupdate notification of given datatypefull dataset of given datatype
0x07Switch to 'Block' protocollswitch to blockmode, datatype has to have the same value as validationno data

Datatypes:

ByteNamenumber of bytes
0x01PositionNUM_TRAINS = 11
0x02DestinationNUM_TRAINS = 11
0x03Cleanup1
0x04Randommode1
0x05LampsNUM_LAMPS = 24
0x06Schedule(actually Station)NUM_TRAINS = 11
0x07SubstationNUM_TRAINS = 11

Running the WebProvider:

go into code/interface

run 'make web'

run './web'

Ideas for a new version:

  • 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.
  • Just use a different command to set the full dataset
  • 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)
  • Maybe add a minimum time between updates (prevents SSE and others from being flodded and the website actually crashing by a JavaScript DOS)


  • No labels