Source packages

<< 点击显示目录 >>

主页  exOS使用助手 > exOS Automation Help > Development > exOS Package >

Source packages

源码包是用于开发组件的软件包,或者用于不区分 "Linux 开发人员 "和 "PLC 程序员 "的项目中,即 Automation Studio 用户同时也是 exOS 组件开发人员。这里需要注意的是,由于是源码包,它用于为目标系统(即 Linux)构建二进制文件,因此使用源码包的系统上必须有构建环境

Templates

exOS 组件生成器可以生成许多不同的模板,以便在为目标机开发 exOS 组件时创建一个简化的起点。在 Automation Studio 中定义好数据模型(.typ 文件)后,VsCode 插件就能生成一个完整的源文件模板,用于编译和传输到目标机。

exOS 组件生成器通常还会生成 makefile 文件,以便在构建过程中自动创建 .deb 包。下图是一个已创建软件包的示例,生成器的唯一输入是 WaterTank.typ 文件:

Watertank source sample component

在这里,.exospkg 文件包含以下内容(由 exOS 组件生成器创建):

<?xml version="1.0" encoding="utf-8"?>
<ComponentPackage Version="2.0.0" ErrorHandling="Component" StartupTimeout="0">
    <File FileName="Linux\exos-comp-watertank_1.0.0_amd64.deb" ChangeEvent="Reinstall"/>
    <File FileName="Linux\index.js" ChangeEvent="Restart"/>
    <Service Type="Install" Command="dpkg -i exos-comp-watertank_1.0.0_amd64.deb"/>
    <Service Type="Remove" Command="dpkg --purge exos-comp-watertank"/>
    <Service Type="Startup" Command="cp index.js /home/user/watertank"/>
    <Service Type="Runtime" Command="node index.js" WorkingDirectory="/home/user/watertank"/>
    <DatamodelInstance Name="WaterTank_0"/>
    <Build>
        <GenerateDatamodel FileName="WaterTank\WaterTank.typ" TypeName="WaterTank">
            <SG4 Include="WaterTank.h"/>
            <Output Path="WaterTank"/>
            <Output Path="Linux"/>
        </GenerateDatamodel>
        <BuildCommand Command="C:\Windows\Sysnative\wsl.exe" WorkingDirectory="Linux" Arguments="-d Debian -e sh build.sh $(EXOS_VERSION)">
            <Dependency FileName="Linux\exos_watertank.h"/>
            <Dependency FileName="Linux\exos_watertank.c"/>
            <Dependency FileName="Linux\CMakeLists.txt"/>
            <Dependency FileName="Linux\build.sh"/>
            <Dependency FileName="Linux\libwatertank.c"/>
            <Dependency FileName="Linux\binding.gyp"/>
            <Dependency FileName="Linux\package.json"/>
            <Dependency FileName="Linux\package-lock.json"/>
        </BuildCommand>
    </Build>
    <!-- ComponentGenerator info - do not change! -->
    <ComponentGenerator Class="ExosComponentNAPI" Version="2.0.0">
        <Option Name="exportLinux" Value="exos-comp-watertank_1.0.0_amd64.deb,index.js"/>
        <Option Name="templateAR" Value="c-api"/>
        <Option Name="typeName" Value="WaterTank"/>
        <Option Name="typeFile" Value="WaterTank\WaterTank.typ"/>
        <Option Name="SG4Includes" Value="WaterTank.h"/>
    </ComponentGenerator>
</ComponentPackage>

该软件包的 <Build> 标记中包含大量附加设置,这些设置 在 Automation Studio 中的 exOS 构建链中有所描述

此软件包也可在 exOS 技术软件包的样本文件夹中找到。

 


Source packages are packages that are used for development of components or in projects that do not have a split between "Linux developers" and "PLC programmers", i.e. where the Automation Studio user is also an exOS Component developer. Important to note here is that - as it is a source package - it is used for building binaries for the target system (i.e. Linux), and therefore a Build Environment must be present on the system where the source packages are used.

Templates

The exOS Component Generator can generate a number of different templates to create a simplified starting point when developing exOS Components for your target. After defining a datamodel (.typ file) in Automation Studio, the VsCode plugin can generate a complete template of source files to compile and transfer to the target.

The exOS Component Generator typically also generates makefiles to automatically create .deb packages in the build process. An example of a created package is shown below, where the only input to the generator was the WaterTank.typ file:

Watertank source sample component

 

Here, the .exospkg file has the following contents (created by the exOS Component Generator):

<?xml version="1.0" encoding="utf-8"?>
<ComponentPackage Version="2.0.0" ErrorHandling="Component" StartupTimeout="0">
    <File FileName="Linux\exos-comp-watertank_1.0.0_amd64.deb" ChangeEvent="Reinstall"/>
    <File FileName="Linux\index.js" ChangeEvent="Restart"/>
    <Service Type="Install" Command="dpkg -i exos-comp-watertank_1.0.0_amd64.deb"/>
    <Service Type="Remove" Command="dpkg --purge exos-comp-watertank"/>
    <Service Type="Startup" Command="cp index.js /home/user/watertank"/>
    <Service Type="Runtime" Command="node index.js" WorkingDirectory="/home/user/watertank"/>
    <DatamodelInstance Name="WaterTank_0"/>
    <Build>
        <GenerateDatamodel FileName="WaterTank\WaterTank.typ" TypeName="WaterTank">
            <SG4 Include="WaterTank.h"/>
            <Output Path="WaterTank"/>
            <Output Path="Linux"/>
        </GenerateDatamodel>
        <BuildCommand Command="C:\Windows\Sysnative\wsl.exe" WorkingDirectory="Linux" Arguments="-d Debian -e sh build.sh $(EXOS_VERSION)">
            <Dependency FileName="Linux\exos_watertank.h"/>
            <Dependency FileName="Linux\exos_watertank.c"/>
            <Dependency FileName="Linux\CMakeLists.txt"/>
            <Dependency FileName="Linux\build.sh"/>
            <Dependency FileName="Linux\libwatertank.c"/>
            <Dependency FileName="Linux\binding.gyp"/>
            <Dependency FileName="Linux\package.json"/>
            <Dependency FileName="Linux\package-lock.json"/>
        </BuildCommand>
    </Build>
    <!-- ComponentGenerator info - do not change! -->
    <ComponentGenerator Class="ExosComponentNAPI" Version="2.0.0">
        <Option Name="exportLinux" Value="exos-comp-watertank_1.0.0_amd64.deb,index.js"/>
        <Option Name="templateAR" Value="c-api"/>
        <Option Name="typeName" Value="WaterTank"/>
        <Option Name="typeFile" Value="WaterTank\WaterTank.typ"/>
        <Option Name="SG4Includes" Value="WaterTank.h"/>
    </ComponentGenerator>
</ComponentPackage>

This package has a number of additional settings within the <Build> tag, which are described in the exOS build-chain in Automation Studio

This package can also be found in the Samples folder of the exOS Technology Package.