public ProgramBlock SaveMacro(string options) { RecordingDisable(); // var program = new ProgramBlock(); program.Name = "New Macro"; program.Address = masterControlProgram.GeneratePid(); program.Type = "Wizard"; foreach (var migCommand in macroCommands) { var command = new ProgramCommand(); command.Domain = migCommand.Domain; command.Target = migCommand.NodeId; command.CommandString = migCommand.Command; command.CommandArguments = ""; if (!string.IsNullOrEmpty(migCommand.GetOption(0)) && migCommand.GetOption(0) != "null") { //TODO: should we pass entire command option string? migCmd.OptionsString command.CommandArguments = migCommand.GetOption(0) + (options != "" && options != "null" ? "/" + options : ""); } program.Commands.Add(command); } masterControlProgram.ProgramAdd(program); // return(program); }
public ProgramBlock SaveMacro(string options) { RecordingDisable(); // ProgramBlock pb = new ProgramBlock(); pb.Name = "New Macro"; pb.Address = _mastercontrolprogram.GeneratePid(); pb.Type = "Wizard"; foreach (MIGInterfaceCommand mc in _macrocommands) { ProgramCommand pc = new ProgramCommand(); pc.Domain = mc.domain; pc.Target = mc.nodeid; pc.CommandString = mc.command; pc.CommandArguments = ""; if (!string.IsNullOrEmpty(mc.GetOption(0)) && mc.GetOption(0) != "null") { //TODO: should we pass entire command option string? migCmd.OptionsString pc.CommandArguments = mc.GetOption(0) + (options != "" && options != "null" ? "/" + options : ""); } pb.Commands.Add(pc); } _mastercontrolprogram.ProgramAdd(pb); // return(pb); }
private void ExecuteProgramCommand(ProgramCommand programCommand) { string command = programCommand.Domain + "/" + programCommand.Target + "/" + programCommand.CommandString + "/" + System.Uri.EscapeDataString(programCommand.CommandArguments); var interfaceCommand = new MIGInterfaceCommand(command); homegenie.InterfaceControl(interfaceCommand); }
public ProgramBlock SaveMacro(string options) { RecordingDisable(); // var program = new ProgramBlock(); program.Name = "New Macro"; program.Address = masterControlProgram.GeneratePid(); program.Type = "Wizard"; foreach (var migCommand in macroCommands) { var command = new ProgramCommand(); command.Domain = migCommand.Domain; command.Target = migCommand.NodeId; command.CommandString = migCommand.Command; command.CommandArguments = ""; if (!string.IsNullOrEmpty(migCommand.GetOption(0)) && migCommand.GetOption(0) != "null") { //TODO: should we pass entire command option string? migCmd.OptionsString command.CommandArguments = migCommand.GetOption(0) + (options != "" && options != "null" ? "/" + options : ""); } program.Commands.Add(command); } masterControlProgram.ProgramAdd(program); // return program; }
private void _mcp_executeCommand(ProgramCommand c) { string wrequest = c.Domain + "/" + c.Target + "/" + c.CommandString + "/" + c.CommandArguments; MIGInterfaceCommand cmd = new MIGInterfaceCommand(wrequest); _homegenie.InterfaceControl(cmd); _homegenie.WaitOnPending(c.Domain); }
// TODO: find a better solution to this... public void ExecuteWizardScript(ProgramBlock pb) { int repeatstartline = 0; int repeatcount = 0; for (int x = 0; x < pb.Commands.Count; x++) { if (pb.Commands[x].Domain == Domains.HomeAutomation_HomeGenie) { switch (pb.Commands[x].Target) { case "Automation": // string cs = pb.Commands[x].CommandString; switch (cs) { case "Program.Pause": Thread.Sleep((int)(double.Parse(pb.Commands[x].CommandArguments, System.Globalization.CultureInfo.InvariantCulture) * 1000)); break; case "Program.Repeat": // TODO: implement check for contiguous repeat statements if (repeatcount <= 0) { repeatcount = (int)(double.Parse(pb.Commands[x].CommandArguments, System.Globalization.CultureInfo.InvariantCulture)); } if (--repeatcount == 0) { repeatstartline = x + 1; } else { x = repeatstartline - 1; } break; default: ProgramCommand c = pb.Commands[x]; string wrequest = c.Domain + "/" + c.Target + "/" + c.CommandString + "/" + c.CommandArguments; _homegenie.ExecuteAutomationRequest(new MIGInterfaceCommand(wrequest)); break; } // break; } } else { _mcp_executeCommand(pb.Commands[x]); } // Thread.Sleep(10); } }
private void ExecuteProgramCommand(ProgramCommand programCommand) { string command = programCommand.Domain + "/" + programCommand.Target + "/" + programCommand.CommandString + "/" + programCommand.CommandArguments; var interfaceCommand = new MIGInterfaceCommand(command); homegenie.InterfaceControl(interfaceCommand); homegenie.WaitOnPending(programCommand.Domain); }