Package org.openmuc.jeebus.spine.impl
Class DeviceBuilder
- java.lang.Object
-
- org.openmuc.jeebus.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 DeviceBuilderaddDeviceListener(DeviceListener listener)Adds the givenDeviceListenerto the device.EntityBuilderaddEntity()Creates a new EntityBuilder instance.DeviceBuilderaddUseCase(UseCase useCase)Adds the passed SPINE use case to this device.Devicebuild()Builds the SPINE device and connects it to the communication network.DevicebuildWithoutConnecting()Builds the SPINE device, but does not connect it to the communication network.java.lang.StringgetId()org.openmuc.jeebus.spine.xsd.v1.EntityAddressTypegetLastAddedEntityAddress()DeviceBuilderwithAcknowledgmentEnabled(boolean acknowledgmentEnabled)DeviceBuilderwithAutomaticDestinationListDetection(boolean enabled)DeviceBuilderwithCommunication(Communication communication)This method must be called before callingbuild()!DeviceBuilderwithCommunicationMode(org.openmuc.jeebus.spine.xsd.v1.NetworkManagementFeatureSetType mode)Controls if the device should support the enhanced communication mode, i.e.DeviceBuilderwithDescription(java.lang.String description)DeviceBuilderwithDeviceType(org.openmuc.jeebus.spine.xsd.v1.DeviceTypeEnumType deviceType)This method must be called before callingbuild()!DeviceBuilderwithDiscoverDevices(boolean discoverDevices)Enables the automatic DetailedDiscovery of newly discovered SPINE devices.DeviceBuilderwithId(java.lang.String id)Sets the device address of the new SPINE device.DeviceBuilderwithLabel(java.lang.String label)DeviceBuilderwithUseCases(java.util.List<UseCase> useCases)Adds all given use cases usingaddUseCase(UseCase)DeviceBuilderwithUseCases(UseCase... useCases)Adds all given use cases usingaddUseCase(UseCase)
-
-
-
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 (withId(String),withCommunication(Communication),withDeviceType(DeviceTypeEnumType)) this operation throws anIncompleteBuildException.- Returns:
- the built SPINE device
- Throws:
IncompleteBuildException- when id, device type and/or communication was not set
-
buildWithoutConnecting
public Device buildWithoutConnecting() throws IncompleteBuildException
Builds the SPINE device, but does not connect it to the communication network. After this operation the device may be further modified if desired, and may be connected to the communication network withCommunication.connect().
If mandatory information was not set (withId(String),withCommunication(Communication),withDeviceType(DeviceTypeEnumType)) this operation throws anIncompleteBuildException.- Returns:
- the built SPINE device
- Throws:
IncompleteBuildException- when id, device type and/or communication was not set
-
withId
public DeviceBuilder withId(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
-
getId
public java.lang.String getId()
- Returns:
- the device address of the new SPINE device.
-
withDeviceType
public DeviceBuilder withDeviceType(org.openmuc.jeebus.spine.xsd.v1.DeviceTypeEnumType deviceType)
This method must be called before callingbuild()!- Parameters:
deviceType- the type of the SPINE device- Returns:
- the updated
DeviceBuilder
-
withCommunication
public DeviceBuilder withCommunication(Communication communication)
This method must be called before callingbuild()!- Parameters:
communication- the communication protocol to use- Returns:
- the updated
DeviceBuilder
-
withDiscoverDevices
public DeviceBuilder withDiscoverDevices(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)
Adds the givenDeviceListenerto the device.- Parameters:
listener- the DeviceListener to add- Returns:
- the updated
DeviceBuilder
-
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
-
withDescription
public DeviceBuilder withDescription(java.lang.String description)
- Parameters:
description- a string describing the new SPINE device- Returns:
- the updated
DeviceBuilder
-
withLabel
public DeviceBuilder withLabel(java.lang.String label)
- Parameters:
label- a human-readable alias of the new SPINE device- Returns:
- the updated
DeviceBuilder
-
withAcknowledgmentEnabled
public DeviceBuilder withAcknowledgmentEnabled(boolean acknowledgmentEnabled)
- Parameters:
acknowledgmentEnabled- true if acknowledgment messages shall be requested, false otherwise- Returns:
- the updated
DeviceBuilder
-
withCommunicationMode
public DeviceBuilder withCommunicationMode(org.openmuc.jeebus.spine.xsd.v1.NetworkManagementFeatureSetType mode)
Controls if the device should support the enhanced communication mode, i.e. can forward messages.NetworkManagementFeatureSetType.SIMPLEmeans 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
-
withAutomaticDestinationListDetection
public DeviceBuilder withAutomaticDestinationListDetection(boolean enabled)
-
withUseCases
public DeviceBuilder withUseCases(java.util.List<UseCase> useCases)
Adds all given use cases usingaddUseCase(UseCase)- Parameters:
useCases- the use cases to add- Returns:
- the updated
DeviceBuilder
-
withUseCases
public DeviceBuilder withUseCases(UseCase... useCases)
Adds all given use cases usingaddUseCase(UseCase)- Parameters:
useCases- the use cases to add- Returns:
- the updated
DeviceBuilder
-
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.openmuc.jeebus.spine.xsd.v1.EntityAddressType getLastAddedEntityAddress()
- Returns:
- the entity address of the last added entity
-
-