/// <summary> /// 채널별 I/O 입력을 읽어온다. /// </summary> /// <param name="Ch"></param> /// <returns></returns> public byte inportbdata(short Ch) { #if PROGRAM_RUNNING ushort DIVal = 0; byte Data = 0x00; ushort wRetVal; //receive the digital single on the board you choose wRetVal = PIO821.PIO821_DigitalIn((byte)0, out DIVal); if (wRetVal > 0) { MessageBox.Show("*** PIO821_DigitalIn() error ! ***"); } else { if (Ch == 0) { Data = (byte)(DIVal & 0x00ff); } else { Data = (byte)((DIVal & 0xff00) >> 8); } } return(Data); #else return((byte)0x00); #endif }
/// <summary> /// I/O 제어 보드를 닫는다. /// </summary> public void CloseIO() { #if PROGRAM_RUNNING try { try { if (mControl.GetConfig.UseSmartIO == true) { Open = false; SmartIO.Close(); } else { PIO821.PIO821_CloseBoard(0); } } catch (Exception Msg) { MessageBox.Show(Msg.Message + "\n" + Msg.StackTrace); } } finally { } #endif return; }
/// <summary> /// 지정 포트가 동작 되었는지 읽어 온다. /// </summary> /// <param name="Pos"></param> /// <returns></returns> public bool inportb(short Pos) { __IOData__ Value = IOCheck(Pos); #if PROGRAM_RUNNING bool Data = false; ushort DIVal = 0; ushort wRetVal; //receive the digital single on the board you choose wRetVal = PIO821.PIO821_DigitalIn((byte)0, out DIVal); if (wRetVal > 0) { MessageBox.Show("*** PIO821_DigitalIn() error ! ***"); } else { Data = false; if (((byte)~DIVal & Value.Data) == Value.Data) { Data = true; } } return(Data); #else return(false); #endif }
/// <summary> /// I/O 제어 보드를 오픈한다. /// </summary> /// <returns></returns> public bool OpenIO() { #if PROGRAM_RUNNING try { try { wTotalBoard = PIO821.PIO821_TotalBoard(); if (wTotalBoard == 0) { MessageBox.Show("NO PIO-821 CARD !!!"); Open = false; return(false); } //active board PIO821.PIO821_ActiveBoard(0); BoaredMaximum = wTotalBoard - 1; Open = true; IOInit(); } catch (Exception Msg) { MessageBox.Show(Msg.Message + "\n" + Msg.StackTrace); } } finally { } #endif return(true); }
byte[] MODBUS_RTU_Out = { 0x01, 0x10, 0x00, 0x00, 0x00, 0x01, 0x02, 0, 0, 0, 0 }; //GSL-DT4C coils write //byte[] MODBUS_RTU_Out = { 0x01, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x02, 0x00, 0x00, 0x00, 0x00 }; /// <summary> /// P32C32 지정된 카드에 지정된 포트로 출력을 On/Off 한다. /// </summary> /// <param name="Card"></param> /// <param name="Port"></param> /// <param name="Value"></param> public void outportb() { #if PROGRAM_RUNNING try { try { if (mControl.GetConfig.UseSmartIO == true) { ushort crc16; MODBUS_RTU_Out[8] = OutData[0]; MODBUS_RTU_Out[7] = OutData[1]; crc16 = CRC16(MODBUS_RTU_Out, MODBUS_RTU_Out.Length - 2); MODBUS_RTU_Out[MODBUS_RTU_Out.Length - 2] = (byte)((crc16 >> 0) & 0x00ff); MODBUS_RTU_Out[MODBUS_RTU_Out.Length - 1] = (byte)((crc16 >> 8) & 0x00ff); if (SmartIO.IsOpen == true) { //SmartIO.DiscardInBuffer(); //SmartIO.ReceivedBytesThreshold = 8; SmartIO.Write(MODBUS_RTU_Out, 0, MODBUS_RTU_Out.Length); } //SmartIO_out_old = SmartIO_out; } else { ushort Out = (ushort)(OutData[0] | (OutData[1] << 8)); PIO821.PIO821_DigitalOut((byte)0, Out); } } catch (Exception Msg) { MessageBox.Show(Msg.Message + "\n" + Msg.StackTrace); } } finally { } #endif return; }