WO2022111209A1 - 数据采集方法、装置、数据采集设备及可读存储介质 - Google Patents

数据采集方法、装置、数据采集设备及可读存储介质 Download PDF

Info

Publication number
WO2022111209A1
WO2022111209A1 PCT/CN2021/127361 CN2021127361W WO2022111209A1 WO 2022111209 A1 WO2022111209 A1 WO 2022111209A1 CN 2021127361 W CN2021127361 W CN 2021127361W WO 2022111209 A1 WO2022111209 A1 WO 2022111209A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
parsing
expression
template
parsing template
Prior art date
Application number
PCT/CN2021/127361
Other languages
English (en)
French (fr)
Inventor
姚杰
洪小敏
陈晖�
史国芳
李冬
Original Assignee
浙江中控技术股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 浙江中控技术股份有限公司 filed Critical 浙江中控技术股份有限公司
Publication of WO2022111209A1 publication Critical patent/WO2022111209A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Definitions

  • the present application belongs to the technical field of data processing, and in particular, relates to a data acquisition method, device, data acquisition device and readable storage medium.
  • the OPC protocol is an interface standard established to ensure the communication between various application programs of the industrial control system. It provides a standard data access mechanism for the industrial control field.
  • Industrial equipment generally uses the OPC protocol. There are many types of equipment in the factory. These equipment are often produced by different manufacturers. Even if the equipment generated by different manufacturers adopts the OPC protocol, the data format of the generated messages will also be different.
  • the current data acquisition scheme is as follows: technicians modify the core code of the data acquisition software according to the message samples provided by the equipment manufacturer, and after receiving the message, use the data acquisition software to parse the message and save the analysis result.
  • the current data acquisition scheme adopts a hard-coded scheme, which is less flexible. For example, when a new device is added, the technician needs to modify the core code of the data acquisition software according to the message generated by the device, and modify the core code of the data acquisition software. Code puts a heavier burden on technicians.
  • the purpose of the present application is to provide a data collection method, device, data collection device and readable storage medium, so as to improve the flexibility of the data collection scheme and reduce the burden on technicians to modify the core code.
  • the application provides a data collection method, which is applied to data collection equipment, including:
  • the target message follows the OPC protocol
  • the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates
  • the target expression is an expression corresponding to the target parsing template
  • the configuration file includes a plurality of parsing templates and expressions corresponding to each parsing template
  • the method further includes: configuring an analysis template and a corresponding expression based on on-site working conditions, and saving the analysis template and the corresponding expression to a configuration file.
  • the method further includes:
  • the correctness of the parsing template and the corresponding expression is verified based on the sample message, and if the correctness verification is passed, the operation of saving the parsing template and the corresponding expression to a configuration file is performed.
  • the method further includes: modifying the parsing template and/or the corresponding expression in the configuration file.
  • the application also provides a data acquisition device, comprising:
  • a target message obtaining unit used to obtain a target message, the target message follows the OPC protocol
  • a target parsing template obtaining unit which determines a target parsing template among the multiple parsing templates included in the configuration file, where the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates;
  • variable value extraction unit configured to extract the macro variable value in the target message based on the target parsing template
  • An expression processing unit configured to write the macro variable value into a target expression, where the target expression is an expression corresponding to the target parsing template, wherein the configuration file includes a plurality of parsing templates and corresponding parsing templates The expression corresponding to the template;
  • a result processing unit configured to save the execution result.
  • the above data acquisition device it also includes:
  • the preprocessing unit is configured to receive a parsing template and a corresponding expression configured based on on-site working conditions, and save the parsing template and the corresponding expression to a configuration file.
  • the above data acquisition device it also includes:
  • a verification unit configured to obtain a sample message after the preprocessing unit receives the parsing template and the corresponding expression configured based on the on-site working conditions, and verify the correctness of the parsing template and the corresponding expression based on the sample message , if the correctness verification is passed, the preprocessing unit is triggered to perform the operation of saving the parsing template and the corresponding expression to the configuration file.
  • the above data acquisition device it also includes:
  • a configuration file modification unit configured to receive a modification instruction, and modify the parsing template and/or the corresponding expression in the configuration file based on the modification instruction.
  • the application also provides a data acquisition device, including a processor and a memory;
  • the memory is used to store programs
  • the processor is configured to call and execute the program stored in the memory, so as to implement each step of any one of the above data collection methods.
  • the present application also provides a readable storage medium on which a program is stored, and when the program is executed by a processor, each step of any of the above data collection methods is implemented.
  • the target analysis template is determined from the multiple analysis templates included in the configuration file, that is, the target analysis template is determined from the multiple analysis templates and the target message.
  • the parsing template with the highest matching degree then extract the macro variable value in the target message based on the target parsing template, then write the extracted macro variable value into the expression corresponding to the target parsing template, and execute the expression to obtain the execution result and to save. It can be seen that the technical solution disclosed in this application completes the analysis of OPC messages based on the configuration file.
  • FIG. 2 is a schematic diagram of an example of data collection disclosed in this application.
  • FIG. 4 is a schematic structural diagram of a data acquisition device disclosed in the application.
  • FIG. 5 is a schematic structural diagram of another data acquisition device disclosed in the application.
  • FIG. 6 is a schematic structural diagram of another data acquisition device disclosed in this application.
  • the present application discloses a data acquisition method, device, data acquisition device and readable storage medium, so as to improve the flexibility of the data acquisition scheme and reduce the burden of modifying core codes for technicians.
  • FIG. 1 is a flowchart of a data collection method disclosed in this application.
  • the data collection method disclosed in this application is applied to data collection equipment, and the data collection method includes:
  • a target message During the operation of industrial equipment, messages that follow the OPC protocol are generated. Data acquisition devices acquire messages generated by industrial equipment based on a variety of strategies and approaches. In this application, the to-be-processed message that complies with the OPC protocol is referred to as a target message.
  • S102 Determine a target parsing template from the multiple parsing templates included in the configuration file.
  • the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates. It should be noted that the configuration file contains multiple parsing templates and expressions corresponding to each parsing template.
  • the set of matching phrases in the parsing template is: macro variables and ordinary characters included in the parsing template that match the target message.
  • the sorting rules are as follows:
  • the parsing templates containing more macro variables and common characters have higher priority.
  • parsing template 1 is: "Change tag $ ⁇ TAG ⁇ $.$ ⁇ CONDITION ⁇ $($ ⁇ MSG ⁇ $) from $ ⁇ OLD ⁇ $ to $ ⁇ NEW ⁇ $";
  • the parsing template 2 is: "Change the tag $ ⁇ TAG ⁇ $.$ ⁇ CONDITION ⁇ $ from $ ⁇ OLD ⁇ $ to $ ⁇ NEW ⁇ $".
  • the matching phrase set of parsing template 2 is the same as the matching phrase set of parsing template 1. According to rules a), b) and c), the priority ordering between the two parsing templates cannot be determined, because the macro variables contained in parsing template 1 and common characters are more than the macro variables and common characters contained in the parsing template 2. Therefore, it is determined that the priority of parsing template 1 is higher than that of parsing template 2.
  • the target expression is an expression corresponding to the target parsing template.
  • FIG. 2 is a schematic diagram of an example of data acquisition disclosed in this application.
  • the data acquisition device monitors the messages from the OPC server in real time.
  • the data acquisition device When the data acquisition device receives the message "change the bit number DI1.PV (standby) from ON to OFF" from the OPC server, it matches the message with the multiple parsing templates contained in the configuration file one by one to determine the highest matching degree.
  • the parsing template (that is, the target parsing template).
  • the configuration file contains the following parsing templates:
  • This message best matches the parsing template "Change tag $ ⁇ TAG ⁇ $.$ ⁇ CONDITION ⁇ $($ ⁇ MSG ⁇ $) from $ ⁇ OLD ⁇ $ to $ ⁇ NEW ⁇ $", so this The parsing template serves as the target parsing template.
  • the data acquisition device extracts the macro variable value in the message based on the target parsing template.
  • the macro variable TAG is equal to "DI1”
  • the macro variable CONDITION is equal to "PV”
  • the macro variable MSG is equal to "backup”
  • the macro variable OLD is equal to " ON”
  • the macro variable NEW is equal to "OFF”
  • the macro variable value is brought into the expression corresponding to the target parsing template (that is, the target expression)
  • the current target expression is executed to obtain the result of business logic processing.
  • the result to the database.
  • step 3 the characters extracted from the gaps appearing in the middle of ordinary characters are the macro variable values.
  • the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates contained in the configuration file, which ensures that even if there is no parsing template with the exact same data format as the target message, the target Messages are parsed accurately.
  • the data acquisition device After the data acquisition device obtains the target message, it determines the target parsing template among the multiple parsing templates included in the configuration file, that is, the parsing template with the highest matching degree with the target message among the multiple parsing templates, and then Extract the macro variable value in the target message based on the target parsing template, then write the extracted macro variable value into an expression corresponding to the target parsing template, execute the expression, and obtain and save the execution result.
  • the data acquisition device completes the analysis of the OPC message based on the configuration file.
  • the configuration file needs to be modified, but the core code does not need to be modified, which greatly improves the data.
  • the flexibility of the acquisition scheme also improves the security and stability of the system, and reduces the burden on technicians to modify the core code.
  • FIG. 3 is a flowchart of another data collection method disclosed in this application.
  • the data collection method includes:
  • technicians collect several data samples, classify the data samples, analyze the data samples of each type, summarize the rules of the data samples of each type, and then write the analysis templates and corresponding expressions for the data samples of each type. , and save the parsing template and corresponding expression to the configuration file.
  • the configuration file is released to the data collection device, and when the data collection device receives the OPC message, it can parse the OPC message based on the configuration file to realize data collection.
  • the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates.
  • the target expression is an expression corresponding to the target parsing template.
  • the method further includes: obtaining a sample message; verifying the correctness of the parsing template and the corresponding expression based on the sample message, and if the correctness verification is passed, executing the The action of saving the parsing template and corresponding expression to the configuration file.
  • the correctness of the parsing template and the corresponding expression is verified, and the following scheme is adopted: extract the macro variable value in the sample message based on the parsing template, substitute the macro variable value into the aforementioned expression, and execute the current Expression, obtain the result of business logic processing, and judge whether the result is consistent with the expected result. If it is consistent, it is determined to pass the correctness verification, and if it is inconsistent, it is determined to fail the correctness verification.
  • the data processing method shown in FIG. 3 of the present application configures a parsing template and corresponding expressions based on on-site working conditions, and saves the parsing templates and corresponding expressions to a configuration file.
  • the message is parsed to complete the data collection.
  • the method further includes: modifying the parsing template and/or the corresponding expression in the configuration file.
  • the data acquisition device can accurately parse the OPC message generated by the industrial device based on the updated configuration file.
  • FIG. 4 is a schematic structural diagram of a data acquisition device disclosed in the present application.
  • the data collection device includes a target message acquisition unit 100 , a target parsing template acquisition unit 200 , a variable value extraction unit 300 , an expression processing unit 400 , an expression execution unit 500 and a result processing unit 600 .
  • the target message obtaining unit 100 is used to obtain the target message. Among them, the target message follows the OPC protocol.
  • the target analysis template obtaining unit 200 determines the target analysis template from among the plurality of analysis templates included in the configuration file.
  • the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates.
  • the variable value extraction unit 300 is configured to extract the macro variable value in the target message based on the target parsing template.
  • the expression processing unit 400 is configured to write the macro variable value into a target expression, where the target expression is an expression corresponding to the target parsing template.
  • the configuration file includes multiple parsing templates and expressions corresponding to each parsing template.
  • Expression execution unit 500 executes the target expression, and obtains the execution result
  • the result processing unit 600 is used for saving the execution result.
  • the data collection device disclosed in the present application after obtaining the target message, determines the target parsing template among the multiple parsing templates included in the configuration file, that is, the parsing template with the highest matching degree with the target message among the multiple parsing templates, and then parses the target based on the The template extracts the macro variable value in the target message, then writes the extracted macro variable value into an expression corresponding to the target parsing template, executes the expression, and obtains and saves the execution result. It can be seen that the data acquisition device disclosed in the present application completes the analysis of OPC messages based on the configuration file. When the on-site working conditions change, only the configuration file needs to be modified, but the core code does not need to be modified, which greatly improves the data acquisition scheme. The flexibility of the system also improves the security and stability of the system, and reduces the burden of technical personnel to modify the core code.
  • FIG. 5 is a schematic structural diagram of another data acquisition device disclosed in this application.
  • the data acquisition device shown in FIG. 5 further includes a preprocessing unit 700 .
  • the preprocessing unit 700 is configured to receive a parsing template and a corresponding expression configured based on on-site working conditions, and save the received parsing template and the corresponding expression to a configuration file.
  • a verification unit 800 is further set.
  • the verification unit 800 is configured to obtain a sample message after the preprocessing unit 700 receives the parsing template and the corresponding expression configured based on the on-site working conditions, and verifies the correctness of the received parsing template and the corresponding expression based on the sample message, if Passing the correctness verification, the preprocessing unit 700 is triggered to execute the operation of saving the received parsing template and the corresponding expression to the configuration file.
  • FIG. 6 is a schematic structural diagram of another data acquisition device disclosed in this application.
  • the data collection apparatus shown in FIG. 6 further includes a configuration file modification unit 900 .
  • the configuration file modification unit 900 is configured to receive a modification instruction, and modify the parsing template and/or the corresponding expression in the configuration file based on the modification instruction.
  • the present application also discloses a data acquisition device, which may include: at least one processor, at least one communication interface, at least one memory and at least one communication bus.
  • the number of the processor, the communication interface, the memory, and the communication bus is at least one, and the processor, the communication interface, and the memory communicate with each other through the communication bus.
  • the processor may be a central processing unit (CPU), or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of the present invention, or the like.
  • CPU central processing unit
  • ASIC Application Specific Integrated Circuit
  • the memory may include high-speed RAM memory, and may also include non-volatile memory, etc., such as at least one disk memory.
  • the memory stores a program
  • the processor can call the program stored in the memory, and the program is used for:
  • the target message follows the OPC protocol
  • the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates
  • the target expression is an expression corresponding to the target parsing template
  • the configuration file includes a plurality of parsing templates and expressions corresponding to each parsing template
  • the present application also discloses a readable storage medium, on which a program is stored, and when the program is executed by a processor, it realizes:
  • the target message follows the OPC protocol
  • the target parsing template is the parsing template with the highest matching degree with the target message among the multiple parsing templates
  • the target expression is an expression corresponding to the target parsing template
  • the configuration file includes a plurality of parsing templates and expressions corresponding to each parsing template

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

一种数据采集方法、装置、数据采集设备及可读存储介质。该方法包括:获得目标消息(S101);在配置文件包含的多个解析模板中确定目标解析模板(S102),目标解析模板为多个解析模板中与目标消息的匹配度最高的解析模板;基于目标解析模板提取目标消息中的宏变量值(S103);将提取出的宏变量值写入目标表达式(S104),目标表达式为目标解析模板对应的表达式,其中,配置文件包含多个解析模板以及与各个解析模板对应的表达式;执行目标表达式,获得执行结果(S105);保存执行结果(S106)。该方法具有较高的灵活性,提高了系统的安全性和稳定性,并且减小了技术人员修改核心代码的负担。

Description

数据采集方法、装置、数据采集设备及可读存储介质
本申请要求于2020年11月30日提交中国专利局、申请号为202011379748.9、发明名称为“一种数据采集方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请属于数据处理技术领域,尤其涉及一种数据采集方法、装置、数据采集设备及可读存储介质。
背景技术
OPC协议是为了保证工业控制系统的各应用程序之间的通信而建立的接口标准,它为工业控制领域提供了一种标准数据访问机制。
工业设备普遍采用OPC协议。工厂中的设备种类繁多,这些设备往往是由不同厂商生产的,而不同厂商生成的设备,即便都采用OPC协议,但生成的消息的数据格式也会存在差异。目前的数据采集方案为:技术人员根据设备厂商提供的消息的样例修改数据采集软件的核心代码,在接收到消息后,利用数据采集软件对消息进行解析,保存解析结果。
但是,目前的数据采集方案采用的是硬编码方案,灵活性较低,例如,当增加新的设备时,技术人员需要根据该设备生成的消息对数据采集软件的核心代码进行修改,而且修改核心代码给技术人员带来的负担较重。
发明内容
有鉴于此,本申请的目的在于提供一种数据采集方法、装置、数据采集设备及可读存储介质,以提高数据采集方案的灵活性,减小技术人员修改核心代码的负担。
为实现上述目的,本申请提供如下技术方案:
本申请提供一种数据采集方法,应用于数据采集设备,包括:
获得目标消息,所述目标消息遵循OPC协议;
在配置文件包含的多个解析模板中确定目标解析模板,所述目标解析模板为所述多个解析模板中与所述目标消息的匹配度最高的解析模板;
基于所述目标解析模板提取所述目标消息中的宏变量值;
将所述宏变量值写入目标表达式,所述目标表达式为所述目标解析模板对应的表达式,其中,所述配置文件包含多个解析模板以及与各个解析模板对应的表达式;
执行所述目标表达式,获得执行结果;
保存所述执行结果。
可选的,在上述数据采集方法的基础上,还包括:基于现场工况配置解析模板以及对应的表达式,将所述解析模板和对应的表达式保存至配置文件。
可选的,在上述数据采集方法的基础上,在所述基于现场工况配置解析模板以及对应的表达式后,还包括:
获得样本消息;
基于所述样本消息对所述解析模板以及对应的表达式进行正确性验证,如果通过正确性验证,则执行将所述解析模板和对应的表达式保存至配置文件的操作。
可选的,在上述数据采集方法的基础上,还包括:修改所述配置文件中的解析模板和/或对应的表达式。
本申请还提供一种数据采集装置,包括:
目标消息获取单元,用于获得目标消息,所述目标消息遵循OPC协议;
目标解析模板获取单元,在配置文件包含的多个解析模板中确定目标解析模板,所述目标解析模板为所述多个解析模板中与所述目标消息的匹配度最高的解析模板;
变量值提取单元,用于基于所述目标解析模板提取所述目标消息中的宏变量值;
表达式处理单元,用于将所述宏变量值写入目标表达式,所述目标表达式为所述目标解析模板对应的表达式,其中,所述配置文件包含多个解析模板以 及与各个解析模板对应的表达式;
表达式执行单元,执行所述目标表达式,获得执行结果;
结果处理单元,用于保存所述执行结果。
可选的,在上述数据采集装置的基础上,还包括:
预处理单元,用于接收基于现场工况配置的解析模板以及对应的表达式,将所述解析模板和对应的表达式保存至配置文件。
可选的,在上述数据采集装置的基础上,还包括:
验证单元,用于在所述预处理单元接收基于现场工况配置的解析模板以及对应的表达式后,获得样本消息,基于所述样本消息对所述解析模板以及对应的表达式进行正确性验证,如果通过正确性验证,则触发所述预处理单元执行将所述解析模板和对应的表达式保存至配置文件的操作。
可选的,在上述数据采集装置的基础上,还包括:
配置文件修改单元,用于接收修改指令,基于所述修改指令修改所述配置文件中的解析模板和/或对应的表达式。
本申请还提供一种数据采集设备,包括处理器和存储器;
所述存储器用于存储程序;
所述处理器用于调用并执行所述存储器存储的程序,实现如上述任意一种数据采集方法的各个步骤。
本申请还提供一种可读存储介质,其上存储有程序,所述程序被处理器执行时,实现如上述任意一种数据采集方法的各个步骤。
由此可见,本申请的有益效果为:
本申请公开的数据采集方法、装置、数据采集设备及可读存储介质,获得目标消息后,在配置文件包含的多个解析模板中确定目标解析模板,即,多个解析模板中与目标消息的匹配度最高的解析模板,之后基于目标解析模板提取目标消息中的宏变量值,之后将提取出的宏变量值写入与目标解析模板对应的表达式,并执行该表达式,获得执行结果并进行保存。可以看到,本申请公开的技术方案基于配置文件完成对OPC消息的解析,当现场工况发生变化时,只需要修改配置文件,而不需要修改核心代码,这极大地提高了数据采集方案 的灵活性,也提高了系统的安全性和稳定性,并且减小了技术人员修改核心代码的负担。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请公开的一种数据采集方法的流程图;
图2为本申请公开的一个数据采集示例的原理图;
图3为本申请公开的另一种数据采集方法的流程图;
图4为本申请公开的一种数据采集装置的结构示意图;
图5为本申请公开的另一种数据采集装置的结构示意图;
图6为本申请公开的另一种数据采集装置的结构示意图。
具体实施方式
本申请公开一种数据采集方法、装置、数据采集设备及可读存储介质,以提高数据采集方案的灵活性,减小技术人员修改核心代码的负担。
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
参见图1,图1为本申请公开的一种数据采集方法的流程图。本申请公开的数据采集方法应用于数据采集设备,该数据采集方法包括:
S101:获得目标消息。
工业设备在运行过程中,生成遵循OPC协议的消息。数据采集设备基于 多种策略和途径获得工业设备生成的消息。本申请中,将待处理的遵循OPC协议的消息称为目标消息。
S102:在配置文件包含的多个解析模板中确定目标解析模板。
其中,目标解析模板为多个解析模板中与目标消息的匹配度最高的解析模板。需要说明的是,配置文件包含多个解析模板以及与各个解析模板对应的表达式。
可选的,在配置文件包含的多个解析模板中确定与目标消息匹配度最高的解析模板,可以采用如下方案:
1)、针对每个解析模板,对解析模板进行拆解,获得该解析模板包含的宏变量和普通字符。
2)、针对每个解析模板,确定该解析模板的匹配词组集合。其中,解析模板的匹配词组集合为:该解析模板包含的宏变量和普通字符中与目标消息匹配的宏变量和普通字符。
3)、根据多个解析模板的匹配词组集合对多个解析模板进行优先级排序,将优先级最高的解析模板确定为目标解析模板。
其中,排序规则如下:
a)、普通字符的优先级高于宏变量的优先级。
b)、宏变量之间的优先级规则:整形>浮点数>布尔型>字符串。
c)、普通字符之间的优先级规则:字符长度较长则优先级较高。
如果按照规则a)、b)和c)未确定出解析模板之间的优先级排序,那么包含较多宏变量和普通字符的解析模板的优先级较高。
例如,解析模板1为:“将位号${TAG}$.${CONDITION}$(${MSG}$)从${OLD}$改变为${NEW}$”;
解析模板2为:“将位号${TAG}$.${CONDITION}$从${OLD}$改变为${NEW}$”。
解析模板2的匹配词组集合与解析模板1的匹配词组集合相同,按照规则a)、b)和c)无法确定出这两个解析模板之间的优先级排序,由于解析模板1包含的宏变量和普通字符多于解析模板2包含的宏变量和普通字符,因此,确定 解析模板1的优先级高于解析模板2的优先级。
S103:基于解析模板提取目标消息中的宏变量值。
S104:将宏变量值写入目标表达式。
其中,目标表达式为目标解析模板对应的表达式。
S105:执行目标表达式,获得执行结果。
S106:保存执行结果。
这里结合一个示例进行说明。
请参见图2,图2为本申请公开的一个数据采集示例的原理图。
数据采集设备实时监听来自OPC服务器的消息。
数据采集设备接收到来自OPC服务器的消息“将位号DI1.PV(备用)从ON改变为OFF”时,将该消息与配置文件包含的多个解析模板逐个进行匹配,以确定出匹配度最高的解析模板(即目标解析模板)。
例如,配置文件包含以下解析模板:
“将位号${TAG}$.${CONDITION}$从${OLD}$改变为${NEW}$修改原因:${REASON}$”;
“新值=${DBL1}$,旧值=${DBL1}$”;
“将位号${TAG}$.${CONDITION}$(${MSG}$)从${OLD}$改变为${NEW}$”。
该消息与解析模板“将位号${TAG}$.${CONDITION}$(${MSG}$)从${OLD}$改变为${NEW}$”的匹配度最高,因此,将该解析模板作为目标解析模板。
之后,数据采集设备基于目标解析模板提取该消息中的宏变量值,具体的:宏变量TAG等于“DI1”、宏变量CONDITION等于“PV”、宏变量MSG等于“备用”、宏变量OLD等于“ON”、宏变量NEW等于“OFF”,将宏变量值带入到与目标解析模板对应的表达式(即目标表达式)中,然后执行当前的目标表达式,获得到业务逻辑处理的结果,最后将结果写入到数据库中。
其中,基于目标解析模板“将位号${TAG}$.${CONDITION}$(${MSG}$)从${OLD}$改变为${NEW}$”提取消息“将位号DI1.PV(备用)从ON改 变为OFF”中的宏变量的步骤如下:
1)、对目标解析模板进行拆分,得到以下词组:“将位号”、“${TAG}$”、“.”、“${CONDITION}$”、“(”、“${MSG}$”、“)从”、“${OLD}$”、“改变为”、“${NEW}$”。
2)、将消息“将位号DI1.PV(备用)从ON改变为OFF”与对目标解析模板拆分得到的多个词组依次进行匹配。
3)、匹配普通字符,目标解析模板中出现的普通字符必须是按照前后次序在消息中出现。
满足步骤3)后,从普通字符中间出现的空隙提取出的字符即宏变量值。
需要说明的是,目标解析模板是配置文件包含的多个解析模板中与目标消息的匹配度最高的解析模板,这保证了即便没有与目标消息的数据格式完全相同的解析模板,仍能够对目标消息进行准确的解析。
本申请公开的数据采集方法,数据采集设备获得目标消息后,在配置文件包含的多个解析模板中确定目标解析模板,即,多个解析模板中与目标消息的匹配度最高的解析模板,之后基于目标解析模板提取目标消息中的宏变量值,之后将提取出的宏变量值写入与目标解析模板对应的表达式,并执行该表达式,获得执行结果并进行保存。可以看到,本申请公开的方案,数据采集设备基于配置文件完成对OPC消息的解析,当现场工况发生变化时,只需要修改配置文件,而不需要修改核心代码,这极大地提高了数据采集方案的灵活性,也提高了系统的安全性和稳定性,并且减小了技术人员修改核心代码的负担。
参见图3,图3为本申请公开的另一种数据采集方法的流程图。该数据采集方法包括:
S301:基于现场工况配置解析模板以及对应的表达式,将解析模板和对应的表达式保存至配置文件。
实施中,技术人员采集若干数据样本,对数据样本进行分类,针对各类别的数据样本进行分析,总结各类别的数据样本的规律,从而针对各类别的数据样本分别编写解析模板和对应的表达式,并将解析模板和对应的表达式保存至 配置文件。之后,向数据采集设备发布配置文件,数据采集设备在接收到OPC消息时,就可以基于配置文件OPC消息进行解析,实现数据采集。
S302:获得目标消息。
S303:在配置文件包含的多个解析模板中确定目标解析模板。
其中,目标解析模板为多个解析模板中与目标消息的匹配度最高的解析模板。
S304:基于解析模板提取目标消息中的宏变量值。
S305:将宏变量值写入目标表达式。
其中,目标表达式为目标解析模板对应的表达式。
S306:执行目标表达式,获得执行结果。
S307:保存执行结果。
可选的,在基于现场工况配置解析模板以及对应的表达式后,还包括:获得样本消息;基于样本消息对解析模板以及对应的表达式进行正确性验证,如果通过正确性验证,则执行将解析模板和对应的表达式保存至配置文件的操作。
实施中,基于样本消息对解析模板以及对应的表达式进行正确性验证,采用如下方案:基于该解析模板提取该样本消息中的宏变量值,将宏变量值代入前述的表达式,执行当前的表达式,获得业务逻辑处理的结果,判断该结果是否与期望的结果一致,如果一致,则确定通过正确性验证,如果不一致,则确定未通过正确性验证。
本申请图3所示的数据处理方法,基于现场工况配置解析模板以及对应的表达式,将解析模板和对应的表达式保存至配置文件,当接收到目标消息时,基于该配置文件对目标消息进行解析,完成数据采集。
在一个实施例中,在图1和图3所示数据采集方法的基础上,还包括:修改配置文件中的解析模板和/或对应的表达式。
当工业设备进行升级或改造后,如果该工业设备生成的OPC消息的数据格式发生变化,那么对配置文件中相应的解析模板和/或与该解析模板对应的 表达式进行修改,并向数据采集设备发布修改后的配置文件。数据采集设备在接收到该工业设备生成的OPC消息时,能够基于更新后的配置文件对该工业设备生成的OPC消息进行准确地解析。
本申请上述公开了数据采集方法,相应的,本申请还公开数据采集装置,说明书中关于两者的描述可以相互参考。
参见图4,图4为本申请公开的一种数据采集装置的结构示意图。
该数据采集装置包括目标消息获取单元100、目标解析模板获取单元200、变量值提取单元300、表达式处理单元400、表达式执行单元500和结果处理单元600。
其中:
目标消息获取单元100,用于获得目标消息。其中,目标消息遵循OPC协议。
目标解析模板获取单元200,在配置文件包含的多个解析模板中确定目标解析模板。其中,目标解析模板为多个解析模板中与目标消息的匹配度最高的解析模板。
变量值提取单元300,用于基于目标解析模板提取目标消息中的宏变量值。
表达式处理单元400,用于将宏变量值写入目标表达式,目标表达式为目标解析模板对应的表达式。其中,配置文件包含多个解析模板以及与各个解析模板对应的表达式。
表达式执行单元500,执行目标表达式,获得执行结果;
结果处理单元600,用于保存执行结果。
本申请公开的数据采集装置,获得目标消息后,在配置文件包含的多个解析模板中确定目标解析模板,即,多个解析模板中与目标消息的匹配度最高的解析模板,之后基于目标解析模板提取目标消息中的宏变量值,之后将提取出的宏变量值写入与目标解析模板对应的表达式,并执行该表达式,获得执行结果并进行保存。可以看到,本申请公开的数据采集装置基于配置文件完成对 OPC消息的解析,当现场工况发生变化时,只需要修改配置文件,而不需要修改核心代码,这极大地提高了数据采集方案的灵活性,也提高了系统的安全性和稳定性,并且减小了技术人员修改核心代码的负担。
参见图5,图5为本申请公开的另一种数据采集装置的结构示意图。
与图4所示的数据采集装置相比,图5所示的数据采集装置进一步包括预处理单元700。
预处理单元700,用于接收基于现场工况配置的解析模板以及对应的表达式,将接收的解析模板和对应的表达式保存至配置文件。
可选的,进一步设置验证单元800。
验证单元800,用于在预处理单元700接收基于现场工况配置的解析模板以及对应的表达式后,获得样本消息,基于样本消息对接收的解析模板以及对应的表达式进行正确性验证,如果通过正确性验证,则触发预处理单元700执行将接收的解析模板和对应的表达式保存至配置文件的操作。
参见图6,图6为本申请公开的另一种数据采集装置的结构示意图。
与图5所示的数据采集装置相比,图6所示的数据采集装置进一步包括配置文件修改单元900。
配置文件修改单元900,用于接收修改指令,基于修改指令修改配置文件中的解析模板和/或对应的表达式。
本申请还公开一种数据采集设备,该数据采集设备可以包括:至少一个处理器,至少一个通信接口,至少一个存储器和至少一个通信总线。
在本申请实施例中,处理器、通信接口、存储器、通信总线的数量为至少一个,且处理器、通信接口、存储器通过通信总线完成相互间的通信。
处理器可能是一个中央处理器CPU,或者是特定集成电路ASIC(Application Specific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路等。
存储器可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory)等,例如至少一个磁盘存储器。
其中,存储器存储有程序,处理器可调用存储器存储的程序,所述程序用于:
获得目标消息,所述目标消息遵循OPC协议;
在配置文件包含的多个解析模板中确定目标解析模板,所述目标解析模板为所述多个解析模板中与所述目标消息的匹配度最高的解析模板;
基于所述目标解析模板提取所述目标消息中的宏变量值;
将所述宏变量值写入目标表达式,所述目标表达式为所述目标解析模板对应的表达式,其中,所述配置文件包含多个解析模板以及与各个解析模板对应的表达式;
执行所述目标表达式,获得执行结果;
保存所述执行结果。
可选的,所述程序的细化功能和扩展功能可参照上文描述。
本申请还公开一种可读存储介质,其上存储有程序,程序被处理器执行时,实现:
获得目标消息,所述目标消息遵循OPC协议;
在配置文件包含的多个解析模板中确定目标解析模板,所述目标解析模板为所述多个解析模板中与所述目标消息的匹配度最高的解析模板;
基于所述目标解析模板提取所述目标消息中的宏变量值;
将所述宏变量值写入目标表达式,所述目标表达式为所述目标解析模板对应的表达式,其中,所述配置文件包含多个解析模板以及与各个解析模板对应的表达式;
执行所述目标表达式,获得执行结果;
保存所述执行结果。
可选的,所述程序的细化功能和扩展功能可参照上文描述。
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置、数据采集设备及可读存储介质而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。

Claims (10)

  1. 一种数据采集方法,应用于数据采集设备,其特征在于,包括:
    获得目标消息,所述目标消息遵循OPC协议;
    在配置文件包含的多个解析模板中确定目标解析模板,所述目标解析模板为所述多个解析模板中与所述目标消息的匹配度最高的解析模板;
    基于所述目标解析模板提取所述目标消息中的宏变量值;
    将所述宏变量值写入目标表达式,所述目标表达式为所述目标解析模板对应的表达式,其中,所述配置文件包含多个解析模板以及与各个解析模板对应的表达式;
    执行所述目标表达式,获得执行结果;
    保存所述执行结果。
  2. 根据权利要求1所述的数据采集方法,其特征在于,还包括:基于现场工况配置解析模板以及对应的表达式,将所述解析模板和对应的表达式保存至配置文件。
  3. 根据权利要求2所述的数据采集方法,其特征在于,在所述基于现场工况配置解析模板以及对应的表达式后,还包括:
    获得样本消息;
    基于所述样本消息对所述解析模板以及对应的表达式进行正确性验证,如果通过正确性验证,则执行将所述解析模板和对应的表达式保存至配置文件的操作。
  4. 根据权利要求2所述的数据采集方法,其特征在于,还包括:修改所述配置文件中的解析模板和/或对应的表达式。
  5. 一种数据采集装置,其特征在于,包括:
    目标消息获取单元,用于获得目标消息,所述目标消息遵循OPC协议;
    目标解析模板获取单元,在配置文件包含的多个解析模板中确定目标解析模板,所述目标解析模板为所述多个解析模板中与所述目标消息的匹配度最高的解析模板;
    变量值提取单元,用于基于所述目标解析模板提取所述目标消息中的宏变量值;
    表达式处理单元,用于将所述宏变量值写入目标表达式,所述目标表达式为所述目标解析模板对应的表达式,其中,所述配置文件包含多个解析模板以及与各个解析模板对应的表达式;
    表达式执行单元,执行所述目标表达式,获得执行结果;
    结果处理单元,用于保存所述执行结果。
  6. 根据权利要求5所述的数据采集装置,其特征在于,还包括:
    预处理单元,用于接收基于现场工况配置的解析模板以及对应的表达式,将所述解析模板和对应的表达式保存至配置文件。
  7. 根据权利要求6所述的数据采集装置,其特征在于,还包括:
    验证单元,用于在所述预处理单元接收基于现场工况配置的解析模板以及对应的表达式后,获得样本消息,基于所述样本消息对所述解析模板以及对应的表达式进行正确性验证,如果通过正确性验证,则触发所述预处理单元执行将所述解析模板和对应的表达式保存至配置文件的操作。
  8. 根据权利要求6所述的数据采集装置,其特征在于,还包括:
    配置文件修改单元,用于接收修改指令,基于所述修改指令修改所述配置文件中的解析模板和/或对应的表达式。
  9. 一种数据采集设备,其特征在于,包括处理器和存储器;
    所述存储器用于存储程序;
    所述处理器用于调用并执行所述存储器存储的程序,实现如权利要求1至4中任一项所述的数据采集方法的各个步骤。
  10. 一种可读存储介质,其上存储有程序,其特征在于,所述程序被处理器执行时,实现如权利要求1至4中任一项所述的数据采集方法的各个步骤。
PCT/CN2021/127361 2020-11-30 2021-10-29 数据采集方法、装置、数据采集设备及可读存储介质 WO2022111209A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011379748.9 2020-11-30
CN202011379748.9A CN112486479A (zh) 2020-11-30 2020-11-30 一种数据采集方法及装置

Publications (1)

Publication Number Publication Date
WO2022111209A1 true WO2022111209A1 (zh) 2022-06-02

Family

ID=74937927

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/127361 WO2022111209A1 (zh) 2020-11-30 2021-10-29 数据采集方法、装置、数据采集设备及可读存储介质

Country Status (2)

Country Link
CN (1) CN112486479A (zh)
WO (1) WO2022111209A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112486479A (zh) * 2020-11-30 2021-03-12 浙江中控技术股份有限公司 一种数据采集方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150089515A1 (en) * 2013-09-21 2015-03-26 Vayavya Labs Private. Limited System and method for generating a device driver using an archive of template code
CN106295132A (zh) * 2016-07-27 2017-01-04 杭州杭氧股份有限公司 一种基于模板技术的空分设备变负荷优化方法
CN111010378A (zh) * 2019-12-03 2020-04-14 江苏百倍云信息科技有限公司 一种多类传感器和多种协议快速接入云平台方法
CN111611788A (zh) * 2020-04-14 2020-09-01 大唐软件技术股份有限公司 一种数据处理的方法及装置、电子设备、存储介质
CN112486479A (zh) * 2020-11-30 2021-03-12 浙江中控技术股份有限公司 一种数据采集方法及装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101246486B (zh) * 2007-02-13 2012-02-01 国际商业机器公司 用于改进的表达式处理的方法和装置
CN102982439A (zh) * 2012-11-12 2013-03-20 中国电子科技集团公司第十五研究所 生成电子公文的方法及电子公文生成系统
CN107332849A (zh) * 2017-07-06 2017-11-07 李长云 一种传感数据解析方法及装置
CN108153520B (zh) * 2018-03-20 2020-10-27 上海屹通信息科技发展有限公司 软件开发方法及装置
CN111241803A (zh) * 2020-01-15 2020-06-05 深圳壹账通智能科技有限公司 生成文本文件的方法、装置、计算机设备及可读存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150089515A1 (en) * 2013-09-21 2015-03-26 Vayavya Labs Private. Limited System and method for generating a device driver using an archive of template code
CN106295132A (zh) * 2016-07-27 2017-01-04 杭州杭氧股份有限公司 一种基于模板技术的空分设备变负荷优化方法
CN111010378A (zh) * 2019-12-03 2020-04-14 江苏百倍云信息科技有限公司 一种多类传感器和多种协议快速接入云平台方法
CN111611788A (zh) * 2020-04-14 2020-09-01 大唐软件技术股份有限公司 一种数据处理的方法及装置、电子设备、存储介质
CN112486479A (zh) * 2020-11-30 2021-03-12 浙江中控技术股份有限公司 一种数据采集方法及装置

Also Published As

Publication number Publication date
CN112486479A (zh) 2021-03-12

Similar Documents

Publication Publication Date Title
CN110263009B (zh) 日志分类规则的生成方法、装置、设备及可读存储介质
CN103092761B (zh) 基于差异信息文件识别和检查修改代码块的方法及装置
WO2018120721A1 (zh) 用户界面的测试方法、系统、电子装置及计算机可读存储介质
US9875098B2 (en) System and method for extracting a business rule embedded in an application source code
US9323650B2 (en) Methods for generating software test input data and devices thereof
CN104391934A (zh) 数据校验方法和装置
US20110016451A1 (en) Method and system for generating test cases for a software application
WO2021082484A1 (zh) Awr报告自动获取方法、装置、电子设备及存储介质
US20190278590A1 (en) Automated generation of service definitions for message queue application clients
WO2019161645A1 (zh) 基于Shell的数据表提取方法、终端、设备及存储介质
US20190286687A1 (en) Identification of sequential browsing operations
CN108694108B (zh) 一种iOS崩溃数据分类与统计的方法和装置
WO2023109074A1 (zh) 一种实现联动功能的方法、装置、设备、存储介质和程序
WO2022111209A1 (zh) 数据采集方法、装置、数据采集设备及可读存储介质
US10782942B1 (en) Rapid onboarding of data from diverse data sources into standardized objects with parser and unit test generation
WO2019161618A1 (zh) 字符串解析方法、装置、设备及计算机可读存储介质
CN114489594A (zh) 一种命令解析器的构建方法、命令解析处理方法及装置
CN111831536A (zh) 一种自动化测试方法和装置
CN112069305B (zh) 数据筛选方法、装置及电子设备
CN112883088B (zh) 一种数据处理方法、装置、设备及存储介质
CN116185853A (zh) 代码校验方法及装置
CN107632899B (zh) 一种应用服务器的快照服务方法及装置
CN113672233B (zh) 一种基于Redfish的服务器带外管理方法、装置及设备
CN114297057A (zh) 一种自动化测试用例的设计及使用方法
TWI756867B (zh) 在作業系統標記物件標籤及產生安全政策的方法及系統

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21896711

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21896711

Country of ref document: EP

Kind code of ref document: A1