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; }
static void ActionByName(IotAction action) { foreach (var actuator in actuators) { if (actuator.Name == action.item) { try { TotalActions++; actuator.Action(action); } catch { _actionErrors++; } break; } } }
public void Action(IotAction action) { }
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; }