
Read latest DLMS/COSEM specific documentation from here.
This documentation is old and will be removed.
We have try to make DLMS/COSEM server easy to use and we have hide all DLMS spesific stuff. We have also try to make use of C++ class as easy as is with Java or C#. We are not supporting all COMSEM interfaces yet. In earlier versions we supported all interfaces, but because the feedback that we received we desided to change class easier to use and this caused that we were forced to rewrite all again. We are adding support to new interfaces all the time.
Our server component do not handle data reading from the serial port, TCP/IP or PLC.You must implement your reading by your self. Gurux DLMS/COSEM component only parses received data to DMLS/COSEM and notifies you what you need to do. Because of this you basically not need to know anything from DLMS/COSEM.
First you must derive class from GXDLMSServerBase and implement few methods like this:
/////////////////////////////////////////////////////////////////////////////
//This class implements Gurux example DLMS/COSEM Server.
/////////////////////////////////////////////////////////////////////////////
class GuruxExampleDLMSServer : public GXDLMSServerBase
{
public:
//Constructor. Logican name referencing is used.
GuruxExampleDLMSServer() : GXDLMSServerBase(true)
{
}
// Called if client tries to make connection using wrong server ID.
int OnInvalidConnection();
// Get Association view (supported COSEM objects).
int OnGetItems();
// Client wants to read some data.
int OnRead(CGXDLMSObject* pItem, int index, CDLMSVariant& value);
// Client wants to write some data.
int OnWrite(CGXDLMSObject* pItem, int index, CDLMSVariant& value);
};
Because there is no object type in C++ we have made own CDLMSVariant.
CDLMSVariant is a struct that you can use to handle different data types.
So basically thanks for CDLMSVariant type setting and getting value is much easier.
Make Connection
In handshake client want to know following information from the server:
- Is Short name or logical name referencing used?
- Maximum PDU Size
- Physical interface type. (HDLC, IEC 62056-47, etc.)
Because we do not want to change those values afterwards values are given at constructor.
Get Association view
After connection is made client usually wants to know what kind of data server is offering. For this reason client might ask Association view. If client is asking Association view GXDLMSServerBase base class calls OnGetItems.
You should returns all items that client can read. Like this:
int GuruxExampleDLMSServer::OnGetItems()
{
////////////////////////////////////////////////////////////////
// COSEM Logical Device Name is defined as an octet-string of 16 octets.
// The first three octets uniquely identify the manufacturer of the device
// and it corresponds to the manufacturer's identification in IEC 62056-21.
// The following 13 octets are assigned by the manufacturer.
//The manufacturer is responsible for guaranteeing the uniqueness of these octets.
CDLMSVariant id(serialNo);
id.ChangeType(DLMS_DATA_TYPE_OCTET_STRING);
GXDLMSData* d = new GXDLMSData("0.0.42.0.0.255", id);
d->GetAttributes().push_back(new CGXDLMSAttribute(2, DLMS_DATA_TYPE_OCTET_STRING));
GetItems().push_back(d);
// Electricity ID 1
d = new GXDLMSData("1.1.0.0.0.255", serialNo);
d->GetAttributes().push_back(new CGXDLMSAttribute(2, DLMS_DATA_TYPE_STRING));
GetItems().push_back(d);
// Electricity ID 2
CDLMSVariant id2(serialNo);
id2.ChangeType(DLMS_DATA_TYPE_OCTET_STRING);
d = new GXDLMSData("1.1.0.0.1.255", id2);
d->GetAttributes().push_back(new CGXDLMSAttribute(2, DLMS_DATA_TYPE_UINT32));
GetItems().push_back(d);
////////////////////////////////////////////////////////////////
//Add data objects.
GXDLMSData* d = new GXDLMSData("1.0.1.0.0.255");
d->GetAttributes().push_back(new CGXDLMSAttribute(2, type));
GetItems().push_back(d);
d = new GXDLMSData("0.0.2.0.0.255");
d->GetAttributes().push_back(new CGXDLMSAttribute(2, type));
GetItems().push_back(d);
return ERROR_CODES_OK;
}
Reading
When client want's to read data to from the meter OnRead method is called.
There are two sepatate cases:
1. If you are storing values in COSEM Objects you only return ERROR_CODES_FALSE.
This means that class library is returning COSEM Object value to the caller.
int GuruxExampleDLMSServer::OnRead(CGXDLMSObject* pItem, int index, CDLMSVariant& value)
{
return ERROR_CODES_FALSE;
}
2. If you want to make proxy or values are saved somewhere else and you do not want to update every time to COSEM Objects you can do it by your self.
int GuruxExampleDLMSServer::OnRead(CGXDLMSObject* pItem, int index, CDLMSVariant& value)
{
//Find value using Logican or Short Name and Attribute Index.
//Update value.
//value = FindValue;
return ERROR_CODES_OK;
}
Data reading and writing
Our DLMS/COSEM component do not take any part for communication media (channel). You can use Gurux DLMS/COSEM using example. Serial port, TCP/IP, PLC, etc.
Please, do not hesitate to take contact if you have problems to create listener server.
Techical info
Size of GXDLMSServerBase is 1216 bytes.
Size of GXDLMSData class is 136 bytes.
Size of GXDLMSRegister class 144 bytes.
Note! Values are indicative. Actual size debends from the content of object value.
| Data Link Layer | |
| Maximum Window Size supported | 0xFFFF |
| HDLC Addressing Scheme supported | 1, 2, 4 Bytes |
| Support for IEC 62056-21 Mode E | No |
| Communication Profiles | HDLC, TCP/IP, UDP |
| Application Layer | |
| Authentication Mechanisms | Lowest, Low and High Level |
| Association Types | Long Name and Short Name |
| Conformance Block | Supported: Read, Write, Unconfirmed Write, Attribute 0 with SET Priority Management Support, Attribute 0 with GET Block Transfer with GET , Block Transfer with SET Block Transfer with READ, Block Transfer with WRITE Multiple References, Information Report, Parameterized Access, GET, SET Selective Access,
|
| Application Contexts | LN and LN with no Ciphering |
| Interface Class DLMS Object Source code Support | |
| 1 Data | Yes |
| 3 Register | Yes |
| 4 Extended register | Yes |
| 5 Demand register | Yes |
| 6 Register activation | Yes |
| 7 Profile generic | Adding at this moment. |
| 8 Clock | Yes |
| 9 Script table | No |
| 10 Schedule | No |
| 11 Special days table | No |
| 12 Association SN | Yes |
| 15 Association LN | Yes |
| 17 SAP assignment | Yes |
| 18 Image transfer | No |
| 19 IEC local port setup | No |
| 20 Activity calendar | No |
| 21 Register monitor | No |
| 22 Single action schedule | No |
| 23 IEC HDLC setup | No |
| 24 IEC twisted pair (1) setup | No |
| 25 M-Bus slave port setup | No |
| 26 Utility tables | No |
| 27 Modem configuration | No |
| 28 Auto answer | No |
| 29 Auto connect | No |
| 41 TCP-UDP setup | No |
| 42 IPv4 setup | No |
| 43 Ethernet setup | No |
| 44 PPP setup | No |
| 45 GPRS modem setup | No |
| 46 SMTP setup | No |
| 50 S-FSK Phy&MAC | No |
| 51 S-FSK Active initiator | No |
| 52 S-FSK MAC synchronization timeouts | No |
| 53 S-FSK MAC counters | No |
| 55 S-FSK IEC 61334-4-32 LLC setup | No |
| 56 S-FSK Reporting system list | No |
| 57 ISO/IEC 8802-2 LLC Type 1 setup | No |
| 58 ISO/IEC 8802-2 LLC Type 2 setup | No |
| 59 ISO/IEC 8802-2 LLC Type 3 setup | No |
| 61 Register table | No |
| 63 Status mapping | No |
| 64 Security setup | No |
| 70 Disconnect control | No |
| 71 Limiter | No |
| 72 M-Bus client | No |
| 73 Wireless Mode Q channel | No |
| 74 M-Bus master port setup | No |