//scan DIO slave status private void systemScan() { while (true) { if (keyOfIOScan) { I16 status; U8 val = 0; for (byte portNo = 0; portNo < 4; portNo++) { status = CMNET_L132.CS_mnet_io_input((U16)dIOPara.CardSwitchNo, (U16)dIOPara.RingNoOfCard, dIOPara.SlaveIP, portNo, ref val); for (int i = 0; i < 8; i++) { Status1[portNo * 8 + i] = BitConverterEx.TestB(val, (byte)i); Status2[portNo, i] = BitConverterEx.TestB(val, (byte)i); } } Thread.Sleep(15); } } }
/// <summary> /// 設定Output數值 /// </summary> /// <param name="portNo">Port Number</param> /// <param name="bitNo">Bit Number</param> /// <param name="status">寫入成功回傳true,反之false(DI點一定false)</param> /// <returns></returns> public bool SetOutput2(PortNo portNo, BitNo bitNo, bool status) { if (dIOPara.IsActive) { U8 val = 0; CMNET_L132.CS_mnet_io_input((U16)dIOPara.CardSwitchNo, (U16)dIOPara.RingNoOfCard, dIOPara.SlaveIP, (U8)portNo, ref val); BitConverterEx.SetBit(ref val, (byte)bitNo, status); I16 retOfSetOutput = CMNET_L132.CS_mnet_io_output((U16)dIOPara.CardSwitchNo, (U16)dIOPara.RingNoOfCard, dIOPara.SlaveIP, (U8)portNo, val); if (retOfSetOutput >= 0) { return(true); } else { return(false); } } else { return(false); } }