'						Performs saftey check on Turret''''''''Inputs are as follows:'''OEMTRIG1 = Encoder Bit 1'OEMTRIG2 = Encoder Bit 2'OEMTRIG3 = Encoder Bit 3'OEMTRIG4 = Encoder Bit 4'OEMTRIG5 = Parity Bit'OEMTRIG6 = Strobe1'OEMTRIG7 = Strobe2'OEMTRIG8 = Index Proximity Switch'OEMTRIG9 = Lock Proximity Switch'OEMTRIG10 = Door Switch''					'Read the Encoder BitsIf IsActive(OEMTRIG1) ThenBit1 = 1ElseBit1 = 0End IfIf IsActive(OEMTRIG2) ThenBit2 = 1ElseBit2 = 0End If					If IsActive(OEMTRIG3) ThenBit3 = 1ElseBit3 = 0End If					If IsActive(OEMTRIG4) ThenBit4 = 1ElseBit4 = 0End IfIf IsActive(OEMTRIG5) ThenParity = 1ElseParity = 0End IfIf IsActive(OEMTRIG6) ThenStrobe1 = 1ElseStrobe1 = 0End IfIf IsActive(OEMTRIG7) ThenStrobe2 = 1ElseStrobe2 = 0End If					'Where the hell is the turret now?If Bit1=1 And Bit2=0 And Bit3=0 And Bit4=0 And Parity=1 And Strobe1=1 And Strobe2=0 ThenPosition = 1ElseIf Bit1=0 And Bit2=1 And Bit3=0 And Bit4=0 And Parity=1 And Strobe1=1 And Strobe2=0 ThenPosition = 2ElseIf Bit1=1 And Bit2=1 And Bit3=0 And Bit4=0 And Parity=0 And Strobe1=1 And Strobe2=0 ThenPosition = 3ElseIf Bit1=0 And Bit2=0 And Bit3=1 And Bit4=0 And Parity=1 And Strobe1=1 And Strobe2=0 ThenPosition = 4ElseIf Bit1=1 And Bit2=0 And Bit3=1 And Bit4=0 And Parity=0 And Strobe1=1 And Strobe2=0 ThenPosition = 5ElseIf Bit1=0 And Bit2=1 And Bit3=1 And Bit4=0 And Parity=0 And Strobe1=1 And Strobe2=0 ThenPosition = 6ElseIf Bit1=1 And Bit2=1 And Bit3=1 And Bit4=0 And Parity=1 And Strobe1=1 And Strobe2=0 ThenPosition = 7ElseIf Bit1=0 And Bit2=0 And Bit3=0 And Bit4=1 And Parity=1 And Strobe1=1 And Strobe2=0 ThenPosition = 8ElseMsgBox("Turret out of position")EndEnd If If IsActive(OEMTRIG6) Then			'check strobe1 state'everything checks outElseMsgBox("Turret out of position")EndEnd IfIf IsActive(OEMTRIG7) Then			'check strobe2 stateMsgBox("Turret out of position")EndEnd IfIf IsActive(OEMTRIG8) Then			'check IndexProx stateMsgBox("Turret Index Proximity Fault")EndEnd IfIf IsActive(OEMTRIG9) Then			'check LockProx stateMsgBox("Turret Lock Pin Retract Failure")EndEnd If'If IsActive(OEMTRIG10) Then			'check Door state'MsgBox("Close the Door")'End IfIf Position = GetSelectedTool() Then		'check tool = selected tool'is OKElseMsgBox("Turret not in selected position!!")EndEnd IfEnd      