1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | IF NOT xInit THEN UM ( sName := 'Normal Operation', dwAllowsLeavingFromStates := PACK_ML.State.Stopped OR PACK_ML.State.Aborted OR PACK_ML.State.Idle, IF SysStrCmp(Client.sCommandToPLC, Client.LockCommands[0]) = 0 THEN overrideKey := TRUE; ELSIF SysStrCmp(Client.sCommandToPLC, 'UnSuspend') = 0 THEN UnSuspend(); END_CASE Client.iCommandToPLC := 0; Client.sCommandToPLC := ''; Client.bReadyToPLC := FALSE; CASE UM.CurrentState OF PACK_ML.State.Stopped: ; PACK_ML.State.Aborted: PACK_ML.State.Idle: PACK_ML.State.Complete : PACK_ML.State.Execute : CASE Client.Mode OF Mode.Mode1: IF puzzleTimer.iProcess = 50 THEN IF Client.ActualStep <= 10 THEN SendCommand(Command := CommandType.Hint ,Value := 'Unlock the panel.'); END_IF END_IF CASE Client.Level OF Level.Beginner: ShadowInByte := ROL(InByte,0); Level.Placeholder1: ShadowInByte := ROL(InByte,2); Level.Intermediate: ShadowInByte := ROL(InByte,4); Level.Placeholder2: ShadowInByte := ROL(InByte,6); Level.Advanced: ShadowInByte := ROL(InByte,8); END_CASE Mode.Mode2: SendCommand(Command := CommandType.Media ,Value := 'https://en.wikipedia.org/wiki/Endianness#Files_and_byte_swap'); temp.7 := InByte.0; temp.6 := InByte.1; temp.5 := InByte.2; temp.4 := InByte.3; temp.3 := InByte.4; temp.2 := InByte.5; temp.1 := InByte.6; temp.0 := InByte.7; ShadowInByte := temp; CASE Client.ActualStep OF 0: // Waiting for key. IF DI_Key_switch OR overrideKey THEN Client.ActualStep := Client.ActualStep + 10; ViewIndex := 0; 10: // Check solution IF ton.Q THEN LocalOutByte := 0; LocalOutByte := LocalOutByte + 1; Client.ActualStep := Client.ActualStep + 5; 15: Client.ActualStep := Client.ActualStep + 5; Client.ActualStep := Client.ActualStep - 5; Client.ActualStep := 0; // Turn off the screen. OutByte := 1; 30: Client.ActualStep := Client.ActualStep + 10; IF NOT DI_Key_switch AND NOT overrideKey THEN ViewIndex := 1; END_IF OutByte := 2; 50: OutByte := 4; OutByte := 8; 100: 110: OutByte := 32; 140: 150: OutByte := 128; 170: StateComplete(); ViewIndex := 1; LocalInByte := 0; ShadowInByte := 0; StateComplete(); PACK_ML.State.Completing : PACK_ML.State.Stopping: END_CASE IF NOT (x_EmergencyGF AND NOT x_EmergencyFF) THEN Abort(); puzzleTimer(xStartTimer := UM.CurrentState = PACK_ML.State.Execute ,xPauseTimer := ,xStopTimer:= NOT (UM.CurrentState = PACK_ML.State.Execute),tMaxPuzzleTime := Client.Duration); IF puzzleTimer.iProcess >= 100 THEN |