Example #1
0
        //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);
                //}
            }
            //}
        }
Example #2
0
 //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);
         //}
     }
     //}
 }
Example #3
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);
                    //}
                }
            }
            //}
        }
Example #4
0
        //scan DAC slave status
        private void systemScan(FlowVar fv)
        {
            if (keyOfIOScan)
            {
                for (int ch = 0; ch < 4; ch++)
                {
                    Value[ch] = GetOutputValue((DACChannel)ch);

                    int nIndexMode = 0;
                    if (ch == 0)
                    {
                        nIndexMode = (int)dacPara.RangeModeCH0;
                    }
                    else if (ch == 1)
                    {
                        nIndexMode = (int)dacPara.RangeModeCH1;
                    }
                    else if (ch == 2)
                    {
                        nIndexMode = (int)dacPara.RangeModeCH2;
                    }
                    else
                    {
                        nIndexMode = (int)dacPara.RangeModeCH3;
                    }

                    double dTempData = Value[ch];
                    dTempData   = g_nModeValue[nIndexMode] + (dTempData * g_nModeLength[nIndexMode] / 0xFFFF);
                    Voltage[ch] = dTempData;
                }
            }
        }
Example #5
0
        //scan M2X4 slave IO _axis
        private void systemScan(FlowVar fv)
        {
            //while (true)
            //{
            if (keyOfIOStatus)
            {
                U16 status = 0;
                I16 rt     = CCMNet.CS_mnet_m204_get_io_status(RingNoOfMNet, axisPara.SlaveIP, (U16)axisPara.AxisNo, 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.IsHome = false;
                }

                //Thread.Sleep(50);
            }
            //}
        }
Example #6
0
        public static IFlowSource <T> FilterChanges <T>(this IFlowSource <T> source, IDisposer?disposer = null)
        {
            var filtered = new FlowVar <T>(source.Value, disposer);

            // FlowVar ignores assignments when new value is equal to old one (so - we filter the changes)
            source.AddSubscription(filtered, () => { filtered.Value = source.Value; });
            return(filtered);
        }
Example #7
0
        //scan ADC slave status
        private void systemScan(FlowVar fv)
        {
            if (keyOfIOScan)
            {
                for (int ch = 0; ch < 4; ch++)
                {
                    Value[ch] = GetInputValue((ADCChannel)ch);

                    int nIndexMode = 0;
                    if (ch == 0)
                    {
                        nIndexMode = (int)adcPara.ADCRangeModeCH0;
                    }
                    else if (ch == 1)
                    {
                        nIndexMode = (int)adcPara.ADCRangeModeCH1;
                    }
                    else if (ch == 2)
                    {
                        nIndexMode = (int)adcPara.ADCRangeModeCH2;
                    }
                    else
                    {
                        nIndexMode = (int)adcPara.ADCRangeModeCH3;
                    }

                    //double dTempData = Value[ch] + 0x8000;
                    //if (dTempData >= 0x10000)
                    //    dTempData -= 0x10000;
                    double dTempData = Value[ch];

                    dTempData   = g_nModeValue[nIndexMode] + (dTempData * g_nModeLength[nIndexMode] / 0xFFFF);
                    Voltage[ch] = dTempData;
                }
            }
        }
Example #8
0
 private void FlowAction(FlowVar flowVar)
 {
     Blinding();
 }