コード例 #1
0
 /// <summary>
 /// 体制服务
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void StopService(object sender, EventArgs e)
 {
     if (CommunicationServices.Stop())
     {
         SetServerInfoInputStatus(true);
     }
 }
コード例 #2
0
        public byte[] WriteBytes(byte[] sendMessage)
        {
            switch (loggerType)
            {
            case 1:
                sendMessage[0] = 0x02;
                sendMessage[1] = 0x07;
                sendMessage[2] = 0x02;
                sendMessage[3] = (byte)addressSection.MemoryNumber;
                sendMessage[4] = 0x3A;
                sendMessage[5] = (byte)addressSection.MemoryAddress;
                sendMessage[6] = (byte)(addressSection.MemoryAddress >> 8);
                return(CommunicationServices.AddCRC(7, sendMessage));

            default:
                sendMessage[0] = 0x02;
                sendMessage[1] = addressSection.LengthLSB;
                sendMessage[2] = addressSection.LengthMSB;
                sendMessage[3] = (byte)addressSection.MemoryNumber;
                sendMessage[4] = addressSection.MemoryAddLSB;
                sendMessage[5] = addressSection.MemoryAddMSB;
                sendMessage[6] = (byte)0x00;
                sendMessage[7] = (byte)0x00;
                return(CommunicationServices.AddCRC(8, sendMessage));
            }
        }
コード例 #3
0
        /// <summary>
        /// 开始服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartService(object sender, EventArgs e)
        {
            if (!ParseServerAddress()) return;

            if (CommunicationServices.Start(new IPEndPoint(_serverAddress, _serverPort)))
            {
                SetServerInfoInputStatus(false);
            }
        }
コード例 #4
0
 /// <summary>
 /// 窗口关闭处理程序
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnClosing(object sender, CancelEventArgs e)
 {
     try
     {
         _statusBarTimer.Stop();
         CommunicationServices.Close();
     }
     catch (Exception ex)
     {
         e.Cancel = true;
         LogService.Instance.Error("通信服务停止失败", ex);
         MessageBox.Show("程序关闭时发生严重错误,请检查错误信息。", "警告", MessageBoxButton.OK);
     }
 }
コード例 #5
0
        public byte[] WriteBytes(byte[] sendMessage)
        {
            switch (loggerType)
            {
            case 1:
                sendMessage[0] = 0x02;
                sendMessage[1] = 0x07;
                sendMessage[2] = 0x02;
                sendMessage[3] = 0x01;
                sendMessage[4] = 0x3A;
                sendMessage[5] = 0x00;
                sendMessage[6] = 0x00;
                return(CommunicationServices.AddCRC(7, sendMessage));

            case 3:
                sendMessage[0] = 0x02;
                sendMessage[1] = 0x06;
                sendMessage[2] = 0x00;
                sendMessage[3] = 0x01;
                sendMessage[4] = 0x46;
                sendMessage[5] = 0x00;
                sendMessage[6] = 0x00;
                sendMessage[7] = 0x00;
                return(CommunicationServices.AddCRC(8, sendMessage));

            case 6:
                sendMessage[0] = 0x02;
                sendMessage[1] = 0x06;
                sendMessage[2] = 0x00;
                sendMessage[3] = 0x01;
                sendMessage[4] = 0x63;
                sendMessage[5] = 0x00;
                sendMessage[6] = 0x00;
                sendMessage[7] = 0x00;
                return(CommunicationServices.AddCRC(8, sendMessage));

            default:
                return(null);
            }
        }
コード例 #6
0
        public void TestLinkBudgetsAlongAPath()
        {
            var Frequency = 14500000000.0;
            var Power     = 1000.0;
            var DataRate  = 16000000.0;
            var Bandwidth = 20000000.0;

            var request = new CommunicationData();

            request.OutputUnits = OutputUnit.Decibels;
            // Transmitter
            var td = new TransmitterData();
            var sd = new SiteData();

            sd.Location         = new ServiceCartographic(42.0, -105.0, 2000.0);
            sd.MeanSeaLevel     = true;
            td.Path             = sd;
            td.PathRouteType    = RouteTypes.FixedSite;
            td.Frequency        = Frequency;
            td.Power            = Power;
            td.DataRate         = DataRate;
            request.Transmitter = td;
            // Interference Sources
            var jammer1     = new TransmitterData();
            var jammer1Path = new SiteData();

            jammer1Path.Location     = new ServiceCartographic(42.001, -105.0, 1900);
            jammer1Path.MeanSeaLevel = true;
            jammer1.Path             = jammer1Path;
            jammer1.PathRouteType    = RouteTypes.FixedSite;
            jammer1.Frequency        = Frequency;
            jammer1.Power            = Power;
            jammer1.DataRate         = DataRate;

            var jammer2     = new TransmitterData();
            var jammer2Path = new SiteData();

            jammer2Path.Location     = new ServiceCartographic(41.997, -105.0, 1900);
            jammer2Path.MeanSeaLevel = true;
            jammer2.Path             = jammer1Path;
            jammer2.PathRouteType    = RouteTypes.FixedSite;
            jammer2.Frequency        = Frequency;
            jammer2.Power            = Power;
            jammer2.DataRate         = DataRate;

            request.InterferenceSources = new List <TransmitterData>();
            request.InterferenceSources.Add(jammer1);
            request.InterferenceSources.Add(jammer2);
            // Receiver
            var receiver     = new ReceiverData();
            var receiverPath = new GreatArcRouteData(2);

            receiverPath.Waypoints[0].Position                 = new ServiceCartographic(41, -105.0, 2000.0);
            receiverPath.Waypoints[0].Time                     = new DateTimeOffset(2016, 02, 23, 4, 44, 0, new TimeSpan(0));
            receiverPath.Waypoints[1].Position                 = new ServiceCartographic(43, -104.0, 2000.0);
            receiverPath.Waypoints[1].Time                     = new DateTimeOffset(2016, 02, 23, 5, 44, 0, new TimeSpan(0));
            receiverPath.OutputSettings.Step                   = 900;
            receiverPath.OutputSettings.TimeFormat             = TimeRepresentation.UTC;
            receiverPath.OutputSettings.CoordinateFormat.Coord = CoordinateRepresentation.LLA;
            receiverPath.OutputSettings.CoordinateFormat.Frame = FrameRepresentation.Fixed;
            receiver.Path                 = receiverPath;
            receiver.PathRouteType        = RouteTypes.GreatArc;
            receiver.TargetFrequency      = Frequency;
            receiver.Bandwidth            = Bandwidth;
            receiver.AmplifierGain        = 100;
            receiver.NoiseFactor          = 2.0;
            receiver.ReferenceTemperature = 16.85;
            request.Receiver              = receiver;
            // Other settings
            request.UseTirem = true;
            request.TiremSettings.SurfaceHumidity     = 10.0;
            request.TiremSettings.SurfaceRefractivity = 200.0;

            // dump the request to see the JSON created
            //File.WriteAllText(@".\CommRequest.json",request.ToString());

            var commResult = CommunicationServices.GetLinkBudget(request).Result;

            Assert.That(commResult != null);
            Assert.That(commResult.LinkBudgets != null);
            Assert.That(commResult.LinkBudgets.Count == 5);
            Assert.AreEqual(0.499, commResult.LinkBudgets[0].BitErrorRate, 1e-3);
        }