Customize the Binding and Unbinding Process

In order to customize the binding or unbinding process it is possible to define special actions that are executed after binding a device or before unbinding it. The method setBindingAction(SDKAction action) defines an action that is executed after binding a device (independent of its device type). With the method setBindingAction(SDKAction action, int deviceType) you can define a binding action for a specific device type. This action is only executed after binding a device of the specifed type.

// This example shows how to define a custom binding action, that
// activates only the last user for scales and only the first user
// for all other device types.
MedicalDeviceTO activateFirstUserConfiguration =
    new MedicalDeviceTO();
activateFirstUserConfiguration.setUserSetting(
    new UserSettingTO(
        1,
        true,false,false,false,
        false,false,false,false) );
MedicalDeviceTO activateLastUserConfiguration =
    new MedicalDeviceTO();
activateLastUserConfiguration.setUserSetting(
    new UserSettingTO(
        8,
        false,false,false,false,
        false,false,false,true) );
sdk.setBindingAction(
    new SetConfigurationsAction(
        sdk,
        activateFirstUserConfiguration,
        SDK.USER_SETTING) );
sdk.setBindingAction(
    new SetConfigurationsAction(
        sdk,
        activateLastUserConfiguration,
        SDK.USER_SETTING),
    SDK.DEVICE_TYPE_SCALE);

To reset all binding actions use the method clearBindingActions(). This includes all type specific actions and type undependent binding actions.

For defining or resetting unbinding actions use the methods setUnbindingAction(SDKAction action), setUnbindingAction(SDKAction action, int deviceType) or clearUnbindingActions(). Both binding and unbinding actions are not executed on temporary binding nor on temporary unbinding.

SDKAction

The interface com.biocomfort.SDK.actions.SDKAction defines a specific blocking function of the SDK. At this time the functions setDeviceConfigurationsAndWait(MedicalDeviceTO,int), getDeviceConfigurationsAndWait(MedicalDeviceTO,int) and setDeviceClearMemAndWait(MedicalDeviceTO) are realized within the classes SetConfigurationsAction, GetConfigurationsAction, SynchronizeDateTimeAction and SetClearMemAction as implementations of this interface. The implementation SequenceAction can be used to join multiple actions. This interface is used to define custom binding or unbinding actions.

// ...clear the device memory and deactivate all users before unbinding the device.
MedicalDeviceTO deactivateAllUsersConfiguration =
    new MedicalDeviceTO();
deactivateAllUsersConfiguration.setUserSetting(
    new UserSettingTO(
        1,
        false,false,false,false,
        false,false,false,false) );
sdk.setUnbindingAction(
    new SequenceAction(
        new SetClearMemAction(sdk),
        new SetConfigurationsAction(sdk,
            deactivateAllUsersConfiguration,SDK.USER_SETTING) ));

 
SourceForge.net Logo