Wiki source code of JSON Communication
Last modified by GiorgioGhisotti on 2025/01/30 12:19
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | == Controller Output == | ||
| 2 | |||
| 3 | The controller executable outputs JSON data whenever certain internal values are updated. The JSON output contains one or more of the following fields. | ||
| 4 | |||
| 5 | (% class="wrapped" %) | ||
| 6 | |=((( | ||
| 7 | Field name | ||
| 8 | )))|=((( | ||
| 9 | Content type | ||
| 10 | )))|=(% colspan="1" %)(% colspan="1" %) | ||
| 11 | ((( | ||
| 12 | Value range | ||
| 13 | )))|=((( | ||
| 14 | Number of values | ||
| 15 | )))|=((( | ||
| 16 | Description | ||
| 17 | ))) | ||
| 18 | |((( | ||
| 19 | TrackSpeeds | ||
| 20 | )))|((( | ||
| 21 | int | ||
| 22 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 23 | ((( | ||
| 24 | 0-255 | ||
| 25 | )))|((( | ||
| 26 | 48 | ||
| 27 | )))|((( | ||
| 28 | The speed each track is set at. | ||
| 29 | ))) | ||
| 30 | |(% colspan="1" %)(% colspan="1" %) | ||
| 31 | ((( | ||
| 32 | TrackContacts | ||
| 33 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 34 | ((( | ||
| 35 | boolean | ||
| 36 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 37 | ((( | ||
| 38 | false-true | ||
| 39 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 40 | ((( | ||
| 41 | 96 | ||
| 42 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 43 | ((( | ||
| 44 | Whether or not a contact is triggered. Contacts on the same track are consecutive, for instance the contacts on track 0 are represented by indexes 0 and 1 in this array. | ||
| 45 | ))) | ||
| 46 | |(% colspan="1" %)(% colspan="1" %) | ||
| 47 | ((( | ||
| 48 | TrackPoints | ||
| 49 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 50 | ((( | ||
| 51 | boolean | ||
| 52 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 53 | ((( | ||
| 54 | false-true | ||
| 55 | |||
| 56 | (Branch=true,Straight=false) | ||
| 57 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 58 | ((( | ||
| 59 | 30 | ||
| 60 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 61 | ((( | ||
| 62 | Whether a given directional switch is set to straight or branch. | ||
| 63 | ))) | ||
| 64 | |(% colspan="1" %)(% colspan="1" %) | ||
| 65 | ((( | ||
| 66 | TrainPositions | ||
| 67 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 68 | ((( | ||
| 69 | int | ||
| 70 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 71 | ((( | ||
| 72 | 0-47 | ||
| 73 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 74 | ((( | ||
| 75 | 11 | ||
| 76 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 77 | ((( | ||
| 78 | The track each train is currently on. | ||
| 79 | ))) | ||
| 80 | |(% colspan="1" %)(% colspan="1" %) | ||
| 81 | ((( | ||
| 82 | Bell | ||
| 83 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 84 | ((( | ||
| 85 | boolean | ||
| 86 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 87 | ((( | ||
| 88 | false-true | ||
| 89 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 90 | ((( | ||
| 91 | 1 | ||
| 92 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 93 | ((( | ||
| 94 | Whether the bell is ringing or not. | ||
| 95 | ))) | ||
| 96 | |(% colspan="1" %)(% colspan="1" %) | ||
| 97 | ((( | ||
| 98 | Gate0 | ||
| 99 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 100 | ((( | ||
| 101 | boolean | ||
| 102 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 103 | ((( | ||
| 104 | false-true | ||
| 105 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 106 | ((( | ||
| 107 | 1 | ||
| 108 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 109 | ((( | ||
| 110 | Whether gate 0 is raised or not. | ||
| 111 | ))) | ||
| 112 | |(% colspan="1" %)(% colspan="1" %) | ||
| 113 | ((( | ||
| 114 | Gate1 | ||
| 115 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 116 | ((( | ||
| 117 | boolean | ||
| 118 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 119 | ((( | ||
| 120 | false-true | ||
| 121 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 122 | ((( | ||
| 123 | 1 | ||
| 124 | )))|(% colspan="1" %)(% colspan="1" %) | ||
| 125 | ((( | ||
| 126 | Whether gate 1 is raised or not. | ||
| 127 | ))) | ||
| 128 | |||
| 129 | \\ | ||
| 130 | |||
| 131 | == Controller Input == | ||
| 132 | |||
| 133 | The controller accepts the following input format read from a JSON file. The JSON file is called input.json and is found in $XDG_CONFIG_HOME/railway if XDG_CONFIG_HOME is set or from $HOME/.config/railway if it isn't. | ||
| 134 | |||
| 135 | (% class="relative-table wrapped" style="width: 99.9208%;" %) | ||
| 136 | |=((( | ||
| 137 | Field name | ||
| 138 | )))|=((( | ||
| 139 | Content type | ||
| 140 | )))|=((( | ||
| 141 | Value range | ||
| 142 | )))|=((( | ||
| 143 | Number of values | ||
| 144 | )))|=((( | ||
| 145 | Description | ||
| 146 | ))) | ||
| 147 | |((( | ||
| 148 | Action | ||
| 149 | )))|((( | ||
| 150 | int | ||
| 151 | )))|((( | ||
| 152 | 0-MAXINT,0-10, 0-47 | ||
| 153 | )))|((( | ||
| 154 | 3 | ||
| 155 | )))|((( | ||
| 156 | Contains the description of a new train action in the format: [ action id, train id, destination ] | ||
| 157 | ))) |