Merged in MBP-109-test-pipelines-for-twincat (pull request #14)

MBP-109 test pipelines for twincat
This commit is contained in:
Dominic Oram
2019-10-15 12:22:31 +00:00
committed by Federico Rojas
5 changed files with 92 additions and 95 deletions

10
bitbucket-pipelines.yml Normal file
View File

@@ -0,0 +1,10 @@
image: python:3.7.3
options:
max-time: 1
pipelines:
pull-requests:
'**':
- step:
script:
- git submodule update --init
- python twincat_version_manager.py

View File

@@ -411,8 +411,7 @@
<SubItem>
<Name>AxisState</Name>
<Type GUID="{18071995-0000-0000-0000-000000000008}">UDINT</Type>
<Comment>
<![CDATA[Present State Of The Axis Movement (continuous axis):
<Comment><![CDATA[Present State Of The Axis Movement (continuous axis):
0 = INACTIVE: axis has no job
1 = RUNNING: axis is executing a motion job
2 = OVERRIDE_ZERO: axis is executing a job but override is zero
@@ -426,8 +425,7 @@ Slaves only:
External Setpoint Generation:
41 = EXTSETGEN_MODE1: external setpoint generation active
42 = EXTSETGEN_MODE2: internal and external setpoint gen. active
]]>
</Comment>
]]></Comment>
<BitSize>32</BitSize>
<BitOffs>64</BitOffs>
</SubItem>
@@ -440,8 +438,7 @@ External Setpoint Generation:
<SubItem>
<Name>HomingState</Name>
<Type GUID="{18071995-0000-0000-0000-000000000008}">UDINT</Type>
<Comment>
<![CDATA[Axis Homing Status:
<Comment><![CDATA[Axis Homing Status:
0: idle
1: start homing
2: searching home switch
@@ -449,22 +446,19 @@ External Setpoint Generation:
4: moving off home switch
5: searching sync pulse
6: stopping after homing
]]>
</Comment>
]]></Comment>
<BitSize>32</BitSize>
<BitOffs>128</BitOffs>
</SubItem>
<SubItem>
<Name>CoupleState</Name>
<Type GUID="{18071995-0000-0000-0000-000000000008}">UDINT</Type>
<Comment>
<![CDATA[Axis Coupling Status:
<Comment><![CDATA[Axis Coupling Status:
0: axis is a single axis (not coupled)
1: axis is a master axis
2: axis is master and slave
3: axis is a slave axis
]]>
</Comment>
]]></Comment>
<BitSize>32</BitSize>
<BitOffs>160</BitOffs>
</SubItem>
@@ -690,13 +684,13 @@ External Setpoint Generation:
<Type GUID="{F794B740-82D7-4637-848E-4F74A711D038}">NCAXLESTRUCT_TOPLC4</Type>
</Relation>
<Relation Priority="100">
<Type GUID="{40BD39B0-C3EA-4F74-9F4F-5F1982786F7C}"/>
<Type GUID="{40BD39B0-C3EA-4F74-9F4F-5F1982786F7C}"></Type>
</Relation>
<Relation Priority="100">
<Type GUID="{40BD39B2-C3EA-4F74-9F4F-5F1982786F7C}"/>
<Type GUID="{40BD39B2-C3EA-4F74-9F4F-5F1982786F7C}"></Type>
</Relation>
<Relation Priority="100">
<Type GUID="{8CDE0C45-AB9D-42DB-BC94-1CF7521AB268}"/>
<Type GUID="{8CDE0C45-AB9D-42DB-BC94-1CF7521AB268}"></Type>
</Relation>
</Relations>
</DataType>
@@ -913,30 +907,22 @@ External Setpoint Generation:
<Name>PlcTask Inputs</Name>
<Var>
<Name>GVL.axes[1].inputs.bLimitFwd</Name>
<Comment>
<![CDATA[////Axis Inputs///////]]>
</Comment>
<Comment><![CDATA[////Axis Inputs///////]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[1].inputs.bLimitBwd</Name>
<Comment>
<![CDATA[Backward limit switch]]>
</Comment>
<Comment><![CDATA[Backward limit switch]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[1].inputs.bHomeSensor</Name>
<Comment>
<![CDATA[Reference siganl for homing]]>
</Comment>
<Comment><![CDATA[Reference siganl for homing]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[1].inputs.bEncLAtch</Name>
<Comment>
<![CDATA[Reference index signal from inc. enconder]]>
</Comment>
<Comment><![CDATA[Reference index signal from inc. enconder]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
@@ -944,8 +930,7 @@ External Setpoint Generation:
<Type GUID="{6A65C767-34E5-42BF-AD87-E1A503EAC7BE}" Namespace="MC">NCTOPLC_AXIS_REF</Type>
<SubVar>
<Name>AxisState</Name>
<Comment>
<![CDATA[Present State Of The Axis Movement (continuous axis):
<Comment><![CDATA[Present State Of The Axis Movement (continuous axis):
0 = INACTIVE: axis has no job
1 = RUNNING: axis is executing a motion job
2 = OVERRIDE_ZERO: axis is executing a job but override is zero
@@ -959,13 +944,11 @@ Slaves only:
External Setpoint Generation:
41 = EXTSETGEN_MODE1: external setpoint generation active
42 = EXTSETGEN_MODE2: internal and external setpoint gen. active
]]>
</Comment>
]]></Comment>
</SubVar>
<SubVar>
<Name>HomingState</Name>
<Comment>
<![CDATA[Axis Homing Status:
<Comment><![CDATA[Axis Homing Status:
0: idle
1: start homing
2: searching home switch
@@ -973,47 +956,36 @@ External Setpoint Generation:
4: moving off home switch
5: searching sync pulse
6: stopping after homing
]]>
</Comment>
]]></Comment>
</SubVar>
<SubVar>
<Name>CoupleState</Name>
<Comment>
<![CDATA[Axis Coupling Status:
<Comment><![CDATA[Axis Coupling Status:
0: axis is a single axis (not coupled)
1: axis is a master axis
2: axis is master and slave
3: axis is a slave axis
]]>
</Comment>
]]></Comment>
</SubVar>
</Var>
<Var>
<Name>GVL.axes[2].inputs.bLimitFwd</Name>
<Comment>
<![CDATA[////Axis Inputs///////]]>
</Comment>
<Comment><![CDATA[////Axis Inputs///////]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[2].inputs.bLimitBwd</Name>
<Comment>
<![CDATA[Backward limit switch]]>
</Comment>
<Comment><![CDATA[Backward limit switch]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[2].inputs.bHomeSensor</Name>
<Comment>
<![CDATA[Reference siganl for homing]]>
</Comment>
<Comment><![CDATA[Reference siganl for homing]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[2].inputs.bEncLAtch</Name>
<Comment>
<![CDATA[Reference index signal from inc. enconder]]>
</Comment>
<Comment><![CDATA[Reference index signal from inc. enconder]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
@@ -1021,8 +993,7 @@ External Setpoint Generation:
<Type GUID="{6A65C767-34E5-42BF-AD87-E1A503EAC7BE}" Namespace="MC">NCTOPLC_AXIS_REF</Type>
<SubVar>
<Name>AxisState</Name>
<Comment>
<![CDATA[Present State Of The Axis Movement (continuous axis):
<Comment><![CDATA[Present State Of The Axis Movement (continuous axis):
0 = INACTIVE: axis has no job
1 = RUNNING: axis is executing a motion job
2 = OVERRIDE_ZERO: axis is executing a job but override is zero
@@ -1036,13 +1007,11 @@ Slaves only:
External Setpoint Generation:
41 = EXTSETGEN_MODE1: external setpoint generation active
42 = EXTSETGEN_MODE2: internal and external setpoint gen. active
]]>
</Comment>
]]></Comment>
</SubVar>
<SubVar>
<Name>HomingState</Name>
<Comment>
<![CDATA[Axis Homing Status:
<Comment><![CDATA[Axis Homing Status:
0: idle
1: start homing
2: searching home switch
@@ -1050,47 +1019,36 @@ External Setpoint Generation:
4: moving off home switch
5: searching sync pulse
6: stopping after homing
]]>
</Comment>
]]></Comment>
</SubVar>
<SubVar>
<Name>CoupleState</Name>
<Comment>
<![CDATA[Axis Coupling Status:
<Comment><![CDATA[Axis Coupling Status:
0: axis is a single axis (not coupled)
1: axis is a master axis
2: axis is master and slave
3: axis is a slave axis
]]>
</Comment>
]]></Comment>
</SubVar>
</Var>
<Var>
<Name>GVL.axes[3].inputs.bLimitFwd</Name>
<Comment>
<![CDATA[////Axis Inputs///////]]>
</Comment>
<Comment><![CDATA[////Axis Inputs///////]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[3].inputs.bLimitBwd</Name>
<Comment>
<![CDATA[Backward limit switch]]>
</Comment>
<Comment><![CDATA[Backward limit switch]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[3].inputs.bHomeSensor</Name>
<Comment>
<![CDATA[Reference siganl for homing]]>
</Comment>
<Comment><![CDATA[Reference siganl for homing]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL.axes[3].inputs.bEncLAtch</Name>
<Comment>
<![CDATA[Reference index signal from inc. enconder]]>
</Comment>
<Comment><![CDATA[Reference index signal from inc. enconder]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
@@ -1098,8 +1056,7 @@ External Setpoint Generation:
<Type GUID="{6A65C767-34E5-42BF-AD87-E1A503EAC7BE}" Namespace="MC">NCTOPLC_AXIS_REF</Type>
<SubVar>
<Name>AxisState</Name>
<Comment>
<![CDATA[Present State Of The Axis Movement (continuous axis):
<Comment><![CDATA[Present State Of The Axis Movement (continuous axis):
0 = INACTIVE: axis has no job
1 = RUNNING: axis is executing a motion job
2 = OVERRIDE_ZERO: axis is executing a job but override is zero
@@ -1113,13 +1070,11 @@ Slaves only:
External Setpoint Generation:
41 = EXTSETGEN_MODE1: external setpoint generation active
42 = EXTSETGEN_MODE2: internal and external setpoint gen. active
]]>
</Comment>
]]></Comment>
</SubVar>
<SubVar>
<Name>HomingState</Name>
<Comment>
<![CDATA[Axis Homing Status:
<Comment><![CDATA[Axis Homing Status:
0: idle
1: start homing
2: searching home switch
@@ -1127,19 +1082,16 @@ External Setpoint Generation:
4: moving off home switch
5: searching sync pulse
6: stopping after homing
]]>
</Comment>
]]></Comment>
</SubVar>
<SubVar>
<Name>CoupleState</Name>
<Comment>
<![CDATA[Axis Coupling Status:
<Comment><![CDATA[Axis Coupling Status:
0: axis is a single axis (not coupled)
1: axis is a master axis
2: axis is master and slave
3: axis is a slave axis
]]>
</Comment>
]]></Comment>
</SubVar>
</Var>
</Vars>
@@ -1147,9 +1099,7 @@ External Setpoint Generation:
<Name>PlcTask Outputs</Name>
<Var>
<Name>MAIN.bOutput1</Name>
<Comment>
<![CDATA[*****Outputs: Power for Limit switches and Home Sensors (every 4th output)*******]]>
</Comment>
<Comment><![CDATA[*****Outputs: Power for Limit switches and Home Sensors (every 4th output)*******]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
@@ -1172,7 +1122,4 @@ External Setpoint Generation:
</Project>
</Plc>
</Project>
<Mappings>
<MappingInfo Identifier="{05000010-2041-0850-3000-040340205008}" Id="#x02030010" Watchdog="04000000080000000400000004000000"/>
</Mappings>
</TcSmProject>

View File

@@ -0,0 +1,40 @@
import glob
import xml.etree.ElementTree as ET
VERSION_TAGS = {"**/*.Tc*": "ProductVersion", "**/*.tsproj": "TcVersion"}
CORRECT_VERSION = "3.1.4024.0"
def check_versions():
"""
Checks the Twincat version used to create a file.
It assumes that the version is stored as an attribute on the top element of the file, the attribute names are
listed in VERSION_TAGS.
:return: A dictionary of incorrect files and their version numbers
"""
incorrect_files = dict()
for file_path, version_attrib in VERSION_TAGS.items():
found_files = glob.glob(file_path, recursive=True)
if not found_files:
raise IOError("ERROR: No files of type {} found".format(file_path))
for file in found_files:
tree = ET.parse(file)
try:
found_version = tree.getroot().attrib[version_attrib]
if found_version != CORRECT_VERSION:
incorrect_files[file] = found_version
except KeyError:
print("WARNING: No version found for {}".format(file))
return incorrect_files
if __name__ == "__main__":
try:
incorrect_files = check_versions()
for file, version in incorrect_files.items():
print("ERROR: {} has incorrect version {}, expected version {}".format(file, version, CORRECT_VERSION))
if incorrect_files:
exit(1)
except IOError as e:
print(e) # Likely no files found
exit(2)