From 442f8400657d88fc608719428fbbfd325112f923 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 17:07:29 +0100 Subject: [PATCH 01/27] First try at running a pipeline --- pipeline.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pipeline.py diff --git a/pipeline.py b/pipeline.py new file mode 100644 index 0000000..e69de29 From 48788d138fbbaf532d22ecbf49af2257759d802d Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 17:09:09 +0100 Subject: [PATCH 02/27] Add pipeline yaml --- bitbucket-pipelines.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 bitbucket-pipelines.yml diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml new file mode 100644 index 0000000..e69de29 From cf5349dced72b364875ef8a2e28e51b5c0778851 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 17:11:57 +0100 Subject: [PATCH 03/27] Allow pipeline to be run manually --- bitbucket-pipelines.yml | 9 +++++++++ pipeline.py | 2 ++ 2 files changed, 11 insertions(+) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index e69de29..9a5f522 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -0,0 +1,9 @@ +image: python:3.7.3 + +pipelines: + custom: + - step: + caches: + - pip + script: + - python pipeline.py \ No newline at end of file diff --git a/pipeline.py b/pipeline.py index e69de29..bbff9c0 100644 --- a/pipeline.py +++ b/pipeline.py @@ -0,0 +1,2 @@ +if __name__ == "__main__": + exit(1) # Fail the pipeline From 1946724be1c6837940b71cac3466a49d8a61d0c4 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 17:15:21 +0100 Subject: [PATCH 04/27] Fix syntax error --- bitbucket-pipelines.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 9a5f522..b951f5d 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -2,8 +2,9 @@ image: python:3.7.3 pipelines: custom: - - step: - caches: - - pip - script: - - python pipeline.py \ No newline at end of file + check_version: + - step: + caches: + - pip + script: + - python pipeline.py \ No newline at end of file From 517bd5dc4e352d2510485e2c1a0e0466e05f67f3 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 18:18:44 +0100 Subject: [PATCH 05/27] Pipeline now checks versions --- pipeline.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/pipeline.py b/pipeline.py index bbff9c0..ef88205 100644 --- a/pipeline.py +++ b/pipeline.py @@ -1,2 +1,36 @@ +import glob +import xml.etree.ElementTree as ET +import os + +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: + print("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__": - exit(1) # Fail the pipeline + incorrect_files = check_versions() + for file, version in incorrect_files.items(): + print("ERROR: {} has incorrect version {}, expected version {}".format(file, version, CORRECT_VERSION)) + exit(len(incorrect_files)) # Exit with non-zero if any bad versions were found From b2b97f583cd0d1b90687a537b546dd61858fdb2b Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 18:23:32 +0100 Subject: [PATCH 06/27] Should now do submodules --- bitbucket-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index b951f5d..e262282 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -7,4 +7,5 @@ pipelines: caches: - pip script: + - git submodule update --init - python pipeline.py \ No newline at end of file From adff4d92d30beca10234d4d30e503896674cdda6 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 18:25:39 +0100 Subject: [PATCH 07/27] Just confirm we can pass a test --- pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline.py b/pipeline.py index ef88205..33fe5e1 100644 --- a/pipeline.py +++ b/pipeline.py @@ -33,4 +33,4 @@ if __name__ == "__main__": incorrect_files = check_versions() for file, version in incorrect_files.items(): print("ERROR: {} has incorrect version {}, expected version {}".format(file, version, CORRECT_VERSION)) - exit(len(incorrect_files)) # Exit with non-zero if any bad versions were found + exit(0) # Exit with non-zero if any bad versions were found From 81b5d1f1dce0999d876e0edaae4d4ccfd4d980dc Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 18:38:05 +0100 Subject: [PATCH 08/27] Only do on PR --- bitbucket-pipelines.yml | 9 ++++----- pipeline.py => twincat_version_manager.py | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) rename pipeline.py => twincat_version_manager.py (91%) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index e262282..32f33bd 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,11 +1,10 @@ image: python:3.7.3 - +options: + max-time: 1 pipelines: custom: - check_version: + pull-requests: - step: - caches: - - pip script: - git submodule update --init - - python pipeline.py \ No newline at end of file + - python twincat_version_manager.py \ No newline at end of file diff --git a/pipeline.py b/twincat_version_manager.py similarity index 91% rename from pipeline.py rename to twincat_version_manager.py index 33fe5e1..58d9f07 100644 --- a/pipeline.py +++ b/twincat_version_manager.py @@ -1,6 +1,5 @@ import glob import xml.etree.ElementTree as ET -import os VERSION_TAGS = {"**/*.Tc*": "ProductVersion", "**/*.tsproj": "TcVersion"} CORRECT_VERSION = "3.1.4024.0" @@ -33,4 +32,4 @@ if __name__ == "__main__": incorrect_files = check_versions() for file, version in incorrect_files.items(): print("ERROR: {} has incorrect version {}, expected version {}".format(file, version, CORRECT_VERSION)) - exit(0) # Exit with non-zero if any bad versions were found + exit(len(incorrect_files)) # Exit with non-zero if any bad versions were found From edbb3e8cdbe190aa142dd134657d3f3635f9291a Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 18:51:00 +0100 Subject: [PATCH 09/27] Try and fix for pipelines --- bitbucket-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 32f33bd..f3e3890 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -2,8 +2,8 @@ image: python:3.7.3 options: max-time: 1 pipelines: - custom: - pull-requests: + pull-requests: + '**': - step: script: - git submodule update --init From 0adff94a4633938c36b9121b75801c2a130f70ea Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 23:13:43 +0100 Subject: [PATCH 10/27] Updated version --- solution/solution.tsproj | 137 ++++++------------ solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- solution/tc_project_app/GlobalTextList.TcGTLO | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 2 +- solution/tc_project_app/PlcTask.TcTTO | 2 +- .../Visualization Manager.TcVMO | 2 +- solution/tc_project_app/tc_mca_std_lib | 2 +- 7 files changed, 48 insertions(+), 101 deletions(-) diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 9224788..d85e701 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,5 +1,5 @@ - - + + NCTOPLC_AXIS_REF_STATE @@ -411,8 +411,7 @@ AxisState UDINT - - - +]]> 32 64 @@ -440,8 +438,7 @@ External Setpoint Generation: HomingState UDINT - - - +]]> 32 128 CoupleState UDINT - - - +]]> 32 160 @@ -690,13 +684,13 @@ External Setpoint Generation: NCAXLESTRUCT_TOPLC4 - + - + - + @@ -913,30 +907,22 @@ External Setpoint Generation: PlcTask Inputs GVL.axes[1].inputs.bLimitFwd - - - + BOOL GVL.axes[1].inputs.bLimitBwd - - - + BOOL GVL.axes[1].inputs.bHomeSensor - - - + BOOL GVL.axes[1].inputs.bEncLAtch - - - + BOOL @@ -944,8 +930,7 @@ External Setpoint Generation: NCTOPLC_AXIS_REF AxisState - - - +]]> HomingState - - - +]]> CoupleState - - - +]]> GVL.axes[2].inputs.bLimitFwd - - - + BOOL GVL.axes[2].inputs.bLimitBwd - - - + BOOL GVL.axes[2].inputs.bHomeSensor - - - + BOOL GVL.axes[2].inputs.bEncLAtch - - - + BOOL @@ -1021,8 +993,7 @@ External Setpoint Generation: NCTOPLC_AXIS_REF AxisState - - - +]]> HomingState - - - +]]> CoupleState - - - +]]> GVL.axes[3].inputs.bLimitFwd - - - + BOOL GVL.axes[3].inputs.bLimitBwd - - - + BOOL GVL.axes[3].inputs.bHomeSensor - - - + BOOL GVL.axes[3].inputs.bEncLAtch - - - + BOOL @@ -1098,8 +1056,7 @@ External Setpoint Generation: NCTOPLC_AXIS_REF AxisState - - - +]]> HomingState - - - +]]> CoupleState - - - +]]> @@ -1147,9 +1099,7 @@ External Setpoint Generation: PlcTask Outputs MAIN.bOutput1 - - - + BOOL @@ -1172,7 +1122,4 @@ External Setpoint Generation: - - - diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index a366e64..2d96afa 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -1,5 +1,5 @@  - + - + diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 1b367f8..50890c8 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -1,5 +1,5 @@  - + - + 1000 diff --git a/solution/tc_project_app/Visualization Manager.TcVMO b/solution/tc_project_app/Visualization Manager.TcVMO index d2e340f..83b1ee8 100644 --- a/solution/tc_project_app/Visualization Manager.TcVMO +++ b/solution/tc_project_app/Visualization Manager.TcVMO @@ -1,5 +1,5 @@  - + diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index f2b1862..7003429 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit f2b186273119f71345ff25367b3145b07dfa66f4 +Subproject commit 7003429e2198b2e194ecb0583c6ea4ec83b898ec From 1d3a7d6c590d6f39d07feccaa71f569011167ce5 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 23:18:38 +0100 Subject: [PATCH 11/27] Updated version --- solution/solution.tsproj | 2 +- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 2 +- solution/tc_project_app/GlobalTextList.TcGTLO | 2 +- solution/tc_project_app/POUs/MAIN.TcPOU | 2 +- solution/tc_project_app/PlcTask.TcTTO | 2 +- solution/tc_project_app/Visualization Manager.TcVMO | 2 +- solution/tc_project_app/tc_mca_std_lib | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 9224788..3678528 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,5 +1,5 @@ - + NCTOPLC_AXIS_REF_STATE diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index a366e64..2d96afa 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -1,5 +1,5 @@  - + - + diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 1b367f8..50890c8 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -1,5 +1,5 @@  - + - + 1000 diff --git a/solution/tc_project_app/Visualization Manager.TcVMO b/solution/tc_project_app/Visualization Manager.TcVMO index d2e340f..83b1ee8 100644 --- a/solution/tc_project_app/Visualization Manager.TcVMO +++ b/solution/tc_project_app/Visualization Manager.TcVMO @@ -1,5 +1,5 @@  - + diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index f2b1862..7003429 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit f2b186273119f71345ff25367b3145b07dfa66f4 +Subproject commit 7003429e2198b2e194ecb0583c6ea4ec83b898ec From 1579c29d6f2dd930457cea3d03bc0566ff5a3901 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 23:20:39 +0100 Subject: [PATCH 12/27] Updated version --- solution/tc_epicscommodule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_epicscommodule b/solution/tc_epicscommodule index 6c86fc4..8692633 160000 --- a/solution/tc_epicscommodule +++ b/solution/tc_epicscommodule @@ -1 +1 @@ -Subproject commit 6c86fc4bd9250add709323079d3c84c63790648b +Subproject commit 8692633c02b4cb0da8bc7fd9f12513ec3c4ce086 From 7f9e9feff5947399857fceda2bf377fafdc90b95 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 11 Oct 2019 23:24:09 +0100 Subject: [PATCH 13/27] Updated submodules --- solution/tc_epicscommodule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_epicscommodule b/solution/tc_epicscommodule index 8692633..370c81a 160000 --- a/solution/tc_epicscommodule +++ b/solution/tc_epicscommodule @@ -1 +1 @@ -Subproject commit 8692633c02b4cb0da8bc7fd9f12513ec3c4ce086 +Subproject commit 370c81aa67f1a39bac865b098d611720ebc82d7b From 9ba0d7a67e42c5f0c5b6c396427365a8467ec7e7 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Mon, 14 Oct 2019 18:01:29 +0100 Subject: [PATCH 14/27] Provide better error codes --- twincat_version_manager.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/twincat_version_manager.py b/twincat_version_manager.py index 58d9f07..3483331 100644 --- a/twincat_version_manager.py +++ b/twincat_version_manager.py @@ -16,7 +16,7 @@ def check_versions(): for file_path, version_attrib in VERSION_TAGS.items(): found_files = glob.glob(file_path, recursive=True) if not found_files: - print("ERROR: No files of type {} found".format(file_path)) + raise IOError("ERROR: No files of type {} found".format(file_path)) for file in found_files: tree = ET.parse(file) try: @@ -29,7 +29,12 @@ def check_versions(): if __name__ == "__main__": - incorrect_files = check_versions() - for file, version in incorrect_files.items(): - print("ERROR: {} has incorrect version {}, expected version {}".format(file, version, CORRECT_VERSION)) - exit(len(incorrect_files)) # Exit with non-zero if any bad versions were found + 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) From d57ad738ee66967c9dc7cd415c78028ba8a4c74a Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Mon, 14 Oct 2019 18:12:31 +0100 Subject: [PATCH 15/27] Attempt to fix bitbucket being wierd --- twincat_version_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/twincat_version_manager.py b/twincat_version_manager.py index 3483331..120547e 100644 --- a/twincat_version_manager.py +++ b/twincat_version_manager.py @@ -29,6 +29,7 @@ def check_versions(): if __name__ == "__main__": + exit(0) try: incorrect_files = check_versions() for file, version in incorrect_files.items(): From eeeaf8a3a1c8cb27462d85ce6d3447302cf8e071 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Mon, 14 Oct 2019 18:17:55 +0100 Subject: [PATCH 16/27] Fix exit codes --- twincat_version_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/twincat_version_manager.py b/twincat_version_manager.py index 120547e..3483331 100644 --- a/twincat_version_manager.py +++ b/twincat_version_manager.py @@ -29,7 +29,6 @@ def check_versions(): if __name__ == "__main__": - exit(0) try: incorrect_files = check_versions() for file, version in incorrect_files.items(): From 9a0b8e98cc2637ac421609a2443630d8eb1a7d87 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 15 Oct 2019 14:04:02 +0200 Subject: [PATCH 17/27] Update tc_epicscommodule to master for new 3024.0 --- solution/tc_epicscommodule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_epicscommodule b/solution/tc_epicscommodule index 6c86fc4..3794bb7 160000 --- a/solution/tc_epicscommodule +++ b/solution/tc_epicscommodule @@ -1 +1 @@ -Subproject commit 6c86fc4bd9250add709323079d3c84c63790648b +Subproject commit 3794bb7a9801d08901fe8efcf3e103582b5d7e2c From 8ced80123e8c9efb648db6e6160c8b52fbff4d50 Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Tue, 15 Oct 2019 14:05:11 +0200 Subject: [PATCH 18/27] Update tc_mca_std_lib to version 3024.0 --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index 7003429..c74a21a 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit 7003429e2198b2e194ecb0583c6ea4ec83b898ec +Subproject commit c74a21a99d2749be86a12e4406bbfcfbb3618841 From 5644dd9bb77e8fdebca01b994b99084ea72d3a6d Mon Sep 17 00:00:00 2001 From: Federico Rojas Date: Wed, 16 Oct 2019 11:35:02 +0200 Subject: [PATCH 19/27] Update Hardware FB for the latest version from Viktor Heirich and 4024.0 Some FB in the Etercat Termianls folder were not the latest version They were replaced by the latest version according to the developer Viktor Heirich# Please enter the commit message for your changes. Lines starting --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index c74a21a..afc8c96 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit c74a21a99d2749be86a12e4406bbfcfbb3618841 +Subproject commit afc8c964ba035d22f55f2ead68c3ab38f62eb7ba From df8fd4f4be640391ba860bb9c1bdeeaa9d064568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 08:16:29 +0100 Subject: [PATCH 20/27] Add check_fix_white_space.py Make it possible to check for whitespace-damage: - a file uses TAB instead of space - a file has trailing whitespace e.g. "text on this line \n" instead of "text on this line\n" Both make reviews unnecessary hard and may lead to merge conflicts, which could be easily avoided. In the next commit this script will be added to the continous integration. --- check_fix_white_space.py | 96 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 check_fix_white_space.py diff --git a/check_fix_white_space.py b/check_fix_white_space.py new file mode 100755 index 0000000..cf6fe3c --- /dev/null +++ b/check_fix_white_space.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 + +# +# Script to fix whithespace errors in files +# All trailing white space are removed +# TAB are replace by spaces +# +import glob +import sys + +file_patterns_tab_width = {"**/*.Tc*": 4, + "**/*.py": 4, + "**/*.sh": 8} +def fix_white_space(debug, fix_files): + """ + Checks the Twincat source code for white space: + TAB should not be used + Trailing SPACE shoulf not be there. + :return: A dictionary of white-space-damaged files + """ + incorrect_files = dict() + for file_path, tab_width in file_patterns_tab_width.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 pathname in found_files: + dirty = False + new_lines = [] + if debug >= 1: + print("tab_with=%d pathname=%s" % (tab_width, pathname)) + file = open(pathname, 'r', newline='', encoding="iso-8859-1") + lines = file.readlines() + file.close() + for old_line in lines: + had_crlf = 0 + this_line_dirty = False + if old_line.endswith('\r\n'): + had_crlf = 2 # Both CR and LF + elif old_line.endswith('\n'): + had_crlf = 1 # LF + # Convert all TAB into SPACE + new_line = old_line.expandtabs(tabsize=tab_width) + # Strip of all trailing white space, including the CRLF + new_line = new_line.rstrip("\r\n ") + if had_crlf == 2: + new_line = new_line + '\r\n' + elif had_crlf == 1: + new_line = new_line + '\n' + + if len(new_line) != len(old_line): + dirty = True + this_line_dirty = True + new_lines.append(new_line) + if this_line_dirty: + if debug >= 2: + print("had_crlf=%d" % had_crlf) + print("old_line=%s" % old_line) + print("new_line=%s" % new_line) + # end of loop of all line in one file + if debug >= 1: + print("pathname=%s dirty=%d" % (pathname, dirty)) + if dirty: + incorrect_files[pathname] = True + if fix_files: + file = open(pathname, 'w', newline='', encoding="iso-8859-1") + file.writelines(new_lines) + file.close() + + return incorrect_files + + +if __name__ == "__main__": + try: + argc = len(sys.argv) + arg_idx = 1 + debug = 0 + fix_files = False + while arg_idx < argc: + if sys.argv[arg_idx] == "--fix": + fix_files = True + elif sys.argv[arg_idx] == "--debug": + debug = debug + 1 + else: + print("%s : [--fix|--debug]" % sys.argv[0]) + exit(2) + arg_idx = arg_idx + 1 + incorrect_files = fix_white_space(debug, fix_files) + if not fix_files: + for file in incorrect_files: + print("ERROR: '{}' has white space damage".format(file)) + if incorrect_files: + exit(1) + except IOError as e: + print(e) # Likely no files found + exit(2) From 2004342dd345de0f6b4183059a1d62a2eb542f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 08:23:40 +0100 Subject: [PATCH 21/27] bitbucket-pipelines.yml: Activate check_fix_white_space.py --- bitbucket-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index f3e3890..093b1f2 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -7,4 +7,5 @@ pipelines: - step: script: - git submodule update --init - - python twincat_version_manager.py \ No newline at end of file + - python twincat_version_manager.py + - python check_fix_white_space.py From 7ce75ac945cd4338f6f9f3b1f7382511b820755d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 09:28:54 +0100 Subject: [PATCH 22/27] bitbucket-pipelines.yml: Change pipline from pull-request to default Allways run the pipeline, for each push, not only pull-requests. This should detect problems early, --- bitbucket-pipelines.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 093b1f2..873f48c 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -2,9 +2,8 @@ image: python:3.7.3 options: max-time: 1 pipelines: - pull-requests: - '**': - - step: + default: + - step: script: - git submodule update --init - python twincat_version_manager.py From 9facfb89c1661dce09f7017fae080a865906c0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 09:43:45 +0100 Subject: [PATCH 23/27] Update tc_epicscommodule to a white+space clean version --- solution/tc_epicscommodule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_epicscommodule b/solution/tc_epicscommodule index 3794bb7..ee4d3b9 160000 --- a/solution/tc_epicscommodule +++ b/solution/tc_epicscommodule @@ -1 +1 @@ -Subproject commit 3794bb7a9801d08901fe8efcf3e103582b5d7e2c +Subproject commit ee4d3b9b86675f4b0ab652681ea9c87aa5fd41b7 From bef8078e9903560186d68c8520046f67ab8194d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 09:45:53 +0100 Subject: [PATCH 24/27] Fix whitespace damage Fix the whitespaces using check_fix_white_space.py modified: solution/tc_project_app/GVLs/GVL_APP.TcGVL modified: solution/tc_project_app/POUs/MAIN.TcPOU --- solution/tc_project_app/GVLs/GVL_APP.TcGVL | 6 +- solution/tc_project_app/POUs/MAIN.TcPOU | 116 ++++++++++----------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index 2d96afa..a846a85 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -3,12 +3,12 @@ \ No newline at end of file diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 50890c8..d74f2d1 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -3,43 +3,43 @@ @@ -52,7 +52,7 @@ ERROR();]]> , - nSelectedError=> , - pErrorSystem=> ); + En:= TRUE, + bReset:= , + nErrorNum:= , + bACK:= , + bValidSelection:= , + nTableRowIndex:= , + EnO=> , + nSelectedError=> , + pErrorSystem=> ); FOR GVL.iAxis:=1 TO gvl_app.axisNum DO - aFbAxesError[gvl.iAxis](EN:=TRUE, - nNC_ErrorID:= gvl.axes[gvl.iAxis].status.nErrorID, - nNC_AxisID:=gvl.axes[gvl.iAxis].Axis.NcToPlc.AxisId, - ErrorSystem:= fbErrorSystem.pErrorSystem); + aFbAxesError[gvl.iAxis](EN:=TRUE, + nNC_ErrorID:= gvl.axes[gvl.iAxis].status.nErrorID, + nNC_AxisID:=gvl.axes[gvl.iAxis].Axis.NcToPlc.AxisId, + ErrorSystem:= fbErrorSystem.pErrorSystem); END_FOR - - + + (*call all the necessary instance (input assistance F2 or right click) according to the terminals that you have in your hardware and - add "TRUE" in the input En, the corresponding number of termianl to the iTerminal_ID and -the variable "fbErrorSystem.pErrorSystem" to the input ErrorSystem in each FB E. g. : + add "TRUE" in the input En, the corresponding number of termianl to the iTerminal_ID and +the variable "fbErrorSystem.pErrorSystem" to the input ErrorSystem in each FB E. g. : fbEL1808( - En:= TRUE, - iTerminal_ID:= 01, - ErrorSystem:= fbErorSystem.pErrorSystem, - EnO=> , - bError=> ); + En:= TRUE, + iTerminal_ID:= 01, + ErrorSystem:= fbErorSystem.pErrorSystem, + EnO=> , + bError=> ); *) ]]> From 69f8fc469605c131b366e4b870f0ef7dc5c956ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 10:56:07 +0100 Subject: [PATCH 25/27] solution/tc_epicscommodule updated to 3.1.4024.0 --- solution/tc_epicscommodule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_epicscommodule b/solution/tc_epicscommodule index ee4d3b9..e746bc4 160000 --- a/solution/tc_epicscommodule +++ b/solution/tc_epicscommodule @@ -1 +1 @@ -Subproject commit ee4d3b9b86675f4b0ab652681ea9c87aa5fd41b7 +Subproject commit e746bc4b801554a2af3cc5432f9374ffc9fbd82b From 403b1c92969846e6e5b59bc74d8153222e4f2251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 11:44:53 +0100 Subject: [PATCH 26/27] bitbucket-pipelines.yml: Print status of `git submodule` --- bitbucket-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 873f48c..d47cd1d 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -6,5 +6,6 @@ pipelines: - step: script: - git submodule update --init + - git submodule - python twincat_version_manager.py - python check_fix_white_space.py From 4b2302d0d45ed8774130c05661f4ff5c673296a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Fri, 29 Nov 2019 11:51:27 +0100 Subject: [PATCH 27/27] Fix whitespace damage in solution/tc_project_app/tc_mca_std_lib --- solution/tc_project_app/tc_mca_std_lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/tc_project_app/tc_mca_std_lib b/solution/tc_project_app/tc_mca_std_lib index afc8c96..ce9f69f 160000 --- a/solution/tc_project_app/tc_mca_std_lib +++ b/solution/tc_project_app/tc_mca_std_lib @@ -1 +1 @@ -Subproject commit afc8c964ba035d22f55f2ead68c3ab38f62eb7ba +Subproject commit ce9f69ffdc2ac817ced936189f4550b65235025d