[go: up one dir, main page]

CN115098218B - Description and simulation method from FMU model to function block model in configuration software - Google Patents

Description and simulation method from FMU model to function block model in configuration software Download PDF

Info

Publication number
CN115098218B
CN115098218B CN202210577956.2A CN202210577956A CN115098218B CN 115098218 B CN115098218 B CN 115098218B CN 202210577956 A CN202210577956 A CN 202210577956A CN 115098218 B CN115098218 B CN 115098218B
Authority
CN
China
Prior art keywords
model
fmu
simulation
function
functional block
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202210577956.2A
Other languages
Chinese (zh)
Other versions
CN115098218A (en
Inventor
彭波
成启林
李强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Southwest University of Science and Technology
Original Assignee
Southwest University of Science and Technology
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 Southwest University of Science and Technology filed Critical Southwest University of Science and Technology
Priority to CN202210577956.2A priority Critical patent/CN115098218B/en
Publication of CN115098218A publication Critical patent/CN115098218A/en
Application granted granted Critical
Publication of CN115098218B publication Critical patent/CN115098218B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators

Landscapes

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

Abstract

本发明公开了一种FMU模型到组态软件中功能块模型的描述和仿真方法,包括以下步骤:S1:封装FMU模型,将FMU模型描述为组态软件中符合IEC 61131‑3标准的功能块模型;S2:对描述为功能块模型的FMU模型进行解析,以使FMU模型实现仿真加载。FMI标准对于复杂仿真模型或系统具有良好的建模仿真能力,将FMI标准和IEC 61131‑3标准集成,可以更好的解决复杂系统的仿真验证分析问题,增加不同仿真软件之间的协作能力。

The invention discloses a description and simulation method from an FMU model to a function block model in configuration software, which includes the following steps: S1: Encapsulate the FMU model and describe the FMU model as a function block in the configuration software that complies with the IEC 61131-3 standard. Model; S2: Analyze the FMU model described as a function block model, so that the FMU model can realize simulation loading. The FMI standard has good modeling and simulation capabilities for complex simulation models or systems. Integrating the FMI standard with the IEC 61131-3 standard can better solve the simulation verification and analysis problems of complex systems and increase the collaboration capabilities between different simulation software.

Description

FMU模型到组态软件中功能块模型的描述和仿真方法Description and simulation method from FMU model to function block model in configuration software

技术领域Technical field

本发明属于工控仿真技术领域,具体涉及一种FMU模型到组态软件中功能块模型的描述和仿真方法。The invention belongs to the technical field of industrial control simulation, and specifically relates to a description and simulation method from an FMU model to a functional block model in configuration software.

背景技术Background technique

面对智能工厂生产工艺上下游耦合、对象复杂多变难控、网络协同和信息多源等新态势传统的PLC和DCS的现场控制站由于计算和存储资源有限,无法应对非线性、时变、分布参数的复杂生产过程控制要求,难以满足智能工厂对智能感知、自主决策和网络协同功能的紧迫需求。使控制器具备云边协同的智能控制能力,实现靠近现场端的实时感知、实时控制和智能分析,已成为工业控制系统新的发展趋势。由于可编程控制器开发工具需要综合软件技术、编译技术、图形化语言编程技术、操作系统、体系结构等计算机领域的专业知识,还需要熟悉工控领域和PLC领域的专业知识,并且有丰富的行业经验,开发要求高、难度大、投入大、周期长。在这种背景下,国产控制器在大规模智能工厂实际应用中处于竞争劣势,因此开展具备实时感知、实时控制和支持复杂智能算法运行的边缘智能控制器及其编程、仿真工具的研发与应用迫在眉睫。Facing new trends such as upstream and downstream coupling of smart factory production processes, complex and changeable objects that are difficult to control, network collaboration and multiple sources of information, traditional PLC and DCS on-site control stations cannot cope with non-linear, time-varying, The complex production process control requirements of distributed parameters are difficult to meet the urgent needs of smart factories for intelligent sensing, autonomous decision-making and network collaboration functions. It has become a new development trend of industrial control systems to equip controllers with intelligent control capabilities for cloud-edge collaboration and achieve real-time perception, real-time control and intelligent analysis close to the field. Since programmable controller development tools require comprehensive software technology, compilation technology, graphical language programming technology, operating systems, architecture and other computer fields, they also need to be familiar with professional knowledge in the industrial control field and PLC field, and have rich industry experience. Experience, development requirements are high, difficult, investment is large, and the cycle is long. In this context, domestic controllers are at a competitive disadvantage in the practical application of large-scale smart factories. Therefore, the development and application of edge smart controllers and their programming and simulation tools with real-time perception, real-time control and support for the operation of complex intelligent algorithms are carried out. Imminent.

发明内容Contents of the invention

本发明为了解决上述问题,提出了一种FMU模型到组态软件中功能块模型的描述和仿真方法。In order to solve the above problems, the present invention proposes a description and simulation method from the FMU model to the function block model in the configuration software.

本发明的技术方案是:一种FMU模型到组态软件中功能块模型的描述和仿真方法包括以下步骤:The technical solution of the present invention is: a description and simulation method from an FMU model to a function block model in configuration software includes the following steps:

S1:封装FMU模型,将FMU模型描述为组态软件中符合IEC 61131-3标准的功能块模型;S1: Encapsulate the FMU model and describe the FMU model as a function block model in the configuration software that complies with the IEC 61131-3 standard;

S2:对描述为功能块模型的FMU模型进行解析,以使FMU模型实现仿真加载。S2: Analyze the FMU model described as a function block model to enable simulation loading of the FMU model.

进一步地,步骤S1包括以下子步骤:Further, step S1 includes the following sub-steps:

S11:构建一个xml对象,并创建符合IEC61131-10标准的功能块XML样式表;S11: Construct an xml object and create a function block XML style sheet that complies with the IEC61131-10 standard;

S12:在功能块XML样式表的各个节点中写入对应的元素名和属性值,生成不包含功能块关键信息的XML文件;S12: Write the corresponding element names and attribute values in each node of the function block XML style sheet, and generate an XML file that does not contain the key information of the function block;

S13:通过DOM技术解析不包含功能块关键信息的XML文件,提取FMU模型的描述文件根节点下的FMU模型名称、唯一标识符属性值以及FMU模型变量节点中的关键属性值;S13: Use DOM technology to parse the XML file that does not contain key information of the function block, and extract the FMU model name, unique identifier attribute value, and key attribute value in the FMU model variable node under the root node of the description file of the FMU model;

S14:创建一个空的功能块接口信息TXT文件,将提取的FMU模型名称、唯一标识符属性值以及FMU模型变量节点中的关键属性值映射为对应的功能块描述信息,并使用结构化文本语言进行描述,将用结构化文本语言描述的功能块描述信息写入TXT文件中保存;S14: Create an empty function block interface information TXT file, map the extracted FMU model name, unique identifier attribute value, and key attribute value in the FMU model variable node to the corresponding function block description information, and use structured text language Description, write the function block description information described in structured text language into a TXT file and save it;

S15:将映射的功能块描述信息进行信息封装。S15: Encapsulate the mapped function block description information.

进一步地,步骤S15中,进行信息封装的具体方法为:通过时间函数获取系统时间戳,将获取到的系统时间戳进行换算,并转换为yyyy-MM-ddTHH:mm:ss格式,储在字符串数组中;Further, in step S15, the specific method for information encapsulation is: obtain the system timestamp through the time function, convert the obtained system timestamp, and convert it into the yyyy-MM-ddTHH:mm:ss format, and store it in the character in string array;

遍历功能块XML样式表,将FMU模型名称、唯一标识符属性值和执行模型描述的时间写入功能块XML样式表对应节点的对应属性值的位置;调用输入接口变量写入函数,将FMU模型的输入变量名称、数据类型和初始值信息写入功能块XML样式表的输入变量节点;调用输出接口变量写入函数,将FMU模型的输出变量名称、数据类型和初始值信息写入功能块XML样式表的输出变量节点;调用局部变量写入函数,将FMU模型的内部变量名称、数据类型和初始值信息写入功能块XML样式表的局部变量节点;调用功能块声明语句函数,将根据FMU模型的变量信息写入功能块XML样式表的纯文本界面节点,完成所有信息的封装。Traverse the function block XML style sheet, and write the FMU model name, unique identifier attribute value and execution time of the model description into the corresponding attribute value position of the corresponding node in the function block XML style sheet; call the input interface variable writing function to write the FMU model The input variable name, data type and initial value information are written into the input variable node of the function block XML style sheet; the output interface variable writing function is called to write the output variable name, data type and initial value information of the FMU model into the function block XML. The output variable node of the style sheet; call the local variable writing function to write the internal variable name, data type and initial value information of the FMU model into the local variable node of the function block XML style sheet; call the function block declaration statement function to write the internal variable name, data type and initial value information of the FMU model to the local variable node of the function block The variable information of the model is written into the plain text interface node of the function block XML style sheet to complete the encapsulation of all information.

进一步地,步骤S2包括以下子步骤:Further, step S2 includes the following sub-steps:

S21:创建ADS客户端,并将ADS客户端与TwinCAT3建立通讯;S21: Create an ADS client and establish communication between the ADS client and TwinCAT3;

S22:将FMU模型描述为功能块模型后生成的XML文件导入TwinCAT3中对应的功能块模型,通过构建MAIN主程序调用功能块模型,并在ADS客户端中获取MAIN主程序对应的变量句柄;S22: Import the XML file generated after describing the FMU model as a function block model into the corresponding function block model in TwinCAT3, call the function block model by building the MAIN main program, and obtain the variable handle corresponding to the MAIN main program in the ADS client;

S23:对FMU模型文件进行解压,得到模型描述文件和模型实现文件;S23: Decompress the FMU model file and obtain the model description file and model implementation file;

S24:获取模型实现文件中各个接口函数的句柄;S24: Obtain the handles of each interface function in the model implementation file;

S25:读取模型描述文件中的唯一标识符属性值和模型标识属性值,并调用FMU模型实例化函数对模型进行实例化操作,在实例化操作后进入步骤S26;S25: Read the unique identifier attribute value and model identification attribute value in the model description file, and call the FMU model instantiation function to instantiate the model. After the instantiation operation, enter step S26;

S26:通过接口函数的句柄,调用仿真时间获取接口函数获取XML文件中的仿真起止时间和步长,并通过仿真时间设置接口函数设置仿真时间信息,验证仿真时间;S26: Through the handle of the interface function, call the simulation time acquisition interface function to obtain the simulation start and end time and step size in the XML file, and set the simulation time information through the simulation time setting interface function to verify the simulation time;

S27:对FMU模型进行求解,从仿真起始时间开始调用FMU模型仿真求解接口函数进行各个仿真步长的求解,直至达到验证通过仿真时间时长;S27: Solve the FMU model, and call the FMU model simulation solution interface function from the simulation start time to solve each simulation step until the verification pass simulation time is reached;

S28:将FMU模型求解结果赋值给MAIN主程序对应的变量句柄,以使FMU模型实现仿真加载。S28: Assign the FMU model solution result to the variable handle corresponding to the MAIN main program, so that the FMU model can be loaded for simulation.

进一步地,步骤S25中,计算一个仿真步长对应调用一次FMU模型仿真求解接口函数。Further, in step S25, calculating one simulation step size corresponds to calling the FMU model simulation solution interface function once.

本发明的有益效果是:The beneficial effects of the present invention are:

(1)FMU模型到功能块模型的表达可以实现FMU模型在组态编程软件上的重用,可以避免仿真模型的手动重构的工作,极大扩展了组态编程软件的应用领域;(1) The expression of the FMU model into the function block model can realize the reuse of the FMU model in the configuration programming software, avoid the manual reconstruction of the simulation model, and greatly expand the application field of the configuration programming software;

(2)FMI标准对于复杂仿真模型或系统具有良好的建模仿真能力,将FMI标准和IEC61131-3标准集成,可以更好的解决复杂系统的仿真验证分析问题,增加不同仿真软件之间的协作能力。(2) The FMI standard has good modeling and simulation capabilities for complex simulation models or systems. Integrating the FMI standard with the IEC61131-3 standard can better solve the simulation verification and analysis problems of complex systems and increase collaboration between different simulation software. ability.

附图说明Description of the drawings

图1为FMU模型到组态软件中功能块模型的描述和仿真方法的流程图;Figure 1 is a flow chart of the description and simulation method from the FMU model to the function block model in the configuration software;

图2为总体模型表达设计方案示意图;Figure 2 is a schematic diagram of the overall model expression design plan;

图3为FMU模型描述文件的导入和转化流程图;Figure 3 is the flow chart of importing and converting FMU model description files;

图4为FMU模型到IEC61131-3标准功能块模型描述流程图;Figure 4 is a flow chart describing the FMU model to the IEC61131-3 standard function block model;

图5为模型描述中间插件的总体功能设计方案示意图。Figure 5 is a schematic diagram of the overall functional design scheme of the model description middle plug-in.

具体实施方式Detailed ways

下面结合附图对本发明的实施例作进一步的说明。The embodiments of the present invention will be further described below with reference to the accompanying drawings.

在描述本发明的具体实施例之前,为使本发明的方案更加清楚完整,首先对本发明中出现的缩略语和关键术语定义进行说明:Before describing the specific embodiments of the present invention, in order to make the solution of the present invention more clear and complete, the abbreviations and key terms appearing in the present invention are first explained:

IEC 61131-3标准:IEC 61131-3是开发可编程逻辑控制器(PLC)的全球相关的标准。IEC61131-3标准包含了许多内容,包括五种编程语言和公用元素。其中公用元素有包含:数据类型定义、变量、软件模型元素、软件模型、程序组织单元等。而功能块属于程序组织单元,是一个事先已定义好的包含标准处理功能的基本程序组织单元。IEC 61131-3 standard: IEC 61131-3 is a globally relevant standard for the development of programmable logic controllers (PLCs). The IEC61131-3 standard contains a lot of content, including five programming languages and common elements. The common elements include: data type definitions, variables, software model elements, software models, program organization units, etc. The function block belongs to the program organization unit, which is a basic program organization unit that has been defined in advance and contains standard processing functions.

FMI标准可译为“功能模型接口”标准,本质上是一个第三方通用的模型接口标准,基于此标准封装的FMU模型可以在任何支持此标准的软件中直接使用;FMU可译为“功能模型单元”,是基于FMI标准封装的可移植、可调用的模型库,其内部包含模型运行所需的源代码以及模型描述文件。The FMI standard can be translated as "Functional Model Interface" standard, which is essentially a third-party universal model interface standard. FMU models packaged based on this standard can be used directly in any software that supports this standard; FMU can be translated as "Functional Model" "Unit" is a portable and callable model library encapsulated based on the FMI standard, which contains the source code and model description files required for model operation.

IEC 61131-10标准是在PLCopen XML的基础上开发的,并扩展了PLCopen XML的功能。IEC 61131-10标准为IEC 61131-3项目的导出和导入指定了一种基于XML的交换格式,可以在不同的编程环境之间转移在IEC 61131-3环境中实现的完整IEC 61131-3项目,包括配置元素、数据类型以及根据标准编程语言编写的程序组织单元等。The IEC 61131-10 standard is developed on the basis of PLCopen XML and extends the functionality of PLCopen XML. The IEC 61131-10 standard specifies an XML-based exchange format for the export and import of IEC 61131-3 projects that enables the transfer of complete IEC 61131-3 projects implemented in an IEC 61131-3 environment between different programming environments, Including configuration elements, data types, and program organization units written according to standard programming languages.

如图1所示,本发明提供了一种FMU模型到组态软件中功能块模型的描述和仿真方法,包括以下步骤:As shown in Figure 1, the present invention provides a description and simulation method from the FMU model to the function block model in the configuration software, which includes the following steps:

S1:封装FMU模型,将FMU模型描述为组态软件中符合IEC 61131-3标准的功能块模型;S1: Encapsulate the FMU model and describe the FMU model as a function block model in the configuration software that complies with the IEC 61131-3 standard;

S2:对描述为功能块模型的FMU模型进行解析,以使FMU模型实现仿真加载。S2: Analyze the FMU model described as a function block model to enable simulation loading of the FMU model.

在本发明实施例中,步骤S1包括以下子步骤:In the embodiment of the present invention, step S1 includes the following sub-steps:

S11:构建一个xml对象,并创建符合IEC61131-10标准的功能块XML样式表;S11: Construct an xml object and create a function block XML style sheet that complies with the IEC61131-10 standard;

S12:在功能块XML样式表的各个节点中写入对应的元素名和属性值,生成不包含功能块关键信息的XML文件;S12: Write the corresponding element names and attribute values in each node of the function block XML style sheet, and generate an XML file that does not contain the key information of the function block;

S13:通过DOM技术解析不包含功能块关键信息的XML文件,提取FMU模型的描述文件根节点下的FMU模型名称、唯一标识符属性值以及FMU模型变量节点中的关键属性值;S13: Use DOM technology to parse the XML file that does not contain key information of the function block, and extract the FMU model name, unique identifier attribute value, and key attribute value in the FMU model variable node under the root node of the description file of the FMU model;

S14:创建一个空的功能块接口信息TXT文件,将提取的FMU模型名称、唯一标识符属性值以及FMU模型变量节点中的关键属性值映射为对应的功能块描述信息,并使用结构化文本语言进行描述,将用结构化文本语言描述的功能块描述信息写入TXT文件中保存;S14: Create an empty function block interface information TXT file, map the extracted FMU model name, unique identifier attribute value, and key attribute value in the FMU model variable node to the corresponding function block description information, and use structured text language Description, write the function block description information described in structured text language into a TXT file and save it;

S15:将映射的功能块描述信息进行信息封装。S15: Encapsulate the mapped function block description information.

步骤S13中,将FMU模型描述文件中的FMU模型名称(modelName)和guid属性的值以及FMU模型变量关键属性信息(模型变量名name、变量数据类型,包括Real、Integer、Boolean等、变量性质causality以及模型变量的初始值)提取出来。In step S13, the FMU model name (modelName) and the value of the guid attribute in the FMU model description file as well as the key attribute information of the FMU model variable (model variable name, variable data type, including Real, Integer, Boolean, etc., variable property causality and the initial values of the model variables) are extracted.

在本发明实施例中,步骤S15中,进行信息封装的具体方法为:通过时间函数获取系统时间戳,将获取到的系统时间戳进行换算,并转换为yyyy-MM-ddTHH:mm:ss格式,储在字符串数组中;In the embodiment of the present invention, in step S15, the specific method for encapsulating information is: obtaining the system timestamp through a time function, converting the obtained system timestamp, and converting it into the yyyy-MM-ddTHH:mm:ss format , stored in the string array;

遍历功能块XML样式表,将FMU模型名称、唯一标识符属性值和执行模型描述的时间写入功能块XML样式表对应节点的对应属性值的位置;调用输入接口变量写入函数,将FMU模型的输入变量名称、数据类型和初始值信息写入功能块XML样式表的输入变量节点;调用输出接口变量写入函数,将FMU模型的输出变量名称、数据类型和初始值信息写入功能块XML样式表的输出变量节点;调用局部变量写入函数,将FMU模型的内部变量名称、数据类型和初始值信息写入功能块XML样式表的局部变量节点;调用功能块声明语句函数,将根据FMU模型的变量信息写入功能块XML样式表的纯文本界面节点,完成所有信息的封装。Traverse the function block XML style sheet, and write the FMU model name, unique identifier attribute value and execution time of the model description into the corresponding attribute value position of the corresponding node in the function block XML style sheet; call the input interface variable writing function to write the FMU model The input variable name, data type and initial value information are written into the input variable node of the function block XML style sheet; the output interface variable writing function is called to write the output variable name, data type and initial value information of the FMU model into the function block XML. The output variable node of the style sheet; call the local variable writing function to write the internal variable name, data type and initial value information of the FMU model into the local variable node of the function block XML style sheet; call the function block declaration statement function to write the internal variable name, data type and initial value information of the FMU model to the local variable node of the function block The variable information of the model is written into the plain text interface node of the function block XML style sheet to complete the encapsulation of all information.

在本发明实施例中,将FMU模型描述为功能块模型,生成的“FMU”功能块只包含基本的输入输出接口变量、变量的数据类型和初始值等信息,具体的逻辑实现则是通过解析器解析FMU模型后,将输入输出的数据映射到对应的功能块输入输出变量实现的,即从表面来看,FMU功能块可以看作一个“空盒子”,而具体的逻辑计算则是通过“盒子”内的FMU解析器对模型解析来实现的。步骤S2包括以下子步骤:In the embodiment of the present invention, the FMU model is described as a function block model. The generated "FMU" function block only contains information such as basic input and output interface variables, data types of variables, and initial values. The specific logic implementation is through analysis. After the processor parses the FMU model, it maps the input and output data to the corresponding function block input and output variables. That is, from the surface, the FMU function block can be regarded as an "empty box", and the specific logical calculation is through " The FMU parser in the "box" is implemented by parsing the model. Step S2 includes the following sub-steps:

S21:创建ADS客户端,并将ADS客户端与TwinCAT3建立通讯;S21: Create an ADS client and establish communication between the ADS client and TwinCAT3;

S22:将FMU模型描述为功能块模型后生成的XML文件导入TwinCAT3中对应的功能块模型,通过构建MAIN主程序调用功能块模型,并在ADS客户端中获取MAIN主程序对应的变量句柄;S22: Import the XML file generated after describing the FMU model as a function block model into the corresponding function block model in TwinCAT3, call the function block model by building the MAIN main program, and obtain the variable handle corresponding to the MAIN main program in the ADS client;

S23:对FMU模型文件进行解压,得到模型描述文件和模型实现文件;S23: Decompress the FMU model file and obtain the model description file and model implementation file;

S24:获取模型实现文件中各个接口函数的句柄;S24: Obtain the handles of each interface function in the model implementation file;

S25:读取模型描述文件中的唯一标识符属性值和模型标识属性值,并调用FMU模型实例化函数对模型进行实例化操作,在实例化操作后进入步骤S26;S25: Read the unique identifier attribute value and model identification attribute value in the model description file, and call the FMU model instantiation function to instantiate the model. After the instantiation operation, enter step S26;

S26:通过接口函数的句柄,调用仿真时间获取接口函数获取XML文件中的仿真起止时间和步长,并通过仿真时间设置接口函数设置仿真时间信息,验证仿真时间;S26: Through the handle of the interface function, call the simulation time acquisition interface function to obtain the simulation start and end time and step size in the XML file, and set the simulation time information through the simulation time setting interface function to verify the simulation time;

S27:对FMU模型进行求解,从仿真起始时间开始调用FMU模型仿真求解接口函数进行各个仿真步长的求解,直至达到验证通过仿真时间时长;S27: Solve the FMU model, and call the FMU model simulation solution interface function from the simulation start time to solve each simulation step until the verification pass simulation time is reached;

S28:将FMU模型求解结果赋值给MAIN主程序对应的变量句柄,以使FMU模型实现仿真加载。S28: Assign the FMU model solution result to the variable handle corresponding to the MAIN main program, so that the FMU model can be loaded for simulation.

步骤S21中,如果TwinCAT3是集成在本地Visual Studio中,则可以不用设置AMSNETID,只需要通过851端口号即可建立通讯,若TwinCAT3不在本地,则需要同时设置端口号与目标AMSNETID。In step S21, if TwinCAT3 is integrated in the local Visual Studio, you do not need to set the AMSNETID and only need to establish communication through the 851 port number. If TwinCAT3 is not local, you need to set the port number and the target AMSNETID at the same time.

步骤S23中,通过调用7-Zip软件解压FMU文件得到模型描述文件。In step S23, the model description file is obtained by calling 7-Zip software to decompress the FMU file.

在本发明实施例中,步骤S25中,计算一个仿真步长对应调用一次FMU模型仿真求解接口函数。In the embodiment of the present invention, in step S25, calculating one simulation step corresponds to calling the FMU model simulation solution interface function once.

在本发明实施例中,本发明所需要解决的问题是在表现层提供一种FMU模型到IEC61131-3标准功能块模型的描述方法以及在IEC61131-3标准下的FMU模型联合仿真方法,通过将FMI/FMU引入工控领域,解决传统组态软件兼容性差、开放性差的问题。In the embodiment of the present invention, the problem that the present invention needs to solve is to provide a description method of the FMU model to the IEC61131-3 standard function block model and a joint simulation method of the FMU model under the IEC61131-3 standard at the presentation layer. FMI/FMU is introduced into the field of industrial control to solve the problems of poor compatibility and poor openness of traditional configuration software.

本发明在表现层FMI标准下FMU模型和IEC 61131-3标准功能块模型结构以及模型描述文件的特点,设计一个中间插件,采用XML技术将FMU模型描述为IEC 61131-3标准功能块模型;在模型执行层对基于联合仿真方式的FMU模型的求解进行了设计,通过解析FMU文件来调用FMU模型DLL库函数进行FMU模型的求解,并基于ADS通讯方式与组态软件建立通信并进行FMU模型的接口绑定以及数据传输,最后实现FMU模型的表达,其总体模型表达设计方案如图2所示。The present invention designs an intermediate plug-in based on the characteristics of the FMU model and the IEC 61131-3 standard function block model structure and the model description file under the presentation layer FMI standard, and uses XML technology to describe the FMU model as the IEC 61131-3 standard function block model; The model execution layer designs the solution of the FMU model based on the joint simulation method. It calls the FMU model DLL library function to solve the FMU model by parsing the FMU file, and establishes communication with the configuration software based on the ADS communication method and performs the calculation of the FMU model. Interface binding and data transmission, and finally the expression of the FMU model is realized. The overall model expression design plan is shown in Figure 2.

鉴于两种标准下的模型都能够以XML文件的形式存储模型变量信息,通过对IEC61131-3标准和FMI标准在数据类型、功能块、名字空间、存储空间、任务绑定、目标平台服务接口规范等方面的研究,采用XML技术,实现FMU模型解析及其数据参数到统一软件模型的映射,将其呈现为可以和POU一同进行组态编程的功能块,如图2所示。In view of the fact that models under both standards can store model variable information in the form of XML files, through the IEC61131-3 standard and FMI standard in data type, function block, name space, storage space, task binding, target platform service interface specification Research in other aspects uses XML technology to realize the mapping of FMU model analysis and its data parameters to a unified software model, and presents it as a function block that can be configured and programmed together with POU, as shown in Figure 2.

整个模型描述流程可以分为两个层次,第一个部分是将FMU模型描述文件(modelDescription.xml)导入,并从中提取FMU模型的关键参数信息;第二个部分则是构建IEC 61131-10标准的工程文件样式表,并将提取的信息写入到IEC 61131-10标准的样式表中,生成一个XML工程文件,然后通过XML接口导入到仿真工具中并运行,最终生成IEC61131-3标准的功能块模型。FMU模型文件描述为功能块的流程如图4所示。The entire model description process can be divided into two levels. The first part is to import the FMU model description file (modelDescription.xml) and extract the key parameter information of the FMU model; the second part is to build the IEC 61131-10 standard. Project file style sheet, and write the extracted information into the IEC 61131-10 standard style sheet, generate an XML project file, and then import it into the simulation tool through the XML interface and run it, and finally generate the IEC61131-3 standard function block model. The process of describing the FMU model file as function blocks is shown in Figure 4.

中间插件实现将FMU模型描述为IEC 61131-3标准的功能块模型,根据模型描述的流程,采用模块化的思想对中间件的功能进行细分设计,中间插件功能如图5所示,The middle plug-in implementation describes the FMU model as a function block model according to the IEC 61131-3 standard. According to the process described by the model, the modular idea is used to subdivide the functions of the middleware. The middle plug-in function is shown in Figure 5.

本发明的有益效果为:The beneficial effects of the present invention are:

(1)FMU模型到功能块模型的表达可以实现FMU模型在组态编程软件上的重用,可以避免仿真模型的手动重构的工作,极大扩展了组态编程软件的应用领域;(1) The expression of the FMU model into the function block model can realize the reuse of the FMU model in the configuration programming software, avoid the manual reconstruction of the simulation model, and greatly expand the application field of the configuration programming software;

(2)FMI标准对于复杂仿真模型或系统具有良好的建模仿真能力,将FMI标准和IEC61131-3标准集成,可以更好的解决复杂系统的仿真验证分析问题,增加不同仿真软件之间的协作能力。(2) The FMI standard has good modeling and simulation capabilities for complex simulation models or systems. Integrating the FMI standard with the IEC61131-3 standard can better solve the simulation verification and analysis problems of complex systems and increase collaboration between different simulation software. ability.

本领域的普通技术人员将会意识到,这里所述的实施例是为了帮助读者理解本发明的原理,应被理解为本发明的保护范围并不局限于这样的特别陈述和实施例。本领域的普通技术人员可以根据本发明公开的这些技术启示做出各种不脱离本发明实质的其它各种具体变形和组合,这些变形和组合仍然在本发明的保护范围内。Those of ordinary skill in the art will appreciate that the embodiments described here are provided to help readers understand the principles of the present invention, and it should be understood that the scope of the present invention is not limited to such specific statements and embodiments. Those of ordinary skill in the art can make various other specific modifications and combinations based on the technical teachings disclosed in the present invention without departing from the essence of the present invention, and these modifications and combinations are still within the protection scope of the present invention.

Claims (3)

1. The method for describing and simulating the function block model from the FMU model to the configuration software is characterized by comprising the following steps:
s1: packaging an FMU model, and describing the FMU model as a functional block model conforming to IEC61131-3 standard in configuration software;
s2: analyzing the FMU model described as the functional block model so as to enable the FMU model to realize simulation loading;
said step S1 comprises the sub-steps of:
s11: constructing an XML object and creating a function block XML style sheet conforming to IEC61131-10 standard;
s12: writing corresponding element names and attribute values in each node of the function block XML style sheet to generate an XML file which does not contain key information of the function block;
s13: analyzing an XML file which does not contain key information of the functional blocks through a DOM technology, and extracting an FMU model name, a unique identifier attribute value and a key attribute value in a variable node of the FMU model under a description file root node of the FMU model;
s14: creating an empty function block interface information TXT file, mapping the extracted FMU model name, unique identifier attribute value and key attribute value in FMU model variable nodes into corresponding function block description information, describing by using a structured text language, and writing the function block description information described by using the structured text language into the TXT file for storage;
s15: information packaging is carried out on the mapped functional block description information;
said step S2 comprises the sub-steps of:
s21: creating an ADS client, and establishing communication between the ADS client and TwinCAT 3;
s22: the FMU model is described as a functional block model, an XML file generated after the functional block model is described is imported into a corresponding functional block model in TwainCAT 3, the functional block model is called through a MAIN MAIN program, and a variable handle corresponding to the MAIN MAIN program is obtained from an ADS client;
s23: decompressing the FMU model file to obtain a model description file and a model realization file;
s24: acquiring handles of all interface functions in the model realization file;
s25: reading a unique identifier attribute value and a model identification attribute value in a model description file, calling an FMU model instantiation function to carry out instantiation operation on a model, and entering step S26 after the instantiation operation;
s26: calling a simulation time obtaining interface function to obtain simulation start-stop time and step length in an XML file through a handle of the interface function, setting simulation time information through the simulation time setting interface function, and verifying the simulation time;
s27: solving the FMU model, and starting to call an FMU model simulation solving interface function from simulation starting time to solve each simulation step length until verification passes simulation time duration;
s28: and assigning the FMU model solving result to a variable handle corresponding to the MAIN MAIN program so as to enable the FMU model to realize simulation loading.
2. The method for describing and simulating the functional block model from the FMU model to the configuration software according to claim 1, wherein in step S15, the specific method for performing information encapsulation is as follows: acquiring a system time stamp through a time function, converting the acquired system time stamp, converting the system time stamp into yyyy-MM-ddTHH: MM: ss format, and storing the yyyy-MM-ddTHH: MM: ss format in a character string array;
traversing the XML style sheet of the functional block, and writing the FMU model name, the unique identifier attribute value and the time for executing the model description into the position of the corresponding attribute value of the corresponding node of the XML style sheet of the functional block; calling an input interface variable writing function, and writing the input variable name, the data type and initial value information of the FMU model into input variable nodes of the XML style sheet of the functional block; calling an output interface variable writing function, and writing the output variable name, the data type and initial value information of the FMU model into an output variable node of the XML style sheet of the functional block; calling a local variable writing function, and writing the internal variable name, the data type and initial value information of the FMU model into local variable nodes of the XML style sheet of the functional block; calling a statement sentence function of the functional block, writing variable information according to the FMU model into a plain text interface node of an XML style sheet of the functional block, and completing encapsulation of all information.
3. The method for describing and simulating a functional block model from an FMU model to configuration software according to claim 1, wherein in step S25, a simulation step is calculated and a simulation solution interface function of the FMU model is called once.
CN202210577956.2A 2022-05-25 2022-05-25 Description and simulation method from FMU model to function block model in configuration software Active CN115098218B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210577956.2A CN115098218B (en) 2022-05-25 2022-05-25 Description and simulation method from FMU model to function block model in configuration software

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210577956.2A CN115098218B (en) 2022-05-25 2022-05-25 Description and simulation method from FMU model to function block model in configuration software

Publications (2)

Publication Number Publication Date
CN115098218A CN115098218A (en) 2022-09-23
CN115098218B true CN115098218B (en) 2024-03-19

Family

ID=83288554

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210577956.2A Active CN115098218B (en) 2022-05-25 2022-05-25 Description and simulation method from FMU model to function block model in configuration software

Country Status (1)

Country Link
CN (1) CN115098218B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
PL247168B1 (en) * 2022-10-28 2025-05-26 Politechnika Slaska Im Wincent Multi-channel shutdown delay timer
PL247129B1 (en) * 2022-10-28 2025-05-19 Politechnika Slaska Im Wincent Multi-channel pulse duration measuring system
CN117632114B (en) * 2024-01-24 2024-05-17 浙江大学 A method and device for importing FMU files based on file analysis
CN117785430B (en) * 2024-02-23 2024-05-14 湖南汇创玮达信息科技有限公司 FMU model hybrid simulation scheduling method and device based on theme
CN119397739A (en) * 2024-09-29 2025-02-07 中国科学院理化技术研究所 A simulation model packaging method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016049893A1 (en) * 2014-09-30 2016-04-07 华为技术有限公司 File page management unit, processing device and file page management method
CN106775746A (en) * 2016-12-28 2017-05-31 国家电网公司 A kind of intelligent substation three-dimensional artificial training soft ware system and its platform building method
CN107908830A (en) * 2017-10-26 2018-04-13 北京动力机械研究所 Model conversion method and model conversion system based on FMI standards
CN108628659A (en) * 2017-03-24 2018-10-09 中国电力科学研究院 User's packaging model emulation mode based on dynamic link ADPSS real-time simulations and system
CN111258707A (en) * 2020-01-08 2020-06-09 北京仿真中心 Distributed simulation method and system based on DDS service encapsulation
CN114428728A (en) * 2021-12-17 2022-05-03 沈阳理工大学 Cyber-physical test protocol processing system and method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11972177B2 (en) * 2013-11-08 2024-04-30 Rockwell Automation Technologies, Inc. Interface for data exchange between industrial controllers and simulation applications for simulating a machine
WO2020017981A1 (en) * 2018-07-19 2020-01-23 Soul Machines Limited Machine interaction

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016049893A1 (en) * 2014-09-30 2016-04-07 华为技术有限公司 File page management unit, processing device and file page management method
CN106775746A (en) * 2016-12-28 2017-05-31 国家电网公司 A kind of intelligent substation three-dimensional artificial training soft ware system and its platform building method
CN108628659A (en) * 2017-03-24 2018-10-09 中国电力科学研究院 User's packaging model emulation mode based on dynamic link ADPSS real-time simulations and system
CN107908830A (en) * 2017-10-26 2018-04-13 北京动力机械研究所 Model conversion method and model conversion system based on FMI standards
CN111258707A (en) * 2020-01-08 2020-06-09 北京仿真中心 Distributed simulation method and system based on DDS service encapsulation
CN114428728A (en) * 2021-12-17 2022-05-03 沈阳理工大学 Cyber-physical test protocol processing system and method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"Enable Co-Simulation for Industrial Automation by an FMU Exporter for IEC 61499 Models";Jose Cabral;《2018 IEEE 23rd International Conference on Emerging Technologies and Factory Automation(ETFA)》;20181025;第449-455页 *
"基于FMI的联合仿真技术研究";仪冉;《中国优秀硕士学位论文全文数据库 信息科技辑》;20210915(2021年第09期);第I138-693页 *
"基于IEC61131-3标准的FMU模型表达方法研究";成启林;《中国优秀硕士学位论文全文数据库 信息科技辑》;20230115(2023年第01期);第I138-365页 *

Also Published As

Publication number Publication date
CN115098218A (en) 2022-09-23

Similar Documents

Publication Publication Date Title
CN115098218B (en) Description and simulation method from FMU model to function block model in configuration software
Cavalieri et al. Asset administration shell for PLC representation based on IEC 61131–3
CN107220064B (en) A kind of digital control system interface configuration development approach
CN103593326B (en) IEC61850 software library assembly for network processing unit chip and achieving method of IEC61850 software library assembly
US9235381B2 (en) Method and device for the programming and configuration of a programmable logic controller
EP3217238B1 (en) Automation control system point configuration from controller program files
CN105159656A (en) PLC software programming aided design method
CN109032577B (en) Data simulation method
CN113722936B (en) A domain modeling method and system for intelligent manufacturing
CN102479079A (en) Method and device for generating application
CN102289593A (en) Multidisciplinary virtual experiment interactive simulation solution system
Drath AutomationML: the industrial cookbook
CN115421940A (en) Multi-source heterogeneous model white box integration method based on shared memory technology
CN111813814A (en) Universal model management method and device supporting multiple machine learning frameworks
CN101211262A (en) Software architecture description language quick construction and support method
Karsai et al. Specifying graphical modeling systems using constraint-based meta models
CN115510563A (en) A model-based product development process design method and device
CN117908868A (en) A configuration system based on Mine Hong system
CN117573132A (en) Integrated compiling and downloading method for controllers of different architectures
Papakonstantinou et al. Object oriented extensions of IEC 61131–3 as an enabling technology of software product lines
Lyu et al. On automatic generation of OPC UA connections in IEC 61499 automation systems
CN114995280A (en) Method for improving PLC data acquisition efficiency
KR101085114B1 (en) PLC Software Development Environment Provision System
Wang et al. Component‐Based Formal Modeling of PLC Systems
Garanina et al. Model checking programs in process-oriented IEC 61131-3 structured text

Legal Events

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
GR01 Patent grant
GR01 Patent grant