最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】把IEC 104的Cause of Transmission COT的全部定义添加到com.iec.analysis的TransferReason

iec crifan 44浏览 0评论
发现
定义也不完整,只有一部分:
src/iec_analysis/src/main/java/com/iec/analysis/common/TransferReason.java
package com.iec.analysis.common;


import com.iec.analysis.exception.UnknownTransferReasonException;


/**
 * 解析传送原因
 *
 * @author 张雨 2018.01.06
 */
public enum TransferReason {
    UNUSED(0, "未用"),
    PERIOD(1, "周期、循环 "),
    BG_SCANNER(2, "背景扫描"),
    OUTBURST(3, "突发(自发)"),
    INITIALIZATION_COMPLETE(4, "初始化完成"),
    REQUEST(5, "请求或者被请求"),
    ACTIVATE(6, "激活"),
    ACTIVATE_CONFIRMATION(7, "激活确认"),
    STOP_ACTIVATION(8, "    停止激活 "),
    STOP_ACTIVATION_CONFIRMATION(9, "停止激活确认"),
    ACTIVATE_TERMINATION(10, "激活终止     "),
    FILE_TRANSFER(13, "文件传输    "),
    ANSWER_STATION_CALL(20, "响应站召唤(总召唤)"),
    UNKNOWN_TYPE(44, "未知的类型标识"),
    UNKNOWN_REASON_TRANSMISSION(45, "未知的传送原因"),
    UNKNOWN_ASDU(46, "未知的应用服务数据单元公共地址"),
    UNKNOWN_ADDRESS(47, "未知的信息对象地址"),
    RC_STATUS_ERROR(48, "遥控执行软压板状态错误"),
    RC_TIME_ERROR(49, "遥控执行时间戳错误"),
    RC_SIGNATURE_ERROR(50, "遥控执行数字签名认证错误");
    private int code;
    private String describe;


    TransferReason(int code, String describe) {
        this.code = code;
        this.describe = describe;
    }


    public static String getDdescribe(int code) throws UnknownTransferReasonException {
        for (TransferReason value : TransferReason.values()) {
            if (value.code == code) return value.describe;
        }
        throw  new UnknownTransferReasonException();
    }
}
所以去添加完整定义:
参考:
Appendix C.2: Cause of Transmission (COT) values
Code
Cause of Transmission
Abbreviation
1
periodic, cyclic
per/cyc
2
background interrogation
back
3
spontaneous
spont
4
initialized
init
5
interrogation or interrogated
req
6
activation
act
7
confirmation activation
actcon
8
deactivation
deact
9
confirmation deactivation
deactcon
10
termination activation
actterm
11
feedback, caused by distant command
retrem
12
feedback, caused by local command
retloc
13
data transmission
file
14-19
reserved for further compatible definitions
20
interrogated by general interrogation
inrogen
21
interrogated by interrogation group 1
inro1
22
interrogated by interrogation group 2
inro2
23
interrogated by interrogation group 3
inro3
24
interrogated by interrogation group 4
inro4
25
interrogated by interrogation group 5
inro5
26
interrogated by interrogation group 6
inro6
27
interrogated by interrogation group 7
inro7
28
interrogated by interrogation group 8
inro8
29
interrogated by interrogation group 9
inro9
30
interrogated by interrogation group 10
inro10
31
interrogated by interrogation group 11
inro11
32
interrogated by interrogation group 12
inro12
33
interrogated by interrogation group 13
inro13
34
interrogated by interrogation group 14
inro14
35
interrogated by interrogation group 15
inro15
36
interrogated by interrogation group 16
inro16
37
interrogated by counter general interrogation
reqcogen
38
interrogated by interrogation counter group 1
reqco1
39
interrogated by interrogation counter group 2
reqco2
40
interrogated by interrogation counter group 3
reqco3
41
interrogated by interrogation counter group 4
reqco4

44
type-Identification unknown
uknown_type
45
cause unknown
uknown_cause
46
ASDU address unknown
unknown_asdu_address
47
Information object address unknown
unknown_object_address
通过VSCode去参考:
【已解决】把IEC 104的ASDU Type Identifier的全部定义添加到com.iec.analysis的TypeIdentifier
借助于VSCode去添加进来:
先复制到VSCode
从pdf中粘贴过去
不满足需求,不好用正则处理,所以先去试试能否处理到excel中
保存后:
拷贝到VSCode中:
去掉第一行和中间个别几行特殊的
1    periodic, cyclic     per/cyc 
        
2    background interrogation     back 
        
3    spontaneous     spont 
        
4    initialized     init 
        
5    interrogation or interrogated     req 
        
6    activation     act 
        
7    confirmation activation     actcon 
        
8    deactivation     deact 
        
9    confirmation deactivation     deactcon 
        
10    termination activation     actterm 
        
11    feedback, caused by distant command     retrem 
        
12    feedback, caused by local command     retloc 
        
13    data transmission     file 
        
14-19     reserved for further compatible definitions     
        
20    interrogated by general interrogation     inrogen 
        
21    interrogated by interrogation group 1     inro1 
        
22    interrogated by interrogation group 2     inro2 
        
23    interrogated by interrogation group 3     inro3 
        
24    interrogated by interrogation group 4     inro4 
        
25    interrogated by interrogation group 5     inro5 
        
26    interrogated by interrogation group 6     inro6 
        
27    interrogated by interrogation group 7     inro7 
        
28    interrogated by interrogation group 8     inro8 
        
29    interrogated by interrogation group 9     inro9 
        
30    interrogated by interrogation group 10     inro10 
        
31    interrogated by interrogation group 11     inro11 
        
32    interrogated by interrogation group 12     inro12 
        
33    interrogated by interrogation group 13     inro13 
        
34    interrogated by interrogation group 14     inro14 
        
35    interrogated by interrogation group 15     inro15 
        
36    interrogated by interrogation group 16     inro16 
        
37    interrogated by counter general interrogation     reqcogen 
        
38    interrogated by interrogation counter group 1     reqco1 
        
39    interrogated by interrogation counter group 2     reqco2 
        
40    interrogated by interrogation counter group 3     reqco3 
        
41    interrogated by interrogation counter group 4     reqco4 
        
44    type-Identification unknown     uknown_type 
        
45    cause unknown     uknown_cause 
        
46    ASDU address unknown     unknown_asdu_address 
        
47    Information object address unknown     unknown_object_address 
然后去掉多行的空行
\n\t+\n+
\n
替换成:
去掉reserved:
14-19     reserved for further compatible definitions     
然后再去写正则,变成需要的格式:
^(\d+)\t+([\w \-,]+) \t+([\w/]+)
    $3($1, "$2"),
从:
 
1    periodic, cyclic     per/cyc 
2    background interrogation     back 
3    spontaneous     spont 
4    initialized     init 
5    interrogation or interrogated     req 
6    activation     act 
7    confirmation activation     actcon 
8    deactivation     deact 
9    confirmation deactivation     deactcon 
10    termination activation     actterm 
11    feedback, caused by distant command     retrem 
12    feedback, caused by local command     retloc 
13    data transmission     file 
20    interrogated by general interrogation     inrogen 
21    interrogated by interrogation group 1     inro1 
22    interrogated by interrogation group 2     inro2 
23    interrogated by interrogation group 3     inro3 
24    interrogated by interrogation group 4     inro4 
25    interrogated by interrogation group 5     inro5 
26    interrogated by interrogation group 6     inro6 
27    interrogated by interrogation group 7     inro7 
28    interrogated by interrogation group 8     inro8 
29    interrogated by interrogation group 9     inro9 
30    interrogated by interrogation group 10     inro10 
31    interrogated by interrogation group 11     inro11 
32    interrogated by interrogation group 12     inro12 
33    interrogated by interrogation group 13     inro13 
34    interrogated by interrogation group 14     inro14 
35    interrogated by interrogation group 15     inro15 
36    interrogated by interrogation group 16     inro16 
37    interrogated by counter general interrogation     reqcogen 
38    interrogated by interrogation counter group 1     reqco1 
39    interrogated by interrogation counter group 2     reqco2 
40    interrogated by interrogation counter group 3     reqco3 
41    interrogated by interrogation counter group 4     reqco4 
44    type-Identification unknown     uknown_type 
45    cause unknown     uknown_cause 
46    ASDU address unknown     unknown_asdu_address 
47    Information object address unknown     unknown_object_address 
变成:
    per/cyc(1, "periodic, cyclic"), 
    back(2, "background interrogation"), 
    spont(3, "spontaneous"), 
    init(4, "initialized"), 
    req(5, "interrogation or interrogated"), 
    act(6, "activation"), 
    actcon(7, "confirmation activation"), 
    deact(8, "deactivation"), 
    deactcon(9, "confirmation deactivation"), 
    actterm(10, "termination activation"), 
    retrem(11, "feedback, caused by distant command"), 
    retloc(12, "feedback, caused by local command"), 
    file(13, "data transmission"), 
    inrogen(20, "interrogated by general interrogation"), 
    inro1(21, "interrogated by interrogation group 1"), 
    inro2(22, "interrogated by interrogation group 2"), 
    inro3(23, "interrogated by interrogation group 3"), 
    inro4(24, "interrogated by interrogation group 4"), 
    inro5(25, "interrogated by interrogation group 5"), 
    inro6(26, "interrogated by interrogation group 6"), 
    inro7(27, "interrogated by interrogation group 7"), 
    inro8(28, "interrogated by interrogation group 8"), 
    inro9(29, "interrogated by interrogation group 9"), 
    inro10(30, "interrogated by interrogation group 10"), 
    inro11(31, "interrogated by interrogation group 11"), 
    inro12(32, "interrogated by interrogation group 12"), 
    inro13(33, "interrogated by interrogation group 13"), 
    inro14(34, "interrogated by interrogation group 14"), 
    inro15(35, "interrogated by interrogation group 15"), 
    inro16(36, "interrogated by interrogation group 16"), 
    reqcogen(37, "interrogated by counter general interrogation"), 
    reqco1(38, "interrogated by interrogation counter group 1"), 
    reqco2(39, "interrogated by interrogation counter group 2"), 
    reqco3(40, "interrogated by interrogation counter group 3"), 
    reqco4(41, "interrogated by interrogation counter group 4"), 
    uknown_type(44, "type-Identification unknown"), 
    uknown_cause(45, "cause unknown"), 
    unknown_asdu_address(46, "ASDU address unknown"), 
    unknown_object_address(47, "Information object address unknown"), 
期间去试试:
【已解决】VSCode正则替换后如何把字母从小写转换成大写
然后再去把内容:
    PER_CYC(1, "periodic, cyclic"), 
    BACK(2, "background interrogation"), 
    SPONT(3, "spontaneous"), 
    INIT(4, "initialized"), 
    REQ(5, "interrogation or interrogated"), 
    ACT(6, "activation"), 
    ACTCON(7, "confirmation activation"), 
    DEACT(8, "deactivation"), 
    DEACTCON(9, "confirmation deactivation"), 
    ACTTERM(10, "termination activation"), 
    RETREM(11, "feedback, caused by distant command"), 
    RETLOC(12, "feedback, caused by local command"), 
    FILE(13, "data transmission"), 
    INROGEN(20, "interrogated by general interrogation"), 
    INRO1(21, "interrogated by interrogation group 1"), 
    INRO2(22, "interrogated by interrogation group 2"), 
    INRO3(23, "interrogated by interrogation group 3"), 
    INRO4(24, "interrogated by interrogation group 4"), 
    INRO5(25, "interrogated by interrogation group 5"), 
    INRO6(26, "interrogated by interrogation group 6"), 
    INRO7(27, "interrogated by interrogation group 7"), 
    INRO8(28, "interrogated by interrogation group 8"), 
    INRO9(29, "interrogated by interrogation group 9"), 
    INRO10(30, "interrogated by interrogation group 10"), 
    INRO11(31, "interrogated by interrogation group 11"), 
    INRO12(32, "interrogated by interrogation group 12"), 
    INRO13(33, "interrogated by interrogation group 13"), 
    INRO14(34, "interrogated by interrogation group 14"), 
    INRO15(35, "interrogated by interrogation group 15"), 
    INRO16(36, "interrogated by interrogation group 16"), 
    REQCOGEN(37, "interrogated by counter general interrogation"), 
    REQCO1(38, "interrogated by interrogation counter group 1"), 
    REQCO2(39, "interrogated by interrogation counter group 2"), 
    REQCO3(40, "interrogated by interrogation counter group 3"), 
    REQCO4(41, "interrogated by interrogation counter group 4"), 
    UKNOWN_TYPE(44, "type-Identification unknown"), 
    UKNOWN_CAUSE(45, "cause unknown"), 
    UNKNOWN_ASDU_ADDRESS(46, "ASDU address unknown"), 
    UNKNOWN_OBJECT_ADDRESS(47, "Information object address unknown"), 
拷贝到代码中
(第一个特殊需要手动处理:PER/CYC -》 PER_CYC)
如此,即可实现:
把原始的pdf中的表格中的定义,最终处理放到代码中,实现完整的枚举TransferReason的定义了。
【总结】
最后代码是:
src/iec_analysis/src/main/java/com/iec/analysis/common/TransferReason.java
package com.iec.analysis.common;


import com.iec.analysis.exception.UnknownTransferReasonException;


/**
 * 解析传送原因
 *
 * @author 张雨 2018.01.06
 */
public enum TransferReason {
    // UNUSED(0, "未用"),
    // PERIOD(1, "周期、循环 "),
    // BG_SCANNER(2, "背景扫描"),
    // OUTBURST(3, "突发(自发)"),
    // INITIALIZATION_COMPLETE(4, "初始化完成"),
    // REQUEST(5, "请求或者被请求"),
    // ACTIVATE(6, "激活"),
    // ACTIVATE_CONFIRMATION(7, "激活确认"),
    // STOP_ACTIVATION(8, "    停止激活 "),
    // STOP_ACTIVATION_CONFIRMATION(9, "停止激活确认"),
    // ACTIVATE_TERMINATION(10, "激活终止     "),
    // FILE_TRANSFER(13, "文件传输    "),
    // ANSWER_STATION_CALL(20, "响应站召唤(总召唤)"),
    // UNKNOWN_TYPE(44, "未知的类型标识"),
    // UNKNOWN_REASON_TRANSMISSION(45, "未知的传送原因"),
    // UNKNOWN_ASDU(46, "未知的应用服务数据单元公共地址"),
    // UNKNOWN_ADDRESS(47, "未知的信息对象地址"),
    // RC_STATUS_ERROR(48, "遥控执行软压板状态错误"),
    // RC_TIME_ERROR(49, "遥控执行时间戳错误"),
    // RC_SIGNATURE_ERROR(50, "遥控执行数字签名认证错误");


    PER_CYC(1, "periodic, cyclic"), 
    BACK(2, "background interrogation"), 
    SPONT(3, "spontaneous"), 
    INIT(4, "initialized"), 
    REQ(5, "interrogation or interrogated"), 
    ACT(6, "activation"), 
    ACTCON(7, "confirmation activation"), 
    DEACT(8, "deactivation"), 
    DEACTCON(9, "confirmation deactivation"), 
    ACTTERM(10, "termination activation"), 
    RETREM(11, "feedback, caused by distant command"), 
    RETLOC(12, "feedback, caused by local command"), 
    FILE(13, "data transmission"), 
    INROGEN(20, "interrogated by general interrogation"), 
    INRO1(21, "interrogated by interrogation group 1"), 
    INRO2(22, "interrogated by interrogation group 2"), 
    INRO3(23, "interrogated by interrogation group 3"), 
    INRO4(24, "interrogated by interrogation group 4"), 
    INRO5(25, "interrogated by interrogation group 5"), 
    INRO6(26, "interrogated by interrogation group 6"), 
    INRO7(27, "interrogated by interrogation group 7"), 
    INRO8(28, "interrogated by interrogation group 8"), 
    INRO9(29, "interrogated by interrogation group 9"), 
    INRO10(30, "interrogated by interrogation group 10"), 
    INRO11(31, "interrogated by interrogation group 11"), 
    INRO12(32, "interrogated by interrogation group 12"), 
    INRO13(33, "interrogated by interrogation group 13"), 
    INRO14(34, "interrogated by interrogation group 14"), 
    INRO15(35, "interrogated by interrogation group 15"), 
    INRO16(36, "interrogated by interrogation group 16"), 
    REQCOGEN(37, "interrogated by counter general interrogation"), 
    REQCO1(38, "interrogated by interrogation counter group 1"), 
    REQCO2(39, "interrogated by interrogation counter group 2"), 
    REQCO3(40, "interrogated by interrogation counter group 3"), 
    REQCO4(41, "interrogated by interrogation counter group 4"), 
    UKNOWN_TYPE(44, "type-Identification unknown"), 
    UKNOWN_CAUSE(45, "cause unknown"), 
    UNKNOWN_ASDU_ADDRESS(46, "ASDU address unknown"), 
    UNKNOWN_OBJECT_ADDRESS(47, "Information object address unknown");


    private int code;
    private String describe;


    TransferReason(int code, String describe) {
        this.code = code;
        this.describe = describe;
    }


    public static String getDdescribe(int code) throws UnknownTransferReasonException {
        for (TransferReason value : TransferReason.values()) {
            if (value.code == code) return value.describe;
        }
        throw  new UnknownTransferReasonException();
    }
}
供参考。

转载请注明:在路上 » 【已解决】把IEC 104的Cause of Transmission COT的全部定义添加到com.iec.analysis的TransferReason

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
19 queries in 0.088 seconds, using 9.93MB memory