//设置单片机控制板控制的按键灯 public void SetKeyLedByKey(Board board, ARM_InputPoint Key, LED_State LedState) { IOValue Value = LedState == (LED_State.LED_ON) ? IOValue.IOValueHigh : IOValue.IOValueLow; ARM_OutputPoint KeyLed = ARM_OutputPoint.IO_OUT_LedKeyRun; switch (Key) { case ARM_InputPoint.IO_IN_KeyRun: KeyLed = ARM_OutputPoint.IO_OUT_LedKeyRun; break; case ARM_InputPoint.IO_IN_KeyPause: KeyLed = ARM_OutputPoint.IO_OUT_LedKeyPause; break; case ARM_InputPoint.IO_IN_KeyStop: KeyLed = ARM_OutputPoint.IO_OUT_LedKeyStop; break; case ARM_InputPoint.IO_IN_KeyReset: KeyLed = ARM_OutputPoint.IO_OUT_LedKeyReset; break; default: break; } SetArmControlBoardIo(board, KeyLed, Value); }
/// <summary> /// 读取输入口 /// </summary> /// <param name="point">输入点位</param> /// <returns></returns> public bool ReadInputPoint(ARM_InputPoint point) { int indexBoard = (int)point / MAX_IO_CHANNEL; //板卡索引 int indexPoint = (int)point % MAX_IO_CHANNEL; //板卡内端口号索引 uint mask = (uint)1 << indexPoint; return((m_InputValue[indexBoard] & mask) > 0); }
/// <summary> /// 读取IO输入点的状态备份 /// </summary> /// <param name="Point">输入点位</param> /// <returns></returns> public bool ReadInputPointStateBackups(ARM_InputPoint Point) { return(m_InputPointStateBackups[(int)Point]); }
/// <summary> /// 设置IO输入点的状态备份 /// </summary> /// <param name="Point">输入点位</param> /// <param name="State">点位状态</param> public void SetInputPointStateBackups(ARM_InputPoint Point, bool State) { m_InputPointStateBackups[(int)Point] = State; }
public static void ProcessArmControlerInputPoint(Board board) { //解析IoIn for (int i = 0; i < (int)ARM_InputPoint.IO_IN_MAX; i++) { bool State = m_ArmControler.ReadInputPoint((ARM_InputPoint)i); LED_State LedState = State ? LED_State.LED_ON : LED_State.LED_OFF; if (State != m_ArmControler.ReadInputPointStateBackups((ARM_InputPoint)i)) { m_ArmControler.SetInputPointStateBackups((ARM_InputPoint)i, State); ARM_InputPoint temp = (ARM_InputPoint)i; switch (temp) { case ARM_InputPoint.IO_IN_KeyRun: { if (State) { ProcessKey(Key.Key_Run); } DataStruct.SysStat.KeyRun = State; m_ArmControler.SetKeyLedByKey(board, ARM_InputPoint.IO_IN_KeyRun, LedState); } break; case ARM_InputPoint.IO_IN_KeyPause: { if (State) { ProcessKey(Key.Key_Pause); } DataStruct.SysStat.KeyPause = State; m_ArmControler.SetKeyLedByKey(board, ARM_InputPoint.IO_IN_KeyPause, LedState); } break; case ARM_InputPoint.IO_IN_KeyStop: { if (State) { ProcessKey(Key.Key_Stop); } DataStruct.SysStat.KeyStop = State; m_ArmControler.SetKeyLedByKey(board, ARM_InputPoint.IO_IN_KeyStop, LedState); } break; case ARM_InputPoint.IO_IN_KeyReset: { if (State) { ProcessKey(Key.Key_Reset); } DataStruct.SysStat.KeyReset = State; m_ArmControler.SetKeyLedByKey(board, ARM_InputPoint.IO_IN_KeyReset, LedState); } break; default: break; } } } }