private bool restartIRApp = false; // Restart Haupp. IR-app. after MP quit /// <summary> /// Initialization /// </summary> public HcwHelper() { InitializeComponent(); using (Settings xmlreader = new MPSettings()) { logVerbose = xmlreader.GetValueAsBool("remote", "HCWVerboseLog", false); port = xmlreader.GetValueAsInt("remote", "HCWHelperPort", 2110); hcwEnabled = xmlreader.GetValueAsBool("remote", "HCW", false); } connection = new Connection(logVerbose); if (hcwEnabled && (GetDllPath() != string.Empty) && connection.Start(port) && irremote.IRSetDllDirectory(GetDllPath())) { Thread checkThread = new Thread(new ThreadStart(CheckThread)); checkThread.IsBackground = true; checkThread.Priority = ThreadPriority.Highest; checkThread.Name = "HcwHelperChecker"; checkThread.Start(); connection.ReceiveEvent += new Connection.ReceiveEventHandler(OnReceive); StartIR(); } else { connection.Send(port + 1, "APP", "STOP", DateTime.Now); Application.Exit(); } }
public void Start() { Connection connection = new Connection(true); Assert.IsTrue(connection.Start(udpPort + 1)); connection.Stop(); }
public void SendMessage() { Connection connection = new Connection(true); Assert.IsTrue(connection.Send(udpPort, "CMD", "0", DateTime.Now)); }
/// <summary> /// DeInit all /// </summary> public void DeInit() { if (_controlEnabled) { _exit = true; if (_allowExternal) { Util.Utils.OnStartExternal -= new Util.Utils.UtilEventHandler(OnStartExternal); Util.Utils.OnStopExternal -= new Util.Utils.UtilEventHandler(OnStopExternal); } _connection.ReceiveEvent -= new Connection.ReceiveEventHandler(OnReceive); _connection.Send(_port, "APP", "SHUTDOWN", DateTime.Now); _connection.Stop(); _connection = null; } }
/// <summary> /// Stop IR.exe and initiate HCW start /// </summary> public void Init() { _exit = false; using (Settings xmlreader = new MPSettings()) { _controlEnabled = xmlreader.GetValueAsBool("remote", "HCW", false); _allowExternal = xmlreader.GetValueAsBool("remote", "HCWAllowExternal", false); _keepControl = xmlreader.GetValueAsBool("remote", "HCWKeepControl", false); _logVerbose = xmlreader.GetValueAsBool("remote", "HCWVerboseLog", false); _buttonRelease = TimeSpan.FromMilliseconds(xmlreader.GetValueAsInt("remote", "HCWButtonRelease", 200)); _repeatFilter = xmlreader.GetValueAsInt("remote", "HCWRepeatFilter", 2); _repeatSpeed = xmlreader.GetValueAsInt("remote", "HCWRepeatSpeed", 0); _filterDoubleKlicks = xmlreader.GetValueAsBool("remote", "HCWFilterDoubleKlicks", false); _port = xmlreader.GetValueAsInt("remote", "HCWHelperPort", 2110); } if (_controlEnabled) { string exePath = irremote.GetHCWPath(); string dllPath = irremote.GetDllPath(); bool hcwDriverUpToDate = true; if (File.Exists(exePath + "Ir.exe")) { FileVersionInfo exeVersionInfo = FileVersionInfo.GetVersionInfo(exePath + "Ir.exe"); if (exeVersionInfo.FileVersion.CompareTo(irremote.CurrentVersion) < 0) { hcwDriverUpToDate = false; } } if (File.Exists(dllPath + "irremote.DLL")) { FileVersionInfo dllVersionInfo = FileVersionInfo.GetVersionInfo(dllPath + "irremote.DLL"); if (dllVersionInfo.FileVersion.CompareTo(irremote.CurrentVersion) < 0) { hcwDriverUpToDate = false; } } if (!hcwDriverUpToDate) { Log.Info("HCW: =============================================================================================="); Log.Info("HCW: Your remote control driver components are not up to date! To avoid problems, you should"); Log.Info("HCW: get the latest Hauppauge drivers here: http://www.hauppauge.co.uk/board/showthread.php?p=25253"); Log.Info("HCW: =============================================================================================="); } _inputHandler = new InputHandler("Hauppauge HCW"); if (!_inputHandler.IsLoaded) { _controlEnabled = false; Log.Info("HCW: Error loading default mapping file - please reinstall MediaPortal"); } } if (_controlEnabled) { _connection = new Connection(_logVerbose); _connection.Start(_port + 1); _connection.ReceiveEvent += new Connection.ReceiveEventHandler(OnReceive); Process process = Process.GetCurrentProcess(); Log.Info("Process: {0}", process.ProcessName); Process procHelper = new Process(); procHelper.StartInfo.FileName = string.Format("{0}\\HcwHelper.exe", Application.StartupPath); procHelper.Start(); if (_allowExternal) { Log.Info("HCW: AllowExternal"); Util.Utils.OnStartExternal += new Util.Utils.UtilEventHandler(OnStartExternal); Util.Utils.OnStopExternal += new Util.Utils.UtilEventHandler(OnStopExternal); } Thread checkThread = new Thread(new ThreadStart(CheckThread)); checkThread.IsBackground = true; checkThread.Name = "HcwHelperCheck"; checkThread.Priority = ThreadPriority.AboveNormal; checkThread.Start(); } }
/// <summary> /// Let's get out of here /// </summary> private void Exit() { if (logVerbose) { Log.Info("HCWHelper: OnClosing"); } connection.ReceiveEvent -= new Connection.ReceiveEventHandler(OnReceive); connection.Send(port + 1, "APP", "STOP", DateTime.Now); connection = null; StopIR(); Application.Exit(); }