您好,欢迎来到纷纭教育。
搜索
您的当前位置:首页DLMS电能表通讯协仪

DLMS电能表通讯协仪

来源:纷纭教育
DLMS电能表通讯协仪(2003 6 26)

本文是对于IEC62056协议族,即DLMS协议族的中文说明手册。本文并没有包含DLMS协议族的全部,但解释了在应用中可能出现的大多数情况。本文的目的是为电能量数据采集终端提供与使用DLMS协议族的电能表通讯的协议说明。 本文参考文献如下: (1)DLMS User Association , COSEM Identification System and Interface Objects , Third Edition (2)IEC62056 - 53 Electricity metering - Data exchange for meter reading, tariff and load

control -Part 53: COSEM application layer control -Part 46: Data link layer using HDLC protocol control -Part 42: Physical layer services and procedures for connection-oriented asynchronous data exchange control -Part 61: Object identification system (OBIS)

MANAGEMENT_LOGICAL_DEVICE ELECTRICITY_LOGICAL_DEVICE

(3)IEC62056 - 46Electricity metering - Data exchange for meter reading, tariff and load (4)IEC62056 - 42 Electricity metering - Data exchange for meter reading, tariff and load

(5)IEC62056 - 61 Electricity metering - Data exchange for meter reading, tariff and load (6)Amber Management logical device-FR:AMBER/FW TECH_SPEC (7)Amber Electricity Logical Device - FR:AMBER/FW TECH_SPEC

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

An RSA Laboratories Technical Note Burton S. Kaliski Jr.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、 请求时间

1

一、DLMS协仪模型

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

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

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

通讯过程描述:

(一) 建立物理层连接

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

(二) 建立链路层连接 物理层连接建立之后,数据通讯的第一步是建立链路层的连接,链路层主要负 责数据传输的可靠性,包括以下几个方面,地址校验,帧长校验,数据的CRC校 验。长数据帧的拆包组包。同时向应用层提供链路传输的服务。 (三) 建立应用层连接 链路层连接建立之后,在DLMS协议中还要建立应用层连接,才可进行数据通讯。 这个应用层连接建立过程被称为Negotiation(协商)。 这个过程是为数据通讯提供一些配置参数。应用层连接请求由Client端发起,Client 端发aarq帧,Server端响应aare帧 (四) 进行数据通讯

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

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

数据通讯结束后,发链路结束帧,结束一次通讯过程。一次数据通讯结束后,可以

2

通过发链路结束帧,来结束一次通讯过程。也可以,不发任何数据帧,依靠server端的超时挂断机制,来结束一次通讯过程。一般应使用前者。 (六) 解除物理层连接

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

二、DLMS物理层协议 物理层协议位于DLMS协议族的最底层,负责数据通讯的物理传输。DLMS可以工作于多种不同的物理介质上(PSTN,网络,串行通道等)。 物理层的功能是接受链路层数据,发送到物理介质上,传送到通信的对端。或是接收通信的对端传送来得数据,再传送到链路层,供更高层的协议处理数据。 DLMS物理层协议,主要规定了物理层应实现的服务,如:打开端口,初始化端口,收发数据,关闭端口等。在通常的嵌入式系统中(如电能量采集装置),物理层对应于系统的底层驱动部分。这部分一般不被通讯规约控制。因此,在不影响通讯协议功能实现的前提下,本文将不具体讨论物理层服务。

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

链路层的构成: 链路层由两个子层构成,即LLC子层,和MAC子层。 (一) 、LLC子层(逻辑链路控制子层) 这一层的功能是将MAC子层的数据转发到应用层,或将应用层的数据转发到MAC子

3

层。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 帧类型与帧长 与不包含应用层数据信息的数据帧相比这里多了3项:

帧头校验:为增强通讯的可靠性,对帧头的数据也加上CRC校验。帧头包括如下 字段:帧类型与帧长、目的地址域、源地址域、和控制域 LLC帧头:用户数据信息前要加0xe6 , 0xe6, 0x00或0xe6 , 0xe7, 0x00。 用户数据信息:应用层处理的数据。

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

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

目的地址域 源地址域 控制域 帧头校验 LLC帧头 用户数据信息 数据帧校验 0x7e

2

Frame Type :用于指出当前数据帧的类型。HDLC有多种数据帧类型,DLMS使 用Frame Type 3。Frame Type恒为A(1010)。 S:(segmentation Bit)这个字段只有一位,它用于说明数据帧是否被分割(在报文

中,该字节为A0表示数据到本帧就已经结束,A8表示下面还有数据帧)。在长数 据帧传输时要使用到这一位。长数据帧的传输将在后面解释。

Frame Length Sub-field :这个字段用于说明当前数据帧的长度,(以字节为单位, 不包括两个0x7e) 3 地址解析 地址域分为两部分。目的地址域和源地址域。对于client端,目的地址为server的地址,源地址为client的地址。对于server端正好相反。

4

(1)扩展编址技术 HDLC使用扩展编址技术,即某一个地址字节的最低位如为0,则表明该地址域没有结束,仍有后续字节是该地址域的一部分。若某一地址字节最低位为1,则说明该地址域已经结束,没有后续字节。 (2)地址结构 Client端的地址永远是一个字节,由于扩展编址技术的使用,最低位置1,所以client端的地址只能有128个。 Server端为了实现一个物理地址对应多个逻辑地址,将地址分成了两部分upper HDLC Address 用于表述逻辑地址,lower HDLC address用于表述物理地址。Upper address总是应当有的,lower address在确认不需要的情况下,可以不出现。(sl7000 电表这两部分地址都是需要的)。 Server端的地址在使用扩展编址技术时,也并非是可以无限长(虽然在理论上可以,但在实践上是有上限的)。Server端的地址结构可以使用如下方式:

One byte: 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,

5

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将会在“建立链路层连接”时解释)

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

6

I:信息传输帧

RR:准备接收数据帧(用来表示准备接收下一帧数据) RNR:接收没有准备好(receive not ready)。相当于别的通讯协议中的忙帧。 SNRM:设置正常相应数据帧。用于建立链路层连接。 UA:对SNRM和DISC的响应帧。 DISC:结束链路帧。 DM:对DISC的响应帧。(Disconnected mode)

UI:可以用于保持链路,这个数据帧的发送,对于链路的控制没有任何影响。 FRMR:拒绝接收帧(Frame reject),由于不确定的某种原因拒绝接收到的数据帧。

5 长数据帧的传输 在很多情况下,数据不能在一次请求和一次响应中,就能够结束数据传输的过程(受限于用户数据字节不超过128字节)。这时就有必要启动长数据帧链路控制流程。 注:请求负荷曲线时一定是使用长数据帧。 当使用长数据帧时,必须把长数据帧分割成短数据帧。然后把这些短数据帧依次发送出去,在接收端将这些短数据帧依次处理。这样就实现了一个较大的数据包,完整的传送到接收端。 在数据帧被分割时,帧类型与帧长字段中的‘S’位,将被置1。当接收端检测到这一位被置位后,就知道数据帧已被分割,此时要做出对分割数据帧的相应处理。 下图介绍了长数据帧的收发过程:

7

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_LENGTH parameter . 最大信息域长度,这个参数用于描 述一个链路数据帧中用户数据的长度。 这两个参数的默认值如下

default WINDOW_SIZE = 1;

default MAXIMUM_INFORMATION_FIELD_LENGTH = 128(BYTEs)

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

transmit maximum information field length receive maximum information field length transmit window size receive window size

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

8

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

S: 7e a0 21 00 22 00 23 03 93 0b 14 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 07 65 5e 7e 解释: 7e a0 21 帧类型与帧长 00 22 00 23 目的地址 03 源地址 93 控制字 0b 14 帧头校验 81 80 SNRM 标识 12 group lenth.

05H parameter identifier (maximum information field length transmit)

01H parameter length (1 octet) 80H parameter value(128 bytes)

06H parameter identifier (maximum information field length receive) 01H parameter length (1 octet) 80H parameter value (128 bytes)

07H parameter identifier (window size, transmit) 04H parameter length (4 octets) 00H parameter value (high byte of value) 00H parameter value 00H parameter value 01H parameter value (low byte of value)

08H parameter 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 A0 21 03 00 22 00 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E 解释:

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

9

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 00 01 08 04 00 00 00 01 //information field //parameter negotiation //81 //80 //12 //05 01 80 :maximum information field length transmit (128 BYTEs) //06 01 80 :maximum information field length receive (128 BYTEs) //07 04 00 00 00 01 :window size, transmit (1) //08 04 00 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

10

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包含两部分class type 和一个数字 Class type有以下四种: 1)Universal 表明name定义的数据帧在所有的DLMS应用中的含义是唯 一的。 2)Application 表明name定义的数据帧的含义同具体的应用有关。 3)Private 表明name定义的数据帧只在某一厂家的自定义范围之内。 4)Context-specific 表明name定义的数据帧同上下文数据项的含义有关。 这种类型的数据,在不同的结构中可能有不同的含义。 Tag中的数字,是作为这个数据帧的标号存在的,它作为该数据帧的句柄出现 在应用数据单元中。

11

当前数据帧(称为子数据帧)可能派生于某一数据帧(称为父数

据帧),这个字段用来描述子数据帧同父数据帧的关系。 IMPLICIT : 改变了父数据帧的Tag。 EXPLICIT : 不改变父数据帧的Tag。 不注明IMPLICIT的项即为EXPLICIT。

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

IMPLICIT/ EXPLICIT

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-Descriptor OPTIONAL }

这是一个在请求数据时常用的数据帧。SEQUENCE表明数据帧的内容是顺序排列的。 2)CHOICE :即选择类型,它表明当前数据帧是从几个数据帧中选择一种做为当前数 据帧的类型。下面以举例说明CHOICE类型。 GET-Request ::= CHOICE

{

get-request-normal get-request-next

get-request-with-list

[1] IMPLICIT Get-Request-Normal, [2] IMPLICIT Get-Request-Next, [3] IMPLICIT Get-Request-With-List

12

}

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 datatype classes(bit15、14) Data type(bit13) Tag number (bit12-8) bit0 data length(bit7-bit0) 1)datatype classes 字段:这一字段用于对ASN.1语法中的class type编码

Context-specific (10) Private

(11)

Universal

(00)

Application (01)

2)Data type字段:用于描述数据内容的结构 Primitive (0) 简单类型 Constructed (1) 复合类型(数组或结构) 3)Tag number字段:指明Tag标号

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

下面以接收到的AARE数据帧为例: AARE数据帧的语法描述:

AARE-apdu ::= [APPLICATION 1] IMPLICIT SEQUENCE

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

13

{

protocol-version result

[0] IMPLICIT BIT STRING {version1 (0) } DEFAULT{version1}, [1] Application-context-name, [2] Association-result,

[3] Associate-source-diagnostic, [4] AP-title OPTIONAL, [5] AE-qualifier OPTIONAL,

[6] AP-invocation-identifier OPTIONAL, [7] AE-invocation-identifier OPTIONAL,

application-context-name result-source-diagnostic responding-AP-title responding-AE-qualifier responding-AP-invocation-id responding-AE-invocation-id

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

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

-- The following field shall only be present if the authentication functional unit is selected. mechanism-name

[9] IMPLICIT mechanism-name OPTIONAL, [10] EXPLICIT authentication-value OPTIONAL, [29] IMPLICIT implementation-data OPTIONAL, [30] IMPLICIT association-information OPTIONAL

-- The following field shall only be present if the authentication functional unit is selected. responding-authentication-value implementation-information user-information }

AARE数据帧的BER编码和AXDR编码实现: 61 //AARE tag 42 //AARE len

A1 //tag of COSEM_Application_Context_Name 09 //数据长度 06 //(OBJECT IDENTIFIER, Universal)OBJECT IDENTIFIER是一种 //ASN.1数据类型. 07 //数据长度 60 85 74 05 08 01 01 //数据内容 //以下的数据帧可以用同样的方法一一解释 A2 //Tag of Association-result,

03 02 01 00

A3 //Tag of Associate-source-diagnostic

05 A1 03 02 01 00

88 //IMPLICIT ACSE-requirements OPTIONA

02 07 80

//IMPLICIT mechanism-name OPTIONAL

07 60 85 74 05 08 02 01

AA //EXPLICIT authentication-value OPTIONAL

0A 80 08 41 42 43 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)

14

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 of the bitstring 00 08 1D// encoding of the fixed length BITSTRING value 21 34 // the A-XDR encoding of an Unsigned16 is its value

00 07 // 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 STRING OPTIONAL, response-allowed BOOLEAN DEFAULT TRUE,

proposed-quality-of-service [0] IMPLICIT Integer8 OPTIONAL, proposed-dlms-version-number Unsigned8, proposed-conformance Conformance,

15

client-max-receive-pdu-size Unsigned16 }

AXDR编码:

01--------------------------------------------------------dlms puu标识

00 ----------------------------------//usage flag for the dedicated-key component (FALSE, not present) 00--------------- //usage flag for the response-allowed component (FALSE, default value conveyed) 00-------------- //usage flag for the proposed-quality-of-service component (FALSE, not present) 06-------------- //the A-XDR encoding of an Unsigned8 is its value

5f ---------- //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 of the BITSTRING 00 00 10------- // encoding of the fixed length 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 the authentication functional units.

{

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

AARQ-apdu ::= [APPLICATION 0] IMPLICIT SEQUENCE protocol-version called-AP-title

[0] IMPLICIT BIT STRING {version1 (0) } DEFAULT{version1}, [1] Application-context-name, [2] AP-title OPTIONAL, [3] AE-qualifier OPTIONAL,

[4] AP-invocation-identifier OPTIONAL, [5] AE-invocation-identifier OPTIONAL, [6] AP-title OPTIONAL, [7] AE-qualifier OPTIONAL,

[8] AP-invocation-identifier OPTIONAL, [9] AE-invocation-identifier OPTIONAL, [10] IMPLICIT ACSE-requirements OPTIONAL, [11] IMPLICIT mechanism-name OPTIONAL, [12] EXPLICIT authentication-value OPTIONAL,

application-context-name called-AE-qualifier called-AP-invocation-id calling-AP-title

called-AE-invocation-id calling-AE-qualifier

calling-AP-invocation-id calling-AE-invocation-id sender-acse-requirements mechanism-name

The following field shall not be present if only the kernel is used.

-- The following field shall only be present if the authentication functional unit is selected. -- The following field shall only be present if the authentication functional unit is selected. calling-authentication-value

16

implementation-information user-information }

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

AARE-apdu ::= [APPLICATION 1] IMPLICIT SEQUENCE {

protocol-version result

[0] IMPLICIT BIT STRING {version1 (0) } DEFAULT{version1}, [1] Application-context-name, [2] Association-result,

[3] Associate-source-diagnostic, [4] AP-title OPTIONAL, [5] AE-qualifier OPTIONAL,

[6] AP-invocation-identifier OPTIONAL, [7] AE-invocation-identifier OPTIONAL,

application-context-name result-source-diagnostic responding-AP-title responding-AE-qualifier responding-AP-invocation-id responding-AE-invocation-id

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

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

-- The following field shall only be present if the authentication functional unit is selected. mechanism-name

[9] IMPLICIT mechanism-name OPTIONAL, [10] EXPLICIT authentication-value OPTIONAL, [29] IMPLICIT implementation-data OPTIONAL, [30] IMPLICIT association-information OPTIONAL

-- The following field shall only be present if the authentication functional unit is selected. responding-authentication-value implementation-information user-information }

被标记为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 0x05 0x08 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 BIT STRING 80 //encoding of the authentication functional unit (0)。最高位置1其余的为unused bits。

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

17

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

user-information: 内容即为xDLMS-Initiate.request PDU,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 referencing with SET is not supported (Bit_08) Priority Management is supported (Bit_09)

Attibute_0 referencing with GET is supported (Bit_10) Block Transfer with the GET service is supported (Bit_11) Block Transfer with the SET service is supported (Bit_12) Block Transfer with the ACTION service is supported (Bit_13) Multiple references are supported (Bit_14)

All LN services (GET, SET, ACTION,EVENT NOTIFICATION) are supported (Bit_19, 20, 22, 23)

Selective Access feature is 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 BA 88 4D //HDLC 帧头

18

00 00 00 02 02 0F 00 16 1E 02 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 00 FF 06 00 4B 09 74 02 02 0F 00 16 1E 02 03 09 06 01 01 17 08 00 FF 06 00 00 7E 72 02 02 0F 00 16 20 02 03 09 06 01 01 2B 08 00 FF 06 00 00 01 2C 02 02 0F 00 16 20 02 03 09 06 01 01 3F 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 02 03 09 06 01 01 03 08 00 FF 06 00 00 7F 2A EA 7E

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

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

//应用层数据单元128字节 //HDLC 帧尾

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.response PDU,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通讯实例。

19

//aarq

S: 7e a0 47 00 22 00 23 03 10 d0 5e e6 e6 00 60 36 a1 09 06 07 60 85 74 05 08 01 01 8a 02 07 80 8b 07 60 85 74 05 08 02 01 ac 0a 80 08 41 42 43 44 45 46 47 48 be 10 04 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 // The application-context-name must be in. a1 //tag for the application-context-name component 09 //the length of the tagged component value field

06 // data type choice for application-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 this application-context-name //is that it chooses LN referencing or SN referencing.

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

8a //encoding 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 BIT STRING 80 //encoding of the authentication functional unit (0) //encoding the mechanism-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 //the value of the Object Identifier ac //the tag for the authentication-information ([12], Context-specific) 0a //Len 80 //the choice for Authentication-information (charstring [0] IMPLICIT GraphicString)

20

}

08 //Len 41 42 43 44 45 46 47 48

/* User information can't be ignored. */ be //user information(x-DLMS context) 10 //Len (according to bytes) { 04 //data type choice for user-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.request PDU. /* 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 } The client-max-receive-pdu-size is 1200D = 0x4B0. */ /* 01 //the tag (explicit tag) of the DLMS PDU CHOICE //--dedicated-key 00 //usage flag for the dedicated-key component (FALSE, not present) //--response-allowed

00 //usage flag for the response-allowed component (FALSE, default value conveyed) //--proposed-quality-of-service

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

present)

//--proposed-quality-of-service 06 //the A-XDR encoding of an 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 of unused bits in the final octet of the BITSTRING

00 08 1d // encoding of the fixed length bitstring value.(LN/SN) //--client-max-receive-pdu-size 00 00 //the A-XDR encoding of an Unsigned16 is its value. */ }

21

9a 7a 7e }

//aare

R: 7E A0 53 03 00 22 00 23 30 40 A6 E6 E7 00 61 42 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 07 60 85 74 05 08 02 01 AA 0A 80 08 41 42 43 44 45 46 47 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 = Object identifier 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)

22

01 // encoding of the length of the result¡¯s value field (1 octets) 00 // encoding of the value of the Result (0, accepted) */ A3 //Tag of Associate-source-diagnostic, 05 //Len of Associate-source-diagnostic A1 03 02 01 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 the result-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-requirements OPTIONAL 02 07 80

23

//IMPLICIT mechanism-name OPTIONAL 07 60 85 74 05 08 02 01 AA //EXPLICIT authentication-value OPTIONAL 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] IMPLICIT Integer8 OPTIONAL, negotiated-dlms-version-number Unsigned8, negotiated-conformance Conformance, server-max-receive-pdu-size Unsigned16, vaa-name ObjectName } */ BE //User information (x-DLMS context) 10 { 04 // encoding the choice for user-information (OCTET STRING, Universal) 0E // encoding of the length of the OCTET STRING¡¯s value field (14 octets) //-- A-XDR encoding the xDLMS-Initiate.response PDU 08 //encoding the tag (explicit tag) of the DLMS PDU CHOICE (InitiateResponse) //-- encoding the negotiated-quality-of-service component (OPTIONAL, not present) 00 // usage flag for the proposed-quality-of-service component (FALSE, not present) 注:服务质量,一般设为0 //-- encoding of the negotiated-dlms-version-number component (Unsigned8, value=6) 注:版本号,一般设为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) // 注:当标号≧31时,应采用高位标识方法,即低字节的低5个bit全部设置为1,高字节为标号。ps.标号等于31时,用高位或低位表示法都可以。 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

24

// encoding of the fixed length BITSTRING value 00 08 1D //-- encoding the server-max-receive-pdu-size component (Unsigned16, value=0x01F4) 21 34 // the A-XDR encoding of an Unsigned16 is 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 Unsigned16 is 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 readRequest writeRequest readResponse writeResponse

[1] IMPLICIT InitiateRequest, [5] IMPLICIT ReadRequest, [6] IMPLICIT WriteRequest, [8] IMPLICIT InitiateResponse, [12] IMPLICIT ReadResponse, [13] IMPLICIT WriteResponse, [14] ConfirmedServiceError,

[22] IMPLICIT UnconfirmedWriteRequest, [24] IMPLICIT InformationReportRequest,

initiateResponse

confirmedServiceError

unconfirmedWriteRequest informationReportRequest -- the two ACSE APDUs aarq AARQ-apdu aare AARE-apdu,

-- APDUs used for data communication services using LN referencing get-request set-request action-request get-response set-response

[192] IMPLICIT GET-Request, [193] IMPLICIT SET-Request,

[194] IMPLICIT EVENT-NOTIFICATION-Request, [195] IMPLICIT ACTION-Request, [196] IMPLICIT GET-Response, [197] IMPLICIT SET-Response, [199] IMPLICIT ACTION-Response, [200] IMPLICIT OCTET STRING, [201] IMPLICIT OCTET STRING,

event-notification-request

action-response -- global ciphered pdus glo-get-request glo-set-request

25

glo-event-notification-request glo-action-request glo-get-response glo-set-response

[202] IMPLICIT OCTET STRING, [203] IMPLICIT OCTET STRING, [204] IMPLICIT OCTET STRING, [205] IMPLICIT OCTET STRING, [207] IMPLICIT OCTET STRING, [208] IMPLICIT OCTET STRING, [209] IMPLICIT OCTET STRING, [211] IMPLICIT OCTET STRING, [212] IMPLICIT OCTET STRING, [213] IMPLICIT OCTET STRING, [215] IMPLICIT OCTET STRING

glo-action-response -- dedicated ciphered pdus ded-get-request ded-set-request ded-actionRequest ded-get-response ded-set-response

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

ded-action-response

}

这里要说明一下OBIS:

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

Cosem-Attribute-Descriptor ::= SEQUENCE {

class-id Cosem-Class-Id, 类ID instance-id Cosem-Object-Instance-Id, OBIS attribute-id Cosem-Object-Attribute-Id 属性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 }

Selective-Access-Descriptor::=SEQUENCE

26

{

access-selector Unsigned8 access-parameter Data }

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 00 c0 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 //Hdlc head c0 // get-request Cosem apdu[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-Data-Result ::= CHOICE {

data [0] Data,

GET-Response ::= CHOICE {

get-response-normal get-response-with-list }

Get-Response-Normal ::= SEQUENCE {

invoke-id-and-priority result }

Invoke-Id-And-Priority, Get-Data-Result

[1] IMPLICIT Get-Response-Normal, [2] IMPLICIT Get-Response-With-Datablock, [3] IMPLICIT Get-Response-With-List

get-response-with-datablock

27

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

Data ::= CHOICE { null-data array

structure boolean bit-string

[0] IMPLICIT NULL,

[1] IMPLICIT SEQUENCE OF Data, [2] IMPLICIT SEQUENCE OF Data, [3] IMPLICIT BOOLEAN, [4] IMPLICIT BIT STRING, [5] IMPLICIT Integer32,

[7] IMPLICIT OCTET STRING(SIZE(4))33, [9] IMPLICIT OCTET STRING, [10] IMPLICIT VisibleString, [11] IMPLICIT GeneralizedTime, [13] IMPLICIT Integer8, [15] IMPLICIT Integer8, [16] IMPLICIT Integer16, [17] IMPLICIT Unsigned8, [18] IMPLICIT Unsigned16, [19] IMPLICIT SEQUENCE

double-long floating-point octet-string time bcd long

visible-string

double-long-unsigned [6] IMPLICIT Unsigned32,

integer unsigned

long-unsigned compact-array {

contents-description [0] TypeDescription, array-contents } long enum

[20] IMPLICIT Integer, [21] IMPLICIT Unsigned, [22] IMPLICIT ENUMERATED,

[23] IMPLICIT OCTET STRING (SIZE(4)), [24] IMPLICIT OCTET STRING (SIZE(8)), [255] IMPLICIT NULL

[1] IMPLICIT OCTET STRING

long-unsigned float32 float don’t-care }

Data-Access-Result ::= ENUMERATED { success

(0), (1), (2), (3), (4), (9), (11),

hardware-fault

temporary-failure read-write-denied object-undefined object-unavailable

object-class-inconsistent

28

type-unmatched (12), (13), (14), (15), (16), (17), (18), (250)

scope-of-access-violated data-block-unavailable long-get-aborted long-set-aborted other-reason }

no-long-get-in-progress no-long-set-in-progress

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

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

7E A0 18 03 00 22 00 23 74 E4 13 E6 E7 00 //Hdlc head C4 01 //Response Normal

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

06 //double-long-unsigned [6] IMPLICIT Unsigned32, 00 35 7B 18 //反向有功值 CD E8 7E//HDLC Tail

五、对于接收到的数据帧的拆解 接收到的请求数据都是按照AXDR编码的。接收到的数据帧的数据结构,在参考文献【7】中都有详细解释。 以下给出数据帧解析的实例: 例:Load_profile //hdlc link //SNRM

S: 7e a0 21 00 22 00 23 03 93 0b 14 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 07 65 5e 7e (注:高4位应当恒等于a,表明帧类型;低4位若小于8,择表明是短帧,若大于等于8,则表明是长帧被分割。一般地,在帧长小于255的情况下,A0表明结束;A8表示被分割。) //UA

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

//aarq

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

//aare

R: 7E A0 53 03 00 22 00 23 30 40 A6 E6 E7 00 61 42 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 07 60 85 74 05 08 02 01 AA 0A 80 08 41 42 43 44 45

29

46 47 48 BE 10 04 0E 08 00 06 5F 1F 04 00 00 08 1D 21 34 00 07 72 A4 7E //

S: 7e a0 0a 00 22 00 23 03 31 12 87 7e

R: 7E A0 0A 03 00 22 00 23 31 3F 84 7E

S: 7e a0 0a 00 22 00 23 03 31 12 87 7e

R: 7E A0 0A 03 00 22 00 23 31 3F 84 7E

//request data

S: 7e a0 1c 00 22 00 23 03 32 8d 58 e6 e6 00 c0 01 81 00 07 00 00 63 80 01 ff 02 00 44 58 7e

R: 7E A0 4F 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 a0 0a 00 22 00 23 03 51 14 e4 7e

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

S: 7e a0 1c 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 A8 8C 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 //octet string , 6 bytes long ,obiscode(01 01 15 08 00 FF)

30

06 00 00 00 00 //Unsigned32(0x06), data (00 00 00 00) 02 02 //scal and unit.02 typ=strcture, 02 num = 2 strctures. 0F 00 // scaler :数据精度,即小数点位数为0 16 1E // unit :ENUMERATED(0x16) , data(0x1e = wh) //unit:enum.This can be founded in Blue book 3rd edition.

//attention (By DL): according to XDR ,when a datatype(Such as octet string,array ,stucture) //can't express the data length ,a data length byte should exist.On the other hand ,when the length can be expressed by

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

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 a0 0a 00 22 00 23 03 71 16 c5 7e

R: 7E A8 8C 03 00 22 00 23 76 E8 41 00 00 00 02 02 0F 00 16 1E 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 00 FF 06 00 2E 6E FE 02 02 0F 00 16 1E 02 03 09 06 01 01 17 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 02 03 09 06 01 01 2B 08 00 FF 06 00 00 00 82 02 02 0F 00 16 20 02 03 09 06 01 01 3F 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 02 03 09 06 01 01 03 08 00 FF 06 00 00 00 CB 00 7E

S: 7e a0 0a 00 22 00 23 03 91 18 22 7e

R: 7E A8 8C 03 00 22 00 23 78 96 A8 82 02 02 0F 00 16 20 09 06 01 01 18 08 00 FF 06 00 03 C2 EE 02 02 0F 00 16 20 02 03 09 06 01 01 2C 08 00 FF 06 00 00 00 82 02 02 0F 00 16 20 02 03 09 06 01 01 40 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 02 03 09 06 01 01 04 08 00 FF 06 00 03 C3 70 02 02 0F 00 16 20 02 03 09 06 01 01 19 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 02 03

31

02 03 02 03 09 06 01 01 2D 08 00 FF 06 00 00 00 50 02 88 CB 7E

S: 7e a0 0a 00 22 00 23 03 b1 1a 03 7e

R: 7E A8 8C 03 00 22 00 23 7A 84 8B 02 0F 00 16 20 02 03

09 06 01 01 41 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 09 06 01 01 05 08 00 FF 06 00 00 00 50 02 02 0F 00 16 20 09 06 01 01 1A 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 09 06 01 01 2E 08 00 FF 06 00 00 00 32 02 02 0F 00 16 20 09 06 01 01 42 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 09 06 01 01 06 08 00 FF 06 00 00 00 32 02 02 0F B9 E0 7E

S: 7e a0 0a 00 22 00 23 03 d1 1c 60 7e

R: 7E A8 8C 03 00 22 00 23 7C B2 EE 09 06 01 01 1B 08 00 FF 06 00 03 C2 EE 02 02 0F 00 16 20 09 06 01 01 2F 08 00 FF 06 00 00 00 02 02 0F 00 16 20 09 06 01 01 43 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 09 06 01 01 07 08 00 FF 06 00 03 C3 52 02 02 0F 00 16 20 09 06 01 01 1C 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 09 06 01 01 30 08 00 FF 06 00 00 00 1E 02 02 0F 00 16 A8 C8 7E

S: 7e a0 0a 00 22 00 23 03 f1 1e 41 7e

R: 7E A8 8C 03 00 22 00 23 7E A0 CD 09 06 01 01 44 08 00 FF 06 00 00 00 00 02 02 0F 00 16 20 09 06 01 01 08 08 00 FF 06 00 00 00 1E 02 02 0F 00 16 20 09 06 01 01 1D 08 00 FF 06 00 00 00 00 02 02 0F 00 16 1F 09 06 01 01 31 08 00 FF 06 00 00 02 62 02 02 0F 00 16 1F 09 06 01 01 45 08 00 FF 06 00 00 00 00 02 02 0F 00 16 1F 09 06 01 01 09 08 00 FF 06 00 00 02 62 02 02 0F 00 16 1F 5B 0C 7E

S: 7e a0 0a 00 22 00 23 03 11 10 a6 7e

R: 7E A8 8C 03 00 22 00 23 70 DE 24 03

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

32

02 03 02 03 02 03 02 03 02 03 00 16 20 02 03 02 03 02 03 02 03 02 03 20 02 03 02 03 02 03 02 03 02 03 02 02 03

02 03

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

1C EB 7E

S: 7e a0 0a 00 22 00 23 03 31 12 87 7e

R: 7E A8 8C 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 02 0F 00 16 FF 02 03 09 06 FF 02 FF 08 00 FF 06 00 00 00 00 02 02 0F 00 16 FF 02 03 09 06 FF 03 FF 08 00 FF 06 00 00 00 00 02 02 0F 00 16 FF 02 03 09 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 02 0F 00 16 FF 02 03 09 06 FF 29 95 7E

S: 7e a0 0a 00 22 00 23 03 51 14 e4 7e

R: 7E A0 5B 03 00 22 00 23 74 8C 7C 06 FF 08 00

FF 06 00 00 00 00 02 02 0F 00 16 FF 02 03 09 06 FF 07 FF 08 00 FF 06 00 00 00 00 02 02 0F 00 16 FF 02 03 09 06 FF 08 FF 08 00 FF 06 00 00 00 00 02 02 0F 00 16 FF 02 03 09 06 FF 09 FF 08 00 FF 06 00 00 00 00 02 02 0F 00 16 FF 0B 2E 7E

S: 7e a0 0a 00 22 00 23 03 71 16 c5 7e

R: 7E A0 0A 03 00 22 00 23 71 3B C6 7E

S: 7e a0 0a 00 22 00 23 03 71 16 c5 7e

R: 7E A0 0A 03 00 22 00 23 71 3B C6 7E

S: 7e a0 0a 00 22 00 23 03 71 16 c5 7e

R: 7E A0 0A 03 00 22 00 23 71 3B C6 7E

S: 7e a0 0a 00 22 00 23 03 71 16 c5 7e

R: 7E A0 0A 03 00 22 00 23 71 3B C6 7E

33

S: 7e a0 0a 00 22 00 23 03 71 16 c5 7e

R: 7E A0 0A 03 00 22 00 23 71 3B C6 7E

S: 7e a0 0a 00 22 00 23 03 71 16 c5 7e

R: 7E A0 0A 03 00 22 00 23 71 3B C6 7E

//disc link

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

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

六、请求数据实例 这里给出几个数据通讯的实例,供程序员编程时参考。 1、 请求电量

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

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

R:7E A0 21 03 00 22 00 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E S:7E A0 46 00 22 00 23 03 10 05 C1 E6 E6 00 60 35 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 01 00 00 00 06 5F 04 00 00 00 14 00 00 BD BF 7E

R:7E A0 52 03 00 22 00 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 07 60 85 74 05 08 02 01 AA 0A 80 08 41 42 43 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 00 23 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 22 00 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 00 23 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 22 00 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 00 23 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 22 00 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 00 23 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 22 00 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 00 23 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 22 00 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 00 23 03 D1 1C 60 7E R:7E A0 0A 03 00 22 00 23 D1 31 63 7E S:7E A0 0A 00 22 00 23 03 53 06 C7 7E R:7E A0 0A 03 00 22 00 23 73 29 E5 7E S:7E A0 0A 00 22 00 23 03 93 0A 01 7E

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

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

34

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

R:7E A0 52 03 00 22 00 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 07 60 85 74 05 08 02 01 AA 0A 80 08 41 42 43 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 00 23 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 22 00 23 52 F1 D1 E6 E7 00 C4 01 81 00 12 00 02 33 53 7E

S:7E A0 1B 00 22 00 23 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 22 00 23 74 C5 95 E6 E7 00 C4 01 81 00 12 00 02 33 53 7E

S:7E A0 1B 00 22 00 23 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 22 00 23 96 D9 51 E6 E7 00 C4 01 81 00 12 00 02 33 53 7E

S:7E A0 1B 00 22 00 23 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 22 00 23 B8 A5 99 E6 E7 00 C4 01 81 00 12 00 01 A8 61 7E

S:7E A0 1B 00 22 00 23 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 22 00 23 DA B1 D9 E6 E7 00 C4 01 81 00 12 00 01 A8 61 7E

S:7E A0 1B 00 22 00 23 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 22 00 23 FC 85 9D E6 E7 00 C4 01 81 00 12 00 01 A8 61 7E S:7E A0 0A 00 22 00 23 03 F1 1E 41 7E R:7E A0 0A 03 00 22 00 23 F1 33 42 7E S:7E A0 0A 00 22 00 23 03 53 06 C7 7E R:7E A0 0A 03 00 22 00 23 73 29 E5 7E

3、请求负荷曲线

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

R:7E A0 21 03 00 22 00 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E S:7E A0 46 00 22 00 23 03 10 05 C1 E6 E6 00 60 35 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 01 00 00 00 06 5F 04 00 00 00 14 00 00 BD BF 7E

R:7E A0 52 03 00 22 00 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 07 60 85 74 05 08 02 01 AA 0A 80 08 41 42 43 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 00 23 03 32 0E 3B E6 E6 00 C0 01 81 00 07 00 00 63 01 00 FF 02 01 01 02 04 00 09 0C 07 D3 06 09 FF FF FF FF FF FF FF FF 09 0C 07 D3 06 0A FF FF FF FF FF FF FF FF DE 82 7E

R:7E A8 8C 03 00 22 00 23 52 CE 26 E6 E7 00 C4 01 81 00 01 22 02 06 02 02 09 0C 07 D3 06 09 FF 09 1D 0D FF FF FF FF 04 06 40 00 00 00 10 00 00 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 00 00 02 06 00 00 00 00 10 00 00 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 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 83 9E 7E S:7E A0 0A 00 22 00 23 03 51 14 E4 7E

R:7E A8 8C 03 00 22 00 23 54 F8 43 00 10 00 00 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 00 00 02 06 00 00 00 00 10 00 00 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 00 00 02 06 00 00 00 00 10 00 00 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 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 F9 31 7E S:7E A0 0A 00 22 00 23 03 71 16 C5 7E

R:7E A8 8C 03 00 22 00 23 56 EA 60 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02

35

06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 00 02 02 09 0C FF FF FF FF FF 0F 08 34 FF FF FF FF 04 06 40 02 02 09 0C FF FF FF FF FF 0F 0E 1F FF FF FF FF 04 06 40 10 00 00 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 00 00 02 06 00 00 00 00 10 00 00 14 24 7E S:7E A0 0A 00 22 00 23 03 91 18 22 7E

R:7E A0 75 03 00 22 00 23 58 40 72 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 00 00 02 06 00 00 00 00 10 00 00 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 00 00 02 06 00 00 00 00 10 00 00 10 00 00 02 06 00 02 02 09 0C FF FF FF FF FF 11 23 0C FF FF FF FF 04 06 40 00 00 10 00 00 10 00 00 A2 1B 7E S:7E A0 0A 00 22 00 23 03 B1 1A 03 7E R:7E A0 0A 03 00 22 00 23 51 39 E7 7E S:7E A0 0A 00 22 00 23 03 53 06 C7 7E R:7E A0 0A 03 00 22 00 23 73 29 E5 7E

4、请求时间

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

R:7E A0 21 03 00 22 00 23 73 28 F0 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E S:7E A0 46 00 22 00 23 03 10 05 C1 E6 E6 00 60 35 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 45 46 47 48 BE 10 04 0E 01 00 00 00 06 5F 04 00 00 00 14 00 00 BD BF 7E

R:7E A0 52 03 00 22 00 23 30 95 39 E6 E7 00 61 41 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 88 02 07 80 07 60 85 74 05 08 02 01 AA 0A 80 08 41 42 43 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 00 23 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 22 00 23 52 A3 C0 E6 E7 00 C4 01 81 00 09 0C 07 D3 06 0E 06 0E 0D 03 FF FF FF 00 10 38 7E

S:7E A0 0A 00 22 00 23 03 51 14 E4 7E R:7E A0 0A 03 00 22 00 23 51 39 E7 7E S:7E A0 0A 00 22 00 23 03 53 06 C7 7E R:7E A0 0A 03 00 22 00 23 73 29 E5 7E

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

补充一:

对于SN Referencing的解释 When SN referencing is used, the attributes and methods of each interface object

are mapped to DLMS named variables. This is done during the design of the meter. Each named variable is identified with a short name, which is a 16 bit unsigned integer.Attribute 1, the logical name of the object is mapped to a DLMS named variable identified by a base name. Except in the case of a few special objects, there are no general rules defined for assigning base names. All other attributes and methods of the object are then

36

also mapped to DLMS named variables. The offsets between the base name and the short name identifying the other attributes and methods are defined in the definition of each interface class. The actual values of the short names thus depend on the number and kind of objects instantiated and the mapping strategy used. The base names allocated in the metering equipment can be retrieved by reading the object_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, attributes and methods are accessed via the logical name of the object, specifying the index(es) of the attribute(s) and/or the method(s). Logical names are defined by OBIS. When LN referencing is used, the attributes and methods are accessed by the xDLMS GET/SET and ACTION services.

(Referencing from “DLMS User Association Frequently Asked Questions”)

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

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

7E A0 11 03 21 32 B7 3D E6 E6 00

05 //SN application-context-name ReadRequest 01 02 FF 08 //short name and attribute ??? A0 E0 7E

补充二:

目前DLMS规约中用到的CLASS ID 和OBIS

数据名称 时钟 正向有功(总) 正向有功(费率一) 正向有功(费率二) 正向有功(费率三) 正向有功(费率四) 反向有功(总) 反向有功(费率一) 反向有功(费率二) 反向有功(费率三) 反向有功(费率四) 有功功率(总) 无功功率(总) L1电压 L2电压 L3电压

CLASS ID 00 08 00 03 00 04 00 04 00 04 00 04 00 03 00 04 00 04 00 04 00 04 00 03 00 03 00 03 00 03 00 03 OBIS 00 00 01 00 00 ff 01 01 01 08 00 ff 01 01 01 08 01 ff 01 01 01 08 02 ff 01 01 01 08 03 ff 01 01 01 08 04 ff 01 01 02 08 00 ff 01 01 02 08 01 ff 01 01 02 08 02 ff 01 01 02 08 03 ff 01 01 02 08 04 ff 01 01 01 07 00 ff 01 01 02 07 00 ff 01 01 1f 07 00 ff 01 01 33 07 00 ff 01 01 47 07 00 ff 37

ATTRIBUTE 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 L1电流 L2电流 L3电流 正向无功(总) 反向无功(总)

00 03 00 03 00 03 00 03 00 03 01 01 20 07 00 ff 01 01 34 07 00 ff 01 01 48 07 00 ff 01 01 03 08 00 ff 01 01 04 08 00 ff 02 00 02 00 02 00 02 00 02 00 38

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- fenyunshixun.cn 版权所有 湘ICP备2023022495号-9

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务