Пример #1
0
        //scan DIO slave status
        private void systemScan(FlowVar fv)
        {
            //while (true)
            //{
            if (keyOfIOScan)
            {
                ushort uValue = BitConverterEx.ConvertToUInt16(Status1);
                if (uValue != _lastOutputValue)
                {
                    _lastOutputValue = uValue;
                    ushort uRet = CEtherCAT_DLL.CS_ECAT_Slave_DIO_Set_Output_Value(dIOPara.CardNo, dIOPara.NodeNo, g_uESCSlotID, uValue);

                    if (uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
                    {
                        throw new Exception("CS_ECAT_Slave_DIO_Set_Output_Value, " + GetEtherCATErrorCode(uRet));
                    }

                    //Thread.Sleep(15);
                    //if (Environment.ProcessorCount == 1 || (++_loops % 100) == 0)
                    //{
                    //    Thread.Sleep(1);
                    //}
                    //else
                    //{
                    //    Thread.SpinWait(_iterations);
                    //}
                }
            }
            //}
        }