You are here: Using External Control Systems with HAL > Integrating Stardraw Control Systems > Exploring the Stardraw Example Application > Toggles


The example application provides two toggle controls, one for muting all audio outputs and one to open and close the Room Combine block’s wall toggle. In the Stardraw form, both of these use the same built-in Switch control from the Stardraw Toolbox Controls palette.

Mute Outputs Toggles

Hooking up the Mute Outputs switch to the driver is a matter of mapping two events to actions which provide bi-directional communication between the Stardraw application and the HAL Control Server.

First, when the end user changes the switch setting, the Stardraw application generates a Click event for the Mute Outputs switch, which is named MuteOutputsToggleControl. In the application, this event is mapped to the action which sets the HAL1 driver’s MuteAllToggle property to the current state of the Stardraw MuteOutputsToggleControl. This means that whenever the end user changes the switch setting, the Stardraw application sends a corresponding change to the Halogen/HAL Control Server.

To see this mapping, double-click on the Mute Outputs switch in the Stardraw form. This brings up the Actions dialog for that control (named MuteOutputsToggleControl):

In this dialog, the event is MuteOutputsToggleControl.Click, shown in the upper right. For this event, the dialog shows the set of actions that run when the event occurs. In this case the application sets the HAL1 MuteAllToggle driver property to the current Checked value of the MuteOutputsToggleControl. As we saw in the driver description, this causes the driver to send a ‘set toggle’ message to the HAL Control Server for the Mute All Toggle Control configured in the Halogen Control Systems dialog.

The other event that needs to be hooked up for the switch control is the HAL1 OnMuteAllToggleChanged event. This occurs when the HAL1 driver receives a ‘set toggle’ message for the Mute All Toggle Control. To keep the Stardraw application ‘in-sync’ with the HAL, this event maps to an action that updates the Checked value of the MuteOutputsToggleControl.

You can see this in the Actions dialog for the MuteOutputsToggleControl by changing the event in the dialog drop-down to HAL1 OnMuteAllToggleChanged. Do this by clicking on the drop-down arrow and then traversing the popup menus: Devices -> HAL1 (1) -> Control Port and then selecting OnMuteAllToggleChanged. The dialog will change to:

This shows the action that runs when the HAL1 driver raises the OnMuteAllToggleChanged event. In this case the action updates the Stardraw MuteOutputToggleControl’s Checked state to the current value of the HAL driver’s MuteAllToggle property.

Open Wall Toggle

The configuration of the Open Wall switch is very similar to the Mute Outputs switch configuration. In this instance, however, the name of the form control is OpenWallToggleControl, and the application maps this control’s Click event to an action that sets the HAL1 driver’s WallOpenToggle property to the current Checked value of OpenWallToggleControl.

In addition, the application maps the HAL1 OnWallOpenToggleChanged event to an action that updates the form’s OpenWallToggleControl to the current value of the HAL1 driver’s WallOpenToggle property.

As before, you can see these events and associated actions by double clicking on the form’s Open Wall switch.