public static bool TryUpdate(DroneConfiguration configuration, ConfigurationPacket packet)
 {
     bool updated = false;
     using (var ms = new MemoryStream(packet.Data))
     using (var sr = new StreamReader(ms))
     {
         string line;
         while ((line = sr.ReadLine()) != null)
         {
             Match match = _reKeyValue.Match(line);
             if (match.Success)
             {
                 string key = match.Groups["key"].Value;
                 IConfigurationItem item;
                 if (configuration.Items.TryGetValue(key, out item))
                 {
                     string value = match.Groups["value"].Value;
                     if (item.TryUpdate(value))
                     {
                         updated = true;
                     }
                 }
                 else
                 {
                     Trace.TraceWarning("Configuration key {0} is not supported by parser. Original line: {1}", key, line);
                 }
             }
         }
     }
     return updated;
 }
Example #2
0
        public static bool TryUpdate(DroneConfiguration configuration, ConfigurationPacket packet)
        {
            bool updated = false;

            using (var ms = new MemoryStream(packet.Data))
                using (var sr = new StreamReader(ms))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        Match match = _reKeyValue.Match(line);
                        if (match.Success)
                        {
                            string             key = match.Groups["key"].Value;
                            IConfigurationItem item;
                            if (configuration.Items.TryGetValue(key, out item))
                            {
                                string value = match.Groups["value"].Value;
                                if (item.TryUpdate(value))
                                {
                                    updated = true;
                                }
                            }
                            else
                            {
                                Trace.TraceWarning("Configuration key {0} is not supported by parser. Original line: {1}", key, line);
                            }
                        }
                    }
                }
            return(updated);
        }
        public DroneClient(string hostname)
        {
            _networkConfiguration = new NetworkConfiguration(hostname);
            _droneConfiguration = new DroneConfiguration();

            _commandQueue = new ConcurrentQueue<ATCommand>();

            _commandSender = new CommandSender(_networkConfiguration, _commandQueue);
            _navdataAcquisition = new NavdataAcquisition(_networkConfiguration, OnNavdataPacketAcquired, OnNavdataAcquisitionStopped);
            _videoAcquisition = new VideoAcquisition(_networkConfiguration, OnVideoPacketAcquired);
            _configurationAcquisition = new ConfigurationAcquisition(_networkConfiguration, OnConfigurationPacketAcquired);
            _watchdog = new Watchdog(_navdataAcquisition, _commandSender, _videoAcquisition);
        }
 private void OnConfigurationUpdated(DroneConfiguration configuration)
 {
   if (configuration.Video.Codec != VideoCodecType.H264_360P_SLRS || configuration.Video.MaxBitrate != 100 || configuration.Video.BitrateCtrlMode != VideoBitrateControlMode.Dynamic)
   {
     droneClient.Send(configuration.Video.Codec.Set(VideoCodecType.H264_360P_SLRS).ToCommand());
     droneClient.Send(configuration.Video.MaxBitrate.Set(100).ToCommand());
     droneClient.Send(configuration.Video.BitrateCtrlMode.Set(VideoBitrateControlMode.Dynamic).ToCommand());
   }
 }