github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/apis/v1/types.proto (about) 1 // Copyright 2019 Ewout Prangsma 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // Author Ewout Prangsma 16 // 17 18 syntax = "proto3"; 19 20 package binkynet.v1; 21 22 import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 23 24 option go_package = "github.com/binkynet/BinkyNet/apis/v1"; 25 option csharp_namespace = "BinkyNet.Apis.V1"; 26 27 // Empty message 28 message Empty {} 29 30 // Information about the command station 31 message CommandStationInfo { 32 // Unique identifier of the command station 33 string id = 1; 34 // Human readable description of the command station 35 string description = 2; 36 // Version of the command station in semantic versioning format. 37 // E.g. 1.0.4 38 string version = 3; 39 // Uptime of the command station in seconds. 40 int64 uptime = 4; 41 } 42 43 // Information about the local worker 44 message LocalWorkerInfo { 45 // Unique identifier of the local worker 46 string id = 1; 47 // Human readable description of the local worker 48 string description = 2; 49 // Version of the local worker in semantic versioning format. 50 // E.g. 1.0.4 51 string version = 3; 52 // Uptime of the local worker in seconds. 53 int64 uptime = 4; 54 // Hash of the current configuration 55 string config_hash = 5; 56 // IDs of all configured devices 57 repeated string configured_device_ids = 6; 58 // IDs of all configured objects 59 repeated string configured_object_ids = 7; 60 // IDs of all unconfigured devices 61 repeated string unconfigured_device_ids = 8; 62 // IDs of all unconfigured objects 63 repeated string unconfigured_object_ids = 9; 64 // HTTP(s) port to serve metrics on 65 int32 metrics_port = 10; 66 // If set to true, metrics are served over HTTPS, otherwise HTTP 67 bool metrics_secure = 11; 68 // Port this local worker is serving the LocalWorkerService on. 69 int32 local_worker_service_port = 12; 70 // If set, LocalWorkerService is served over TLS. 71 bool local_worker_service_secure = 13; 72 73 // If set, local worker implements LocalWorkerService.Reset 74 bool supports_reset = 101; 75 // If set, local worker implements LocalWorkerService.SetLocRequest 76 bool supports_set_loc_request = 102; 77 // If set, local worker implements LocalWorkerService.SetPowerRequest 78 bool supports_set_power_request = 103; 79 // If set, local worker implements LocalWorkerService.SetOutputRequest 80 bool supports_set_output_request = 104; 81 // If set, local worker implements LocalWorkerService.SetSwitchRequest 82 bool supports_set_switch_request = 105; 83 // If set, local worker implements LocalWorkerService.SetDeviceDiscoveryRequest 84 bool supports_set_device_discovery_request = 106; 85 } 86 87 // Request arguments for GetPowerRequests 88 message PowerRequestsOptions { 89 // If set, the network master must wait for an actual Power message 90 // to confirm the state transition. 91 // If not set, the network master assumes the power state is effective directly 92 // after sending the message. 93 bool manual_confirm = 1; 94 } 95 96 // Power message contains the requested & actual state of the power on the track. 97 message Power { 98 // Requested power state 99 PowerState request = 1; 100 // Actual power state 101 PowerState actual = 2; 102 } 103 104 // PowerState message contains the requested/actual state of the power on the track. 105 message PowerState { 106 // Power on/off 107 bool enabled = 1; 108 } 109 110 // Request arguments for GetLocRequests 111 message LocRequestsOptions { 112 // If set, the network master must wait for an actual Loc message 113 // to confirm the state transition. 114 // If not set, the network master assumes the state is effective directly 115 // after sending the message. 116 bool manual_confirm = 1; 117 } 118 119 // Direction of locs 120 enum LocDirection { 121 FORWARD = 0; 122 REVERSE = 1; 123 } 124 125 // Loc message is used to request/report the speed, direction & functions of a loc. 126 message Loc { 127 // Addres of the loc 128 string address = 1 [(gogoproto.customtype) = "ObjectAddress", (gogoproto.nullable) = false]; 129 // Requested state of the loc 130 LocState request = 2; 131 // Actual state of the loc 132 LocState actual = 3; 133 } 134 135 // LocState message is used to request/report the speed, direction & functions of a loc. 136 message LocState { 137 // Speed in steps 138 int32 speed = 1; 139 // Maximum speed steps of this loc 140 int32 speed_steps = 2; 141 // Direction "forward|reverse" 142 LocDirection direction = 3; 143 // State of functions 144 map<int32, bool> functions = 4; 145 } 146 147 // Sensor captures the current value of a sensor with specified address 148 message Sensor { 149 // Addres of the sensor 150 string address = 1 [(gogoproto.customtype) = "ObjectAddress", (gogoproto.nullable) = false]; 151 // Current state of the sensor 152 SensorState actual = 2; 153 } 154 155 // SensorState captures the current value of a sensor 156 message SensorState { 157 // Current value of the sensor 158 int32 value = 1; 159 } 160 161 // Request arguments for GetOutputRequests 162 message OutputRequestsOptions { 163 // If set, the network master must wait for an actual Output message 164 // to confirm the state transition. 165 // If not set, the network master assumes the state is effective directly 166 // after sending the message. 167 bool manual_confirm = 1; 168 // If set, pass only output requests that match this module ID. 169 string module_id = 2; 170 } 171 172 // Output is used to control a generic output device. E.g. a light. 173 message Output { 174 // Addres of the output 175 string address = 1 [(gogoproto.customtype) = "ObjectAddress", (gogoproto.nullable) = false]; 176 // Requested state of the output 177 OutputState request = 2; 178 // Actual state of the output 179 OutputState actual = 3; 180 } 181 182 // OutputState is used to request/report the state of a generic output device. E.g. a light. 183 message OutputState { 184 // Value of the output 185 int32 value = 1; 186 } 187 188 // Request arguments for GetSwitchRequests 189 message SwitchRequestsOptions { 190 // If set, the network master must wait for an actual Output message 191 // to confirm the state transition. 192 // If not set, the network master assumes the state is effective directly 193 // after sending the message. 194 bool manual_confirm = 1; 195 // If set, pass only switch requests that match this module ID. 196 string module_id = 2; 197 } 198 199 // Direction of switches 200 enum SwitchDirection { 201 STRAIGHT = 0; 202 OFF = 1; 203 } 204 205 // Switch is used to request/report the state of a generic switch. 206 message Switch { 207 // Addres of the switch 208 string address = 1 [(gogoproto.customtype) = "ObjectAddress", (gogoproto.nullable) = false]; 209 // Requested state of the switch 210 SwitchState request = 2; 211 // Actual state of the switch 212 SwitchState actual = 3; 213 } 214 215 // SwitchState describe the requested/actual state of a generic switch. 216 message SwitchState { 217 // Requested/current direction of the switch 218 SwitchDirection direction = 1; 219 // Set if the switch is currently in use. 220 // This can be used to power down a switch if it is not in use. 221 bool is_used = 2; 222 } 223 224 // TimePeriod indicates time of day in 4 periods. 225 enum TimePeriod { 226 MORNING = 0; 227 AFTERNOON = 1; 228 EVENING = 2; 229 NIGHT = 3; 230 } 231 232 // Clock is used to identity global time. 233 message Clock { 234 // Current time period. 235 TimePeriod period = 1; 236 // Current hours (0..23) 237 int32 hours = 2; 238 // Current minutes (0..59) 239 int32 minutes = 3; 240 // Current realworld time in seconds elapsed since January 1, 1970 UTC 241 int64 unixtime = 4; 242 } 243 244 // Device represents a hardware device such as a I2C chip. 245 message Device { 246 // ID of the device 247 string id = 1 [(gogoproto.customtype) = "DeviceID", (gogoproto.nullable) = false]; 248 // Type of the device. 249 // See devicetypes.go 250 string type = 2 [(gogoproto.customtype) = "DeviceType", (gogoproto.nullable) = false]; 251 // Logical address of the device on the local worker. 252 string address = 3; 253 } 254 255 // Object represents a logical object on the railway such as a switch. 256 message Object { 257 // ID of the object 258 string id = 1 [(gogoproto.customtype) = "ObjectID", (gogoproto.nullable) = false]; 259 // Type of the object. 260 // See objectypes.go 261 string type = 2 [(gogoproto.customtype) = "ObjectType", (gogoproto.nullable) = false]; 262 // Connections to devices used by this object 263 // The keys used in this map are specific to the type of object. 264 repeated Connection connections = 3; 265 // Optional configuration for this object. 266 // Keys & values are specific to the object type. 267 map<string, string> configuration = 4 [(gogoproto.castkey) = "ObjectConfigKey"]; 268 } 269 270 // Connection from an Object to a Device. 271 message Connection { 272 // Key is specific to the type of device. 273 string key = 1 [(gogoproto.customtype) = "ConnectionName", (gogoproto.nullable) = false]; 274 // Pins of devices to connect to 275 repeated DevicePin pins = 2; 276 // Optional configuration for this connection. 277 // Keys & values are specific to the connection name. 278 map<string, string> configuration = 3 [(gogoproto.castkey) = "ConfigKey"]; 279 } 280 281 // DevicePin identifies a hardware device and an index within that hardware address. 282 message DevicePin { 283 // Unique identifier of the device that this connection refers to. 284 string device_id = 1 [(gogoproto.customtype) = "DeviceID", (gogoproto.nullable) = false, (gogoproto.jsontag) = "device"]; 285 // Index on the device (1...) 286 uint64 index = 2 [(gogoproto.customtype) = "DeviceIndex", (gogoproto.nullable) = false]; 287 } 288 289 // Configuration for a local worker 290 message LocalWorkerConfig { 291 // Human readable alias for this local worker. 292 string alias = 1; 293 // List of devices that must be configured on this local worker. 294 repeated Device devices = 2; 295 // List of real world objects controlled by the local worker 296 repeated Object objects = 3; 297 // Timestamp of network manager in seconds since 1970. 298 int64 unixtime = 4; 299 // Hash of the configuration (excluding unixtime) 300 string hash = 5; 301 } 302 303 // Requested & actual state of a local worker 304 message LocalWorker { 305 // Unique identifier of the local worker 306 string id = 1; 307 // Requested configuration of the local worker 308 LocalWorkerConfig request = 2; 309 // Actual state of the local worker 310 LocalWorkerInfo actual = 3; 311 } 312 313 // Request to discover devices on a local worker 314 message DeviceDiscovery { 315 // ID of the module to perform the request on 316 string id = 1; 317 // Requested state of the discovery 318 DiscoverRequest request = 2; 319 // Actual state of the discovery 320 DiscoverResult actual = 3; 321 } 322 323 // DiscoverRequest is sent when the netmanager wants to local worker to 324 // probe its locally attached devices. 325 message DiscoverRequest { 326 // Unique ID of the request 327 int32 request_id = 1; 328 } 329 330 // DiscoverResult is returned in a response to a discover request by the netmanager. 331 message DiscoverResult { 332 // ID of local worker 333 string id = 1; 334 // The addresses that were found 335 repeated string addresses = 2; 336 }