diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 7c786ab..873f48c 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,11 +1,10 @@ -image: python:3.7.3 -options: - max-time: 1 -pipelines: - default: - - step: - script: - - git submodule update --init - - git submodule - - 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 diff --git a/check_fix_white_space.py b/check_fix_white_space.py index cf6fe3c..6597e58 100755 --- a/check_fix_white_space.py +++ b/check_fix_white_space.py @@ -26,6 +26,8 @@ def fix_white_space(debug, fix_files): for pathname in found_files: dirty = False + had_TAB = False + had_trailing_WS = False new_lines = [] if debug >= 1: print("tab_with=%d pathname=%s" % (tab_width, pathname)) @@ -41,8 +43,16 @@ def fix_white_space(debug, fix_files): 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 new_line != old_line: + had_TAB = True + # Strip the CRLF + new_line = new_line.rstrip("\r\n") + # Strip trailing WS + tmp_line = new_line.rstrip(" ") + if tmp_line != new_line: + had_trailing_WS = True + new_line = tmp_line + if had_crlf == 2: new_line = new_line + '\r\n' elif had_crlf == 1: @@ -61,7 +71,12 @@ def fix_white_space(debug, fix_files): if debug >= 1: print("pathname=%s dirty=%d" % (pathname, dirty)) if dirty: - incorrect_files[pathname] = True + if had_TAB and had_trailing_WS: + incorrect_files[pathname] = 'has white space damage' + elif had_TAB: + incorrect_files[pathname] = 'has TAB' + elif had_trailing_WS: + incorrect_files[pathname] = 'has trailing whitespace' if fix_files: file = open(pathname, 'w', newline='', encoding="iso-8859-1") file.writelines(new_lines) @@ -88,8 +103,10 @@ if __name__ == "__main__": 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)) + message = incorrect_files[file] + print("ERROR: '{}' {}".format(file,message)) if incorrect_files: + print('run %s --fix' % sys.argv[0]) exit(1) except IOError as e: print(e) # Likely no files found diff --git a/solution/solution.tsproj b/solution/solution.tsproj index 62c7257..336b132 100644 --- a/solution/solution.tsproj +++ b/solution/solution.tsproj @@ -1,880 +1,8 @@ - - - NCTOPLC_AXIS_REF_STATE - 32 - - Operational - BIT - 1 - 0 - - - Homed - BIT - 1 - 1 - - - NotMoving - BIT - 1 - 2 - - - InPositionArea - BIT - 1 - 3 - - - InTargetPosition - BIT - 1 - 4 - - - Protected - BIT - 1 - 5 - - - ErrorPropagationDelayed - BIT - 1 - 6 - - - HasBeenStopped - BIT - 1 - 7 - - - HasJob - BIT - 1 - 8 - - - PositiveDirection - BIT - 1 - 9 - - - NegativeDirection - BIT - 1 - 10 - - - HomingBusy - BIT - 1 - 11 - - - ConstantVelocity - BIT - 1 - 12 - - - Compensating - BIT - 1 - 13 - - - ExtSetPointGenEnabled - BIT - 1 - 14 - - - PhasingActive - BIT - 1 - 15 - - - ExternalLatchValid - BIT - 1 - 16 - - - NewTargetPos - BIT - 1 - 17 - - - ContinuousMotion - BIT - 1 - 19 - - - ControlLoopClosed - BIT - 1 - 20 - - - CamTableQueued - BIT - 1 - 21 - - - CamDataQueued - BIT - 1 - 22 - - - CamScalingPending - BIT - 1 - 23 - - - CmdBuffered - BIT - 1 - 24 - - - PTPmode - BIT - 1 - 25 - - - SoftLimitMinExceeded - BIT - 1 - 26 - - - SoftLimitMaxExceeded - BIT - 1 - 27 - - - DriveDeviceError - BIT - 1 - 28 - - - MotionCommandsLocked - BIT - 1 - 29 - - - IoDataInvalid - BIT - 1 - 30 - - - Error - BIT - 1 - 31 - - - %08x - - - 0x%08x - - - 16#%08X - - - - NCTOPLC_AXIS_REF_OPMODE - 32 - - OpModePosAreaMonitoring - BIT - 1 - 0 - - - OpModeTargetPosMonitoring - BIT - 1 - 1 - - - OpModeLoop - BIT - 1 - 2 - - - OpModeMotionMonitoring - BIT - 1 - 3 - - - OpModePEHTimeMonitoring - BIT - 1 - 4 - - - OpModeBacklashCompensation - BIT - 1 - 5 - - - OpModeDelayedErrorReaction - BIT - 1 - 6 - - - OpModeModulo - BIT - 1 - 7 - - - OpModeSimulationAxis - BIT - 1 - 8 - - - OpModePosLagMonitoring - BIT - 1 - 16 - - - OpModeVeloLagMonitoring - BIT - 1 - 17 - - - OpModeSoftLimitMinMonitoring - BIT - 1 - 18 - - - OpModeSoftLimitMaxMonitoring - BIT - 1 - 19 - - - OpModePosCorrection - BIT - 1 - 20 - - - OpModeAllowSlaveCommands - BIT - 1 - 21 - - - OpModeAllowExtSetAxisCommands - BIT - 1 - 22 - - - ApplicationRequest - BIT - 1 - 23 - - - - NCTOPLC_AXIS_REF_STATE2_FLAGS - 32 - - AvoidingCollision - BIT - 1 - 0 - - - %08x - - - 0x%08x - - - 16#%08X - - - - NCTOPLC_AXIS_REF_STATE2 - 32 - - Value - DWORD - 32 - 0 - - - Flags - NCTOPLC_AXIS_REF_STATE2_FLAGS - 32 - 0 - - - %08x - - - 0x%08x - - - 16#%08X - - - - NCTOPLC_AXIS_REF_CAMCOUPLINGSTATE - 8 - - CamActivationPending - BIT - 1 - 0 - - - CamDeactivationPending - BIT - 1 - 1 - - - CamActive - BIT - 1 - 2 - - - CamDataQueued - BIT - 1 - 6 - - - CamScalingPending - BIT - 1 - 7 - - - - UINTARR8 - 128 - UINT - - 0 - 8 - - - - NCTOPLC_AXIS_REF - 2048 - - StateDWord - NCTOPLC_AXIS_REF_STATE - 32 - 0 - - - ErrorCode - UDINT - 32 - 32 - - - AxisState - UDINT - - 32 - 64 - - - AxisModeConfirmation - UDINT - 32 - 96 - - - HomingState - UDINT - - 32 - 128 - - - CoupleState - UDINT - - 32 - 160 - - - SvbEntries - UDINT - 32 - 192 - - - SafEntries - UDINT - 32 - 224 - - - AxisId - UDINT - 32 - 256 - - - OpModeDWord - NCTOPLC_AXIS_REF_OPMODE - 32 - 288 - - - ActPos - LREAL - 64 - 320 - - - ModuloActPos - LREAL - 64 - 384 - - - ActiveControlLoopIndex - UINT - 16 - 448 - - - ControlLoopIndex - UINT - 16 - 464 - - - ModuloActTurns - DINT - 32 - 480 - - - ActVelo - LREAL - 64 - 512 - - - PosDiff - LREAL - 64 - 576 - - - SetPos - LREAL - 64 - 640 - - - SetVelo - LREAL - 64 - 704 - - - SetAcc - LREAL - 64 - 768 - - - TargetPos - LREAL - 64 - 832 - - - ModuloSetPos - LREAL - 64 - 896 - - - ModuloSetTurns - DINT - 32 - 960 - - - CmdNo - UINT - 16 - 992 - - - CmdState - UINT - 16 - 1008 - - - SetJerk - LREAL - 64 - 1024 - - - SetTorque - LREAL - 64 - 1088 - - - ActTorque - LREAL - 64 - 1152 - - - StateDWord2 - NCTOPLC_AXIS_REF_STATE2 - 32 - 1216 - - - StateDWord3 - DWORD - 32 - 1248 - - - TouchProbeState - DWORD - 32 - 1280 - - - TouchProbeCounter - DWORD - 32 - 1312 - - - CamCouplingState - NCTOPLC_AXIS_REF_CAMCOUPLINGSTATE - - 0 - 8 - - 64 - 1344 - - - CamCouplingTableID - UINTARR8 - 128 - 1408 - - - ActTorqueDerivative - LREAL - 64 - 1536 - - - SetTorqueDerivative - LREAL - 64 - 1600 - - - ActPosWithoutPosCorrection - LREAL - 64 - 1792 - - - ActAcc - LREAL - 64 - 1856 - - - DcTimeStamp - UDINT - 32 - 1920 - - - - NcStructType - 2 - - - - - NCAXLESTRUCT_TOPLC - - - NCAXLESTRUCT_TOPLC2 - - - NCAXLESTRUCT_TOPLC3 - - - NCAXLESTRUCT_TOPLC4 - - - - - - - - - - - - - - PLCTONC_AXIS_REF_CTRL - 32 - - Enable - BIT - 1 - 0 - - - FeedEnablePlus - BIT - 1 - 1 - - - FeedEnableMinus - BIT - 1 - 2 - - - HomingSensor - BIT - 1 - 5 - - - AcceptBlockedDrive - BIT - 1 - 8 - - - PlcDebugFlag - BIT - 1 - 30 - - - NcDebugFlag - BIT - 1 - 31 - - - %08x - - - 0x%08x - - - 16#%08X - - - - PLCTONC_AXIS_REF - 1024 - - ControlDWord - PLCTONC_AXIS_REF_CTRL - 32 - 0 - - - Override - UDINT - 32 - 32 - - - AxisModeRequest - UDINT - 32 - 64 - - - AxisModeDWord - UDINT - 32 - 96 - - - AxisModeLReal - LREAL - 64 - 128 - - - PositionCorrection - LREAL - 64 - 192 - - - ExtSetPos - LREAL - 64 - 256 - - - ExtSetVelo - LREAL - 64 - 320 - - - ExtSetAcc - LREAL - 64 - 384 - - - ExtSetDirection - DINT - 32 - 448 - - - ExtControllerOutput - LREAL - 64 - 512 - - - GearRatio1 - LREAL - 64 - 576 - - - GearRatio2 - LREAL - 64 - 640 - - - GearRatio3 - LREAL - 64 - 704 - - - GearRatio4 - LREAL - 64 - 768 - - - MapState - BOOL - 8 - 832 - - - PlcCycleControl - BYTE - 8 - 840 - - - PlcCycleCount - BYTE - 8 - 848 - - - - NcStructType - 1 - - - - - NCAXLESTRUCT_FROMPLC3 - - - - + {3EBB9639-5FF3-42B6-8847-35C70DC013C8} @@ -897,79 +25,7 @@ External Setpoint Generation: tc_project_app Instance {08500001-0000-0000-F000-000000000064} - - PlcTask Inputs - - GVL.axes[1].bLimitFwd - - BOOL - - - GVL.axes[1].bLimitBwd - - BOOL - - - GVL.axes[1].bHomeSensor - - BOOL - - - GVL.axes[1].bEncLAtch - - BOOL - - - GVL.axes[1].Axis.NcToPlc - NCTOPLC_AXIS_REF - - AxisState - - - - HomingState - - - - CoupleState - - - - - - PlcTask Outputs - - GVL.axes[1].Axis.PlcToNc - PLCTONC_AXIS_REF - - + diff --git a/solution/tc_project_app/POUs/MAIN.TcPOU b/solution/tc_project_app/POUs/MAIN.TcPOU index 3ff0212..8e73b6a 100644 --- a/solution/tc_project_app/POUs/MAIN.TcPOU +++ b/solution/tc_project_app/POUs/MAIN.TcPOU @@ -86,7 +86,6 @@ END_IF]]> @@ -240,7 +239,6 @@ END_FOR]]> - diff --git a/solution/tc_project_app/Test/standard_library_tests/FB_Axis_TEST.TcPOU b/solution/tc_project_app/Test/standard_library_tests/FB_Axis_TEST.TcPOU new file mode 100644 index 0000000..36cf024 --- /dev/null +++ b/solution/tc_project_app/Test/standard_library_tests/FB_Axis_TEST.TcPOU @@ -0,0 +1,248 @@ + + + + of the axis within GVL.axes[] to test against. +END_VAR]]> + + + + + + + nMaxCycles OR ExpectedResult = Result THEN + AssertEquals(Expected := ExpectedResult, + Actual := Result, + Message := 'Axis is not moving.'); + TEST_FINISHED(); +ELSE + nCycle := nCycle + 1; +END_IF]]> + + + + + + nCycleMax OR ExpectedResult = Result THEN + AssertEquals(Expected := ExpectedResult, + Actual := Result, + Message := 'fPosition of the axis is different.'); + TEST_FINISHED(); +ELSE + nCycle := nCycle + 1; +END_IF]]> + + + + + + + + + + + + nMaxCycles OR ExpectedResult = Result THEN + AssertEquals(Expected := ExpectedResult, + Actual := Result, + Message := 'Axis is not enabled.'); + TEST_FINISHED(); +ELSE + nCycle := nCycle + 1; +END_IF +]]> + + + + + + + + + + + + nMaxCycles OR ExpectedResult = Result THEN + AssertEquals(Expected := ExpectedResult, + Actual := Result, + Message := 'Axis bLimitFwd is not enabled.'); + TEST_FINISHED(); +ELSE + nCycle := nCycle + 1; +END_IF]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/Test/standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU b/solution/tc_project_app/Test/standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU new file mode 100644 index 0000000..e7cb079 --- /dev/null +++ b/solution/tc_project_app/Test/standard_library_tests/tcUNIT_STD_LIB_RUN.TcPOU @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/solution/tc_project_app/tc_project_app.plcproj b/solution/tc_project_app/tc_project_app.plcproj index ef75202..a0d9d56 100644 --- a/solution/tc_project_app/tc_project_app.plcproj +++ b/solution/tc_project_app/tc_project_app.plcproj @@ -29,6 +29,15 @@ Code + + Code + + + Code + + + Code + Code @@ -118,6 +127,12 @@ Code + + Code + + + Code + Code @@ -145,6 +160,7 @@ + @@ -247,8 +263,8 @@ - - + + "<ProjectRoot>" {192FAD59-8248-4824-A8DE-9177C94C195A} @@ -299,15 +315,15 @@ - - - System.Boolean - System.Collections.Hashtable - System.Int32 - {54dd0eac-a6d8-46f2-8c27-2f43c7e49861} - System.String - - + + + System.Boolean + System.Collections.Hashtable + System.Int32 + {54dd0eac-a6d8-46f2-8c27-2f43c7e49861} + System.String + + \ No newline at end of file