Skip to content

Commit

Permalink
Get latest packet state from backend on frontend initialization (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
aywaldron committed Oct 8, 2019
1 parent a32e330 commit f1feff9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions ait/gui/static/js/ait/gui/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class DygraphsBackend
if (!names) return

let row = [ this._plot._time.get(packet) ]
console.log("Received by plotting:")
console.log(packet)
// For each series of data, if it's in the current packet
// that we're updating, add the associated point. Otherwise,
Expand Down
6 changes: 6 additions & 0 deletions ait/gui/static/js/ait/gui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ function init () {
ait.events.emit(e.name, e.data)
});

m.request({ url: '/tlm/latest' }).then((latest) => {
ait.tlm.state = latest
console.log('requested latest tlm')
console.log(ait.tlm.state)
})

m.mount(root, { view: () => createMithrilNodes(elems) })
})
}
Expand Down
20 changes: 13 additions & 7 deletions ait/gui/static/js/ait/tlm.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ class TelemetryStream
this._socket = new WebSocket(url)
this._stale = 0
this._url = url
this._pkt_states = { }
m.request({ url: '/tlm/latest' }).then((latest) => {
this._pkt_states = latest
console.log('requested latest tlm from within stream')
console.log(ait.tlm.state)
})
console.log(this._pkt_states)

// Re-map telemetry dictionary to be keyed by a PacketDefinition
// 'id' instead of 'name'.
Expand Down Expand Up @@ -390,6 +395,7 @@ class TelemetryStream
let delta = data['data']
let dntoeus = data['dntoeus']

console.log('packet states:')
console.log(this._pkt_states)

// add delta to last full packet
Expand All @@ -405,13 +411,13 @@ class TelemetryStream
// delta is empty - request full packet from backend
if ( Object.keys(delta).length == 0 ) {
m.request({ url: '/tlm/latest' }).then( (latest) => {
packet_name = latest['packet']
delta = latest['data']
dntoeus = latest['dntoeus']
console.log('here')
console.log(delta)
console.log('requesting latest tlm')
console.log(latest)
//ait.tlm.state = latest
//packet_name = latest['packet']
//delta = latest['data']
//dntoeus = latest['dntoeus']
})
console.log(delta)
}

this._pkt_states[packet_name] = delta
Expand Down

0 comments on commit f1feff9

Please sign in to comment.