public override void Action(IotAction action)
        {
            double sampleRate;

            if (action.cmd == null)
            {
                return;
            }
            switch (action.cmd)
            {
            case "measure":
                DoMeasure();
                break;

            case "start":
                Action(Actions.Start);
                break;

            case "stop":
                Action(Actions.Stop);
                break;

            case "rate":
                //test for numeric sensor sample rate
                if (action.parameters == null)
                {
                    return;
                }
                if (double.TryParse(action.parameters, out sampleRate))
                {
                    Action((int)sampleRate);
                }
                break;
            }
        }
Exemplo n.º 2
0
        private IotAction ActionParts(string[] topicParts, int startPos, string message)
        {
            IotAction action = new IotAction();

            action.parameters = message;

            for (int i = startPos, p = 0; i < topicParts.Length; i++, p++)
            {
                string part = topicParts[i].Length == 0 ? null : topicParts[i];
                if (part == null)
                {
                    continue;
                }
                switch (p)
                {
                case 0:
                    action.cmd = part;
                    break;

                case 1:
                    action.item = part;
                    break;

                case 2:
                    action.subItem = part;
                    break;

                default:
                    break;
                }
            }
            return(action);
        }
Exemplo n.º 3
0
 public override void Action(IotAction action)
 {
     // cap the queue to prevent flooding attack
     if (actionQueue.Count > 100)
     {
         return;
     }
     actionQueue.Enqueue((object)action);
 }
Exemplo n.º 4
0
 protected override void DoAction(IotAction action)
 {
     switch (action.cmd)
     {
     case "text":
         ScrollStringInFromRight(action.parameters, 100);
         break;
     }
 }
Exemplo n.º 5
0
 private void DoAction(IotAction a)
 {
     switch (a.cmd)
     {
     case "start":
         if (a.parameters == "xbox")
         {
             XboxLightItUp();
         }
         break;
     }
 }
Exemplo n.º 6
0
        public override void Action(IotAction action)
        {
            switch (action.cmd)
            {
            case "on":
                TurnOn();
                break;

            case "off":
                TurnOff();
                break;
            }
        }
Exemplo n.º 7
0
        public override void Action(IotAction action)
        {
            //        if (action.identified) { return; }
            switch (action.cmd)
            {
            case "halt":
                Shutdown();
                break;

            case "reboot":
                Restart();
                break;
            }
        }
Exemplo n.º 8
0
        public override void Action(IotAction action)
        {
            switch (action.cmd.ToLower())
            {
            case "forward":
                Step(this.StepsPerRevolution, MotorDirection.Forward);
                break;

            case "reverse":
                Step(this.StepsPerRevolution, MotorDirection.Reverse);
                break;

            case "release":
                Step(this.StepsPerRevolution, MotorDirection.Release);
                break;
            }
        }
Exemplo n.º 9
0
        public override void Action(IotAction action)
        {
            if (action.subItem == string.Empty)
            {
                return;
            }
            uint   colourIndex = 0;
            string colourName  = action.subItem;

            string[] colours = new string[] { "red", "green", "blue" };
            for (colourIndex = 0; colourIndex < colours.Length; colourIndex++)
            {
                if (colourName == colours[colourIndex])
                {
                    break;
                }
            }
            if (colourIndex > 2)
            {
                return;
            }
            switch (action.cmd)
            {
            case "on":
                //check params to get colour?
                On((Led)colourIndex);
                break;

            case "blink":
                // get rate and duration from action.params
                break;

            case "fade":
                //get params
                break;

            case "colour":
                //get colour from params
                break;

            default:
                base.Action(action);
                break;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Set Servo position, min, max, by points between min and max or by degrees
        /// </summary>
        /// <param name="action"></param>
        public override void Action(IotAction action)
        {
            switch (action.cmd)
            {
            case "min":
                Action(Actions.Min);
                break;

            case "max":
                Action(Actions.Max);
                break;

            case "position":
                ActionSetPosition(action.parameters);
                break;

            case "degrees":
                ActionSetDegrees(action.parameters);
                break;
            }
        }
Exemplo n.º 11
0
        public override void Action(IotAction action)
        {
            switch (action.cmd)
            {
            case "beepok":
                Action(Actions.BeepOk);
                break;

            case "beepalert":
                Action(Actions.BeepAlert);
                break;

            case "beepstartup":
                Action(Actions.BeepStartup);
                break;

            case "play":
                DecodePlayAction(action.parameters);
                break;
            }
        }
Exemplo n.º 12
0
        private void DoAction(IotAction a)
        {
            switch (a.cmd)
            {
            case "play":
                Command command = CommandHelpers.CommandFromJson(HttpUtility.HtmlDecode(a.parameters));
                if (command != null)
                {
                    RunCommand(command);
                }
                break;

            case "start":
                for (int i = 0; i < cycles.Length; i++)
                {
                    if (a.parameters == CycleNames[i].ToLower())
                    {
                        cycles[i]();
                        break;
                    }
                }
                break;
            }
        }
Exemplo n.º 13
0
 protected abstract void DoAction(IotAction action);
Exemplo n.º 14
0
 public virtual void Action(IotAction action)
 {
 }
 public override void Action(IotAction action)
 {
     // no actions implemented
 }
Exemplo n.º 16
0
 public abstract override void Action(IotAction action);
 private void DoAction(IotAction a)
 {
     switch (a.cmd) {
         case "play":
             Command command = CommandHelpers.CommandFromJson(HttpUtility.HtmlDecode(a.parameters));
             if (command != null) { RunCommand(command); }
             break;
         case "start":
             for (int i = 0; i < cycles.Length; i++) {
                 if (a.parameters == CycleNames[i].ToLower()) {
                     cycles[i]();
                     break;
                 }
             }
             break;
     }
 }