Exemplo n.º 1
0
        public RunCncCommand(Dictionary <int, int> speeds, uint sensor, uint value, ValueEdge edge) : base()
        {
            steppers = speeds;

            this.sensor = sensor;
            this.value  = value;
            valueEdge   = edge;
        }
Exemplo n.º 2
0
        private static string ParseRunCommand(IList <ICommand> commands, Match matchedString)
        {
            string    parsedCommand;
            ValueEdge edgeType = ValueEdge.RisingEdge;
            int       sensor   = -1;
            int       value    = -1;

            Dictionary <int, int> arguments = new Dictionary <int, int>();

            parsedCommand  = "Run {";
            parsedCommand += ParseSpeedArguments(matchedString, parsedCommand, arguments);

            Match arg = ParserRegexes.SensorArgumentPattern.Match(matchedString.Value);

            if (arg.Success)
            {
                edgeType = arg.Groups["edgeType"].Value == "r" ? ValueEdge.RisingEdge : ValueEdge.FallingEdge;
                sensor   = int.Parse(arg.Groups["sensor"].Value);
                value    = int.Parse(arg.Groups["value"].Value);

                if (sensor < 0)
                {
                    Logger.Debug("[Command parser] - Номер датчика не может быть меньше 0.");
                }

                if (value < 0)
                {
                    Logger.Debug("[Command parser] - Значение датчика не может быть меньше 0.");
                }

                parsedCommand += $" | sensor = {sensor}, value = {value}, edge = {edgeType}";
            }

            commands.Add(new RunCncCommand(arguments, (uint)sensor, (uint)value, edgeType));
            return(parsedCommand);
        }