internal ISUConfiguration( string name, bool echoEnabled, QuietModes quietMode, VerbosityModes verbosityMode, bool dtrOption, FlowControls flowControl, List <SRegister> registers) { Name = name; EchoEnabled = echoEnabled; QuietMode = quietMode; VerbosityMode = verbosityMode; DTROption = dtrOption; FlowControl = flowControl; Registers = registers; }
public List <ISUConfiguration> GetConfigurations() { IssueCommand(new BasicATCommand(BasicATCommand.Commands.ViewConfigs, 0)); WaitForCommandResponse(); return(ParseResponse(PopOldestLines(), (lines, OK) => { List <string> ConfigLines = new List <string>(); string CurrentLine = ""; foreach (string line in lines) { string tLine = line.Trim(); if (tLine.EndsWith(":") && !string.IsNullOrWhiteSpace(CurrentLine)) { ConfigLines.Add(CurrentLine); CurrentLine = ""; } CurrentLine += line; } if (!string.IsNullOrWhiteSpace(CurrentLine)) { ConfigLines.Add(CurrentLine); } List <ISUConfiguration> configs = new List <ISUConfiguration>(); foreach (string confLine in ConfigLines) { string[] colonSplitFirst = confLine.Split(":".ToCharArray()); string name = colonSplitFirst[0]; string[] parts = string.Join(":", colonSplitFirst, 1, colonSplitFirst.Length - 1).Split(" ".ToCharArray()); bool echoEnabled = false; QuietModes quietMode = QuietModes.Unset; VerbosityModes verbosityMode = VerbosityModes.Unset; bool dtrOption = false; FlowControls flowControl = FlowControls.Disable; List <SRegister> registers = new List <SRegister>(); foreach (string part in parts) { if (string.IsNullOrWhiteSpace(part)) { continue; } if (part[0] == 'E') { echoEnabled = part[1] == '1'; } else if (part[0] == 'Q') { quietMode = (QuietModes)(part[1] - '0'); } else if (part[0] == 'V') { verbosityMode = (VerbosityModes)(part[1] - '0'); } else if (part.StartsWith("&D")) { dtrOption = part[2] != '0'; } else if (part.StartsWith("&K")) { flowControl = (FlowControls)(part[2] - '0'); } else if (part[0] == 'S') { string[] regParts = part.Split(":".ToCharArray()); string regIdxStr = regParts[0].Substring(1); string regValStr = regParts[1]; registers.Add(new SRegister(int.Parse(regIdxStr), int.Parse(regValStr))); } } configs.Add(new ISUConfiguration(name, echoEnabled, quietMode, verbosityMode, dtrOption, flowControl, registers)); } return configs; }).Data); }