Open jimjeffers opened 2 years ago
Thanks @jimjeffers .
While we focus on this, let me also copy some of my initial reactions on slack a couple months ago, that I think are still relevant, at least to some extent:
I would replace “Mission” to “CommandStatus” (or something “command” related) because submitting a mission is one of the many possible commands. Scheduling is for commands in general
We know there are several aspects TBD, but I’m adding an endpoint with preliminaries for this “command status” information. Initially, it will just provide the complete list of command and run events belonging to the given deploymentId.
the new endpoint is GET deployments/commandStatus
As captured in my notes:
GET /deployments/commandStatus?deploymentId=<id>
endpoint
run
or command
; by default, both are reported.GET /deployments?deploymentId=<id>
)status
, which is just TBD
for nowrelatedEvents
, which is empty for now
Again, very preliminary, just mainly as a basis to elaborate as we get input from
@bkieft
and others when the time comes.For the ongoing Brizo deployment, you can try:
curlie 'https://okeanids.mbari.org/TethysDash/api/deployments/commandStatus?deploymentId=3000418' $TD_AUTH
for reference, just ran that request with ongoing Pontus deployment:
curlie -s 'https://okeanids.mbari.org/TethysDash/api/deployments/commandStatus?deploymentId=3000426' $TD_AUTH
{
"result": {
"deploymentInfo": {
"deploymentId": 3000426,
"vehicleName": "pontus",
"name": "Pontus 28 FishCam",
"path": "2022-10-11",
"startEvent": {
"unixTime": 1666199462487,
"state": 1,
"eventId": 17249934
},
"launchEvent": {
"unixTime": 1666199472564,
"eventId": 17249961,
"note": "Vehicle in water"
}
},
"eventTypes": "run,command",
"commandStatuses": [
{
"event": {
"eventId": 17250901,
"vehicleName": "pontus",
"unixTime": 1666217837722,
"isoTime": "2022-10-19T22:17:17.722Z",
"eventType": "command",
"user": "Brian Kieft",
"data": "schedule resume",
"text": "schedule resume"
},
"status": "TBD",
"relatedEvents": [
]
},
{
"event": {
"eventId": 17249964,
"vehicleName": "pontus",
"unixTime": 1666201236613,
"isoTime": "2022-10-19T17:40:36.613Z",
"eventType": "run",
"user": "Brian Kieft",
"data": "load Science/sci2.tl;set sci2.MissionTimeout 8 h;set sci2.Lat1 36.32285 degree;set sci2.Lon1 -121.943979 degree;set sci2.Lat2 36.402559 degree;set sci2.Lon2 -122.240232 degree;set sci2.YoYoMaxDepth 35 m;set sci2.MaxDepth 50 m;run"
},
"status": "TBD",
"relatedEvents": [
]
},
{
"event": {
"eventId": 17249962,
"vehicleName": "pontus",
"unixTime": 1666201160299,
"isoTime": "2022-10-19T17:39:20.299Z",
"eventType": "command",
"user": "Brian Kieft",
"note": "Vehicle in water",
"data": "restart logs",
"text": "restart logs"
},
"status": "TBD",
"relatedEvents": [
]
}
]
}
}
run
and command
are reportedrun
type refers to missions per se, and command
refers to any other commandCan we get past and future missions?
(I'll assume both past and future here refer to the relevant deployment, typically the ongoing deployment -- unless perhaps during a playback exercise as supported by dash4)
That commandStatus
endpoint is in fact intended to provide all commands and missions that have been issued wrt the given deployment. What we still need is the appropriate logic to determine the status for each entry, as well as:
@carueda this looks great. If I'm understanding correctly - we can get the past missions (runs) and commands via the commandStatus attribute in the response and that we would eventually be able to query scheduled or queued commands/runs once we get functionality in place.
For the commandStatus
results -- the unixTime is the starting point correct? How would I determine the end timestamp of a run? Would it effectively be the startTime of the next event in the list? If it's the most recent item how would I determine the end time of that run? I'm thinking we'd have to check against the actual deployment events to determine if the deployment is still running and then deduce the most recent run is ongoing or in fact terminated?
For ease of use it might be best just to return two timestamps on each event indicating the end time or null if a run is considered ongoing. Thoughts?
the unixTime is the starting point correct?
correct.
How would I determine the end timestamp of a run? Would it effectively be the startTime of the next event in the list?
I don't think so. Still something we'll need to think through, but perhaps such "endTime" would be for commands/missions that have already been fully executed by the vehicle. That said, my general idea in the response above has been that the status
attribute is actually accompanied with other associated attrs, in particular including a corresponding timestamp.
Will you need an endTime for missions that have been scheduled but not yet completed? In these cases I think you would instead be using the estimated "mission duration" discussed elsewhere... or are you suggesting that we include some sort of "estimatedEndTime" for the relevant entries here?
@carueda I would prefer that the API could send over the endTime or status + timestamp. The less derived state on the client the better. I was originally thinking the estimated duration, distance, and depth was all handled server side. I can look into replicating the existing solution on the current dash client though. It'd be best if this routine was centralized somewhere on the server as a single source of truth rather than two different clients implementing these predictions in one form or another.
@jimjeffers Agree in general, but some "derived state on the client" will still need to happen such that, while the user is going through the mission preparation wizard sequence (say, when editing a waypoint's latitude value, or dragging the tentative waypoints on the map), it would be more responsive to reflect the estimates on the fly without necessarily relying on the backend for them (at least for duration, distance, and the like). As mentioned those are rather easy to compute UI-side. On the other hand, we can think a bit more carefully about estimates like "depth profile" associated to the planned waypoint trajectory (though a basic point-to-point strategy could also be handled UI-side using the google elevation api...)
@carueda I'll take a stab at it on the client this week.
This portion of the application is currently stubbed with a mock response:
The mock response we propose looks like this but you could add more data to make this more reusable as you see fit. The main gist is we need a straightforward way to request all applicable missions and or commands executed on a per deployment basis. Here is the complete body of attributes:
And here is how we mocked a simplified response for testing purposes:
Some questions: