Пример #1
0
        public InputPort?GetInputPortForOutputPort(OutputPort outputPort, TieType tieType)
        {
            if (!_rs232Device.Enabled)
            {
                return(null);
            }

            string result = null;

            if (tieType == TieType.AudioVideo)
            {
                throw new ArgumentException("Unable to get Audio and Video ties at the same time.");
            }

            switch (tieType)
            {
            case TieType.Video:
                result = _rs232Device.WriteWithResponse($"{(int)outputPort}&", @"^[0-9]+$");
                break;

            case TieType.Audio:
                result = _rs232Device.WriteWithResponse($"{(int)outputPort}$", @"^[0-9]+$");
                break;
            }

            if (result == null)
            {
                return(null);
            }

            InputPort tie = (InputPort)int.Parse(result);

            if (!tie.Valid())
            {
                return(null);
            }

            return(tie);
        }