Example #1
0
        /// <summary>
        /// 仪器巡检:仅巡检部分设备,不去更新控制对象。
        /// </summary>
        /// <param name="inToDetectDeviceType"></param>
        public void InstrumentDetect(InstrumentType[] inToDetectDeviceType)
        {
            ProgressShower tmpShower = ProgressShower.CurrentShower;

            tmpShower.ShowMe();
            try
            {
                int tmpIndex = 0;
                int tmpCount = this.m_CurrentInstruments.Count;

                IAsyncResult[] tmpTasksResult = new IAsyncResult[tmpCount];
                //(WWG 加入ISOPT)
                Action <InstrumentInfo>[] tmpActions = new Action <InstrumentInfo> [tmpCount];

                foreach (InstrumentInfo tmpInstrumentInfo in this.m_CurrentInstruments)
                {
                    tmpShower.SetTaskAndProgress("正在巡检" + tmpInstrumentInfo.InstrumentName + "......,地址:" + tmpInstrumentInfo.IpAddress, 0);
                    //tmpShower.SetTaskAndProgress("正在巡检" + tmpInstrumentInfo.InstrumentName + "......,地址:" + tmpInstrumentInfo.IpAddress, tmpIndex * 100 / tmpCount);
                    if (tmpInstrumentInfo.Enabled)
                    {
                        if (inToDetectDeviceType.Contains(tmpInstrumentInfo.InstrumentTypeID))
                        {
                            Action <InstrumentInfo> task = (inInstrumentInfo) =>
                            {
                                UpdateInstrumentInfo(inInstrumentInfo);
                            };
                            tmpTasksResult[tmpIndex] = task.BeginInvoke(tmpInstrumentInfo, null, null);
                            tmpActions[tmpIndex]     = task;
                        }
                    }

                    tmpIndex++;
                    //tmpShower.SetTaskAndProgress("巡检" + tmpInstrumentInfo.InstrumentName + "......完毕", tmpIndex * 100 / tmpCount);
                }
                for (int i = 0; i < tmpCount; i++)
                {
                    InstrumentInfo tmpInstrumentInfo = this.m_CurrentInstruments[i];
                    if (tmpActions[i] != null)
                    {
                        tmpShower.SetTaskAndProgress("等待仪表" + tmpInstrumentInfo.InstrumentName + "结束巡检,地址:" + tmpInstrumentInfo.IpAddress, i * 100 / tmpCount);
                        tmpActions[i].EndInvoke(tmpTasksResult[i]);
                        tmpShower.SetTaskAndProgress("仪表" + tmpInstrumentInfo.InstrumentName + "连接完毕", i * 100 / tmpCount);
                    }
                }
            }
            finally
            {
                tmpShower.HideMe();
                GC.Collect();
            }
        }
Example #2
0
        /// <summary>
        /// 单个仪表连接
        /// </summary>
        /// <param name="inToDetectDeviceType"></param>
        public void CreateInstrumentInstanceByInstrumentType(InstrumentType inToDetectDeviceType)
        {
            ProgressShower tmpShower = ProgressShower.CurrentShower;

            tmpShower.ShowMe();
            try
            {
                int tmpIndex = 0;
                int tmpCount = this.m_CurrentInstruments.Count;

                IAsyncResult[]            tmpTasksResult = new IAsyncResult[tmpCount];
                Action <InstrumentInfo>[] tmpActions     = new Action <InstrumentInfo> [tmpCount];

                List <DCPowerBase> tmpDCPowers = new List <DCPowerBase>();
                foreach (InstrumentInfo tmpInstrumentInfo in this.m_CurrentInstruments)
                {
                    //tmpShower.SetTaskAndProgress("正在巡检" + tmpInstrumentInfo.InstrumentName + "......,地址:" + tmpInstrumentInfo.IpAddress, tmpIndex * 100 / tmpCount);
                    if (tmpInstrumentInfo.Enabled)
                    {
                        if (inToDetectDeviceType == tmpInstrumentInfo.InstrumentTypeID)
                        {
                            tmpShower.SetTaskAndProgress("正在巡检" + tmpInstrumentInfo.InstrumentName + "......,地址:" + tmpInstrumentInfo.IpAddress, 0);
                            Action <InstrumentInfo> task = (inInstrumentInfo) =>
                            {
                                CreateInstrumentCtrlObj(tmpDCPowers, inInstrumentInfo);
                            };
                            tmpTasksResult[tmpIndex] = task.BeginInvoke(tmpInstrumentInfo, null, null);
                            tmpActions[tmpIndex]     = task;
                        }
                    }

                    tmpIndex++;
                    //tmpShower.SetTaskAndProgress("巡检" + tmpInstrumentInfo.InstrumentName + "......完毕", tmpIndex * 100 / tmpCount);
                }
                for (int i = 0; i < tmpCount; i++)
                {
                    InstrumentInfo tmpInstrumentInfo = this.m_CurrentInstruments[i];
                    if (tmpActions[i] != null)
                    {
                        tmpShower.SetTaskAndProgress("等待仪表" + tmpInstrumentInfo.InstrumentName + "结束巡检,地址:" + tmpInstrumentInfo.IpAddress, i * 100 / tmpCount);
                        tmpActions[i].EndInvoke(tmpTasksResult[i]);
                        tmpShower.SetTaskAndProgress("仪表" + tmpInstrumentInfo.InstrumentName + "连接完毕", i * 100 / tmpCount);
                    }
                }

                if ((inToDetectDeviceType == InstrumentType.DCPower) || (inToDetectDeviceType == InstrumentType.DCPowerAnalyzer))
                {
                    this.m_DCPowers = tmpDCPowers.ToArray();
                }

                this.InitSysCapability();


                //List<string> tmpIpAddressList = new List<string>();
                //string tmpIpAddress = tmpDCPowers[0].ResourceName;
                //foreach(DCPowerBase APowerBase in tmpDCPowers)
                //{
                //    tmpIpAddressList.Add(APowerBase.ResourceName);
                //}

                //int index = 0;
                //foreach(DCPowerBase APowerBase in this.m_DCPowers)
                //{
                //    if (APowerBase != null)
                //    {
                //        if (tmpIpAddressList.Contains(tmpIpAddress))
                //        {
                //            this.m_DCPowers[index] = tmpDCPowers[0];
                //            break;

                //        }
                //    }
                //    index++;
                //}

                //if (tmpDCPowers.Count() > 0)
                //{
                //    this.m_DCPowers = tmpDCPowers.ToArray();
                //    this.m_DCPowers.
                //}
            }
            finally
            {
                tmpShower.HideMe();
                GC.Collect();
            }
        }
Example #3
0
        /// <summary>
        /// 系统连接过程
        /// </summary>
        public void ConnectInner()
        {
            ProgressShower tmpTaskShower = ProgressShower.CurrentShower;

            tmpTaskShower.ShowMe();
            try
            {
                List <DCPowerBase> tmpDCPowers = new List <DCPowerBase>();

                int tmpCount = this.m_CurrentInstruments.Count;
                int tmpIndex = 0;
                tmpTaskShower.SetTaskAndProgress("开始连接测试系统硬件", 0);

                IAsyncResult[] tmpTasksResult = new IAsyncResult[tmpCount];
                Action <List <DCPowerBase>, InstrumentInfo>[] tmpActions = new Action <List <DCPowerBase>, InstrumentInfo> [tmpCount];
                foreach (InstrumentInfo tmpInstrumentInfo in this.m_CurrentInstruments)
                {
                    //tmpTaskShower.SetTaskAndProgress("开始连接" + tmpInstrumentInfo.InstrumentName + "......", tmpIndex * 100 / tmpCount);
                    tmpTaskShower.SetTaskAndProgress("开始连接" + tmpInstrumentInfo.InstrumentName + "......", 2);
                    if (tmpInstrumentInfo.Enabled)
                    {
                        Action <List <DCPowerBase>, InstrumentInfo> task = (inDCPowers, inInstrumentInfo) =>
                        {
                            this.CreateInstrumentCtrlObj(inDCPowers, inInstrumentInfo);
                            //this.ConnectInner();
                        };

                        //task.Invoke(tmpDCPowers, tmpInstrumentInfo);
                        tmpTasksResult[tmpIndex] = task.BeginInvoke(tmpDCPowers, tmpInstrumentInfo, null, null);
                        //tmpTasksResult[tmpIndex] = null;
                        //task.Invoke(tmpDCPowers, tmpInstrumentInfo);
                        tmpActions[tmpIndex] = task;
                        //this.CreateInstrumentCtrlObj(tmpDCPowers, tmpInstrumentInfo);
                    }
                    else
                    {
                        tmpTasksResult[tmpIndex] = null;
                        tmpActions[tmpIndex]     = null;
                    }
                    tmpIndex++;
                    //tmpTaskShower.SetTaskAndProgress("仪表" + tmpInstrumentInfo.InstrumentName + "连接完毕", tmpIndex * 100 / tmpCount);
                }

                //等待测试结束
                for (int i = 0; i < tmpCount; i++)
                {
                    InstrumentInfo tmpInstrumentInfo = this.m_CurrentInstruments[i];
                    if (tmpActions[i] != null)
                    {
                        tmpTaskShower.SetTaskAndProgress("等待仪表" + tmpInstrumentInfo.InstrumentName + "结束连接", i * 100 / tmpCount);
                        tmpActions[i].EndInvoke(tmpTasksResult[i]);
                        tmpTaskShower.SetTaskAndProgress("仪表" + tmpInstrumentInfo.InstrumentName + "连接完毕", i * 100 / tmpCount);
                    }
                }


                tmpTaskShower.SetTaskComplete(null, null);

                this.m_DCPowers = tmpDCPowers.ToArray();

                ///初始化系统能力
                this.InitSysCapability();
            }
            finally
            {
                tmpTaskShower.HideMe();
                GC.Collect();
            }
        }