Previous Topic

Next Topic

Book Contents

Book Index

Adapter Information

The DeviceAdmin service can be used to obtain information about all protocol adapters currently available in the OSGi runtime. Information for each specific protocol adapter is provided in the form of a com.prosyst.mbs.services.da.AdapterInfo object.

DeviceAdmin.PROPERTY_ADAPTER_INFOS

The DeviceAdmin has functional property DeviceAdmin.PROPERTY_ADAPTER_INFOS which type is Set of AdapterInfo. The following example use a getter method for DeviceAdmin.PROPERTY_ADAPTER_INFOS property to print information about all available protocol adapters. In our example there is only one available protocol adapter – "DA Demo". For this reason you should have the Device Access Protocol Adapter Demo installed and started.

private DeviceAdmin deviceAdmin;

public DeviceAdmin addingService(ServiceReference<DeviceAdmin> reference) {

  deviceAdmin = bc.getService(reference);

  printAdapterInfos();

  return deviceAdmin;

}

private static void printAdapterInfos() {

  Set<AdapterInfo> adapterInfos = deviceAdmin.getAdapterInfos();

  for (AdapterInfo adapterInfo : adapterInfos) {

    System.out.println("Adapter Name : " + adapterInfo.getName());

    System.out.println("Adapter Version : " + adapterInfo.getVersion());

    System.out.println("Supported Operations : " + adapterInfo.getOperations());

    System.out.println("Supported Remove Arguments : " + adapterInfo.getRemoveArguments());

  }

}

The result after executing the example is:

Adapter Name : DA DEMO

Adapter Version : 1.0.0

Supported Operations : [CREATE. REMOVE ]

Supported Remove Arguments : []

DeviceAdmin.OPERATION_GET_ADAPTER_INFO

The DeviceAdmin has an operation DeviceAdmin.OPERATION_GET_ADAPTER_INFO which returns information for specific protocol adapter. The following example shows the information about "DA Demo" protocol adapter.

private DeviceAdmin deviceAdmin;

public DeviceAdmin addingService(ServiceReference<DeviceAdmin> reference) {

  deviceAdmin = bc.getService(reference);

  printAdapterInfo();

  return deviceAdmin;

}

private static void printAdapterInfo() {

  AdapterInfo adapterInfo = deviceAdmin.getAdapterInfo("DA Demo");

  System.out.println("Adapter Name : " + adapterInfo.getName());

  System.out.println("Adapter Version : " + adapterInfo.getVersion());

  System.out.println("Suported Operations : " + adapterInfo.getOperations());

  System.out.println("Supported Remove Arguments : " + adapterInfo.getRemoveArguments());

}

The result after executing the example is same as of the previous example:

Adapter Name : DA DEMO

Adapter Version : 1.0.0

Supported Operations : [CREATE. REMOVE ]

Supported Remove Arguments : []

AdapterOperation

The method of AdapterInfo.getOperation() returns the supported operations. The AdapterOperation (com.prosyst.mbs.services.da.AdapterOperation) provides detail information for the operations of the specific protocol adapter. The possible values for the protocol adapter operations are:

Operation

Description

AdapterOperation.CREATE

This operation is used for creation of a new Device. On Creating a Device page there is an example of how to create a Device.

AdapterOperation.REMOVE

This operation is used for remove an existing Device. On Removing a Device page there is an example of how to remove a Device.

AdapterOperation.CANCEL_REMOVE

This operation is used for cancel removing an existing Device.

RemoveArgument

The method of AdapterInfo.getRemoveArguments() returns the supported removal arguments. The RemoveArgument (com.prosyst.mbs.services.da.RemoveArgument) provides arguments for the removing of a specified device. The possible values for the removal arguments are:

Remove argument

Description

RemoveArgument.FORCE

This removal argument defines that the Device should be removed immediately. The protocol adapter must not put the Device on the DeviceStatus.REMOVING.

RemoveArgument.POSTPONE

This removal argument define that the Device should be postpone removed. For example the use must press any button before removing a Device. The protocol adapter must put the Device on the DeviceStatus.REMOVING state and must throw a NotRemovedException exception to the Device Access.

RemoveArgument.FORCE_RESET

This removal argument defines that the Device should be removed immediately and reset afterward.

RemoveArgument.POSTPONE_RESET

This removal argument defines that the Device should be postpone removed and reset afterward.

These are the constants that are defined on the API level. They are related to the implementation of the protocol adapter which is on the SPI level. To see how to implement a protocol adapter click here.