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");