# # Set test options (True to enable) # VAR(False) PrintLabel VAR(False) LoopMode # # DR5088RC Factory Test Script # (C) Digikeijs B.V. # # Current DR5088RC Firmware Version VAR Version # DR5088 Serial number VAR Serial # The Base Address (0 based) of both DR4018 # Both should be set to CV47=1 (16 on/off outputs) and # the 1st DR4018 has $TurnoutBase + 1, # the 2nd DR4018 has $TurnoutBase + 17 VAR(1500) TurnoutBase # The Loco Address of the decoder # that reports "Forward" VAR(3) LocoForward # The Loco Address of the decoder # that reports "Backward" VAR(4) LocoBackward # The current Loco under test VAR Loco # The current Direction under test VAR Direction # Feedback max wait time in ms VAR(1000) wt # Loop and other helper vars # Turnout helpers VAR(0) ti VAR(0) t # Input helpers VAR(0) ii VAR(0) i # misc VAR result VAR start VAR tmp VAR msg VAR time VAR date VAR pass VAR qc VAR defect VAR(No) LoopTest VAR(No) NextTest ################ # Script start # ################ # Jump to the test-entry-point GOTO Main ################## # Initialisation # ################## # # Perform version check and initialisation # Init: CALL Dark Version = $VERSION ? Serial = $SERIAL ? IF($Version = $APPVERSION) GOTO InitVersionOK tmp = $MESSAGE(YesNo,Question,Button2) Firmware Version not equal to Latest Version !\n\nUpdate Firmware now? IF($tmp = No) GOTO InitVersionOK UpdateRetry: tmp = $FWUPDATE(True) IF($tmp = True) GOTO InitVersionOK tmp = $MESSAGE(AbortRetryIgnore,Error) Firmware Update failed IF($tmp = Abort) STOP IF($tmp = Retry) GOTO UpdateRetry IF($tmp = Ignore) GOTO InitVersionOK InitVersionOK: IF($LoopMode = False) GOTO InitNoLoop LoopTest = $MESSAGE(YesNo,Question,Button2) Run test for DR5088RC $Serial with FW: $Version\n\nin loop mode ? InitNoLoop: start = $SECONDS ? pass = 0 # Initialise both DR4018 Finit: CALL BlueOFF CALL RedON CALL GreenON # Reset DR5088RC to Factory Defaults for the test FWRESET(True) ti = 0 InitLoopA: t = $TurnoutBase + $ti TURNOUT $t / ti = $ti + 1 IF($ti != 8) GOTO InitLoopA ti = 0 InitLoopB: t = $TurnoutBase + $ti + 16 TURNOUT $t / ti = $ti + 1 IF($ti != 14) GOTO InitLoopB CALL Dark RETURN ###################### # Decoder Connection # ###################### # # Forward On # # Connect the Forward decoder to 1-8 ForwardOn1_8: t = $TurnoutBase + 27 TURNOUT $t | RETURN #Connect the Forward decoder to GL ForwardOnGL: t = $TurnoutBase + 28 TURNOUT $t | RETURN #Connect the Forward decoder to 9-16 ForwardOn9_16: t = $TurnoutBase + 29 TURNOUT $t | RETURN # # Backward On # # Connect the Backward decoder to 1-8 BackwardOn1_8: t = $TurnoutBase + 26 TURNOUT $t | RETURN # Connect the Backward decoder to GL BackwardOnGL: t = $TurnoutBase + 25 TURNOUT $t | RETURN # Connect the Backward decoder to 9-16 BackwardOn9_16: t = $TurnoutBase + 24 TURNOUT $t | RETURN # # Forward Off # # Disconnect the Forward decoder from 1-8 ForwardOff1_8: t = $TurnoutBase + 27 TURNOUT $t / RETURN # Disconnect the Forward decoder from GL ForwardOffGL: t = $TurnoutBase + 28 TURNOUT $t / RETURN # Disconnect the Forward decoder from 9-16 ForwardOff9_16: t = $TurnoutBase + 29 TURNOUT $t / RETURN # Disconnect the Forward decoder from all inputs ForwardOff: CALL ForwardOff1_8 CALL ForwardOffGL CALL ForwardOff9_16 RETURN # # Backward Off # # Disconnect the Backward decoder from 1-8 BackwardOff1_8: t = $TurnoutBase + 26 TURNOUT $t / RETURN # Disconnect the Backward decoder from GL BackwardOffGL: t = $TurnoutBase + 25 TURNOUT $t / RETURN # Disconnect the Backward decoder from 9-16 BackwardOff9_16: t = $TurnoutBase + 24 TURNOUT $t / RETURN # Disconnect the Backward decoder from all inputs BackwardOff: CALL BackwardOff1_8 CALL BackwardOffGL CALL BackwardOff9_16 RETURN ################################################ # Input selection, uses $ii (0-based) as index # ################################################ # # Select # SelectInput: IF($ii > 7) GOTO SelectInput9_16 i = 7 - $ii t = $TurnoutBase + $i TURNOUT $t | RETURN SelectInput9_16: i = 15 - $ii t = $TurnoutBase + $i + 16 TURNOUT $t | RETURN # # Deselect # DeselectInput: IF($ii > 7) GOTO DeselectInput9_16 i = 7 - $ii t = $TurnoutBase + $i TURNOUT $t / RETURN DeselectInput9_16: i = 15 - $ii t = $TurnoutBase + $i + 16 TURNOUT $t / RETURN ######## # LEDs # ######## BlueON: t = $TurnoutBase + 15 TURNOUT $t | RETURN BlueOFF: t = $TurnoutBase + 15 TURNOUT $t / RETURN RedON: t = $TurnoutBase + 14 TURNOUT $t | RETURN RedOFF: t = $TurnoutBase + 14 TURNOUT $t / RETURN GreenON: t = $TurnoutBase + 13 TURNOUT $t | RETURN GreenOFF: t = $TurnoutBase + 13 TURNOUT $t / RETURN Blue: CALL RedOFF CALL GreenOFF GOTO BlueON Red: CALL BlueOFF CALL GreenOFF GOTO RedON Green: CALL RedOFF CALL BlueOFF GOTO GreenON Dark: CALL RedOFF CALL BlueOFF GOTO GreenOFF ######### # Label # ######### Label: IF($PrintLabel = False) RETURN date = $DATE time = $TIME PRINTLABEL(Arial:10:Bold) SN: $Serial\nFW: $Version\nQC: $qc\n$defect\n$date $time RETURN ######### # Tests # ######### # # Wait for input feedback # WaitFeedback: result = $WAITFOR($wt) F:\s*$ii:1 IF(False = $result) GOTO OccupanceError result = $WAITFOR($wt) F:\s*$ii:1 0*$Loco $Direction IF(False = $result) GOTO AddressError result = $READCV(POM:$Loco) 1 IF($Loco != $result) GOTO POMError RETURN # # Test all inputs # TestAllInputs: ii = 0 CALL SelectInput CALL WaitFeedback TestAllLoopA: ii = $ii + 1 CALL SelectInput ii = $ii - 1 CALL DeselectInput ii = $ii + 1 CALL WaitFeedback IF($ii != 15) GOTO TestAllLoopA ii = 15 CALL DeselectInput RETURN ###################### # Main Program Entry # ###################### Main: CALL Init # MainLoop: pass = $pass + 1 CALL Blue # # First test the forward decoder # Loco = $LocoForward Direction = > CALL ForwardOn1_8 CALL ForwardOn9_16 CALL TestAllInputs CALL ForwardOff1_8 CALL ForwardOff9_16 # CALL ForwardOnGL ii = 1000 CALL WaitFeedback CALL ForwardOffGL # # # Next test the backward decoder # PAUSE 500 Loco = $LocoBackward Direction = < CALL BackwardOn1_8 CALL BackwardOn9_16 CALL TestAllInputs CALL BackwardOff1_8 CALL BackwardOff9_16 # CALL BackwardOnGL ii = 1000 CALL WaitFeedback CALL BackwardOffGL # CALL Green IF($LoopTest = No) GOTO TestSuccess LOG Test for: DR5088RC $Serial with FW:$Version Completed successfully ! PAUSE 2000 GOTO MainLoop TestAgain: CALL Dark FWRESET(true) Version = $VERSION ? Serial = $SERIAL ? start = $SECONDS ? GOTO MainLoop TestSuccess: tmp = $SECONDS ? tmp = $tmp - $start time = $TIME date = $DATE NextTest = $MESSAGE(YesNo) Test of DR5088RC $Serial with FW:$Version\n\nCompleted successfully in $tmp seconds !\n\n\nRun another test ?\n\n\n$date $time pass $pass IF($NextTest = Yes) GOTO TestAgain qc = Passed defect = CALL Label FWRESET(true) CALL Dark STOP OccupanceError: CALL Red tmp = $ii + 1 time = $TIME date = $DATE NextTest = $MESSAGE(YesNo,Error) Test of DR5088RC $Serial with FW: $Version\n\nFailed: No occupance feedback from input: [ $tmp ] [ $Direction ]\n\n\nRun another test ?\n\n\n$date $time pass $pass IF($NextTest = Yes) GOTO TestAgain qc = Failed defect = No occupance fb on input: [ $tmp ] [ $Direction ] CALL Label CALL Finit STOP AddressError: CALL Red tmp = $ii + 1 time = $TIME date = $DATE NextTest = $MESSAGE(YesNo,Error) Test of DR5088RC $Serial with FW: $Version\n\nFailed: No address feedback from input: [ $tmp ] loco: [ $Loco $Direction ]\n\n\nRun another test ?\n\n\n$date $time pass $pass IF($NextTest = Yes) GOTO TestAgain qc = Failed defect = No address fb on input: [ $tmp ] loco: [ $Loco $Direction ] CALL Label CALL Finit STOP POMError: CALL Red tmp = $ii + 1 time = $TIME date = $DATE NextTest = $MESSAGE(YesNo,Error) Test of DR5088RC $Serial with FW: $Version\n\nFailed: POM read error from input: [ $tmp ] loco: [ $Loco $Direction ]\n\n\nRun another test ?\n\n\n$date $time pass $pass IF($NextTest = Yes) GOTO TestAgain qc = Failed defect = POM read error on input: [ $tmp ] loco: [ $Loco $Direction ] CALL Label CALL Finit STOP