Basic infrastructure for elevators

This commit is contained in:
ronreg-ribdev 2020-06-01 00:24:08 -07:00
parent 4fd6a5ee25
commit ed15a2a5a7
2 changed files with 28 additions and 1 deletions

View File

@ -20,7 +20,11 @@ export class Subscription {
this.handleError.bind(this)); this.handleError.bind(this));
*/ */
api.bind('/bartstations', 'PUT', api.authTokens.ship, 'bartinfo', api.bind("/elevators", "PUT", api.authTokens.ship, "bartinfo",
this.handleEvent.bind(this),
this.handleError.bind(this));
api.bind("/bartstations", "PUT", api.authTokens.ship, 'bartinfo',
this.handleEvent.bind(this), this.handleEvent.bind(this),
this.handleError.bind(this)); this.handleError.bind(this));

View File

@ -79,6 +79,12 @@
=/ req bart-api-request-stations:cc =/ req bart-api-request-stations:cc
[%pass /bartstationrequest %arvo %i %request req out] [%pass /bartstationrequest %arvo %i %request req out]
[~[bart-station-request] this] [~[bart-station-request] this]
?: ?=([%elevators *] path)
=/ elevator-status-request
=/ out *outbound-config:iris
=/ req bart-api-elevator-status:cc
[%pass /elevators %arvo %i %request req out]
[~[elevator-status-request] this]
?: ?=([%http-response *] path) ?: ?=([%http-response *] path)
`this `this
?. =(/ path) ?. =(/ path)
@ -99,6 +105,12 @@
?> ?=(%o -.value) ?> ?=(%o -.value)
=/ update=json (pairs:enjs:format [update+o+p.value ~]) =/ update=json (pairs:enjs:format [update+o+p.value ~])
[%give %fact ~[/bartstations] %json !>(update)]~ [%give %fact ~[/bartstations] %json !>(update)]~
::
[%elevators *]
=/ value=json (parse-elevator-status-response:cc client-response.sign-arvo)
?> ?=(%o -.value)
=/ update=json (pairs:enjs:format [update+o+p.value ~])
[%give %fact ~[/elevators] %json !>(update)]~
== ==
[http-moves this] [http-moves this]
?. ?=(%bound +<.sign-arvo) ?. ?=(%bound +<.sign-arvo)
@ -154,6 +166,17 @@
(pairs:enjs [name+s+p.name abbr+s+p.abbr ~]) (pairs:enjs [name+s+p.name abbr+s+p.abbr ~])
(pairs:enjs [[%stations %a abbr-and-name] ~]) (pairs:enjs [[%stations %a abbr-and-name] ~])
:: ::
++ bart-api-elevator-status
^- request:http
=/ url (crip "{bart-api-url-base}/stn.aspx?cmd=stns&key={bart-api-key}&json=y")
=/ headers [['Accept' 'application/json']]~
[%'GET' url headers *(unit octs)]
++ parse-elevator-status-response
|= response=client-response:iris
^- json
=, format
(pairs:enjs [[%yolo %b %.y] ~])
::
++ poke-handle-http-request ++ poke-handle-http-request
|= =inbound-request:eyre |= =inbound-request:eyre
^- simple-payload:http ^- simple-payload:http