diff --git a/.gitattributes b/.gitattributes index 31f31e7..d78faef 100755 --- a/.gitattributes +++ b/.gitattributes @@ -11,8 +11,23 @@ # Tc files must be CRLF *.plcproj text eol=crlf -*.Tc* text eol=crlf -*.tsproj text eol=crlf +*.Tc* text eol=crlf filter=cleanCode +*.tsproj text eol=crlf filter=ignoreNetId *.txt text eol=crlf *.xml text eol=crlf *.xti text eol=crlf + + +# Configure the following in TwinCAT: +# TOOLS -> Options -> TwinCAT -> PLC Environment -> Write Options -> Separate LineIDS : True +# To activate the filter, run +#git config filter.ignoreNetId.clean 'sed -b -f filter/ignoreTargetNetId.sed' +#git config filter.cleanCode.clean 'sed -b -f filter/cleanCode.sed' + +# the check if the filter is there by running +# cat ../../../../.git/modules/solution/tc_project_app/tc_pils/tc_pils_generic/config + +#[filter "ignoreNetId"] +# clean = sed -f filter/ignoreTargetNetId.sed +#[filter "cleanCode"] +# clean = sed -f filter/cleanCode.sed diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 873f48c..3412348 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,10 +1,13 @@ -image: python:3.7.3 -options: - max-time: 1 -pipelines: - default: - - step: - script: - - git submodule update --init - - python twincat_version_manager.py - - python check_fix_white_space.py +image: python:3.7.3 +options: + max-time: 1 +pipelines: + default: + - step: + script: + - git submodule update --init + - python twincat_version_manager.py + - python check_fix_white_space.py + - ./check_no_lineids.sh + - ./check_code_before_sq_brackets.sh + diff --git a/check_code_before_sq_brackets.sh b/check_code_before_sq_brackets.sh new file mode 100755 index 0000000..2d0403f --- /dev/null +++ b/check_code_before_sq_brackets.sh @@ -0,0 +1,6 @@ +#!/bin/sh +git grep '.\]\]>' *.Tc* +if test $? -ne 1; then + echo >&2 "code before double square brackets found" + exit 1 +fi diff --git a/check_no_lineids.sh b/check_no_lineids.sh new file mode 100755 index 0000000..eefb9ea --- /dev/null +++ b/check_no_lineids.sh @@ -0,0 +1,6 @@ +#!/bin/sh +git grep '&2 "LineIds found" + exit 1 +fi diff --git a/filter/cleanCode.sed b/filter/cleanCode.sed new file mode 100644 index 0000000..2daf757 --- /dev/null +++ b/filter/cleanCode.sed @@ -0,0 +1,10 @@ +# remove LineIds +//s/]]>/\r\n]]>/g +# convert tab to space +/\t/s/\t/ /g +# remove trailing space +s/[[:blank:]]*$// +s/[[:blank:]]*\r$/\r/ diff --git a/filter/gitconfig b/filter/gitconfig new file mode 100644 index 0000000..0fc59d6 --- /dev/null +++ b/filter/gitconfig @@ -0,0 +1,5 @@ +[filter "ignoreNetId"] + clean = sed -b -f filter/ignoreTargetNetId.sed +[filter "cleanCode"] + clean = sed -b -f filter/cleanCode.sed + diff --git a/filter/ignoreTargetNetId.sed b/filter/ignoreTargetNetId.sed new file mode 100644 index 0000000..8610381 --- /dev/null +++ b/filter/ignoreTargetNetId.sed @@ -0,0 +1 @@ +s/}\" TargetNetId=\"[0-9.]+\"/}\" /g diff --git a/solution/tc_project_app/GVLs/GVL_APP.TcGVL b/solution/tc_project_app/GVLs/GVL_APP.TcGVL index b8e952e..f6150d2 100644 --- a/solution/tc_project_app/GVLs/GVL_APP.TcGVL +++ b/solution/tc_project_app/GVLs/GVL_APP.TcGVL @@ -8,6 +8,7 @@ END_VAR VAR_GLOBAL CONSTANT nAXIS_NUM: UINT := 0; (*~ (OPC: 1 : available for OPC-clients)(OPC_PROP[0005]: 1 : OPC_PROP_RIGHTS, here read only)*) nPNEUMATIC_AXIS_NUM: UINT := 0; -END_VAR]]> +END_VAR +]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU index d653e82..dd7adb2 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Applications/Application_Template.TcPOU @@ -8,7 +8,8 @@ END_VAR ]]> +//Eg. Collision avoidance, interlocks, sequencing, etc. +]]> \ No newline at end of file diff --git a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU index 5e9edcc..0944ca1 100644 --- a/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU +++ b/solution/tc_project_app/POUs/Application_Specific/Axes/Axis_Template.TcPOU @@ -8,7 +8,8 @@ VAR //Hardware interlocks //bInterlockFwdOK AT %I*: BOOL; -END_VAR]]> +END_VAR +]]> +Eg. GVL.astAxes[x].stControl.bInterlockFwd := NOT bInterlockFwdOK;*) +]]> \ 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 76d2080..462b081 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -27,11 +27,13 @@ END_VAR VAR PERSISTENT bRestoreOnStartup: BOOL; -END_VAR]]> +END_VAR +]]> +AXES(); +]]> @@ -56,7 +58,8 @@ END_FOR //Execute Pneumatic Axis logic FOR GVL.iPneumaticAxis := 1 TO GVL_APP.nPNEUMATIC_AXIS_NUM DO afbPneumaticAxes[GVL.iPneumaticAxis](stPneumaticAxisStruct := GVL.astPneumaticAxes[GVL.iPneumaticAxis]); -END_FOR]]> +END_FOR +]]> @@ -83,7 +86,8 @@ ELSIF eGlobalSUpsState <> eSUPS_PowerOK THEN //next cycles of powerfailure //skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown... RETURN; -END_IF]]> +END_IF +]]> @@ -92,7 +96,8 @@ END_IF]]> IF (fbGetDeviceIdentification.stDevIdent.strHardwareSerialNo <> '') THEN CHECK_UPS(); RESTORE_POSITIONS(); -END_IF]]> +END_IF +]]> @@ -108,7 +113,8 @@ GVL.fbGetCurTaskIndex(); //Pneumatics_Template(); //Application program calls -//Application_Template();]]> +//Application_Template(); +]]> @@ -260,7 +266,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN bRestoreExecute := FALSE; END_FOR END_CASE -END_IF]]> +END_IF +]]> @@ -278,7 +285,8 @@ END_IF]]> ELSE astAxesPersistent[iAxes].bMovingAtShutdown := TRUE; END_IF -END_FOR]]> +END_FOR +]]>