Package org.openmuc.eebus.spine.impl
Class DeviceBuilder
- java.lang.Object
-
- org.openmuc.eebus.spine.impl.DeviceBuilder
-
public class DeviceBuilder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description DeviceBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeviceBuilder
addDeviceListener(DeviceListener listener)
EntityBuilder
addEntity()
Creates a new EntityBuilder instance.DeviceBuilder
addUseCase(UseCase useCase)
Adds the passed SPINE use case to this device.Device
build()
Builds the SPINE device and connects it to the communication network.org.eebus.docs.spine.xsd.v1.EntityAddressType
getLastAddedEntityAddress()
DeviceBuilder
setAcknowledgmentEnabled(boolean acknowledgmentEnabled)
DeviceBuilder
setAutomaticDestinationListDetection(boolean enabled)
DeviceBuilder
setCommunication(Communication communication)
This method must be called before callingbuild()
!DeviceBuilder
setCommunicationMode(org.eebus.docs.spine.xsd.v1.NetworkManagementFeatureSetType mode)
Controls if the device should support the enhanced communication mode, i.e. can forward messages.NetworkManagementFeatureSetType.SIMPLE
means no forwarding is possible and is the default.DeviceBuilder
setDescription(java.lang.String description)
DeviceBuilder
setDeviceType(org.eebus.docs.spine.xsd.v1.DeviceTypeEnumType deviceType)
This method must be called before callingbuild()
!DeviceBuilder
setDiscoverDevices(boolean discoverDevices)
Enables the automatic DetailedDiscovery of newly discovered SPINE devices.DeviceBuilder
setId(java.lang.String id)
Sets the device address of the new SPINE device.DeviceBuilder
setLabel(java.lang.String label)
-
-
-
Method Detail
-
build
public Device build() throws IncompleteBuildException
Builds the SPINE device and connects it to the communication network. After this operation the device is available for communication.
If mandatory information was not set (setId(String)
,setCommunication(Communication)
,setDeviceType(DeviceTypeEnumType)
) this operation throws anIncompleteBuildException
.- Returns:
- the built SPINE device
- Throws:
IncompleteBuildException
- when id, device type and/or communication was not set
-
setId
public DeviceBuilder setId(java.lang.String id)
Sets the device address of the new SPINE device. This must be a unique address with the following pattern:d:_(i:[1-9][0-9]*|n:[a-zA-Z0-9-]+)_[^\p{Cc}\p{Cf}\p{Z}]+
see Chapter 7.1.1.1 in the Protocol Specification for more details.
This method must be called before callingbuild()
!- Parameters:
id
- the device address identifying this unique SPINE device- Returns:
- the updated
DeviceBuilder
-
setDeviceType
public DeviceBuilder setDeviceType(org.eebus.docs.spine.xsd.v1.DeviceTypeEnumType deviceType)
This method must be called before callingbuild()
!- Parameters:
deviceType
- the type of the SPINE device- Returns:
- the updated
DeviceBuilder
-
setCommunication
public DeviceBuilder setCommunication(Communication communication)
This method must be called before callingbuild()
!- Parameters:
communication
- the communication protocol to use- Returns:
- the updated
DeviceBuilder
-
setDiscoverDevices
public DeviceBuilder setDiscoverDevices(boolean discoverDevices)
Enables the automatic DetailedDiscovery of newly discovered SPINE devices. If disabled (default) the DetailedDiscovery must be executed manually viaNodeManagement
- Parameters:
discoverDevices
- true if DetailedDiscovery should be started automatically, false otherwise- Returns:
- the updated
DeviceBuilder
-
addDeviceListener
public DeviceBuilder addDeviceListener(DeviceListener listener)
-
addEntity
public EntityBuilder addEntity()
Creates a new EntityBuilder instance. The entity can then be fluently added to this device withEntityBuilder.applyToDevice()
.- Returns:
- a new EntityBuilder instance
-
setDescription
public DeviceBuilder setDescription(java.lang.String description)
- Parameters:
description
- a string describing the new SPINE device- Returns:
- the updated
DeviceBuilder
-
setLabel
public DeviceBuilder setLabel(java.lang.String label)
- Parameters:
label
- a human-readable alias of the new SPINE device- Returns:
- the updated
DeviceBuilder
-
setAcknowledgmentEnabled
public DeviceBuilder setAcknowledgmentEnabled(boolean acknowledgmentEnabled)
- Parameters:
acknowledgmentEnabled
- true if acknowledgment messages shall be requested, false otherwise- Returns:
- the updated
DeviceBuilder
-
setCommunicationMode
public DeviceBuilder setCommunicationMode(org.eebus.docs.spine.xsd.v1.NetworkManagementFeatureSetType mode)
Controls if the device should support the enhanced communication mode, i.e. can forward messages.NetworkManagementFeatureSetType.SIMPLE
means no forwarding is possible and is the default. With every other value this device maintains a list with known SPINE devices and is able to forward messages to them.- Parameters:
mode
- the NetworkFeatureSet as which the device acts- Returns:
- the updated
DeviceBuilder
-
setAutomaticDestinationListDetection
public DeviceBuilder setAutomaticDestinationListDetection(boolean enabled)
-
addUseCase
public DeviceBuilder addUseCase(UseCase useCase)
Adds the passed SPINE use case to this device. The use case is executed when this device is built.- Parameters:
useCase
- the SPINE use case this device supports- Returns:
- the updated
DeviceBuilder
-
getLastAddedEntityAddress
public org.eebus.docs.spine.xsd.v1.EntityAddressType getLastAddedEntityAddress()
- Returns:
- the entity address of the last added entity
-
-