public void createdevice(OSAEObject obj)
        {
            MCDevice d = new MCDevice(obj.Name, pName);
            foreach (OSAEObjectProperty prop in obj.Properties)
            {
                switch (prop.Name)
                {
                    case "Type":
                        d.Type = prop.Value;
                        break;
                    case "IP":
                        d.IP = prop.Value;
                        break;
                    case "Network Port":
                        try
                        {
                            d.CommandPort = Int32.Parse(prop.Value);
                        }
                        catch
                        {
                            d.CommandPort = 0;
                        }
                        break;
                }
            }

            mcdevices.Add(d);
            Log.Info("Added MCDevice to list: " + d.Name);

            d.EstablishInitialConnections();
        }
Ejemplo n.º 2
0
        public void createdevice(OSAEObject obj)
        {
            MCDevice d = new MCDevice(obj.Name, pName);

            foreach (OSAEObjectProperty prop in obj.Properties)
            {
                switch (prop.Name)
                {
                case "Type":
                    d.Type = prop.Value;
                    break;

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

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

            mcdevices.Add(d);
            log("Added MCDevice to list: " + d.Name, false);

            d.EstablishInitialConnections();
        }
Ejemplo n.º 3
0
        public void update()
        {
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("MediaCenter Device");

            String msg = "";

            //add any new objects created since pluggin started
            foreach (OSAEObject obj in objects)
            {
                MCDevice d = getMCDevice(obj.Name);
                if (d == null)
                {
                    log("Poll- device was null so we are creating it-" + obj.Name, false);
                    createdevice(obj);
                }
            }

            foreach (MCDevice d in mcdevices)
            {
                Boolean connected;
                connected = d.CheckConnections();

                if (connected)
                {
                    if (OSAEObjectStateManager.GetObjectStateValue(d.Name).Value == "Off")
                    {
                        OSAEObjectStateManager.ObjectStateSet(d.Name, "ON", pName);
                    }
                    if (!msg.Equals(""))
                    {
                        msg = msg + ", ";
                    }
                    msg = msg + d.Name + ":ON";
                }
                else
                {
                    if (OSAEObjectStateManager.GetObjectStateValue(d.Name).Value != "Off")
                    {
                        OSAEObjectStateManager.ObjectStateSet(d.Name, "OFF", pName);
                    }
                    if (!msg.Equals(""))
                    {
                        msg = msg + ", ";
                    }
                    msg = msg + d.Name + ":OFF";
                }
            }
            log("Poll to check which media center devices are online(" + msg + ")", false);
        }
Ejemplo n.º 4
0
        public override void ProcessCommand(OSAEMethod method)
        {
            String object_name = method.ObjectName;
            String method_name = method.MethodName;
            String parameter_1 = method.Parameter1;
            String parameter_2 = method.Parameter2;
            String mycommand;

            log("Found Command: " + method_name + " | param1: " + parameter_1 + " | param2: " + parameter_2, true);

            if (object_name == pName)
            {
                switch (method_name)
                {
                case "SCAN":
                    //will eventaully try to run a network scan to check if any devices are active on port 40400 or 40500
                    log("Scan event triggered... currently it does nothing ", false);
                    break;

                case "NOTIFYALL":
                    mycommand = @"msgbox ""OSA"" """ + parameter_1 + @""" " + parameter_2;
                    log("NOTIFYALL event triggered, command to send=" + mycommand, false);

                    foreach (MCDevice d in mcdevices)
                    {
                        d.SendCommand_Network(mycommand);
                    }

                    break;
                }
            }
            else
            {
                MCDevice d = getMCDevice(object_name);
                if (d != null)
                {
                    d.ProcessCommand(method_name, parameter_1, parameter_2);
                }
            }
        }