コード例 #1
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <summary>
        /// 更新仪器标识信息
        /// </summary>
        /// <param name="inInstrumentInfo"></param>
        /// <param name="inInstrumentObj"></param>
        private void UpdateInstrumentIdentity(InstrumentInfo inInstrumentInfo, InstrumentBase inInstrumentObj)
        {
            if (inInstrumentObj == null)
            {
                inInstrumentInfo.ModelNo      = "";
                inInstrumentInfo.Identity     = "";
                inInstrumentInfo.SN           = "";
                inInstrumentInfo.OptionList   = "";
                inInstrumentInfo.ConnectOK    = devState.error;
                inInstrumentInfo.DevInfoState = devState.error;
                inInstrumentInfo.ErrorMsgs    = "未连接";
            }
            else
            {
                inInstrumentInfo.ModelNo    = inInstrumentObj.Model;
                inInstrumentInfo.Identity   = inInstrumentObj.Identity;
                inInstrumentInfo.SN         = inInstrumentObj.SerialNumber;
                inInstrumentInfo.OptionList = inInstrumentObj.Options;

                inInstrumentInfo.Manufacter = inInstrumentObj.Manufactor;

                inInstrumentInfo.ConnectOK    = devState.connect;
                inInstrumentInfo.DevInfoState = devState.connect;
                inInstrumentInfo.ErrorMsgs    = "";
            }
        }
コード例 #2
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
 private void SetInstrumentErrorInfo(InstrumentInfo inInstrumentInfo, string inErrorMsg)
 {
     inInstrumentInfo.ModelNo    = "";
     inInstrumentInfo.Manufacter = "";
     inInstrumentInfo.Identity   = "";
     inInstrumentInfo.SN         = "";
     inInstrumentInfo.OptionList = "";
     inInstrumentInfo.ConnectOK  = devState.error;
     inInstrumentInfo.ErrorMsgs  = inErrorMsg;
 }
コード例 #3
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <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();
            }
        }
コード例 #4
0
        public InstrumentInfo Clone()
        {
            InstrumentInfo Result = new InstrumentInfo()
            {
                ConnectOK        = this.ConnectOK,
                IDInInstitute    = this.IDInInstitute,
                Identity         = this.Identity,
                DevInfoState     = this.DevInfoState,
                Enabled          = this.Enabled,
                ErrorMsgs        = this.ErrorMsgs,
                InstrumentName   = this.InstrumentName,
                InstrumentTypeID = this.InstrumentTypeID,
                IpAddress        = this.IpAddress,
                Manufacter       = this.Manufacter,
                ModelNo          = this.ModelNo,
                OptionList       = this.OptionList,
                SN = this.SN,
            };

            return(Result);
        }
コード例 #5
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <summary>
        /// 更新设备信息
        /// </summary>
        /// <param name="tmpInstrumentInfo"></param>
        private static void UpdateInstrumentInfo(InstrumentInfo tmpInstrumentInfo)
        {
            try
            {
                GlobalStatusReport.Report(string.Format("UpdateInstrumentInfo 仪表名称:{0} 地址:{1},开始连接", tmpInstrumentInfo.InstrumentName, tmpInstrumentInfo.IpAddress));
                tmpInstrumentInfo.DevInfoState = devState.ischeck;
                string Identity   = "";
                string ModelNo    = "";
                string InstSN     = "";
                string Firmware   = "";
                string Options    = "";
                string Manufactor = "";
                ModelNo = ScpiInstrument.DetermineInstrumentInfo(tmpInstrumentInfo.IpAddress, out Identity, out InstSN, out Options, out Firmware, out Manufactor);
                if ((ModelNo == null) || (ModelNo == string.Empty))
                {
                    tmpInstrumentInfo.ConnectOK    = devState.error;
                    tmpInstrumentInfo.DevInfoState = devState.error;
#if Simulate
                    tmpInstrumentInfo.ConnectOK    = devState.connect;
                    tmpInstrumentInfo.DevInfoState = devState.connect;
#endif
                }
                else
                {
                    tmpInstrumentInfo.ConnectOK    = devState.connect;
                    tmpInstrumentInfo.DevInfoState = devState.connect;

                    tmpInstrumentInfo.ModelNo    = ModelNo;
                    tmpInstrumentInfo.Identity   = Identity;
                    tmpInstrumentInfo.SN         = InstSN;
                    tmpInstrumentInfo.OptionList = Options;
                    tmpInstrumentInfo.Manufacter = Manufactor;
                }
                GlobalStatusReport.Report(string.Format("UpdateInstrumentInfo 仪表名称:{0} 地址:{1},连接结束!", tmpInstrumentInfo.InstrumentName, tmpInstrumentInfo.IpAddress));
            }
            catch (Exception ex)
            {
                tmpInstrumentInfo.ConnectOK = devState.error;
            }
        }
コード例 #6
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <summary>
        /// 更新仪表控制对象
        /// </summary>
        /// <param name="tmpDCPowers"></param>
        /// <param name="tmpInstrumentInfo"></param>
        private void UpdateInstrumentCtrlObjIfNeeded(List <DCPowerBase> tmpDCPowers, InstrumentInfo tmpInstrumentInfo)
        {
            switch (tmpInstrumentInfo.InstrumentTypeID)
            {
            case InstrumentType.Pna:
                try
                {
                    bool bNeedUpdateCtrlObj = IfNeedUpdateCtrlObj(tmpInstrumentInfo.IpAddress, this.m_PNAScpiObj);
                    if (bNeedUpdateCtrlObj)
                    {
                        ///创建PNA对象
                        string tmpPnaIpAddr;
                        int    port = 5025;
                        VisaServices.GetLanConnectionInfo(tmpInstrumentInfo.IpAddress, out tmpPnaIpAddr, out port);
                        Type t = Type.GetTypeFromProgID("AgilentPNA835x.Application", tmpPnaIpAddr, true);
                        m_PNAApp        = (AgilentPNA835x.Application)Activator.CreateInstance(t);
                        m_PNASCPIParser = (AgilentPNA835x.ScpiStringParser)m_PNAApp.ScpiStringParser;

                        this.m_PNAScpiObj = NetworkAnalyzer.Connect(tmpInstrumentInfo.IpAddress, null
                                                                    , false);
                    }
                }
                catch (Exception ex)
                {
                    tmpInstrumentInfo.ConnectOK = devState.error;
                    tmpInstrumentInfo.ErrorMsgs = "型号不匹配";
                }
                break;

            case InstrumentType.InputMatrix:
                try
                {
                    bool bNeedUpdateCtrlObj = IfNeedUpdateCtrlObj(tmpInstrumentInfo.IpAddress, this.m_InputMatrix);
                    if (bNeedUpdateCtrlObj)
                    {
                        this.m_InputMatrix = Matrix.Connect(tmpInstrumentInfo.IpAddress, true, false);
                        //this.m_InputMatrixForHighPower = Matrix.Connect(tmpInstrumentInfo.IpAddress, true, true);
                        //this.m_InputMatrix = Matrix.Connect(tmpInstrumentInfo.IpAddress, true);
                    }
                }
                catch (Exception ex)
                {
                    tmpInstrumentInfo.ConnectOK = devState.error;
                    tmpInstrumentInfo.ErrorMsgs = "型号不匹配";
                }
                try
                {
                    bool bNeedUpdateCtrlObj = IfNeedUpdateCtrlObj(tmpInstrumentInfo.IpAddress, this.m_OutputMatrix);
                    if (bNeedUpdateCtrlObj)
                    {
                        this.m_OutputMatrix = Matrix.Connect(tmpInstrumentInfo.IpAddress, false, false);
                    }
                }
                catch (Exception ex)
                {
                    tmpInstrumentInfo.ConnectOK = devState.error;
                    tmpInstrumentInfo.ErrorMsgs = "型号不匹配";
                }
                break;
            }
        }
コード例 #7
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <summary>
        /// 更新仪表控制对象
        /// </summary>
        /// <param name="tmpDCPowers"></param>
        /// <param name="tmpInstrumentInfo"></param>
        private void CreateInstrumentCtrlObj(List <DCPowerBase> tmpDCPowers, InstrumentInfo tmpInstrumentInfo)
        {
            GlobalStatusReport.Report(string.Format("UpdateInstrumentInfo 仪表名称:{0} 地址:{1},开始连接", tmpInstrumentInfo.InstrumentName, tmpInstrumentInfo.IpAddress));
            switch (tmpInstrumentInfo.InstrumentTypeID)
            {
            case InstrumentType.Pna:
                try
                {
                    //置为巡检状态
                    tmpInstrumentInfo.DevInfoState = devState.ischeck;

                    this.m_PNAScpiObj = NetworkAnalyzer.Connect(tmpInstrumentInfo.IpAddress, null
                                                                , false);

                    if (this.m_PNAScpiObj != null)
                    {
                        //判断对应的连接License选件是否有,如果有,则继续,没有,报告错误;
                        LicenseCheckingResult tmpResult = this.Check_Pna_Connectivity_Licenses(this.m_PNAScpiObj.Model, this.m_PNAScpiObj.SerialNumber);

                        ///
                        tmpResult = LicenseCheckingResult.PNAPassed;

                        ///
                        if (tmpResult != LicenseCheckingResult.PNAPassed)
                        {
                            ///设置异常信息
                            this.SetInstrumentErrorInfo(
                                tmpInstrumentInfo,
                                string.Format("没有找到矢网{0}-{1}连接选件RAC1200-001",
                                              new object[] { this.m_PNAScpiObj.Model, this.m_PNAScpiObj.SerialNumber }));

                            this.m_PNAScpiObj    = null;
                            this.m_PNAApp        = null;
                            this.m_PNASCPIParser = null;

                            throw new Exception(string.Format("没有找到矢网{0}-{1}的连接选件RAC1200-001",
                                                              new object[] { this.m_PNAScpiObj.Model, this.m_PNAScpiObj.SerialNumber }));
                        }
                        else
                        {
                            ///创建PNA对象
                            string tmpPnaIpAddr;
                            int    port = 5025;
                            VisaServices.GetLanConnectionInfo(tmpInstrumentInfo.IpAddress, out tmpPnaIpAddr, out port);
                            Type t = Type.GetTypeFromProgID("AgilentPNA835x.Application", tmpPnaIpAddr, true);
                            m_PNAApp        = (AgilentPNA835x.Application)Activator.CreateInstance(t);
                            m_PNASCPIParser = (AgilentPNA835x.ScpiStringParser)m_PNAApp.ScpiStringParser;


                            UpdateInstrumentIdentity(tmpInstrumentInfo, this.m_PNAScpiObj);
                        }

                        //设置PNASource mathmatical on/off
                        if (PowerMode.NormalPower == ProjectName.CurrentPowerMode)
                        {
                            this.m_PNAScpiObj.SendSCPI("system:preferences:item:offset:src ON");
                        }
                        else if (PowerMode.HighPower == ProjectName.CurrentPowerMode)
                        {
                            this.m_PNAScpiObj.SendSCPI("system:preferences:item:offset:src OFF");
                        }
                        else
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.SetInstrumentErrorInfo(tmpInstrumentInfo, /*"连接错误,异常信息:"+*/ ex.Message);
                    //置为错误状态
                    tmpInstrumentInfo.DevInfoState = devState.error;
                }
                break;

            case InstrumentType.InputMatrix:
                try
                {
                    //置为巡检状态
                    tmpInstrumentInfo.DevInfoState = devState.ischeck;

                    this.m_InputMatrix = Matrix.Connect(tmpInstrumentInfo.IpAddress, true, false);

                    UpdateInstrumentIdentity(tmpInstrumentInfo, m_InputMatrix);
                }
                catch (Exception ex)
                {
                    this.SetInstrumentErrorInfo(tmpInstrumentInfo, /*"连接错误,异常信息:"+*/ ex.Message);
                    //置为错误状态
                    tmpInstrumentInfo.DevInfoState = devState.error;
                }
                break;

            case InstrumentType.OutputMatrix:
                try
                {
                    //置为巡检状态
                    tmpInstrumentInfo.DevInfoState = devState.ischeck;
                    this.m_OutputMatrix            = Matrix.Connect(tmpInstrumentInfo.IpAddress, false, false);
                    //this.m_OutputMatrix = Matrix.Connect(tmpInstrumentInfo.IpAddress, false);
                    UpdateInstrumentIdentity(tmpInstrumentInfo, this.m_OutputMatrix);
                }
                catch (Exception ex)
                {
                    this.SetInstrumentErrorInfo(tmpInstrumentInfo, /*"连接错误,异常信息:"+*/ ex.Message);
                    //置为错误状态
                    tmpInstrumentInfo.DevInfoState = devState.error;
                }
                break;
            }
            GlobalStatusReport.Report(string.Format("UpdateInstrumentInfo 仪表名称:{0} 地址:{1},连接结束", tmpInstrumentInfo.InstrumentName, tmpInstrumentInfo.IpAddress));
        }
コード例 #8
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <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();
            }
        }
コード例 #9
0
ファイル: SystemHardware.cs プロジェクト: lihuangroove/SG-PXA
        /// <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();
            }
        }