


技术领域technical field
本申请涉及安全控制技术领域,具体而言,涉及一种数据读取方法、数据写入方法及安全控制系统。The present application relates to the technical field of safety control, in particular, to a data reading method, a data writing method and a safety control system.
背景技术Background technique
安全仪表系统是一种被广泛用于石化、化工等行业的安全控制系统,其主要用于报警和停车控制,当工厂在正常生产过程中发生异常工况时,安全仪表系统启动报警或停车操作,防止工况继续恶化,保障人员和设备的安全。The safety instrumented system is a safety control system widely used in petrochemical, chemical and other industries. It is mainly used for alarm and parking control. When abnormal conditions occur in the normal production process of the factory, the safety instrumented system will start the alarm or stop operation. , prevent the working conditions from deteriorating further, and ensure the safety of personnel and equipment.
相关技术中,安全控制系统的控制器多采用1oo2D或2oo3D的表决架构,该类控制器包含有多个相同的控制通道,每个控制通道都能单独完成控制功能,控制通道间通过表决完成安全输出。但由于控制器采用的是实时操作系统,对响应时间的要求高,不允许响应时间超时,针对大规模的操作变量难以实现表决处理;同时,当外部设备对控制器的操作变量进行读操作时,由于每次需要同时读取多个控制通道,可能会因读命令异步的原因,导致各控制通道间的值不一致而显示异常的问题;当外部设备对控制器的操作变量进行写操作时,由于写命令异步的原因,可能存在某个通道的写失败或延迟,导致各控制通道间程序运行不一致的问题。In related technologies, the controllers of safety control systems mostly adopt 1oo2D or 2oo3D voting architecture. This type of controller includes multiple identical control channels, and each control channel can independently complete the control function. output. However, since the controller uses a real-time operating system, the requirements for response time are high, and the response time is not allowed to be overtime. It is difficult to implement voting processing for large-scale operating variables; at the same time, when the external device reads the operating variables of the controller , because multiple control channels need to be read at the same time each time, it may cause the value inconsistency between the control channels and abnormal display due to the asynchronous read command; when the external device writes the operation variable of the controller, Due to the asynchronous writing command, there may be a write failure or delay of a certain channel, resulting in inconsistent program operation among control channels.
针对上述的问题,目前尚未提出有效的解决方案。For the above problems, no effective solution has been proposed yet.
发明内容Contents of the invention
本申请实施例提供了一种数据读取方法、数据写入方法及安全控制系统,以至少解决安全控制系统中控制器的多个控制通道读写数据不一致的技术问题。Embodiments of the present application provide a data reading method, a data writing method, and a safety control system to at least solve the technical problem of inconsistency in reading and writing data of multiple control channels of a controller in the safety control system.
根据本申请实施例的一个方面,提供了一种数据读取方法,应用于安全控制系统中的通讯模块,包括:在每个控制周期内,接收来自控制器中的第一数量个控制通道发送的第一数量组第一操作变量数据;对第一数量组第一操作变量数据进行数据一致性表决,并在表决通过时,将第一操作变量数据存储至通讯模块中的第一缓存区;响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机。According to an aspect of the embodiment of the present application, there is provided a data reading method, which is applied to the communication module in the safety control system, including: in each control period, receiving the first number of control channel transmissions from the controller The first quantity group of the first operational variable data; the data consistency vote is performed on the first quantity group of the first operational variable data, and when the vote is passed, the first operational variable data is stored in the first buffer area in the communication module; In response to the read command sent by the host computer for reading the target manipulated variable data, the target manipulated variable data is queried from all the first manipulated variable data stored in the first buffer, and the target manipulated variable data is fed back to the host computer.
可选地,在对第一数量组第一操作变量数据进行数据一致性表决之前,获取第一数量个控制通道的状态信息;若存在故障控制通道,禁止故障控制通道发送的第一操作变量数据参与数据一致性表决。Optionally, before performing data consistency voting on the first number of groups of first manipulated variable data, the state information of the first number of control channels is obtained; if there is a faulty control channel, the first manipulated variable data sent by the faulty control channel is prohibited Participate in data consistency voting.
可选地,若在连续的第二数量个控制周期内的数据一致性表决的结果均为表决未通过,发出第一告警信息,第一告警信息用于提示第一数量个控制通道中的操作变量数据不一致。Optionally, if the results of the data consistency voting in the second consecutive control cycles are all votes failed, a first warning message is issued, and the first warning message is used to prompt the operation in the first number of control channels Variable data is inconsistent.
根据本申请实施例的另一方面,还提供了一种数据写入方法,应用于安全控制系统中的通讯模块,包括:响应于上位机发送的写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的第一数量个控制通道,其中,写命令中包括待写入的第二操作变量数据;每个控制通道用于将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果;接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机。According to another aspect of the embodiment of the present application, there is also provided a data writing method, which is applied to the communication module in the safety control system, including: in response to the write command sent by the host computer, copying the write command into the first number of copies , and send the first number of write commands to the first number of control channels in the controller respectively, wherein the write command includes the second manipulated variable data to be written; each control channel is used to write the received write Copy the command to the first quantity, save one of the write commands, and send the other write commands to other control channels in the controller, and perform data consistency on the write commands saved by itself and the write commands sent by other control channels Voting, write or discard the second operational variable data based on the voting result, and feed back the writing result to the communication module; receive the first number of writing results fed back by the first number of control channels, and write the first number of writing results Feedback to the host computer.
可选地,在将写命令复制为第一数量份之前,对写命令中的第二操作变量数据进行数据完整性校验;在校验通过时,将写命令复制为第一数量份;在校验未通过时,发出第二告警信息,第二告警信息用于提示第二操作变量数据不完整,需要重新写入。Optionally, before copying the write command into the first number of copies, perform a data integrity check on the second operational variable data in the write command; when the verification is passed, copy the write command into the first number of copies; When the verification fails, a second warning message is issued, and the second warning message is used to prompt that the data of the second operational variable is incomplete and needs to be rewritten.
可选地,在将写命令复制为第一数量份之前,获取第一数量个控制通道的状态信息;若存在故障控制通道,禁止向故障控制通道发送复制的写命令。Optionally, before copying the write command into the first number of copies, acquire the status information of the first number of control channels; if there is a faulty control channel, prohibit sending the copied write command to the faulty control channel.
可选地,每个控制通道将接收到的写命令复制为第一数量份,将其中一份写命令存储至控制通道中的第二缓存区,并生成与写命令对应的表决命令,将表决命令插入表决命令队列;将其他份写命令分别发送至控制器中的其他控制通道,并将表决命令发送至控制器中的其他控制通道;在接收到其他控制通道发送的写命令以及表决命令时,将其他控制通道发送的表决命令插入表决命令队列,并将其他控制通道发送的写命令存储至第二缓存区;在每个控制周期内,检查表决命令队列是否满足预设要求,并在表决命令队列满足预设要求时,对第二缓存区中的多个写命令进行数据一致性表决。Optionally, each control channel copies the received write command into the first number of copies, stores one of the write commands in the second buffer area in the control channel, and generates a voting command corresponding to the write command, and votes Commands are inserted into the voting command queue; other write commands are sent to other control channels in the controller, and voting commands are sent to other control channels in the controller; when receiving write commands and voting commands sent by other control channels , insert the voting commands sent by other control channels into the voting command queue, and store the write commands sent by other control channels in the second buffer area; in each control cycle, check whether the voting command queue meets the preset requirements, and vote When the command queue meets the preset requirements, a data consistency vote is performed on the multiple write commands in the second buffer area.
可选地,第二操作变量数据中至少包括以下之一:第二操作变量的地址、数据内容、数据长度、对应的人机接口软件种类及特征码信息;每个控制通道基于接收到的写命令中的第二操作变量数据生成与写命令对应的唯一标识信息,将唯一标识信息作为表决命令。Optionally, the second operational variable data includes at least one of the following: the address of the second operational variable, data content, data length, corresponding man-machine interface software type and feature code information; each control channel is based on the received write The second operational variable data in the command generates unique identification information corresponding to the write command, and the unique identification information is used as the voting command.
可选地,每个表决命令均具有预设的有效时间段;在每个控制周期内,每个控制通道检查表决命令队列中的表决命令的数量和状态,在表决命令队列中具有第一数量个表决命令且第一数量个表决命令均处于有效时间段内时,对第二缓存区中的第一数量个写命令进行数据一致性表决。Optionally, each voting command has a preset effective time period; in each control cycle, each control channel checks the number and status of voting commands in the voting command queue, and has a first number of voting commands in the voting command queue voting commands and the first number of voting commands are all within the valid time period, perform data consistency voting on the first number of write commands in the second cache area.
可选地,对于每个控制通道,在数据一致的写命令的数量不小于第一预设阈值时,确认表决通过,将第二操作变量数据写入控制器中的操作变量数据区,并向通讯模块反馈写入成功的第一写入结果;在数据一致的写命令的数量小于预设阈值时,确认表决未通过,丢弃第二操作变量数据,并向通讯模块反馈写入失败的第二写入结果。Optionally, for each control channel, when the number of write commands with consistent data is not less than the first preset threshold, the confirmation vote is passed, and the second manipulated variable data is written into the manipulated variable data area in the controller, and sent to The communication module feeds back the first write result of successful writing; when the number of write commands with consistent data is less than the preset threshold, the confirmation vote fails, the second operation variable data is discarded, and the second operation variable data that fails to be written is fed back to the communication module. Write the result.
可选地,在接收到的第二写入结果的数量不小于第二预设阈值时,重新向第二写入结果对应的控制通道发送写命令。Optionally, when the number of received second write results is not less than a second preset threshold, resend the write command to the control channel corresponding to the second write results.
根据本申请实施例的另一方面,还提供了一种安全控制系统,包括:上位机,通讯模块和控制器,其中,上位机用于向通讯模块发送用于读取目标操作变量数据的读命令;接收通讯模块反馈的目标操作变量数据;通讯模块用于在每个控制周期内,接收来自控制器中的第一数量个控制通道发送的第一数量组第一操作变量数据;对第一数量组第一操作变量数据进行数据一致性表决,并在表决通过时,将第一操作变量数据存储至通讯模块中的第一缓存区;响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机;控制器包括第一数量个控制通道,其中,每个控制通道用于在每个控制周期内向通讯模块发送第一操作变量数据。According to another aspect of the embodiment of the present application, there is also provided a safety control system, including: a host computer, a communication module and a controller, wherein the host computer is used to send a read message for reading target manipulated variable data to the communication module. command; receive the target manipulated variable data fed back by the communication module; the communication module is used to receive the first quantity group of first manipulated variable data sent from the first quantity of control channels in the controller in each control cycle; for the first Data consistency voting is performed on the first operational variable data of the quantity group, and when the vote is passed, the first operational variable data is stored in the first buffer area in the communication module; read command, query the target manipulated variable data from all the first manipulated variable data stored in the first cache area, and feed back the target manipulated variable data to the host computer; the controller includes a first number of control channels, wherein each The control channel is used to send the first manipulated variable data to the communication module in each control cycle.
根据本申请实施例的另一方面,还提供了一种安全控制系统,包括:上位机,通讯模块和控制器,其中,上位机,用于向通讯模块发送用于写入第二操作变量数据的写命令;接收通讯模块反馈的写入结果;通讯模块,用于响应于写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的第一数量个控制通道,接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机;控制器,包括第一数量个控制通道,其中,每个控制通道用于将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果。According to another aspect of the embodiment of the present application, there is also provided a safety control system, including: a host computer, a communication module and a controller, wherein the host computer is used to send data for writing the second operating variable to the communication module the write command; receive the writing result fed back by the communication module; the communication module is used to respond to the write command, copy the write command into the first number of copies, and send the first number of write commands to the first number of copies in the controller respectively The number of control channels receives the first number of write results fed back by the first number of control channels, and feeds back the first number of write results to the host computer; the controller includes the first number of control channels, wherein each A control channel is used to copy the received write command into the first number of copies, save one of the write commands, and send the other copies of the write command to other control channels in the controller, write commands saved by itself and others The write command sent by the control channel performs data consistency voting, writes or discards the second operation variable data based on the voting result, and feeds back the writing result to the communication module.
根据本申请实施例的另一方面,还提供了一种非易失性存储介质,该非易失性存储介质包括存储的程序,其中,非易失性存储介质所在设备通过运行该程序执行上述的数据读取方法或数据写入方法。According to another aspect of the embodiment of the present application, there is also provided a non-volatile storage medium, the non-volatile storage medium includes a stored program, wherein, the device where the non-volatile storage medium is located executes the above-mentioned program by running the program. The data read method or data write method.
根据本申请实施例的另一方面,还提供了一种电子设备,该电子设备包括:存储器和处理器,其中,存储器中存储有计算机程序,处理器被配置为通过计算机程序执行上述的数据读取方法或数据写入方法。According to another aspect of the embodiments of the present application, there is also provided an electronic device, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the above-mentioned data reading through the computer program. get method or data write method.
在本申请实施例中,通讯模块在每个控制周期内接收来自控制器中的多个控制通道发送的多组第一操作变量数据,并对多组第一操作变量数据进行数据一致性表决,在表决通过时将第一操作变量数据存储至通讯模块中的第一缓存区,之后响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机;同时,通讯模块可以响应于上位机发送的写入第二操作变量数据的写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的多个控制通道,每个控制通道将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果,通讯模块接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机。其中,通过在读写过程引入数据一致性表决处理过程,有效解决了安全控制系统中控制器的多个控制通道读写数据不一致的技术问题。In the embodiment of the present application, the communication module receives multiple sets of first manipulated variable data sent from multiple control channels in the controller in each control cycle, and performs data consistency voting on multiple sets of first manipulated variable data, When the vote is passed, the first operational variable data is stored in the first buffer area in the communication module, and then in response to the read command sent by the host computer for reading the target operational variable data, all the first operational variable data stored in the first buffer area Query the target manipulated variable data in the manipulated variable data, and feed back the target manipulated variable data to the host computer; at the same time, the communication module can respond to the write command sent by the host computer to write the second manipulated variable data, and copy the write command as the first A number of copies, and send the first number of write commands to multiple control channels in the controller, each control channel will copy the received write commands into the first number of copies, save one of the write commands, and send Other write commands are sent to other control channels in the controller respectively, data consistency voting is performed on the write commands saved by itself and the write commands sent by other control channels, and the second operation variable data is written or discarded based on the voting results, and sent to The communication module feeds back the writing results, and the communication module receives the first number of writing results fed back by the first number of control channels, and feeds back the first number of writing results to the host computer. Among them, by introducing the data consistency voting process in the reading and writing process, the technical problem of inconsistent reading and writing data of multiple control channels of the controller in the safety control system is effectively solved.
附图说明Description of drawings
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described here are used to provide a further understanding of the application and constitute a part of the application. The schematic embodiments and descriptions of the application are used to explain the application and do not constitute an improper limitation to the application. In the attached picture:
图1是根据本申请实施例的一种可选的安全控制系统的结构示意图;FIG. 1 is a schematic structural diagram of an optional security control system according to an embodiment of the present application;
图2是根据本申请实施例的一种可选的数据读取方法的流程示意图;Fig. 2 is a schematic flow chart of an optional data reading method according to an embodiment of the present application;
图3是根据本申请实施例的一种可选的数据写入方法的流程示意图。Fig. 3 is a schematic flowchart of an optional data writing method according to an embodiment of the present application.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiment of the application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiment of the application. Obviously, the described embodiment is only It is an embodiment of a part of the application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.
需要说明的是,本申请的说明书和权利要求书及附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first" and "second" in the specification, claims and drawings of the present application are used to distinguish similar objects, but not necessarily used to describe a specific order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or device comprising a sequence of steps or elements is not necessarily limited to the expressly listed instead, may include other steps or elements not explicitly listed or inherent to the process, method, product or apparatus.
实施例1Example 1
相关技术的安全控制系统中,当外部设备对控制器的操作变量进行读操作时,每次需要同时读取多个控制通道,由于读命令异步的原因,往往会出现通道间值不一致而显示异常的问题;当外部设备对控制器的操作变量进行写操作时,由于写命令异步的原因,可能存在某个通道的写失败或延迟,此种情况下会导致控制通道间程序运行不一致,最终表决结果出错。常规的冗余控制系统是通过备用控制器拷贝工作控制器的数据,以解决数据不一致的问题,但安全控制系统控制器的冗余控制通道要求相互独立,不适合使用该方法。In the safety control system of the related technology, when the external device reads the operation variable of the controller, multiple control channels need to be read at the same time at the same time. Due to the asynchronous reason of the read command, the values between the channels are often inconsistent and the display is abnormal. The problem; when the external device writes the operation variable of the controller, due to the asynchronous reason of the write command, there may be a write failure or delay of a certain channel. The result is wrong. Conventional redundant control systems copy the data of the working controller through the standby controller to solve the problem of data inconsistency, but the redundant control channels of the safety control system controllers require mutual independence, so this method is not suitable.
为了解决上述问题,本申请实施例提供了一种能够更加高效且准确地对操作变量进行读写操作的安全控制系统,如图1所示,该安全控制系统中至少包括:上位机10,通讯模块11和控制器12,其中:In order to solve the above problems, the embodiment of the present application provides a safety control system capable of more efficiently and accurately reading and writing operation variables. As shown in FIG. 1 , the safety control system at least includes: a host computer 10, a communication Module 11 and controller 12, wherein:
上位机10可以是计算机等终端设备,通常运行有HMI(Human Machine Interface,人机接口)软件,用于通过通讯模块11与控制器12进行交互;The upper computer 10 can be a terminal device such as a computer, and usually runs HMI (Human Machine Interface, Human Machine Interface) software for interacting with the controller 12 through the communication module 11;
通讯模块11是上位机10和控制器12之间的桥梁,其中通常包括有一片用于存储操作变量镜像数据的第一缓存区;The communication module 11 is a bridge between the upper computer 10 and the controller 12, which usually includes a first buffer area for storing the image data of the operating variable;
控制器12中包括有多个控制通道12(a~n),多个控制通道12(a~n)之间也可以进行交互,实现对操作变量数据的一致性表决。The controller 12 includes a plurality of control channels 12 (a-n), and the plurality of control channels 12 (a-n) can also interact with each other to implement consistent voting on the manipulated variable data.
以下以安全控制系统中对操作变量的读操作过程为例,对各模块的功能进行具体说明。The following takes the reading operation process of the operating variable in the safety control system as an example to describe the functions of each module in detail.
上位机,用于向通讯模块发送用于读取目标操作变量数据的读命令;接收通讯模块反馈的目标操作变量数据。The upper computer is used to send a read command for reading the target operation variable data to the communication module; and receive the target operation variable data fed back by the communication module.
通讯模块,用于在每个控制周期内,接收来自控制器中的第一数量个控制通道发送的第一数量组第一操作变量数据;对第一数量组第一操作变量数据进行数据一致性表决,并在表决通过时,将第一操作变量数据存储至通讯模块中的第一缓存区;响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机。The communication module is used to receive the first quantity of first manipulated variable data sent from the first quantity of control channels in the controller in each control cycle; perform data consistency on the first quantity of first manipulated variable data vote, and when the vote is passed, store the first manipulated variable data into the first buffer area in the communication module; in response to the read command sent by the host computer for reading the target manipulated variable data, store the first manipulated variable data from the first buffer area Query the target manipulated variable data from all the first manipulated variable data, and feed back the target manipulated variable data to the host computer.
控制器,包括第一数量(n)个控制通道,其中,每个控制通道用于在每个控制周期内向通讯模块发送第一操作变量数据。The controller includes a first number (n) of control channels, wherein each control channel is used to send the first manipulated variable data to the communication module in each control cycle.
其中,第一操作变量数据中至少包括以下之一:第一操作变量的地址、数据内容、数据长度、对应的HMI软件种类及特征码信息。Wherein, the first operational variable data includes at least one of the following: the address of the first operational variable, data content, data length, corresponding HMI software type, and feature code information.
为了保证读取的操作变量数据的一致性,通讯模块需要先对第一数量个控制通道发送的第一数量组第一操作变量数据进行数据一致性表决,在表决通过时,即确认各个控制通道的第一操作变量数据一致,此时通讯模块可以将第一操作变量数据存储至第一缓存区内,以方便后续上位机读取对应的操作变量数据。In order to ensure the consistency of the read operation variable data, the communication module needs to vote on the data consistency of the first number of first operation variable data sent by the first number of control channels. When the vote is passed, each control channel is confirmed. The data of the first manipulated variable are consistent, and the communication module can store the data of the first manipulated variable in the first buffer area, so as to facilitate subsequent host computer to read the corresponding manipulated variable data.
可选地,在对第一数量组第一操作变量数据进行数据一致性表决之前,通讯模块还可以获取第一数量个控制通道的状态信息;若存在故障控制通道,则禁止故障控制通道发送的第一操作变量数据参与数据一致性表决,避免错误数据的干扰。Optionally, before performing a data consistency vote on the data of the first operational variable of the first quantity group, the communication module may also acquire the status information of the first number of control channels; if there is a faulty control channel, prohibit the faulty control channel from sending The data of the first operation variable participates in the data consistency vote to avoid the interference of wrong data.
可选地,若在连续的第二数量个控制周期内的数据一致性表决的结果均为表决未通过,发出第一告警信息,第一告警信息用于提示第一数量个控制通道中的操作变量数据不一致。其中,第二数量可以由用户根据需求自行设置,如设置为3,此处不做具体限定。通过报警方式,能够帮助用户及时发现问题。Optionally, if the results of the data consistency voting in the second consecutive control cycles are all votes failed, a first warning message is issued, and the first warning message is used to prompt the operation in the first number of control channels Variable data is inconsistent. Wherein, the second number can be set by the user according to requirements, for example, it is set to 3, which is not specifically limited here. Through the alarm mode, it can help users find problems in time.
当用户通过上位机的HMI软件读取控制器的目标操作变量数据时,HMI软件向通讯模块发送读命令,通讯模块从第一缓存区中查询目标操作变量数据,并将目标操作变量数据反馈至HMI软件。通过这种方式,HMI软件每次读取控制器的操作变量数据时,仅需要一次查询即可,降低了HMI软件和控制器之间的通讯开销。When the user reads the target operating variable data of the controller through the HMI software of the host computer, the HMI software sends a read command to the communication module, and the communication module queries the target operating variable data from the first buffer area, and feeds back the target operating variable data to HMI software. In this way, each time the HMI software reads the operating variable data of the controller, only one query is required, which reduces the communication overhead between the HMI software and the controller.
作为一种可选的实施方式,上述结构的安全控制系统也可以实现对操作变量的写操作,其中,各模块所实现的功能具体如下:As an optional implementation, the safety control system with the above structure can also implement the write operation to the operating variable, wherein the functions implemented by each module are specifically as follows:
上位机,用于向通讯模块发送用于写入第二操作变量数据的写命令;接收通讯模块反馈的写入结果。The upper computer is used to send a write command for writing the second operation variable data to the communication module; and receive the writing result fed back by the communication module.
通讯模块,用于响应于写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的第一数量个控制通道,接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机。The communication module is configured to copy the write command into a first number of copies in response to the write command, and send the first number of write commands to the first number of control channels in the controller respectively, and receive feedback from the first number of control channels The first number of write results, and feed back the first number of write results to the host computer.
控制器,包括第一数量(n)个控制通道,其中,每个控制通道用于将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果。A controller comprising a first number (n) of control channels, wherein each control channel is used to copy the received write command into a first number of copies, save one copy of the write command, and send the other copies of the write command respectively To other control channels in the controller, perform data consistency voting on the write commands saved by itself and the write commands sent by other control channels, write or discard the second operation variable data based on the voting results, and feed back the writing results to the communication module .
其中,第二操作变量数据中至少包括以下之一:第二操作变量的地址、数据内容、数据长度、对应的HMI软件种类及特征码信息。Wherein, the second operational variable data includes at least one of the following: the address of the second operational variable, data content, data length, corresponding HMI software type, and feature code information.
可选地,在将写命令复制为第一数量份之前,通讯模块可以先对写命令中的第二操作变量数据进行数据完整性校验,如进行CRC(Cyclic Redundancy Check,循环冗余码校验);在校验通过时,将写命令复制为第一数量份;在校验未通过时,发出第二告警信息,第二告警信息用于提示第二操作变量数据不完整,需要重新写入。Optionally, before copying the write command into the first quantity, the communication module can first perform a data integrity check on the second operational variable data in the write command, such as performing a CRC (Cyclic Redundancy Check, Cyclic Redundancy Check) verification); when the verification is passed, the write command is copied to the first quantity; when the verification fails, a second warning message is issued, and the second warning message is used to prompt that the data of the second operating variable is incomplete and needs to be rewritten enter.
可选地,在将写命令复制为第一数量份之前,通讯模块还可以获取第一数量个控制通道的状态信息;若存在故障控制通道,则禁止向故障控制通道发送复制的写命令,避免后续该故障控制通道发送数据对其他正常控制通道造成干扰。Optionally, before copying the write command into the first number of copies, the communication module can also obtain the status information of the first number of control channels; if there is a faulty control channel, it is forbidden to send duplicated write commands to the faulty control channel to avoid Subsequent data sent by the faulty control channel interferes with other normal control channels.
在通讯模块将第一数量份写命令分别发送至第一数量个控制通道后,作为一种可选的实施方式,每个控制通道会将接收到的写命令复制为第一数量份,将其中一份写命令存储至控制通道中的第二缓存区,并生成与写命令对应的表决命令,将表决命令插入表决命令队列;然后将其他份写命令分别发送至控制器中的其他控制通道,并将表决命令发送至控制器中的其他控制通道;在接收到其他控制通道发送的写命令以及表决命令时,将其他控制通道发送的表决命令插入表决命令队列,并将其他控制通道发送的写命令存储至第二缓存区;在每个控制周期内,检查表决命令队列是否满足预设要求,并在表决命令队列满足预设要求时,对第二缓存区中的多个写命令进行数据一致性表决。After the communication module sends the first number of write commands to the first number of control channels, as an optional implementation, each control channel will copy the received write command into the first number of copies, and the A write command is stored in the second buffer area in the control channel, and a voting command corresponding to the write command is generated, and the voting command is inserted into the voting command queue; then other write commands are sent to other control channels in the controller, And send the voting commands to other control channels in the controller; when receiving the write commands and voting commands sent by other control channels, insert the voting commands sent by other control channels into the voting command queue, and write the write commands sent by other control channels The command is stored in the second buffer area; in each control cycle, check whether the voting command queue meets the preset requirements, and when the voting command queue meets the preset requirements, perform data consistency on multiple write commands in the second buffer area gender vote.
其中,为了解决数据包重复和相似命令的相互干扰问题,以提高系统的可用性,本申请实施例可以通过以下方式增加表决命令的唯一确认方式:每个控制通道基于接收到的写命令中的第二操作变量数据生成与写命令对应的唯一标识信息,将该唯一标识信息作为表决命令。例如,将第二操作变量的地址、数据长度、HMI软件种类及特征码信息转换成16进制,每种信息占4个字节,按顺序排列得到唯一标识信息。Among them, in order to solve the problem of data packet repetition and mutual interference of similar commands to improve the availability of the system, the embodiment of the present application can increase the unique confirmation method of the voting command in the following way: each control channel is based on the first Second, the operation variable data generates unique identification information corresponding to the write command, and uses the unique identification information as a voting command. For example, the address, data length, HMI software type, and feature code information of the second operational variable are converted into hexadecimal, each type of information occupies 4 bytes, and the unique identification information is obtained by arranging in order.
可选地,为了解决数据包延迟和丢失的问题,以提高系统的可用性,可以为每个表决命令预设有效时间段,如设置为2s。在每个控制周期内,每个控制通道检查表决命令队列中的表决命令的数量和状态,在表决命令队列中具有第一数量个表决命令且第一数量个表决命令均处于有效时间段内时,即该控制通道已接收到其他所有控制通道发送的写命令及表决命令,且所有表决命令均未超时,则该控制通道可以对第二缓存区中的第一数量个写命令进行数据一致性表决。Optionally, in order to solve the problem of packet delay and loss and improve the availability of the system, a valid time period can be preset for each voting command, for example, set to 2s. In each control cycle, each control channel checks the number and status of the voting commands in the voting command queue, when there are the first number of voting commands in the voting command queue and the first number of voting commands are within the valid time period , that is, the control channel has received write commands and voting commands sent by all other control channels, and all voting commands have not timed out, then the control channel can perform data consistency on the first number of write commands in the second buffer vote.
可选地,在进行数据一致性表决时,对于每个控制通道,在数据一致的写命令的数量不小于第一预设阈值时,确认表决通过,此时可以将第二操作变量数据写入控制器中的操作变量数据区,并向通讯模块反馈写入成功的第一写入结果;在数据一致的写命令的数量小于预设阈值时,确认表决未通过,丢弃第二操作变量数据,并向通讯模块反馈写入失败的第二写入结果。其中,第一预设阈值可以由用户根据控制通道的数量适应性调整,此处不做具体限定。通过表决可以解决数据包错误问题,防止控制器接收错误的数据。Optionally, when performing data consistency voting, for each control channel, when the number of write commands with consistent data is not less than the first preset threshold, the confirmation vote is passed, and the second operation variable data can be written at this time The operation variable data area in the controller, and feeds back the successful first write result to the communication module; when the number of write commands with consistent data is less than the preset threshold, the confirmation vote is not passed, and the second operation variable data is discarded. And feed back the second writing result of writing failure to the communication module. Wherein, the first preset threshold can be adaptively adjusted by the user according to the number of control channels, which is not specifically limited here. The packet error problem can be solved by voting, preventing the controller from receiving wrong data.
可选地,通讯模块还可以在接收到的写入失败的第二写入结果的数量不小于第二预设阈值时,重新向第二写入结果对应的控制通道发送写命令。其中,第二预设阈值同样可以由用户根据控制通道的数量适应性调整,此处不做具体限定。通过写命令重发的方式可以解决数据包丢失的问题,提高系统的可用性。Optionally, the communication module may also resend the write command to the control channel corresponding to the second write result when the number of received second write results that fail to write is not less than a second preset threshold. Wherein, the second preset threshold can also be adaptively adjusted by the user according to the number of control channels, which is not specifically limited here. The problem of data packet loss can be solved by resending the write command, and the availability of the system can be improved.
在本申请实施例中,通讯模块在每个控制周期内接收来自控制器中的多个控制通道发送的多组第一操作变量数据,并对多组第一操作变量数据进行数据一致性表决,在表决通过时将第一操作变量数据存储至通讯模块中的第一缓存区,之后响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机;同时,通讯模块可以响应于上位机发送的写入第二操作变量数据的写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的多个控制通道,每个控制通道将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果,通讯模块接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机。其中,通过在读写过程引入数据一致性表决处理过程,有效解决了安全控制系统中控制器的多个控制通道读写数据不一致的技术问题。In the embodiment of the present application, the communication module receives multiple sets of first manipulated variable data sent from multiple control channels in the controller in each control cycle, and performs data consistency voting on multiple sets of first manipulated variable data, When the vote is passed, the first operational variable data is stored in the first buffer area in the communication module, and then in response to the read command sent by the host computer for reading the target operational variable data, all the first operational variable data stored in the first buffer area Query the target manipulated variable data in the manipulated variable data, and feed back the target manipulated variable data to the host computer; at the same time, the communication module can respond to the write command sent by the host computer to write the second manipulated variable data, and copy the write command as the first A number of copies, and send the first number of write commands to multiple control channels in the controller, each control channel will copy the received write commands into the first number of copies, save one of the write commands, and send Other write commands are sent to other control channels in the controller respectively, data consistency voting is performed on the write commands saved by itself and the write commands sent by other control channels, and the second operation variable data is written or discarded based on the voting results, and sent to The communication module feeds back the writing results, and the communication module receives the first number of writing results fed back by the first number of control channels, and feeds back the first number of writing results to the host computer. Among them, by introducing the data consistency voting process in the reading and writing process, the technical problem of inconsistent reading and writing data of multiple control channels of the controller in the safety control system is effectively solved.
实施例2Example 2
在实施例1提供的安全控制系统的基础上,本申请实施例提供了一种由通讯模块执行的数据读取方法,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。On the basis of the safety control system provided in Embodiment 1, the embodiment of the present application provides a data reading method executed by the communication module. computer-executable instructions, and, although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in an order different from that shown or described herein.
图2是根据本申请实施例的一种可选的数据读取方法的流程示意图,如图2所示,该方法至少包括步骤S202-S206,其中:Fig. 2 is a schematic flowchart of an optional data reading method according to an embodiment of the present application. As shown in Fig. 2, the method includes at least steps S202-S206, wherein:
步骤S202,在每个控制周期内,接收来自控制器中的第一数量个控制通道发送的第一数量组第一操作变量数据。Step S202, in each control cycle, receive a first quantity of first manipulated variable data sent from a first quantity of control channels in the controller.
其中,控制器中共包括第一数量个控制通道,每个控制通道均会在每个控制周期内将自身的第一操作变量数据发送至通讯模块,该第一操作变量数据中至少包括以下之一:第一操作变量的地址、数据内容、数据长度、对应的HMI软件种类及特征码信息。Wherein, the controller includes a first number of control channels, and each control channel will send its own first manipulated variable data to the communication module in each control cycle, and the first manipulated variable data includes at least one of the following: : The address, data content, data length, corresponding HMI software type and feature code information of the first operational variable.
步骤S204,对第一数量组第一操作变量数据进行数据一致性表决,并在表决通过时,将第一操作变量数据存储至通讯模块中的第一缓存区。Step S204, perform a data consistency vote on the first quantity group of first manipulated variable data, and store the first manipulated variable data in the first buffer area in the communication module when the vote is passed.
为了保证读取的操作变量数据的一致性,通讯模块需要先对获取的第一数量组第一操作变量数据进行数据一致性表决,在表决通过时,即确认各个控制通道的第一操作变量数据一致,此时通讯模块可以将第一操作变量数据存储至第一缓存区内,以方便后续上位机读取对应的操作变量数据。In order to ensure the consistency of the read operation variable data, the communication module needs to vote on the data consistency of the obtained first quantity group first operation variable data first, and confirm the first operation variable data of each control channel when the vote is passed At this point, the communication module can store the first manipulated variable data in the first buffer area, so that the subsequent host computer can read the corresponding manipulated variable data.
作为一种可选的实施方式,在对第一数量组第一操作变量数据进行数据一致性表决之前,通讯模块还可以获取第一数量个控制通道的状态信息;若存在故障控制通道,则禁止故障控制通道发送的第一操作变量数据参与数据一致性表决,避免错误数据的干扰。As an optional implementation, before performing a data consistency vote on the data of the first operational variable of the first quantity group, the communication module can also obtain the status information of the first number of control channels; if there is a faulty control channel, prohibit The first operational variable data sent by the faulty control channel participates in the data consistency vote to avoid the interference of erroneous data.
可选地,若在连续的第二数量个控制周期内的数据一致性表决的结果均为表决未通过,发出第一告警信息,第一告警信息用于提示第一数量个控制通道中的操作变量数据不一致。其中,第二数量可以由用户根据需求自行设置,如设置为3,此处不做具体限定。通过报警方式,能够帮助用户及时发现问题。Optionally, if the results of the data consistency voting in the second consecutive control cycles are all votes failed, a first warning message is issued, and the first warning message is used to prompt the operation in the first number of control channels Variable data is inconsistent. Wherein, the second number can be set by the user according to requirements, for example, it is set to 3, which is not specifically limited here. Through the alarm mode, it can help users find problems in time.
步骤S206,响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机。Step S206, in response to the read command sent by the host computer for reading the target manipulated variable data, query the target manipulated variable data from all the first manipulated variable data stored in the first buffer area, and feed back the target manipulated variable data to PC.
当用户通过上位机的HMI软件读取控制器的目标操作变量数据时,HMI软件向通讯模块发送读命令,通讯模块从第一缓存区中查询目标操作变量数据,并将目标操作变量数据反馈至HMI软件。通过这种方式,HMI软件每次读取控制器的操作变量数据时,仅需要一次查询即可,降低了HMI软件和控制器之间的通讯开销。When the user reads the target operating variable data of the controller through the HMI software of the host computer, the HMI software sends a read command to the communication module, and the communication module queries the target operating variable data from the first buffer area, and feeds back the target operating variable data to HMI software. In this way, each time the HMI software reads the operating variable data of the controller, only one query is required, which reduces the communication overhead between the HMI software and the controller.
在本申请实施例中,通讯模块在每个控制周期内接收来自控制器中的多个控制通道发送的多组第一操作变量数据,并对多组第一操作变量数据进行数据一致性表决,在表决通过时将第一操作变量数据存储至通讯模块中的第一缓存区,之后响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机。其中,通过在读过程引入数据一致性表决处理过程,有效解决了安全控制系统中控制器的多个控制通道读写数据不一致的技术问题。In the embodiment of the present application, the communication module receives multiple sets of first manipulated variable data sent from multiple control channels in the controller in each control cycle, and performs data consistency voting on multiple sets of first manipulated variable data, When the vote is passed, the first operational variable data is stored in the first buffer area in the communication module, and then in response to the read command sent by the host computer for reading the target operational variable data, all the first operational variable data stored in the first buffer area Query the target manipulated variable data in the manipulated variable data, and feed back the target manipulated variable data to the upper computer. Among them, by introducing the data consistency voting process in the reading process, the technical problem of inconsistency in reading and writing data of multiple control channels of the controller in the safety control system is effectively solved.
实施例3Example 3
在实施例1提供的安全控制系统的基础上,本申请实施例还提供了一种由通讯模块执行的数据写入方法,需要说明的是,在附图的流程图示出的步骤同样可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。On the basis of the safety control system provided in Embodiment 1, the embodiment of the present application also provides a data writing method executed by the communication module. It should be noted that the steps shown in the flow chart of the accompanying drawings can also be and, although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in an order different from that shown or described herein.
图3是根据本申请实施例的一种可选的数据写入方法的流程示意图,如图3所示,该方法至少包括步骤S302-S304,其中:FIG. 3 is a schematic flowchart of an optional data writing method according to an embodiment of the present application. As shown in FIG. 3 , the method includes at least steps S302-S304, wherein:
步骤S302,响应于上位机发送的写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的第一数量个控制通道,其中,写命令中包括待写入的第二操作变量数据;每个控制通道用于将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果。Step S302, in response to the write command sent by the host computer, copy the write command into a first number of copies, and send the first number of write commands to the first number of control channels in the controller, wherein the write command includes The second operational variable data to be written; each control channel is used to copy the received write command into the first quantity, save one of the write commands, and send the other write commands to other controllers respectively. The control channel performs data consistency voting on the write commands saved by itself and the write commands sent by other control channels, writes or discards the second operation variable data based on the voting results, and feeds back the writing results to the communication module.
其中,第二操作变量数据中至少包括以下之一:第二操作变量的地址、数据内容、数据长度、对应的HMI软件种类及特征码信息。Wherein, the second operational variable data includes at least one of the following: the address of the second operational variable, data content, data length, corresponding HMI software type, and feature code information.
作为一种可选的实施方式,在将写命令复制为第一数量份之前,通讯模块可以先对写命令中的第二操作变量数据进行数据完整性校验,如进行CRC(Cyclic RedundancyCheck,循环冗余码校验);在校验通过时,将写命令复制为第一数量份;在校验未通过时,发出第二告警信息,第二告警信息用于提示第二操作变量数据不完整,需要重新写入。As an optional implementation, before copying the write command into the first quantity, the communication module can first perform a data integrity check on the second operational variable data in the write command, such as performing a CRC (Cyclic RedundancyCheck, cycle Redundancy code verification); when the verification is passed, the write command is copied to the first quantity; when the verification fails, a second warning message is issued, and the second warning message is used to prompt that the data of the second operating variable is incomplete , needs to be rewritten.
可选地,在将写命令复制为第一数量份之前,通讯模块还可以获取第一数量个控制通道的状态信息;若存在故障控制通道,则禁止向故障控制通道发送复制的写命令,避免后续该故障控制通道发送数据对其他正常控制通道造成干扰。Optionally, before copying the write command into the first number of copies, the communication module can also obtain the status information of the first number of control channels; if there is a faulty control channel, it is forbidden to send duplicated write commands to the faulty control channel to avoid Subsequent data sent by the faulty control channel interferes with other normal control channels.
在通讯模块将第一数量份写命令分别发送至第一数量个控制通道后,作为一种可选的实施方式,每个控制通道会将接收到的写命令复制为第一数量份,将其中一份写命令存储至控制通道中的第二缓存区,并生成与写命令对应的表决命令,将表决命令插入表决命令队列;然后将其他份写命令分别发送至控制器中的其他控制通道,并将表决命令发送至控制器中的其他控制通道;在接收到其他控制通道发送的写命令以及表决命令时,将其他控制通道发送的表决命令插入表决命令队列,并将其他控制通道发送的写命令存储至第二缓存区;在每个控制周期内,检查表决命令队列是否满足预设要求,并在表决命令队列满足预设要求时,对第二缓存区中的多个写命令进行数据一致性表决。After the communication module sends the first number of write commands to the first number of control channels, as an optional implementation, each control channel will copy the received write command into the first number of copies, and the A write command is stored in the second buffer area in the control channel, and a voting command corresponding to the write command is generated, and the voting command is inserted into the voting command queue; then other write commands are sent to other control channels in the controller, And send the voting commands to other control channels in the controller; when receiving the write commands and voting commands sent by other control channels, insert the voting commands sent by other control channels into the voting command queue, and write the write commands sent by other control channels The command is stored in the second buffer area; in each control cycle, check whether the voting command queue meets the preset requirements, and when the voting command queue meets the preset requirements, perform data consistency on multiple write commands in the second buffer area gender vote.
其中,为了解决数据包重复和相似命令的相互干扰问题,以提高系统的可用性,本申请实施例可以通过以下方式增加表决命令的唯一确认方式:每个控制通道基于接收到的写命令中的第二操作变量数据生成与写命令对应的唯一标识信息,将该唯一标识信息作为表决命令。例如,将第二操作变量的地址、数据长度、HMI软件种类及特征码信息转换成16进制,每种信息占4个字节,按顺序排列得到唯一标识信息。Among them, in order to solve the problem of data packet repetition and mutual interference of similar commands to improve the availability of the system, the embodiment of the present application can increase the unique confirmation method of the voting command in the following way: each control channel is based on the first Second, the operation variable data generates unique identification information corresponding to the write command, and uses the unique identification information as a voting command. For example, the address, data length, HMI software type, and feature code information of the second operational variable are converted into hexadecimal, each type of information occupies 4 bytes, and the unique identification information is obtained by arranging in order.
可选地,为了解决数据包延迟和丢失的问题,以提高系统的可用性,可以为每个表决命令预设有效时间段,如设置为2s。在每个控制周期内,每个控制通道检查表决命令队列中的表决命令的数量和状态,在表决命令队列中具有第一数量个表决命令且第一数量个表决命令均处于有效时间段内时,即该控制通道已接收到其他所有控制通道发送的写命令及表决命令,且所有表决命令均未超时,则该控制通道可以对第二缓存区中的第一数量个写命令进行数据一致性表决。Optionally, in order to solve the problem of packet delay and loss and improve the availability of the system, a valid time period can be preset for each voting command, for example, set to 2s. In each control cycle, each control channel checks the number and status of the voting commands in the voting command queue, when there are the first number of voting commands in the voting command queue and the first number of voting commands are within the valid time period , that is, the control channel has received write commands and voting commands sent by all other control channels, and all voting commands have not timed out, then the control channel can perform data consistency on the first number of write commands in the second buffer vote.
可选地,在进行数据一致性表决时,对于每个控制通道,在数据一致的写命令的数量不小于第一预设阈值时,确认表决通过,此时可以将第二操作变量数据写入控制器中的操作变量数据区,并向通讯模块反馈写入成功的第一写入结果;在数据一致的写命令的数量小于预设阈值时,确认表决未通过,丢弃第二操作变量数据,并向通讯模块反馈写入失败的第二写入结果。其中,第一预设阈值可以由用户根据控制通道的数量适应性调整,此处不做具体限定。通过表决可以解决数据包错误问题,防止控制器接收错误的数据。Optionally, when performing data consistency voting, for each control channel, when the number of write commands with consistent data is not less than the first preset threshold, the confirmation vote is passed, and the second operation variable data can be written at this time The operation variable data area in the controller, and feeds back the successful first write result to the communication module; when the number of write commands with consistent data is less than the preset threshold, the confirmation vote is not passed, and the second operation variable data is discarded. And feed back the second writing result of writing failure to the communication module. Wherein, the first preset threshold can be adaptively adjusted by the user according to the number of control channels, which is not specifically limited here. The packet error problem can be solved by voting, preventing the controller from receiving wrong data.
步骤S304,接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机。Step S304, receiving the first number of writing results fed back by the first number of control channels, and feeding back the first number of writing results to the host computer.
可选地,通讯模块还可以在接收到的写入失败的第二写入结果的数量不小于第二预设阈值时,重新向第二写入结果对应的控制通道发送写命令。其中,第二预设阈值同样可以由用户根据控制通道的数量适应性调整,此处不做具体限定。通过写命令重发的方式可以解决数据包丢失的问题,提高系统的可用性。Optionally, the communication module may also resend the write command to the control channel corresponding to the second write result when the number of received second write results that fail to write is not less than a second preset threshold. Wherein, the second preset threshold can also be adaptively adjusted by the user according to the number of control channels, which is not specifically limited here. The problem of data packet loss can be solved by resending the write command, and the availability of the system can be improved.
在本申请实施例中,通讯模块可以响应于上位机发送的写入第二操作变量数据的写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的多个控制通道,每个控制通道将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果,通讯模块接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机。其中,通过在写过程引入数据一致性表决处理过程,有效解决了安全控制系统中控制器的多个控制通道读写数据不一致的技术问题。In the embodiment of the present application, the communication module may respond to the write command sent by the host computer to write the second manipulated variable data, copy the write command into the first number of copies, and send the first number of write commands to the controller respectively Multiple control channels in the control channel, each control channel copies the received write command into the first number of copies, saves one copy of the write command, and sends the other copies of the write command to other control channels in the controller, for itself The stored write command and the write command sent by other control channels are voted on for data consistency, and the second operation variable data is written or discarded based on the voting result, and the write result is fed back to the communication module, and the communication module receives the feedback of the first number of control channels The first number of write results, and feed back the first number of write results to the host computer. Among them, by introducing the data consistency voting process in the writing process, the technical problem of inconsistency in reading and writing data of multiple control channels of the controller in the safety control system is effectively solved.
实施例4Example 4
根据本申请实施例,还提供了一种非易失性存储介质,该非易失性存储介质包括存储的程序,其中,非易失性存储介质所在设备通过运行该程序执行实施例2中的数据读取方法或实施例3中的数据写入方法。According to an embodiment of the present application, a non-volatile storage medium is also provided, the non-volatile storage medium includes a stored program, wherein the device where the non-volatile storage medium is located executes the program in Embodiment 2 by running the program. The data reading method or the data writing method in Embodiment 3.
根据本申请实施例,还提供了一种处理器,该处理器用于运行程序,其中,程序运行时执行实施例2中的数据读取方法或实施例3中的数据写入方法。According to an embodiment of the present application, a processor is also provided, and the processor is used to run a program, wherein the data reading method in Embodiment 2 or the data writing method in Embodiment 3 is executed when the program is running.
根据本申请实施例,还提供了一种电子设备,该电子设备包括:存储器和处理器,其中,存储器中存储有计算机程序,处理器被配置为通过计算机程序执行实施例2中的数据读取方法或实施例3中的数据写入方法。According to an embodiment of the present application, there is also provided an electronic device, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the data reading in Embodiment 2 through the computer program method or the data writing method in Embodiment 3.
可选地,程序运行时执行实现以下步骤:在每个控制周期内,接收来自控制器中的第一数量个控制通道发送的第一数量组第一操作变量数据;对第一数量组第一操作变量数据进行数据一致性表决,并在表决通过时,将第一操作变量数据存储至通讯模块中的第一缓存区;响应于上位机发送的用于读取目标操作变量数据的读命令,从第一缓存区中存储的所有第一操作变量数据中查询目标操作变量数据,并将目标操作变量数据反馈至上位机。Optionally, when the program is running, the following steps are executed: within each control cycle, receiving a first quantity of first manipulated variable data sent from a first number of control channels in the controller; Data consistency voting is performed on the manipulated variable data, and when the vote is passed, the first manipulated variable data is stored in the first buffer area in the communication module; in response to the read command sent by the host computer for reading the target manipulated variable data, Query the target manipulated variable data from all the first manipulated variable data stored in the first buffer area, and feed back the target manipulated variable data to the host computer.
可选地,程序运行时执行实现以下步骤:响应于上位机发送的写命令,将写命令复制为第一数量份,并将第一数量份写命令分别发送至控制器中的第一数量个控制通道,其中,写命令中包括待写入的第二操作变量数据;每个控制通道用于将接收到的写命令复制为第一数量份,保存其中一份写命令,并将其他份写命令分别发送至控制器中的其他控制通道,对自身保存的写命令以及其他控制通道发送的写命令进行数据一致性表决,基于表决结果写入或丢弃第二操作变量数据,并向通讯模块反馈写入结果;接收第一数量个控制通道反馈的第一数量个写入结果,并将第一数量个写入结果反馈至上位机。Optionally, the following steps are executed when the program is running: in response to the write command sent by the host computer, copy the write command into a first number of copies, and send the first number of write commands to the first number of controllers respectively The control channel, wherein the write command includes the second operation variable data to be written; each control channel is used to copy the received write command into the first number of copies, save one of the write commands, and write the other copies The commands are sent to other control channels in the controller respectively, and the data consistency voting is performed on the write commands saved by itself and the write commands sent by other control channels, and the second operation variable data is written or discarded based on the voting results, and feedback to the communication module Writing results: receiving the first number of writing results fed back by the first number of control channels, and feeding back the first number of writing results to the host computer.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present application are for description only, and do not represent the advantages and disadvantages of the embodiments.
在本申请的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present application, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如单元的划分,可以为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed technical content can be realized in other ways. Wherein, the device embodiments described above are only illustrative. For example, the division of units can be a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into Another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of units or modules may be in electrical or other forms.
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。A unit described as a separate component may or may not be physically separated, and a component shown as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed over multiple units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods in the various embodiments of the present application. The aforementioned storage media include: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes. .
以上仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。The above are only the preferred embodiments of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the application, some improvements and modifications can also be made, and these improvements and modifications should also be considered as For the scope of protection of this application.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211303467.4ACN115437576A (en) | 2022-10-24 | 2022-10-24 | Data reading method, data writing method and safety control system |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211303467.4ACN115437576A (en) | 2022-10-24 | 2022-10-24 | Data reading method, data writing method and safety control system |
| Publication Number | Publication Date |
|---|---|
| CN115437576Atrue CN115437576A (en) | 2022-12-06 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202211303467.4APendingCN115437576A (en) | 2022-10-24 | 2022-10-24 | Data reading method, data writing method and safety control system |
| Country | Link |
|---|---|
| CN (1) | CN115437576A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103092778A (en)* | 2013-01-23 | 2013-05-08 | 浪潮(北京)电子信息产业有限公司 | Cache mirroring method for memory system |
| CN111552172A (en)* | 2020-04-27 | 2020-08-18 | 浙江中控技术股份有限公司 | Data processing method and device, storage medium and electronic equipment |
| CN113782071A (en)* | 2020-06-09 | 2021-12-10 | 三星电子株式会社 | System and method for processing input/output requests |
| CN114556283A (en)* | 2019-11-13 | 2022-05-27 | 华为技术有限公司 | Method and device for data writing, consistency checking and reading |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103092778A (en)* | 2013-01-23 | 2013-05-08 | 浪潮(北京)电子信息产业有限公司 | Cache mirroring method for memory system |
| CN114556283A (en)* | 2019-11-13 | 2022-05-27 | 华为技术有限公司 | Method and device for data writing, consistency checking and reading |
| CN111552172A (en)* | 2020-04-27 | 2020-08-18 | 浙江中控技术股份有限公司 | Data processing method and device, storage medium and electronic equipment |
| CN113782071A (en)* | 2020-06-09 | 2021-12-10 | 三星电子株式会社 | System and method for processing input/output requests |
| Publication | Publication Date | Title |
|---|---|---|
| US7478274B2 (en) | Duplex system | |
| JPH02287858A (en) | Distributed processing system restart method | |
| CN102096615A (en) | Remote incremental backup method and system | |
| WO2020232859A1 (en) | Distributed storage system, data writing method, device, and storage medium | |
| US8504786B2 (en) | Method and apparatus for backing up storage system data | |
| CN102025758B (en) | Method, device and system for recovering data copy in distributed system | |
| CN115437576A (en) | Data reading method, data writing method and safety control system | |
| CN112072620B (en) | A relay protection outlet method using a relay protection device | |
| CN114281589A (en) | Exception handling method and device and cluster system | |
| JP2012133456A (en) | Storage device and control method of storage device | |
| CN116932275B (en) | Data scrubbing control method, DDR controller and system on chip | |
| CN115617587A (en) | Firmware testing method, device, equipment and medium for solid state disk | |
| CN115729477A (en) | Distributed storage IO path data writing and reading method, device and equipment | |
| CN116186661A (en) | Method for summarizing service data, service data summarizing device and storage medium | |
| CN112181705A (en) | Management storage control method based on multiple controllers and storage equipment | |
| CN110515778B (en) | Method, device and system for data protection based on shared logical volume | |
| CN112463669B (en) | A storage arbitration management method, system, terminal and storage medium | |
| CN114880152B (en) | Data three-party disaster recovery abnormal monitoring and processing method, system, terminal and storage medium | |
| CN102541699B (en) | Failover information management device, failover control method and storage processing device | |
| US20250044954A1 (en) | Storage Apparatus and Data Processing Method | |
| CN113568710B (en) | High availability realization method, device and equipment for virtual machine | |
| CN110647526B (en) | Batch data processing method, device, computer equipment and storage medium | |
| KR100389835B1 (en) | Apparatus and method for recovering the error of connection management data in host digital terminal of fiber loop carrier system | |
| CN118337723A (en) | Burst data transmission method and device | |
| CN119576375A (en) | Software upgrade method, device, host computer and system for battery management unit |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| CB02 | Change of applicant information | ||
| CB02 | Change of applicant information | Country or region after:China Address after:No. 309 Liuhe Road, Binjiang District, Hangzhou City, Zhejiang Province (High tech Zone) Applicant after:Zhongkong Technology Co.,Ltd. Address before:No. six, No. 309, Binjiang District Road, Hangzhou, Zhejiang Applicant before:ZHEJIANG SUPCON TECHNOLOGY Co.,Ltd. Country or region before:China |