public override void Action(IotAction action) { // cap the queue to prevent flooding attack if (actionQueue.Count > 50) { return; } actionQueue.Enqueue((object)action); }
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; } }
public static string[] Action(IotAction action) { if (action.cmd == "hello") { return GetAllItemName(); } if (action.cmd == null || action.item == null) { return null; } ActionByName(action); return null; }
private void DoAction(IotAction a) { switch (a.cmd) { case "start": if (a.parameters == "xbox") { XboxLightItUp(); } break; } }
public override void Action(IotAction action) { switch (action.cmd) { case "on": TurnOn(); break; case "off": TurnOff(); break; } }
public override void Action(IotAction action) { // if (action.identified) { return; } switch (action.cmd) { case "halt": Shutdown(); break; case "reboot": Restart(); break; } }
public static string[] Action(IotAction action) { if (action.cmd == "hello") { return(GetAllItemName()); } if (action.cmd == null || action.item == null) { return(null); } ActionByName(action); return(null); }
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; } }
/// <summary> /// Play a command /// </summary> /// <param name="action"> /// Action object format. /// Action.cmd: beepok, beepalert, beepstartup, or play /// If cmd = play, Action.parameters required. String format: BeatsPerMiniute, note definition, note definition, note definition... eg 60, 3qc#,31c /// BeatsPerMiniute: Numeric. /// Note Definition format: octave, length, note. /// Octave: Between 0 and 8 inclusive, Middle C Octave is 4. /// Length: Beats per note. Beats: 0 to 9, t=thirty secondth, s=sixteenth, e=eighth, q=quarter beat, h=half beats. /// Note: C, D, E, F, G, A, B. Suffix: #=sharp, b=flat. eg c#. /// </param> 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; } }
static void ActionByName(IotAction action) { for (int i = 0; i < maxIoT; i++) { if (IotItems[i] == null || IotItems[i].Name.Length == 0) { continue; } if (IotItems[i].Name == action.item) { try { TotalActions++; IotItems[i].IncrementActionCount(); IotItems[i].Action(action); } catch { _actionErrors++; } break; } } }
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; }
/// <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; } }
public override void Action(IotAction action) { // no actions implemented }
protected abstract void DoAction(IotAction action);
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; } }
protected override void DoAction(IotAction action) { switch (action.cmd) { case "text": ScrollStringInFromRight(action.parameters, 100); break; } }
public abstract override void Action(IotAction action);
public virtual 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; } }