[FEATURE]-Add event when ConfigWriter writes the file
Is your feature request related to a problem? Please describe. The class ReconfigurableDevice (BridgeableReconfigurableDevice) contains a method CustomSetConfig(DeviceConfig config) which uses ConfigWriter.UpdateDeviceConfig to write new config data to file. The ConfigWriter uses a Timer mechanism to rate limit the file write. This can take up to 30 sec. There is no event fired when write is complete and no return from the method CustomSetConfig(). So at the device implementation there is no way to know if a file has been successfully written or not. There is also a circumstance where a device can make the write using. CustomWriteConfig and restart the app within the 30sec window. This would result in the new values not being written.
Describe the solution you'd like
- Add an event to ConfigWriter and ReconfigurableDevice when the file write is completed successfully.
- Write any pending files on a reboot or program reset
I see no reason not to add the event as described in item 1.
For item 2, we'd have to test and make sure that we could successfully perform a file write after the ProgramStopping event fires on the ControlSystem class. I believe we may have investigated this previously and were advised by Crestron that we likely wouldn't have time to write a file and this was advised against. Would be good to reconfirm.
Awesome I changed the title to "Add event".
Agreed on the issues with write on the ProgramStopping. Essentials does it for debug but with the config file there's no way to control the size. Perhaps we just shorten the window in the next version. 30seconds is a long time and this would reduce the opportunity for this issue (reboot before the filer is written) to happen.
Agreed. 30s was a somewhat arbitrary time interval. Shortening to something like 10s would achieve a similar effect in preventing multiple subsequent file write operations when multiple values change on different reconfigurable devices while reducing the risks of data loss in the debounce period 👍
@jtalborough see if this is still an issue