The library that is used to connect to DLMS devices contains functionality to build a simulator for a device. The library offers the following core functionality.
zero or more servers can be started on a host (different ports)
zero or more logical devices can be registered with a server (different device id)
zero or more annotated objects can be registered with a logical device
these objects define available dlms classes, ObisCodes, attributeIds and methods for the device and can contain any logic
authentication and encryption are supported
If you want to simulate a certain device you will prepare annotated classes and register instances of these with a logical device. Because you create plain Java you can make use of all functionality Java offers, for example databases. To try and make the simulation more realistic you may build in connection timeouts etc.
For each combination of a cosem class and obiscode you create a java class that you annotate with @CosemClass(id = ..., obis = "x.x.x.x.x.255")
In these java classes you can add fields of type DataObject that you annotate with @CosemAttribute(id = ..., type = Type.x)
Also you can create getXXX and setXXX methods to intercept getting and setting data on a logical device. XXX will be the name of the corresponding field starting with a capital letter.
For example:
The value of the field will be the response to get(AttributeAddress...) that is fired from osgp CommandExecutors. NOTE that these values can also be set! For example using the ClientConsole.
You can also annotate methods with or without a DataObject return value and with or without a DataObject parameter: @CosemMethod(id = ..., consumes = Type.x)
For example:
Such a method will be called when osgp fires ClientConnection.action, the DataObject that may be returned will become available in osgp on the MethodResult object.
GXF has an implementation of DLMS device simulators that builds on the DLMS COSEM Server concepts as described in the General Usage section.
This project contains the code to activate a DLMS COSEM server simulating a smart meter by running the DeviceServer Spring Boot Application configure by settings defined in DlmsServerConfig.
More details about how to configure and start a simulator can be found in the readme documentation for simulators on GitHub.
The following diagrams provides some insight into the different parts that together provide access to COSEM interface object attributes and methods supported by the server.
Spring configuration classes define beans of type CosemInterfaceObject that are collected for activated Spring profiles to define the objects on the simulated device.
A COSEM interface object like octet-string deviceid1 can have a readable and writable value, that is made available outside the server and DLMS communication as well.
The role the DlmsAttributeValuesClient can play in a scenario where data is read and set from tests is described with the DLMS Attribute Values REST Resource.
The Cucumber test implementation using simulated DLMS device for smart metering comprises of a number of classes spread across the following projects:
dlms-device-simulator
osgp-simulator-dlms-triggered
cucumber-tests-platform-smartmetering
Dynamic values in smart meters (changed by DLMS communication or getting/setting values from test code) are implemented by using a REST resource, both from the simulated device and from the code behind Cucumber step definitions.
The following picture describes the REST resource endpoints and the way the resource is used by the different components.
The open smart grid platform supports DLMS/COSEM (IEC 62056]. DLMS/COSEM is a popular protocol to read smart meters. DLMS/COSEM is the de facto standard in Europe.
The open smart grid platform DLMS/COSEM implementation was initial based on SMR5 and DSMR v4. Other types of meters/profiles can be added to the platform. The open smart grid platform implementation supports HLS3/4/5.
Public/private key pair(s)
Multiple encryption levels inside protocol (DSMR requires highest encryption level)
Full encryption of communication
The OpenMUC jDLMS library from Fraunhofer is used to implement the protocol. Please note that jDLMS is licensed under the GPLv3.
DLMS protocol adapter configuration
DLMS device simulator
These devices can be used in combination with the Open Smart Grid Platform.
A specific protocol adapter can be used for a specific protocol The protocol-adapter that will be used by the device, is configured in the protocol_info field of the device. The following steps are required to configure and use a specific protocol-adapter:
Create a protocol-adapter that listens to a specific queue
Add a protocol-info record that uses this queue for the requests
Configure the device in osgp-core, so that it will use this new protocol-info
Configure the name of the JMS queue on which the protocol adpater will listen for requests.
By using a different outgoing_requests_property_prefix value, osgp-core can use a separate JMS queue for the requests.
Column | Example value | Description |
---|---|---|
The property with the prefix specified in the protocol-info table must be configured in the osgp-core.properties file The value is the name of the JMS queue. This is the same name as the name of the JMS queue specified in the osgp-protocol-adapter-dlms
A device can be configured to use the specific protocol adapter, by pointing it to the new protocol_info record
E/G | Supplier | Type | x fase |
---|---|---|---|
Column | Example value | Description |
---|---|---|
E
Kaifa
MA105
E
Kaifa
MA105C
1 fase
E
Kaifa
MA304
E
Kaifa
MA304C
3 fase
E
L+G
ZCF110CCtFs2
1 fase
E
L+G
ZMF110CCtFs2
3 fase
E
L+G
ZCF110CBtFs2
1 fase
E
L+G
E350
E
L+G
E650
E
Iskra
Mx382
G
L+G
G350 (wireless/wired)
G
Itron
G1 RF1
id
1
Auto generated ID
protocol
SMR_CDMA
Identifier of the configuration
protocol_version
5.1
Version identifier of the configuration
incoming_requests_property_prefix
jms.protocol.dlms.incoming.requests
Property prefix of the JMS queue for incoming requests
outgoing_requests_property_prefix
jms.protocol.dlms.outgoing.cdma.requests
Property prefix of the JMS queue for outgoing requests
incoming_responses_property_prefix
jms.protocol.dlms.incoming.responses
Property prefix of the JMS queue for incoming responses
outgoing_responses_property_prefix
jms.protocol.dlms.outgoing.cdma.responses
Property prefix of the JMS queue for outgoing responses
device_identification
E0049007469584219
Identification of the device
protocol_info_id
1
Reference to id in Protocol Info table