I'm designing a system that manages multiple hardware boards. Each board has a class that provides core functionality, such as:
- Device enumeration
- Capability enumeration (power management, polling, hardware info, etc.)
- Restart
- hardware information like serial number
Now I want to introduce a Maintenance mode.
Requirements for Maintenance mode:
- Software upgrades are only allowed when the board is in this state.
- LEDs on the board should switch to a maintenance configuration.
- Active alarms should be suppressed.
I see two ways of implementing this:
Inside the board class so that in clasd I would have a method called set_maintenance_mode that would suppress alarms and *turn on LEDs
Outside board class as a result of the MaintenanceStateEnabled event raised by the board
I'm inclined to go for 2nd solution, especially in case of alarms, but on the other hand, setting LEDs as a response for entering a maintenance mode is kinda a hardware thing, so this suggests that perhaps I should do this directly in a class representing hardware.
What do you think? How to decide what should be an action that happens directly when some method is called (eg, set maintenance mode configures the LED) and what should be like a side effect handled by an event handler (eg, Maintenance Mode Event handler changes the configuration of the LED)