本文是对于IEC62056协议族,即DLMS协议族的中文说明手册。本文并没有包含DLMS协议族的全部,但解释了在应用中可能出现的大多数情况。本文的目的是为电能量数据采集终端提供与使用DLMS协议族的电能表通讯的协议说明。

本文参考文献如下:

(1)DLMS User Association , COSEM Identification System andInterface Objects , Third Edition

(2)IEC62056 -53 Electricitymetering - Data exchange for meter reading, tariff and load                                                        control -Part 53: COSEM applicationlayer

(3)IEC62056 -46Electricity metering - Data exchange for meter reading, tariff and load                                                             control -Part 46: Data link layerusing HDLC protocol

(4)IEC62056 -42 Electricity metering - Data exchange for meter reading, tariff and load                                                            control -Part 42: Physical layer servicesand procedures for                                                                     connection-orientedasynchronous data exchange

(5)IEC62056 -61 Electricity metering - Data exchange for meter reading, tariff and load                                                            control -Part 61: Object identificationsystem (OBIS)

(6)Amber Management logical device-FR:AMBER/FW TECH_SPEC                                                                                          MANAGEMENT_LOGICAL_DEVICE

(7)Amber Electricity Logical Device - FR:AMBER/FWTECH_SPEC                                                                                           ELECTRICITY_LOGICAL_DEVICE

     (8)A Layman's Guide to a Subset of ASN.1, BER, and DER-

AnRSA Laboratories Technical Note

Burton S. KaliskiJr.Revised November 1, 1993

(9)IEC61334采用配线载波的配电自动化,译文汇编。

一、本文的结构

由于DLMS协议族的复杂性,必然导致本文篇幅较长,涉及的内容比较多。这里有必要把本文的内容,做一个综述,并解释各部分之间的相互关系。

一、DLMS协仪模型:从整体上介绍DLMS协议。

二、DLMS物理层协议:讲述DLMS物理层在整个协议族中的作用。

三、DLMS链路层协议:讲述HDLC链路层协议在整个协议族中的作用。

四、DLMS应用层协议:讲述DLMS应用层协议在整个协议族中的作用。这一部分又                 包括如下几部分内容。

(一、)ASN.1语法:这个语法是用来描述DLMS应用层协议帧的组成的。

(二、)BER编码与AXDR编码:这两种编码是用来实现ASN.1语法的。

(三、)AARQ与AARE数据帧:这是两个特殊的数据帧,它用来构筑DLMS协                                议中的client端与server端的应用层连接。

(四、)数据请求过程描述:介绍请求数据时所用的的数据帧。

五、请求数据实例:这里提供了几个请求数据的实际范例的数据包文。

1、  请求电量

2、  请求瞬时量(电压、电流、功率)

3、  请求负荷曲线

4、  请求时间

一、DLMS协仪模型

下图从整体上描述了DLMS协仪模型。

协仪共分为3层,物理层,链路层,应用层。层与层之间使用指定的服务通讯。

通讯的双方采用Client—Server结构,数据请求端(采集器)为Client,数据提供端(电表)为Server.

通讯过程描述:

(一)   建立物理层连接

物理层位于通讯模型的最底层。DLMS规约可以建立在多种物理层之上,物理 层的做用主要是对底层通讯硬件的操做(如对PSTN MODEM的初始化,打开,   关闭。)

(二)   建立链路层连接

物理层连接建立之后,数据通讯的第一步是建立链路层的连接,链路层主要负            责数据传输的可靠性,包括以下几个方面,地址校验,帧长校验,数据的CRC校                验。长数据帧的拆包组包。同时向应用层提供链路传输的服务。

(三)   建立应用层连接

链路层连接建立之后,在DLMS协仪中还要建立应用层连接,才可进行数据通讯。

这个应用层连接建立过程被称为Negotioation。

这个过程是为数据通讯提供一些配置参数。应用层连接请求由Client端发起,Client      端发aarq帧,Server端响应aare帧

(四)   进行数据通讯

当连接建立起后,就可进行数据通讯了。Client端发送数据请求帧Server端以数据响应。Client在请求不同的数据时,要使用特定数据的独有的class id和OBIS,用以标识不同类型的数据。

(五)   数据通讯结束,释放链路,解除连接。

数据通讯结束后,发链路结束帧,结束一次通讯过程。一次数据通讯结束后,可以通过发链路结束帧,来结束一次通讯过程。也可以,不发任何数据帧,依靠server端的超时挂断机制,来结束一次通讯过程。一般应使用前者。

(六)   解除物理层连接

关闭物理端口(如挂断Modem)。从物理上结束一次通讯。

二、DLMS物理层协议

物理层协议位于DLMS协议族的最底层,负责数据通讯的物理传输。DLMS可以工作于多种不同的物理介质上(PSTN,网络,串行通道等)。

物理层的功能是接受链路层数据,发送到物理介质上,传送到通信的对端。或是接收通信的对端传送来得数据,再传送到链路层,供更高层的协议处理数据。

DLMS物理层协议,主要规定了物理层应实现的服务,如:打开端口,初始化端口,收发数据,关闭端口等。在通常的嵌入式系统中(如电能量采集装置),物理层对应于系统的底层驱动部分。这部分一般不被通讯规约控制。因此,在不影响通讯协议功能实现的前提下,本文将不具体讨论物理层服务。

三、DLMS链路层协议

物理层之上即为链路层,链路层是物理层与应用层通信的通道。DLMS链路层使用的是HDLC高速链路控制协议。

链路层的构成:

链路层由两个子层构成,即LLC子层,和MAC子层。

(一) 、LLC子层(逻辑链路控制子层)

这一层的功能是将MAC子层的数据转发到应用层,或将应用层的数据转发到MAC子层。LLC子层只是作转发而不对数据做出处理。其存在的重要性在于向应用层提供链路传输的服务(从链路层接收或发送数据)。

具体到数据通讯时,对于client端应用层发送的数据,要加上LLC帧头(0xe6 , 0xe6, 0x00),server端应用层发送的数据,要加上LLC帧头 ( 0xe6  ,  0xe7 , 0x00)。

由于LLC子层链路传输服务的具体实现,可以不受DLMS协议的限制,由应用程序实现。故本文不具体说明LLC子层的各种服务。

(二)、MAC子层(媒体访问控制子层)

MAC子层在链路层中负责数据传输的可靠性,包括地址检查,数据的CRC校验,长数据帧的打包拆包等。这些工作对于数据通讯都是必不可少的,MAC子层功能的说明将是以下的重点。

1          HDLC帧格式

(1)       不包含应用层数据信息

0x7e

帧类型与帧长

目的地址域

源地址域

控制域

数据帧校验

0x7e

两个0x7e是HDLC数据帧固定的帧头与帧尾,两个0x7e之间是链用户数据。

(2)       包含应用层数据信息

0x7e

帧类型与帧长

目的地址域

源地址域

控制域

帧头校验

LLC帧头

用户数据信息

数据帧校验

0x7e

与不包含应用层数据信息的数据帧相比这里多了3项:

帧头校验:为增强通讯的可靠性,对帧头的数据也加上CRC校验。帧头包括如下                       字段:帧类型与帧长、目的地址域、源地址域、和控制域

LLC帧头:用户数据信息前要加0xe6 , 0xe6, 0x00或0xe6 , 0xe7, 0x00。

用户数据信息:应用层处理的数据。

注:出于数据完整性的考虑,用户数据信息的最大长度,默认为128字节。如果想要更多的字节,可以在SNRM数据帧中协议。

2          帧类型字段与‘S’位

帧类型与帧长字段,共两个字节。内容如下:

FrameType :用于指出当前数据帧的类型。HDLC有多种数据帧类型,DLMS使                               用Frame Type 3。FrameType恒为A(1010)。

S:(segmentation Bit)这个字段只有一位,它用于说明数据帧是否被分割。在长数                      据帧传输时要使用到这一位。长数据帧的传输将在后面解释。

FrameLength Sub-field :这个字段用于说明当前数据帧的长度,(以字节为单位,                           不包括两个0x7e)

3          地址解析

地址域分为两部分。目的地址域和源地址域。对于client端,目的地址为server的地址,源地址为client的地址。对于server端正好相反。

(1)扩展编址技术

HDLC使用扩展编址技术,即某一个地址字节的最低位如为0,则表明该地址域没有结束,仍有后续字节是该地址域的一部分。若某一地址字节最低位为1,则说明该地址域已经结束,没有后续字节。

(2)地址结构

Client端的地址永远是一个字节,由于扩展编址技术的使用,最低位置1,所以client       端的地址只能有128个。

Server端为了实现一个物理地址对应多个逻辑地址,将地址分成了两部分upper HDLCAddress 用于表述逻辑地址,lower HDLC address用于表述物理地址。Upper address总是应当有的,lower address在确认不需要的情况下,可以不出现。(sl7000 电表这两部分地址都是需要的)。

Server端的地址在使用扩展编址技术时,也并非是可以无限长(虽然在理论上可以,但在实践上是有上限的)。Server端的地址结构可以使用如下方式:

Onebyte: only the upper HDLC address is present.

一字节:只出现HDLC高位一字节地址。

两字节:只出现HDLC高位一字节地址,和HDLC低位一字节地址。

四字节:只出现HDLC高位两字节地址,和HDLC低位两字节地址

对于SL7000电表,经测试只有四字节sever地址结构可用。

(3)特殊地址

有一些地址被HDLC定为保留地址。这其中比较重要的是广播地址。

对于SL7000电能表,实践中可行的地址结构是client端一字节,server端4字节。对于DLMS协议族是可以使用上述地址结构中的任一种,并且支持特殊地址。

4          帧控制字

帧控制字字段主要负责,通讯中的帧计数,以及特殊数据帧的标识。

帧控制字字段结构如下:

对应项的解释如下:

RRR:为接收帧计数。

SSS:为发送帧计数。

注:对帧计数的解释,

在链路层连接建立之后,第一次请求数据时(在client端,包括发送AARQ)                 RRR置为0,SSS置为0。Server端收到这一帧数据后,返回数据响应RRR为1,                 SSS为0。Client再次请求数据时RRR加1,SSS加1。Server端收到这一帧数据后,              返回数据响应RRR加1(成为2),SSS加1。如此反复直到client得到所有的数据                为止。整个数据传输过程以I数据帧请求和响应。这里要说明的是在请求数据结束                 后还要再发送RR帧,收到确认后。才可以再发送DISC帧结束链路。其中Client端                的RR帧中的帧计数位RRR只需将client的帧计数位RRR加1得到。

下图描述了帧计数位的变化过程:

P/F:poll/final bit。

Poll bit :由client发送,置1时表示server端回应,置0时表示不允许回应。

final bit:由server发送,置1时表示一次数据帧的发送结束,置0时表示还未                         发送完。final bit只有在通讯窗口(window size)大于1的情况下才有意               义。在window size = 1时,由server端返回的数据帧中的这一位总是                     置1。(关于window size将会在“建立链路层连接”时解释)

几种不同的数据帧分别应用在不同的场合,下图列出了几种请求和响应的对应的情况。

I      :信息传输帧

RR   :准备接收数据帧(用来表示准备接收下一帧数据)

RNR:接收没有准备好(receive not ready)。相当于别的通讯协议中的忙帧。

SNRM:设置正常相应数据帧。用于建立链路层连接。

UA:对SNRM和DISC的响应帧。

DISC:结束链路帧。

DM:对DISC的响应帧。(Disconnected mode)

UI:可以用于保持链路,这个数据帧的发送,对于链路的控制没有任何影响。

FRMR:拒绝接收帧(Frame reject),由于不确定的某种原因拒绝接收到的数据帧。

5          长数据帧的传输

在很多情况下,数据不能在一次请求和一次响应中,就能够结束数据传输的过程(受限于用户数据字节不超过128字节)。这时就有必要启动长数据帧链路控制流程。

注:请求负荷曲线时一定是使用长数据帧。

当使用长数据帧时,必须把长数据帧分割成短数据帧。然后把这些短数据帧依次发送出去,在接收端将这些短数据帧依次处理。这样就实现了一个较大的数据包,完整的传送到接收端。

在数据帧被分割时,帧类型与帧长字段中的‘S’位,将被置1。当接收端检测到这一位被置位后,就知道数据帧已被分割,此时要做出对分割数据帧的相应处理。

下图介绍了长数据帧的收发过程:

client端通过发送RR数据帧来请求被分割的数据帧的其他部分。

6          数据帧校验

HDLC使用16位CRC校验。使用的多项式是:

具体的实现程序,可参照英文参考文献IEC62056 - 46的附录A。

(三)、链路层连接的建立,与断开

(1)建立连接

链路层在开始工作之前,要建立链路层连接(Association)。这一步骤是通过client端发送SNRM数据帧,server端响应UA数据帧表示已建立连接,server端响应DM数据帧表示链路断开,连接没有建立。

UA数据帧常含有链路参数的配置信息。链路参数是指2个控制数据传输的参数。

WINDOW_SIZE parameter;         这个参数描述通讯时,通讯的双方一次发送数据帧的数目。                                                 HDLC允许一次发送多帧数据。

MAXIMUM_INFORMATION_FIELD_LENGTHparameter . 最大信息域长度,这个参数用于描                                             述一个链路数据帧中用户数据的长度。

这两个参数的默认值如下

default WINDOW_SIZE = 1;

defaultMAXIMUM_INFORMATION_FIELD_LENGTH = 128(BYTEs)

具体在数据帧中有如下4个参数:

transmit maximum information field length 

receive maximum information field length 

transmit window size

receive window size

注:这里没有给出数据帧的具体格式,而是用举例来说明如何组帧。这种做法可能给读者带来不便。但在DLMS的规约原文中就是用这种办法,故这里仍这样做。

以下举例说明如何建立连接:

//SNRM

S: 7e a021 00 22 00 23 03 93 0b 14 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 0400 00 00 07 65 5e 7e

解释:

7e

a0 21      帧类型与帧长

00 22 0023    目的地址

03          源地址

93           控制字

0b 14     帧头校验

81 80   SNRM 标识

12          group lenth.

05Hparameter identifier (maximum information field length transmit)

01H parameter length (1 octet)

80H parameter value(128 bytes)

06Hparameter identifier (maximum information field length receive)

01H parameter length (1 octet)

80H parameter value  (128 bytes)

07Hparameter identifier (window size, transmit)

04H parameter length (4 octets)

00H parameter value  (high byte of value)

00H parameter value

00H parameter value

01Hparameter value  (low byte of value)

08Hparameter identifier (window size, receive)

04H parameter length (4 octets)

00H parameter value  (high byte of value)

00H parameter value

00H parameter value

07H parameter value  (low byte of value)

65 5e      数据帧校验(CRC校验)

7e

在SNRM数据帧中的用户信息可以不出现,表示client接收server端的已配置数据。

//UA

R: 7E A021 03 00 22 00 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 0400 00 00 01 53 3B 7E

解释:

7E//Flag

0xA0 21//(type=a :frame type 3 , s=0 :end of frame , len=021 : 33 bytes)

03//source address

00 22

00 23 //destination address

73 //control UA

28 F0 //hcs

81 80 12 05 01 80 06 01 80 07 04 00 00 0001 08 04 00 00 00 01

//information field

//parameter negotiation

//81

//80

//12

//05  0180                           :maximuminformation field length  transmit (128BYTEs)

//06  0180                           :maximuminformation field length  receive  (128 BYTEs)

//07  0400 00 00 01              :window size,transmit (1)

//08  0400 00 00 01              :window size,receive  (1)

53 3B//fcs

7E

(2)断开连接

断开连接由于不用参数设置,所以比建立连接要简单。Client端发送DISC数据帧,Server端响应UA或DM表示断开连接。UA表示接到DISC后断开连接。DM表示在接到DISC之前已处于断开状态。

一下仍给出具体的通讯实例:

S: 7e a0 0a 00 22 00 23 03 53 06 c7 7e

解释:

7e a0 0a 00 22 00 23 03

53 // 帧类型Disc

06 c7 7e

R: 7E A0 0A 03 00 22 00 23 1F 43 4C 7E

解释:

7E A0 0A 03 00 22 00 23

1F//帧类型DM

43 4C 7E

(四)、关于链路层的透明数据传输

0x7e

帧类型与帧长

目的地址域

源地址域

控制域

帧头校验

LLC帧头

用户数据信息

数据帧校验

0x7e

HDLC是一种透明数据传输的链路层协议。用户数据信息与链路层没有任何关系。在DLMS的协议模型中,链路层负责数据传输的可靠性,应用层处理用户数据信息。链路层为应用层数据的传输提供透明通道。

四、DLMS应用层协议

理解DLMS应用层协议,需要首先建立以下几个概念:

ASN.1语法,BER编码,AXDR编码。

ASN.1语法是用来描述应用层数据帧的。DLMS协议不同于其他一些简单通讯协议的地方就在于此。他不是用一些表格,及一些固定的帧格式来描述的,而是用一种抽象语法语言来描述。这样做的好处是,极大的提高了协议的抽象性和通用性,有利于程序移植。

BER编码和AXDR编码是用来实现ASN.1语法的。为了实现ASN.1的抽象性和通用性,这个语法要用特殊的编码来描述。这就引入了BER编码和AXDR编码。

以下分别解释这几项。

(一)ASN.1语法

一个用ASN.1语法描述的数据帧,看上去应该是下面的样子:

Name  ::=  [tag]        IMPLICIT/ EXPLICIT         Data type

{

null-data           [0] IMPLICIT NULL,

item1             [1] IMPLICIT/ EXPLICIT    Data type  A1 OPTIONAL

item2             [2] IMPLICIT/ EXPLICIT     Data type  A2 OPTIONAL

item3             [3] Data type

}

下面解释这个语法描述。

Name    -    是这个数据帧的名字。

Tag         -    tag包含两部分classtype 和一个数字

Class type有以下四种:

1)Universal  表明name定义的数据帧在所有的DLMS应用中的含义是唯                      一的。

2)Application 表明name定义的数据帧的含义同具体的应用有关。

3)Private      表明name定义的数据帧只在某一厂家的自定义范围之内。

4)Context-specific 表明name定义的数据帧同上下文数据项的含义有关。                            这种类型的数据,在不同的结构中可能有不同的含义。

Tag中的数字,是作为这个数据帧的标号存在的,它做为该数据帧的句柄出现               在应用数据单元中。

IMPLICIT/ EXPLICIT -     当前数据帧(称为子数据帧)可能派生于某一数据帧(称为父数                                          据帧),这个字段用来描述子数据帧同父数据帧的关系。

IMPLICIT  :     改变了父数据帧的Tag。

EXPLICIT :   不改变父数据帧的Tag。

不注明IMPLICIT的项即为EXPLICIT。

Data type -     描述数据帧的数据类型。数据类型分为简单型和复合型。多数数据类型可以从               名字看出其类型。以下列出了几种,完整的数据类型集合请参见附录。

        Type                     Tag number     Tag number
                             (decimal)      (hexadecimal)
    INTEGER                  2              02
    BIT STRING               3              03
    OCTET STRING             4              04
    NULL                     5              05
    OBJECT IDENTIFIER        6              06
    SEQUENCE and SEQUENCE OF 16             10
    SET and SET OF           17             11
    PrintableString          19             13
    T61String                20             14
    IA5String                22             16
    UTCTime                  23             17
 

“{}”-        大括号中的内容,即为数据帧中的数据项。每一数据项后的数字序号,即为该                     数据项的标识(tag)。每一数据项可以是对另一数据帧的复合。即一个数据                       帧通常是对其它数据帧的一种组合。

OPTIONAL - 这个关键字描述的数据项,在用户认为需要的场合可以省略。

比较重要的两种复合类型SEQUENCE和CHOICE 下面举例解释:

1)SEQUENCE : 数据帧中的内容是顺序排列的。下面以举例说明SEQUENCE类型。

Get-Request-Normal ::= SEQUENCE

{

invoke-id-and-priority           Invoke-Id-And-Priority,

cosem-attribute-descriptor   Cosem-Attribute-Descriptor,

access-selection-parameters Selective-Access-DescriptorOPTIONAL

}

这是一个在请求数据时常用的数据帧。SEQUENCE表明数据帧的内容是顺序排列的。

2)CHOICE :即选则类型,它表明当前数据帧是从几个数据帧中选择一种做为当前数                 据帧的类型。下面以举例说明CHOICE类型。

GET-Request ::= CHOICE

{

get-request-normal         [1] IMPLICIT Get-Request-Normal,

get-request-next                [2]IMPLICIT Get-Request-Next,

get-request-with-list           [3] IMPLICIT Get-Request-With-List

}

GET-Request数据帧只能填入三个选择项之一。

以上简单介绍了ASN.1语法,由这一语法描述的各种数据帧,将在附录中全部给出。这些各种各样的数据帧,将构成DLMS协议中Client同Server应用层交互时使用的语言。

读者如对ASN.1语法有不解之处,可参阅本文的英文参考文献【7】

(二)BER编码与AXDR编码

ASN.1只是一种语法,要把它写入数据帧中,就要把它转换为一个个数据字节。这就要一种(实际是两种)编码来实现这种语法。于是就引入了BER编码与AXDR编码。

在DLMS中用ASN.1描述的DLMS协议,用BER编码实现;用ASN.1描述的XDLMS协议用AXDR编码实现。

注:DLMS中只有AARQ与AARE数据帧的部分内容是使用DLMS协议的。绝大多数的应用层数据通讯使用XDLMS。这里无意对DLMS和XDLMS做出划分和解释,具体的解释可参见英文参考文献【2】。这里只需知道这两种协议使用不同的编码。

1 BER

编码的详细语法参见附录。

通常的BER编码采用如下结构,其中数据内容部分可以嵌套另一BER编码结构:

数据标识

数据长度

数据内容

数据长度,和数据内容从名字即可知道内容。

这里有必要解释一下数据标识的构成:

一个BER数据标识和一个BER数据长度构成一个16位的位串:

bit15                                                                                                                      bit0

datatype classes(bit15、14)

Data type(bit13)

data length(bit12-bit0)

1)datatype classes 字段:这一字段用于对ASN.1语法中的class type编码

Universal    (00)

Application  (01)

Context-specific  (10)

Private            (11)

2)Datatype字段:用于描述数据内容的结构

Primitive          (0)     简单类型

Constructed        (1)      复合类型(数组或结构)

3)datalength字段:用于描述数据内容的长度(以字节为单位)。

下面以接收到的AARE数据帧为例:

AARE数据帧的语法描述:

AARE-apdu ::= [APPLICATION1] IMPLICIT SEQUENCE

――[APPLICATION 1] == [ 61H ] = [ 97 ]

{

protocol-version                           [0] IMPLICIT BITSTRING {version1 (0) } DEFAULT{version1},

application-context-name          [1]Application-context-name,

result                                              [2] Association-result,

result-source-diagnostic            [3] Associate-source-diagnostic,

responding-AP-title                     [4] AP-title OPTIONAL,

responding-AE-qualifier            [5] AE-qualifier OPTIONAL,

responding-AP-invocation-id    [6] AP-invocation-identifier OPTIONAL,

responding-AE-invocation-id    [7] AE-invocation-identifier OPTIONAL,

-- The following field shall not be presentif only the kernel is used.

responder-acse-requirements  [8] IMPLICIT ACSE-requirements OPTIONAL,

-- The following field shall only be presentif the authentication functional unit is selected.

mechanism-name                              [9] IMPLICITmechanism-name OPTIONAL,

-- The following field shall only be presentif the authentication functional unit is selected.

responding-authentication-value     [10] EXPLICIT authentication-value OPTIONAL,

implementation-information              [29] IMPLICIT implementation-dataOPTIONAL,

user-information                                   [30]IMPLICIT association-information OPTIONAL

}

AARE数据帧的BER编码和AXDR编码实现:

61 //AARE tag

42 //AARE len

A1 //tag of COSEM_Application_Context_Name

09                        //数据长度

06                        //(OBJECTIDENTIFIER, Universal)OBJECT IDENTIFIER是一种                                          //ASN.1数据类型.

07                         //数据长度

6085 74 05 08 01 01 //数据内容

//以下的数据帧可以用同样的方法一一解释

A2 //Tag of Association-result,

03 02 01 00

A3 //Tag of Associate-source-diagnostic

05 A1 03 02 0100

88 //IMPLICIT ACSE-requirements OPTIONA

02 07 80

89 //IMPLICIT mechanism-name OPTIONAL

07 60 85 74 0508 02 01

AA //EXPLICIT authentication-value OPTIONAL

0A 80 08 41 4243 44 45 46 47 48

BE

04 // encoding the choice for user-information (OCTET STRING,Universal)

0E // encoding of the length of the OCTET STRING’s value field (14 octets)

/*以下内容为XDLMS用AXDR描述*/

08 //encoding the tag (explicit tag) of the DLMS PDU CHOICE(InitiateResponse)

00 // usage flag for the proposed-quality-of-service component(FALSE, not present)

06 //negotiated-dlms-version-number

5F 1F // encoding the [APPLICATION 31] tag (ASN.1 explicit tag)

04 // encoding the length of the 'contents' field in octet (4)

00 // encoding of the number of unused bits in the final octet ofthe bitstring

00 08 1D// encoding of the fixed length BITSTRING value

21 34 // the A-XDR encoding of an Unsigned16 is its value

0007 // the A-XDR encoding of an Unsigned16 is its value . 00 07 == LN

2  A-XDR:

这种编码是对unix的XDR(外部数据标识法)编码的扩展。参见IEC61334采用配线载波的配电自动化,译文汇编,下册,第六部分。本文参考文献【9】

3     两种编码的比较:

A-XDR编码,与BER编码的区别可从下例看出。

对两数进行编码,其值分别为0x1234,0x5678

1) 用BER编码

30

08

02

02

12

34

34

02

56

78

序列标识

序列长度

A的标识(整型)

A的字长

A的数值

B的标识(整型)

B的字长

B的数值

2) 用AXDR编码

1

12

34

56

78

序列标识

A的数值

B的数值

这里给出一个AXDR编码的实例:

注:这里的语法仍是ASN.1但将采用不同的编码。

ASN.1语法描述:(这一数据帧是AARQ数据帧的一部分)

xDLMS-Initiate.request ::= SEQUENCE

{

dedicated-key OCTET STRINGOPTIONAL,

response-allowed BOOLEANDEFAULT TRUE,

proposed-quality-of-service[0] IMPLICIT Integer8 OPTIONAL,

proposed-dlms-version-numberUnsigned8,

proposed-conformanceConformance,

client-max-receive-pdu-sizeUnsigned16

}

AXDR编码:

01--------------------------------------------------------dlmspuu标识

00 ----------------------------------//usageflag for the dedicated-key component (FALSE, not present)

00--------------- //usage flag for theresponse-allowed component (FALSE, default value conveyed)

00-------------- //usage flag for theproposed-quality-of-service component (FALSE, not present)

06-------------- //the A-XDR encoding of anUnsigned8 is its value

5f ---------- //encoding the [APPLICATION31] tag (ASN.1 explicit tag)

04---------- //encoding the length of the'contents' field in octet (4)

00-----//encoding of the number of unused bits in the final octet of the BITSTRING

00 00 10------- // encoding of the fixedlength bitstring value.(LN/SN)

00 80 // client-max-receive-pdu-size(128 bytes)

(三)AARQ与AARE数据帧

有了基本的语法和编码的概念后,下面就开始讨论具体的DLMS应用层协议。在前面的DLMS协议模型中已经说明,在进行应用层数据通讯之前,要建立链路层连接和应用层连接。链路层连接已经在链路层协议中解释过,下面讲如何建立应用层连接。

应用层连接的建立是通过client端发送AARQ数据帧,server端响应AARE数据帧来实现的。这两个数据帧主要是配置应用层数据通讯的参数。

关于AARQ,AARE:

在标准的面向连接的应用层服务控制(ACSE)中,为了同服务的使用者进行交互,ACSE提供了很多功能单元。在COSEM中只使用了其中的两个:the kernel and theauthentication functional units.

(一) AARQ , AARE数据帧的具体描述(ASN.1语法描述):

AARQ-apdu ::= [APPLICATION0] IMPLICIT SEQUENCE

{

protocol-version                          [0] IMPLICIT BIT STRING{version1 (0) } DEFAULT{version1},

application-context-name         [1] Application-context-name,

called-AP-title                               [2] AP-title OPTIONAL,

called-AE-qualifier                      [3] AE-qualifier OPTIONAL,

called-AP-invocation-id              [4] AP-invocation-identifier OPTIONAL,

called-AE-invocation-id             [5] AE-invocation-identifier OPTIONAL,

calling-AP-title                              [6] AP-title OPTIONAL,

calling-AE-qualifier                    [7] AE-qualifier OPTIONAL,

calling-AP-invocation-id            [8] AP-invocation-identifier OPTIONAL,

calling-AE-invocation-id             [9] AE-invocation-identifier OPTIONAL,

. Thefollowing field shall not be present if only the kernel is used.

. sender-acse-requirements     [10]IMPLICIT ACSE-requirements OPTIONAL,

-- The following field shall only be presentif the authentication functional unit is selected.

mechanism-name                     [11] IMPLICIT mechanism-nameOPTIONAL,

-- The following field shall only be presentif the authentication functional unit is selected.

calling-authentication-value      [12] EXPLICIT authentication-value OPTIONAL,

implementation-information   [29] IMPLICIT implementation-data OPTIONAL,

user-information                         [30] IMPLICITassociation-information OPTIONAL

}

AARE-apdu ::= [APPLICATION1] IMPLICIT SEQUENCE

{

protocol-version                           [0] IMPLICIT BITSTRING {version1 (0) } DEFAULT{version1},

application-context-name          [1]Application-context-name,

result                                              [2] Association-result,

result-source-diagnostic            [3] Associate-source-diagnostic,

responding-AP-title                     [4] AP-title OPTIONAL,

responding-AE-qualifier            [5] AE-qualifier OPTIONAL,

responding-AP-invocation-id    [6] AP-invocation-identifier OPTIONAL,

responding-AE-invocation-id    [7] AE-invocation-identifier OPTIONAL,

-- The following field shall not be presentif only the kernel is used.

responder-acse-requirements  [8] IMPLICIT ACSE-requirements OPTIONAL,

-- The following field shall only be presentif the authentication functional unit is selected.

mechanism-name                              [9] IMPLICITmechanism-name OPTIONAL,

-- The following field shall only be presentif the authentication functional unit is selected.

responding-authentication-value     [10] EXPLICIT authentication-value OPTIONAL,

implementation-information              [29] IMPLICIT implementation-dataOPTIONAL,

user-information                                   [30]IMPLICIT association-information OPTIONAL

}

被标记为OPTIONAL的项,在组成数据帧时都是可以被省略的。但有如下几个例外:

(1)    user-information携带着XDLMS信息(XDLMS将在稍后解释),是永远不能被省略的。

(2)      如Server端声明了身份校验(要求提供密码登陆),则AARQ中的sender-acse-requirements,mechanism-name,calling-authentication-value,AARE中的responder-acse-requirement,mechanism-name ,responding-authentication-value 都是不能被省略的。如果省略这些项,则请求数据将被拒绝。

(二)AARQ , AARE数据帧中各项的解释:

1     AARQ

protocol-version: 即 ACSE protocol-version. 使用默认值在数据帧中不出现。

application-contex-name:这项是必须项,对于目前的使用情况这个值是唯一的。(0x60 0x85     0x74 0x050x08 0x01 0x01,具体含义不解释了,可参见IEC62056-53 的7.3.7.1)

sender and responder acse requirements: 指明是否使用ACSE authentication功能(请求数据等),       使用BER位串编码,只使用BIT0位。该位置位时表明使用authentication功能

例:

8a // the tag for the acse-requirements field component ([10],IMPLICIT, Context-specific )

02 //Len

//the sender-acse-requirements component (ACSE-requirements::= BIT STRING)

07 //the number of unused bits in the last byte of the BITSTRING

80 //encoding of the authentication functional unit (0)。最高位置1其余的为unused bits。

mechanism-name:用于指明使用何种Authentication。共有4种。

calling and authentication value: 指出Authentication的值(即密码)。

user-information: 内容即为xDLMS-Initiate.requestPDU,xDLMS-Initiate.request的内容如            下。

xDLMS-Initiate.request :: = SEQUENCE

{

dedicated-key OCTET STRING OPTIONAL,

response-allowed BOOLEAN DEFAULT TRUE,

proposed-quality-of-service [0] IMPLICIT Integer8 OPTIONAL,

proposed-dlms-version-number Unsigned8,

proposed-conformance Conformance,

client-max-receive-pdu-size Unsigned16

}

下面分别解释xDLMS-Initiate.request的各项内容:

dedicated-key :指出数据是否被加密(ciphering)。通常不用。

response-allowed :是否允许回应。通常允许。

proposed-quality-of-service:通常不用。

proposed-dlms-version-number:目前是6

proposed-conformance :这是主体部分,主要描述需要server端提供的XDLMS服务类型和种类。

它是一个24位的位串,如上图所示,每一位都代表一种服务,具体解释如下:

Attibute_0 referencingwith SET is not supported (Bit_08)

Priority Management issupported (Bit_09)

Attibute_0 referencingwith GET is supported (Bit_10)

Block Transfer with theGET service is supported (Bit_11)

Block Transfer with theSET service is supported (Bit_12)

Block Transfer with theACTION service is supported (Bit_13)

Multiple references aresupported (Bit_14)

All LNservices (GET, SET, ACTION,EVENT NOTIFICATION) are supported (Bit_19, 20, 22,23)

Selective Access featureis supported (Bit_21)

这里提供的多种服务,对于采集器抄表来说,对于采集器最重要的服务是GET service,即读取数据的功能。通常这个24位的位串被定义为0x00,0x00,0x10即可。即只使用LN services的GET service。

client-max-receive-pdu-size:client端接受数据的最大限制。设为0x0000 表明使用默认设置,则应用层数据单元最长为128字节。

例:以下为接受到的一个最长数据单元

R:

7E A8 8C 03 00 22 00 23 BA88 4D    //HDLC 帧头

00 00 00 02 02 0F 00 16 1E02 03 09 06 01 01 3E 08 00 FF 06 00 00 00 00 02 02 0F 00 16 1E

02 03 09 06 01 01 02 08 00FF 06 00 4B 09 74 02 02 0F 00 16 1E 02 03 09 06 01 01 17 08 00 FF 06 00 00 7E72 02 02 0F 00 16 20 02 03 09 06 01 01 2B 08 00 FF 06 00 00 01 2C 02 02 0F 0016 20 02 03 09 06 01 01 3F 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 02 03 0906 01 01 03 08 00 FF 06 00 00 7F                    //应用层数据单元128字节

2A EA 7E                                          //HDLC帧尾

(IMPORTANT For compliance with existing implementations, encoding ofthe [Application 31] tag on one byte (5F)

instead of two bytes (5F1F) is accepted when the 3-layer, connection-oriented, HDLC based profile isused.)

2          AARE

protocol-version: 即 ACSE protocol-version. 使用默认值在数据帧中不出现。

result: Server端对于Client端的连接请求回复的结果

result-source-diagnostics: Server端拒绝Client端的连接请求,在这里给出原因。

application-context-name: 同AARQ

responding authentication value: 同AARQ

user-information: 内容即为xDLMS-Initiate.responsePDU,xDLMS-Initiate.response的内容          如下。

xDLMS-Initiate.response :: = SEQUENCE

{

negotiated-quality-of-service                               [0] IMPLICIT Integer8 OPTIONAL,

negotiated-dlms-version-number Unsigned8,

negotiated-conformance Conformance,

server-max-receive-pdu-size Unsigned16,

vaa-name ObjectName

}

下面分别解释xDLMS-Initiate. response的各项内容:

negotiated-quality-of-service: 对应于xDLMS-Initiate.request的proposed-quality-of-service, 通                                               常不用。

negotiated-dlms-version-number:对应于xDLMS-Initiate.request 的

proposed-dlms-version-number,目前是6

negotiated-conformance :这里是server端对client端请求的XDLMS服务的回应。如果允许client                                              端的请求,就对相应的位置1。位串的模式与                                                                 xDLMS-Initiate.request 的conformance相同

server-max-receive-pdu-size: server端可以接收的应用数据单元的最大限制。对于采集器而                                                  言,通常不会向server端发送很长的数据帧。

vaa-name : 目前此项没有什么用处,server端只是回应一默认值0x0007。

3 其它项

AARQ,AARE数据帧中其它标为OPTIONAL的项,可以在数据帧中不出现,如果一旦在client端出现,而server端没有相应的处理,则server端只会把这些项略过,不作处理,而不会影响连接的建立。

4 实例

这里给出一AARQ、AARE通讯实例。

//aarq

S: 7e a047 00 22 00 23 03 10 d0 5e e6 e6 00 60 36 a1 09 06 07 60 85 74 05 08 01 01 8a02 07 80 8b 07 60 85 74 05 08 02 01 ac 0a 80 08 41 42 43 44 45 46 47 48 be 1004 0e 01 00 00 00 06 5f 1f 04 00 00 08 1d 00 00 9a 7a 7e

解释:

{

7e

a0 47 //

00 22 00 23 //

03

10

d0 5e

e6 e6 00 //LLC

{

60 // AARQ tag

36 // length

//     Theapplication-context-name must be in.

a1 //tag for theapplication-context-name component

09 //the length of the taggedcomponent value field

06 // data type choice forapplication-context-name (OBJECT IDENTIFIER,

Universal)

07 // Len

60 85 74 05 08 01 01//(context_id = 1 ; means LN referncing);

//COMMENT by DL : The most important part of thisapplication-context-name //is that it chooses LN referencing or SN referencing.

//encoding the sender-acse-requirementsfield component (tagged component, [10]

8a //encoding the tag for theacse-requirements field component

([10], IMPLICIT,Context-specific )

02 //Len

//thesender-acse-requirements component (ACSE-requirements ::= BIT STRING)

07 //the number of unusedbits in the last byte of the BIT STRING

80 //encoding of theauthentication functional unit (0)

//encoding themechanism-name component (tagged component [11])

8b //the tag for the mechanism-name component ([11], IMPLICIT,Context-specific)

07 //the length of the tagged component's value field

60 85 74 05 08 02 01 //thevalue of the Object Identifier

ac //the tag for the mechanism-name component ([12], Context-specific)

0a //Len

80 //the choice forAuthentication-information (charstring [0] IMPLICIT GraphicString)

08 //Len

41 42 43 44 45 46 47 48

/* User information can't beignored. */

be //user information(x-DLMS context)

10 //Len (according to bytes)

{

04 //data type choice foruser-information (OCTET STRING, Universal)

0e //Len = 14 bytes

01 00 00 00 06 5f 1f 04 00 00 08 1d 00 00

//the octet sequence of the xDLMS-Initiate.requestPDU.

/*

xDLMS-Initiate.request:: = SEQUENCE

{

dedicated-key                                   OCTETSTRING OPTIONAL,

response-allowed                       BOOLEAN DEFAULTTRUE,

proposed-quality-of-service          [0] IMPLICIT Integer8 OPTIONAL,

proposed-dlms-version-number   Unsigned8,

proposed-conformance               Conformance,

client-max-receive-pdu-size Unsigned16

}

Theclient-max-receive-pdu-size is 1200D = 0x4B0.

*/

/*

01 //the tag (explicit tag)of the DLMS PDU CHOICE

//--dedicated-key

00 //usage flag for thededicated-key component (FALSE, not present)

//--response-allowed

00 //usage flag for the response-allowedcomponent (FALSE, default value conveyed)

//--proposed-quality-of-service

00 //usage flag for theproposed-quality-of-service component (FALSE, not present)

//--proposed-quality-of-service

06 //the A-XDR encoding ofan Unsigned8 is its value

//--proposed-conformance

5f 1f //encoding the[APPLICATION 31] tag (ASN.1 explicit tag)

04 //encoding the length of the 'contents'field in octet (4)

00 //encoding of the number ofunused bits in the final octet of the BITSTRING

00 08 1d // encoding of the fixed lengthbitstring value.(LN/SN)

//--client-max-receive-pdu-size

00 00 //the A-XDRencoding of an Unsigned16 is its value.

*/

}

}

9a 7a

7e

}

//aare

R: 7E A053 03 00 22 00 23 30 40 A6 E6 E7 00 61 42 A1 09 06 07 60 85 74 05 08 01 01 A203 02 01 00 A3 05 A1 03 02 01

00 88 02 07 80 89 07 60 85 74 05 08 02 01 AA 0A 80 08 41 42 43 44 45 4647 48 BE 10 04 0E 08 00 06 5F 1F 04

00 00 08 1D 21 34 00 07 72 A4 7E

{

7E

A0 53

03

00 22 00 23

30

40 A6

E6 E7 00

61 //AARE tag

42 //AARE len

{

A1//COSEM_Application_Context_Name

09

06 //type = Objectidentifier

07 //length = 07

60 85 74 05 08 01 01

A2 //Tag of Association-result,

03 //Len of Association-result,

02 //type = structure

01 //length = 1

00 //

/*

Association-result ::= INTEGER

{

accepted (0),

rejected-permanent (1),

rejected-transient (2)

}

encoding the result component(tagged component [2])

A2 // encoding the tag &length for the result component ([2], Context-specific )

03 // encoding of the length of the tagged component¡¯s value field

-- encoding the result-component(INTEGER)

02 // encoding the choice for result(INTEGER, Universal)

01 // encoding of the length of theresult¡¯s value field (1 octets)

00 // encoding of the value of theResult (0, accepted)

*/

A3 //Tag ofAssociate-source-diagnostic,

05 //Len ofAssociate-source-diagnostic

A1

03

0201 00

/*

Associate-source-diagnostic ::=CHOICE

{

acse-service-user                  [1] INTEGER

{

null (0),

no-reason-given (1),

application-context-name-not-supported(2),

authentication-mechanism-name-not-recognised(11),

authentication-mechanism-name-required(12),

authentication-failure(13),

authentication-required(14)

},

acse-service-provider            [2] INTEGER

{

null (0),

no-reason-given (1),

no-common-acse-version(2)

}

}

-- encoding theresult-source-diagnostic (tagged component [3])

A3 //encoding the tag for the result-source-diagnostic component ([3],Context-specific )

05 //encoding of the length of the tagged component¡¯s value field

A1 //encoding the tag for the acse-service-user CHOICE (1)

03 //encoding of the length of the tagged component's value field

--encoding the result-source-diagnostics component (INTEGER)

02 //encoding the choice for result-source-diagnostics (INTEGER, Universal)

01 //encoding of the length of the value field (1 octets)

00 //encoding of the value: 0, no diagnostics provided.

*/

//Contents below can be ignored.

88 //IMPLICIT ACSE-requirementsOPTIONAL

02

07

80

89 //IMPLICIT mechanism-nameOPTIONAL

07

60 85 74 05 08 02 01

AA //EXPLICIT authentication-valueOPTIONAL

0A

80

08

41 42 43 44 45 46 47 48

//User information must be exist.

/*

xDLMS-Initiate.response :: =SEQUENCE

{

negotiated-quality-of-service                             [0] IMPLICITInteger8 OPTIONAL,

negotiated-dlms-version-number                               Unsigned8,

negotiated-conformance                                           Conformance,

server-max-receive-pdu-size                                     Unsigned16,

vaa-name                                                                ObjectName

}

*/

BE //User information (x-DLMScontext)

10

{

04 // encoding the choicefor user-information (OCTET STRING, Universal)

0E // encoding of thelength of the OCTET STRING¡¯s value field (14 octets)

//-- A-XDR encoding thexDLMS-Initiate.response PDU

08 //encoding the tag (explicit tag) of theDLMS PDU CHOICE (InitiateResponse)

//-- encoding the negotiated-quality-of-servicecomponent (OPTIONAL, not present)

00 // usage flag for theproposed-quality-of-service component (FALSE, not present)

//-- encoding of thenegotiated-dlms-version-number component (Unsigned8, value=6)

06 //negotiated-dlms-version-number

//-- encoding the conformance block[APPLICATION 31] IMPLICIT BITSTRING (SIZE(24))

5F 1F // encoding the [APPLICATION 31] tag(ASN.1 explicit tag)

04 // encoding the length of the'contents' field in octet (4)

00 // encoding of the number of unused bitsin the final octet of the bitstring

// encodingof the fixed length BITSTRING value

00 08 1D

//-- encoding theserver-max-receive-pdu-size component (Unsigned16, value=0x01F4)

21 34 // the A-XDR encoding of an Unsigned16is its value

//-- encoding the VAA-Name component(Unsigned16, value=0x0007 for LN and FA 00 for SN)

00 07 // the A-XDR encoding of an Unsigned16is its value . 00 07 == LN

}

}

72 A4

7E

(四)必要的数据请求帧,和响应帧

在应用层连接建立之后,client就可以向server请求数据了。这里只介绍两个基本的数据通讯帧。

所有的DLMS应用数据帧都是COSEMpdu的一部分下面首先列出COSEMpdu。

COSEMpdu ::= CHOICE {

-- standardized DLMS PDUs used in COSEM

-- DLMS PDUs (no encryption selected30)

initiateRequest                           [1] IMPLICIT InitiateRequest,

readRequest                              [5] IMPLICIT ReadRequest,

writeRequest                       [6] IMPLICIT WriteRequest,

initiateResponse                        [8] IMPLICIT InitiateResponse,

readResponse                           [12] IMPLICIT ReadResponse,

writeResponse                           [13] IMPLICIT WriteResponse,

confirmedServiceError               [14] ConfirmedServiceError,

unconfirmedWriteRequest          [22] IMPLICIT UnconfirmedWriteRequest,

informationReportRequest          [24] IMPLICIT InformationReportRequest,

-- the two ACSE APDUs

aarq AARQ-apdu

aare AARE-apdu,

-- APDUs used for data communication servicesusing LN referencing

get-request                                [192] IMPLICIT GET-Request,

set-request                                [193] IMPLICIT SET-Request,

event-notification-request          [194] IMPLICIT EVENT-NOTIFICATION-Request,

action-request                            [195] IMPLICIT ACTION-Request,

get-response                             [196] IMPLICIT GET-Response,

set-response                             [197] IMPLICIT SET-Response,

action-response                         [199] IMPLICIT ACTION-Response,

-- global ciphered pdus

glo-get-request                          [200] IMPLICITOCTET STRING,

glo-set-request                          [201] IMPLICITOCTET STRING,

glo-event-notification-request    [202] IMPLICIT OCTET STRING,

glo-action-request                      [203] IMPLICITOCTET STRING,

glo-get-response                       [204] IMPLICITOCTET STRING,

glo-set-response                        [205] IMPLICITOCTET STRING,

glo-action-response                   [207] IMPLICITOCTET STRING,

-- dedicated ciphered pdus

ded-get-request                         [208] IMPLICITOCTET STRING,

ded-set-request                         [209] IMPLICITOCTET STRING,

ded-event-notification-request   [210] IMPLICIT OCTET STRING,

ded-actionRequest                     [211] IMPLICITOCTET STRING,

ded-get-response                      [212] IMPLICITOCTET STRING,

ded-set-response                       [213] IMPLICITOCTET STRING,

ded-action-response                  [215] IMPLICITOCTET STRING

}

这里要说明一下OBIS:

在数据请求帧中,必须有Cosem-Attribute-Descriptor项:

Cosem-Attribute-Descriptor ::= SEQUENCE

{

class-id Cosem-Class-Id,

instance-id Cosem-Object-Instance-Id,

attribute-id Cosem-Object-Attribute-Id

}

其中的class-id  attribute-id由本文参考文献【1】定义。

Cosem-Object-Instance-Id由本文参考文献【5】定义。

由参考文献【5】定义的内容即OBIS。它是由COSEM定义的一系列编码,共6个字节长。他的作用就是为每一种数据类型提供一个唯一的编码。有关OBIS的具体内容请参阅参考文献【5】。

1)    数据请求帧

GET-Request ::= CHOICE

{

get-request-normal        [1] IMPLICIT Get-Request-Normal,

get-request-next            [2] IMPLICIT Get-Request-Next,

get-request-with-list       [3] IMPLICIT Get-Request-With-List

}

Get-Request-Normal ::= SEQUENCE

{

invoke-id-and-priority                 Invoke-Id-And-Priority,

cosem-attribute-descriptor            Cosem-Attribute-Descriptor,

access-selection-parameters           Selective-Access-Descriptor OPTIONAL

}

Cosem-Attribute-Descriptor ::= SEQUENCE

{

class-id Cosem-Class-Id,

instance-id Cosem-Object-Instance-Id,

attribute-id Cosem-Object-Attribute-Id

}

Cosem-Object-Instance-Id ::= OCTET STRING(SIZE(6))

Cosem-Object-Attribute-Id ::= Integer8

以请求反向有功为例:

S: 7e a0 1c 00 22 00 23 03 54 bd 5e e6 e6 00c0 01 81 00 03 01 01 02 08 00 ff 02 00 9f 36 7e

解释:

7e a0 1c 00 22 00 23 03 54 bd 5e e6 e6 00 //Hdlchead

c0 // get-request                                Cosemapdu[192]

01 //Request Nomal

81 // invoke-id(000 0001) and priority(1)

00 // Get-Data-Result = data

03//Class id

01 01 02 08 00 ff //反向总有功 OBIS

02 00 //反向总有功的第二属性,值域。

9f 36 7e //HDLC Tail

2)    数据响应帧

GET-Response ::= CHOICE

{

get-response-normal                  [1]IMPLICIT Get-Response-Normal,

get-response-with-datablock              [2]IMPLICIT Get-Response-With-Datablock,

get-response-with-list                 [3]IMPLICIT Get-Response-With-List

}

Get-Response-Normal ::= SEQUENCE

{

invoke-id-and-priority                 Invoke-Id-And-Priority,

result                                         Get-Data-Result

}

Get-Data-Result ::= CHOICE

{

data [0] Data,

data-access-result [1] IMPLICIT Data-Access-Result

}

Data ::= CHOICE

{

null-data                       [0]IMPLICIT NULL,

array                            [1]IMPLICIT SEQUENCE OF Data,

structure                      [2]IMPLICIT SEQUENCE OF Data,

boolean                       [3]IMPLICIT BOOLEAN,

bit-string                      [4]IMPLICIT BIT STRING,

double-long                 [5]IMPLICIT Integer32,

double-long-unsigned   [6]IMPLICIT Unsigned32,

floating-point               [7]IMPLICIT OCTET STRING(SIZE(4))33,

octet-string                  [9]IMPLICIT OCTET STRING,

visible-string                [10]IMPLICIT VisibleString,

time                             [11]IMPLICIT GeneralizedTime,

bcd                             [13]IMPLICIT Integer8,

integer                         [15]IMPLICIT Integer8,

long                             [16]IMPLICIT Integer16,

unsigned                      [17]IMPLICIT Unsigned8,

long-unsigned                     [18]IMPLICIT Unsigned16,

compact-array              [19]IMPLICIT SEQUENCE

{

contents-description    [0]TypeDescription,

array-contents              [1]IMPLICIT OCTET STRING

}

long64                                [20]IMPLICIT Integer64,

long64-unsigned                  [21]IMPLICIT Unsigned64,

enum                                  [22]IMPLICIT ENUMERATED,

float32                                [23]IMPLICIT OCTET STRING (SIZE(4)),

float64                                [24]IMPLICIT OCTET STRING (SIZE(8)),

don’t-care                           [255]IMPLICIT NULL

}

Data-Access-Result ::= ENUMERATED

{

success                              (0),

hardware-fault              (1),

temporary-failure                 (2),

read-write-denied                 (3),

object-undefined                 (4),

object-class-inconsistent     (9),

object-unavailable               (11),

type-unmatched                  (12),

scope-of-access-violated    (13),

data-block-unavailable         (14),

long-get-aborted                 (15),

no-long-get-in-progress       (16),

long-set-aborted                  (17),

no-long-set-in-progress        (18),

other-reason                        (250)

}

以响应“请求反向有功”为例:

R: 7E A0 18 03 00 22 00 23 74 E4 13 E6 E7 00C4 01 81 00 06 00 35 7B 18 CD E8 7E

解释:

7E A0 18 03 00 22 00 23 74 E4 13 E6 E700  //Hdlc head

C4 01 //Response Normal

81 // invoke-id(000 0001) and priority(1)

00 //by data

06 //数据长度

00 35 7B 18 //反向有功值

CD E8 7E//HDLC Tail

五、对于接收到的数据帧的拆解

接收到的请求数据都是按照AXDR编码的。接收到的数据帧的数据结构,在参考文献【7】中都有详细解释。

以下给出数据帧解析的实例:

例:Load_profile

//hdlclink

//SNRM

S: 7e a021 00 22 00 23 03 93 0b 14 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 0400 00 00 07 65 5e 7e

//UA

R: 7E A021 03 00 22 00 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 0400 00 00 01 53 3B 7E

//aarq

S: 7e a047 00 22 00 23 03 10 d0 5e e6 e6 00 60 36 a1 09 06 07 60 85 74 05 08 01 01 8a02 07 80 8b 07 60 85 74 05 08 02 01 ac 0a 80 08 41 42 43 44 45 46 47 48 be 1004 0e 01 00 00 00 06 5f 1f 04 00 00 08 1d 00 00 9a 7a 7e

//aare

R: 7E A053 03 00 22 00 23 30 40 A6 E6 E7 00 61 42 A1 09 06 07 60 85 74 05 08 01 01 A203 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 89 07 60 85 74 05 08 02 01 AA 0A80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 08 00 06 5F 1F 04 00 00 08 1D 21 3400 07 72 A4 7E

//

S: 7e a00a 00 22 00 23 03 31 12 87 7e

R: 7E A00A 03 00 22 00 23 31 3F 84 7E

S: 7e a00a 00 22 00 23 03 31 12 87 7e

R: 7E A00A 03 00 22 00 23 31 3F 84 7E

//requestdata

S: 7e a01c 00 22 00 23 03 32 8d 58 e6 e6 00 c0 01 81

00 07 0000 63 80 01 ff   02 00

44 58 7e

R: 7E A04F 03 00 22 00 23 52 07 E2 E6 E7 00 C4 01 81 00

01 01 //1 array

02 06 //6 strures

09 06 01 01 01 1B 00 FF //1

02 02 0F 03 16 1B          //2

09 06 01 01 02 1B 00 FF //3

02 02 0F 03 16 1B          //4

09 0C 07 D3 05 08 FF FF FF FF FF FF FF FF     //5

09 0C 07 D3 05 17 FF FF FF FF FF FF FF FF     //6

F6 CE 7E

S: 7e a00a 00 22 00 23 03 51 14 e4 7e

R: 7E A00A 03 00 22 00 23 51 39 E7 7E

S: 7e a01c 00 22 00 23 03 54 bd 5e e6 e6 00 c0 01 81 00 07

ff ff 62 85 02 ff

02 00

7a 23 7e

R: 7E A88C 03 00 22 00 23 74 FA 62 E6 E7 00 C4 01 81 00

01 //arry

01 //total 1 array

02 //structure

34 //total 52 structure

02 03 //3 structure

09 06             01 01 15 08 00 FF         //octetstring , 6 bytes long ,obiscode(01 01 15 08 00 FF)

06                  0000 00 00                         //Unsigned32(0x06),data (00 00 00 00)

02 02      //scal and unit.02 typ=strcture, 02 num = 2 strctures.

0F 00      // scal :Êý¾ÝÀàÐÍInteger8(0x0f),Êý¾ÝÄÚÈÝdata (0x00)   //¼û62056µÄpdf

16 1E      // unit :ENUMERATED(0x16) , data(0x1e =wh)

//unit:enum.Thiscan be founded in Blue book 3rd edition.

//attention (By DL): according to XDR ,whena datatype(Such as octet string,array ,stucture)

//can't express the data length ,a datalength byte should exist.On the other hand ,when the length can be expressed by

//the data type(such asInteger8,Unsigned32,and ENUMERATED),the length byte arnn't exist.

//¸ù¾ÝBER±àÂë??

02 03

09 06 01 01 29 08 00 FF              06 00 00 00 00 02 02     0F 00 16 1E

02 03

09 06 01 01 3D 08 00 FF             06 00 00 00 00 02 02     0F 00 16 1E

02 03

09 06 01 01 01 08 00 FF              06 00 00 00 00 02 02     0F 00 16 1E

02 03

09 06 01 01 16 08 00 FF              06 00 2E 6E FE 02 02   0F 00 16 1E

02 03

09 06 01 01 2A 08 00 FF             06 00

9E 5D 7E

S: 7e a00a 00 22 00 23 03 71 16 c5 7e

R: 7E A88C 03 00 22 00 23 76 E8 41

00 00 00 02 02   0F 00 16 1E          02 03

09 06 0101 3E 08 00 FF 06 00 00 00 00 02 02     0F 00 16 1E          0203

09 06 0101 02 08 00 FF  06 00 2E 6E FE 02 02   0F 00 16 1E          0203

09 06 0101 17 08 00 FF  06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 2B 08 00 FF 06 00 00 00 82 02 02     0F 00 16 20           0203

09 06 0101 3F 08 00 FF 06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 03 08 00 FF  06 00 00 00

CB 00 7E

S: 7e a00a 00 22 00 23 03 91 18 22 7e

R: 7E A88C 03 00 22 00 23 78 96 A8

82 02 02  0F00 16 20           02 03

09 06 0101 18 08 00 FF  06 00 03 C2 EE 02 02   0F 00 16 20           0203

09 06 0101 2C 08 00 FF 06 00 00 00 82 02 02     0F 00 16 20           0203

09 06 0101 40 08 00 FF  06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 04 08 00 FF  06 00 03 C3 70 02 02    0F 00 16 20           0203

09 06 0101 19 08 00 FF  06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 2D 08 00 FF 06 00 00 00 50 02

88 CB7E

S: 7e a00a 00 22 00 23 03 b1 1a 03 7e

R: 7E A88C 03 00 22 00 23 7A 84 8B

02       0F00 16 20           02 03

09 06 0101 41 08 00 FF  06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 05 08 00 FF  06 00 00 00 50 02 02     0F 00 16 20           0203

09 06 0101 1A 08 00 FF 06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 2E 08 00 FF 06 00 00 00 32 02 02     0F 00 16 20           0203

09 06 0101 42 08 00 FF  06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 06 08 00 FF  06 00 00 00 32 02 02     0F

B9 E0 7E

S: 7e a00a 00 22 00 23 03 d1 1c 60 7e

R: 7E A88C 03 00 22 00 23 7C B2 EE

00 16 20          0203

09 06 0101 1B 08 00 FF 06 00 03 C2 EE 02 02   0F 00 16 20           0203

09 06 0101 2F 08 00 FF 06 00 00 00 64 02 02     0F 00 16 20           0203

09 06 0101 43 08 00 FF  06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 07 08 00 FF  06 00 03 C3 52 02 02    0F 00 16 20           0203

09 06 0101 1C 08 00 FF 06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 30 08 00 FF  06 00 00 00 1E 02 02    0F 00 16

A8 C8 7E

S: 7e a00a 00 22 00 23 03 f1 1e 41 7e

R: 7E A88C 03 00 22 00 23 7E A0 CD

20         0203

09 06 0101 44 08 00 FF  06 00 00 00 00 02 02     0F 00 16 20           0203

09 06 0101 08 08 00 FF  06 00 00 00 1E 02 02    0F 00 16 20           0203

09 06 0101 1D 08 00 FF 06 00 00 00 00 02 02     0F 00 16 1F           0203

09 06 0101 31 08 00 FF  06 00 00 02 62 02 02     0F 00 16 1F           0203

09 06 0101 45 08 00 FF  06 00 00 00 00 02 02     0F 00 16 1F           0203

09 06 0101 09 08 00 FF  06 00 00 02 62 02 02     0F 00 16 1F           02

5B 0C 7E

S: 7e a00a 00 22 00 23 03 11 10 a6 7e

R: 7E A88C 03 00 22 00 23 70 DE 24

03

09 06 01 01 1E 08 00 FF 06 00 2E 8D B2 02 020F 00 16 1F 02 03

09 06 01 01 32 08 00 FF 06 00 00 00 00 02 020F 00 16 1F 02 03

09 06 01 01 46 08 00 FF 06 00 00 00 00 02 020F 00 16 1F 02 03

09 06 01 01 0A 08 00 FF 06 00 2E 8D B2 02 020F 00 16 1F 02 03

09 06 FF 02 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 03 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09

1C EB 7E

S: 7e a00a 00 22 00 23 03 31 12 87 7e

R: 7E A88C 03 00 22 00 23 72 CC 07

06 FF 04 FF 08 00 FF 06 00 00 00 00 02 02 0F 00 16 FF 02 03

09 06 FF 05 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 02 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 03 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 04 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 05 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF

29 95 7E

S: 7e a00a 00 22 00 23 03 51 14 e4 7e

R: 7E A05B 03 00 22 00 23 74 8C 7C 06 FF 08 00

FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 07 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 08 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF 02 03

09 06 FF 09 FF 08 00 FF 06 00 00 00 00 02 020F 00 16 FF

0B 2E 7E

S: 7e a00a 00 22 00 23 03 71 16 c5 7e

R: 7E A00A 03 00 22 00 23 71 3B C6 7E

S: 7e a00a 00 22 00 23 03 71 16 c5 7e

R: 7E A00A 03 00 22 00 23 71 3B C6 7E

S: 7e a00a 00 22 00 23 03 71 16 c5 7e

R: 7E A00A 03 00 22 00 23 71 3B C6 7E

S: 7e a00a 00 22 00 23 03 71 16 c5 7e

R: 7E A00A 03 00 22 00 23 71 3B C6 7E

S: 7e a00a 00 22 00 23 03 71 16 c5 7e

R: 7E A00A 03 00 22 00 23 71 3B C6 7E

S: 7e a00a 00 22 00 23 03 71 16 c5 7e

R: 7E A00A 03 00 22 00 23 71 3B C6 7E

//disclink

S: 7e a00a 00 22 00 23 03 53 06 c7 7e

R: 7E A00A 03 00 22 00 23 1F 43 4C 7E

六、请求数据实例

这里给出几个数据通讯的实例,供程序员编程时参考。

1、    请求电量

请求正向有功总电量,及分费率电量。

S:7E A0 0A 00 22 0023 03 93 0A 01 7E

R:7E A0 21 03 00 2200 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 0153 3B 7E

S:7E A0 46 00 22 0023 03 10 05 C1 E6 E6 00 60 35 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 01 0000 00 06 5F 04 00 00 00 14 00 00 BD BF 7E

R:7E A0 52 03 00 2200 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00A3 05 A1 03 02 01 00 88 02 07 80 89 07 60 85 74 05 08 02 01 AA 0A 80 08 41 4243 44 45 46 47 48 BE 0F 04 0D 08 00 06 5F 04 00 00 00 14 21 34 00 07 14 53 7E

S:7E A0 1B 00 22 0023 03 32 95 9F E6 E6 00 C0 01 81 00 03 01 01 01 08 00 FF 02 0C F6 7E

R:7E A0 18 03 00 2200 23 52 D0 57 E6 E7 00 C4 01 81 00 06 00 06 1B 98 5A 60 7E

S:7E A0 1B 00 22 0023 03 54 A5 99 E6 E6 00 C0 01 81 00 04 01 01 01 08 01 FF 02 DE 30 7E

R:7E A0 18 03 00 2200 23 74 E4 13 E6 E7 00 C4 01 81 00 06 00 01 C7 14 A0 54 7E

S:7E A0 1B 00 22 0023 03 76 B5 9B E6 E6 00 C0 01 81 00 04 01 01 01 08 02 FF 02 BA DF 7E

R:7E A0 18 03 00 2200 23 96 F8 D7 E6 E7 00 C4 01 81 00 06 00 03 17 5E 7D 53 7E

S:7E A0 1B 00 22 0023 03 98 C5 95 E6 E6 00 C0 01 81 00 04 01 01 01 08 03 FF 02 66 85 7E

R:7E A0 18 03 00 2200 23 B8 84 1F E6 E7 00 C4 01 81 00 06 00 01 3D 26 49 C7 7E

S:7E A0 1B 00 22 0023 03 BA D5 97 E6 E6 00 C0 01 81 00 04 01 01 01 08 04 FF 02 63 09 7E

R:7E A0 18 03 00 2200 23 DA 90 5F E6 E7 00 C4 01 81 00 06 00 00 00 00 7B DF 7E

S:7E A0 0A 00 22 0023 03 D1 1C 60 7E

R:7E A0 0A 03 00 2200 23 D1 31 63 7E

S:7E A0 0A 00 22 0023 03 53 06 C7 7E

R:7E A0 0A 03 00 2200 23 73 29 E5 7E

2、请求瞬时量(电压、电流、功率)

S:7E A0 0A 00 22 0023 03 93 0A 01 7E

R:7E A0 21 03 00 2200 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 0153 3B 7E

S:7E A0 46 00 22 0023 03 10 05 C1 E6 E6 00 60 35 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 01 0000 00 06 5F 04 00 00 00 14 00 00 BD BF 7E

R:7E A0 52 03 00 2200 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00A3 05 A1 03 02 01 00 88 02 07 80 89 07 60 85 74 05 08 02 01 AA 0A 80 08 41 4243 44 45 46 47 48 BE 0F 04 0D 08 00 06 5F 04 00 00 00 14 21 34 00 07 14 53 7E

S:7E A0 1B 00 22 0023 03 32 95 9F E6 E6 00 C0 01 81 00 03 01 01 1F 07 00 FF 02 0D 91 7E

R:7E A0 16 03 00 2200 23 52 F1 D1 E6 E7 00 C4 01 81 00 12 00 02 33 53 7E

S:7E A0 1B 00 22 0023 03 54 A5 99 E6 E6 00 C0 01 81 00 03 01 01 33 07 00 FF 02 AC 86 7E

R:7E A0 16 03 00 2200 23 74 C5 95 E6 E7 00 C4 01 81 00 12 00 02 33 53 7E

S:7E A0 1B 00 22 0023 03 76 B5 9B E6 E6 00 C0 01 81 00 03 01 01 47 07 00 FF 02 4F BE 7E

R:7E A0 16 03 00 2200 23 96 D9 51 E6 E7 00 C4 01 81 00 12 00 02 33 53 7E

S:7E A0 1B 00 22 0023 03 98 C5 95 E6 E6 00 C0 01 81 00 03 01 01 20 07 00 FF 02 20 2F 7E

R:7E A0 16 03 00 2200 23 B8 A5 99 E6 E7 00 C4 01 81 00 12 00 01 A8 61 7E

S:7E A0 1B 00 22 0023 03 BA D5 97 E6 E6 00 C0 01 81 00 03 01 01 34 07 00 FF 02 70 B6 7E

R:7E A0 16 03 00 2200 23 DA B1 D9 E6 E7 00 C4 01 81 00 12 00 01 A8 61 7E

S:7E A0 1B 00 22 0023 03 DC E5 91 E6 E6 00 C0 01 81 00 03 01 01 48 07 00 FF 02 B3 D4 7E

R:7E A0 16 03 00 2200 23 FC 85 9D E6 E7 00 C4 01 81 00 12 00 01 A8 61 7E

S:7E A0 0A 00 22 0023 03 F1 1E 41 7E

R:7E A0 0A 03 00 2200 23 F1 33 42 7E

S:7E A0 0A 00 22 0023 03 53 06 C7 7E

R:7E A0 0A 03 00 2200 23 73 29 E5 7E

3、请求负荷曲线

S:7E A0 0A 00 22 0023 03 93 0A 01 7E

R:7E A0 21 03 00 2200 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 0153 3B 7E

S:7E A0 46 00 22 0023 03 10 05 C1 E6 E6 00 60 35 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 01 0000 00 06 5F 04 00 00 00 14 00 00 BD BF 7E

R:7E A0 52 03 00 2200 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00A3 05 A1 03 02 01 00 88 02 07 80 89 07 60 85 74 05 08 02 01 AA 0A 80 08 41 4243 44 45 46 47 48 BE 0F 04 0D 08 00 06 5F 04 00 00 00 14 21 34 00 07 14 53 7E

S:7E A0 3C 00 22 0023 03 32 0E 3B E6 E6 00 C0 01 81 00 07 00 00 63 01 00 FF 02 01 01 02 04 00 090C 07 D3 06 09 FF FF FF FF FF FF FF FF 09 0C 07 D3 06 0A FF FF FF FF FF FF FFFF DE 82 7E

R:7E A8 8C 03 00 2200 23 52 CE 26 E6 E7 00 C4 01 81 00 01 22 02 06 02 02 09 0C 07 D3 06 09 FF 091D 0D FF FF FF FF 04 06 40 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 0000 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 1000 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 0002 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 0600 00 00 83 9E 7E

S:7E A0 0A 00 22 0023 03 51 14 E4 7E

R:7E A8 8C 03 00 2200 23 54 F8 43 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 0600 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 0000 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 0010 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 0000 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 0000 02 F9 31 7E

S:7E A0 0A 00 22 0023 03 71 16 C5 7E

R:7E A8 8C 03 00 2200 23 56 EA 60 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 1000 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 0002 06 00 00 02 02 09 0C FF FF FF FF FF 0F 08 34 FF FF FF FF 04 06 40 02 02 090C FF FF FF FF FF 0F 0E 1F FF FF FF FF 04 06 40 10 00 00 10 00 00 02 06 00 0000 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 0010 00 00 14 24 7E

S:7E A0 0A 00 22 0023 03 91 18 22 7E

R:7E A0 75 03 00 2200 23 58 40 72 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 0010 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 0000 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 1000 00 02 06 00 02 02 09 0C FF FF FF FF FF 11 23 0C FF FF FF FF 04 06 40 00 0010 00 00 10 00 00 A2 1B 7E

S:7E A0 0A 00 22 0023 03 B1 1A 03 7E

R:7E A0 0A 03 00 2200 23 51 39 E7 7E

S:7E A0 0A 00 22 0023 03 53 06 C7 7E

R:7E A0 0A 03 00 2200 23 73 29 E5 7E

4、请求时间

S:7E A0 0A 00 22 0023 03 93 0A 01 7E

R:7E A0 21 03 00 2200 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 0153 3B 7E

S:7E A0 46 00 22 0023 03 10 05 C1 E6 E6 00 60 35 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 01 0000 00 06 5F 04 00 00 00 14 00 00 BD BF 7E

R:7E A0 52 03 00 2200 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00A3 05 A1 03 02 01 00 88 02 07 80 89 07 60 85 74 05 08 02 01 AA 0A 80 08 41 4243 44 45 46 47 48 BE 0F 04 0D 08 00 06 5F 04 00 00 00 14 21 34 00 07 14 53 7E

S:7E A0 1B 00 22 0023 03 32 95 9F E6 E6 00 C0 01 81 00 08 00 00 01 00 00 FF 02 46 2F 7E

R:7E A0 21 03 00 2200 23 52 A3 C0 E6 E7 00 C4 01 81 00 09 0C 07 D3 06 0E 06 0E 0D 03 FF FF FF 0010 38 7E

S:7E A0 0A 00 22 0023 03 51 14 E4 7E

R:7E A0 0A 03 00 2200 23 51 39 E7 7E

S:7E A0 0A 00 22 0023 03 53 06 C7 7E

R:7E A0 0A 03 00 2200 23 73 29 E5 7E

本文到这里就结束了。彻底理解DLMS协议是一个大的系统工程。这个协议的制定,又很多地方时面向通用性的。为实现通用性,其实协议中的很多地方不必那么复杂的地方,显得很复杂。同时这个协议又涉及到了许多别的标准,在看本文时最好同时参照本文的参考文献,将有助于理解本文。

补充一:对于SNReferencing的解释

When SN referencing is used, the attributes and methodsof each interface object are mapped to DLMS named variables. This isdone during the design of the meter.Each named variable is identified with a short name, which is a 16 bitunsigned integer.Attribute 1, the logical name of the object is mapped to aDLMS named variable identified by a base name. Except in the case of afew special objects, there are no general rules defined for assigning base names.All other attributes and methods of the object are then also mapped to DLMSnamed variables. The offsets between the base name and the short nameidentifying the other attributes and methods are defined in the definition ofeach interface class. The actual values of the short names thus depend on thenumber and kind of objects instantiated and the mapping strategy used. The basenames allocated in the metering equipment can be retrieved by reading theobject_list attribute of the SN Association object. When SN referencing is used,the DLMS named variables are accessed by the standard DLMS READ and WRITE services.

When LN referencing is used, attributesand methods are accessed via the logical name of the object, specifying theindex(es) of the attribute(s) and/or the method(s). Logical names are definedby OBIS. When LN referencing is used, the attributes and methods are accessedby the xDLMS GET/SET and ACTION services.

(Referencingfrom “DLMS User Association Frequently Asked Questions”)

SNReferencing 不同于LN Referencing 它使用一个整型数(WORD)即ShortName,来取代LN Referencing中的OBIS . Short Name 由厂家自定义.对于西门子D型表使用了SN . 因此只有在厂家提供SN的情况下,才可以使用SN的application-context-name 访问表内的数据.

下面是一个SN数据请求帧的例子:

S:7E A011 03 21 32 B7 3D E6 E6 00 05 01 02 FF 08 A0 E0 7E

7E A0 1103 21 32 B7 3D E6 E6 00

05//SN application-context-name  ReadRequest

01 02 FF08 //short name and attribute ???

A0 E0 7E

补充二:   目前DLMS规约中用到的CLASS ID 和OBIS

数据名称

CLASS ID

OBIS

ATTRIBUTE

时钟

00 08

00 00 01 00 00 ff

02 00

正想有功(总)

00 03

01 01 01 08 00 ff

02 00

正想有功(费率一)

00 04

01 01 01 08 01 ff

02 00

正想有功(费率二)

00 04

01 01 01 08 02 ff

02 00

正想有功(费率三)

00 04

01 01 01 08 03 ff

02 00

正想有功(费率四)

00 04

01 01 01 08 04 ff

02 00

反想有功(总)

00 03

01 01 02 08 00 ff

02 00

反想有功(费率一)

00 04

01 01 02 08 01 ff

02 00

反想有功(费率二)

00 04

01 01 02 08 02 ff

02 00

反想有功(费率三)

00 04

01 01 02 08 03 ff

02 00

反想有功(费率四)

00 04

01 01 02 08 04 ff

02 00

有功功率(总)

00 03

01 01 01 07 00 ff

02 00

无功功率(总)

00 03

01 01 02 07 00 ff

02 00

L1电压

00 03

01 01 1f 07 00 ff

02 00

L2电压

00 03

01 01 33 07 00 ff

02 00

L3电压

00 03

01 01 47 07 00 ff

02 00

L1电流

00 03

01 01 20 07 00 ff

02 00

L2电流

00 03

01 01 34 07 00 ff

02 00

L3电流

00 03

01 01 48 07 00 ff

02 00

DLMS电能表通讯协仪相关推荐

  1. DLT645-2007电能表通讯协议+DDSY5188电能表之间通讯简介

    DLT645-2007通讯协议: 1.发送的帧格式: 1.1 帧起始符 0x68H     这个不多说,记住就好: 1.2 地址域A0-A5 地址域由 6 个字节构成,每字节 2 位 BCD 码,地址 ...

  2. DLT645-2007电能表通讯协议

    DLT645-2007通讯协议: 1.发送的帧格式: 1.1 帧起始符 0x68H     这个不多说,记住就好: 1.2 地址域A0-A5 地址域由 6 个字节构成,每字节 2 位 BCD 码,地址 ...

  3. 一种兼容645和698通信协议的电能表

    1 概述 ADL400 导轨式多功能电能表(支持698通讯协议的电能表),是主要针对电力系统,工矿企业,公用设施的电能统计. 管理需求而设计的一款智能仪表,产品具有精度高.体积小.安装方便等优点. 集 ...

  4. 电子式预付费电能表对于安全校园建设的意义

    1远程控制预付费集中抄表系统 国内开发生产的低压集中抄表系统的厂家非常多,抄表成功率.准确率都相当高.在此类系统的基础上,进行二次开发,扩展功能,即可实现预收电费.远程切断/恢复电力供应.实时抄读电表 ...

  5. 多功电子表是否采用计算机技术计量,浅谈电子式电能表应用的几点问题

    摘要:文章通过对感应式电能表和电子式电能表的对比分析,总结出了电子式电能表的一些性能特点,并对其应用提出了一些看法和建议. 关键词:电子式电能表 电能计量 1 概述 现代企业管理强调自动化.智能化,要 ...

  6. 智能电网势头好 电能表商纷纷扩张产能

    随着智能电网的全面建设,作为连接电网与客户的关键环节,智能电能表作用非常重要.它不仅决定客户用电的智能化水平,还将帮助客户合理用电,并实现节能减排. 有资料表明,从2010年至2015年间,我国电网系 ...

  7. 单三相智能电表的工作原理及电能表模块介绍

    现在的智能电表已经不仅仅是简单的计量了,还要传输多种数据,还有防窃电功能,智能电表相对于之前的机械电表更加安全,现在甚至可以分析出我们的用电习惯,那么智能电表的工作原理到底是什么呢,现在把单相智能电表 ...

  8. 安科瑞预付费电能表及电能管理系统的应用分析

    安科瑞 王文杰 摘要:本文阐述了传统IC卡式预付费电能表的主要功能,分析了其应用优势和存在的弊端:较为详细地介绍了一种预付费电能表,在融入了通讯技术和智能控制技术后的功能拓展及推广实用价值,从而描述出 ...

  9. 智能电能表怎么看电量?

    智能电表是能源互联网的智能终端,它早已并不是传统上的电能表,智能电表除开具有传统的电能表基本上用电量的测量功用之外,为融入智慧能源和电网它还具备双重多种费率计量功能.用户端操纵功能.多种传输数据方式的 ...

最新文章

  1. Gut:人体最初的微生物起源与生殖健康
  2. 单身的我听着单身情歌。。。看着那些儿时看过的小说。。。
  3. Android中几种常用的定时器和延时方法
  4. Eclipse的Ctrl+鼠标左键的智能化链接配置
  5. MySQL-[Err] 1055 - Expression #1
  6. URL处理两个小工具方法
  7. PHP新手上路(十)
  8. javaweb基础知识点记录1
  9. mongodb数组更新操作符$push
  10. (转) 淘淘商城系列——使用FastDFS-Client客户端进行上传图片的测试
  11. 漫谈 - 从技术业务骨干走向管理
  12. POJPower Network (最大流)
  13. Java I/O(输入输出流)
  14. mac如何使用adb安装apk
  15. 8.《创业邦》:十大创业困境
  16. HTML页面中显示时间
  17. 数学 导数表 求导公式求导法则
  18. 【kafka专栏】集成apache kafka-clients实现数据消费者
  19. transitive fanout与set_dont_touch_network
  20. python(六)动态网页爬虫

热门文章

  1. [其他] MSVC编译器的选择(x86,amd64_x86,amd64,x86_amd64)
  2. 微信公众平台开发 mysql_微信公众平台开发数据库操作
  3. 13年12月CCF计算机软件能力认证
  4. Kindeditor入门教程及注意事项
  5. 最好的免费图像托管网站
  6. 我快被食人花吃掉了。
  7. 多种方式实现web端截屏录屏
  8. hexo搭建个人独立博客 | NexT主题深度美化方案
  9. IDS(***检测)要“退休”了吗?
  10. 3. 交易开拓者-TB公式(二)