Previous Topic

Next Topic

Book Contents

Book Index

EEBUS SPINE Exporter

Overview

The purpose of the EEBUS SPINE Exporter is to:

API Details

The API allows to fully customize the device and its structure. This can be done in a very flexible way. There are four general levels of customization:

  1. On the base level are the virtual SPINE devices.
  2. The next level is the level of the virtual SPINE entities
  3. The next level is the level of the virtual SPINE features.

A feature can be removed by unregistering the corresponding OSGI service or any of its ancestors.

  1. The highest level is the level of SPINE functions.

The four levels above are following the SPINE specification. Only the "SPINEDeviceAccessHandler" requires some explanation and showcasing. Here is an excerpt from the com.prosyst.mbs.spine.virtual-device-demo which implements the SPINEDeviceAccessHandler to get an instance of SpineDeviceAccess which is called deviceAccess. In the sample below the handler uses the deviceAccess to get all of the devices subscribed for changes in the Operation State and notifies them for any change:

void notifyOperationStateUpdated() {

    List<FeatureAddressType> subscribers = deviceAccess.getSubscriptions(featureAddress);

    CmdType cmdState = new CmdType();

    cmdState.setDeviceDiagnosisStateData(getDeviceDiagnosisState());

    PayloadType payload = new PayloadType();

    payload.getCmd().add(cmdState);

    for (FeatureAddressType addressDestination : subscribers) {

      DatagramType stateDatagram = new DatagramType();

      HeaderType header = new HeaderType();

      header.setAddressSource(featureAddress);

      header.setAddressDestination(addressDestination);

      header.setAckRequest(null);

      header.setCmdClassifier(CmdClassifierType.NOTIFY);

      header.setSpecificationVersion(SPINEConstants.CURRENT_VERSION);

      stateDatagram.setHeader(header);

      stateDatagram.setPayload(payload);

      SPINEDevice targetDevice = deviceAccess.getDevice(addressDestination.getDevice());

      targetDevice.send(stateDatagram);

    }

}

Request handling

When an incoming request comes the following verifications are performed:

  1. The target device is determined using the address destination from the header. If this is missing the local device is chosen.
  2. The target feature within the specified device is found, using the provided feature address.
  3. Each of the function handlers is "asked" if the request can be handled by it, using the "isRequestSupported" method.
  4. If some of the function handler declares that the specified request is supported it is "asked" to provide the response for this request.

For the cases when some of the components is missing the appropriate set of exceptions is prepared. Here is an example of a well defined function handler. It handles reading of DeviceClassificationManufacturerData and is part of the com.prosyst.mbs.spine.virtual-device-demo:

boolean isRequestSupported(FeatureAddressType sourceAddress, CmdClassifierType cmdClassifier, CmdType cmdRequest) {

    return cmdClassifier == CmdClassifierType.READ && cmdRequest.getDeviceClassificationManufacturerData() != null;

}

CmdType handleReadRequest(FeatureAddressType sourceAddress, CmdType cmdRequest) {

    CmdType cmdResponse = new CmdType();

    cmdResponse.setDeviceClassificationManufacturerData(getManufacturerData());

    return cmdResponse;

}

DeviceClassificationManufacturerDataType getManufacturerData() {

    DeviceClassificationManufacturerDataType result = new DeviceClassificationManufacturerDataType();

    result.setDeviceName("My Virtual Device");

    result.setDeviceCode("My Virtual Device Code");

    result.setSerialNumber("1234567890");

    result.setSoftwareRevision("1.1.0");

    result.setVendorName("Bosch.IO GmbH");

    result.setBrandName("Bosch.IO");

    

    return result;

}

As the isRequestSupported method shows this handler declares that it can handle only READ requests containing a DeviceClassificationManufacturerData element. After the verifications are performed and this handler is requested to process the request it provides the actual response through the handleReadRequest method. As it shows it just populates the DeviceClassificationManufacturerData with some hardcoded values because it has a demo purpose.

Virtual Devices and Destination List

The Exported devices are "visible" through the "DestinationList" function of the primary feature of the primary entity of the local device i.e. using the address of the machine where the SPINE module is running. For more information you can see "Chapter 7.2 Destination list" from the "EEBus SPINE Technical Specification - Protocol Specification".