Exemple #1
0
        public override void ProcessCommand(OSAEMethod method)
        {
            Log.Debug("Found Command: " + method.MethodName + " | param1: " + method.Parameter1 + " | param2: " + method.Parameter2);

            if (method.ObjectName == pName)
            {
                if (method.MethodName == "SCAN")
                {
                    _UDPSend.Send();
                }
            }
            else
            {
                Receiver r = getReceiver(method.ObjectName);
                if (r != null)
                {
                    #region Network
                    if (r.Type == "Network")
                    {
                        switch (method.MethodName)
                        {
                        case "ON":
                            SendCommand_Network(r, "!1PWR01");
                            OSAEObjectStateManager.ObjectStateSet(r.Name, "ON", pName);
                            break;

                        case "OFF":
                            SendCommand_Network(r, "!1PWR00");
                            OSAEObjectStateManager.ObjectStateSet(r.Name, "OFF", pName);
                            break;

                        case "MUTE":
                            SendCommand_Network(r, "!1AMT01");
                            break;

                        case "UNMUTE":
                            SendCommand_Network(r, "!1AMT00");
                            break;

                        case "VOLUME UP":
                            SendCommand_Network(r, "!1MVLUP");
                            break;

                        case "VOLUME DOWN":
                            SendCommand_Network(r, "!1MVLDOWN");
                            break;

                        case "SET VOLUME":
                            SendCommand_Network(r, "!1MVL" + Int32.Parse(method.Parameter1).ToString("X"));
                            break;

                        case "VCR/DVR":
                            SendCommand_Network(r, "!1SLI00");
                            break;

                        case "CBL/SAT":
                            SendCommand_Network(r, "!1SLI01");
                            break;

                        case "GAME":
                            SendCommand_Network(r, "!1SLI02");
                            break;

                        case "AUX1":
                            SendCommand_Network(r, "!1SLI03");
                            break;

                        case "BD/DVD":
                            SendCommand_Network(r, "!1SLI10");
                            break;

                        case "TV/CD":
                            SendCommand_Network(r, "!1SLI23");
                            break;

                        case "TUNER":
                            SendCommand_Network(r, "!1SLI26");
                            break;

                        case "DLNA":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV00");
                            break;

                        case "VTUNER":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV02");
                            break;

                        case "PANDORA":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV04");
                            break;

                        case "SIRIUS":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV03");
                            break;

                        case "MEDIAFLY":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV09");
                            break;

                        case "NAPSTER":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV07");
                            break;

                        case "FAVORITES":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV01");
                            break;

                        case "UP":
                            SendCommand_Network(r, "!1OSDUP");
                            break;

                        case "DOWN":
                            SendCommand_Network(r, "!1OSDDOWN");
                            break;

                        case "RIGHT":
                            SendCommand_Network(r, "!1OSDRIGHT");
                            break;

                        case "LEFT":
                            SendCommand_Network(r, "!1OSDLEFT");
                            break;

                        case "ENTER":
                            SendCommand_Network(r, "!1OSDENTER");
                            break;

                        case "NETUP":
                            SendCommand_Network(r, "!1NTCUP");
                            break;

                        case "NETDOWN":
                            SendCommand_Network(r, "!1NTCDOWN");
                            break;

                        case "NETRIGHT":
                            SendCommand_Network(r, "!1NTCRIGHT");
                            break;

                        case "NETLEFT":
                            SendCommand_Network(r, "!1NTCLEFT");
                            break;

                        case "NETENTER":
                            SendCommand_Network(r, "!1NTCSELECT");
                            break;
                        }
                    }
                    #endregion
                    else if (r.Type == "Serial")
                    {
                    }
                }
            }
        }
        public void ProcessCommand(System.Data.DataTable table)
        {
            System.Data.DataRow row = table.Rows[0];
            osae.AddToLog("Found Command: " + row["method_name"].ToString() + " | param1: " + row["parameter_1"].ToString() + " | param2: " + row["parameter_1"].ToString(), false);

            if (row["object_name"].ToString() == pName)
            {
                if (row["method_name"].ToString() == "SCAN")
                {
                    _UDPSend.Send();
                }
            }
            else
            {
                Receiver r = getReceiver(row["object_name"].ToString());
                if (r != null)
                {
                    #region Network
                    if (r.Type == "Network")
                    {
                        switch (row["method_name"].ToString())
                        {
                        case "ON":
                            SendCommand_Network(r, "!1PWR01");
                            osae.ObjectStateSet(r.Name, "ON");
                            break;

                        case "OFF":
                            SendCommand_Network(r, "!1PWR00");
                            osae.ObjectStateSet(r.Name, "OFF");
                            break;

                        case "MUTE":
                            SendCommand_Network(r, "!1AMT01");
                            break;

                        case "UNMUTE":
                            SendCommand_Network(r, "!1AMT00");
                            break;

                        case "VOLUME UP":
                            SendCommand_Network(r, "!1MVLUP");
                            break;

                        case "VOLUME DOWN":
                            SendCommand_Network(r, "!1MVLDOWN");
                            break;

                        case "SET VOLUME":
                            SendCommand_Network(r, "!1MVL" + Int32.Parse(row["parameter_1"].ToString()).ToString("X"));
                            break;

                        case "VCR/DVR":
                            SendCommand_Network(r, "!1SLI00");
                            break;

                        case "CBL/SAT":
                            SendCommand_Network(r, "!1SLI01");
                            break;

                        case "GAME":
                            SendCommand_Network(r, "!1SLI02");
                            break;

                        case "AUX1":
                            SendCommand_Network(r, "!1SLI03");
                            break;

                        case "BD/DVD":
                            SendCommand_Network(r, "!1SLI10");
                            break;

                        case "TV/CD":
                            SendCommand_Network(r, "!1SLI23");
                            break;

                        case "TUNER":
                            SendCommand_Network(r, "!1SLI26");
                            break;

                        case "DLNA":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV00");
                            break;

                        case "VTUNER":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV02");
                            break;

                        case "PANDORA":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV04");
                            break;

                        case "SIRIUS":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV03");
                            break;

                        case "MEDIAFLY":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV09");
                            break;

                        case "NAPSTER":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV07");
                            break;

                        case "FAVORITES":
                            SendCommand_Network(r, "!1SLI2B");
                            SendCommand_Network(r, "!1NSV01");
                            break;

                        case "UP":
                            SendCommand_Network(r, "!1OSDUP");
                            break;

                        case "DOWN":
                            SendCommand_Network(r, "!1OSDDOWN");
                            break;

                        case "RIGHT":
                            SendCommand_Network(r, "!1OSDRIGHT");
                            break;

                        case "LEFT":
                            SendCommand_Network(r, "!1OSDLEFT");
                            break;

                        case "ENTER":
                            SendCommand_Network(r, "!1OSDENTER");
                            break;

                        case "NETUP":
                            SendCommand_Network(r, "!1NTCUP");
                            break;

                        case "NETDOWN":
                            SendCommand_Network(r, "!1NTCDOWN");
                            break;

                        case "NETRIGHT":
                            SendCommand_Network(r, "!1NTCRIGHT");
                            break;

                        case "NETLEFT":
                            SendCommand_Network(r, "!1NTCLEFT");
                            break;

                        case "NETENTER":
                            SendCommand_Network(r, "!1NTCSELECT");
                            break;
                        }
                    }
                    #endregion
                    else if (r.Type == "Serial")
                    {
                    }
                }
            }
        }
Exemple #3
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            Log.Debug("Running interface");

            OSAEObjectType objt = OSAEObjectTypeManager.ObjectTypeLoad("ONKYO RECEIVER");

            OSAEObjectTypeManager.ObjectTypeUpdate(objt.Name, objt.Name, objt.Description, pName, "THING", objt.Owner, objt.SysType, objt.Container, objt.HideRedundant);

            _UDPListen              = new UDPListen();
            _UDPSend                = new UDPSend();
            _UDPListen.OnkyoDevice += new DelegateOnkyoReply(OnkyoMessageHandler);

            _UDPListen.Listen();
            _UDPSend.Send();

            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("ONKYO RECEIVER");

            foreach (OSAEObject obj in objects)
            {
                Receiver r = new Receiver(obj.Name);
                foreach (OSAEObjectProperty prop in obj.Properties)
                {
                    switch (prop.Name)
                    {
                    case "Communication Type":
                        r.Type = prop.Value;
                        break;

                    case "IP":
                        r.IP = prop.Value;
                        break;

                    case "Network Port":
                        try
                        { r.NetworkPort = Int32.Parse(prop.Value); }
                        catch
                        { r.NetworkPort = 0; }
                        break;

                    case "COM Port":
                        try
                        { r.ComPort = Int32.Parse(prop.Value); }
                        catch
                        { r.ComPort = 0; }
                        break;
                    }
                }

                receivers.Add(r);
                Log.Debug("Added receiver to list: " + r.Name);

                try
                {
                    if (r.Type == "Network" && r.IP != "" && r.NetworkPort != 0)
                    {
                        Log.Debug("Creating TCP Client: ip-" + r.IP + " port-" + r.NetworkPort);
                        r.tcpClient = new TcpClient(r.IP, r.NetworkPort);

                        //get a network stream from server
                        r.clientSockStream = r.tcpClient.GetStream();

                        // create new writer and reader stream to send and receive
                        r.clientStreamWriter = new StreamWriter(r.clientSockStream);
                        r.clientStreamReader = new StreamReader(r.clientSockStream);

                        //Start listening
                        r.Connect();
                    }
                    else if (r.Type == "Serial" && r.ComPort != 0)
                    { //not implemented
                    }
                    else
                    {
                        Log.Info(r.Name + " - Properties not set");
                    }
                }
                catch (Exception ex)
                { Log.Error("Error creating connection to receiver", ex); }
            }
            Log.Info("Run Interface Complete");
        }
        public void RunInterface(string pluginName)
        {
            osae.AddToLog("Running interface", false);
            pName = pluginName;
            osae.ObjectTypeUpdate("ONKYO RECEIVER", "ONKYO RECEIVER", "Onkyo Receiver", pluginName, "ONKYO RECEIVER", 0, 0, 0, 1);

            _UDPListen              = new UDPListen();
            _UDPSend                = new UDPSend();
            _UDPListen.OnkyoDevice += new DelegateOnkyoReply(OnkyoMessageHandler);

            _UDPListen.Listen();
            _UDPSend.Send();

            List <OSAEObject> objects = osae.GetObjectsByType("ONKYO RECEIVER");

            foreach (OSAEObject obj in objects)
            {
                Receiver r = new Receiver(obj.Name);
                foreach (ObjectProperty prop in obj.Properties)
                {
                    switch (prop.Name)
                    {
                    case "Communication Type":
                        r.Type = prop.Value;
                        break;

                    case "IP":
                        r.IP = prop.Value;
                        break;

                    case "Network Port":
                        try
                        {
                            r.NetworkPort = Int32.Parse(prop.Value);
                        }
                        catch
                        {
                            r.NetworkPort = 0;
                        }
                        break;

                    case "COM Port":
                        try
                        {
                            r.ComPort = Int32.Parse(prop.Value);
                        }
                        catch
                        {
                            r.ComPort = 0;
                        }
                        break;
                    }
                }

                receivers.Add(r);
                osae.AddToLog("Added receiver to list: " + r.Name, false);

                try
                {
                    if (r.Type == "Network" && r.IP != "" && r.NetworkPort != 0)
                    {
                        osae.AddToLog("Creating TCP Client: ip-" + r.IP + " port-" + r.NetworkPort, false);
                        r.tcpClient = new TcpClient(r.IP, r.NetworkPort);

                        //get a network stream from server
                        r.clientSockStream = r.tcpClient.GetStream();

                        // create new writer and reader stream to send and receive
                        r.clientStreamWriter = new StreamWriter(r.clientSockStream);
                        r.clientStreamReader = new StreamReader(r.clientSockStream);

                        //Start listening
                        r.Connect();
                    }
                    else if (r.Type == "Serial" && r.ComPort != 0)
                    {
                        //not implemented
                    }
                    else
                    {
                        osae.AddToLog(r.Name + " - Properties not set", true);
                    }
                }
                catch (Exception ex)
                {
                    osae.AddToLog("Error creating connection to receiver: " + ex.Message, true);
                }
            }
            osae.AddToLog("Run Interface Complete", false);
        }