public TieState GetTieState(TiePreset tiePreset = TiePreset.CurrentConfiguration) { if (!_rs232Device.Enabled) { return(null); } //0 0 0 0 Vid 0 0 0 0 Aud string pattern = @"^([0-4]) ([0-4]) ([0-4]) ([0-4]) Vid ([0-4]) ([0-4]) ([0-4]) ([0-4]) Aud $"; var result = _rs232Device.WriteWithResponse($"{_cmdEsc}{(int)tiePreset:D2}VC{_cmdCr}", pattern); if (result == null) { return(null); } var tieState = new TieState(); var match = Regex.Match(result, pattern); if (!match.Success) { return(null); } tieState.Video.Add(OutputPort.Port1, (InputPort)int.Parse(match.Groups[1].Value)); tieState.Video.Add(OutputPort.Port2, (InputPort)int.Parse(match.Groups[2].Value)); tieState.Video.Add(OutputPort.Port3, (InputPort)int.Parse(match.Groups[3].Value)); tieState.Video.Add(OutputPort.Port4, (InputPort)int.Parse(match.Groups[4].Value)); tieState.Audio.Add(OutputPort.Port1, (InputPort)int.Parse(match.Groups[5].Value)); tieState.Audio.Add(OutputPort.Port2, (InputPort)int.Parse(match.Groups[6].Value)); tieState.Audio.Add(OutputPort.Port3, (InputPort)int.Parse(match.Groups[7].Value)); tieState.Audio.Add(OutputPort.Port4, (InputPort)int.Parse(match.Groups[8].Value)); return(tieState); }
public static bool Valid(this TiePreset tiePreset) { return(Enum.IsDefined(typeof(TiePreset), tiePreset)); }