pez-globo / pufferfish-software

All software for the Pufferfish ventilator.
Apache License 2.0
0 stars 1 forks source link

Reimplement state synchronization in firmware for nestable schedules #398

Closed ethanjli closed 3 years ago

ethanjli commented 3 years ago

This PR prepares the firmware for implementation of the Event Synchronization application-level protocol layer by refactoring the firmware's implementation of the State Synchronization protocol layer (but without changing the State Synchronization protocol specification), specifically:

Making schedules nestable is required for implementation of the Event Synchronization protocol, but it also makes our schedules for State Synchronization more maintainable. For example, to send a SensorMeasurements every 30 ms and the other state segments every 90 ms, the previous implementation required us to specify the schedule this way:

Schedule: Message Type duration
SensorMeasurements 10 ms
CycleMeasurements 10 ms
Parameters 10 ms
SensorMeasurements 10 ms
AlarmLimits 10 ms
NextLogEvents 10 ms
SensorMeasurements 10 ms
ActiveLogEvents 10 ms
AlarmMute 10 ms

While the new implementation allows us to specify the same schedule this way:

The Event Synchronization implementation will use SequentialStateSenders for a significant part of its implementation: there will be an EventSender class which implements the StateSender interface, and it will have its own internal SequentialStateSenders (though the SequentialStateSender will be further modified to allow skipping over schedule entries from which no output is available).

This PR also performs some other refactoring and interface changes:

Because all unit tests written for StateSynchronizer were about testing its timing-related functionality, and timing-related functionality is no longer provided in its replacement class SequentialStateSender, I have fully removed the unit tests which were written for StateSynchronizer. We should hold off on writing unit tests for Protocols/Application/States.h, as the interfaces of the classes may undergo further changes for implementation of the Event Synchronization protocol layer.

ethanjli commented 3 years ago

@rohanpurohit For this PR, let's merge after you test this to look for any regressions - the firmware should still behave the same as before this PR.

For records-keeping:

  1. This project is licensed under Apache License v2.0 for any software, and Solderpad Hardware License v2.1 for any hardware - do you agree that your contributions to this project will be under these licenses, too? Yes
  2. Were any of these contributions also part of work you did for an employer or a client? No
  3. Does this work include, or is it based on, any third-party work which you did not create? No