-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattern: Enable/Disable of plugins #607
Comments
Some observations on approaches to implementing this, assuming the pub/sub routing table is in place:
|
Proposed message format: class ROVHeader
{
status: number; // 0 - Disposed, 1 - Active, 2 - Inactive
}
class ROVMessage
{
topic: string;
header: ROVHeader;
payload: any;
} From the firmware's point of view, it will treat individual sensors as a group of topics. To use the IMU as an example with the following state messages: IMU.State = { id: number, statusCode: number } On the firmware side, we condense the Topic names into the shortest possible descriptions. They do not necessarily need to be human readable, though they can be since topic names are strings. We can use the following convention for topic names when trying to use the "Requester Effector" pattern:
Firmware pseudocode example: // Choose an ID
m_id = 3;
// Register the IMU by sending a state message to say we're alive
SERIAL_PRINTF( "is:%d|%d", m_id, EStatus::ALIVE );
// Check for new message
auto msg = NComms::GetMessage();
// Listen for mode switch command ( "imr": "IMU Mode Request" )
if( msg->IsType( "imr" ) && msg->arguments[ 0 ] == m_id )
{
// Get requested mode
int requestedMode = msg->arguments[ 1 ];
// Send target mode as an acknowledgement ( "imt": "IMU Mode Target" )
// Sending a negative value could represent an error code. Contextual decision to make
SERIAL_PRINTF( "imt:%d|%d", m_id, requestedMode );
// Do a bunch of things that eventually gets us to that mode
// Whenever a mode change occurs, print the current mode ( "im": "IMU Current Mode" )
SERIAL_PRINTF( "im:%d|%d", m_id, m_mode );
} On the MCU manager side, classes can be used to model the devices as implemented on the firmware side. Serialization between the MCU and MCU Interface is a separate concern from the serialization (if any) used on the cockpit bus, but the message information should be translatable between the two. The MCU interface will translate firmware information into "ROVMessage" instances as described by the Cockpit system bus and handle publishing/subscribing to the available API that the firmware implements. Eventually the MCU interface should also be responsible for best effort reliability in terms of transport over the wire to the MCU. This could be a separate design discussion. |
In progress...
We have a single logical application that we are deploying across multiple ROVs products. We want the system to gracefully degrade functionality if the platform that it is deployed on is unable to service features available in the application. Ex, if the system does not have lights, we should not show buttons and options for enabling/disabling lights.
There are a couple of use cases to use to rationalize the design:
Assumptions:
Prior Art:
Overview:
Interrogating the bus for device state
To allow the last-value-cache service to support state propagation of multiple devices, the topic names are namespaced. Since there are potentially multiple of any device type in a vehicle that are sending the same class of messages, we need to be able to namespace by "topic:message:device".
This allows the listeners to take advantage of the wild cards support in many platforms. For instance, a system that tracks the status of all lights could subscribe to "light:state:*" to get the state of all light devices.
Regarding the state messages that are sent. If the device has meta data, such a position of light for instance, that meta data should be embedded in the state message. In that way, a client only has to listen to the single state message to get all relevant data about the device.
Every device needs to publish a basic "deviceClass:state" message that can be used to determine if the device is active in the system or not.
Devices should have sub-state messages such as "IMU:state:orientation:deviceid". This is useful for limiting the impact of high rate messages through the system.
Disabling devices
Devices can either fail, or be effectively turned off. In either case we need to be able to pass that state through the system.
In the case that a device is intentionally removed from the system (either turned off, reconfigured as another device, etc...) the device or its agent should update the state message for that device. So in the case of lights, if the light were disabled, we would expect the "light:state:pwm8light" message with a payload such as {device:"na"}. In the contract with the clients, the clients are then responsible for removing anything they have setup to work with that device.
In the case a device fails, it is the responsibility of the agent of the device to manage the health check for the device and to send the updated state message.
System with no lights
Normal light discovery sequence diagram
Edit
In the case of an ROV that does not have lights installed, the clients will fire up and listen for any light device state messages, but since none are on the bus, the client never creates the UI elements for interacting with the device.
The text was updated successfully, but these errors were encountered: