Ejemplo n.º 1
0
        public override void LoadSettings()
        {
            if (_serialPort != null && _serialPort.IsOpen)
            {
                _serialPort.Close();
            }

            using (Settings reader = new MPSettings())
            {
                DeviceModelName = reader.GetValueAsString("Auto3DPlugin", "EpsonModel", "Default");
                PortName        = reader.GetValueAsString("Auto3DPlugin", "EpsonPort", "None");
            }

            if (_serialPort != null)
            {
                _serialPort.PortName = PortName;

                try
                {
                    if (_serialPort.PortName != "None")
                    {
                        _serialPort.Open();
                    }
                }
                catch (Exception ex)
                {
                    Auto3DHelpers.ShowAuto3DMessage("Opening serial port failed: " + ex.Message, false, 0);
                    Log.Info("Auto3D: " + ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        private bool InternalSendCommand(String command)
        {
            if (UDAPnP.Protocol == UDAPnP.LGProtocol.LG2011 ||
                UDAPnP.Protocol == UDAPnP.LGProtocol.LG2012x)
            {
                if (!UDAPnP.HandleKeyInput(command))
                {
                    // if for some reason connection was lost, try to reconnect

                    if (!ConnectAndPair())
                    {
                        Auto3DHelpers.ShowAuto3DMessage("Connection to LG TV failed!", false, 0);
                        Log.Error("Auto3D: Connection to LG TV failed!");

                        return(false);
                    }

                    // second try to send the command

                    if (!UDAPnP.HandleKeyInput(command))
                    {
                        Log.Error("Auto3D: HandleKeyInput failed for command: " + command);
                        return(false);
                    }
                }
            }
            else // WebOS
            {
                WebOS.SendSpecialKey(command);
            }

            return(true);
        }
Ejemplo n.º 3
0
 private void buttonPingGenericDevice_Click(object sender, EventArgs e)
 {
     if (_device.IsOn())
     {
         Auto3DHelpers.ShowAuto3DMessage("Ping was returned. TV seems to be on.", false, 0);
     }
     else
     {
         Auto3DHelpers.ShowAuto3DMessage("Ping was not returned. TV seems to be off.", false, 0);
     }
 }
Ejemplo n.º 4
0
 static void internalStopGenericDevice()
 {
     try
     {
         _irToy.Close();
     }
     catch (Exception ex)
     {
         Auto3DHelpers.ShowAuto3DMessage("Could not close IrToy: " + ex.Message, false, 0);
         Log.Error("Auto3D: Could not close IrToy: " + ex.Message);
     }
 }
Ejemplo n.º 5
0
        protected string GetRequest(string url, string jsonString)
        {
            string result;

            try
            {
                Log.Debug("Auto3D: GetRequest to URL = \"" + url + "\"");

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

                request.Timeout     = 3000;
                request.ContentType = ContentType;
                request.Accept      = ContentType;
                request.Method      = "GET";

                if (!string.IsNullOrEmpty(jsonString))
                {
                    Log.Debug("Auto3D: JSON-String = \"" + jsonString + "\"");

                    using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                    {
                        streamWriter.Write(jsonString);
                        streamWriter.Flush();
                        streamWriter.Close();
                    }
                }

                Application.DoEvents();
                Thread.Sleep(50);

                using (var httpResponse = (HttpWebResponse)request.GetResponse())
                {
                    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    {
                        result = streamReader.ReadToEnd();
                        Log.Debug(result);
                    }
                }

                Application.DoEvents();
            }
            catch (Exception ex)
            {
                Log.Info("Auto3D: GetRequest: " + ex.Message);
                Auto3DHelpers.ShowAuto3DMessage("Request to TV could not be sent: " + ex.Message, false, 0);
                result = string.Empty;
            }

            return(result);
        }
Ejemplo n.º 6
0
        private bool InternalSendCommand(String command)
        {
            try
            {
                _serialPort.WriteLine(command);
            }
            catch (System.Exception ex)
            {
                Auto3DHelpers.ShowAuto3DMessage("Command to TV could not be sent: " + ex.Message, false, 0);
                Log.Error("Auto3D: Error sending command: " + ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            RemoteCommand rc = (RemoteCommand)comboBoxCommands.SelectedItem;

            try
            {
                _device.IrToy.Send(rc.IrCode);
                Log.Info("Auto3D: Code sent: " + rc.IrCode);
            }
            catch (Exception ex)
            {
                Auto3DHelpers.ShowAuto3DMessage("Sending code failed: " + ex.Message, false, 0);
                Log.Error("Auto3D: Sending code " + rc.IrCode + " failed: " + ex.Message);
            }
        }
Ejemplo n.º 8
0
 static void internalStartGenericDevice()
 {
     if (!string.IsNullOrEmpty(IrPortName) && IrPortName != "None" && !IsIrConnected())
     {
         try
         {
             _irToy.Connect(IrPortName);
             Log.Info("Auto3D: IrToy connected");
         }
         catch (Exception ex)
         {
             Auto3DHelpers.ShowAuto3DMessage("Could not connect to IrToy: " + ex.Message, false, 0);
             Log.Error("Auto3D: Could not connect to IrToy: " + ex.Message);
         }
     }
 }
Ejemplo n.º 9
0
        public override bool SendCommand(RemoteCommand rc)
        {
            try
            {
                IrToy.Send(rc.IrCode);
                Log.Info("Auto3D: Code sent: " + rc.IrCode);
            }
            catch (Exception ex)
            {
                Auto3DHelpers.ShowAuto3DMessage("Sending code failed: " + ex.Message, false, 0);
                Log.Error("Auto3D: Sending code " + rc.IrCode + " failed: " + ex.Message);

                return(false);
            }

            return(true);
        }
Ejemplo n.º 10
0
        protected bool PostRequest(string url, JointSpaceKey key)
        {
            try
            {
                Log.Debug("Auto3D: PostRequest to URL = \"" + url + "\"");

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

                request.Timeout     = 3000;
                request.ContentType = ContentType;
                request.Method      = "POST";

                var jsonString = JsonConvert.SerializeObject(key, Formatting.None);
                Log.Debug("Auto3D: JSON-String = \"" + jsonString + "\"");

                using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                {
                    streamWriter.Write(jsonString);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                Application.DoEvents();
                Thread.Sleep(50);

                using (var httpResponse = (HttpWebResponse)request.GetResponse())
                {
                    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    {
                        var result = streamReader.ReadToEnd();
                        Log.Debug(result);
                    }
                }

                Application.DoEvents();
            }
            catch (Exception ex)
            {
                Log.Info("Auto3D: PostRequest: " + ex.Message);
                Auto3DHelpers.ShowAuto3DMessage("Command to TV could not be sent: " + ex.Message, false, 0);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 11
0
        public override bool SendCommand(RemoteCommand rc)
        {
            try
            {
                Client.Open();
                Client.SetName("Auto3D");
                Client.SetPriority(0);
                Client.TriggerEventsByName(rc.Command);
                Client.Close();
                Log.Info("Auto3D: Trigger Event: " + rc.Command);
            }
            catch (Exception ex)
            {
                Auto3DHelpers.ShowAuto3DMessage("Sending code failed: " + ex.Message, false, 0);
                Log.Error("Auto3D: Sending code " + rc.IrCode + " failed: " + ex.Message);

                return(false);
            }

            return(true);
        }
Ejemplo n.º 12
0
        private void StartSerial()
        {
            if (_serialPort != null && _serialPort.IsOpen)
            {
                _serialPort.Close();
            }

            _serialPort               = new SerialPort(PortName, 9600, Parity.None, 8, StopBits.One);
            _serialPort.NewLine       = "\r";
            _serialPort.DataReceived += _serialPort_DataReceived;

            try
            {
                if (_serialPort.PortName != "None")
                {
                    _serialPort.Open();
                }
            }
            catch (Exception ex)
            {
                Auto3DHelpers.ShowAuto3DMessage("Opening serial port failed: " + ex.Message, false, 0);
                Log.Info("Auto3D: " + ex.Message);
            }
        }
Ejemplo n.º 13
0
        public bool SwitchFormat(VideoFormat fmtOld, VideoFormat fmtNew)
        {
            if (/*GUIGraphicsContext.IsFullScreenVideo &&*/ bShowMessageOnModeChange)
            {
                String format = "";

                switch (fmtNew)
                {
                case VideoFormat.Fmt2D:

                    switch (GUIGraphicsContext.Render3DMode)
                    {
                    case GUIGraphicsContext.eRender3DMode.None:
                    case GUIGraphicsContext.eRender3DMode.SideBySide:
                    case GUIGraphicsContext.eRender3DMode.TopAndBottom:

                        format = "2D";
                        break;

                    case GUIGraphicsContext.eRender3DMode.SideBySideTo2D:

                        format = "3D SBS -> 2D via MediaPortal";
                        break;

                    case GUIGraphicsContext.eRender3DMode.TopAndBottomTo2D:

                        format = "3D TAB -> 2D via MediaPortal";
                        break;
                    }
                    break;

                case VideoFormat.Fmt3DSBS:

                    format = "3D Side by Side";

                    if (GUIGraphicsContext.Switch3DSides)
                    {
                        format += " Reverse";
                    }
                    break;

                case VideoFormat.Fmt3DTAB:

                    format = "3D Top and Bottom";

                    if (GUIGraphicsContext.Switch3DSides)
                    {
                        format += " Reverse";
                    }
                    break;

                case VideoFormat.Fmt2D3D:

                    format = "2D -> 3D via TV";
                    break;
                }

                Auto3DHelpers.ShowAuto3DMessage("VideoFormat: " + format, true, 4);
            }

            Log.Info("Auto3D: Begin SwitchToFormat");

            try
            {
                switch (fmtNew)
                {
                case VideoFormat.Fmt3DSBS:

                    if (!SendCommandList(SelectedDeviceModel.RemoteCommandSequences.Commands2D3DSBS))
                    {
                        return(false);
                    }
                    break;

                case VideoFormat.Fmt3DTAB:

                    if (!SendCommandList(SelectedDeviceModel.RemoteCommandSequences.Commands2D3DTAB))
                    {
                        return(false);
                    }
                    break;

                case VideoFormat.Fmt2D3D:

                    if (!SendCommandList(SelectedDeviceModel.RemoteCommandSequences.Commands2D3D))
                    {
                        return(false);
                    }
                    break;

                case VideoFormat.Fmt2D:

                    switch (fmtOld)
                    {
                    case VideoFormat.Fmt3DSBS:

                        if (!SendCommandList(SelectedDeviceModel.RemoteCommandSequences.Commands3DSBS2D))
                        {
                            return(false);
                        }
                        break;

                    case VideoFormat.Fmt3DTAB:

                        if (!SendCommandList(SelectedDeviceModel.RemoteCommandSequences.Commands3DTAB2D))
                        {
                            return(false);
                        }
                        break;

                    case VideoFormat.Fmt2D3D:

                        if (!SendCommandList(SelectedDeviceModel.RemoteCommandSequences.Commands3D2D))
                        {
                            return(false);
                        }
                        break;
                    }

                    break;
                }

                if (bSendEventGhostEvents)
                {
                    SendEventGhostEvent(fmtNew);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.Info("Auto3D: " + ex.Message);
                return(false);
            }
            finally
            {
                Log.Info("Auto3D: End SwitchToFormat");
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aNewVideoFormat"></param>
        public void DisplayFormatChangeMessage(VideoFormat aNewVideoFormat)
        {
            if (/*GUIGraphicsContext.IsFullScreenVideo &&*/ bShowMessageOnModeChange)
            {
                String format = "";

                switch (aNewVideoFormat)
                {
                case VideoFormat.Fmt2D:

                    switch (GUIGraphicsContext.Render3DMode)
                    {
                    case GUIGraphicsContext.eRender3DMode.None:
                    case GUIGraphicsContext.eRender3DMode.SideBySide:
                    case GUIGraphicsContext.eRender3DMode.TopAndBottom:

                        format = "2D";
                        break;

                    case GUIGraphicsContext.eRender3DMode.SideBySideTo2D:

                        format = "3D SBS -> 2D via MediaPortal";
                        break;

                    case GUIGraphicsContext.eRender3DMode.TopAndBottomTo2D:

                        format = "3D TAB -> 2D via MediaPortal";
                        break;
                    }
                    break;

                case VideoFormat.Fmt3DSBS:

                    format = "3D Side by Side";

                    if (GUIGraphicsContext.Switch3DSides)
                    {
                        format += " Reverse";
                    }
                    break;

                case VideoFormat.Fmt3DTAB:

                    format = "3D Top and Bottom";

                    if (GUIGraphicsContext.Switch3DSides)
                    {
                        format += " Reverse";
                    }
                    break;

                case VideoFormat.Fmt2D3D:

                    format = "2D -> 3D via TV";
                    break;

                case VideoFormat.Mvc3D:

                    format = "3D MVC mode";
                    break;
                }

                Auto3DHelpers.ShowAuto3DMessage("VideoFormat: " + format, true, 4);
            }
        }