Session Basics#
Sessions are a logical way to organise telemetry — like a file system.
An RTA Session does not have to be a 1:1 match for a telemetry recording, and there is no prescribed file or database layout. An RTA service can present any bounded subset of telemetry as a session, with associated metadata and descriptors.
The RTA API represents sessions in JSON, like this:
{
"sessions": [
{
"identity": "f10f4a19-3831-4dd6-a178-faa94931a5b0",
"state": "closed",
"timestamp": "2021-05-06T18:58:56.20289+01:00",
"startTimestamp": "2021-05-06T18:58:56.20289+01:00",
"endTimestamp": "2021-05-06T19:08:56.20289+01:00",
"timeRange": {
"startTime": 1620323936202890000,
"endTime": 1620324536202890000
},
"identifier": "Session Demo 06 May 2021 18:58",
"details": {
"Lab Tech": "Bob Jones",
"Run": 17
},
"configBindings": [
{
"identifier": "6d711dbc-5f0d-47d2-b127-8c9d20bcec01",
"channelOffset": 0
}
]
}
]
}
Review the Session Model for more detail.
The Toolkit Session Service provides an API to create and modify sessions using gRPC.
This C# sample — using the MAT.OCS.RTA.Toolkit.API.GrpcClients NuGet Package — produces an equivalent result:
// re-use the channel across service calls
using var sessionChannel = GrpcChannel.ForAddress("http://localhost:2652");
var sessionClient = new SessionStore.SessionStoreClient(sessionChannel);
await sessionClient.CreateOrUpdateSessionAsync(new CreateOrUpdateSessionRequest
{
Identity = "f10f4a19-3831-4dd6-a178-faa94931a5b0",
CreateIfNotExists = new()
{
Identifier = "Session Demo 06 May 2021 18:58",
Timestamp = "2021-05-06T18:58:56.20289+01:00",
State = (int)SessionState.Closed
},
Updates =
{
new SessionUpdate
{
SetTimeRange = new()
{
StartTime = 1620323936202890000,
EndTime = 1620324536202890000
}
},
new SessionUpdate
{
SetDetailsJson = new()
{
Json = new JObject
{
["Lab Tech"] = "Bob Jones",
["Run"] = 17
}.ToString()
}
},
new SessionUpdate
{
SetConfigBindings = new()
{
ConfigBindings =
{
new ConfigBinding
{
Identifier = "6d711dbc-5f0d-47d2-b127-8c9d20bcec01"
}
}
}
}
}
});