资讯详情

DLMS/COSEM 蓝皮书解读(五十一):Measurement data monitoring objects(class_id = 66)—— 抓一段“事故波形“

📅 2026/10/30 6:39:56 | 华诺云谱 👁 阅读
DLMS/COSEM 蓝皮书解读(五十一):Measurement data monitoring objects(class_id = 66)—— 抓一段“事故波形“
DLMS/COSEM 蓝皮书解读五十一Measurement data monitoring objectsclass_id 66—— 抓一段事故波形触发点前后各留多少采样点系列说明本系列基于 DLMS UA《Blue Book蓝皮书第 16 版 · 第 2 部分》一个接口类一篇。第 50 篇的Parameter monitorclass_id 65监视的是配置参数有没有变。本篇的Measurement data monitoring objectsclass_id 66监视的是连续的物理量采样——它的典型场景是电压骤降/过流事件发生时把事件前后那段波形抓下来。上篇回顾Parameter monitor关心值变了没是离散事件。但在电能质量分析里光知道电压跌到了 180 V远远不够——还需要知道跌下去之前和之后的波形长什么样是瞬间跌落还是缓慢下降有没有振荡。这就要求设备能连续采样、并在触发时刻把前后一段数据保留下来。Measurement data monitoring就是干这个的。0. 为什么需要这个类 —— 事件前后的上下文才是分析价值所在一个真实的痛点只有事件记录有事件前后波形“10:23:45 发生电压跌落”“10:23:45 发生电压跌落跌落前 20 个周期波形正常跌落后 40 个周期逐步恢复中间有 3 次振荡”只能统计次数能分析原因是雷击是大电机启动是开关操作蓝皮书原文Measurement data monitoring objects, Overview“Instances of the ‘Measurement data monitoring IC’ are used to capture samples in a circular buffer and upon a trigger, a number of samples captured before the trigger and after the trigger are retained and captured to a ‘Profile generic’ object buffer, together with other relevant data. The data in the buffer can then be retrieved by or pushed to the client.”机制是循环缓冲区 触发保留…… [采样][采样][采样][采样][★触发][采样][采样][采样] …… └──── before ────┘ └──── after ────┘设备一直在采样循环覆盖触发发生时把触发前 N 个 触发后 M 个共 NM 个样本定格下来。一个关键设计选择原文专门强调“The IC does not specify the time period before and after the trigger point, but the sampling rate and the number of samples retained before and after the trigger point.”它不定义前后多少毫秒而是定义采样率前后各多少个样本。实际时长 样本数 ÷ 采样率。这样设备和主站都不必关心绝对时间只按样本计数走。触发源可以来自别的对象“The trigger method of the ‘Measurement data monitoring’ class can be linked to the observation of an attribute of another class such as an “Alarm register” logging a particular event, or ‘Register’ reaching a particular value. This can be achieved by coupling the ‘Measurement data monitoring’ object with ‘Register monitor’ and ‘Script table’ objects to achieve the desired use case for waveform measurement capture.”也就是Register monitor(21) 监视某 Register 越限 → 执行 Script table(9) 里的脚本 → 脚本调用 Measurement data monitoring.trigger()1. 类蓝图Measurement data monitoring 0..n class_id 66, version 0属性静态/动态数据类型MinMaxDefShort namelogical_namestaticoctet-string———xwaveform_datadynamiccompact-array———x 0x08trigger_timedynamiclong64-unsigned———x 0x10trigger_sourcedynamicstructure———x 0x18statusdynamicenum———x 0x20sampling_ratestaticdouble-long-unsigned———x 0x28number_of_samples_before_triggerstaticdouble-long-unsigned——0x 0x30number_of_samples_after_triggerstaticdouble-long-unsigned——0x 0x38scaler_unitstaticstructure———x 0x40方法必选/可选(m/o)Short namereset (data)?x 0x48trigger (data)—x 0x50说明原文方法表中reset的 m/o 列显示为“?”未能识别的记号trigger未给出 m/o 标记——本文照录原文不作推断。属性表中原文写作(dynamic)而非其他类常见的(dyn.)此处按原文保留。2. 属性逐条解读2.1 logical_name“Identifies the ‘Measurement data monitoring’ object instance.”2.2 waveform_data —— 波形数据本体蓝皮书原文Measurement data monitoring, waveform_data“Contains sampled values of the quantity monitored. The sampling rate is determined by attribute 6. The data is encoded in compact-array data type. The data capture will only be enabled if the capturing window (attributes 78) are configured with non-zero values. This attribute stores a number of samples determined by attribute 7 and 8, following which it can be captured in a ‘Profile generic’ object.”拆成四条规则规则内容编码compact-array所有样本同类型类型标签只写一次——和第 47 篇Compact data的思路一致采样率由 attribute 6sampling_rate决定启用条件只有 attribute 7 和 8 都配成非 0 时捕获才启用容量存attribute 7 attribute 8个样本之后可被Profile generic捕获“attributes 78 非 0 才启用”是一条很重要的实现约束默认 Def 都是 0也就是说刚建好的对象默认不捕获必须先把前后样本数配好。触发方式也在原文里说清楚了“The trigger of a waveform capture shall be initiated by invoking method 2, which can be either a manual execution or driven by a register monitor (example: point to an event).”waveform_element的 CHOICE原文完整清单CHOICE { double-long [5], double-long-unsigned [6], integer [15], long [16], unsigned [17], long-unsigned [18], long64 [20], long64-unsigned [21], float32 [23], float64 [24] }三条 NOTE都很关键NOTE 1“One instance of this class (1 object) can hold the samples of only one type of measured quantity at once. If waveform data of several quantities are required, a separate object shall be instantiated for each.”——一个对象只存一种量。要同时抓电压和电流波形建两个对象。NOTE 2“The number of samples saved is equal to the sum of number_of_samples_before_trigger and number_of_samples_after_trigger”—— 样本总数 前 后。NOTE 3“This attribute is a candidate for Profile generic to be captured.”—— 它是Profile generic(7) 的捕获候选。2.3 trigger_time —— 微秒级时间戳蓝皮书原文Measurement data monitoring, trigger_time“The trigger_time attribute is of type ‘Microseconds clock’ (see ) and is used to retrieve the exact date time at which the trigger method is executed. From this value and the number of samples before and after, the start and end time of waveform capture can be determined. In this case precision is very important, so clock measurements need to be down to microseconds accuracy.”三个要点类型是Microseconds clock数据类型写作long64-unsigned用途是反推波形的起止时间起始时间 trigger_time − (before ÷ sampling_rate)结束时间 trigger_time (after ÷ sampling_rate)精度要求到微秒——因为采样率可能是每周期几十个点普通秒级时钟根本定位不了。NOTE“This attribute is a candidate for ‘Profile generic’ object to be captured.”2.4 trigger_source —— 谁触发的、为什么触发trigger_source :: structure { trigger_origin: enum { remote, local script } trigger_cause: long-unsigned }字段原文定义工程含义trigger_origin“indicates if capturing the event was triggered remotely or locally”主站远程调trigger()还是本地脚本调的trigger_cause“indicates the event that led to the invocation of the trigger method when the script is invoked by a ‘Script table’ object, monitoring for example a phase voltage or current value. In the case of remote invocation, this value shall be 0x0000. Other values may be specified in companion specifications.”脚本触发时 具体事件码远程触发时必须是0x0000其他取值由配套规范定义NOTE“This attribute is a candidate to be captured in the buffer attribute of a ‘Profile generic’ object.”排障价值事后看trigger_source能区分这是主站手动抓的还是这是某个越限事件自动抓的以及是哪个事件trigger_cause。2.5 status —— 由配套规范定义的波形状态蓝皮书原文Measurement data monitoring, status“Provides information about the status of waveform measurements. It can indicate conditions as follows: missing data in the waveform array, measurement error, measurement in progress. The definition of this attribute shall be part of a companion specification.”三种可指示的状态状态含义missing data in the waveform array波形数组里有数据缺失样本没采全measurement error测量出错measurement in progress测量进行中注意最后一句“The definition of this attribute shall be part of a companion specification”——具体 enum 取值不在本类里定义要看项目配套规范。这和Status mapping(63) 的含义在参考表里是同一个套路。NOTE“This attribute is a candidate for profile generic to be captured. It could have similar meaning as status flags in load profiles.”2.6 sampling_rate —— 每周期采多少个点蓝皮书原文Measurement data monitoring, sampling_rate“User configurable attribute, which determines the number of elements to be captured in a certain amount of time, so this parameter defines the granularity of data sampling. This parameter is defined in number of measurements / cycle (period).”NOTE“The recommendation is to configure this parameter at manufacturing and not modify it in operation.”单位是每周期测量次数number of measurements / cycle不是 Hz。50 Hz 系统、每周期 32 点 → 采样率 32 → 实际 1600 次/秒改这个参数会改变波形的物理含义所以原文建议出厂配置、运行中别改。2.7 / 2.8 number_of_samples_before_trigger / after_trigger“User configurable attribute, which indicates the number of waveform samples to be retained before the trigger point.”“User configurable attribute, indicating the number of waveform samples to be recorded after the trigger point.”两个都是double-long-unsigned、static、Def 0。Def 0 的含义要特别注意默认两个都是 0 →捕获窗口为 0 → 捕获不启用呼应waveform_data里那句“The data capture will only be enabled if the capturing window (attributes 78) are configured with non-zero values”。2.9 scaler_unit“See the specification of ‘scaler_unit’ in .”原文指向Register(3) 里的scaler_unit定义即scaler: integer, unit: enum的 structure。波形值乘上 scaler 才是物理值。3. 方法reset 与 trigger3.1 reset (data)蓝皮书原文Measurement data monitoring, reset“Upon invocation of this method, the application aborts the process of capturing samples. This method can be useful if the waveform capture is in progress due to an event, but an override by a new action is required. In such cases the trigger method needs to be invoked following the invocation of the reset method.”reset是中止捕获不是清空波形数据。典型用法正在抓一段波形还没抓完 → 发现有更重要的事件要抓 → reset() 中止当前捕获 → trigger() 重新开始抓3.2 trigger (data)蓝皮书原文Measurement data monitoring, trigger“At the point of invoking this method a number of samples are saved equal to number_of_samples_before_trigger plus number_of_samples_after_trigger that will be subsequently captured and saved in the waveform_data attribute (attribute 2).”语义很有意思调用trigger()的那一刻设备的循环缓冲区里已经有过去 N 个样本于是立刻定格这 N 个然后再继续采 M 个凑齐 NM 存入waveform_data。NOTE“If a capture is in progress, new capture attempts will be rejected by the application process with the corresponding DLMS error code (at the time of capture a lockout timer will be started within the DLMS server).”并发保护捕获进行中时新的捕获尝试会被拒绝并返回相应 DLMS 错误码。因为捕获期间 server 内会启动一个lockout timer。工程含义主站轮询式地频繁调trigger()会拿到错误码——这是预期行为不是故障。正确做法是先读status若指示 measurement in progress 就等或先reset()再trigger()。4. 【实战举例】说明以下 OBIS、取值、时序均为帮助理解而构造的示例非蓝皮书原文原文未给出数值示例实际以设备对象列表与项目配套规范为准。示例 1配置一个电压骤降波形捕获对象Measurement data monitoring 对象 logical_name 0-0:96.50.1.255 示意 OBIS sampling_rate 32 -- 每周期 32 点50 Hz → 1600 点/秒 number_of_samples_before_trigger 64 -- 触发前 2 个周期 number_of_samples_after_trigger 128 -- 触发后 4 个周期 scaler_unit { scaler -1, unit 35 } -- 0.1 V示意总样本数 64 128 192个对应 NOTE 2 的前后之和。对应时长工程推算非原文公式每周期 32 点 → 64 点 2 个周期 40 ms50 Hz 128 点 4 个周期 80 ms 总窗口 ≈ 120 ms注意原文不给时间周期只给采样率与样本数上面的时长换算是工程推算用于理解不作为规格依据。示例 2忘了配 before/after 会怎样number_of_samples_before_trigger 0 -- 默认值 number_of_samples_after_trigger 0 -- 默认值调用trigger()→不会捕获任何波形。因为原文规定“The data capture will only be enabled if the capturing window (attributes 78) are configured with non-zero values.”这是最容易踩的坑之一对象建好了、trigger()也调了、也没报错但waveform_data是空的。示例 3一次完整的事件触发抓波形链路① Register monitor(21) 监视 Register(3)「L1 相电压」阈值 19800198.0 Vscaler -2 ② 电压跌到 180 V → Register monitor 触发 ③ 执行 Script table(9) 中的脚本条目 ④ 脚本调用 Measurement data monitoring.trigger() ⑤ 设备定格 64前 继续采 128后 192 个样本 ⑥ 写入 waveform_data ⑦ 同时 trigger_time、trigger_source、status 被更新 ⑧ Profile generic(7) 捕获 waveform_data trigger_time 等入 buffer ⑨ 主站读取 profile buffer或设备通过 Push setup(40) 推送对应的trigger_source{ trigger_origin local script, -- 由脚本调用非远程 trigger_cause 0x0001 -- 示意某事件码由配套规范定义 }示例 4远程手动抓波形时 trigger_cause 必须是 0主站想现在就抓一段看看ACTION trigger (data …)此时{ trigger_origin remote, trigger_cause 0x0000 -- 原文In the case of remote invocation, this value shall be 0x0000 }主站侧校验价值读到trigger_origin remote但trigger_cause ≠ 0x0000→ 设备实现有问题反之读到local script但trigger_cause 0x0000→ 脚本没填事件码信息丢失。示例 5捕获进行中再次触发会被拒绝t0ms 事件 A → trigger() 开始捕获server 启动 lockout timer t10ms 事件 B → trigger() → ❌ 被拒绝返回相应 DLMS 错误码原文 NOTE“If a capture is in progress, new capture attempts will be rejected by the application process with the corresponding DLMS error code”正确处理方式工程建议非原文若事件 B 更重要 → 先reset()中止 A再trigger()抓 B否则接受拒绝等 A 完成后再抓可通过读status判断是否 measurement in progress。示例 6用 trigger_time 反推波形起止时刻trigger_time microseconds clock 值对应 2024-05-11 14:23:45.123456 sampling_rate 32每周期50 Hz before 64 → 2 个周期 40 ms after 128 → 4 个周期 80 ms推得波形起始 14:23:45.123456 − 40 ms 14:23:45.083456 波形结束 14:23:45.123456 80 ms 14:23:45.203456原文依据“From this value and the number of samples before and after, the start and end time of waveform capture can be determined. In this case precision is very important, so clock measurements need to be down to microseconds accuracy.”上面具体时刻为构造示例。示例 7要抓电压和电流得建两个对象对象 1logical_name 0-0:96.50.1.255 → 电压波形V 对象 2logical_name 0-0:96.50.2.255 → 电流波形ANOTE 1“One instance of this class (1 object) can hold the samples of only one type of measured quantity at once. If waveform data of several quantities are required, a separate object shall be instantiated for each.”两个对象各自的sampling_rate建议一致否则后续做功率计算时样本无法对齐。示例 8把波形塞进 Profile genericProfile generic 的 capture_objects [ { class_id 66, logical_name 0-0:96.50.1.255, attribute_index 3, data_index 0 }, -- trigger_time { class_id 66, logical_name 0-0:96.50.1.255, attribute_index 4, data_index 0 }, -- trigger_source { class_id 66, logical_name 0-0:96.50.1.255, attribute_index 2, data_index 0 }, -- waveform_data { class_id 66, logical_name 0-0:96.50.1.255, attribute_index 5, data_index 0 } -- status ]原文对 attribute 2/3/4/5 都给了 NOTE “is a candidate for Profile generic to be captured”——这四个属性都是捕获候选一起入 profile 才能形成时间 来源 波形 状态的完整记录。5. 工程上容易踩的坑没配 before/after 就调trigger()两者默认 Def 0原文规定窗口非 0 才启用捕获——结果是调了没反应。以为reset()会清空waveform_data原文说它是中止捕获过程aborts the process of capturing samples用法是reset 后再 trigger。捕获进行中反复调trigger()会被拒绝并返回 DLMS 错误码因为 server 内启动了 lockout timer。这是保护机制不是故障。一个对象想抓多个量NOTE 1 明确一次只能一种量多量要建多个对象。把sampling_rate当成 Hz原文单位是每周期测量次数改它会改变波形物理含义原文建议出厂配置、运行中别改。用秒级时钟算波形时间trigger_time要求微秒精度Microseconds clock。远程触发时trigger_cause填了非 0原文规定必须是0x0000。指望本类定义status的 enum 取值“shall be part of a companion specification”要看配套规范。指望本类给出前后多少毫秒它只给采样率和样本数时长要自己换算。把waveform_data当普通 array 解析它是compact-array类型标签只出现一次。忽略scaler_unit波形原始值要乘 scaler 才是物理值原文指向Register的scaler_unit定义。6. 小结 下期预告本篇要点Measurement data monitoring objects(66) 用循环缓冲区 触发保留抓波形典型场景是电压骤降/过流等电能质量事件它不定义时间窗口只定义sampling_rate每周期测量次数前后样本数总数 before after前后样本数默认 0非 0 才启用捕获——这是最容易踩的坑waveform_data是compact-array一个对象只能存一种量多量需多对象trigger_time是微秒级Microseconds clock可据此反推波形起止时间trigger_source区分 remote / local script远程触发时trigger_cause必须为0x0000status的 enum 取值由配套规范定义attribute 2/3/4/5 都是Profile generic的捕获候选捕获进行中再触发会被拒绝lockout timer需要时用reset()中止后重试。下一篇第 52 篇Sensor managerclass_id 67—— 从电测量转向非电计量热表、水表、气表15 个 attribute 把传感器铭牌、原始值、处理后值、阈值与动作打包成一个对象。参考资料DLMS UA《Blue Book Ed.16 Part 2 – COSEM interface classes》Measurement data monitoring objects(class_id 66, version 0) 章节文中属性名与顺序、数据类型、(dynamic)标注、Def 值、Short name 偏移、方法表含 reset 的 m/o 为 “?”、trigger 无 m/o 标记、CHOICE 成员清单与引文均与原文一致原文未提供数值示例本文 8 个示例均为帮助理解而构造非蓝皮书原文实际以设备对象列表及项目配套规范为准。
📝

华诺云谱内容团队

资深建站顾问 · 行业研究员

10年+企业数字化服务经验,专注智能建站、SEO优化与品牌营销,持续输出建站技巧、行业洞察与营销干货,已帮助5000+企业实现数字化增长。

你可能需要的服务

订阅华诺云谱资讯周报

每周一封,精选建站技巧、SEO与营销干货,直达邮箱。已有 8,000+ 企业主订阅,助你少走弯路。

↑