Exemple #1
0
        public override void Send()
        {
            CoAPSettings.Instance.AddressFamily = System.Net.Sockets.AddressFamily.InterNetworkV6;
            byte[]        payload        = this.ToBytes();
            TestStatus    result         = new TestStatus();
            TestManager   m_test_manager = new TestManager();
            BasicReporter r = new BasicReporter(result);

            m_test_manager.TestReporter = r;

            CoApFsuCommand cmd = new CoApFsuCommand();

            cmd.CoApPayload           = this.ToBytes();
            FsuFacade.UseSecurePort   = false;
            FsuFacade.UseNullHeader   = false;
            FsuFacade.RequiresUserPIN = false;
            FileLogger.Write(String.Format("FsuFacade.UseSecurePort={0}", FsuFacade.UseSecurePort));
            FileLogger.Write(String.Format("FsuFacade.UseNullHeader={0}", FsuFacade.UseNullHeader));
            FileLogger.Write(String.Format("FsuFacade.RequiresUserPIN={0}", FsuFacade.RequiresUserPIN));
            CattEng.Test test = cmd.ToTest(this.IpAddress);//);SSNUtils.MiscTypes.fsu_ip_address);

            m_test_manager.Add(test);
            DateTime startTime = DateTime.Now;

            while (!m_test_manager.Empty)
            {
                Console.WriteLine("Sleeping");
                Thread.Sleep(50);
                DateTime now  = DateTime.Now;
                TimeSpan diff = now - startTime;
                if (diff.TotalMilliseconds > CoApSettings.Instance.RequestTimeout)
                {
                    m_test_manager.Clear();
                    break;
                }
            }

            CoApFsuTest t = (CoApFsuTest)r.TestResult;

            FileLogger.Write(String.Format("Fsu call returned {0}", r.TestResult.CurStatus));
            try
            {
                CoApFsuResponse resp        = (CoApFsuResponse)r.TestResult.ResponseResult.response;
                byte[]          respPayload = resp.Payload;

                //CoAPResponse cr = new CoAPResponse();
                //cr.FromByteStream(respPayload);
                //CoAPPayload p = cr.Payload;
                base.SetGetResult(resp.Payload);
                string toLog = SSNUtils.Conversion.BytesToHexView(resp.Payload);
                FileLogger.Write(String.Format("Payload returned:\n {0}", toLog));
            }
            catch
            {
                base.SetGetResult(new byte[0]);
            }
            //(p.ToStream(0));        }
        }
Exemple #2
0
        private void treeResources_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            CoApGet get = new CoApGet();

            get.IpAddress  = lstDevices.SelectedItem.ToString();
            get.ServerPort = Convert.ToInt32(cboPort.Text);
            get.URI        = treeResources.SelectedNode.Text;
            if (NetworkInterface.Instance.UsingFSU)
            {
                byte[]        payload        = get.ToBytes();
                TestStatus    result         = new TestStatus();
                TestManager   m_test_manager = new TestManager();
                BasicReporter r = new BasicReporter(result);
                m_test_manager.TestReporter = r;

                CoApFsuCommand cmd = new CoApFsuCommand();
                cmd.CoApPayload           = get.ToBytes();
                FsuFacade.UseSecurePort   = false;
                FsuFacade.UseNullHeader   = false;
                FsuFacade.RequiresUserPIN = false;
                FileLogger.Write(String.Format("FsuFacade.UseSecurePort={0}", FsuFacade.UseSecurePort));
                FileLogger.Write(String.Format("FsuFacade.UseNullHeader={0}", FsuFacade.UseNullHeader));
                FileLogger.Write(String.Format("FsuFacade.RequiresUserPIN={0}", FsuFacade.RequiresUserPIN));
                CattEng.Test test = cmd.ToTest(lstDevices.SelectedItem.ToString());//);SSNUtils.MiscTypes.fsu_ip_address);

                m_test_manager.Add(test);
                while (!m_test_manager.Empty)
                {
                    Console.WriteLine("Sleeping");
                    Thread.Sleep(50);
                }

                CoApFsuTest     t           = (CoApFsuTest)r.TestResult;
                CoApFsuResponse resp        = (CoApFsuResponse)r.TestResult.ResponseResult.response;
                byte[]          respPayload = resp.Payload;
                //CoAPResponse cr = new CoAPResponse();
                //cr.FromByteStream(respPayload);
                //CoAPPayload p = cr.Payload;
                get.SetGetResult(resp.Payload);//(p.ToStream(0));
            }
            else
            {
                get.Send();
            }
            txtResult.Text = get.Response.ToString();
            Cursor.Current = Cursors.Default;
        }