From: <an...@us...> - 2007-09-12 12:28:36
|
Revision: 916 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=916&view=rev Author: and-81 Date: 2007-09-12 05:28:29 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs trunk/plugins/IR Server Suite/Applications/Translator/Program.cs trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs trunk/plugins/IR Server Suite/Applications/Virtual Remote/Program.cs trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs trunk/plugins/IR Server Suite/IPC/Named Pipes/PipeMessage.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs trunk/plugins/IR Server Suite/IR Server Suite.sln trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -349,7 +349,6 @@ this.buttonIRBlastAutoTest.Text = "IRBlast Auto-Test"; this.toolTips.SetToolTip(this.buttonIRBlastAutoTest, "Runs a random number blasting test"); this.buttonIRBlastAutoTest.UseVisualStyleBackColor = true; - this.buttonIRBlastAutoTest.Visible = false; this.buttonIRBlastAutoTest.Click += new System.EventHandler(this.buttonAutoTest_Click); // // buttonHelp Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -163,7 +163,7 @@ { PipeMessage received = PipeMessage.FromString(message); - this.Invoke(_AddStatusLine, new Object[] { String.Format("Received Message: \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)) }); + this.Invoke(_AddStatusLine, new Object[] { String.Format("Received Message: \"{0}, {1}\"", received.Type, received.Flags) }); try { Modified: trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -441,7 +441,7 @@ { PipeMessage received = PipeMessage.FromString(message); - IrssLog.Debug("Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + IrssLog.Debug("Received Message \"{0}\"", received.Type); try { @@ -500,7 +500,7 @@ file.Read(outData, 4 + port.Length, (int)file.Length); file.Close(); - PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.BlastIR, PipeMessageFlags.Request, outData); + PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.BlastIR, PipeMessageFlags.Request | PipeMessageFlags.ForceNotRespond, outData); PipeAccess.SendMessage(Common.ServerPipeName, _serverHost, message); } Modified: trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -403,7 +403,7 @@ { PipeMessage received = PipeMessage.FromString(message); - IrssLog.Debug("Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + IrssLog.Debug("Received Message \"{0}\"", received.Type); try { @@ -462,7 +462,7 @@ file.Read(outData, 4 + port.Length, (int)file.Length); file.Close(); - PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.BlastIR, PipeMessageFlags.Request, outData); + PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.BlastIR, PipeMessageFlags.Request | PipeMessageFlags.ForceNotRespond, outData); PipeAccess.SendMessage(Common.ServerPipeName, _serverHost, message); } Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -257,7 +257,7 @@ if (_mode == IRServerMode.ServerMode) { - PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.ServerShutdown, PipeMessageFlags.Request); + PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.ServerShutdown, PipeMessageFlags.Notify); SendToAll(message); } @@ -498,7 +498,7 @@ } while (retry); - PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.RegisterRepeater); + PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.RegisterRepeater, PipeMessageFlags.Request); PipeAccess.SendMessage(Common.ServerPipeName, _hostComputer, message); } catch (Exception ex) @@ -517,7 +517,7 @@ { _registered = false; - PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.UnregisterRepeater); + PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.UnregisterRepeater, PipeMessageFlags.Request); PipeAccess.SendMessage(Common.ServerPipeName, _hostComputer, message); } } @@ -541,14 +541,14 @@ { case IRServerMode.ServerMode: { - PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.RemoteEvent, PipeMessageFlags.None, bytes); + PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.RemoteEvent, PipeMessageFlags.Notify, bytes); SendToAll(message); break; } case IRServerMode.RelayMode: { - PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.ForwardRemoteEvent, PipeMessageFlags.None, bytes); + PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.ForwardRemoteEvent, PipeMessageFlags.Request, bytes); SendTo(Common.ServerPipeName, _hostComputer, message); break; } @@ -573,14 +573,14 @@ { case IRServerMode.ServerMode: { - PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.KeyboardEvent, PipeMessageFlags.None, bytes); + PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.KeyboardEvent, PipeMessageFlags.Notify, bytes); SendToAll(message); break; } case IRServerMode.RelayMode: { - PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.ForwardKeyboardEvent, PipeMessageFlags.None, bytes); + PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.ForwardKeyboardEvent, PipeMessageFlags.Request, bytes); SendTo(Common.ServerPipeName, _hostComputer, message); break; } @@ -606,14 +606,14 @@ { case IRServerMode.ServerMode: { - PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.MouseEvent, PipeMessageFlags.None, bytes); + PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.MouseEvent, PipeMessageFlags.Notify, bytes); SendToAll(message); break; } case IRServerMode.RelayMode: { - PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.ForwardMouseEvent, PipeMessageFlags.None, bytes); + PipeMessage message = new PipeMessage(Environment.MachineName, _localPipeName, PipeMessageType.ForwardMouseEvent, PipeMessageFlags.Request, bytes); SendTo(Common.ServerPipeName, _hostComputer, message); break; } @@ -657,7 +657,7 @@ // Inform clients ... if (_mode == IRServerMode.ServerMode) { - PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.ServerShutdown); + PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.ServerShutdown, PipeMessageFlags.Notify); SendToAll(message); } break; @@ -935,23 +935,30 @@ return false; } } - byte[] LearnIR() + LearnStatus LearnIR(out byte[] data) { IrssLog.Debug("Learn IR"); - if (_pluginTransmit == null || !(_pluginTransmit is ILearnIR)) + data = null; + + if (_pluginTransmit == null) { - IrssLog.Debug("Active transceiver doesn't support learn"); - return null; + IrssLog.Debug("No transmit plugin loaded, can't learn"); + return LearnStatus.Failure; } + else if (!(_pluginTransmit is ILearnIR)) + { + IrssLog.Debug("Active transmit plugin doesn't support learn"); + return LearnStatus.Failure; + } - Thread.Sleep(500); + Thread.Sleep(250); - byte[] data = null; + LearnStatus status = LearnStatus.Failure; try { - LearnStatus status = (_pluginTransmit as ILearnIR).Learn(out data); + status = (_pluginTransmit as ILearnIR).Learn(out data); switch (status) { case LearnStatus.Success: @@ -972,7 +979,7 @@ IrssLog.Error(ex.ToString()); } - return data; + return status; } void HandlePipeMessage(PipeMessage received) @@ -984,49 +991,43 @@ switch (received.Type) { case PipeMessageType.ForwardRemoteEvent: - { - PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.RemoteEvent, PipeMessageFlags.None, received.DataAsBytes); if (_mode == IRServerMode.RelayMode) { - forward.Type = received.Type; + PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.ForwardRemoteEvent, PipeMessageFlags.Request, received.DataAsBytes); SendTo(Common.ServerPipeName, _hostComputer, forward); } else { + PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.RemoteEvent, PipeMessageFlags.Notify, received.DataAsBytes); SendToAllExcept(received.FromPipe, received.FromServer, forward); } break; - } case PipeMessageType.ForwardKeyboardEvent: - { - PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.KeyboardEvent, PipeMessageFlags.None, received.DataAsBytes); if (_mode == IRServerMode.RelayMode) { - forward.Type = received.Type; + PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.ForwardKeyboardEvent, PipeMessageFlags.Request, received.DataAsBytes); SendTo(Common.ServerPipeName, _hostComputer, forward); } else { + PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.KeyboardEvent, PipeMessageFlags.Notify, received.DataAsBytes); SendToAllExcept(received.FromPipe, received.FromServer, forward); } break; - } case PipeMessageType.ForwardMouseEvent: - { - PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.MouseEvent, PipeMessageFlags.None, received.DataAsBytes); if (_mode == IRServerMode.RelayMode) { - forward.Type = received.Type; + PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.ForwardMouseEvent, PipeMessageFlags.Request, received.DataAsBytes); SendTo(Common.ServerPipeName, _hostComputer, forward); } else { + PipeMessage forward = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.MouseEvent, PipeMessageFlags.Notify, received.DataAsBytes); SendToAllExcept(received.FromPipe, received.FromServer, forward); } break; - } case PipeMessageType.BlastIR: { @@ -1047,7 +1048,9 @@ response.Flags |= PipeMessageFlags.Failure; } - SendTo(received.FromPipe, received.FromServer, response); + if ((received.Flags & PipeMessageFlags.ForceNotRespond) != PipeMessageFlags.ForceNotRespond) + SendTo(received.FromPipe, received.FromServer, response); + break; } @@ -1061,12 +1064,25 @@ } else { - byte[] bytes = LearnIR(); + byte[] bytes = null; - if (bytes == null) - response.Flags |= PipeMessageFlags.Failure; - else - response.Flags |= PipeMessageFlags.Success; + LearnStatus status = LearnIR(out bytes); + + switch (status) + { + case LearnStatus.Success: + response.Flags |= PipeMessageFlags.Success; + response.DataAsBytes = bytes; + break; + + case LearnStatus.Failure: + response.Flags |= PipeMessageFlags.Failure; + break; + + case LearnStatus.Timeout: + response.Flags |= PipeMessageFlags.Timeout; + break; + } } SendTo(received.FromPipe, received.FromServer, response); @@ -1076,14 +1092,21 @@ case PipeMessageType.ServerShutdown: if (_mode == IRServerMode.ServerMode) { - IrssLog.Info("Shutdown command received"); - Stop(); - Application.Exit(); + if ((received.Flags & PipeMessageFlags.Request) == PipeMessageFlags.Request) + { + IrssLog.Info("Shutdown command received"); + Stop(); + Application.Exit(); + } } else { - IrssLog.Warn("Host server has shut down"); - _registered = false; + if ((received.Flags & PipeMessageFlags.Notify) == PipeMessageFlags.Notify) + { + + IrssLog.Warn("Host server has shut down"); + _registered = false; + } } break; @@ -1095,47 +1118,50 @@ } case PipeMessageType.RegisterClient: - if ((received.Flags & PipeMessageFlags.Response) == PipeMessageFlags.Response) + if (_mode == IRServerMode.ServerMode) { - if ((received.Flags & PipeMessageFlags.Success) == PipeMessageFlags.Success) + if ((received.Flags & PipeMessageFlags.Request) == PipeMessageFlags.Request) { - IrssLog.Info("Registered with host server"); - _registered = true; - } - else - { - IrssLog.Warn("Host server refused registration"); - _registered = false; - } - } - else if ((received.Flags & PipeMessageFlags.Request) == PipeMessageFlags.Request) - { - PipeMessage response = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.RegisterClient, PipeMessageFlags.Response); + PipeMessage response = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.RegisterClient, PipeMessageFlags.Response); - if (RegisterClient(received.FromPipe, received.FromServer)) - { - IRServerInfo irServerInfo = new IRServerInfo(); + if (RegisterClient(received.FromPipe, received.FromServer)) + { + IRServerInfo irServerInfo = new IRServerInfo(); - if (_pluginReceive != null) - irServerInfo.CanReceive = true; + if (_pluginReceive != null) + irServerInfo.CanReceive = true; - if (_pluginTransmit != null) + if (_pluginTransmit != null) + { + irServerInfo.CanLearn = (_pluginTransmit is ILearnIR); + irServerInfo.CanTransmit = true; + irServerInfo.Ports = (_pluginTransmit as ITransmitIR).AvailablePorts; + } + + response.DataAsBytes = irServerInfo.ToBytes(); + response.Flags |= PipeMessageFlags.Success; + } + else { - irServerInfo.CanLearn = (_pluginTransmit is ILearnIR); - irServerInfo.CanTransmit = true; - irServerInfo.Ports = (_pluginTransmit as ITransmitIR).AvailablePorts; + response.Flags |= PipeMessageFlags.Failure; } - response.DataAsBytes = irServerInfo.ToBytes(); - response.Flags |= PipeMessageFlags.Success; + SendTo(received.FromPipe, received.FromServer, response); } + } + else if ((received.Flags & PipeMessageFlags.Response) == PipeMessageFlags.Response) + { + if ((received.Flags & PipeMessageFlags.Success) == PipeMessageFlags.Success) + { + IrssLog.Info("Registered with host server"); + _registered = true; + } else { - response.Flags |= PipeMessageFlags.Failure; + IrssLog.Warn("Host server refused registration"); + _registered = false; } - - SendTo(received.FromPipe, received.FromServer, response); - } + } break; case PipeMessageType.UnregisterClient: @@ -1163,7 +1189,7 @@ catch (Exception ex) { IrssLog.Error(ex.ToString()); - PipeMessage response = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.Error, PipeMessageFlags.None, ex.Message); + PipeMessage response = new PipeMessage(Common.ServerPipeName, Environment.MachineName, PipeMessageType.Error, PipeMessageFlags.Notify, ex.Message); SendTo(received.FromPipe, received.FromServer, response); } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -906,7 +906,7 @@ { PipeMessage received = PipeMessage.FromString(message); - IrssLog.Debug("Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + IrssLog.Debug("Received Message \"{0}\"", received.Type); try { Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -409,7 +409,7 @@ { PipeMessage received = PipeMessage.FromString(message); - IrssLog.Debug("Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + IrssLog.Debug("Received Message \"{0}\"", received.Type); try { Modified: trunk/plugins/IR Server Suite/Applications/Virtual Remote/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Virtual Remote/Program.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/Virtual Remote/Program.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -471,7 +471,7 @@ { PipeMessage received = PipeMessage.FromString(message); - IrssLog.Debug("Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + IrssLog.Debug("Received Message \"{0}\"", received.Type); try { Modified: trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/Applications/Virtual Remote Skin Editor/MainForm.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -528,7 +528,7 @@ { PipeMessage received = PipeMessage.FromString(message); - IrssLog.Debug("Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + IrssLog.Debug("Received Message \"{0}\"", received.Type); try { Modified: trunk/plugins/IR Server Suite/IPC/Named Pipes/PipeMessage.cs =================================================================== --- trunk/plugins/IR Server Suite/IPC/Named Pipes/PipeMessage.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IPC/Named Pipes/PipeMessage.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -43,18 +43,18 @@ Request = 0x0001, Response = 0x0002, - //Notify = 0x0004, + Notify = 0x0004, Success = 0x0008, Failure = 0x0010, Timeout = 0x0020, - Error = 0x0040, + //Error = 0x0040, //DataString = 0x0080, //DataBytes = 0x0100, //ForceRespond = 0x0200, - //ForceNotRespond = 0x0400, + ForceNotRespond = 0x0400, } #endregion Enumerations @@ -182,10 +182,9 @@ if (_data != null && _data.Length != 0) data = ByteArrayToByteString(_data); - string messageType = Enum.GetName(typeof(PipeMessageType), _type); + string messageType = ((int)_type).ToString(); + string flags = ((int)_flags).ToString(); - string flags = _flags.ToString(); - return String.Format( "{0},{1},{2},{3},{4}", _fromServer, @@ -213,8 +212,8 @@ if (stringItems.Length != 5) return null; - PipeMessageType type = (PipeMessageType)Enum.Parse(typeof(PipeMessageType), stringItems[2]); - PipeMessageFlags flags = (PipeMessageFlags)Enum.Parse(typeof(PipeMessageFlags), stringItems[3]); + PipeMessageType type = (PipeMessageType)int.Parse(stringItems[2]); + PipeMessageFlags flags = (PipeMessageFlags)int.Parse(stringItems[3]); if (String.IsNullOrEmpty(stringItems[4])) { Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Driver.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -8,6 +8,8 @@ using Microsoft.Win32.SafeHandles; +using IRServerPluginInterface; + namespace MicrosoftMceTransceiver { @@ -212,13 +214,14 @@ /// Stop access to the device. /// </summary> public abstract void Stop(); - // TODO: Change learn interface to return LearnStatus + /// <summary> /// Learn an IR Command. /// </summary> /// <param name="learnTimeout">How long to wait before aborting learn.</param> - /// <returns>Newly learned IR Command.</returns> - public abstract IrCode Learn(int learnTimeout); + /// <param name="learned">Newly learned IR Command.</param> + /// <returns>Learn status.</returns> + public abstract LearnStatus Learn(int learnTimeout, out IrCode learned); /// <summary> /// Send an IR Command. Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverReplacement.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -9,6 +9,8 @@ using Microsoft.Win32.SafeHandles; +using IRServerPluginInterface; + namespace MicrosoftMceTransceiver { @@ -222,10 +224,11 @@ //_debugFile.Close(); } - public override IrCode Learn(int learnTimeout) + public override LearnStatus Learn(int learnTimeout, out IrCode learned) { //_debugFile.WriteLine("Start Learn"); + learned = null; _learningCode = new IrCode(); SetInputPort(InputPort.Learning); @@ -244,27 +247,31 @@ _readThreadMode = ReadThreadMode.Receiving; SetInputPort(InputPort.Receive); + LearnStatus status = LearnStatus.Failure; + switch (modeWas) { case ReadThreadMode.Learning: - // Timeout. - return null; + status = LearnStatus.Timeout; + break; case ReadThreadMode.LearningFailed: - // Failure. - return null; + status = LearnStatus.Failure; + break; case ReadThreadMode.LearningDone: //_debugFile.WriteLine(_learningCode.ToByteArray()); if (_learningCode.FinalizeData()) - return _learningCode; // Success. - else - return null; // Failure. + { + learned = _learningCode; + status = LearnStatus.Success; + } + break; + } - default: - return null; - } + _learningCode = null; + return status; } public override void Send(IrCode code, uint port) Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverVista.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -9,6 +9,8 @@ using Microsoft.Win32.SafeHandles; +using IRServerPluginInterface; + namespace MicrosoftMceTransceiver { @@ -537,12 +539,13 @@ //_debugFile.Close(); } - public override IrCode Learn(int learnTimeout) + public override LearnStatus Learn(int learnTimeout, out IrCode learned) { //_debugFile.WriteLine("Learn"); StopReadThread(); + learned = null; _learningCode = new IrCode(); StartReceive(_learnPort, PacketTimeout); @@ -569,29 +572,33 @@ StartReadThread(); + LearnStatus status = LearnStatus.Failure; + switch (modeWas) { case ReadThreadMode.Learning: - // Timeout. - return null; + status = LearnStatus.Timeout; + break; case ReadThreadMode.LearningFailed: - // Failure. - return null; + status = LearnStatus.Failure; + break; case ReadThreadMode.LearningDone: //_debugFile.WriteLine(_learningCode.ToByteArray()); if (_learningCode.FinalizeData()) - return _learningCode; // Success. - else - return null; // Failure. - - default: - return null; + { + learned = _learningCode; + status = LearnStatus.Success; + } + break; } + + _learningCode = null; + return status; } - + public override void Send(IrCode code, uint port) { byte[] data = DataPacket(code); Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/DriverXP.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -9,6 +9,8 @@ using Microsoft.Win32.SafeHandles; +using IRServerPluginInterface; + namespace MicrosoftMceTransceiver { @@ -216,10 +218,11 @@ //_debugFile.Close(); } - public override IrCode Learn(int learnTimeout) + public override LearnStatus Learn(int learnTimeout, out IrCode learned) { //_debugFile.WriteLine("Start Learn"); + learned = null; _learningCode = new IrCode(); SetInputPort(InputPort.Learning); @@ -238,27 +241,31 @@ _readThreadMode = ReadThreadMode.Receiving; SetInputPort(InputPort.Receive); + LearnStatus status = LearnStatus.Failure; + switch (modeWas) { case ReadThreadMode.Learning: - // Timeout. - return null; + status = LearnStatus.Timeout; + break; case ReadThreadMode.LearningFailed: - // Failure. - return null; + status = LearnStatus.Failure; + break; case ReadThreadMode.LearningDone: //_debugFile.WriteLine(_learningCode.ToByteArray()); if (_learningCode.FinalizeData()) - return _learningCode; // Success. - else - return null; // Failure. + { + learned = _learningCode; + status = LearnStatus.Success; + } + break; + } - default: - return null; - } + _learningCode = null; + return status; } public override void Send(IrCode code, uint port) Modified: trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/MicrosoftMceTransceiver.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -245,18 +245,16 @@ } public LearnStatus Learn(out byte[] data) { - IrCode code = _driver.Learn(_learnTimeout); + IrCode code = null; + LearnStatus status = _driver.Learn(_learnTimeout, out code); + if (code != null) - { data = code.ToByteArray(); - return LearnStatus.Success; - } else - { data = null; - return LearnStatus.Failure; - } + + return status; } void LoadSettings() Modified: trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IR Server Plugins/USB-UIRT Transceiver/UirtTransceiver.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -86,13 +86,14 @@ static extern bool UUIRTLearnIR( IntPtr hHandle, int codeFormat, - [MarshalAs(UnmanagedType.LPStr)] StringBuilder ircode, + //[MarshalAs(UnmanagedType.LPStr)] + StringBuilder ircode, IRLearnCallbackDelegate progressProc, - int userData, - ref int pAbort, + IntPtr userData, + IntPtr abort, int param1, - [MarshalAs(UnmanagedType.AsAny)] Object o, - [MarshalAs(UnmanagedType.AsAny)] Object oo); + IntPtr reserved1, + IntPtr reserved2); [DllImport("uuirtdrv.dll")] [return: MarshalAs(UnmanagedType.Bool)] @@ -132,7 +133,7 @@ static readonly string[] Ports = new string[] { "Default", "Port 1", "Port 2", "Port 3" }; - const int AbortLearn = -1; + const int AbortLearn = 1; const int AllowLearn = 0; #endregion Constants @@ -147,14 +148,12 @@ int _blastRepeats; int _learnTimeout; - //ulong _learnCarrierFreq; - string _lastCode = String.Empty; DateTime _lastCodeTime = DateTime.Now; // ------- - int _abortLearn = AllowLearn; + IntPtr _abortLearn = IntPtr.Zero; bool _learnTimedOut; UUIRTReceiveCallbackDelegate _receiveCallback = null; bool _isUsbUirtLoaded = false; @@ -236,7 +235,11 @@ } public override void Stop() { - UUIRTClose(_usbUirtHandle); + if (_abortLearn != IntPtr.Zero) + Marshal.WriteInt32(_abortLearn, AbortLearn); + + if (_usbUirtHandle != new IntPtr(-1)) + UUIRTClose(_usbUirtHandle); _usbUirtHandle = IntPtr.Zero; _isUsbUirtLoaded = false; @@ -303,35 +306,34 @@ data = null; - StringBuilder irCode = new StringBuilder("1", 2048); - _abortLearn = AllowLearn; + StringBuilder irCode = new StringBuilder(4096); _learnTimedOut = false; - //_learnCarrierFreq = 0; - Timer timer = new Timer(); timer.Interval = _learnTimeout; timer.Tick += new EventHandler(timer_Tick); timer.Enabled = true; timer.Start(); - //IRLearnCallbackDelegate learnCallback = new IRLearnCallbackDelegate(UUIRTLearnCallback); - + _abortLearn = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int))); + Marshal.WriteInt32(_abortLearn, AllowLearn); + result = UirtTransceiver.UUIRTLearnIR( _usbUirtHandle, // Handle to USB-UIRT - UirtTransceiver.UUIRTDRV_IRFMT_PRONTO | UirtTransceiver.UUIRTDRV_IRFMT_LEARN_FREQDETECT, // | UirtTransceiver.UUIRTDRV_IRFMT_LEARN_FORCERAW + UirtTransceiver.UUIRTDRV_IRFMT_PRONTO, irCode, // Where to put the IR Code null, // Learn status callback - 0, // User data - ref _abortLearn, // Abort flag? + IntPtr.Zero, // User data + _abortLearn, // Abort flag? 0, - null, - null); + IntPtr.Zero, + IntPtr.Zero); + Marshal.FreeHGlobal(_abortLearn); + _abortLearn = IntPtr.Zero; + timer.Stop(); - //MessageBox.Show(_learnCarrierFreq.ToString()); - if (_learnTimedOut) { return LearnStatus.Timeout; @@ -364,7 +366,7 @@ Console.WriteLine(ex.ToString()); _repeatDelay = 500; - _blastRepeats = 4; + _blastRepeats = 3; _learnTimeout = 10000; } } @@ -425,7 +427,9 @@ */ void timer_Tick(object sender, EventArgs e) { - _abortLearn = AbortLearn; + if (_abortLearn != IntPtr.Zero) + Marshal.WriteInt32(_abortLearn, AbortLearn); + _learnTimedOut = true; ((Timer)sender).Stop(); Modified: trunk/plugins/IR Server Suite/IR Server Suite.sln =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite.sln 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/IR Server Suite.sln 2007-09-12 12:28:29 UTC (rev 916) @@ -247,6 +247,12 @@ Release.AspNetCompiler.Debug = "False" EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Named Pipes Tool", "Applications\NamedPipesTool\Named Pipes Tool.csproj", "{6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C}" + ProjectSection(WebsiteProperties) = preProject + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.Debug = "False" + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -534,6 +540,12 @@ {8ADDE1CB-2D23-4AB1-88B1-A241C60C16BA}.Release|Any CPU.Build.0 = Release|Any CPU {8ADDE1CB-2D23-4AB1-88B1-A241C60C16BA}.Release|x86.ActiveCfg = Release|x86 {8ADDE1CB-2D23-4AB1-88B1-A241C60C16BA}.Release|x86.Build.0 = Release|x86 + {6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C}.Debug|x86.ActiveCfg = Debug|Any CPU + {6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C}.Release|Any CPU.Build.0 = Release|Any CPU + {6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -550,6 +562,7 @@ {905131F8-F8AC-4A65-A722-37783902D7B8} = {0C209E91-5AD5-4662-AD0E-976A940D4806} {A533F58F-2402-47CF-A258-377A669DB56F} = {0C209E91-5AD5-4662-AD0E-976A940D4806} {B5E711A2-E6D0-4BEA-B66B-7A8B0BCA6A4D} = {0C209E91-5AD5-4662-AD0E-976A940D4806} + {6E7C6F27-DA95-4F2F-A97D-1EA8E1517A4C} = {0C209E91-5AD5-4662-AD0E-976A940D4806} {A4023992-CCD6-461E-8E14-219A496734C5} = {0D1620EE-01B9-43B5-9FAA-E983BD9EBDBD} {7C686499-7517-4338-8837-7E8617549D9A} = {0D1620EE-01B9-43B5-9FAA-E983BD9EBDBD} {BABC30EB-7D0F-4398-9FCB-E517EA8D2AA9} = {0D1620EE-01B9-43B5-9FAA-E983BD9EBDBD} Modified: trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs =================================================================== --- trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -557,7 +557,7 @@ PipeMessage received = PipeMessage.FromString(message); if (LogVerbose) - Log.Debug("MPBlastZonePlugin: Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + Log.Debug("MPBlastZonePlugin: Received Message \"{0}\"", received.Type); try { Modified: trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs =================================================================== --- trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -817,7 +817,7 @@ PipeMessage received = PipeMessage.FromString(message); if (LogVerbose) - Log.Debug("MPControlPlugin: Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + Log.Debug("MPControlPlugin: Received Message \"{0}\"", received.Type); try { Modified: trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs =================================================================== --- trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -152,7 +152,7 @@ public bool CanEnable() { return true; } public bool HasSetup() { return true; } - public string PluginName() { return "TV2 STB Blaster Plugin for IR Server"; } + public string PluginName() { return "TV2 Blaster Plugin for IR Server"; } public bool DefaultEnabled() { return true; } public int GetWindowId() { return 0; } public string Author() { return "and-81"; } @@ -430,7 +430,7 @@ PipeMessage received = PipeMessage.FromString(message); if (LogVerbose) - Log.Debug("TV2BlasterPlugin: Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + Log.Debug("TV2BlasterPlugin: Received Message \"{0}\"", received.Type); try { Modified: trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs =================================================================== --- trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs 2007-09-11 19:30:37 UTC (rev 915) +++ trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs 2007-09-12 12:28:29 UTC (rev 916) @@ -66,7 +66,7 @@ /// <summary> /// Returns the name of the plugin. /// </summary> - public string Name { get { return "TV3 STB Blaster Plugin for IR Server"; } } + public string Name { get { return "TV3 Blaster Plugin for IR Server"; } } /// <summary> /// Returns the version of the plugin. /// </summary> @@ -407,7 +407,7 @@ PipeMessage received = PipeMessage.FromString(message); if (LogVerbose) - Log.Debug("TV3BlasterPlugin: Received Message \"{0}\"", Enum.GetName(typeof(PipeMessageType), received.Type)); + Log.Debug("TV3BlasterPlugin: Received Message \"{0}\"", received.Type); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |