//scan m1x1 slave IO status private void systemScan() { while (true) { if (keyOfIOStatus) { U32 status = 0; I16 rt = CCMNet.CS_mnet_m1_get_io_status(RingNoOfMNet, axisPara.SlaveIP, ref status); this.status.RDY = BitConverterEx.TestB(status, 0); this.status.ALM = BitConverterEx.TestB(status, 1); this.status.LimitP = BitConverterEx.TestB(status, 2); this.status.LimitN = BitConverterEx.TestB(status, 3); this.status.ORG = BitConverterEx.TestB(status, 4); this.status.DIR = BitConverterEx.TestB(status, 5); this.status.EMG = BitConverterEx.TestB(status, 6); this.status.PCS = BitConverterEx.TestB(status, 7); this.status.ERC = BitConverterEx.TestB(status, 8); this.status.ZPhase = BitConverterEx.TestB(status, 9); this.status.CLR = BitConverterEx.TestB(status, 10); this.status.Latch = BitConverterEx.TestB(status, 11); this.status.SD = BitConverterEx.TestB(status, 12); this.status.INP = BitConverterEx.TestB(status, 13); this.status.SVON = BitConverterEx.TestB(status, 14); this.status.RALM = BitConverterEx.TestB(status, 15); if (this.status.ALM || this.status.EMG) { this.status.Home = false; } Thread.Sleep(50); } } }
//scan DIO slave status private void systemScan(FlowVar fv) { //while (true) //{ if (keyOfIOScan) { I16 status; for (byte portNo = 0; portNo < 4; portNo++) { status = CCMNet.CS_mnet_io_input(RingNoOfMNet, dIOPara.SlaveIP, portNo); for (int i = 0; i < 8; i++) { Status1[portNo * 8 + i] = BitConverterEx.TestB(status, (byte)i); Status2[portNo, i] = BitConverterEx.TestB(status, (byte)i); } } //Thread.Sleep(15); //if (Environment.ProcessorCount == 1 || (++_loops % 100) == 0) //{ // Thread.Sleep(1); //} //else //{ // Thread.SpinWait(_iterations); //} } //} }
//scan DIO slave status private void systemScan(FlowVar fv) { //while (true) //{ if (keyOfIOScan) { ushort uValue = 0, uRet = 0; uRet = CEtherCAT_DLL.CS_ECAT_Slave_DIO_Get_Input_Value(dIOPara.CardNo, dIOPara.NodeNo, g_uESCSlotID, ref uValue); if (uRet == CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR) { for (int nBit = 0; nBit < 16; nBit++) { Status1[nBit] = BitConverterEx.TestB(uValue, (byte)nBit); Status2[nBit / 8, nBit % 8] = BitConverterEx.TestB(uValue, (byte)nBit); } } else { throw new Exception("CS_ECAT_Slave_DIO_Get_Input_Value, " + GetEtherCATErrorCode(uRet)); } //Thread.Sleep(15); //if (Environment.ProcessorCount == 1 || (++_loops % 100) == 0) //{ // Thread.Sleep(1); //} //else //{ // Thread.SpinWait(_iterations); //} } //} }
private byte getCheckDigit(List <byte> cmdCombined) { bool[] bits = BitConverterEx.GetBits(cmdCombined[0]); for (int j = 1; j < cmdCombined.Count; j++) { for (byte i = 0; i < 8; i++) { bits[i] ^= BitConverterEx.TestB(cmdCombined[j], i); } } return(BitConverterEx.ConvertToByte(bits)); }
private string getCheckDigit(string cmdCombined) { bool[] bits = BitConverterEx.GetBits((byte)cmdCombined[0]); for (int j = 1; j < cmdCombined.Length; j++) { for (byte i = 0; i < 8; i++) { bits[i] ^= BitConverterEx.TestB(cmdCombined[j], i); } } int upperBit = 0; int lowerBit = 0; for (byte i = 0; i < 4; i++) { BitConverterEx.SetBit(ref lowerBit, i, bits[i]); BitConverterEx.SetBit(ref upperBit, i, bits[i + 4]); } return(string.Format("{0:x}{1:x}", upperBit, lowerBit)); }
//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); } } }