# HG changeset patch # User StephaneLenclud # Date 1472519279 -7200 # Node ID 3f1d16d233dc45854bee844165472d97e3954011 # Parent 51b86efdc4487ce37f64cd8c2705e2f6faacb635 Using Harmony Function Action Command. diff -r 51b86efdc448 -r 3f1d16d233dc Server/Actions/ActionHarmonyCommand.cs --- a/Server/Actions/ActionHarmonyCommand.cs Mon Aug 29 17:36:02 2016 +0200 +++ b/Server/Actions/ActionHarmonyCommand.cs Tue Aug 30 03:07:59 2016 +0200 @@ -19,7 +19,7 @@ public string DeviceId { get; set; } = ""; [DataMember] - public string FunctionName { get; set; } = ""; + public string Command { get; set; } = ""; [DataMember] [AttributeObjectProperty( @@ -48,7 +48,8 @@ brief += DeviceId; } - brief += " do " + FunctionName; + // TODO: Fetch function label from command + brief += " do " + Command; return brief; } @@ -76,7 +77,9 @@ { // Wait synchronously for now until we figure out how we could do async stuff in EAR. // TODO: Have an abort option in EAR. For instance we don't want to keep sending Harmony command if one failed. - Program.HarmonyClient.TrySendCommandAsync(DeviceId, FunctionName).Wait(10*1000); + Task task = Program.HarmonyClient.TrySendKeyPressAsync(DeviceId, Command); + bool result = task.Result; //Synchronously waiting for result + Trace.WriteLine("ActionHarmonyCommand.DoExecute result: " + result.ToString()); } else { @@ -101,7 +104,7 @@ { foreach (HarmonyHub.Function f in cg.Functions) { - if (f.Name.Equals(FunctionName)) + if (f.Action.Command.Equals(Command)) { //We found our device and our function return true; @@ -115,7 +118,11 @@ return false; } - + /// + /// + /// + /// + /// void ClickEventHandler(object sender, EventArgs e) { FormSelectHarmonyCommand dlg = new FormSelectHarmonyCommand(); @@ -123,7 +130,7 @@ if (res == DialogResult.OK) { DeviceId = dlg.DeviceId; - FunctionName = dlg.FunctionName; + Command = dlg.Command; SelectCommand.Text = Brief(); //Tell observer the object itself changed OnPropertyChanged("Brief"); diff -r 51b86efdc448 -r 3f1d16d233dc Server/FormMain.cs --- a/Server/FormMain.cs Mon Aug 29 17:36:02 2016 +0200 +++ b/Server/FormMain.cs Tue Aug 30 03:07:59 2016 +0200 @@ -3065,7 +3065,7 @@ foreach (HarmonyHub.Function f in cg.Functions) { - TreeNode fNode = cgNode.Nodes.Add(f.Name); + TreeNode fNode = cgNode.Nodes.Add(f.Label); fNode.Tag = f; } } @@ -3083,9 +3083,9 @@ HarmonyHub.Function f = tag; HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag; - Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}..."); - - await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name); + Trace.WriteLine($"Harmony: Sending {f.Label} to {d.Label}..."); + + await Program.HarmonyClient.TrySendKeyPressAsync(d.Id, f.Action.Command); } } diff -r 51b86efdc448 -r 3f1d16d233dc Server/FormSelectHarmonyCommand.cs --- a/Server/FormSelectHarmonyCommand.cs Mon Aug 29 17:36:02 2016 +0200 +++ b/Server/FormSelectHarmonyCommand.cs Tue Aug 30 03:07:59 2016 +0200 @@ -19,7 +19,7 @@ } public string DeviceId; - public string FunctionName; + public string Command; /// /// @@ -51,7 +51,7 @@ foreach (HarmonyHub.Function f in cg.Functions) { - TreeNode fNode = cgNode.Nodes.Add(f.Name); + TreeNode fNode = cgNode.Nodes.Add(f.Label); fNode.Tag = f; } } @@ -74,9 +74,9 @@ HarmonyHub.Function f = tag; HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag; - Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}..."); + Trace.WriteLine($"Harmony: Sending {f.Label} to {d.Label}..."); - await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name); + await Program.HarmonyClient.TrySendKeyPressAsync(d.Id, f.Action.Command); } } @@ -97,12 +97,12 @@ HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag; DeviceId = d.Id; - FunctionName = f.Name; + Command = f.Action.Command; } else { DeviceId = ""; - FunctionName = ""; + Command = ""; } } diff -r 51b86efdc448 -r 3f1d16d233dc Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Mon Aug 29 17:36:02 2016 +0200 +++ b/Server/SharpDisplayManager.csproj Tue Aug 30 03:07:59 2016 +0200 @@ -34,7 +34,7 @@ index.htm false 0 - 1.0.5.0 + 1.0.7.0 false true true @@ -112,7 +112,7 @@ True - ..\packages\SharpLibHarmony.0.6.1\lib\net451\HarmonyHub.dll + ..\packages\SharpLibHarmony.0.6.2\lib\net451\HarmonyHub.dll True diff -r 51b86efdc448 -r 3f1d16d233dc Server/packages.config --- a/Server/packages.config Mon Aug 29 17:36:02 2016 +0200 +++ b/Server/packages.config Tue Aug 30 03:07:59 2016 +0200 @@ -4,7 +4,7 @@ - +