1.1 --- a/Server/Actions/ActionCecActiveSource.cs Mon Aug 22 13:20:54 2016 +0200
1.2 +++ b/Server/Actions/ActionCecActiveSource.cs Thu Aug 25 00:42:09 2016 +0200
1.3 @@ -2,6 +2,7 @@
1.4 using SharpLib.Ear;
1.5 using System;
1.6 using System.Collections.Generic;
1.7 +using System.Diagnostics;
1.8 using System.Linq;
1.9 using System.Runtime.Serialization;
1.10 using System.Text;
1.11 @@ -29,7 +30,7 @@
1.12 {
1.13 if (Cec.Client.Static == null)
1.14 {
1.15 - Console.WriteLine("WARNING: No CEC client installed.");
1.16 + Trace.WriteLine("WARNING: No CEC client installed.");
1.17 return;
1.18 }
1.19
2.1 --- a/Server/Actions/ActionCecClose.cs Mon Aug 22 13:20:54 2016 +0200
2.2 +++ b/Server/Actions/ActionCecClose.cs Thu Aug 25 00:42:09 2016 +0200
2.3 @@ -2,6 +2,7 @@
2.4 using SharpLib.Ear;
2.5 using System;
2.6 using System.Collections.Generic;
2.7 +using System.Diagnostics;
2.8 using System.Linq;
2.9 using System.Runtime.Serialization;
2.10 using System.Text;
2.11 @@ -17,7 +18,7 @@
2.12 {
2.13 if (Cec.Client.Static == null)
2.14 {
2.15 - Console.WriteLine("WARNING: No CEC client installed.");
2.16 + Trace.WriteLine("WARNING: No CEC client installed.");
2.17 return;
2.18 }
2.19
3.1 --- a/Server/Actions/ActionCecDevicePowerOn.cs Mon Aug 22 13:20:54 2016 +0200
3.2 +++ b/Server/Actions/ActionCecDevicePowerOn.cs Thu Aug 25 00:42:09 2016 +0200
3.3 @@ -2,6 +2,7 @@
3.4 using SharpLib.Ear;
3.5 using System;
3.6 using System.Collections.Generic;
3.7 +using System.Diagnostics;
3.8 using System.Linq;
3.9 using System.Runtime.InteropServices;
3.10 using System.Runtime.Serialization;
3.11 @@ -30,7 +31,7 @@
3.12 {
3.13 if (Cec.Client.Static == null)
3.14 {
3.15 - Console.WriteLine("WARNING: No CEC client installed.");
3.16 + Trace.WriteLine("WARNING: No CEC client installed.");
3.17 return;
3.18 }
3.19
4.1 --- a/Server/Actions/ActionCecDeviceStandby.cs Mon Aug 22 13:20:54 2016 +0200
4.2 +++ b/Server/Actions/ActionCecDeviceStandby.cs Thu Aug 25 00:42:09 2016 +0200
4.3 @@ -2,6 +2,7 @@
4.4 using SharpLib.Ear;
4.5 using System;
4.6 using System.Collections.Generic;
4.7 +using System.Diagnostics;
4.8 using System.Linq;
4.9 using System.Runtime.InteropServices;
4.10 using System.Runtime.Serialization;
4.11 @@ -30,7 +31,7 @@
4.12 {
4.13 if (Cec.Client.Static == null)
4.14 {
4.15 - Console.WriteLine("WARNING: No CEC client installed.");
4.16 + Trace.WriteLine("WARNING: No CEC client installed.");
4.17 return;
4.18 }
4.19
5.1 --- a/Server/Actions/ActionCecInactiveSource.cs Mon Aug 22 13:20:54 2016 +0200
5.2 +++ b/Server/Actions/ActionCecInactiveSource.cs Thu Aug 25 00:42:09 2016 +0200
5.3 @@ -2,6 +2,7 @@
5.4 using SharpLib.Ear;
5.5 using System;
5.6 using System.Collections.Generic;
5.7 +using System.Diagnostics;
5.8 using System.Linq;
5.9 using System.Runtime.Serialization;
5.10 using System.Text;
5.11 @@ -17,7 +18,7 @@
5.12 {
5.13 if (Cec.Client.Static == null)
5.14 {
5.15 - Console.WriteLine("WARNING: No CEC client installed.");
5.16 + Trace.WriteLine("WARNING: No CEC client installed.");
5.17 return;
5.18 }
5.19
6.1 --- a/Server/Actions/ActionCecOpen.cs Mon Aug 22 13:20:54 2016 +0200
6.2 +++ b/Server/Actions/ActionCecOpen.cs Thu Aug 25 00:42:09 2016 +0200
6.3 @@ -2,6 +2,7 @@
6.4 using SharpLib.Ear;
6.5 using System;
6.6 using System.Collections.Generic;
6.7 +using System.Diagnostics;
6.8 using System.Linq;
6.9 using System.Runtime.Serialization;
6.10 using System.Text;
6.11 @@ -17,7 +18,7 @@
6.12 {
6.13 if (Cec.Client.Static == null)
6.14 {
6.15 - Console.WriteLine("WARNING: No CEC client installed.");
6.16 + Trace.WriteLine("WARNING: No CEC client installed.");
6.17 return;
6.18 }
6.19
7.1 --- a/Server/Actions/ActionCecScan.cs Mon Aug 22 13:20:54 2016 +0200
7.2 +++ b/Server/Actions/ActionCecScan.cs Thu Aug 25 00:42:09 2016 +0200
7.3 @@ -2,6 +2,7 @@
7.4 using SharpLib.Ear;
7.5 using System;
7.6 using System.Collections.Generic;
7.7 +using System.Diagnostics;
7.8 using System.Linq;
7.9 using System.Runtime.Serialization;
7.10 using System.Text;
7.11 @@ -18,7 +19,7 @@
7.12 {
7.13 if (Cec.Client.Static == null)
7.14 {
7.15 - Console.WriteLine("WARNING: No CEC client installed.");
7.16 + Trace.WriteLine("WARNING: No CEC client installed.");
7.17 return;
7.18 }
7.19
8.1 --- a/Server/Actions/ActionCecUserControlPressed.cs Mon Aug 22 13:20:54 2016 +0200
8.2 +++ b/Server/Actions/ActionCecUserControlPressed.cs Thu Aug 25 00:42:09 2016 +0200
8.3 @@ -2,6 +2,7 @@
8.4 using SharpLib.Ear;
8.5 using System;
8.6 using System.Collections.Generic;
8.7 +using System.Diagnostics;
8.8 using System.Linq;
8.9 using System.Runtime.InteropServices;
8.10 using System.Runtime.Serialization;
8.11 @@ -60,7 +61,7 @@
8.12 {
8.13 if (Cec.Client.Static == null)
8.14 {
8.15 - Console.WriteLine("WARNING: No CEC client installed.");
8.16 + Trace.WriteLine("WARNING: No CEC client installed.");
8.17 return;
8.18 }
8.19
9.1 --- a/Server/Actions/ActionCecUserControlReleased.cs Mon Aug 22 13:20:54 2016 +0200
9.2 +++ b/Server/Actions/ActionCecUserControlReleased.cs Thu Aug 25 00:42:09 2016 +0200
9.3 @@ -2,6 +2,7 @@
9.4 using SharpLib.Ear;
9.5 using System;
9.6 using System.Collections.Generic;
9.7 +using System.Diagnostics;
9.8 using System.Linq;
9.9 using System.Runtime.InteropServices;
9.10 using System.Runtime.Serialization;
9.11 @@ -52,7 +53,7 @@
9.12 {
9.13 if (Cec.Client.Static == null)
9.14 {
9.15 - Console.WriteLine("WARNING: No CEC client installed.");
9.16 + Trace.WriteLine("WARNING: No CEC client installed.");
9.17 return;
9.18 }
9.19
10.1 --- a/Server/Actions/ActionHarmonyCommand.cs Mon Aug 22 13:20:54 2016 +0200
10.2 +++ b/Server/Actions/ActionHarmonyCommand.cs Thu Aug 25 00:42:09 2016 +0200
10.3 @@ -2,6 +2,7 @@
10.4 using SharpLib.Ear;
10.5 using System;
10.6 using System.Collections.Generic;
10.7 +using System.Diagnostics;
10.8 using System.Linq;
10.9 using System.Text;
10.10 using System.Threading.Tasks;
10.11 @@ -77,7 +78,7 @@
10.12 }
10.13 else
10.14 {
10.15 - Console.WriteLine("WARNING: No Harmony client connection.");
10.16 + Trace.WriteLine("WARNING: No Harmony client connection.");
10.17 }
10.18
10.19 }
11.1 --- a/Server/CecClient.cs Mon Aug 22 13:20:54 2016 +0200
11.2 +++ b/Server/CecClient.cs Thu Aug 25 00:42:09 2016 +0200
11.3 @@ -34,6 +34,7 @@
11.4 using System.Text;
11.5 using CecSharp;
11.6 using System.Threading;
11.7 +using System.Diagnostics;
11.8
11.9 namespace Cec
11.10 {
11.11 @@ -98,7 +99,7 @@
11.12
11.13 if (Static != null)
11.14 {
11.15 - Console.WriteLine("WARNING: CEC client static already exists");
11.16 + Trace.WriteLine("WARNING: CEC client static already exists");
11.17 }
11.18 else
11.19 {
11.20 @@ -106,8 +107,8 @@
11.21 }
11.22
11.23
11.24 - //Console.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
11.25 - Console.WriteLine("INFO: CEC Parser created - libCEC version " + Config.ServerVersion);
11.26 + //Trace.WriteLine("CEC Parser created - libCEC version " + Lib.VersionToString(Config.ServerVersion));
11.27 + Trace.WriteLine("INFO: CEC Parser created - libCEC version " + Config.ServerVersion);
11.28 }
11.29
11.30
11.31 @@ -125,7 +126,7 @@
11.32 log += " " + data.Data;
11.33 }
11.34
11.35 - Console.WriteLine(log);
11.36 + Trace.WriteLine(log);
11.37
11.38 Close();
11.39 //Try reconnect
11.40 @@ -140,7 +141,7 @@
11.41 /// <returns></returns>
11.42 public override int ReceiveMenuStateChange(CecMenuState newVal)
11.43 {
11.44 - Console.WriteLine("CEC menu state changed to: " + iLib.ToString(newVal));
11.45 + Trace.WriteLine("CEC menu state changed to: " + iLib.ToString(newVal));
11.46 return 1;
11.47 }
11.48
11.49 @@ -151,13 +152,13 @@
11.50 /// <param name="activated"></param>
11.51 public override void SourceActivated(CecLogicalAddress logicalAddress, bool activated)
11.52 {
11.53 - Console.WriteLine("CEC source activated: " + iLib.ToString(logicalAddress) + "/" + activated.ToString() );
11.54 + Trace.WriteLine("CEC source activated: " + iLib.ToString(logicalAddress) + "/" + activated.ToString() );
11.55 return;
11.56 }
11.57
11.58 public override int ReceiveCommand(CecCommand command)
11.59 {
11.60 - Console.WriteLine(string.Format("CEC command '{5}' from {0} to {1} - Ack: {2} Eom: {3} OpcodeSet: {4} Timeout: {6}",
11.61 + Trace.WriteLine(string.Format("CEC command '{5}' from {0} to {1} - Ack: {2} Eom: {3} OpcodeSet: {4} Timeout: {6}",
11.62 iLib.ToString(command.Initiator),
11.63 iLib.ToString(command.Destination),
11.64 command.Ack.ToString(),
11.65 @@ -171,7 +172,7 @@
11.66
11.67 public override int ReceiveKeypress(CecKeypress key)
11.68 {
11.69 - Console.WriteLine(string.Format("CEC keypress: {0} Duration:{1} Empty: {2}",
11.70 + Trace.WriteLine(string.Format("CEC keypress: {0} Duration:{1} Empty: {2}",
11.71 key.Keycode.ToString(), key.Duration.ToString(), key.Empty.ToString()));
11.72 return 1;
11.73 }
11.74 @@ -207,7 +208,7 @@
11.75 break;
11.76 }
11.77 string strLog = string.Format("{0} {1} {2}", strLevel, message.Time, message.Message);
11.78 - Console.WriteLine(strLog);
11.79 + Trace.WriteLine(strLog);
11.80
11.81 }
11.82 return 1;
11.83 @@ -228,7 +229,7 @@
11.84 }
11.85 else
11.86 {
11.87 - Console.WriteLine("CEC did not find any adapters");
11.88 + Trace.WriteLine("CEC did not find any adapters");
11.89 }
11.90
11.91 return iConnected;
11.92 @@ -280,7 +281,7 @@
11.93 break;
11.94
11.95 default:
11.96 - Console.WriteLine(i.ToString());
11.97 + Trace.WriteLine(i.ToString());
11.98 Thread.Sleep(1000);
11.99 iLib.SendKeypress(CecLogicalAddress.Tv, (CecUserControlCode)i, true);
11.100
11.101 @@ -343,7 +344,7 @@
11.102 scanRes += "===================" + "\n";
11.103 }
11.104
11.105 - Console.Write(scanRes);
11.106 + Trace.Write(scanRes);
11.107 }
11.108
11.109 public void ListAdapters()
11.110 @@ -351,214 +352,9 @@
11.111 int iAdapter = 0;
11.112 foreach (CecAdapter adapter in iLib.FindAdapters(string.Empty))
11.113 {
11.114 - Console.WriteLine("Adapter: " + iAdapter++);
11.115 - Console.WriteLine("Path: " + adapter.Path);
11.116 - Console.WriteLine("Com port: " + adapter.ComPort);
11.117 - }
11.118 - }
11.119 -
11.120 - void ShowConsoleHelp()
11.121 - {
11.122 - Console.WriteLine(
11.123 - "================================================================================" + Environment.NewLine +
11.124 - "Available commands:" + Environment.NewLine +
11.125 - Environment.NewLine +
11.126 - "[tx] {bytes} transfer bytes over the CEC line." + Environment.NewLine +
11.127 - "[txn] {bytes} transfer bytes but don't wait for transmission ACK." + Environment.NewLine +
11.128 - "[on] {address} power on the device with the given logical address." + Environment.NewLine +
11.129 - "[standby] {address} put the device with the given address in standby mode." + Environment.NewLine +
11.130 - "[la] {logical_address} change the logical address of the CEC adapter." + Environment.NewLine +
11.131 - "[pa] {physical_address} change the physical address of the CEC adapter." + Environment.NewLine +
11.132 - "[osd] {addr} {string} set OSD message on the specified device." + Environment.NewLine +
11.133 - "[ver] {addr} get the CEC version of the specified device." + Environment.NewLine +
11.134 - "[ven] {addr} get the vendor ID of the specified device." + Environment.NewLine +
11.135 - "[lang] {addr} get the menu language of the specified device." + Environment.NewLine +
11.136 - "[pow] {addr} get the power status of the specified device." + Environment.NewLine +
11.137 - "[poll] {addr} poll the specified device." + Environment.NewLine +
11.138 - "[scan] scan the CEC bus and display device info" + Environment.NewLine +
11.139 - "[mon] {1|0} enable or disable CEC bus monitoring." + Environment.NewLine +
11.140 - "[log] {1 - 31} change the log level. see cectypes.h for values." + Environment.NewLine +
11.141 - "[ping] send a ping command to the CEC adapter." + Environment.NewLine +
11.142 - "[bl] to let the adapter enter the bootloader, to upgrade" + Environment.NewLine +
11.143 - " the flash rom." + Environment.NewLine +
11.144 - "[r] reconnect to the CEC adapter." + Environment.NewLine +
11.145 - "[h] or [help] show this help." + Environment.NewLine +
11.146 - "[q] or [quit] to quit the CEC test client and switch off all" + Environment.NewLine +
11.147 - " connected CEC devices." + Environment.NewLine +
11.148 - "================================================================================");
11.149 - }
11.150 -
11.151 - public void MainLoop()
11.152 - {
11.153 - bool bContinue = true;
11.154 - string command;
11.155 - while (bContinue)
11.156 - {
11.157 - Console.WriteLine("waiting for input");
11.158 -
11.159 - command = Console.ReadLine();
11.160 - if (command != null && command.Length == 0)
11.161 - continue;
11.162 - string[] splitCommand = command.Split(' ');
11.163 - if (splitCommand[0] == "tx" || splitCommand[0] == "txn")
11.164 - {
11.165 - CecCommand bytes = new CecCommand();
11.166 - for (int iPtr = 1; iPtr < splitCommand.Length; iPtr++)
11.167 - {
11.168 - bytes.PushBack(byte.Parse(splitCommand[iPtr], System.Globalization.NumberStyles.HexNumber));
11.169 - }
11.170 -
11.171 - if (command == "txn")
11.172 - bytes.TransmitTimeout = 0;
11.173 -
11.174 - iLib.Transmit(bytes);
11.175 - }
11.176 - else if (splitCommand[0] == "on")
11.177 - {
11.178 - if (splitCommand.Length > 1)
11.179 - iLib.PowerOnDevices((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.180 - else
11.181 - iLib.PowerOnDevices(CecLogicalAddress.Broadcast);
11.182 - }
11.183 - else if (splitCommand[0] == "standby")
11.184 - {
11.185 - if (splitCommand.Length > 1)
11.186 - iLib.StandbyDevices((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.187 - else
11.188 - iLib.StandbyDevices(CecLogicalAddress.Broadcast);
11.189 - }
11.190 - else if (splitCommand[0] == "poll")
11.191 - {
11.192 - bool bSent = false;
11.193 - if (splitCommand.Length > 1)
11.194 - bSent = iLib.PollDevice((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.195 - else
11.196 - bSent = iLib.PollDevice(CecLogicalAddress.Broadcast);
11.197 - if (bSent)
11.198 - Console.WriteLine("POLL message sent");
11.199 - else
11.200 - Console.WriteLine("POLL message not sent");
11.201 - }
11.202 - else if (splitCommand[0] == "la")
11.203 - {
11.204 - if (splitCommand.Length > 1)
11.205 - iLib.SetLogicalAddress((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.206 - }
11.207 - else if (splitCommand[0] == "pa")
11.208 - {
11.209 - if (splitCommand.Length > 1)
11.210 - iLib.SetPhysicalAddress(ushort.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.211 - }
11.212 - else if (splitCommand[0] == "osd")
11.213 - {
11.214 - if (splitCommand.Length > 2)
11.215 - {
11.216 - StringBuilder osdString = new StringBuilder();
11.217 - for (int iPtr = 1; iPtr < splitCommand.Length; iPtr++)
11.218 - {
11.219 - osdString.Append(splitCommand[iPtr]);
11.220 - if (iPtr != splitCommand.Length - 1)
11.221 - osdString.Append(" ");
11.222 - }
11.223 - iLib.SetOSDString((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber), CecDisplayControl.DisplayForDefaultTime, osdString.ToString());
11.224 - }
11.225 - }
11.226 - else if (splitCommand[0] == "ping")
11.227 - {
11.228 - iLib.PingAdapter();
11.229 - }
11.230 - else if (splitCommand[0] == "mon")
11.231 - {
11.232 - bool enable = splitCommand.Length > 1 ? splitCommand[1] == "1" : false;
11.233 - iLib.SwitchMonitoring(enable);
11.234 - }
11.235 - else if (splitCommand[0] == "bl")
11.236 - {
11.237 - iLib.StartBootloader();
11.238 - }
11.239 - else if (splitCommand[0] == "lang")
11.240 - {
11.241 - if (splitCommand.Length > 1)
11.242 - {
11.243 - string language = iLib.GetDeviceMenuLanguage((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.244 - Console.WriteLine("Menu language: " + language);
11.245 - }
11.246 - }
11.247 - else if (splitCommand[0] == "ven")
11.248 - {
11.249 - if (splitCommand.Length > 1)
11.250 - {
11.251 - CecVendorId vendor = iLib.GetDeviceVendorId((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.252 - Console.WriteLine("Vendor ID: " + iLib.ToString(vendor));
11.253 - }
11.254 - }
11.255 - else if (splitCommand[0] == "ver")
11.256 - {
11.257 - if (splitCommand.Length > 1)
11.258 - {
11.259 - CecVersion version = iLib.GetDeviceCecVersion((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.260 - Console.WriteLine("CEC version: " + iLib.ToString(version));
11.261 - }
11.262 - }
11.263 - else if (splitCommand[0] == "pow")
11.264 - {
11.265 - if (splitCommand.Length > 1)
11.266 - {
11.267 - CecPowerStatus power = iLib.GetDevicePowerStatus((CecLogicalAddress)byte.Parse(splitCommand[1], System.Globalization.NumberStyles.HexNumber));
11.268 - Console.WriteLine("power status: " + iLib.ToString(power));
11.269 - }
11.270 - }
11.271 - else if (splitCommand[0] == "r")
11.272 - {
11.273 - Console.WriteLine("closing the connection");
11.274 - iLib.Close();
11.275 -
11.276 - Console.WriteLine("opening a new connection");
11.277 - Open(10000);
11.278 -
11.279 - Console.WriteLine("setting active source");
11.280 - iLib.SetActiveSource(CecDeviceType.PlaybackDevice);
11.281 - }
11.282 - else if (splitCommand[0] == "scan")
11.283 - {
11.284 - StringBuilder output = new StringBuilder();
11.285 - output.AppendLine("CEC bus information");
11.286 - output.AppendLine("===================");
11.287 - CecLogicalAddresses addresses = iLib.GetActiveDevices();
11.288 - for (int iPtr = 0; iPtr < addresses.Addresses.Length; iPtr++)
11.289 - {
11.290 - CecLogicalAddress address = (CecLogicalAddress)iPtr;
11.291 - if (!addresses.IsSet(address))
11.292 - continue;
11.293 -
11.294 - CecVendorId iVendorId = iLib.GetDeviceVendorId(address);
11.295 - bool bActive = iLib.IsActiveDevice(address);
11.296 - ushort iPhysicalAddress = iLib.GetDevicePhysicalAddress(address);
11.297 - string strAddr = "todo: fixme"; //Lib.PhysicalAddressToString(iPhysicalAddress);
11.298 - CecVersion iCecVersion = iLib.GetDeviceCecVersion(address);
11.299 - CecPowerStatus power = iLib.GetDevicePowerStatus(address);
11.300 - string osdName = iLib.GetDeviceOSDName(address);
11.301 - string lang = iLib.GetDeviceMenuLanguage(address);
11.302 -
11.303 - output.AppendLine("device #" + iPtr + ": " + iLib.ToString(address));
11.304 - output.AppendLine("address: " + strAddr);
11.305 - output.AppendLine("active source: " + (bActive ? "yes" : "no"));
11.306 - output.AppendLine("vendor: " + iLib.ToString(iVendorId));
11.307 - output.AppendLine("osd string: " + osdName);
11.308 - output.AppendLine("CEC version: " + iLib.ToString(iCecVersion));
11.309 - output.AppendLine("power status: " + iLib.ToString(power));
11.310 - if (!string.IsNullOrEmpty(lang))
11.311 - output.AppendLine("language: " + lang);
11.312 - output.AppendLine("");
11.313 - }
11.314 - Console.WriteLine(output.ToString());
11.315 - }
11.316 - else if (splitCommand[0] == "h" || splitCommand[0] == "help")
11.317 - ShowConsoleHelp();
11.318 - else if (splitCommand[0] == "q" || splitCommand[0] == "quit")
11.319 - bContinue = false;
11.320 - else if (splitCommand[0] == "log" && splitCommand.Length > 1)
11.321 - LogLevel = int.Parse(splitCommand[1]);
11.322 + Trace.WriteLine("Adapter: " + iAdapter++);
11.323 + Trace.WriteLine("Path: " + adapter.Path);
11.324 + Trace.WriteLine("Com port: " + adapter.ComPort);
11.325 }
11.326 }
11.327
12.1 --- a/Server/FormMain.cs Mon Aug 22 13:20:54 2016 +0200
12.2 +++ b/Server/FormMain.cs Thu Aug 25 00:42:09 2016 +0200
12.3 @@ -131,7 +131,7 @@
12.4 /// <summary>
12.5 ///
12.6 /// </summary>
12.7 - RichTextBoxTextWriter iWriter;
12.8 + RichTextBoxTraceListener iWriter;
12.9
12.10
12.11 /// <summary>
12.12 @@ -172,8 +172,8 @@
12.13 InitializeComponent();
12.14
12.15 //Redirect console output
12.16 - iWriter = new RichTextBoxTextWriter(richTextBoxLogs);
12.17 - Console.SetOut(iWriter);
12.18 + iWriter = new RichTextBoxTraceListener(richTextBoxLogs);
12.19 + Trace.Listeners.Add(iWriter);
12.20
12.21 //Populate device types
12.22 PopulateDeviceTypes();
12.23 @@ -993,9 +993,6 @@
12.24 //This is our timer tick responsible to perform our render
12.25 private void timer_Tick(object sender, EventArgs e)
12.26 {
12.27 - //Not ideal cause this has nothing to do with display render
12.28 - LogsUpdate();
12.29 -
12.30 //Update our animations
12.31 DateTime NewTickTime = DateTime.Now;
12.32
12.33 @@ -2498,25 +2495,11 @@
12.34 }
12.35
12.36 /// <summary>
12.37 - ///
12.38 - /// </summary>
12.39 - private void LogsUpdate()
12.40 - {
12.41 - if (iWriter != null)
12.42 - {
12.43 - iWriter.Flush();
12.44 - }
12.45 -
12.46 - }
12.47 -
12.48 - /// <summary>
12.49 /// Broadcast messages to subscribers.
12.50 /// </summary>
12.51 /// <param name="message"></param>
12.52 protected override void WndProc(ref Message aMessage)
12.53 {
12.54 - LogsUpdate();
12.55 -
12.56 if (OnWndProc != null)
12.57 {
12.58 OnWndProc(ref aMessage);
12.59 @@ -2577,8 +2560,8 @@
12.60 }
12.61 catch (Exception ex)
12.62 {
12.63 - Console.WriteLine("Exception thrown by ConnectHarmonyAsync");
12.64 - Console.WriteLine(ex.ToString());
12.65 + Trace.WriteLine("Exception thrown by ConnectHarmonyAsync");
12.66 + Trace.WriteLine(ex.ToString());
12.67 }
12.68 }
12.69 }
12.70 @@ -3008,35 +2991,35 @@
12.71 Program.HarmonyClient = null;
12.72 Program.HarmonyConfig = null;
12.73
12.74 - Console.WriteLine("Harmony: Connecting... ");
12.75 + Trace.WriteLine("Harmony: Connecting... ");
12.76 Program.HarmonyClient = new HarmonyHub.Client(iTextBoxHarmonyHubAddress.Text);
12.77 //First create our client and login
12.78 if (File.Exists("SessionToken") && !aForceAuth)
12.79 {
12.80 var sessionToken = File.ReadAllText("SessionToken");
12.81 - Console.WriteLine("Harmony: Reusing token: {0}", sessionToken);
12.82 + Trace.WriteLine("Harmony: Reusing token: {0}", sessionToken);
12.83 Program.HarmonyClient.Open(sessionToken);
12.84 }
12.85 else
12.86 {
12.87 if (string.IsNullOrEmpty(iTextBoxLogitechPassword.Text))
12.88 {
12.89 - Console.WriteLine("Harmony: Credentials missing!");
12.90 + Trace.WriteLine("Harmony: Credentials missing!");
12.91 return;
12.92 }
12.93
12.94 - Console.WriteLine("Harmony: Authenticating with Logitech servers...");
12.95 + Trace.WriteLine("Harmony: Authenticating with Logitech servers...");
12.96 await Program.HarmonyClient.Open(iTextBoxLogitechUserName.Text, iTextBoxLogitechPassword.Text);
12.97 File.WriteAllText("SessionToken", Program.HarmonyClient.Token);
12.98 }
12.99
12.100 - Console.WriteLine("Harmony: Fetching Harmony Hub configuration...");
12.101 + Trace.WriteLine("Harmony: Fetching Harmony Hub configuration...");
12.102
12.103 //Fetch our config
12.104 Program.HarmonyConfig = await Program.HarmonyClient.GetConfigAsync();
12.105 PopulateTreeViewHarmony(Program.HarmonyConfig);
12.106
12.107 - Console.WriteLine("Harmony: Ready");
12.108 + Trace.WriteLine("Harmony: Ready");
12.109
12.110 //Make sure harmony command actions are showing device name instead of device id
12.111 PopulateEventsTreeView();
12.112 @@ -3080,7 +3063,7 @@
12.113 HarmonyHub.Function f = tag;
12.114 HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
12.115
12.116 - Console.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
12.117 + Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
12.118
12.119 await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name);
12.120 }
13.1 --- a/Server/FormSelectHarmonyCommand.cs Mon Aug 22 13:20:54 2016 +0200
13.2 +++ b/Server/FormSelectHarmonyCommand.cs Thu Aug 25 00:42:09 2016 +0200
13.3 @@ -1,5 +1,6 @@
13.4 using System;
13.5 using System.Collections.Generic;
13.6 +using System.Diagnostics;
13.7 using System.ComponentModel;
13.8 using System.Data;
13.9 using System.Drawing;
13.10 @@ -73,7 +74,7 @@
13.11 HarmonyHub.Function f = tag;
13.12 HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
13.13
13.14 - Console.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
13.15 + Trace.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
13.16
13.17 await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name);
13.18 }
14.1 --- a/Server/MarqueeLabel.cs Mon Aug 22 13:20:54 2016 +0200
14.2 +++ b/Server/MarqueeLabel.cs Thu Aug 25 00:42:09 2016 +0200
14.3 @@ -122,7 +122,7 @@
14.4 private double PixelsLeft { get; set; }
14.5 //DateTime a = new DateTime(2010, 05, 12, 13, 15, 00);
14.6 //DateTime b = new DateTime(2010, 05, 12, 13, 45, 00);
14.7 - //Console.WriteLine(b.Subtract(a).TotalMinutes);
14.8 + //Trace.WriteLine(b.Subtract(a).TotalMinutes);
14.9
14.10 public MarqueeLabel()
14.11 {
15.1 --- a/Server/RichTextBoxTextWriter.cs Mon Aug 22 13:20:54 2016 +0200
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,81 +0,0 @@
15.4 -using System;
15.5 -using System.Text;
15.6 -using System.IO;
15.7 -using System.Windows.Forms;
15.8 -
15.9 -namespace SharpDisplayManager
15.10 -{
15.11 - public class RichTextBoxTextWriter : TextWriter
15.12 - {
15.13 - public delegate void WriteDelegate(char aChar);
15.14 -
15.15 - RichTextBox iRichTextBox = null;
15.16 - string iAccumulator = "";
15.17 - private char iLastChar='\n';
15.18 -
15.19 - public RichTextBoxTextWriter(RichTextBox aRichTextBox)
15.20 - {
15.21 - iRichTextBox = aRichTextBox;
15.22 - }
15.23 -
15.24 - public override void Write(char aChar)
15.25 - {
15.26 - if (aChar == '\r')
15.27 - {
15.28 - //Skip
15.29 - return;
15.30 - }
15.31 -
15.32 - //Put our time stamp if starting a new line
15.33 - char previousChar = iLastChar;
15.34 - iLastChar = aChar;
15.35 - if (previousChar == '\n')
15.36 - {
15.37 - //Write(DateTime.Now.ToString("yyyy/MM/dd - HH:mm:ss.fff: "));
15.38 - Write(DateTime.Now.ToString("MM/dd HH:mm:ss.fff: "));
15.39 - }
15.40 -
15.41 -
15.42 - base.Write(aChar);
15.43 - if (iRichTextBox.InvokeRequired)
15.44 - {
15.45 - lock (iAccumulator)
15.46 - {
15.47 - iAccumulator += aChar;
15.48 - }
15.49 -
15.50 - //Invoke was not working from here
15.51 - //WriteDelegate d = new WriteDelegate(Write);
15.52 - //iRichTextBox.Invoke(d, new object[] { aChar });
15.53 - }
15.54 - else
15.55 - {
15.56 - Flush();
15.57 - iRichTextBox.AppendText(aChar.ToString()); // When character data is written, append it to the text box.
15.58 - }
15.59 - }
15.60 -
15.61 - public override Encoding Encoding
15.62 - {
15.63 - get { return System.Text.Encoding.UTF8; }
15.64 - }
15.65 -
15.66 - /// <summary>
15.67 - ///
15.68 - /// </summary>
15.69 - public override void Flush()
15.70 - {
15.71 - base.Flush();
15.72 -
15.73 - lock (iAccumulator)
15.74 - {
15.75 - if (!string.IsNullOrEmpty(iAccumulator))
15.76 - {
15.77 - iRichTextBox.AppendText(iAccumulator); // When character data is written, append it to the text box.
15.78 - iAccumulator = "";
15.79 - }
15.80 - }
15.81 -
15.82 - }
15.83 - }
15.84 -}
15.85 \ No newline at end of file
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/Server/RichTextBoxTraceListener.cs Thu Aug 25 00:42:09 2016 +0200
16.3 @@ -0,0 +1,43 @@
16.4 +using System;
16.5 +using System.Text;
16.6 +using System.IO;
16.7 +using System.Windows.Forms;
16.8 +using System.Diagnostics;
16.9 +
16.10 +namespace SharpDisplayManager
16.11 +{
16.12 + public class RichTextBoxTraceListener : TraceListener
16.13 + {
16.14 + RichTextBox iRichTextBox = null;
16.15 +
16.16 + public RichTextBoxTraceListener(RichTextBox aRichTextBox)
16.17 + {
16.18 + iRichTextBox = aRichTextBox;
16.19 + }
16.20 +
16.21 + public override void WriteLine(string aString)
16.22 + {
16.23 + //Add time stamp and new line characters
16.24 + Write(DateTime.Now.ToString("MM/dd HH:mm:ss.fff: ") + aString + "\r\n");
16.25 + }
16.26 +
16.27 + public override void Write(string aString)
16.28 + {
16.29 + //Allows iRichTextBox to be updated from different thread
16.30 + if (iRichTextBox.InvokeRequired)
16.31 + {
16.32 + // Fire and forget invocation
16.33 + // Using the synchronous variant Invoke tends to result in deadlock here
16.34 + iRichTextBox.BeginInvoke(new MethodInvoker(delegate ()
16.35 + {
16.36 + iRichTextBox.Text += aString;
16.37 + }));
16.38 + }
16.39 + else
16.40 + {
16.41 + iRichTextBox.Text += aString;
16.42 + }
16.43 + }
16.44 +
16.45 + }
16.46 +}
16.47 \ No newline at end of file
17.1 --- a/Server/Settings.cs Mon Aug 22 13:20:54 2016 +0200
17.2 +++ b/Server/Settings.cs Thu Aug 25 00:42:09 2016 +0200
17.3 @@ -18,6 +18,7 @@
17.4 //
17.5
17.6 using System;
17.7 +using System.Diagnostics;
17.8
17.9 namespace SharpDisplayManager.Properties {
17.10
17.11 @@ -43,23 +44,23 @@
17.12
17.13 private void PropertyChangedEventHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e)
17.14 {
17.15 - Console.WriteLine($"Settings: property changed {e.PropertyName}");
17.16 + Trace.WriteLine($"Settings: property changed {e.PropertyName}");
17.17 Default.Save();
17.18 }
17.19
17.20 private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
17.21 // Add code to handle the SettingChangingEvent event here.
17.22 - Console.WriteLine($"Settings: changing {e.SettingKey}.{e.SettingName}");
17.23 + Trace.WriteLine($"Settings: changing {e.SettingKey}.{e.SettingName}");
17.24 }
17.25
17.26 private void SettingsLoadedEventHandler(object sender, System.Configuration.SettingsLoadedEventArgs e)
17.27 {
17.28 - Console.WriteLine($"Settings: loaded {e.Provider.ApplicationName}");
17.29 + Trace.WriteLine($"Settings: loaded {e.Provider.ApplicationName}");
17.30 }
17.31
17.32 private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
17.33 // Add code to handle the SettingsSaving event here.
17.34 - Console.WriteLine("Settings: saving");
17.35 + Trace.WriteLine("Settings: saving");
17.36 }
17.37 }
17.38 }
18.1 --- a/Server/SharpDisplayManager.csproj Mon Aug 22 13:20:54 2016 +0200
18.2 +++ b/Server/SharpDisplayManager.csproj Thu Aug 25 00:42:09 2016 +0200
18.3 @@ -34,7 +34,7 @@
18.4 <WebPage>index.htm</WebPage>
18.5 <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
18.6 <ApplicationRevision>0</ApplicationRevision>
18.7 - <ApplicationVersion>0.12.2.0</ApplicationVersion>
18.8 + <ApplicationVersion>1.0.0.0</ApplicationVersion>
18.9 <UseApplicationTrust>false</UseApplicationTrust>
18.10 <CreateDesktopShortcut>true</CreateDesktopShortcut>
18.11 <PublishWizardCompleted>true</PublishWizardCompleted>
18.12 @@ -112,7 +112,7 @@
18.13 <Private>True</Private>
18.14 </Reference>
18.15 <Reference Include="HarmonyHub, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
18.16 - <HintPath>..\packages\SharpLibHarmony.0.3.0\lib\net451\HarmonyHub.dll</HintPath>
18.17 + <HintPath>..\packages\SharpLibHarmony.0.4.0\lib\net451\HarmonyHub.dll</HintPath>
18.18 <Private>True</Private>
18.19 </Reference>
18.20 <Reference Include="LibCecSharp, Version=2.2.0.0, Culture=neutral, processorArchitecture=x86">
18.21 @@ -219,7 +219,7 @@
18.22 <DependentUpon>ProgressForm.cs</DependentUpon>
18.23 </Compile>
18.24 <Compile Include="Properties\AssemblyInfo.cs" />
18.25 - <Compile Include="RichTextBoxTextWriter.cs" />
18.26 + <Compile Include="RichTextBoxTraceListener.cs" />
18.27 <Compile Include="Session.cs" />
18.28 <Compile Include="Settings.cs" />
18.29 <Compile Include="StartupManager.cs" />
19.1 --- a/Server/packages.config Mon Aug 22 13:20:54 2016 +0200
19.2 +++ b/Server/packages.config Thu Aug 25 00:42:09 2016 +0200
19.3 @@ -4,7 +4,7 @@
19.4 <package id="Loamen.agsXMPP" version="1.3.1" targetFramework="net46" />
19.5 <package id="NAudio" version="1.7.3" targetFramework="net45" />
19.6 <package id="SharpLibDisplay" version="0.2.5" targetFramework="net46" />
19.7 - <package id="SharpLibHarmony" version="0.3.0" targetFramework="net46" />
19.8 + <package id="SharpLibHarmony" version="0.4.0" targetFramework="net46" />
19.9 <package id="SharpLibHid" version="1.4.2" targetFramework="net46" />
19.10 <package id="SharpLibNotification" version="0.0.1" targetFramework="net46" />
19.11 <package id="SharpLibWin32" version="0.0.9" targetFramework="net46" />
20.1 --- a/SharpLibEar/Action.cs Mon Aug 22 13:20:54 2016 +0200
20.2 +++ b/SharpLibEar/Action.cs Thu Aug 25 00:42:09 2016 +0200
20.3 @@ -3,6 +3,7 @@
20.4
20.5 using System;
20.6 using System.Collections.Generic;
20.7 +using System.Diagnostics;
20.8 using System.Runtime.Serialization;
20.9 using System.Threading;
20.10
20.11 @@ -18,16 +19,16 @@
20.12 /// </summary>
20.13 public void Test()
20.14 {
20.15 - Console.WriteLine("Action test");
20.16 + Trace.WriteLine("Action test");
20.17 Execute();
20.18 }
20.19
20.20 public void Execute()
20.21 {
20.22 - Console.WriteLine("Action executing: " + Brief());
20.23 + Trace.WriteLine("Action executing: " + Brief());
20.24 if (!IsValid())
20.25 {
20.26 - Console.WriteLine($"WARNING: action invalid, aborting execution.");
20.27 + Trace.WriteLine($"WARNING: action invalid, aborting execution.");
20.28 return;
20.29 }
20.30
21.1 --- a/SharpLibEar/Event.cs Mon Aug 22 13:20:54 2016 +0200
21.2 +++ b/SharpLibEar/Event.cs Thu Aug 25 00:42:09 2016 +0200
21.3 @@ -3,6 +3,7 @@
21.4
21.5 using System;
21.6 using System.Collections.Generic;
21.7 +using System.Diagnostics;
21.8 using System.Runtime.Serialization;
21.9
21.10 namespace SharpLib.Ear
21.11 @@ -42,14 +43,14 @@
21.12 /// </summary>
21.13 public void Test()
21.14 {
21.15 - Console.WriteLine("Event test");
21.16 + Trace.WriteLine("Event test");
21.17 Trigger();
21.18 }
21.19
21.20
21.21 public void Trigger()
21.22 {
21.23 - Console.WriteLine("Event triggered: " + Name);
21.24 + Trace.WriteLine("Event triggered: " + Name);
21.25 foreach (Action action in Actions)
21.26 {
21.27 action.Execute();
22.1 --- a/SharpLibUtils/TypeConverterJson.cs Mon Aug 22 13:20:54 2016 +0200
22.2 +++ b/SharpLibUtils/TypeConverterJson.cs Thu Aug 25 00:42:09 2016 +0200
22.3 @@ -60,7 +60,7 @@
22.4 //catch (Exception ex)
22.5 //{
22.6 //That's not helping with partial loading
22.7 - // Console.WriteLine("WARNING: Internalize exception -" + ex.ToString() );
22.8 + // Trace.WriteLine("WARNING: Internalize exception -" + ex.ToString() );
22.9 // return null;
22.10 //}
22.11 }