Exemplo n.º 1
0
        private void OperationIOCard()
        {
            TaskOperationIOCard = new Task(() =>
            {
                /// <summary>
                ///  高八位   低八位
                /// 00000000 00000000
                ///   15-8   76543210
                /// </summary>
                long InPutData    = 0;
                long InPutDataOld = 0;
                while (TaskControl)
                {
                    lock (balanceLock_IOOut)
                    {
                        if (IOOut.Count > 0)                                      //IO输出列队中有值?
                        {
                            long OutPutData = (long)IOOut.Dequeue();              //取出值
                            WENYU_PIO32P.WY_SetOutPutData(DeviceID0, OutPutData); //io输出值
                        }
                    }

                    WENYU_PIO32P.WY_GetInPutData(DeviceID0, ref InPutData); //io读取值
                    if (InPutDataOld != InPutData)                          //输入值变化了?
                    {
                        InPutDataOld = InPutData;                           //将变化后的值更新到InPutDataOld
                        IOIn.Enqueue((int)InPutDataOld);                    //将值加入输入列队
                    }
                    Thread.Sleep(1);
                }
            });
            TaskOperationIOCard.Start();//开始线程
        }
Exemplo n.º 2
0
        public IOManager()//构造函数
        {
            IOOut      = new Queue();
            IOIn       = new Queue();
            ManagerOut = new Queue();
            ManagerIn  = new Queue();
            int Result = WENYU_PIO32P.WY_Open(0, ref DeviceID0);//打开IO卡

            if (Result == 0)
            {
                OperationIOCard();
                ProcessData();
                EventNotification();
            }
        }