private List <InternalDroneConfigurationState> GetInternalDroneConfigStates(String configMessage) { String[] configEntries = configMessage.Split('\n'); List <InternalDroneConfigurationState> configStates = new List <InternalDroneConfigurationState>(); foreach (String configEntry in configEntries) { char[] separators = new char[] { ':', '=' }; String[] configEntryValues = configEntry.Split(separators, 3); if (configEntryValues.Length != 3) { //Console.WriteLine ("Invalid config entry: " + configEntry); continue; } InternalDroneConfigurationState configState = new InternalDroneConfigurationState(); configState.MainSection = configEntryValues[0].ToLower().Trim(); configState.Key = configEntryValues[1].ToLower().Trim(); configState.Value = configEntryValues[2].Trim(); configStates.Add(configState); } return(configStates); }
private void DetermineNetworkConfiguration(InternalDroneConfigurationState configState) { switch (configState.Key) { case "ssid_single_player": networkConfiguration.SsidInt = configState.Value; break; case "passkey": networkConfiguration.NetworkPasswordInt = configState.Value; break; case "infrastructure": networkConfiguration.InfrastructureInt = Boolean.Parse(configState.Value); break; case "navdata_port": networkConfiguration.NavigationDataPortInt = Int32.Parse(configState.Value); break; case "video_port": networkConfiguration.VideoDataPortInt = Int32.Parse(configState.Value); break; case "at_port": networkConfiguration.CommandDataPortInt = Int32.Parse(configState.Value); break; } }
private List<InternalDroneConfigurationState> GetInternalDroneConfigStates(String configMessage) { String[] configEntries = configMessage.Split('\n'); List<InternalDroneConfigurationState> configStates = new List<InternalDroneConfigurationState>(); foreach (String configEntry in configEntries) { char[] separators = new char[] { ':', '=' }; String[] configEntryValues = configEntry.Split(separators, 3); if (configEntryValues.Length != 3) { //Console.WriteLine ("Invalid config entry: " + configEntry); continue; } InternalDroneConfigurationState configState = new InternalDroneConfigurationState(); configState.MainSection = configEntryValues[0].ToLower().Trim(); configState.SubSection = configEntryValues[1].ToLower().Trim(); configState.Value = configEntryValues[2].Trim(); configStates.Add(configState); } return configStates; }
private void DetermineOtherConfiguration(InternalDroneConfigurationState configState) { switch (configState.Key) { case "ultrasound_freq": otherConfiguration.UltraSoundFrequencyInt = Int32.Parse(configState.Value); break; } }
private void DetermineControlConfiguration(InternalDroneConfigurationState configState) { switch (configState.Key) { case "altitude_max": controlConfiguration.MaxAltitudeInt = Int32.Parse(configState.Value); break; case "altitude_min": controlConfiguration.MinAltitudeInt = Int32.Parse(configState.Value); break; } }
private void DetermineGeneralConfiguration(InternalDroneConfigurationState configState) { switch (configState.Key) { case "num_version_mb": generalConfiguration.MainboardVersionInt = configState.Value; break; case "num_version_soft": generalConfiguration.SoftwareVersionInt = configState.Value; break; case "soft_build_date": generalConfiguration.SoftwareCompilationDateInt = DateTime.ParseExact(configState.Value, "yyyy-MM-dd HH:mm", null); break; // Assuming motor values come in in the ordered correctly case "motor1_soft": case "motor2_soft": case "motor3_soft": case "motor4_soft": generalConfiguration.MotorSoftwareVersionsInt.Add(configState.Value); break; case "motor1_hard": case "motor2_hard": case "motor3_hard": case "motor4_hard": generalConfiguration.MotorHardwareVersionsInt.Add(configState.Value); break; case "motor1_supplier": case "motor2_supplier": case "motor3_supplier": case "motor4_supplier": generalConfiguration.MotorSuppliersInt.Add(configState.Value); break; case "ardrone_name": generalConfiguration.DroneNameInt = configState.Value; break; case "flying_time": generalConfiguration.FlightTimeInt = new TimeSpan(0, 0, Int32.Parse(configState.Value)); break; } }
private InternalDroneConfigurationState GetEntryOption(String entry) { Regex optionRegex = new Regex(@"^(?<key>[a-zA-Z0-9_]+)\s*\=\s*(?<value>.*)$", RegexOptions.Compiled); // Matches abc_9 = [ bla ] MatchCollection optionRegexMatches = optionRegex.Matches(entry); if (optionRegexMatches.Count == 1) { String key = optionRegexMatches[0].Groups["key"].Value; String value = optionRegexMatches[0].Groups["value"].Value; InternalDroneConfigurationState configState = new InternalDroneConfigurationState(); configState.MainSection = currentSectionName; configState.Key = key; configState.Value = value; return configState; } return null; }