Merged in MBP-169-pou-for-application-specific-code (pull request #49)

MBP-169 pou for application specific code
This commit is contained in:
Federico Rojas
2021-01-29 11:03:12 +00:00
7 changed files with 115 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4023.119">
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4024.11">
<Project ProjectGUID="{9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}" TargetNetId="5.65.73.242.1.1" Target64Bit="true" ShowHideConfigurations="#x106">
<System>
<Tasks>
@@ -16,7 +16,7 @@
<Instance Id="#x08502040" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="tc_project_app\tc_project_app.tmc">
<Name>tc_project_app Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="2">
<Vars VarGrpType="2" AreaNo="1">
<Name>PlcTask Outputs</Name>
<Var>
<Name>MAIN.bOutput1</Name>
@@ -24,6 +24,17 @@
<Type>BOOL</Type>
</Var>
</Vars>
<Contexts>
<Context>
<Id NeedCalleeCall="true">0</Id>
<Name>PlcTask</Name>
<ManualConfig>
<OTCID>#x02010040</OTCID>
</ManualConfig>
<Priority>20</Priority>
<CycleTime>10000000</CycleTime>
</Context>
</Contexts>
<TaskPouOids>
<TaskPouOid Prio="20" OTCID="#x08502041"/>
</TaskPouOids>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<POU Name="Application_Template" Id="{4bdeebc0-15d8-4790-97d0-e9c4239d121c}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM Application_Template
VAR
//Define all necessary variables for your application
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[//Program any specific code or safety code for an specific application when it involves multiple axes
//Eg. Collision avoidance, interlocks, sequencing, etc.]]></ST>
</Implementation>
<LineIds Name="Application_Template">
<LineId Id="5" Count="0" />
<LineId Id="10" Count="0" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<POU Name="Axis_Template" Id="{1a43acb4-bd2e-4637-97fb-9976d47292b6}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM Axis_Template
VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[//Initial parameters of an Axis
(*IF _TaskInfo[fbGetCurTaskIndex.index].FirstCycle THEN
//Initial default values:
GVL.astAxes[1].stControl.fVelocity := GVL.astAxes[1].stConfig.fVelocityDefaultSlow;
GVL.astAxes[1].stConfig.eHomeSeq := 0;
GVL.astAxes[1].stConfig.fHomePosition := 0.0;
GVL.astAxes[1].stConfig.fHomeFinishDistance := 0.0;
END_IF*)
//Define ACTIONS() or write exclusive code for an specific axis.
//Eg. Stop when temperature reaches certain values, reduce speed if a signal is activated, etc.
]]></ST>
</Implementation>
<LineIds Name="Axis_Template">
<LineId Id="20" Count="0" />
<LineId Id="5" Count="0" />
<LineId Id="13" Count="0" />
<LineId Id="15" Count="0" />
<LineId Id="17" Count="2" />
<LineId Id="14" Count="0" />
<LineId Id="22" Count="0" />
<LineId Id="21" Count="0" />
<LineId Id="24" Count="0" />
<LineId Id="23" Count="0" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<POU Name="MAIN" Id="{33eb6f49-7781-4211-a70b-87ada6d80cb7}" SpecialFunc="None">
<Declaration><![CDATA[
PROGRAM MAIN
<Declaration><![CDATA[PROGRAM MAIN
VAR
sVersion: STRING := '1.0.0';
afbAxes: ARRAY [1..GVL_APP.nAXIS_NUM] OF FB_Axis;
@@ -36,13 +35,17 @@ VAR PERSISTENT
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[POSITION_RECOVERY();
PROG();
AXES();]]></ST>
AXES();
PROG();]]></ST>
</Implementation>
<Folder Name="POSITION_RECOVERY" Id="{3561f6ef-e145-4ed3-9839-f17334bd2d97}" />
<Action Name="AXES" Id="{7eb32732-9b53-4934-8cd9-20ba971dd8ff}">
<Implementation>
<ST><![CDATA[FOR GVL.iAxis := 1 TO GVL_APP.nAXIS_NUM DO
<ST><![CDATA[//Get task index for Axes parameters initialization.
GVL.fbGetCurTaskIndex();
//Create an stAxisStruct for every axis in the project.
FOR GVL.iAxis := 1 TO GVL_APP.nAXIS_NUM DO
afbAxes[GVL.iAxis](stAxisStruct := GVL.astAxes[GVL.iAxis]);
END_FOR]]></ST>
</Implementation>
@@ -75,7 +78,14 @@ END_IF]]></ST>
</Action>
<Action Name="PROG" Id="{5d03ebbb-2a47-4890-ad6d-e82daf72dc51}">
<Implementation>
<ST><![CDATA[//Program any sequence, safety or feature (if necessary) application specific in thsi section]]></ST>
<ST><![CDATA[//Call the programs that are defined in the "Application Specific" folder.
//Create as many programs in that folder as axes and applications you have or need
//Axes initial parameters and program
Axis_Template();
//Application program calls
Application_Template();]]></ST>
</Implementation>
</Action>
<Action Name="RESTORE_POSITIONS" Id="{0c7ee537-7bd9-4833-b428-c17cbb57e893}" FolderPath="POSITION_RECOVERY\">
@@ -204,10 +214,12 @@ END_FOR]]></ST>
</Action>
<LineIds Name="MAIN">
<LineId Id="505" Count="0" />
<LineId Id="134" Count="0" />
<LineId Id="81" Count="0" />
<LineId Id="538" Count="0" />
</LineIds>
<LineIds Name="MAIN.AXES">
<LineId Id="11" Count="1" />
<LineId Id="14" Count="1" />
<LineId Id="1" Count="0" />
<LineId Id="4" Count="0" />
<LineId Id="10" Count="0" />
@@ -221,7 +233,13 @@ END_FOR]]></ST>
<LineId Id="1" Count="0" />
</LineIds>
<LineIds Name="MAIN.PROG">
<LineId Id="2" Count="0" />
<LineId Id="4" Count="1" />
<LineId Id="7" Count="0" />
<LineId Id="6" Count="0" />
<LineId Id="8" Count="0" />
<LineId Id="10" Count="0" />
<LineId Id="9" Count="0" />
<LineId Id="3" Count="0" />
</LineIds>
<LineIds Name="MAIN.RESTORE_POSITIONS">
<LineId Id="567" Count="105" />

View File

@@ -27,6 +27,12 @@
<Compile Include="PlcTask.TcTTO">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Application Specific\Applications\Application_Template.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Application Specific\Axes\Axis_Template.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\MAIN.TcPOU">
<SubType>Code</SubType>
</Compile>
@@ -128,6 +134,9 @@
<ItemGroup>
<Folder Include="DUTs" />
<Folder Include="GVLs" />
<Folder Include="POUs\Application Specific" />
<Folder Include="POUs\Application Specific\Applications" />
<Folder Include="POUs\Application Specific\Axes" />
<Folder Include="tc_mca_std_lib\POUs\Motion\Homing" />
<Folder Include="tc_mca_std_lib\VISUs" />
<Folder Include="Test" />
@@ -238,8 +247,8 @@
<ProjectExtensions>
<PlcProjectOptions>
<XmlArchive>
<Data>
<o xml:space="preserve" t="OptionKey">
<Data>
<o xml:space="preserve" t="OptionKey">
<v n="Name">"&lt;ProjectRoot&gt;"</v>
<d n="SubKeys" t="Hashtable" ckt="String" cvt="OptionKey">
<v>{192FAD59-8248-4824-A8DE-9177C94C195A}</v>
@@ -290,15 +299,15 @@
</d>
<d n="Values" t="Hashtable" />
</o>
</Data>
<TypeList>
<Type n="Boolean">System.Boolean</Type>
<Type n="Hashtable">System.Collections.Hashtable</Type>
<Type n="Int32">System.Int32</Type>
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
<Type n="String">System.String</Type>
</TypeList>
</XmlArchive>
</Data>
<TypeList>
<Type n="Boolean">System.Boolean</Type>
<Type n="Hashtable">System.Collections.Hashtable</Type>
<Type n="Int32">System.Int32</Type>
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
<Type n="String">System.String</Type>
</TypeList>
</XmlArchive>
</PlcProjectOptions>
</ProjectExtensions>
</Project>

View File

@@ -2,7 +2,7 @@ import glob
import xml.etree.ElementTree as ET
VERSION_TAGS = {"**/*.Tc*": "ProductVersion", "**/*.tsproj": "TcVersion"}
CORRECT_VERSIONS = {"**/*.Tc*": "3.1.4024.5", "**/*.tsproj": "3.1.4023.119"}
CORRECT_VERSIONS = {"**/*.Tc*": "3.1.4024.5", "**/*.tsproj": "3.1.4024.11"}
def check_versions():