Template files

<< 点击显示目录 >>

主页  mappServices帮助手册 > mapp IO 管理硬件配置 > 概念
 >

Template files

 

有关此主题的信息,请参阅入门 在运行时使用模板文件管理硬件配置

模板文件是某些硬件模块的模板,为将硬件模块集成到硬件配置中提供了另一种方法。

基本原理部分 介绍了将包括所有可能模块在内的硬件配置从 AS 转移到控制器的变体。然后由导入文件确定哪些模块应位于硬件配置的哪个位置。

template_data

模板文件提供了另一种更灵活的硬件模块引用方式。主要区别在于  导入配置中的参数 "源 "选择了 模板 而不是 AR即使用 AS 传输的硬件配置(见下面的代码示例)。然后,系统会在模板文件设备(MpIO 配置中的 "模板设备名称")上搜索模板文件。每个模块必须有 2 个模板文件:

MyTemplate.ar: (e.g. X20DI9371.ar) – 该文件包含整个模块配置,其方式与 AR 配置相同。

MyTemplate.io: (e.g. X20DI9371.io) – 该文件包含与 I/O 映射表相同的整个 I/O 映射。

除扩展名外,模板文件的名称可根据需要选择。导入文件中的模板由其文件名(不含扩展名)指定。

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">
    <Module ID="$root" Source="AR" SourceID="$root" />
    <!-- ... -->
    <Module ID="IF6.ST1" Source="Template" SourceName="MyTemplate" />
</IOCFG>

每个模板文件只允许定义一个硬件模块。接口模块和总线控制器除外。对于这些模块,也可在模板文件中添加所有子模块/子槽。同样,它们的导入也取决于 导入模式(ImportMode

创建模板文件

可在本节下部下载模板文件示例。

创建模板文件的方法是打开现有配置的 "arconfig.br "文件。具体方法是打开包含所需模块的 AS 项目的路径。arconfig.br "文件位于 "MyASProject/Temp/Object "文件夹中。所有正在使用的模块及其属性都将输入该文件。以模块 X20DI9371 为例:

 

<Module ID="IF6.ST1" Hardware="X20DI9371">

  <Parameter ID="HardwareModuleName" Value="X20DI9371" />

</Module>

<Module ID="IF6.ST1.IO" Hardware="X20DI9371">

  <Parameter ID="FunctionModel" Value="Standard" />

  <Parameter ID="FunctionModelNumber" Value="0" Type="USINT" />

  <Parameter ID="Supervision" Value="on" />

  <Parameter ID="InputFilter" Value="10" Type="USINT" />

  <Parameter ID="DigitalInputsPacked" Value="off" />

</Module>

 

模板文件中的模块 ID 可以是任何 ID。插入模板文件的位置由导入的文件决定!

 

这些参数被复制到一个名为 "DI9371.ar "的文件中。该文件的结构必须如下:

 

<?AutomationRuntimeIOSystem Version = 1.0?>

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

  <!-- Add Module Konfiguration here.-->

</IOCFG>

 

在 <IOCFG> 节点内添加上图所示内容。这样,包含模块配置的模板文件就完成了。

接下来将创建包含 I/O 映射的模板文件。

"iomap.br 文件包含将模块 I/O 映射打包到第二个模板文件所需的全部信息。iomap.br 文件 "也位于 "MyASProject/Temp/Object "路径下。以上示例的一小部分摘录:

 

<LN ID="%IX.IF6.ST1.ModuleOk" Type="BOOL">

  <Prod Device="IF6.ST1" DPName="ModuleOk" Kind="io" />

</LN>

<LN ID="%ID.IF6.ST1.SerialNumber" Type="UDINT">

  <Prod Device="IF6.ST1" DPName="SerialNumber" Kind="io" />

</LN>

<LN ID="%IW.IF6.ST1.ModuleID" Type="UINT">

  <Prod Device="IF6.ST1" DPName="ModuleID" Kind="io" />

</LN>

<LN ID="%IX.IF6.ST1.DigitalInput01" Type="BOOL">

  <Prod Device="IF6.ST1" DPName="DigitalInput01" Kind="io"/>

  <Cons Device="TC#4-CPYDEV" DPName="gdiVariable" Kind="pv"/>

</LN>

 

必须将模块的所有 I/O 数据点复制到模板文件 "DI9371.io "中。该文件的结构

 

<?AutomationRuntimeIOSystem Version="1.0"?>

<IO xmlns="http://www.br-automation.com/AR/IO">

  <Links>

      <!-- Add Module IO-Information here. -->

  </Links>

</IO>

 

上图所示内容添加到节点 <IO> 内。这样就完成了带有 I/O 映射的模板文件。

完成这两个文件后,就有了硬件模块 X20DI9371 的模板。

 

模板文件示例

 

.io file:Template_DI2377Template_DI2377

.ar file:Template_DI2377

 

然后,必须在导入文件中引用模板文件。例如,它可以是这样的

 

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

  <Module ID="$root" Source="AR" SourceID="$root" />

  <Module ID="IF6.ST1" Source="Template" SourceName="Template_DI2377" />

</IOCFG>

模板文件中的模块固件

为确保模板文件中引用的模块固件也在控制器上,可使用 AS 中的 "Additionally supported hardware(额外支持的硬件)"功能。该选项位于控制器的配置中:

 

addsupportedhw

如果模块不在主配置中,且未在 "另外支持的硬件 "中定义,则该模块的固件不在目标系统中,因此无法在运行时使用。

使用模板时如何处理运动控制

mapp IO 还可以通过模板管理运动控制。模板文件的创建原则与模块相同。使用和创建的文件如下:

 

arconfig.br

首先,打开现有配置的 arconfig.br 文件。所用驱动器的数据被复制到一个新文件中,如 "MyTemplate.br":

 

<?AutomationRuntimeIOSystem Version = 1.0?>

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

<Module ID="IF3.ST1" Hardware="8B0P0110HC00.000-1">

<Parameter ID="HardwareModuleName" Value="8B0P0110HC00.000-1" />

<Parameter ID="Mode" Value="CN" />

<Parameter ID="ResponseTimeout" Value="25" Type="UDINT" />

<Parameter ID="MuxNetworkSlot" Value="0" Type="UDINT" />

<Parameter ID="MinimalInputLatency" Value="off" />

<Parameter ID="EPL_Chained" Value="off" />

<Parameter ID="EnableDNA" Value="off" />

<Parameter ID="FunctionModel" Value="DoubleAxis" />

<Parameter ID="InSize" Value="152" Type="UDINT" />

<Parameter ID="OutSize" Value="64" Type="UDINT" />

</Module>

</IOCFG>

 

iomap.br (Optional)

该文件包含完整的 I/O 映射。只有在需要 I/O 映射时才必须使用。如果使用 I/O 映射,则必须创建文件 "MyTemplate.io"。

 

Acp10map.br

该文件包含驱动器的相关信息。这些信息会被复制并保存到新创建的模板文件 "MyTemplate.nc "中:

 

<?AutomationStudio Version="4.4.4.112"?>

<NcDeployment NcSwId="ACP10">  <NcObject Name="gAxis01" InterfaceType="Powerlink" Type="ncAXIS" AcoposSimulation="Off" InitParameterModule="gAxis01i" AcoposParameterModule="gAxis01a" Disabled="FALSE" Channel="1"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

<NcObject Name="8B0P0110HC00.000-1_ncAXIS2" InterfaceType="Powerlink" Type="ncAXIS" AcoposSimulation="Off" InitParameterModule="" AcoposParameterModule="" Disabled="TRUE" Channel="2"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

<NcObject Name="8B0P0110HC00.000-1_ncV_AXIS1" InterfaceType="Powerlink" Type="ncV_AXIS" InitParameterModule="" AcoposParameterModule="" Disabled="TRUE" Channel="1"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

<NcObject Name="8B0P0110HC00.000-1_ncV_AXIS2" InterfaceType="Powerlink" Type="ncV_AXIS" InitParameterModule="" AcoposParameterModule="" Disabled="TRUE" Channel="2"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

</NcDeployment>

 

要使用的模板文件将在导入文件中的所需位置("IF5.ST1")引用:

 

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

<Module ID="$root" Source="AR" SourceID="$root" />

<!-- ... -->

<Module ID="IF5.ST1" Source="Template" SourceName="MyTemplate" ImportMode="ModuleWithSubslots" />

</IOCFG>

 

导入模式还可用于定义是只导入指定模板的模块、模块和相关子槽,还是导入模板的整个分支。默认情况下导入模块和相关子槽。更多信息,请参 "模块 "部分。

 

模板文件中的模块 ID 可以是任何 ID。模板文件的添加位置由导入文件决定!

 

例如,在加载导入文件时,系统会自动检查变量 "gAxis01 "在目标系统中是否可用。这意味着必须创建该变量,否则将禁用变量检查。这可以通过 MpIO 配置实现

config_checkaxispvs

 

 


 

For information related to this topic, see Getting Started Managing the hardware configuration at runtime using template files.

Template files are templates for certain hardware modules and provide another way to integrate hardware modules into the hardware configuration.

Section Basic principle introduces the variant of transferring a hardware configuration including all possible modules from Automation Studio to the controller. The import file then determines which modules should be located at which position in the hardware configuration.

template_data

Template files provide another way to reference hardware modules with more flexibility. The main difference is that Template is selected for parameter "Source" in the configuration being imported instead of AR, i.e. the hardware configuration transferred using Automation Studio (see code example below). The system then searches for a template file on the template file device ("Template device name" in the MpIO configuration). There must be 2 template files per module:

MyTemplate.ar: (e.g. X20DI9371.ar) – This file contains the entire module configuration in the same way that it is contained in the AR configuration.

MyTemplate.io: (e.g. X20DI9371.io) – This file contains the entire I/O mapping in the same way that it is contained in the I/O mapping table.

Except for the extension, the name of template files can be selected as needed. The template is specified in the import file by its filename without the extension.

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">
    <Module ID="$root" Source="AR" SourceID="$root" />
    <!-- ... -->
    <Module ID="IF6.ST1" Source="Template" SourceName="MyTemplate" />
</IOCFG>

Only one hardware module is permitted to be defined in each template file. Interface modules and bus controllers are exceptions to this. For these modules, all submodules/subslots can be also added in the template file. They are likewise imported depending on ImportMode.

Creating template files

An example template file can be downloaded in the lower part of the section.

Template files are created by opening file "arconfig.br" for an existing configuration. This is done by opening the path to an AS project that contains the desired module. File "arconfig.br" is located in folder "MyASProject/Temp/Object". All modules being used as well as their properties are entered in this file. Example for module X20DI9371:

 

<Module ID="IF6.ST1" Hardware="X20DI9371">

  <Parameter ID="HardwareModuleName" Value="X20DI9371" />

</Module>

<Module ID="IF6.ST1.IO" Hardware="X20DI9371">

  <Parameter ID="FunctionModel" Value="Standard" />

  <Parameter ID="FunctionModelNumber" Value="0" Type="USINT" />

  <Parameter ID="Supervision" Value="on" />

  <Parameter ID="InputFilter" Value="10" Type="USINT" />

  <Parameter ID="DigitalInputsPacked" Value="off" />

</Module>

 

The module ID in the template file can be any ID. The location where the template file is inserted is determined by the file being imported!

 

These parameters are copied to a file called "DI9371.ar". The structure of this file must appear as follows:

 

<?AutomationRuntimeIOSystem Version = 1.0?>

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

  <!-- Add Module Konfiguration here.-->

</IOCFG>

 

The content shown above is added inside node <IOCFG>. This completes the template file with the module configuration.

The template file with the I/O mapping is created next.

"iomap.br" contains all of the information needed to pack the module's I/O mapping into the second template file. File "iomap.br file" is also located in the path "MyASProject/Temp/Object". Small excerpt for the example above:

 

<LN ID="%IX.IF6.ST1.ModuleOk" Type="BOOL">

  <Prod Device="IF6.ST1" DPName="ModuleOk" Kind="io" />

</LN>

<LN ID="%ID.IF6.ST1.SerialNumber" Type="UDINT">

  <Prod Device="IF6.ST1" DPName="SerialNumber" Kind="io" />

</LN>

<LN ID="%IW.IF6.ST1.ModuleID" Type="UINT">

  <Prod Device="IF6.ST1" DPName="ModuleID" Kind="io" />

</LN>

<LN ID="%IX.IF6.ST1.DigitalInput01" Type="BOOL">

  <Prod Device="IF6.ST1" DPName="DigitalInput01" Kind="io"/>

  <Cons Device="TC#4-CPYDEV" DPName="gdiVariable" Kind="pv"/>

</LN>

 

All of the module's I/O data points must be copied to template file "DI9371.io". Structure of this file:

 

<?AutomationRuntimeIOSystem Version="1.0"?>

<IO xmlns="http://www.br-automation.com/AR/IO">

  <Links>

      <!-- Add Module IO-Information here. -->

  </Links>

</IO>

 

The content shown above is added inside node <IO>. This completes the template file with the I/O mapping.

Once these 2 files are completed, there is a template for hardware module X20DI9371.

 

Example of a template file:

 

.io file:Template_DI2377Template_DI2377

.ar file:Template_DI2377

The template file must then be referenced in an import file. It can look like this, for example:

 

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

  <Module ID="$root" Source="AR" SourceID="$root" />

  <Module ID="IF6.ST1" Source="Template" SourceName="Template_DI2377" />

</IOCFG>

Module firmware in template files

To ensure that the firmware for the modules referenced in the template files is also on the controller, function "Additionally supported hardware" in Automation Studio is used. This option is located in the configuration for the controller:

addsupportedhw

If a module is not in the master configuration and it was not defined under "Additionally supported hardware", the module's firmware is not located on the target system; the module therefore cannot be used at runtime.

How to handle motion control when using templates

mapp IO also makes it possible to manage motion control via templates. The template file is created based on the same principle as for modules. The following files are used and created:

 

arconfig.br

First, the arconfig.br file of an existing configuration is opened. The data of the drive used is copied to a new file, such as "MyTemplate.br":

 

<?AutomationRuntimeIOSystem Version = 1.0?>

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

<Module ID="IF3.ST1" Hardware="8B0P0110HC00.000-1">

<Parameter ID="HardwareModuleName" Value="8B0P0110HC00.000-1" />

<Parameter ID="Mode" Value="CN" />

<Parameter ID="ResponseTimeout" Value="25" Type="UDINT" />

<Parameter ID="MuxNetworkSlot" Value="0" Type="UDINT" />

<Parameter ID="MinimalInputLatency" Value="off" />

<Parameter ID="EPL_Chained" Value="off" />

<Parameter ID="EnableDNA" Value="off" />

<Parameter ID="FunctionModel" Value="DoubleAxis" />

<Parameter ID="InSize" Value="152" Type="UDINT" />

<Parameter ID="OutSize" Value="64" Type="UDINT" />

</Module>

</IOCFG>

 

iomap.br (Optional)

This file contains the complete I/O mapping. Must only be used if I/O mapping is desired. If an I/O mapping is used, file "MyTemplate.io" must be created.

 

Acp10map.br

This file contains information about the drive. The information is copied and saved in the newly created template file "MyTemplate.nc":

 

<?AutomationStudio Version="4.4.4.112"?>

<NcDeployment NcSwId="ACP10">  <NcObject Name="gAxis01" InterfaceType="Powerlink" Type="ncAXIS" AcoposSimulation="Off" InitParameterModule="gAxis01i" AcoposParameterModule="gAxis01a" Disabled="FALSE" Channel="1"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

<NcObject Name="8B0P0110HC00.000-1_ncAXIS2" InterfaceType="Powerlink" Type="ncAXIS" AcoposSimulation="Off" InitParameterModule="" AcoposParameterModule="" Disabled="TRUE" Channel="2"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

<NcObject Name="8B0P0110HC00.000-1_ncV_AXIS1" InterfaceType="Powerlink" Type="ncV_AXIS" InitParameterModule="" AcoposParameterModule="" Disabled="TRUE" Channel="1"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

<NcObject Name="8B0P0110HC00.000-1_ncV_AXIS2" InterfaceType="Powerlink" Type="ncV_AXIS" InitParameterModule="" AcoposParameterModule="" Disabled="TRUE" Channel="2"   Advanced="    " InterfaceName="IF3" NodeNumber="1" />

</NcDeployment>

 

The template file to be used is referenced in the import file at the desired position ("IF5.ST1"):

 

<IOCFG xmlns="http://www.br-automation.com/AR/IO" Version="2.0">

<Module ID="$root" Source="AR" SourceID="$root" />

<!-- ... -->

<Module ID="IF5.ST1" Source="Template" SourceName="MyTemplate" ImportMode="ModuleWithSubslots" />

</IOCFG>

 

The import mode can also be used to define whether only the module of the specified template, the module and the associated subslots or the entire branch of the template should be imported. The module and the associated subslots are imported by default. For additional information, see here in section "Modules".

 

The module ID in the template file can be any ID. Where the template file is added is determined by the file being imported!

 

When the import file is loaded, the system automatically checks, for example, whether variable "gAxis01" is available on the target system. This means that the variable must be created or otherwise the variable check is disabled. This is done via the MpIO configuration:

config_checkaxispvs