Using Harmony Function Action Command.
1.1 --- a/Server/Actions/ActionHarmonyCommand.cs Mon Aug 29 17:36:02 2016 +0200
1.2 +++ b/Server/Actions/ActionHarmonyCommand.cs Tue Aug 30 03:07:59 2016 +0200
1.3 @@ -19,7 +19,7 @@
1.4 public string DeviceId { get; set; } = "";
1.5
1.6 [DataMember]
1.7 - public string FunctionName { get; set; } = "";
1.8 + public string Command { get; set; } = "";
1.9
1.10 [DataMember]
1.11 [AttributeObjectProperty(
1.12 @@ -48,7 +48,8 @@
1.13 brief += DeviceId;
1.14 }
1.15
1.16 - brief += " do " + FunctionName;
1.17 + // TODO: Fetch function label from command
1.18 + brief += " do " + Command;
1.19
1.20 return brief;
1.21 }
1.22 @@ -76,7 +77,9 @@
1.23 {
1.24 // Wait synchronously for now until we figure out how we could do async stuff in EAR.
1.25 // TODO: Have an abort option in EAR. For instance we don't want to keep sending Harmony command if one failed.
1.26 - Program.HarmonyClient.TrySendCommandAsync(DeviceId, FunctionName).Wait(10*1000);
1.27 + Task<bool> task = Program.HarmonyClient.TrySendKeyPressAsync(DeviceId, Command);
1.28 + bool result = task.Result; //Synchronously waiting for result
1.29 + Trace.WriteLine("ActionHarmonyCommand.DoExecute result: " + result.ToString());
1.30 }
1.31 else
1.32 {
1.33 @@ -101,7 +104,7 @@
1.34 {
1.35 foreach (HarmonyHub.Function f in cg.Functions)
1.36 {
1.37 - if (f.Name.Equals(FunctionName))
1.38 + if (f.Action.Command.Equals(Command))
1.39 {
1.40 //We found our device and our function
1.41 return true;
1.42 @@ -115,7 +118,11 @@
1.43 return false;
1.44 }
1.45
1.46 -
1.47 + /// <summary>
1.48 + ///
1.49 + /// </summary>
1.50 + /// <param name="sender"></param>
1.51 + /// <param name="e"></param>
1.52 void ClickEventHandler(object sender, EventArgs e)
1.53 {
1.54 FormSelectHarmonyCommand dlg = new FormSelectHarmonyCommand();
1.55 @@ -123,7 +130,7 @@
1.56 if (res == DialogResult.OK)
1.57 {
1.58 DeviceId = dlg.DeviceId;
1.59 - FunctionName = dlg.FunctionName;
1.60 + Command = dlg.Command;
1.61 SelectCommand.Text = Brief();
1.62 //Tell observer the object itself changed
1.63 OnPropertyChanged("Brief");
2.1 --- a/Server/FormMain.cs Mon Aug 29 17:36:02 2016 +0200
2.2 +++ b/Server/FormMain.cs Tue Aug 30 03:07:59 2016 +0200
2.3 @@ -3065,7 +3065,7 @@
2.4
2.5 foreach (HarmonyHub.Function f in cg.Functions)
2.6 {
2.7 - TreeNode fNode = cgNode.Nodes.Add(f.Name);
2.8 + TreeNode fNode = cgNode.Nodes.Add(f.Label);
2.9 fNode.Tag = f;
2.10 }
2.11 }
2.12 @@ -3083,9 +3083,9 @@
2.13 HarmonyHub.Function f = tag;
2.14 HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
2.15
2.16 - Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
2.17 -
2.18 - await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name);
2.19 + Trace.WriteLine($"Harmony: Sending {f.Label} to {d.Label}...");
2.20 +
2.21 + await Program.HarmonyClient.TrySendKeyPressAsync(d.Id, f.Action.Command);
2.22 }
2.23 }
2.24
3.1 --- a/Server/FormSelectHarmonyCommand.cs Mon Aug 29 17:36:02 2016 +0200
3.2 +++ b/Server/FormSelectHarmonyCommand.cs Tue Aug 30 03:07:59 2016 +0200
3.3 @@ -19,7 +19,7 @@
3.4 }
3.5
3.6 public string DeviceId;
3.7 - public string FunctionName;
3.8 + public string Command;
3.9
3.10 /// <summary>
3.11 ///
3.12 @@ -51,7 +51,7 @@
3.13
3.14 foreach (HarmonyHub.Function f in cg.Functions)
3.15 {
3.16 - TreeNode fNode = cgNode.Nodes.Add(f.Name);
3.17 + TreeNode fNode = cgNode.Nodes.Add(f.Label);
3.18 fNode.Tag = f;
3.19 }
3.20 }
3.21 @@ -74,9 +74,9 @@
3.22 HarmonyHub.Function f = tag;
3.23 HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
3.24
3.25 - Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
3.26 + Trace.WriteLine($"Harmony: Sending {f.Label} to {d.Label}...");
3.27
3.28 - await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name);
3.29 + await Program.HarmonyClient.TrySendKeyPressAsync(d.Id, f.Action.Command);
3.30 }
3.31 }
3.32
3.33 @@ -97,12 +97,12 @@
3.34 HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
3.35
3.36 DeviceId = d.Id;
3.37 - FunctionName = f.Name;
3.38 + Command = f.Action.Command;
3.39 }
3.40 else
3.41 {
3.42 DeviceId = "";
3.43 - FunctionName = "";
3.44 + Command = "";
3.45 }
3.46
3.47 }
4.1 --- a/Server/SharpDisplayManager.csproj Mon Aug 29 17:36:02 2016 +0200
4.2 +++ b/Server/SharpDisplayManager.csproj Tue Aug 30 03:07:59 2016 +0200
4.3 @@ -34,7 +34,7 @@
4.4 <WebPage>index.htm</WebPage>
4.5 <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
4.6 <ApplicationRevision>0</ApplicationRevision>
4.7 - <ApplicationVersion>1.0.5.0</ApplicationVersion>
4.8 + <ApplicationVersion>1.0.7.0</ApplicationVersion>
4.9 <UseApplicationTrust>false</UseApplicationTrust>
4.10 <CreateDesktopShortcut>true</CreateDesktopShortcut>
4.11 <PublishWizardCompleted>true</PublishWizardCompleted>
4.12 @@ -112,7 +112,7 @@
4.13 <Private>True</Private>
4.14 </Reference>
4.15 <Reference Include="HarmonyHub, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
4.16 - <HintPath>..\packages\SharpLibHarmony.0.6.1\lib\net451\HarmonyHub.dll</HintPath>
4.17 + <HintPath>..\packages\SharpLibHarmony.0.6.2\lib\net451\HarmonyHub.dll</HintPath>
4.18 <Private>True</Private>
4.19 </Reference>
4.20 <Reference Include="LibCecSharp, Version=2.2.0.0, Culture=neutral, processorArchitecture=x86">
5.1 --- a/Server/packages.config Mon Aug 29 17:36:02 2016 +0200
5.2 +++ b/Server/packages.config Tue Aug 30 03:07:59 2016 +0200
5.3 @@ -4,7 +4,7 @@
5.4 <package id="Loamen.agsXMPP" version="1.3.1" targetFramework="net46" />
5.5 <package id="NAudio" version="1.7.3" targetFramework="net45" />
5.6 <package id="SharpLibDisplay" version="0.2.5" targetFramework="net46" />
5.7 - <package id="SharpLibHarmony" version="0.6.1" targetFramework="net46" />
5.8 + <package id="SharpLibHarmony" version="0.6.2" targetFramework="net46" />
5.9 <package id="SharpLibHid" version="1.4.2" targetFramework="net46" />
5.10 <package id="SharpLibNotification" version="0.0.1" targetFramework="net46" />
5.11 <package id="SharpLibWin32" version="0.0.9" targetFramework="net46" />