一种集散控制系统中设备软件兼容加载的方法及装置 技术领域 Method and device for compatible loading of equipment software in distributed control system
本发明涉及一种适用于集散控制系统的软件版本控制方法及装置,使同一 个软件版本能够兼容于不同的硬件平台,特别是涉及通讯领域的软件版本集散 控制, 使具有相同或不同功能的各种硬件平台只使用一个相同的软件版本即可 完成功能。 背景技术 The invention relates to a software version control method and device suitable for a distributed control system, so that the same software version can be compatible with different hardware platforms, in particular, a software version distributed control related to the communication field, so that each has the same or different functions A hardware platform can be completed using only one and the same software version. Background technique
目前,集散控制系统广泛应用于社会生活的各个方面,工业自动化,监控, 通讯等都有大量的使用, 随着计算机控制和嵌入式系统的发展, 目前在集散控 制系统中使用软件进行设备控制已经成为主流。 At present, distributed control systems are widely used in all aspects of social life. Industrial automation, monitoring, communication, etc. are widely used. With the development of computer control and embedded systems, software control has been used in distributed control systems. Become the mainstream.
在一个集散控制系统中, 一个中心设备往往要控制很多外围设备,而具有 同样或不同功能的外围设备可能有多种不同的硬件实现方式,因而需要不同的 软件版本进行控制。 、 在目前的技术中, 一般使用不同的软件版本对应不同的硬件设备进行控 制,如果硬件发生了改变,往往不能通过简单的软件修改实现多种硬件的兼容, 这就需要相应增加一个新的软件版本进行控制,这样, 随着系统中设备种类越 来越多, 需要控制的软件版本也越来越多, 系统的控制关系也越来越复杂。. 本方法提出了一种使用同一软件版本对不同硬件设备进行兼容控制的方 法, 降低了中心设备软件的控制复杂度, 提高了设备的通用性和兼容性, 对于 解决具有相同功能而硬件实现不同的设备兼容性问题有独特的优势。 发明公开 In a distributed control system, a central device often has to control many peripheral devices, while peripheral devices with the same or different functions may have different hardware implementations, and thus require different software versions for control. In the current technology, different software versions are generally used to control different hardware devices. If the hardware changes, it is often impossible to implement multiple hardware compatibility through simple software modification, which requires a new software to be added accordingly. The version is controlled. In this way, as more and more types of devices are in the system, more and more software versions need to be controlled, and the control relationship of the system becomes more and more complicated. The method proposes a method for controlling the compatibility of different hardware devices by using the same software version, which reduces the control complexity of the central device software, improves the versatility and compatibility of the device, and has different hardware implementations for solving the same function. The device compatibility issue has unique advantages. Invention disclosure
本发明所要解决的技术问题是提供一种集散控制系统中设备软件兼容加 载的方法及装置, 克服现有集散控制系统中,对逻辑功能相似而物理实现不同 的外围子模块要使用不同的软件版本进行控制的缺点,解决现有技术中存在的 不同硬件实现的软件版本兼容困难的问题。 The technical problem to be solved by the present invention is to provide a method and device for compatible loading of device software in a distributed control system, and to overcome the existing distributed control system, different software versions are required for peripheral sub-modules with different logical functions and different physical implementations. The disadvantage of performing control is to solve the problem that the software versions of different hardware implementations existing in the prior art are difficult to be compatible.
为达到上述目的,本发明提供了一种集散控制系统中设备软件兼容加载的 方法, 其特点在于, 将支持多种硬件的不同子文件合并到一个文件中, 并在文
件开头写入子文件信息,标识出各子文件的查询方法并根据硬件的需求选择所 述子文件。 In order to achieve the above object, the present invention provides a method for compatible loading of device software in a distributed control system, which is characterized in that different sub-files supporting multiple hardwares are combined into one file, and The sub-file information is written at the beginning of the piece, the query method of each sub-file is identified, and the sub-file is selected according to the requirements of the hardware.
上述的方法, 其特点在于, 进一步包括如下步骤: 步骤一, 从文件头中读 出文件信息的个数; 步骤二, 逐个检查文件信息, 提取需要的子文件的版本类 型和版本号; 步骤三, 根据文件信息索引出子文件所在的子文件块; 步骤四, 使用该子文件做为运行文件。 The above method is characterized in that the method further includes the following steps: Step 1: Read the number of file information from the file header; Step 2, check the file information one by one, and extract the version type and version number of the required subfile; Step 3 According to the file information, the sub-file block in which the sub-file is located is indexed; Step 4, the sub-file is used as the running file.
上述的方法, 其特点在于, 所述文件头中包含了文件标识、 文件长度、 子 文件信息个数和文件头校验; 文件标识是一个魔数, 用来代表文件的类别, 以 快速判断文件格式; 文件长度等于整个软件版本文件的长度; 子文件信息个数 用来说明当前的文件中含有的子文件的数目;文件信息校验用于校验整个文件 头以及所有文件信息的数据是否正确。 The above method is characterized in that: the file header includes a file identifier, a file length, a number of sub-file information, and a file header check; the file identifier is a magic number, which is used to represent a file category, to quickly determine the file. Format; file length is equal to the length of the entire software version file; the number of subfile information is used to indicate the number of subfiles contained in the current file; the file information check is used to verify that the data of the entire file header and all file information is correct. .
上述的方法, 其特点在于, 所述子文件信息中包括: 版本类型、 版本号、 子文件起始地址、 子文件块长度、 子文件块校验; 版本类型是一个判别信息, 代表子文件对应支持的硬件类型,通过判别版本类型与硬件类型是否相符, 以 得到当前硬件需要的子文件块; 版本号用于版本管理及判别该子文件是否匹 配; 子文件起始地址用以给出子文件块在整个文件中的偏移地址; 子文件块长 度是一个子文件信息所表示的子文件块的长度;子文件块校验是一个子文件信 息所表示的子文件块的校验。 The above method is characterized in that: the sub-file information includes: a version type, a version number, a sub-file start address, a sub-file block length, and a sub-file block check; the version type is a discriminating information, and represents a sub-file corresponding Supported hardware type, by judging whether the version type matches the hardware type, to obtain the sub-file block required by the current hardware; the version number is used for version management and discriminating whether the sub-file matches; the sub-file start address is used to give the sub-file The offset address of the block in the entire file; the subfile block length is the length of the subfile block represented by the subfile information; the subfile block check is the check of the subfile block represented by the subfile information.
上述的方法, 其特点在于, 在所述步骤三进一步包括: 通过从当前的子文 件信息提取出子文件块的起始偏移地址, 读出整个子文件块。 The above method is characterized in that, in the step 3, the method further comprises: reading out the entire sub-file block by extracting a starting offset address of the sub-file block from the current sub-file information.
上述的方法, 其特点在于,在所述步骤四是通过将所述子文件块另生成一 个单独版本文件来使用该子文件。 The above method is characterized in that in the step four, the subfile is used by generating a separate version file of the subfile block.
上述的方法, 其特点在于,在所述步骤四是通过直接从文件中提取该子文 件块来使用该子文件。 The above method is characterized in that the sub-file is used in the step four by extracting the sub-file block directly from the file.
上述的方法, 其特点在于, 在所述步骤一中还包括版本文件头的校验提取 流程: The above method is characterized in that, in the step 1, the verification extraction process of the version file header is further included:
步骤 a,判别文件标志, 符合要求则执行步骤 b, 否则执行步骤 f ; Step a, discriminate the file mark, if the requirements are met, perform step b, otherwise perform step f;
步骤 b,读取子文件信息个数; Step b, reading the number of sub-file information;
步骤 c,计算文件信息长度; Step c, calculating the length of the file information;
步骤 d,计算文件信息校验;
步骤 e,判别校验是否正确, 是则执行步骤 g, 否则执行步骤 f; Step d, calculating file information verification; Step e, determining whether the verification is correct, if yes, executing step g, otherwise performing step f;
步骤 f,进行异常处理; Step f, performing exception processing;
步骤 g,本流程结束。 Step g, the process ends.
上述的方法, 其特点在于, 所述生成单独版本文件包括如下步骤: 步骤 A,获得下级设备的硬件类型; The foregoing method is characterized in that: the generating a separate version file includes the following steps: Step A: obtaining a hardware type of the lower level device;
步骤 B,取得适合下级设备的子文件块; Step B: Obtain a sub-file block suitable for the subordinate device;
步骤 C,将该子文件块做为一个单独的软件版本下发。 In step C, the sub-file block is delivered as a separate software version.
本发明的技术效果在于: 采用本发明所述方法, 与现有技术相比, 在软件 的兼容性上取得非常大的进步, 以往在做同一软件兼容于多个硬件设备时, 由 于受硬件设备的限制, 软件兼容所能达到的设计目的非常有限, 一旦硬件差异 过大, 就有可能无法兼容, 而本方法几乎完全避开了硬件差异的问题, 可以兼 容差异极大的硬件设备, 在系统软硬件的设计上获达很大的自由度,起到了简 化复杂系统的效果, 节省了大量的开发人力物力, 替客户节约了设备投资, 延 长了老设备的使用寿命, 提高了系统控制的灵活性。 附图简要说明 The technical effect of the present invention is that: according to the method of the present invention, compared with the prior art, great progress is made in software compatibility, and in the past, when the same software is compatible with multiple hardware devices, due to hardware devices The limitation of the software compatibility is very limited. Once the hardware difference is too large, it may not be compatible. This method almost completely avoids the hardware difference problem and can be compatible with the extremely different hardware devices. The software and hardware design has achieved a great degree of freedom, which has the effect of simplifying complex systems, saving a lot of development manpower and material resources, saving equipment investment for customers, extending the service life of old equipment, and improving the flexibility of system control. Sex. BRIEF DESCRIPTION OF THE DRAWINGS
图 1 是版本文件头的校验提取流程; Figure 1 is the verification extraction process of the version file header;
图 2 是子文件信息索引流程; Figure 2 is a sub-file information indexing process;
图 3 是子文件块提取流程; Figure 3 is a sub-file block extraction process;
图 4是上级控制设备对下级设备进行软件加载的流程; FIG. 4 is a flowchart of software loading of a lower-level device by a superior control device;
图 5是硬件设备选择性使用子文件块的流程; Figure 5 is a flow diagram of a hardware device selectively using a subfile block;
图 6是本发明方法的步骤流程图。 实现本发明的最佳方式 Figure 6 is a flow chart of the steps of the method of the present invention. The best way to implement the invention
下面结合附图对技术方案的实施作进一步的详细描述: The implementation of the technical solution will be further described in detail below with reference to the accompanying drawings:
本发明所述的软件版本兼容于不同硬件的方法如下: The software version of the present invention is compatible with different hardware methods as follows:
方法实现的核心是,一个软件版本支持多种硬件, 实际上是将多个文件合 并到一个文件中, 并在文件开头写入文件信息,标识出支持各种不同硬件的软 件子文件的查询方法。 整个软件版本文件的格式如下所示 The core of the method implementation is that a software version supports multiple hardwares. In fact, multiple files are merged into one file, and file information is written at the beginning of the file to identify the query method for software sub-files supporting various hardware. . The format of the entire software version file is as follows
文件头 子文件信 * 子文件信息 子文件 子文件
File header file letter* subfile information subfile subfile
图 6是本发明方法的步骤流程图, 包括如下步骤: Figure 6 is a flow chart of the steps of the method of the present invention, comprising the following steps:
步骤 601从文件头中读出文件信息的个数。 Step 601 reads the number of file information from the file header.
文件头 File header
在一个文件头中包含了文件标识, 文件长度, 子文件信息个数, 文件头校 验几部分。 其中: The file identifier, the file length, the number of subfile information, and the file header check are included in a file header. among them:
文件标识是一个特定的魔数 (Magic numbers , 魔数指二进制文件开头处的 一串数字), 特指文件的类别, 用于快速判断文件格式。 The file identifier is a specific magic number (Magic numbers, which refers to a string of numbers at the beginning of the binary file), especially the category of the file, used to quickly determine the file format.
文件长度等于整个软件版本文件的长度。 The file length is equal to the length of the entire software version file.
子文件信息个数说明当前的文件中含有的子文件的数目。 The number of subfile information indicates the number of subfiles contained in the current file.
文件信息校验用于校验整个文件头以及从文件信息 1到子文件信息 N范围 内的数据是否正确。 The file information check is used to verify the entire header and whether the data in the range from file information 1 to subfile information N is correct.
从文件头中, 可以索引到子文件的个数, 并校验文件头是否正确。 From the header, you can index the number of subfiles and verify that the header is correct.
步骤 602逐个检查文件信息, 提取需要的版本类型和版本号。 Step 602 checks the file information one by one, and extracts the required version type and version number.
子文件信息
确认文件头正确后, 便可以对所有的子文件信息进行扫描, 子文件信息中 包括了如下信息: Subfile information After confirming that the file header is correct, all sub-file information can be scanned. The sub-file information includes the following information:
版本类型 Version type
版本号 version number
子文件起始地址 Subfile start address
子文件块长度 Subfile block length
子文件块校验 Subfile block check
版本类型是一个主要的判别信息, 它代表了该子文件支持的硬件类型,通 过判别版本类型与硬件类型是否相符, 就可以得到当前硬件需要的子文件块。 The version type is a main discriminating information, which represents the type of hardware supported by the subfile. By judging whether the version type matches the hardware type, the subfile block required by the current hardware can be obtained.
版本号主要用于版本管理, 可以判别这个该软件是否与其他软件齐套。
子文件起始地址给出了子文件块在整个文件中的偏移地址。 The version number is mainly used for version management, and it can be determined whether the software is integrated with other software. The subfile start address gives the offset address of the subfile block in the entire file.
子文件块长度是指一个子文件信息所表示的子文件块的长度。 The subfile block length refers to the length of the subfile block represented by one subfile information.
子文件块校验是指一个子文件信息所表示的子文件块的校验。 Subfile block check refers to the check of a subfile block represented by a subfile information.
这样,通过对文件子信息的扫描, 就可以找出与当前硬件对应的子文件信 息, 通过该子文件信息, 就可以找到文件块了。 In this way, by scanning the file sub-information, the sub-file information corresponding to the current hardware can be found, and the file block can be found by the sub-file information.
步骤 603 根据文件信息索引出子文件块。 Step 603 indexes the subfile block according to the file information.
获取了当前的子文件信息后,可以提取出子文件块在在软件版本中的起始 偏移地址, 读出整个子文件块, 并进行子文件块校验。 After the current sub-file information is obtained, the starting offset address of the sub-file block in the software version can be extracted, the entire sub-file block is read, and the sub-file block check is performed.
步骤 604使用该子文件块为本板运行软件。 Step 604 uses the sub-file block to run the software for the board.
在取得该子文件块后, 可以将该子文件块另生成一个单独版本文件, 或者 只是在需要使用该子文件块时再从文件中提取。 After the sub-file block is obtained, the sub-file block can be additionally generated as a separate version file, or only extracted from the file when the sub-file block needs to be used.
图 1 是版本文件头的校验提取流程, 包括: Figure 1 shows the verification extraction process of the version file header, including:
步骤 101 : 判别文件标志, 符合要求则执行步骤 102, 否则执行步骤 106; 步骤 102: 读取子文件信息个数; Step 101: Identify the file identifier, if yes, go to step 102, otherwise go to step 106; Step 102: Read the number of sub-file information;
步骤 103 : 计算文件信息长度; Step 103: Calculate the length of the file information;
步骤 104: 计算文件信息校验; ' 步骤 105: 判别校验是否正确, 是则执行步骤 107, 否则执行步骤 106; 步骤 106 : 进行异常处理; Step 104: Calculate the file information check; 'Step 105: Determine whether the check is correct, if yes, go to step 107, otherwise go to step 106; Step 106: Perform exception handling;
步骤 107 : 进入下一流程。 Step 107: Go to the next process.
版本文件头必需经过校验确定数据无错后, 方能有效, 文件头中的校验是 整个文件头和所有子文件信息的校验。文件头通过校验后, 提取出子文件信息 个数, 做为索引子文件信息的范围。 The version file header must be verified to verify that the data is error-free before it can be valid. The check in the file header is the verification of the entire file header and all sub-file information. After the file header is verified, the number of subfile information is extracted as the range of the index subfile information.
图 2 是子文件信息索引流程; 包括: Figure 2 is a sub-file information indexing process;
步骤 201 : 当前子文件信息索引置零; Step 201: The current sub-file information index is set to zero;
步骤 202: 判断文件版本类型是否与硬件匹配, 是则执行步骤 206, 否则 执行步骤 203 ; Step 202: Determine whether the file version type matches the hardware, if yes, go to step 206, otherwise go to step 203;
步骤 203 : 当前子文件信息索引加一; Step 203: The current sub-file information index is incremented by one;
步骤 204: 判断当前子文件信息索引是否为最大, 是则执行步骤 205, 否. 则返回步骤 202; Step 204: Determine whether the current sub-file information index is the maximum, if yes, go to step 205, no. Return to step 202;
步骤 205: 进行异常处理;
步骤 206 : 提取当前子文件信息并保存; Step 205: Perform exception processing. Step 206: Extract current sub-file information and save it;
步骤 207 : 进入下一流程. Step 207: Go to the next process.
图 2流程是图 1流程的继续, 子文件信息索引流程中需要用到图 1流程中 读取到的子文件信息个数, 做为子文件信息索引的最大值。流程遍历所有的子 文件信息, 直到找到所需子文件信息为止。 The flow of Figure 2 is the continuation of the flow of Figure 1. The sub-file information indexing process needs to use the number of sub-file information read in the process of Figure 1, as the maximum value of the sub-file information index. The process iterates through all the subfile information until it finds the required subfile information.
图 3 是子文件块提取流程, 包括- 步骤 301 : 取得文件信息; Figure 3 is a sub-file block extraction process, including - step 301: obtaining file information;
步骤 302 : 读出子文件块起始地址; Step 302: Read a sub-file block start address;
步骤 303 : 读出子文件块长度; Step 303: Read the sub-file block length;
步骤 304: 计算子文件块并校验; Step 304: Calculate the subfile block and verify;
步骤 305 : 判断计算的校验与子文件信息中存放的是否相等, 是则执行步 骤 307, 否则执行步骤 306 ; Step 305: Determine whether the calculated checksum is equal to the stored in the subfile information, if yes, go to step 307, otherwise go to step 306;
步骤 306 : 异常处理; Step 306: exception handling;
步骤 307 : 读出整个子文件块; Step 307: Read out the entire subfile block;
步骤 308 : 结束。 Step 308: End.
图 3流程紧接图 2流程, 图 2流程中获取的当前子文件信息是图 3流程的 入口参数。流程通过当前子文件信息取得子文件块的偏移和长度, 并计算文件 块的校验。 提取出的子文件块就是可用的目标数据了。 The flow of Figure 3 is next to the flow of Figure 2, and the current sub-file information obtained in the process of Figure 2 is the entry parameter of the process of Figure 3. The process obtains the offset and length of the subfile block from the current subfile information, and calculates the checksum of the file block. The extracted subfile block is the available target data.
本说明书提供两种常用的实施方案。 This specification provides two common implementations.
实施方案一, 上级控制设备对下级设备的选择性软件加载: Embodiment 1, the selective software loading of the superior control device to the lower device:
如图 4所示, 是上级控制设备对下级设备进行软件加载的流程, 包括: 步骤 401 : 获得下级设备的硬件类型; As shown in FIG. 4, the process of software loading the lower-level device by the upper-level control device includes: Step 401: Obtain a hardware type of the lower-level device;
步骤 402 : 取得适合下级设备的子文件块; Step 402: Obtain a sub-file block suitable for the subordinate device;
步骤 403 : 将该子文件块做为一个单独的软件版本下发。 Step 403: The sub-file block is delivered as a separate software version.
在上级控制设备对下级设备进行软件加载时, 上级控制设备可不将全部的 软件版本加载到下级设备,而只需将适应下级设备需要的子文件块重构成一个 新的软件版本后,直接加载到下级设备,这样做的好处是可以节省下级设备的 存储资源。 When the upper-level control device performs software loading on the lower-level device, the upper-level control device may not load all the software versions to the lower-level device, but only need to reconfigure the sub-file blocks needed for the lower-level device to form a new software version, and then directly load the The lower-level device has the advantage of saving storage resources of the lower-level device.
实施方案二, 硬件设备选择性使用子文件块: In the second embodiment, the hardware device selectively uses the subfile block:
图 5所示是硬件设备选择性使用子文件块的流程, 包括:
步骤 501 : 从版本文件中提取子文件块; Figure 5 shows the flow of selective use of subfile blocks by hardware devices, including: Step 501: Extract a subfile block from the version file.
步骤 502: 使用该子文件块。 Step 502: Use the subfile block.
硬件设备将整个软件版本都下载到设备的存储装置中, 然后根据当前硬件 类型, 确定提取的子文件块, 并使用该子文件块。 The hardware device downloads the entire software version to the storage device of the device, and then determines the extracted sub-file block according to the current hardware type, and uses the sub-file block.
这两种实施方案的区别, 实际上是在不同的设备上提取子文件块,第一中 实施是在上级控制设备提取子文件块, 而第二中实施是在本设备提取子文件 块。 The difference between the two implementations is actually to extract the sub-file blocks on different devices. The first implementation is to extract the sub-file blocks at the superior control device, and the second implementation is to extract the sub-file blocks at the device.
为了更好地实现上述目的,本发明还提供了一种集散控制系统, 包括一设 备软件兼容加载模块, 其中, 所述设备软件兼容加载模块, 用于将支持多种硬 件的不同子文件合并到一个文件中, 并在文件开头写入子文件信息,标识出各 子文件的查询方法并根据硬件的需求选择所述子文件。 In order to achieve the above object, the present invention further provides a distributed control system, including a device software compatible loading module, wherein the device software is compatible with a loading module, and is used to merge different sub-files supporting multiple hardware into In a file, and write sub-file information at the beginning of the file, identify the query method of each sub-file and select the sub-file according to the requirements of the hardware.
本文所述的集散控制系统软件兼容方案是一种功能很强的软件兼容方案, 对于在复杂系统中简化系统结构, 提高系统兼容性都有非常重要的作用。 The distributed control system software compatibility scheme described in this paper is a very powerful software compatibility scheme, which plays an important role in simplifying the system structure and improving system compatibility in complex systems.
以上仅为本发明的具体实施例, 不应被视为是对本发明范围的限制。本发 明还可有其他多种实施例,在不背离本发明精神及其实质的情况下,任何等效 变化与修改都应属于发明所附的权利要求的保护范围。 工业应用性 The above are only specific embodiments of the invention and should not be construed as limiting the scope of the invention. The invention may be embodied in a variety of other embodiments without departing from the spirit and scope of the invention. Industrial applicability
本发明解决了硬件差异的问题, 可以兼容差异极大的硬件设备,在系统软 硬件的设计上获达很大的自由度,起到了简化复杂系统的效果,节省了大量的 开发人力物力, 替客户节约了设备投资, 延长了老设备的使用寿命, 提高了系 统控制的灵活性。 本发明可在社会生活的各个方面, 工业自动化, 监控, 通讯 等方面得到广泛应用。
The invention solves the problem of hardware difference, can be compatible with the hardware device with great difference, obtains a great degree of freedom in the design of the system software and hardware, plays the effect of simplifying the complex system, saves a lot of development manpower and material resources, and replaces Customers save on equipment investment, extend the life of older equipment, and increase the flexibility of system control. The invention can be widely applied in various aspects of social life, industrial automation, monitoring, communication and the like.