private void UpdateVersion(ulong new_version) { if (this._version == new_version) { return; } this._version = new_version; this._versionStr = "v" + FlexVersion.ToString(this._version); base.RaisePropertyChanged("Version"); base.RaisePropertyChanged("VersionStr"); }
public static void Main(string[] args) { SetupLogging(); ParseOptions(args, out var configurationFile, out var repoPath, out var variables, out var diagnostic); try { Logger.Trace("Starting to run FlexVersion analysis..."); var flexVersion = new FlexVersion(configurationFile, repoPath, variables.ToArray()); var result = flexVersion.Analyze(); Logger.Trace("Done analysing."); System.Console.WriteLine(diagnostic ? JsonConvert.SerializeObject(result, Formatting.Indented) : JsonConvert.SerializeObject(result.Output, Formatting.Indented)); } catch (Exception ex) { Logger.Fatal(diagnostic ? ex.ToString() : ex.Message); Environment.Exit(-1); } }
private static void Discovery_RadioDiscovered(Radio discovered_radio) { //Log("1 API::Discovery_RadioDiscovered("+discovered_radio.ToString()+")"); if (filter_serial.Count > 0) { bool found = false; foreach (string s in filter_serial) { if (discovered_radio.Serial.Contains(s)) { found = true; //Debug.WriteLine("Found radio that matches filter: " + radio.Serial); break; } } if (!found) { return; } } // keep the radio alive in the list if it exists if (_radio_list_timed.ContainsKey(discovered_radio.Serial)) { _cleanupTimer.Stop(); _radio_list_timed[discovered_radio.Serial] = _cleanupTimer.Duration; } Radio r = null; lock (radio_list) { if (_radioDictionaryByIP.ContainsKey(discovered_radio.IP)) { r = _radioDictionaryByIP[discovered_radio.IP]; } if (r != null) { if (r.Model == discovered_radio.Model && r.Serial == discovered_radio.Serial) { LogDiscovery("2 API::Discovery_RadioDiscovered(" + discovered_radio.ToString() + ") - IP/Model/Serial match found in list"); ulong ver_1_0 = FlexVersion.Parse("1.0.0.0"); if (r.DiscoveryProtocolVersion <= ver_1_0 && discovered_radio.DiscoveryProtocolVersion > ver_1_0) { LogDiscovery("3 API::Discovery_RadioDiscovered(" + discovered_radio.ToString() + ") - newer protocol, updating radio info"); r.DiscoveryProtocolVersion = discovered_radio.DiscoveryProtocolVersion; r.Callsign = discovered_radio.Callsign; r.Nickname = discovered_radio.Nickname; r.Serial = discovered_radio.Serial; } if (discovered_radio.Version != r.Version) { LogDiscovery("4 API::Discovery_RadioDiscovered(" + discovered_radio.ToString() + ") - updating radio version"); Debug.WriteLine("Version Updated-" + r.ToString()); r.Version = discovered_radio.Version; r.Updating = false; } // update the status if this is a newer discovery version if (discovered_radio.DiscoveryProtocolVersion > ver_1_0) { if (r.Status != discovered_radio.Status) { LogDiscovery("5 API::Discovery_RadioDiscovered(" + discovered_radio.ToString() + ") - update radio status - " + discovered_radio.Status); r.Status = discovered_radio.Status; } if (r.InUseIP != discovered_radio.InUseIP) { r.InUseIP = discovered_radio.InUseIP; } if (r.InUseHost != discovered_radio.InUseHost) { r.InUseHost = discovered_radio.InUseHost; } } //Debug.WriteLine("Skipping Radio -- already in list: "+radio.ToString()); return; } } Debug.WriteLine("Discovered " + discovered_radio.ToString()); LogDiscovery("6 API::Discovery_RadioDiscovered(" + discovered_radio.ToString() + ") - Add radio to list"); radio_list.Add(discovered_radio); bool b = _radioDictionaryByIP.TryAdd(discovered_radio.IP, discovered_radio); } if (!_radio_list_timed.ContainsKey(discovered_radio.Serial)) { _cleanupTimer.Stop(); bool b = _radio_list_timed.TryAdd(discovered_radio.Serial, _cleanupTimer.Duration); } OnRadioAddedEventHandler(discovered_radio); //Debug.WriteLine("Adding Radio: " + radio.ToString()); }
private static void ProcessVitaDiscoveryDataPacket(VitaDiscoveryPacket packet) { Radio radio = new Radio(); string[] words = packet.payload.Trim().Split(' '); foreach (string kv in words) { string[] tokens = kv.Split('='); if (tokens.Length != 2) { Debug.WriteLine("FlexLib::Discovery::ProcessVitaDiscoveryDataPacket: Invalid key/value pair (" + kv + ")"); continue; } string key = tokens[0].Trim(); string value = tokens[1].Trim(); value = value.Replace("\0", ""); switch (key.ToLower()) { case "callsign": radio.Callsign = value; break; case "discovery_protocol_version": { ulong temp; bool b = FlexVersion.TryParse(value, out temp); if (!b) { Debug.WriteLine("FlexLib::Discovery::ProcessVitaDiscoveryDataPacket: Error converting version string (" + value + ")"); continue; } radio.DiscoveryProtocolVersion = temp; } break; case "inuse_host": radio.InUseHost = value; break; case "inuse_ip": radio.InUseIP = value; break; case "ip": { IPAddress temp; bool b = IPAddress.TryParse(value, out temp); if (!b) { Debug.WriteLine("FlexLib::Discovery::ProcessVitaDiscoveryDataPacket: Invalid key/value pair (" + kv + ")"); continue; } radio.IP = temp; } break; case "model": radio.Model = value; break; case "nickname": radio.Nickname = value; break; case "port": { ushort temp; bool b = ushort.TryParse(value, out temp); if (!b) { Debug.WriteLine("FlexLib::Discovery::ProcessVitaDiscoveryDataPacket: Invalid key/value pair (" + kv + ")"); continue; } radio.CommandPort = temp; } break; case "serial": radio.Serial = StringHelper.Sanitize(value); break; case "status": radio.Status = value; break; case "version": { ulong temp; bool b = FlexVersion.TryParse(value, out temp); if (!b) { Debug.WriteLine("FlexLib::Discovery::ProcessVitaDiscoveryDataPacket: Error converting version string (" + value + ")"); continue; } radio.Version = temp; } break; } } OnRadioDiscoveredEventHandler(radio); }