To make it as straight-forward as possible for the Stardraw Control example application, the driver provides a set of properties that allow the application to get and set the value of each external control included in the example Halogen configuration. In addition, the driver also provides several “On…Changed” events which notify the Stardraw application whenever it receives a message that requires an update of the state of a control.
For example, the driver structure for the lounge volume level control and how it interacts with both the Stardraw application and the Halogen/HAL Control Server is as follows:
This builds upon the information in the previous section, which describes everything in the ‘Driver Utilities’ layer and below. The Driver Application Interface layer provides a property, LoungeVolumeLevel
, that allows the Stardraw Control application to get or set the value of the Lounge Volume control. When the application ‘gets’ the LoungeVolumeLevel
, the driver simply returns its current value, _loungeVolumeLevel
, stored locally inside the driver. When the application ‘sets’ the LoungeVolumeLevel
, for instance when the end user adjusts the slider control, the driver sends the new value to the HAL Control Server by calling the setLevel
utility method with the proper control number and desired value. As described before, setLevel
creates a new message for the change and sends it to Halogen/HAL by calling the built-in WriteLine
method.
As part of setting a new lounge volume level, LoungeVolumeLevel
also calls the updateLoungeVolumeLevel
method, which updates the locally stored value of the lounge volume level, _loungeVolumeLevel
, and also sends an OnLoungeVolumeLevelChanged
event for to the Stardraw application. This lets anything registered to receive this event know that it should update to the new value of LoungeVolumeLevel
.
When the Stardraw application wants HAL to send the current value of the lounge volume control, it calls RequestLoungeVolumeLevel
, which in turn calls requestLevel
, causing the driver to send a ‘get level’ message to the Halogen/HAL Control Server asking for the value. When Halogen/HAL responds, it sends a ‘set level’ message to the Stardraw driver, which the driver handles starting with OnByteIn
, eventually resulting in an OnLoungeVolumeLevelChanged
event, letting the application know that a new value for the lounge volume level is available.