Exemplo n.º 1
0
 public TestRunner(SwitchController sc,
                   NetworkAnalyzer av,
                   Oscillograph osc)
 {
     this.av  = av;
     this.osc = osc;
     this.sc  = sc;
 }
Exemplo n.º 2
0
        public void Start(string offlinePcapDumpPath = null)
        {
            var stateHandler = new StateHandler(_gameData);

            using (new StaticFileServer())
                using (var ws = new SocketServer(stateHandler, _gameData))
                {
                    var packageHandler  = new AlbionPackageHandler(stateHandler, _gameData);
                    var networkAnalyzer = new NetworkAnalyzer(packageHandler);

                    ws.Start();
                    networkAnalyzer.Start(offlinePcapDumpPath);
                }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //connect to db
            using (var dbContext = new DbContext())
            {
                //ensure initial data
                dbContext.Database.EnsureCreated();
                if (!dbContext.NetworkEvents.Any())
                {
                    dbContext.AddRange(DataGeneration.GenerateInitial());
                    dbContext.SaveChanges();
                }

                //query data
                var events = dbContext.NetworkEvents.ToList();

                //analyze data
                var networkAnalyzer = new NetworkAnalyzer();
                networkAnalyzer.Analyze(events);
                Console.WriteLine("Finished analyzing");
            }
        }
Exemplo n.º 4
0
 public SITest(ISwitch iSwitch, NetworkAnalyzer iNetworkAnalyzer, Dictionary <string, string> information)
 {
     this._switch      = iSwitch;
     this._analyzer    = iNetworkAnalyzer;
     this._information = information;
 }
Exemplo n.º 5
0
        /// <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;
            }
        }
Exemplo n.º 6
0
        /// <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));
        }