Skip to content

Commit f91dd46

Browse files
committed
MBP-369: Add warn/info messages to param check
1 parent bfc78cc commit f91dd46

File tree

3 files changed

+64
-21
lines changed

3 files changed

+64
-21
lines changed

DUTs/E_AxisParamCheckState.TcDUT

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
TYPE E_AxisParamCheckState :
77
(
88
eInit,
9-
eSelect,
10-
eRead,
9+
eSelectParam,
10+
eWaitRead,
1111
eCheck,
12-
eAllParamValid,
13-
eInvalidParam
12+
eParamValid,
13+
eParamInvalid,
14+
eNext,
15+
eFinish
1416
);
1517
END_TYPE
1618
]]></Declaration>

DUTs/E_AxisParameters.TcTLEO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<EnumerationTextList Name="E_AxisParameters" Id="{9199cc42-106a-4663-aaa5-d49855d9aa9f}">
44
<Declaration><![CDATA[{attribute 'qualified_only'}
55
{attribute 'strict'}
6+
{attribute 'to_string'}
67
TYPE E_AxisParameters :
78
(
89
//PLCopen specific parameters Index-Group 0x4000 + ID

POUs/Motion/FB_SlitPair.TcPOU

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ VAR
4949
bAxisErrorsPresent: BOOL := FALSE; //TRUE if error present on any real or virtual axis
5050
bUpdateSoftLimits: BOOL := FALSE; //TRUE if update of soft limits are being executed
5151
bHomingRequested: BOOL := FALSE; //TRUE if homing is requested for all axis
52+
bInvalidParamFound: BOOL := FALSE; //TRUE if startup finds atleast one invalid parameter
5253
fGapSizePosition: LREAL; //Virtual axis gap size calculated position
5354
nGapSizePosition AT %Q*: UDINT := 0; //Virtual axis gap size encoder position/counter
5455
fGapCentrePosition: LREAL; //Virtual axis gap centre calculated position
@@ -93,9 +94,7 @@ actAnticollision(); //Handle blades anticollision
9394
CASE eSlitPairState OF
9495
E_SlitPairStates.eStartup:
9596
checkStartupParams(stGapSize, stGapCentre);
96-
IF eParameterCheck = E_AxisParamCheckState.eAllParamValid
97-
OR eParameterCheck = E_AxisParamCheckState.eInvalidParam
98-
THEN
97+
IF eParameterCheck = E_AxisParamCheckState.eFinish THEN
9998
eSlitPairState := E_SlitPairStates.eInit;
10099
END_IF
101100
@@ -686,6 +685,9 @@ VAR_IN_OUT
686685
stGapSize: ST_AxisStruct; //Axis data of the gap size
687686
stGapCentre: ST_AxisStruct; //Axis data of the gap centre
688687
END_VAR
688+
VAR
689+
sWarnMsg: T_MaxString;
690+
END_VAR
689691
]]></Declaration>
690692
<Implementation>
691693
<ST><![CDATA[CASE eParameterCheck OF
@@ -696,9 +698,9 @@ END_VAR
696698
END_IF
697699
698700
iParamCheck := 1;
699-
eParameterCheck := E_AxisParamCheckState.eSelect;
701+
eParameterCheck := E_AxisParamCheckState.eSelectParam;
700702
701-
E_AxisParamCheckState.eSelect:
703+
E_AxisParamCheckState.eSelectParam:
702704
stGapSize.stConfig.eAxisParameters := cParameters[iParamCheck].eParam;
703705
stGapSize.stControl.eCommand := E_MotionFunctions.eReadParameter;
704706
stGapSize.stControl.bExecute := TRUE;
@@ -707,9 +709,9 @@ END_VAR
707709
stGapCentre.stControl.eCommand := E_MotionFunctions.eReadParameter;
708710
stGapCentre.stControl.bExecute := TRUE;
709711
710-
eParameterCheck := E_AxisParamCheckState.eRead;
712+
eParameterCheck := E_AxisParamCheckState.eWaitRead;
711713
712-
E_AxisParamCheckState.eRead:
714+
E_AxisParamCheckState.eWaitRead:
713715
//Parameter reading still in progress
714716
IF stGapSize.stStatus.bBusy OR stGapCentre.stStatus.bBusy THEN
715717
RETURN;
@@ -721,21 +723,59 @@ END_VAR
721723
IF stGapSize.stConfig.fReadAxisParameter = cParameters[iParamCheck].fValue
722724
AND stGapCentre.stConfig.fReadAxisParameter = cParameters[iParamCheck].fValue
723725
THEN
724-
IF iParamCheck = cMaxParams THEN
725-
eParameterCheck := E_AxisParamCheckState.eAllParamValid;
726-
ELSE
727-
iParamCheck := iParamCheck + 1;
728-
eParameterCheck := E_AxisParamCheckState.eSelect;
726+
eParameterCheck := E_AxisParamCheckState.eParamValid;
727+
ELSE
728+
eParameterCheck := E_AxisParamCheckState.eParamInvalid;
729+
END_IF
730+
731+
E_AxisParamCheckState.eParamValid:
732+
eParameterCheck := E_AxisParamCheckState.eNext;
733+
734+
E_AxisParamCheckState.eParamInvalid:
735+
//Gap Size
736+
IF stGapSize.stConfig.fReadAxisParameter <> cParameters[iParamCheck].fValue THEN
737+
sWarnMsg := CONCAT(
738+
STR1 := 'Slit virtual axis Gap Size (AxisId=%d) has an invalid parameter of ',
739+
STR2 := TO_STRING(cParameters[iParamCheck].eParam));
740+
741+
ADSLOGDINT(
742+
msgCtrlMask := ADSLOG_MSGTYPE_WARN,
743+
msgFmtStr := sWarnMsg,
744+
dintArg := TO_DINT(iGapSize));
745+
END_IF
746+
//Gap Centre
747+
IF stGapCentre.stConfig.fReadAxisParameter <> cParameters[iParamCheck].fValue THEN
748+
sWarnMsg := CONCAT(
749+
STR1 := 'Slit virtual axis Gap Centre (AxisId=%d) has an invalid parameter of ',
750+
STR2 := TO_STRING(cParameters[iParamCheck].eParam));
751+
752+
ADSLOGDINT(
753+
msgCtrlMask := ADSLOG_MSGTYPE_WARN,
754+
msgFmtStr := sWarnMsg,
755+
dintArg := TO_DINT(iGapCentre));
756+
END_IF
757+
bInvalidParamFound := TRUE;
758+
759+
eParameterCheck := E_AxisParamCheckState.eNext;
760+
761+
E_AxisParamCheckState.eNext:
762+
IF iParamCheck = cMaxParams THEN
763+
IF NOT bInvalidParamFound THEN
764+
ADSLOGSTR(
765+
msgCtrlMask := ADSLOG_MSGTYPE_LOG,
766+
msgFmtStr := 'Slit all parameters of both virtual axes are valid',
767+
strArg := '');
729768
END_IF
769+
eParameterCheck := E_AxisParamCheckState.eFinish;
730770
ELSE
731-
eParameterCheck := E_AxisParamCheckState.eInvalidParam;
771+
;
772+
iParamCheck := iParamCheck + 1;
773+
eParameterCheck := E_AxisParamCheckState.eSelectParam;
732774
END_IF
733775
734-
E_AxisParamCheckState.eAllParamValid:
735-
;
736776
737-
E_AxisParamCheckState.eInvalidParam:
738-
; //Atleast one invalid parameter found
777+
E_AxisParamCheckState.eFinish:
778+
;
739779
740780
END_CASE
741781
]]></ST>

0 commit comments

Comments
 (0)