Bind and Unbind Devices

To bind or unbind a single device the SDK provides the methods bindDevice(MedicalDeviceTO medicalDevice) and unbindDevice(MedicalDeviceTO medicalDevice). The parameter medicalDevice indicates the device that should be bound or unbound. Only the attribute deviceId of this data structure is used (and only read) within these functions.

// this example code will bind myMedicalDevice1 and unbind
// myMedicalDevice2
sdk.bindDevice(myMedicalDevice1);
sdk.unbindDevice(myMedicalDevice2);

If the device is successfully bound or unbound the binding state of this device changes to DeviceBindingState.BOUND or DeviceBindingState.UNBOUND and the event onDeviceBindingStateChanges of the listener SDKDevicesListener will be fired.

public class MySDKDevicesListener implements SDKDevicesListener {
    public void onDeviceBindingStateChanges(MedicalDeviceTO
            medicalDevice) {
        switch(medicalDevice.getDeviceBindingState()) {
        case UNBOUND:
            // indicates that this device is unbound yet...
            break;
        case BINDING:
            // the binding operation is in progress
            break;
        case BOUND:
            // now, the device is bound
            break;
        case UNBINDING:
            // the unbinding operation is in progress
            break;
        // ...test all other possible states here
        }
    }
}

Multiple devices can be bound or unbound with the method bindDevices( List medicalDevices) or unbindDevices(List medicalDevices) of the SDK.

// create two device lists
List devicesToBind = new ArrayList(2);
devicesToBind.add(myMedicalDevice1);
devicesToBind.add(myMedicalDevice2);
List devicesToUnbind = new ArrayList(2);
devicesToUnbind.add(myMedicalDevice3);
devicesToUnbind.add(myMedicalDevice4);
// bind and undbind these devices
sdk.bindDevices(devicesToBind);
sdk.unbindDevices(devicesToUnbind);

To bind all unbound devices the method bindAllUnboundDevices() can be used. Vice versa the method unbindAllBoundDevices() unbinds all bound devices.

// bind all unbound devices
sdk.bindAllUnboundDevices();
// unbind all bound devices
sdk.unbindAllBoundDevices();

 
SourceForge.net Logo