示例#1
0
        private Global()
        {
            MessageHub = new TinyMessengerHub();

            Texts = new ResXResourceSet(@".\Resources\Texts.resx");

            MessageHub.Subscribe<UserBoatsRetrieved>((m) => {
                UserBoats = m.Content;
#if DEBUG                
                MessageHub.PublishAsync(new LogMessage(this, new LogText(Texts.GetString("UserBoatsRetrieved"))));
#endif
            });

            MessageHub.Subscribe<SelectedBoatRefreshed>((m) => {
                Boat = m.Content;
                Boat.FixTime = DateTime.Now;
                if(Boat.FixQuality == InstrumentsData.FixQualityType.ESTIMATED_DEAD_RECKONING)
                {
                    MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("BoatDataRefreshedDeadReckoning")} - {Boat.UserName}'s {Boat.BoatName} - {DateTime.Now.ToString("hh:mm:ss")}", Color.Goldenrod)));
                } else
                {
                    MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("BoatDataRefreshed")} - {Boat.UserName}'s {Boat.BoatName} - {DateTime.Now.ToString("hh:mm:ss")}", Color.DarkGreen)));
                }
                Boat.toInstrumentsData(ref boatData);
                NmeaServer.SendData();
            });

            NmeaServer = new NMEAServer(ref boatData, NmeaTcpPort);
            NmeaServer.OnServerStarted += delegate
            {
                MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("NMEAServerStarted")} {NmeaTcpPort}")));
            };
            NmeaServer.OnServerStop += delegate
            {
                MessageHub.PublishAsync(new LogMessage(this, new LogText(Texts.GetString("NMEAServerStopped"))));
            };
            NmeaServer.OnNMEASent += NmeaServer_OnNMEASent;
            NmeaServer.OnServerError += NmeaServer_OnServerError;
            NmeaServer.OnClientConnected += NmeaServer_OnClientConnected;

            DeadReckoning.Active = true;
            DeadReckoning.Rate = 1;
            DeadReckoning.StartDeadReckoningTask();
        }
示例#2
0
 private void NmeaServer_OnClientConnected(string address)
 {
     MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("ClientConnected")}{address}")));
     NmeaServer.SendData();
 }