private void ParseCommandLine() { if (_UpdateInProgress > 0) { return; } _UpdateInProgress++; try { var cmdLine = new RedLinkServerCommandLine(CommandLine); //Update devices var devices = _Database.AllDevices.Select(d => new KnownDeviceEntry(d)).ToList(); string mcuVendor = _Host.MCU.ExpandedMCU.AdditionalSystemVars?.FirstOrDefault(v => v.Key == "REDLINK:VENDOR_ID")?.Value; string mcuDev = _Host.MCU.ExpandedMCU.AdditionalSystemVars?.FirstOrDefault(v => v.Key == "REDLINK:DEVICE_ID")?.Value; var resolvedDevice = devices.FirstOrDefault(d => d.Device.MatchesDefinition(mcuVendor, mcuDev))?.Device; devices.Insert(0, new KnownDeviceEntry(mcuDev, resolvedDevice)); string cmdlineVendor = cmdLine.Vendor ?? RedLinkServerCommandLine.DefaultVendor; string cmdlineDev = cmdLine.Device ?? RedLinkServerCommandLine.DefaultDevice; var selectedDevice = devices.FirstOrDefault(d => d.Device.MatchesDefinition(cmdlineVendor, cmdlineDev)); if (selectedDevice == null) { selectedDevice = new KnownDeviceEntry(new RedLinkDeviceDatabase.KnownDevice(new RedLinkDeviceDatabase.Key(cmdlineVendor, cmdlineDev), null, false)); devices.Add(selectedDevice); } Devices = devices.ToArray(); Device = selectedDevice; //Update cores ResetMode.Load(cmdLine); Interface.Load(cmdLine); Core.Load(cmdLine); } finally { _UpdateInProgress--; } }
void UpdateCommandLine(Action <RedLinkServerCommandLine> updateAction) { if (_UpdateInProgress > 0) { return; } _UpdateInProgress++; try { var cmdLine = new RedLinkServerCommandLine(CommandLine); updateAction(cmdLine); CommandLine = cmdLine.CommandLine; } finally { _UpdateInProgress--; } }
internal void Load(RedLinkServerCommandLine cmdLine) { List <LabelAndValue> choices = LoadChoices?.Invoke() ?? _Defaults.Select(MakeChoice).ToList(); var currentValue = cmdLine.GetOptionValue(_Mode, _Key); LabelAndValue selection = null; if (currentValue != null) { selection = choices.FirstOrDefault(c => c.Value == currentValue); if (selection == null) { selection = new LabelAndValue(currentValue == "" ? "Unspecified" : currentValue, currentValue); choices.Add(selection); } } Values = choices.ToArray(); Value = selection; }