Exemple #1
0
        public void parse()
        {
            this.currentCommandDefinition = new CommandDefinition();

            foreach (string arg in this.args)
            {
                if (this.parseCommand(arg))     { continue; }
                if (this.parseTarget(arg))      { continue; }
                if (this.parseWaveType(arg))    { continue; }
                if (this.parseColor(arg))       { continue; }
                if (this.parsePatternType(arg)) { continue; }
                if (this.parseSpeed(arg))       { continue; }
                if (this.parseRepetitions(arg)) { continue; }
            }

            if (this.isCurrentCommandSet)
            {
                this.appendCurrentCommandDefinition();
            }
        }
Exemple #2
0
        public async Task<bool> run(CommandDefinition command)
        {
            switch (command.command)
            {
                case CommandType.Color:
                    return await device.SetColor(getDeviceTarget(command.target), command.color, command.speed);
                    break;

                case CommandType.Blink:
                    return await device.Blink(getDeviceTarget(command.target), command.color, command.speed, command.repeat);
                    break;

                case CommandType.Wave:
                    return await device.Wave(command.waveType, command.color, command.speed, command.repeat);
                    break;

                case CommandType.Pattern:
                    return await device.CarryOutPattern(command.patternType, command.repeat);
                    break;
            }

            return false;
        }
Exemple #3
0
        private void appendCurrentCommandDefinition()
        {
            this.checkCurrentDefinition();

            // add current CommandDefinition to the list
            this.commands.Add(this.currentCommandDefinition);

            // reset current CommandDefinition
            this.currentCommandDefinition = new CommandDefinition();

            // reset flags
            this.isCurrentCommandSet = false;
            this.isCurrentTargetSet = false;
            this.isCurrentColorSet = false;
            this.isCurrentWaveTypeSet = false;
            this.isCurrentPatternTypeSet = false;
            this.isCurrentSpeedSet = false;
            this.isCurrentRepeatSet = false;
        }