public static void Run(device_type_command_que cmd) { using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString)) { db.device_type_command_que.AddObject(cmd); db.SaveChanges(); DeviceTypeCommandAddedToQue(cmd.id); } }
public override bool ProcessDeviceTypeCommand(device_type_command_que cmd) { return true; }
void device_type_command_que_DeviceTypeCommandRunCompleteEvent(device_type_command_que cmd, bool withErrors, string txtError) { if (withErrors) BroadcastMessage("ERR~" + txtError + Environment.NewLine); }
public override bool ProcessDeviceTypeCommand(device_type_command_que cmd) { if(cmd.device.device_types.name == "CONTROLLER") { switch (cmd.device_type_commands.name) { case "RESET": { m_manager.ResetController(m_homeId); return true; } case "ADDDEVICE": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.AddDevice, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "AddController": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.AddController, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "CreateNewPrimary": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.CreateNewPrimary, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "ReceiveConfiguration": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.ReceiveConfiguration, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "RemoveController": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.RemoveController, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "RemoveDevice": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.RemoveDevice, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "TransferPrimaryRole": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.TransferPrimaryRole, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "HasNodeFailed": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.HasNodeFailed, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "RemoveFailedNode": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.RemoveFailedNode, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } case "ReplaceFailedNode": { ControllerCommandDlg dlg = new ControllerCommandDlg(m_manager, m_homeId, ZWControllerCommand.ReplaceFailedNode, (byte)cmd.device.node_id); dlg.ShowDialog(); dlg.Dispose(); return true; } } } else if (cmd.device.device_types.name == "SWITCH") { switch (cmd.device_type_commands.name) { case "MOMENTARY": { int delay = 1000; int.TryParse(cmd.arg, out delay); m_manager.SetNodeOn(m_homeId, (byte)cmd.device.node_id); System.Timers.Timer t = new System.Timers.Timer(); t.Interval = delay; t.Elapsed += (sender, e) => { m_manager.SetNodeOff(m_homeId, (byte)cmd.device.node_id); t.Enabled = false; t.Dispose(); }; t.Enabled = true; return true; } case "TURNON": { m_manager.SetNodeOn(m_homeId, (byte)cmd.device.node_id); return true; } case "TURNOFF": { m_manager.SetNodeOff(m_homeId, (byte)cmd.device.node_id); break; } } } else if (cmd.device.device_types.name == "DIMMER") { switch (cmd.device_type_commands.name) { case "TURNON": { byte defaultonlevel = 99; byte.TryParse(device_property_values.GetDevicePropertyValue(cmd.device_id, "DEFAULONLEVEL"), out defaultonlevel); m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, defaultonlevel); return true; } case "TURNOFF": { m_manager.SetNodeOff(m_homeId, (byte)cmd.device.node_id); return true; } case "SETPRESETLEVEL": { switch (cmd.arg) { case "0%": m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, Convert.ToByte(0)); break; case "20%": m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, Convert.ToByte(20)); break; case "40%": m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, Convert.ToByte(40)); break; case "60%": m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, Convert.ToByte(60)); break; case "80%": m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, Convert.ToByte(80)); break; case "100%": m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, Convert.ToByte(100)); break; case "255": m_manager.SetNodeLevel(m_homeId, (byte)cmd.device.node_id, Convert.ToByte(255)); break; } return true; } } } else if (cmd.device.device_types.name == "THERMOSTAT") { switch (cmd.device_type_commands.name) { case "SETENERGYMODE": { m_manager.SetNodeOff(m_homeId, (byte)cmd.device.node_id); return true; } case "SETCONFORTMODE": { m_manager.SetNodeOn(m_homeId, (byte)cmd.device.node_id); return true; } } } return false; }
public override bool ProcessDeviceTypeCommand(device_type_command_que cmd) { if (cmd.device.device_types.name == "USBUIRT") { switch (cmd.device_type_commands.name) { case "ADD": var addDeviceForm = new Forms.AddDeviceDlg(this.controller); if (addDeviceForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.CreateNewInfraredDevice(addDeviceForm.DeviceName); } break; } } else if (cmd.device.device_types.name == "INFRARED") { switch (cmd.device_type_commands.name) { case "LEARN": var learnForm = new Forms.LearnCommandDlg(this.controller); if (learnForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { } break; } } return true; }
void device_type_command_que_DeviceTypeCommandRunCompleteEvent(device_type_command_que cmd, bool withErrors, string txtError) { }
void device_type_command_que_DeviceTypeCommandRunCompleteEvent(device_type_command_que cmd, bool withErrors, string txtError) { if (cmd.id == CmdWaitingForProcessingQueID) { Waiting = false; if (withErrors) errorCount++; } }
void device_type_command_que_DeviceTypeCommandRunCompleteEvent(device_type_command_que cmd, bool withErrors, string txtError) { if (this.InvokeRequired) this.Invoke(new device_type_command_que.DeviceTypeCommandRunCompleteEventHandler(device_type_command_que_DeviceTypeCommandRunCompleteEvent), new object[] { cmd, withErrors, txtError }); else { if (withErrors) Logger.WriteToLog(Urgency.INFO, "Qued device type command #'" + cmd.id + "' has completed with errors.", "EVENT"); } }
public static void DeviceTypeCommandRunComplete(device_type_command_que cmd, bool withErrors, string txtError) { if (DeviceTypeCommandRunCompleteEvent != null) DeviceTypeCommandRunCompleteEvent(cmd, withErrors, txtError); }
public abstract bool ProcessDeviceTypeCommand(device_type_command_que cmd);
void device_type_command_que_DeviceTypeCommandRunCompleteEvent(device_type_command_que cmd, bool withErrors, string txtError) { this.BroadcastEvent("DeviceTypeCommandRunComplete", cmd.id.ToString()); }
public void Run(long device_id, string argument = "") { device_type_command_que cmd = new device_type_command_que { device_type_command_id = this.id, arg = argument, device_id = device_id }; cmd.Run(); }
/// <summary> /// Deprecated Method for adding a new object to the device_type_command_que EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTodevice_type_command_que(device_type_command_que device_type_command_que) { base.AddObject("device_type_command_que", device_type_command_que); }
/// <summary> /// Create a new device_type_command_que object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="device_type_command_id">Initial value of the device_type_command_id property.</param> /// <param name="device_id">Initial value of the device_id property.</param> /// <param name="arg">Initial value of the arg property.</param> public static device_type_command_que Createdevice_type_command_que(global::System.Int64 id, global::System.Int64 device_type_command_id, global::System.Int64 device_id, global::System.String arg) { device_type_command_que device_type_command_que = new device_type_command_que(); device_type_command_que.id = id; device_type_command_que.device_type_command_id = device_type_command_id; device_type_command_que.device_id = device_id; device_type_command_que.arg = arg; return device_type_command_que; }