Exemple #1
1
        public void AddFiles(DroneConfig config, IList<string> sourceFiles, IList<string> referenceFiles)
        {
            if(config == null)
                throw new ArgumentNullException("config");

            if(sourceFiles == null)
                throw new ArgumentNullException("sourceFiles");

            if(referenceFiles == null)
                throw new ArgumentNullException("referenceFiles");

            var sourcesToAdd = sourceFiles.Except(config.SourceFiles).ToList();

            var referencesToAdd = referenceFiles.Except(config.ReferenceFiles).ToList();

            if (sourcesToAdd.Count == 0 && referencesToAdd.Count == 0)
            {
                this.log.Warn("no files added. files already exists in config");
                return;
            }

            var fileNotFound = this.EnsureFilesExists(config.DirPath, sourcesToAdd.Concat(referencesToAdd));

            if (fileNotFound)
                return;

            config.SourceFiles.AddRange(sourcesToAdd);
            config.ReferenceFiles.AddRange(referencesToAdd);

            foreach (var file in sourcesToAdd.Concat(referencesToAdd))
                this.log.Info("added '{0}'", file);
        }
Exemple #2
0
        private void SetDialogSettings(DroneConfig droneConfig, HudConfig hudConfig)
        {
            configSettings = new GeneralConfigBinding(droneConfig, hudConfig);
            configSettings.PropertyChanged += configSettings_PropertyChanged;

            this.DataContext = configSettings;
        }
Exemple #3
0
        public GeneralConfigWindow(DroneConfig droneConfig, HudConfig hudConfig)
        {
            InitializeComponent();
            SetDialogSettings(droneConfig, hudConfig);

            UpdateDependentHudCheckBoxes(hudConfig.ShowHud);
        }
Exemple #4
0
        public GeneralConfigBinding(DroneConfig droneConfig, HudConfig hudConfig)
        {
            networkUtils = new NetworkUtils();

            TakeOverDroneConfigSettings(droneConfig);
            TakeOverHudConfigSettings(hudConfig);
        }
Exemple #5
0
        private void InitializeDroneControl()
        {
            currentDroneConfig = new DroneConfig();
            currentDroneConfig.Load();

            InitializeDroneControl(currentDroneConfig);
        }
Exemple #6
0
        private void SaveDroneAndHudConfigStates(DroneConfig droneConfig /*, HudConfig hudConfig*/)
        {
            currentDroneConfig = droneConfig;
            //currentHudConfig = hudConfig;

            droneConfig.Save();
            //hudConfig.Save();
        }
Exemple #7
0
        private void SaveDroneAndHudConfigStates(DroneConfig droneConfig, HudConfig hudConfig)
        {
            currentDroneConfig = droneConfig;
            currentHudConfig   = hudConfig;

            droneConfig.Save();
            hudConfig.Save();
        }
Exemple #8
0
        public GeneralConfigWindow(DroneConfig droneConfig, HudConfig hudConfig)
        {
            InitializeComponent();
            SetDialogSettings(droneConfig, hudConfig);

            UpdateDependentHudCheckBoxes(hudConfig.ShowHud);
            UpdateFirmwareVersionComboBox(droneConfig.UseSpecificFirmwareVersion);
        }
Exemple #9
0
        public CommandSender(NetworkConnector networkConnector, String remoteIpAddress, int port, int timeoutValue, SupportedFirmwareVersion firmwareVersion, DroneCameraMode defaultCameraMode, DroneConfig droneConfig)
            : base(networkConnector, remoteIpAddress, port, timeoutValue)
        {
            this.firmwareVersion   = firmwareVersion;
            this.defaultCameraMode = defaultCameraMode;
            this.droneConfig       = droneConfig;

            ResetVariables();
        }
        public CommandSender(NetworkConnector networkConnector, String remoteIpAddress, int port, int timeoutValue, SupportedFirmwareVersion firmwareVersion, DroneCameraMode defaultCameraMode, DroneConfig droneConfig)
            : base(networkConnector, remoteIpAddress, port, timeoutValue)
        {
            this.firmwareVersion = firmwareVersion;
            this.defaultCameraMode = defaultCameraMode;
            this.droneConfig = droneConfig;

            ResetVariables();
        }
Exemple #11
0
        public DroneModule Load(DroneConfig config)
        {
            if (!File.Exists(config.AssemblyFilePath))
                throw DroneAssemblyNotFoundException.Get(config.AssemblyFilePath);

            var assembly = null as Assembly;

            this.log.Debug("attempting to load drone module assembly: '{0}'", Path.GetFileName(config.AssemblyFilePath));

            try
            {
                assembly = Assembly.LoadFrom(config.AssemblyFilePath);
                this.log.Debug("assembly loaded");
            }
            catch (Exception ex)
            {
                throw DroneAssemblyLoadException.Get(config.AssemblyFilePath, ex);
            }

            this.log.Debug("searching for main drone module...");

            var moduleTypes = (from type in assembly.GetTypes()
                               where typeof(DroneModule).IsAssignableFrom(type) &&
                                     type.Name.ToLower() == DroneModule.MainModuleName.ToLower()
                               select type).ToList();

            if (moduleTypes.Count > 0)
            {
                this.log.Debug("found {0} drone module{1}", moduleTypes.Count, moduleTypes.Count > 1 ? "s" : string.Empty);

                if(moduleTypes.Count > 1)
                    throw DroneTooManyMainModulesFoundException.Get(moduleTypes);

                var moduleType = moduleTypes[0];

                this.log.Debug("creating drone module instance from type: '{0}'", moduleType.FullName);

                try
                {
                    var module = Activator.CreateInstance(moduleType) as DroneModule;
                    this.log.Debug("drone module created");
                    return module;
                }
                catch(Exception ex)
                {
                    throw DroneCreateMainModuleFailedException.Get(ex, moduleType);
                }
            }
            else
            {
                this.log.Debug("no drone modules found");

                throw DroneMainModuleNotFoundException.Get();
            }
        }
Exemple #12
0
        private void InitializeDroneControl()
        {
            DroneConfig droneConfig = new DroneConfig();

            droneConfig.FirmwareVersion   = SupportedFirmwareVersion.Firmware_164_Or_Above;
            droneConfig.DefaultCameraMode = DroneCameraMode.BottomCamera;

            droneControl        = new DroneControl(droneConfig);
            droneControl.Error += droneControl_Error_Async;
            droneControl.ConnectionStateChanged += droneControl_ConnectionStateChanged_Async;
        }
        private void InitializeDroneControl()
        {
            DroneConfig droneConfig = new DroneConfig();

            droneConfig.DefaultCameraMode = DroneCameraMode.BottomCamera;

            droneControl = new DroneControl();
            droneControl.Init(droneConfig);
            droneControl.Error += droneControl_Error_Async;
            droneControl.ConnectionStateChanged += droneControl_ConnectionStateChanged_Async;
        }
Exemple #14
0
        public bool IsRecompileNeeded(DroneConfig config)
        {
            this.EnsureBuildDirExits(config);

            if(!File.Exists(config.AssemblyFilePath))
                return true;

            if(!File.Exists(this.GetCacheFileName(config)))
                return true;

            var cache = this.store.Load<FileMetadataCache>(this.GetCacheFileName(config));
            return cache.HasChanges();
        }
        private void TakeOverDroneConfigSettings(DroneConfig droneConfig)
        {
            DroneNetworkSSID = droneConfig.DroneNetworkIdentifierStart;

            DroneIpAddress = droneConfig.DroneIpAddress;
            OwnIpAddress   = droneConfig.StandardOwnIpAddress;

            VideoPortText      = droneConfig.VideoPort.ToString();
            CommandPortText    = droneConfig.CommandPort.ToString();
            NavigationPortText = droneConfig.NavigationPort.ToString();
            ControlPortText    = droneConfig.ControlInfoPort.ToString();

            firmwareVersion = droneConfig.FirmwareVersion;
        }
        private void TakeOverDroneConfigSettings(DroneConfig droneConfig)
        {
            DroneNetworkSSID = droneConfig.DroneNetworkIdentifierStart;

            DroneIpAddress = droneConfig.DroneIpAddress;
            OwnIpAddress   = droneConfig.StandardOwnIpAddress;

            VideoPortText      = droneConfig.VideoPort.ToString();
            CommandPortText    = droneConfig.CommandPort.ToString();
            NavigationPortText = droneConfig.NavigationPort.ToString();
            ControlPortText    = droneConfig.ControlInfoPort.ToString();

            firmwareVersion = droneConfig.FirmwareVersion;

            UseP264 = droneConfig.InitialSettings.Any(x => x.Key == videoCodec && x.Value == VideoCodecs.P264);
        }
        public DroneConfig GetResultingDroneConfig()
        {
            DroneConfig droneConfig = new DroneConfig();

            droneConfig.DroneNetworkIdentifierStart = droneNetworkSSID;
            droneConfig.DroneIpAddress       = droneIpAddress;
            droneConfig.StandardOwnIpAddress = ownIpAddress;

            droneConfig.CommandPort     = Int32.Parse(commandPortText);
            droneConfig.NavigationPort  = Int32.Parse(navigationPortText);
            droneConfig.VideoPort       = Int32.Parse(videoPortText);
            droneConfig.ControlInfoPort = Int32.Parse(controlPortText);

            droneConfig.FirmwareVersion = firmwareVersion;

            return(droneConfig);
        }
        public DroneConfig GetResultingDroneConfig()
        {
            DroneConfig droneConfig = new DroneConfig();

            droneConfig.DroneNetworkIdentifierStart = droneNetworkSSID;
            droneConfig.DroneIpAddress       = droneIpAddress;
            droneConfig.StandardOwnIpAddress = ownIpAddress;

            droneConfig.CommandPort     = Int32.Parse(commandPortText);
            droneConfig.NavigationPort  = Int32.Parse(navigationPortText);
            droneConfig.VideoPort       = Int32.Parse(videoPortText);
            droneConfig.ControlInfoPort = Int32.Parse(controlPortText);

            droneConfig.FirmwareVersion = firmwareVersion;

            droneConfig.InitialSettings.RemoveAll(x => x.Key == videoCodec);
            droneConfig.InitialSettings.Add(new DroneSetting(videoCodec, UseP264 ? VideoCodecs.P264 : VideoCodecs.VLIB));

            return(droneConfig);
        }
Exemple #19
0
 private void InitializeDroneControl(DroneConfig droneConfig)
 {
     droneControl = new DroneControl(droneConfig);
 }
Exemple #20
0
        public void RemoveFiles(DroneConfig config, IList<string> sourceFiles, IList<string> referenceFiles)
        {
            if(config == null)
                throw new ArgumentNullException("config");

            if(sourceFiles == null)
                throw new ArgumentNullException("sourceFiles");

            if(referenceFiles == null)
                throw new ArgumentNullException("referenceFiles");

            var sourcesRemoved = sourceFiles
                .Where(x => config.SourceFiles.Remove(x))
                .ToList();

            var referencesRemoved = referenceFiles
                .Where(x => config.ReferenceFiles.Remove(x))
                .ToList();

            if (sourcesRemoved.Count == 0 && referencesRemoved.Count == 0)
            {
                this.log.Warn("nothing to remove. files do not exist in config");
                return;
            }

            foreach (var file in sourcesRemoved.Concat(referencesRemoved))
                this.log.Info("removed '{0}'", file);
        }
Exemple #21
0
        public void SaveConfig(DroneConfig config)
        {
            if(config == null)
                throw new ArgumentNullException("config");

            this.store.Save(config.FilePath, config);
        }
        public override String CreateCommand(SupportedFirmwareVersion firmwareVersion, DroneConfig droneConfig, Func <uint> additionalSequenceNumber)
        {
            CheckSequenceNumber();
            if (!multiConfig)
            {
                return(String.Format("AT*CONFIG={0},\"{1}\",\"{2}\"\r", sequenceNumber, configurationKey, configurationValue));
            }

            string cmd = String.Format("AT*CONFIG_IDS={0},\"{1}\",\"{2}\",\"{3}\"\r", sequenceNumber, GetCrc32(droneConfig.SessionId), GetCrc32(droneConfig.UserId), GetCrc32(droneConfig.ApplicationId));

            if (configurationKey == null)
            {
                return(cmd);
            }

            return(string.Format("{0}AT*CONFIG={1},\"{2}\",\"{3}\"\r", cmd, additionalSequenceNumber(), configurationKey, configurationValue));
        }
Exemple #23
0
        public void InitDroneDir(DroneConfig config)
        {
            if(config == null)
                throw new ArgumentNullException("config");

            if(Directory.Exists(config.DroneDirPath))
                return;

            Directory.CreateDirectory(config.DroneDirPath);

            if(!Directory.Exists(config.DroneSourceDirPath))
                Directory.CreateDirectory(config.DroneSourceDirPath);

            if(!Directory.Exists(config.DroneReferencesDirPath))
                Directory.CreateDirectory(config.DroneReferencesDirPath);

            var referenceFiles = this.compiler.GetBaseReferenceFiles(this.GetAppPathBaseDir());

            foreach(var referenceFile in referenceFiles)
            {
                var destFile = Path.Combine(config.DroneReferencesDirPath, Path.GetFileName(referenceFile));
                File.Copy(referenceFile, destFile);
            }
        }
Exemple #24
0
 public DroneController(IOptions <DroneConfig> config, ILoggerFactory loggerFactory, IHttpClientService httpClientService)
 {
     _httpClientService = httpClientService;
     _config            = config.Value;
     _logger            = loggerFactory.CreateLogger <DroneController>();
 }
Exemple #25
0
        private void CreateCache(DroneConfig config)
        {
            var cache = new FileMetadataCache();

            cache.Add(new FileInfo(config.FilePath));

            foreach(var source in this.ResolveSourceFiles(config.SourceFiles, config.DirPath))
                cache.Add(new FileInfo(source));

            foreach(var reference in this.ResolveReferenceFiles(config.ReferenceFiles, config.DirPath))
                cache.Add(new FileInfo(reference));

            this.store.Save(this.GetCacheFileName(config), cache);
        }
Exemple #26
0
 private void CreateNewDroneConfig()
 {
     droneConfig = configSettings.GetResultingDroneConfig();
 }
Exemple #27
0
        private void EnsureBuildDirExits(DroneConfig config)
        {
            if(config == null)
                throw new ArgumentNullException("config");

            if(!Directory.Exists(config.BuildDirPath))
                Directory.CreateDirectory(config.BuildDirPath);
        }
Exemple #28
0
 private string GetCacheFileName(DroneConfig config)
 {
     return Path.Combine(config.BuildDirPath, CacheFileName);
 }
Exemple #29
0
 public MvcConfig()
 {
     Debug = new DebugConfig();
     Drone = new DroneConfig();
     Site  = new SiteConfig();
 }
 public virtual string CreateCommand(SupportedFirmwareVersion firmwareVersion, DroneConfig config, Func<uint> additionalSequenceNumber)
 {
     return CreateCommand(firmwareVersion);
 }
Exemple #31
0
 public MvcConfig()
 {
     Debug = new DebugConfig();
     Drone = new DroneConfig();
     Site = new SiteConfig();
 }
Exemple #32
0
 public virtual string CreateCommand(SupportedFirmwareVersion firmwareVersion, DroneConfig config, Func <uint> additionalSequenceNumber)
 {
     return(CreateCommand(firmwareVersion));
 }