Пример #1
0
        public override void ProcessCommand(OSAEMethod method)
        {
            Log.Debug("Process command: " + method.MethodName);
            switch (method.MethodName)
            {
            case "SET TEMPORARY COOL":
                ThermostatLib.ThermostatInfo.SetTemporaryCool(method.Address, Double.Parse(method.Parameter1));
                break;

            case "SET TEMPORARY HEAT":
                ThermostatLib.ThermostatInfo.SetTemporaryHeat(method.Address, Double.Parse(method.Parameter1));
                break;

            case "SET HOLD":
                ThermostatLib.ThermostatInfo.SetHold(method.Address, true);
                break;

            case "REMOVE HOLD":
                ThermostatLib.ThermostatInfo.SetHold(method.Address, false);
                break;

            case "REBOOT":
                ThermostatLib.SystemInfo.Reboot(method.Address);
                break;

            case "SET LED":
                ThermostatLib.SystemInfo.SetLED(method.Address, method.Parameter1);
                break;
            }
        }
Пример #2
0
        public override void ProcessCommand(OSAEMethod method)
        {
            this.Log.Debug("Found Command: " + method.MethodName + " | param1: " + method.Parameter1 + " | param2: " + method.Parameter2);

            XBMCSystem s = getXBMCSystem(method.ObjectName);

            if (s != null)
            {
                switch (method.MethodName)
                {
                case "VPLAYPAUSE":
                    s.xbmcSystem.Player.PlayPause();
                    break;

                case "VSTOP":
                    s.xbmcSystem.Player.Stop();
                    break;

                case "VBIGSKIPFORWARD":
                    s.xbmcSystem.Player.Seek2(0, Player.Seekvalue.bigforward);
                    break;

                case "VBIGSKIPBACK":
                    s.xbmcSystem.Player.Seek2(0, Player.Seekvalue.bigbackward);
                    break;
                }
            }
        }
Пример #3
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try {
                string object_name = method.ObjectName;
                string method_name = method.MethodName;
                string parameter_1 = method.Parameter1;
                string parameter_2 = method.Parameter2;

                Log.Debug("Found Command: " + method_name + " | param1: " + parameter_1 + " | param2: " + parameter_2);

                if (object_name == pName)
                {
                    switch (method_name)
                    {
                    case "NOTIFYALL":
                        Log.Debug("NOTIFYALL event triggered");
                        Log.Debug("NOTIFYALL devices to loop:" + mdevices.Count);

                        foreach (AndroidDevice d in mdevices)
                        {
                            Log.Debug("NOTIFYALL loop for device:" + d.Name);
                            d.ProcessCommand("NOTIFY", parameter_1, parameter_2);
                        }

                        break;

                    case "EXECUTEALL":
                        Log.Debug("EXECUTEALL event triggered");
                        Log.Debug("EXECUTEALL devices to loop:" + mdevices.Count);

                        foreach (AndroidDevice d in mdevices)
                        {
                            Log.Debug("EXECUTEALL loop for device:" + d.Name);
                            d.ProcessCommand("EXECUTE", parameter_1, parameter_2);
                        }
                        break;
                    }
                }
                else
                {
                    AndroidDevice d = getAndroidDevice(object_name);

                    if (d == null)
                    {
                        OSAEObject obj = OSAEObjectManager.GetObjectByName(object_name);
                        createdevice(obj);
                        d = getAndroidDevice(object_name);
                    }

                    if (d != null)
                    {
                        d.ProcessCommand(method_name, parameter_1, parameter_2);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error processing command!", ex);
            }
        }
Пример #4
0
        public override void ProcessCommand(OSAEMethod method)
        {
            Log.Debug("Received command: " + method.MethodName);
            if (method.MethodName == "TWEET")
            {
                SendTweet(Common.PatternParse(method.Parameter1));
            }
            else if (method.MethodName == "AUTHENTICATE")
            {
                string pin = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Pin").Value;

                if (pin != "")
                {
                    Log.Info("Found pin: " + pin + ". Attempting to authorize");
                    try
                    {
                        // Now that the application's been authenticated, let's get the (permanent)
                        // token and secret token that we'll use to authenticate from now on.
                        _oAuth.AccessTokenGet(_oAuth.OAuthToken, pin.Trim());
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Token", _oAuth.Token, pName);
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Token Secret", _oAuth.TokenSecret, pName);
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Auth Token", _oAuth.OAuthToken, pName);
                        this.Log.Info("Success! You're ready to start tweeting!");
                    }
                    catch (Exception ex)
                    { Log.Error("An error occurred during authorization", ex); }
                }
                else
                {
                    Log.Info("No pin found.  Please enter the pin from twitter into the Twitter object property.");
                }
            }
        }
Пример #5
0
 public void ProcessCommand(OSAEMethod method)
 {
     if (method.MethodName == "UPDATE")
     {
         update();
     }
 }
Пример #6
0
        public void ProcessCommand(OSAEMethod method)
        {
            osae.AddToLog("Received command: " + method.MethodName, false);
            if (method.MethodName == "TWEET")
            {
                SendTweet(osae.PatternParse(method.Parameter1));
            }
            else if (method.MethodName == "AUTHENTICATE")
            {
                string pin = osae.GetObjectPropertyValue(_pname, "Pin").Value;

                if (pin != "")
                {
                    osae.AddToLog("Found pin: " + pin + ". Attempting to authorize", true);
                    try
                    {
                        // Now that the application's been authenticated, let's get the (permanent)
                        // token and secret token that we'll use to authenticate from now on.
                        _oAuth.AccessTokenGet(_oAuth.OAuthToken, pin.Trim());
                        osae.ObjectPropertySet(_pname, "Token", _oAuth.Token);
                        osae.ObjectPropertySet(_pname, "Token Secret", _oAuth.TokenSecret);
                        osae.ObjectPropertySet(_pname, "Auth Token", _oAuth.OAuthToken);
                        osae.AddToLog("Success! You're ready to start tweeting!", true);
                    }
                    catch (Exception ex)
                    {
                        osae.AddToLog("An error occurred during authorization:\n\n" + ex.Message, true);
                    }
                }
                else
                {
                    osae.AddToLog("No pin found.  Please enter the pin from twitter into the Twitter object property.", true);
                }
            }
        }
Пример #7
0
        //private System.Timers.Timer Clock;



        public override void ProcessCommand(OSAEMethod method)
        {
            //System.Data.DataRow row = table.Rows[0];
            //logging.AddToLog("Found Command: " + row["method_name"].ToString() + " | param1: " + row["parameter_1"].ToString() + " | param2: " + row["parameter_1"].ToString(), false);

            //XBMCSystem s = getXBMCSystem(row["object_name"].ToString());
            //if (s != null)
            //{
            //    switch (row["method_name"].ToString())
            //    {
            //        case "VPLAYPAUSE":
            //            s.Connection.Player.PlayPause();
            //            break;
            //        case "VSTOP":
            //            s.Connection.Player.Stop();
            //            break;
            //        case "VBIGSKIPFORWARD":
            //            s.Connection.Player.BigSkipForward();
            //            break;
            //        case "VBIGSKIPBACK":
            //            s.Connection.Player.BigSkipBackward();
            //            break;
            //    }
            //}
        }
Пример #8
0
        //private System.Timers.Timer Clock;




        public override void ProcessCommand(OSAEMethod method)
        {
            //System.Data.DataRow row = table.Rows[0];
            //logging.AddToLog("Found Command: " + row["method_name"].ToString() + " | param1: " + row["parameter_1"].ToString() + " | param2: " + row["parameter_1"].ToString(), false);

            //XBMCSystem s = getXBMCSystem(row["object_name"].ToString());
            //if (s != null)
            //{
            //    switch (row["method_name"].ToString())
            //    {
            //        case "VPLAYPAUSE":
            //            s.Connection.Player.PlayPause();
            //            break;
            //        case "VSTOP":
            //            s.Connection.Player.Stop();
            //            break;
            //        case "VBIGSKIPFORWARD":
            //            s.Connection.Player.BigSkipForward();
            //            break;
            //        case "VBIGSKIPBACK":
            //            s.Connection.Player.BigSkipBackward();
            //            break;
            //    }
            //}

        }
        /// <summary>
        /// A Command to be processed bu the plugin
        /// </summary>
        /// <param name="method"></param>
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string script = "";

                int scriptId;
                if (int.TryParse(method.Parameter1, out scriptId))
                {
                    script = OSAEScriptManager.GetScript(method.Parameter1);
                }
                else
                {
                    script = OSAEScriptManager.GetScriptByName(method.Parameter1);
                }

                logging.AddToLog("running script: " + script, false);

                if(!string.IsNullOrEmpty(script))
                {
                    RunScript(script, method);
                }
            }
            catch (Exception exc)
            {
                logging.AddToLog("Error Processing Command: " + exc.Message, true);
            }
        }
Пример #10
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                //basically just need to send parameter two to the contact in parameter one with sendMessage();
                //Process incomming command
                string to = "";
                if (gDebug)
                {
                    Log.Debug("Process command: " + method.MethodName);
                }
                if (gDebug)
                {
                    Log.Debug("Message: " + method.Parameter2);
                }
                OSAEObjectProperty prop = OSAEObjectPropertyManager.GetObjectPropertyValue(method.Parameter1, "JabberID");

                if (prop != null)
                {
                    to = prop.Value;
                }
                else
                {
                    to = method.Parameter1;
                }

                if (to == "")
                {
                    to = method.Parameter1;
                }

                if (gDebug)
                {
                    Log.Debug("To: " + to);
                }

                switch (method.MethodName)
                {
                case "SEND MESSAGE":
                    sendMessage(Common.PatternParse(method.Parameter2), to);
                    break;

                case "SEND QUESTION":
                    Ask_Question(to);
                    break;

                case "SEND FROM LIST":
                    string speechList = method.Parameter2.Substring(0, method.Parameter2.IndexOf(","));
                    string listItem   = method.Parameter2.Substring(method.Parameter2.IndexOf(",") + 1, method.Parameter2.Length - (method.Parameter2.IndexOf(",") + 1));
                    if (gDebug)
                    {
                        Log.Debug("List = " + speechList + "   Item=" + listItem);
                    }
                    sendMessage(Common.PatternParse(OSAEObjectPropertyManager.ObjectPropertyArrayGetRandom(speechList, listItem)), to);
                    break;
                }
            }
            catch (Exception ex)
            { Log.Error("Error in ProcessCommand!", ex); }
        }
Пример #11
0
        public override void ProcessCommand(OSAEMethod method)
        {
            this.Log.Debug("Found Command: " + method.MethodName + " | param1: " + method.Parameter1 + " | param2: " + method.Parameter2);

            XBMCSystem s = getXBMCSystem(method.ObjectName);
            if (s != null)
            {
                switch (method.MethodName)
                {
                    case "VPLAYPAUSE":
                        s.xbmcSystem.Player.PlayPause();
                        break;
                    case "VSTOP":
                        s.xbmcSystem.Player.Stop();
                        break;
                    case "VBIGSKIPFORWARD":
                        s.xbmcSystem.Player.Seek2(0,Player.Seekvalue.bigforward);
                        break;
                    case "VBIGSKIPBACK":
                        s.xbmcSystem.Player.Seek2(0, Player.Seekvalue.bigbackward);
                        break;
                }
            }

        }
Пример #12
0
 public override void ProcessCommand(OSAEMethod method)
 {
     if (method.MethodName == "UPDATE")
     {
         updateFeeds();
     }
 }
        /// <summary>
        /// A Command to be processed bu the plugin
        /// </summary>
        /// <param name="method"></param>
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string script = "";

                int scriptId;
                if (int.TryParse(method.Parameter1, out scriptId))
                {
                    script = OSAEScriptManager.GetScript(method.Parameter1);
                }
                else
                {
                    script = OSAEScriptManager.GetScriptByName(method.Parameter1);
                }

                this.Log.Debug("running script: " + script);

                if(!string.IsNullOrEmpty(script))
                {
                    RunScript(script, method);
                }
            }
            catch (Exception exc)
            {
                this.Log.Error("Error Processing Command ", exc);
            }
        }
        public override void ProcessCommand(OSAEMethod method)
        {
            Log.Debug("Received command: " + method.MethodName);
            if (method.MethodName == "TWEET")
                SendTweet(Common.PatternParse(method.Parameter1));
            else if (method.MethodName == "AUTHENTICATE")
            {
                string pin = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Pin").Value;

                if (pin != "")
                {
                    Log.Info("Found pin: " + pin + ". Attempting to authorize");
                    try
                    {
                        // Now that the application's been authenticated, let's get the (permanent)
                        // token and secret token that we'll use to authenticate from now on.
                        _oAuth.AccessTokenGet(_oAuth.OAuthToken, pin.Trim());
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Token", _oAuth.Token, pName);
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Token Secret", _oAuth.TokenSecret, pName);
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Auth Token", _oAuth.OAuthToken, pName);
                        this.Log.Info("Success! You're ready to start tweeting!");
                    }
                    catch (Exception ex)
                    { Log.Error("An error occurred during authorization", ex); }
                }
                else
                    Log.Info("No pin found.  Please enter the pin from twitter into the Twitter object property.");
            }
        }
        public override void ProcessCommand(OSAEMethod method)
        {
            logging.AddToLog("Process command: " + method.MethodName, false);

            switch (method.MethodName)
            {
                case "SET TEMPORARY COOL":
                    ThermostatLib.ThermostatInfo.SetTemporaryCool(method.Address, Double.Parse(method.Parameter1));
                    break;

                case "SET TEMPORARY HEAT":
                    ThermostatLib.ThermostatInfo.SetTemporaryHeat(method.Address, Double.Parse(method.Parameter1));
                    break;

                case "SET HOLD":
                    ThermostatLib.ThermostatInfo.SetHold(method.Address, true);
                    break;

                case "REMOVE HOLD":
                    ThermostatLib.ThermostatInfo.SetHold(method.Address, false);
                    break;

                case "REBOOT":
                    ThermostatLib.SystemInfo.Reboot(method.Address);
                    break;

                case "SET LED":
                    ThermostatLib.SystemInfo.SetLED(method.Address, method.Parameter1);
                    break;
            }
        }
        /// <summary>
        /// A Command to be processed bu the plugin
        /// </summary>
        /// <param name="method"></param>
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string script = "";

                int scriptId;
                if (int.TryParse(method.Parameter1, out scriptId))
                {
                    script = OSAEScriptManager.GetScript(method.Parameter1);
                }
                else
                {
                    script = OSAEScriptManager.GetScriptByName(method.Parameter1);
                }

                logging.AddToLog("running script: " + script, false);

                if (!string.IsNullOrEmpty(script))
                {
                    RunScript(script, method);
                }
            }
            catch (Exception exc)
            {
                logging.AddToLog("Error Processing Command: " + exc.Message, true);
            }
        }
Пример #17
0
        public void updateonline()
        {
            OSAEObjectCollection sonydevices = OSAEObjectManager.GetObjectsByOwner("Sony");

            if (refresh > 0)
            {
                foreach (OSAEObject device in sonydevices)
                {
                    string objName = device.Name;
                    if (objName != "Sony")
                    {
                        if (device.Property("Registered").Value == "TRUE")
                        {
                            if (debug)
                            {
                                this.Log.Debug("Updating Online Status for: " + objName);
                            }
                            sonyobj = OSAEObjectManager.GetObjectByName(objName);
                            if (debug)
                            {
                                this.Log.Debug("Initializing: " + sonyobj.Name);
                            }
                            mySonyDevice.Name        = sonyobj.Name;
                            mySonyDevice.DocumentUrl = sonyobj.Property("DocumentURL").Value;
                            mySonyDevice.ServerName  = "OSAE.Sony";
                            mySonyDevice.BuildFromDocument(new Uri(mySonyDevice.DocumentUrl));
                            OSAEMethod updatereg = new OSAEMethod();
                            updatereg.ObjectName = mySonyDevice.Name;
                            checkStatus(updatereg);
                        }
                    }
                }
            }
        }
Пример #18
0
        public override void ProcessCommand(OSAEMethod method)
        {
            // COSMUPDATER.Run Method.RELOADITEMS

            switch (method.MethodName.ToUpper())
            {
                case "OFF":
                    logging.AddToLog("COSMUpdater Stopped", true);
                    enabled = false;
                    break;
                case "ON":
                    logging.AddToLog("COSMUpdater Started", true);
                    enabled = true;
                    break;
                case "WRITEDATA":
                    logging.AddToLog("COSMUpdater DataWrite Forced", true);
                    WriteData();
                    break;
                case "RELOADITEMS":
                    logging.AddToLog("COSMUpdater ReloadItems", true);
                    GetCurrentList();
                    break;
                default:
                    logging.AddToLog(string.Format("COSMUpdater got method of {0} but it is not implemented", method.MethodName), true);
                    break;
            }
        }
Пример #19
0
 public override void ProcessCommand(OSAEMethod method)
 {
     try
     {
         string command = method.MethodName;
         string address = method.Address;
         string name    = method.ObjectName;
         if (address.Length > 0)
         {
             string serial = OSAEObjectPropertyManager.GetObjectPropertyValue(name, "Serial").Value;
             string id     = OSAEObjectPropertyManager.GetObjectPropertyValue(name, "Id").Value;
             ushort n      = UInt16.Parse(id);
             if (command == "ON")
             {
                 Jsb34xCloseRelay(serial, (byte)n);
                 Log.Info("Set state: " + name + " (" + address + ")" + " to ON");
             }
             else if (command == "OFF")
             {
                 Jsb34xOpenRelay(serial, (byte)n);
                 Log.Info("Set state: " + name + " (" + address + ")" + " to OFF");
             }
         }
         else if (command == "POLL")
         {
             Poll(this, new EventArgs());
         }
     }
     catch (Exception ex)
     { Log.Error("Error processing command!", ex); }
 }
Пример #20
0
        public void sendtext(OSAEMethod method)
        {
            bool reg = checkStatus(method);

            if (reg == true)
            {
                try
                {
                    objName                  = method.ObjectName;
                    sonyobj                  = OSAEObjectManager.GetObjectByName(objName);
                    mySonyDevice.Name        = sonyobj.Name;
                    mySonyDevice.DocumentUrl = sonyobj.Property("DocumentURL").Value;
                    mySonyDevice.ServerName  = "OSAE.Sony";
                    mySonyDevice.BuildFromDocument(new Uri(mySonyDevice.DocumentUrl));
                    mySonyDevice.SendText(method.Parameter1);
                }
                catch (Exception ex)
                {
                    this.Log.Info("An error occurred!!!: " + ex.Message);
                    if (debug)
                    {
                        this.Log.Debug("The Send Text method was unsuccessful.");
                    }
                }
            }
        }
Пример #21
0
        /// <summary>
        /// A Command to be processed bu the plugin
        /// </summary>
        /// <param name="method"></param>
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string script = "";

                int scriptId;
                if (int.TryParse(method.Parameter1, out scriptId))
                {
                    script = OSAEScriptManager.GetScript(method.Parameter1);
                }
                else
                {
                    script = OSAEScriptManager.GetScriptByName(method.Parameter1);
                }

                this.Log.Debug("running script: " + script);

                if (!string.IsNullOrEmpty(script))
                {
                    RunScript(script, method);
                }
            }
            catch (Exception exc)
            {
                this.Log.Error("Error Processing Command ", exc);
            }
        }
Пример #22
0
        public void ProcessCommand(OSAEMethod method)
        {
            osae.AddToLog("Received command: " + method.MethodName, false);
            if (method.MethodName == "TWEET")
            {
                SendTweet(osae.PatternParse(method.Parameter1));
            }
            else if (method.MethodName == "AUTHENTICATE")
            {
                string pin = osae.GetObjectPropertyValue(_pname, "Pin").Value;

                if (pin != "")
                {
                    osae.AddToLog("Found pin: " + pin + ". Attempting to authorize", true);
                    try
                    {
                        // Now that the application's been authenticated, let's get the (permanent)
                        // token and secret token that we'll use to authenticate from now on.
                        _oAuth.AccessTokenGet(_oAuth.OAuthToken, pin.Trim());
                        osae.ObjectPropertySet(_pname, "Token", _oAuth.Token);
                        osae.ObjectPropertySet(_pname, "Token Secret", _oAuth.TokenSecret);
                        osae.ObjectPropertySet(_pname, "Auth Token", _oAuth.OAuthToken);
                        osae.AddToLog("Success! You're ready to start tweeting!", true);
                    }
                    catch (Exception ex)
                    {
                        osae.AddToLog("An error occurred during authorization:\n\n" + ex.Message, true);
                    }
                }
                else
                {
                    osae.AddToLog("No pin found.  Please enter the pin from twitter into the Twitter object property.", true);
                }
            }
        }
Пример #23
0
        public override void ProcessCommand(OSAEMethod method)
        {
            // COSMUPDATER.Run Method.RELOADITEMS

            switch (method.MethodName.ToUpper())
            {
            case "OFF":
                Log.Info("COSMUpdater Stopped");
                enabled = false;
                break;

            case "ON":
                Log.Info("COSMUpdater Started");
                enabled = true;
                break;

            case "WRITEDATA":
                Log.Info("COSMUpdater DataWrite Forced");
                WriteData();
                break;

            case "RELOADITEMS":
                Log.Info("COSMUpdater ReloadItems");
                GetCurrentList();
                break;

            default:
                Log.Info(string.Format("COSMUpdater got method of {0} but it is not implemented", method.MethodName));
                break;
            }
        }
        public override void ProcessCommand(OSAEMethod method)
        {
            try {
                string object_name = method.ObjectName;
                string method_name = method.MethodName;
                string parameter_1 = method.Parameter1;
                string parameter_2 = method.Parameter2;

                Log.Debug("Found Command: " + method_name + " | param1: " + parameter_1 + " | param2: " + parameter_2);

                if (object_name == pName)
                {
                    switch (method_name)
                    {
                        case "NOTIFYALL":
                            Log.Debug("NOTIFYALL event triggered");
                            Log.Debug("NOTIFYALL devices to loop:" + mdevices.Count);

                            foreach (AndroidDevice d in mdevices)
                            {
                                Log.Debug("NOTIFYALL loop for device:" + d.Name);
                                d.ProcessCommand("NOTIFY", parameter_1, parameter_2);
                            }

                            break;

                        case "EXECUTEALL":
                            Log.Debug("EXECUTEALL event triggered");
                            Log.Debug("EXECUTEALL devices to loop:" + mdevices.Count);

                            foreach (AndroidDevice d in mdevices)
                            {
                                Log.Debug("EXECUTEALL loop for device:" + d.Name);
                                d.ProcessCommand("EXECUTE", parameter_1, parameter_2);
                            }
                            break;
                    }
                }
                else
                {
                    AndroidDevice d = getAndroidDevice(object_name);

                    if (d == null)
                    {
                        OSAEObject obj = OSAEObjectManager.GetObjectByName(object_name);
                        createdevice(obj);
                        d = getAndroidDevice(object_name);
                    }

                    if (d != null)
                        d.ProcessCommand(method_name, parameter_1, parameter_2);

                }
            }
            catch (Exception ex)
            {
                Log.Error("Error processing command!",ex);
            }
        }
Пример #25
0
 public void ProcessCommand(OSAEMethod method)
 {
     //This plugin does not process commands
     if (method.MethodName == "UPDATE")
     {
         update();
     }
 }
 /// <summary>
 /// Logs information about a method found in the Queue
 /// </summary>
 /// <param name="method">The method to log</param>
 private void LogMethodInformation(OSAEMethod method)
 {
     logging.AddToLog("Found method in queue: " + method.MethodName, false);
     logging.AddToLog("-- object name: " + method.ObjectName, false);
     logging.AddToLog("-- param 1: " + method.Parameter1, false);
     logging.AddToLog("-- param 2: " + method.Parameter2, false);
     logging.AddToLog("-- object owner: " + method.Owner, false);
 }
Пример #27
0
 /// <summary>
 /// Logs information about a method found in the Queue
 /// </summary>
 /// <param name="method">The method to log</param>
 private void LogMethodInformation(OSAEMethod method)
 {
     this.Log.Debug("Found method in queue: " + method.MethodName);
     this.Log.Debug("-- object name: " + method.ObjectName);
     this.Log.Debug("-- param 1: " + method.Parameter1);
     this.Log.Debug("-- param 2: " + method.Parameter2);
     this.Log.Debug("-- object owner: " + method.Owner);
 }
 /// <summary>
 /// Logs information about a method found in the Queue
 /// </summary>
 /// <param name="method">The method to log</param>
 private void LogMethodInformation(OSAEMethod method)
 {
     logging.AddToLog("Found method in queue: " + method.MethodName, false);
     logging.AddToLog("-- object name: " + method.ObjectName, false);
     logging.AddToLog("-- param 1: " + method.Parameter1, false);
     logging.AddToLog("-- param 2: " + method.Parameter2, false);
     logging.AddToLog("-- object owner: " + method.Owner, false);
 }
 /// <summary>
 /// Logs information about a method found in the Queue
 /// </summary>
 /// <param name="method">The method to log</param>
 private void LogMethodInformation(OSAEMethod method)
 {
     this.Log.Debug("Found method in queue: " + method.MethodName);
     this.Log.Debug("-- object name: " + method.ObjectName);
     this.Log.Debug("-- param 1: " + method.Parameter1);
     this.Log.Debug("-- param 2: " + method.Parameter2);
     this.Log.Debug("-- object owner: " + method.Owner);
 }
Пример #30
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;

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

            if (object_name == pName)
            {
                switch (method_name)
                {
                case "NOTIFYALL":
                    log("NOTIFYALL event triggered", false);

                    log("NOTIFYALL devices to loop:" + mdevices.Count, false);

                    foreach (AndroidDevice d in mdevices)
                    {
                        log("NOTIFYALL loop for device:" + d.Name, false);
                        d.ProcessCommand("NOTIFY", parameter_1, parameter_2);
                    }

                    break;

                case "EXECUTEALL":
                    log("EXECUTEALL event triggered", false);

                    log("EXECUTEALL devices to loop:" + mdevices.Count, false);

                    foreach (AndroidDevice d in mdevices)
                    {
                        log("EXECUTEALL loop for device:" + d.Name, false);
                        d.ProcessCommand("EXECUTE", parameter_1, parameter_2);
                    }

                    break;
                }
            }
            else
            {
                AndroidDevice d = getAndroidDevice(object_name);

                if (d == null)
                {
                    OSAEObject obj = OSAEObjectManager.GetObjectByName(object_name);
                    createdevice(obj);
                    d = getAndroidDevice(object_name);
                }

                if (d != null)
                {
                    d.ProcessCommand(method_name, parameter_1, parameter_2);
                }
            }
        }
        public override void ProcessCommand(OSAEMethod method)
        {
            //Process incomming command
            Log.Debug("Process command: " + method.MethodName);
            Log.Debug("Process parameter1: " + method.Parameter1);
            Log.Debug("Process parameter2: " + method.Parameter2);
            Log.Debug("Address: " + method.Address);

            switch (method.MethodName)
            {
                case "PLAY":
                    if (method.Parameter1.Trim() == string.Empty)
                        sbs.Play(method.Address);
                    else
                        sbs.PlaylistPlay(method.Address, method.Parameter1);
                    OSAEObjectStateManager.ObjectStateSet(OSAEObjectManager.GetObjectByAddress(method.Address).Name, "PLAYING", pName);
                    break;
                case "STOP":
                    sbs.StopPlayer(method.Address);
                    OSAEObjectStateManager.ObjectStateSet(OSAEObjectManager.GetObjectByAddress(method.Address).Name, "STOPPED", pName);
                    break;
                case "NEXT":
                    sbs.Next(method.Address);
                    break;
                case "PREV":
                    sbs.Previous(method.Address);
                    break;
                case "SHOW":
                    sbs.ShowMessage(method.Address, method.Parameter1, Int32.Parse(method.Parameter2));
                    break;
                case "PAUSE":
                    sbs.PausePlayer(method.Address);
                    OSAEObjectStateManager.ObjectStateSet(OSAEObjectManager.GetObjectByAddress(method.Address).Name, "PAUSED", pName);
                    break;
                case "TTS":
                    TextToSpeech(method.Parameter1);
                    sbs.PlaylistPlay(method.Address, ttsPlay);
                    break;
                case "TTSLIST":
                    DataSet list = OSAEObjectPropertyManager.ObjectPropertyArrayGetAll(method.Parameter1, method.Parameter2);
                    string tts = "";
                    int count = 1;
                    foreach(DataRow item in list.Tables[0].Rows)
                    {
                        tts += "  RSS item number " + count.ToString() + ".  " + item["item_name"].ToString();
                        count++;
                    }
                    TextToSpeech(tts);
                    sbs.PlaylistPlay(method.Address, ttsPlay);
                    break;
                case "TTSLISTRAND":
                    string listItem = OSAEObjectPropertyManager.ObjectPropertyArrayGetRandom(method.Parameter1, method.Parameter2);
                    TextToSpeech(listItem);
                    sbs.PlaylistPlay(method.Address, ttsPlay);
                    break;
            }
        }
Пример #32
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                //basically just need to send parameter two to the contact in parameter one with sendMessage();
                //Process incomming command
                string to = "";
                if (gDebug)
                {
                    Log.Debug("Process command: " + method.MethodName);
                }
                if (gDebug)
                {
                    Log.Debug("Message: " + method.Parameter2);
                }
                OSAEObjectProperty prop = OSAEObjectPropertyManager.GetObjectPropertyValue(method.Parameter1, "JabberID");

                if (prop != null)
                {
                    to = prop.Value;
                }
                else
                {
                    to = method.Parameter1;
                }

                if (to == "")
                {
                    to = method.Parameter1;
                }

                if (gDebug)
                {
                    Log.Debug("To: " + to);
                }

                switch (method.MethodName)
                {
                case "SEND MESSAGE":
                    sendMessage(Common.PatternParse(method.Parameter2), to);
                    break;

                case "SEND FROM LIST":
                    //Speech List here should not be hard coded, but I understand we only have 2 parameters to work with...
                    sendMessage(Common.PatternParse(OSAEObjectPropertyManager.ObjectPropertyArrayGetRandom("Speech List", method.Parameter2)), to);
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error processing command ", ex);
            }
        }
Пример #33
0
 public override void ProcessCommand(OSAEMethod method)
 {
     this.Log.Info("RECEIVED: " + method.ObjectName + " - " + method.MethodName);
     sMethod = method.MethodName;
     camName = method.ObjectName;
     camobj  = OSAEObjectManager.GetObjectByName(camName);
     if (sMethod == "SNAPSHOT")
     {
         string i = DateTime.Now.ToLongTimeString();
         string j = DateTime.Now.ToShortDateString();
         i = i.Replace(":", "_");
         j = j.Replace("/", "_");
         i = j + "_" + i;
         i = i.Replace(" ", "");
         try
         {
             string camSnapShot = camobj.Property("camSnapShot").Value;
             string camSloc     = camobj.Property("Save Location").Value;
             camSloc = camSloc + @"\";
             string    filename = camSloc + camName + "_" + i + ".jpg";
             var       URI      = new Uri(renameingSys(camSnapShot, "", ""));
             WebClient wc       = new WebClient();
             wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
             wc.DownloadFileCompleted  += new AsyncCompletedEventHandler(DownloadFileCallback2);
             wc.DownloadFile(URI, filename);
             this.Log.Info(filename + " was created");
         }
         catch (Exception ex)
         {
             this.Log.Error("An error occurred durning the snapshot!!!: " + ex.Message);
         }
     }
     else
     {
         try
         {
             WebClient wc = new WebClient();
             sProperty = camobj.Property(sMethod).Value.ToString();
             wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
             wc.UploadStringCompleted  += new UploadStringCompletedEventHandler(UploadStringCallback2);
             sProperty = renameingSys(sProperty, method.Parameter1, method.Parameter2);
             wc.UploadStringAsync(new Uri(sProperty), "POST", "");
             this.Log.Info("SENT TO: " + method.ObjectName + ": " + sProperty);
         }
         catch (Exception ex)
         {
             this.Log.Error("An error occurred!!!: " + ex.Message);
         }
     }
     this.Log.Info("===================================================");
 }
 /// <summary>
 /// Starts a plugin based on a method
 /// </summary>
 /// <param name="method">The method containing the information of the plugin to stop</param>
 private void StartPlugin(string serviceName, OSAEMethod method)
 {
     foreach (Plugin p in plugins)
     {
         if (p.PluginName == method.ObjectName)
         {
             OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
             if (obj != null)
             {
                 startPlugin(serviceName, p);
             }
         }
     }
 }
Пример #35
0
        /// <summary>
        /// Runs the content of the script parameter as a powershell script
        /// </summary>
        /// <param name="script">The script to be run</param>
        private void RunScript(string script, OSAEMethod method)
        {
            Pipeline pipeline = null;
            Runspace runspace = null;

            try
            {
                RunspaceConfiguration runConfig = RunspaceConfiguration.Create();

                PSSnapInException psEx = null;

                runConfig.AddPSSnapIn("OSA", out psEx);
                runspace = RunspaceFactory.CreateRunspace(runConfig);
                runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;

                runspace.Open();

                runspace.SessionStateProxy.SetVariable("parameter2", method.Parameter2);

                pipeline = runspace.CreatePipeline();
                pipeline.Commands.AddScript(script);
                pipeline.Commands.Add("Out-String");

                Collection <PSObject> results = pipeline.Invoke();

                StringBuilder stringBuilder = new StringBuilder();
                foreach (PSObject obj in results)
                {
                    stringBuilder.AppendLine(obj.ToString());
                }

                this.Log.Debug("Script return: " + stringBuilder.ToString());
            }
            catch (Exception ex)
            {
                this.Log.Error("An error occured while trying to run the script, details", ex);
            }
            finally
            {
                if (pipeline != null)
                {
                    pipeline.Dispose();
                }
                if (runspace != null)
                {
                    runspace.Close();
                    runspace.Dispose();
                }
            }
        }
Пример #36
0
 /// <summary>
 /// Starts a plugin based on a method
 /// </summary>
 /// <param name="method">The method containing the information of the plugin to stop</param>
 private void StartPlugin(OSAEMethod method)
 {
     foreach (Plugin p in plugins)
     {
         if (p.PluginName == method.Parameter1)
         {
             OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
             if (obj != null)
             {
                 enablePlugin(p);
             }
         }
     }
 }
Пример #37
0
 /// <summary>
 /// Stops a plugin based on a method
 /// </summary>
 /// <param name="method">The method containing the information of the plugin to stop</param>
 private void StopPlugin(OSAEMethod method)
 {
     foreach (Plugin p in plugins)
     {
         if (p.PluginName == method.Parameter1)
         {
             OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
             if (obj != null)
             {
                 disablePlugin(p);
                 UDPConnection.SendObject("Plugin", p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Stopped | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051));
             }
         }
     }
 }
        /// <summary>
        /// A Command to be processed bu the plugin
        /// </summary>
        /// <param name="method"></param>
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string script = OSAEScriptManager.GetScript(method.Parameter1);

                logging.AddToLog("running script: " + script, false);

                RunScript(script, method);
            }
            catch (Exception exc)
            {
                logging.AddToLog("Error Processing Command: " + exc.Message, true);
            }
        }
 /// <summary>
 /// Stops a plugin based on a method
 /// </summary>
 /// <param name="method">The method containing the information of the plugin to stop</param>
 private void StopPlugin(OSAEMethod method)
 {
     foreach (Plugin p in plugins)
     {
         if (p.PluginName == method.Parameter1)
         {
             OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
             if (obj != null)
             {
                 disablePlugin(p);
                 sendMessageToClients(WCF.OSAEWCFMessageType.PLUGIN, p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Stopped | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName);
             }
         }
     }
 }
Пример #40
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;

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

            if (object_name == pName)
            {

                switch (method_name)
                {

                    case "NOTIFYALL":
                        log("NOTIFYALL event triggered", false);

                        log("NOTIFYALL devices to loop:"+mdevices.Count, false);

                        foreach (AndroidDevice d in mdevices)
                        {
                            log("NOTIFYALL loop for device:"+d.Name, false);
                            d.ProcessCommand("NOTIFY", parameter_1, parameter_2);
                        }

                        break;

                }
            }
            else
            {
                AndroidDevice d = getAndroidDevice(object_name);

                if (d == null)
                {
                    OSAEObject obj = OSAEObjectManager.GetObjectByName(object_name);
                    createdevice(obj);
                    d = getAndroidDevice(object_name);
                }

                if (d != null)
                {
                    d.ProcessCommand(method_name, parameter_1, parameter_2);
                }

            }
        }
        public override void ProcessCommand(OSAEMethod method)
        {
            string sMethod = method.MethodName;
            string sParam1 = method.Parameter1;
            string sParam2 = method.Parameter2;

            if (gDebug) Log.Debug("Received Command to: " + sMethod + " (" + sParam1 + ", " + sParam2 + ")");

            if (sMethod == "SENDMESSAGE")
            {
                string sText = Common.PatternParse(sParam1);
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Speaking", "TRUE", gAppName);
                Thread.Sleep(500);
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Speaking", "FALSE", gAppName);
            }
        }
Пример #42
0
 /// <summary>
 /// OSA Plugin Interface - Commands the be processed by the plugin
 /// </summary>
 /// <param name="method">Method containging the command to run</param>
 public override void ProcessCommand(OSAEMethod method)
 {
     Log.Info("Processing Method: " + method.MethodLabel);
     //No commands to process
     if (method.MethodLabel == "GenerateApiKey")
     {
         OSAESecurity.GenerateAPIKey();
     }
     if (method.MethodLabel == "GenerateSecurityKey")
     {
         OSAESecurity.GenerateSecurityKey();
     }
     if (method.MethodLabel == "GenerateCurrentAuthKey")
     {
         Log.Info("currentAPIAuthKey: " + OSAESecurity.generateCurrentAuthKey(method.Parameter1));
     }
 }
Пример #43
0
        public void ProcessCommand(OSAEMethod method)
        {
            try
            {
                //basically just need to send parameter two to the contact in parameter one with sendMessage();
                //Process incomming command
                string to = "";
                osae.AddToLog("Process command: " + method.MethodName, false);
                osae.AddToLog("Message: " + method.Parameter2, false);
                osae.AddToLog("To: " + method.Parameter1, false);
                ObjectProperty prop = osae.GetObjectPropertyValue(method.Parameter1, "JabberID");
                if (prop != null)
                {
                    to = prop.Value;
                }
                if (to == "")
                {
                    to = method.Parameter1;
                }
                else
                {
                    to = method.Parameter1;
                }

                if (to == "")
                {
                    to = method.Parameter1;
                }

                switch (method.MethodName)
                {
                case "SEND MESSAGE":
                    sendMessage(osae.PatternParse(method.Parameter2), to);
                    break;

                case "SEND FROM LIST":
                    sendMessage(osae.PatternParse(osae.ObjectPropertyArrayGetRandom("Speech List", method.Parameter2)), to);
                    break;
                }
            }
            catch (Exception ex)
            {
                osae.AddToLog("Error processing command: " + ex.Message, true);
            }
        }
Пример #44
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);
                    
                }
            }
        }
Пример #45
0
 /// <summary>
 /// OSA Plugin Interface - Commands the be processed by the plugin
 /// </summary>
 /// <param name="method">Method containging the command to run</param>
 public override void ProcessCommand(OSAEMethod method)
 {
     Log.Info("Processing Method: " + method.MethodLabel);
     //No commands to process
     if (method.MethodLabel == "GenerateApiKey")
     {
         OSAEObjectPropertyManager.ObjectPropertySet("Rest", "APIKEY", OSAESecurity.GenerateAPIKey(), "Rest");
         Log.Debug("New APIKEY Generated");
     }
     if (method.MethodLabel == "GenerateSecurityKey")
     {
         OSAEObjectPropertyManager.ObjectPropertySet("System", "SecurityKey", OSAESecurity.GenerateSecurityKey(), "Rest");
         Log.Debug("New SecurityKey Generated");
     }
     if (method.MethodLabel == "GenerateCurrentAuthKey")
     {
         Log.Info("currentAPIAuthKey: " + OSAESecurity.generateCurrentAuthKey(method.Parameter1));
     }
 }
Пример #46
0
        public override void ProcessCommand(OSAEMethod method)
        {
            string sMethod = method.MethodName;
            string sParam1 = method.Parameter1;
            string sParam2 = method.Parameter2;

            if (gDebug)
            {
                Log.Debug("Received Command to: " + sMethod + " (" + sParam1 + ", " + sParam2 + ")");
            }

            if (sMethod == "SENDMESSAGE")
            {
                string sText = Common.PatternParse(sParam1);
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Speaking", "TRUE", gAppName);
                Thread.Sleep(500);
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Speaking", "FALSE", gAppName);
            }
        }
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string[] tmp = method.Parameter1.Split('/');
                server = tmp[0];
                username = tmp[1];
                password = tmp[2];
                string command = method.Parameter2;
                Log.Debug("Sending command: " + command + " | " + server + " | " + username + " | " + password);
                SshExec ssh = new SshExec(server, username, password);
                ssh.Connect();

                string response = ssh.RunCommand(command);
                Log.Debug("Response: " + response);
                ssh.Close();
            }
            catch (Exception ex)
            { Log.Error("Error Sending command", ex); }
        }
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                //basically just need to send parameter two to the contact in parameter one with sendMessage();
                //Process incomming command
                string to = "";
                if (gDebug) Log.Debug("Process command: " + method.MethodName);
                if (gDebug) Log.Debug("Message: " + method.Parameter2);
                OSAEObjectProperty prop = OSAEObjectPropertyManager.GetObjectPropertyValue(method.Parameter1, "JabberID");

                if(prop != null)
                    to = prop.Value;
                else
                    to = method.Parameter1;

                if (to == "") to = method.Parameter1;

                if (gDebug) Log.Debug("To: " + to);

                switch (method.MethodName)
                {
                    case "SEND MESSAGE":
                        sendMessage(Common.PatternParse(method.Parameter2), to);
                        break;

                    case "SEND QUESTION":
                        Ask_Question(to);
                        break;

                    case "SEND FROM LIST":
                        string speechList = method.Parameter2.Substring(0,method.Parameter2.IndexOf(","));
                        string listItem = method.Parameter2.Substring(method.Parameter2.IndexOf(",") + 1, method.Parameter2.Length - (method.Parameter2.IndexOf(",")+ 1));
                        if (gDebug) Log.Debug("List = " + speechList + "   Item=" + listItem);
                        sendMessage(Common.PatternParse(OSAEObjectPropertyManager.ObjectPropertyArrayGetRandom(speechList, listItem)), to);
                        break;
                }
            }
            catch (Exception ex)
            { Log.Error("Error in ProcessCommand!", ex); }
        }
Пример #49
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string[] tmp = method.Parameter1.Split('/');
                server = tmp[0];
                username = tmp[1];
                password = tmp[2];
                string command = method.Parameter2;
                logging.AddToLog("Sending command: " + command + " | " + server + " | " + username + " | " + password, false);
                SshExec ssh = new SshExec(server, username, password);
                ssh.Connect();

                string response = ssh.RunCommand(command);
                logging.AddToLog("Response: " + response, false);
                ssh.Close();
            }
            catch (Exception ex)
            {
                logging.AddToLog("Error Sending command - " + ex.Message + " -" + ex.InnerException, true);
            }
        }
Пример #50
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                //basically just need to send parameter two to the contact in parameter one with sendMessage();
                //Process incomming command
                string to = "";
                this.Log.Debug("Process command: " + method.MethodName);
                this.Log.Debug("Message: " + method.Parameter2);
                OSAEObjectProperty prop = OSAEObjectPropertyManager.GetObjectPropertyValue(method.Parameter1, "JabberID");

                if(prop != null)
                    to = prop.Value;
                else
                    to = method.Parameter1;

                if (to == "")
                    to = method.Parameter1;

                this.Log.Debug("To: " + to);

                switch (method.MethodName)
                {
                    case "SEND MESSAGE":
                        sendMessage(Common.PatternParse(method.Parameter2), to);
                        break;

                    case "SEND FROM LIST":
                        //Speech List here should not be hard coded, but I understand we only have 2 parameters to work with...
                        sendMessage(Common.PatternParse(OSAEObjectPropertyManager.ObjectPropertyArrayGetRandom("Speech List", method.Parameter2)), to);
                        break;
                }
            }
            catch (Exception ex)
            {
                this.Log.Error("Error processing command ", ex);
            }
        }
Пример #51
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                //basically just need to send parameter two to the contact in parameter one with sendMessage();
                //Process incomming command
                string to = "";
                logging.AddToLog("Process command: " + method.MethodName, false);
                logging.AddToLog("Message: " + method.Parameter2, false);
                logging.AddToLog("To: " + method.Parameter1, false);
                OSAEObjectProperty prop = OSAEObjectPropertyManager.GetObjectPropertyValue(method.Parameter1, "JabberID");
                if(prop != null)
                    to = prop.Value;
                    if (to == "")
                        to = method.Parameter1;
                else
                    to = method.Parameter1;

                if (to == "")
                    to = method.Parameter1;

                switch (method.MethodName)
                {
                    case "SEND MESSAGE":
                        sendMessage(Common.PatternParse(method.Parameter2), to);
                        break;

                    case "SEND FROM LIST":
                        sendMessage(Common.PatternParse(OSAEObjectPropertyManager.ObjectPropertyArrayGetRandom("Speech List", method.Parameter2)), to);
                        break;
                }
            }
            catch (Exception ex)
            {
                logging.AddToLog("Error processing command: " +ex.Message, true);
            }
        }
Пример #52
0
 /// <summary>
 /// OSA Plugin Interface - Commands the be processed by the plugin
 /// </summary>
 /// <param name="method">Method containging the command to run</param>
 public override void ProcessCommand(OSAEMethod method)
 {
     // place the plugin command code here leave empty if unable to process commands
 }
Пример #53
0
        public override void ProcessCommand(OSAEMethod method)
        {
            this.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")
                    {

                    }

                }
            }
        }
Пример #54
0
 public override void ProcessCommand(OSAEMethod method)
 {
     //This plugin does not have commands
 }
Пример #55
0
        public override void ProcessCommand(OSAEMethod method)
        {
            //process command
            try
            {
                string to = string.Empty;
                string parameter2 = string.Empty;
                string subject = string.Empty;
                string body = string.Empty;
                OSAEObjectProperty prop = OSAEObjectPropertyManager.GetObjectPropertyValue(method.Parameter1, "Email Address");
                if (prop != null)
                {
                    to = prop.Value;
                }

                if (to == string.Empty)
                {
                    to = method.Parameter1;
                }

                // To
                MailMessage mailMsg = new MailMessage();
                mailMsg.To.Add(to);

                // From
                MailAddress mailAddress = new MailAddress(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "From Address").Value);
                mailMsg.From = mailAddress;

                // Subject and Body
                mailMsg.Subject = "Message from OSAE";
                mailMsg.Body = Common.PatternParse(method.Parameter2);
                parameter2 = Common.PatternParse(method.Parameter2);

                // Make sure there is a body of text.
                if (parameter2.Equals(string.Empty))
                {
                    throw new ArgumentOutOfRangeException("Message body missing.");
                }

                // See if there is a subject.
                // Opening delimiter in first char is good indication of subject.
                if (parameter2[0] == ':')
                {
                    // Find clossing delimiter
                    int i = parameter2.IndexOf(':', 1);
                    if (i != -1)
                    {
                        subject = parameter2.Substring(1, i - 1);
                        body = parameter2.Substring(i + 1, parameter2.Length - i - 1);
                    }
                }

                if (subject.Equals(string.Empty))
                {
                    mailMsg.Subject = "Message from OSAE";
                    mailMsg.Body = parameter2;
                }
                else
                {
                    mailMsg.Subject = subject;
                    mailMsg.Body = body;
                }

                // Init SmtpClient and send
                SmtpClient smtpClient = new SmtpClient(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "SMTP Server").Value, int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "SMTP Port").Value));
                if (OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "ssl").Value == "TRUE")
                {
                    smtpClient.EnableSsl = true;
                }
                else
                {
                    smtpClient.EnableSsl = false;
                }

                smtpClient.Timeout = 10000;
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new NetworkCredential(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Username").Value, OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Password").Value);

                this.Log.Info("to: " + mailMsg.To);
                this.Log.Info("from: " + mailMsg.From);
                this.Log.Info("subject: " + mailMsg.Subject);
                this.Log.Info("body: " + mailMsg.Body);
                this.Log.Info("smtpServer: " + OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "SMTP Server").Value);
                this.Log.Info("smtpPort: " + OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "SMTP Port").Value);
                this.Log.Info("username: "******"Username").Value);
                this.Log.Info("password: "******"Password").Value);
                this.Log.Info("ssl: " + OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "ssl").Value);

                smtpClient.Send(mailMsg);
            }
            catch (Exception ex)
            {
                this.Log.Error("Error Sending email" , ex);
            }
        }
 /// <summary>
 /// Starts a plugin based on a method
 /// </summary>
 /// <param name="method">The method containing the information of the plugin to stop</param>
 private void StartPlugin(OSAEMethod method)
 {
     foreach (Plugin p in plugins)
     {
         if (p.PluginName == method.Parameter1)
         {
             OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
             if (obj != null)
             {
                 enablePlugin(p);
             }
         }
     }
 }
Пример #57
0
        public void ProcessCommand(OSAEMethod method)
        {
            osae.AddToLog("Found Command: " + method.MethodName + " | param1: " + method.Parameter1 + " | param2: " + method.Parameter2 + " | obj: " + method.ObjectName, false);
            //process command
            try
            {
                if (method.Address.Length > 0)
                {
                    int address;
                    byte instance = 0;
                    byte nid;
                    if (int.TryParse(method.Address.Substring(1), out address))
                    {
                        nid = (byte)address;
                    }
                    else
                    {
                        nid = (byte)Int32.Parse(method.Address.Substring(1).Split('-')[0]);
                        instance = (byte)Int32.Parse(method.Address.Substring(1).Split('-')[1]);
                    }
                    Node node = GetNode(m_homeId, nid);

                    if (method.MethodName == "NODE NEIGHBOR UPDATE")
                    {
                        osae.AddToLog("Requesting Node Neighbor Update: " + osae.GetObjectByAddress("Z" + nid.ToString()).Name, true);
                        m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                        if (!m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.RequestNodeNeighborUpdate, false, nid))
                        {
                            osae.AddToLog("Request Node Neighbor Update Failed: " + osae.GetObjectByAddress("Z" + nid.ToString()).Name, true);
                            m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                        }
                    }
                    else if (method.MethodName == "ENABLE POLLING")
                        enablePolling(nid);
                    else
                    {
                        switch (node.Label)
                        {
                            #region Binary Switch
                            case "Binary Switch":
                            case "Binary Power Switch":
                                if (method.MethodName == "ON")
                                {
                                    if (instance != 0)
                                    {
                                        foreach (Value value in node.Values)
                                        {
                                            if (value.Label == "Switch" && value.ValueID.GetInstance() == instance)
                                                m_manager.SetValue(value.ValueID, true);
                                        }

                                    }
                                    else
                                        m_manager.SetNodeOn(m_homeId, nid);
                                    osae.ObjectStateSet(method.ObjectName, "ON");
                                    osae.AddToLog("Turned light on: " + method.ObjectName, false);
                                }
                                else
                                {
                                    if (instance != 0)
                                    {
                                        foreach (Value value in node.Values)
                                        {
                                            if (value.Label == "Switch" && value.ValueID.GetInstance() == instance)
                                                m_manager.SetValue(value.ValueID, false);
                                        }

                                    }
                                    else
                                        m_manager.SetNodeOff(m_homeId, nid);
                                    osae.ObjectStateSet(method.ObjectName, "OFF");
                                    osae.AddToLog("Turned light off: " + method.ObjectName, false);
                                }
                                break;
                            #endregion

                            #region Dimmers
                            case "Multilevel Switch":
                            case "Multilevel Power Switch":
                            case "Multilevel Scene Switch":
                                if (method.MethodName == "ON")
                                {
                                    byte lvl;
                                    if (method.Parameter1 != "")
                                        lvl = (byte)Int32.Parse(method.Parameter1);
                                    else if (osae.GetObjectPropertyValue(method.ObjectName, "Default Dim").Value != "")
                                        lvl = (byte)Int32.Parse(osae.GetObjectPropertyValue(method.ObjectName, "Default Dim").Value);
                                    else
                                        lvl = (byte)100;

                                    m_manager.SetNodeLevel(m_homeId, nid, lvl);
                                    osae.ObjectStateSet(method.ObjectName, "ON");
                                    osae.AddToLog("Turned light on: " + method.ObjectName + "|" + method.Parameter1, false);
                                }
                                else
                                {
                                    m_manager.SetNodeOff(m_homeId, nid);
                                    osae.ObjectStateSet(method.ObjectName, "OFF");
                                    osae.AddToLog("Turned light off: " + method.ObjectName, false);
                                }
                                break;
                            #endregion

                            #region Thermostats
                            case "General Thermostat V2":
                                if (method.MethodName == "ON")
                                {
                                    m_manager.SetNodeOn(m_homeId, nid);
                                    osae.ObjectStateSet(method.ObjectName, "ON");
                                    osae.AddToLog("Turned thermostat on: " + method.ObjectName, false);
                                }
                                else if (method.MethodName == "OFF")
                                {
                                    m_manager.SetNodeOff(m_homeId, nid);
                                    osae.ObjectStateSet(method.ObjectName, "OFF");
                                    osae.AddToLog("Turned thermostat off: " + nid.ToString(), false);
                                }
                                else if (method.MethodName == "COOLSP")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Cooling 1")
                                        {
                                            m_manager.SetValue(value.ValueID, Convert.ToSingle(method.Parameter1));
                                            osae.AddToLog("Set cool target temperature to " + method.Parameter1 + ": " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "HEATSP")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Heating 1")
                                        {
                                            m_manager.SetValue(value.ValueID, Convert.ToSingle(method.Parameter1));
                                            osae.AddToLog("Set heat target temperature to " + method.Parameter1 + ": " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "UNIT OFF")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Mode")
                                        {
                                            m_manager.SetValueListSelection(value.ValueID, "Off");
                                            osae.AddToLog("Set Unit Mode to Off: " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "HEAT")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Mode")
                                        {
                                            m_manager.SetValueListSelection(value.ValueID, "Heat");
                                            osae.AddToLog("Set Unit Mode to Heat: " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "COOL")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Mode")
                                        {
                                            m_manager.SetValueListSelection(value.ValueID, "Cool");
                                            osae.AddToLog("Set Unit Mode to Cool: " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "AUTO")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Mode")
                                        {
                                            m_manager.SetValueListSelection(value.ValueID, "Auto");
                                            osae.AddToLog("Set Unit Mode to Auto: " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "AUX HEAT")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Mode")
                                        {
                                            m_manager.SetValueListSelection(value.ValueID, "Aux Heat");
                                            osae.AddToLog("Set Unit Mode to Aux Heat: " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "FAN ON")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Fan Mode")
                                        {
                                            m_manager.SetValueListSelection(value.ValueID, "On Low");
                                            osae.AddToLog("Set Fan Mode to On: " + method.ObjectName, false);
                                        }
                                    }
                                }
                                else if (method.MethodName == "FAN AUTO")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Fan Mode")
                                        {
                                            m_manager.SetValueListSelection(value.ValueID, "Auto Low");
                                            osae.AddToLog("Set Fan Mode to Auto: " + method.ObjectName, false);
                                        }
                                    }
                                }
                                break;
                            #endregion

                            #region MultiSensor
                            case "Binary Routing Sensor":
                                if (method.MethodName == "SET WAKEUP INTERVAL")
                                {
                                    foreach (Value value in node.Values)
                                    {
                                        if (value.Label == "Wake-up Interval")
                                        {
                                            m_manager.SetValue(value.ValueID, Convert.ToSingle(method.Parameter1));
                                            osae.AddToLog("Set wake-up interval to " + method.Parameter1 + ": " + method.ObjectName, false);
                                        }
                                    }
                                }
                                break;
                            #endregion
                        }
                    }
                }
                else
                {
                    #region Controller Commands
                    try
                    {
                        byte nid = 0xff;
                        if (method.Parameter1 != "")
                            nid = (byte)Int32.Parse(method.Parameter1.Substring(1));

                        switch (method.MethodName)
                        {
                            case "ADD CONTROLLER":
                                m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                                if (!m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.AddController, false, nid))
                                {
                                    osae.AddToLog("Add Controller Failed", true);
                                    m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                                }
                                //osae.MethodQueueAdd(osae.GetPluginName("GUI CLIENT", osae.ComputerName), "POPUP MESSAGE", "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller being added.", "");
                                break;
                            case "REMOVE CONTROLLER":
                                m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                                if (!m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.RemoveController, false, nid))
                                {
                                    osae.AddToLog("Remove Controller Failed", true);
                                    m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                                }
                                //osae.MethodQueueAdd(osae.GetPluginName("GUI CLIENT", osae.ComputerName), "POPUP MESSAGE", "Put the target controller into receive configuration mode.\nThe PC Z-Wave Controller must be within 2m of the controller being removed.", "");
                                break;
                            case "ADD DEVICE":
                                m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                                if (!m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.AddDevice, false, nid))
                                {
                                    osae.AddToLog("Add Device Failed", true);
                                    m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                                }
                                //osae.MethodQueueAdd(osae.GetPluginName("GUI CLIENT", osae.ComputerName), "POPUP MESSAGE", "Press the program button on the Z-Wave device to add it to the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being added.", "");
                                break;
                            case "REMOVE DEVICE":
                                m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                                if (m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.RemoveDevice, false, nid))
                                {
                                    osae.ObjectDelete(osae.GetObjectByAddress("Z" + nid.ToString()).Name);
                                }
                                else
                                {
                                    osae.AddToLog("Remove Device Failed", true);
                                    m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                                }
                                //osae.MethodQueueAdd(osae.GetPluginName("GUI CLIENT", osae.ComputerName), "POPUP MESSAGE", "Press the program button on the Z-Wave device to remove it from the network.\nFor security reasons, the PC Z-Wave Controller must be close to the device being removed.", "");
                                break;
                            case "REMOVE FAILED NODE":
                                m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                                if (m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.RemoveFailedNode, false, nid))
                                {
                                    osae.ObjectDelete(osae.GetObjectByAddress("Z" + nid.ToString()).Name);
                                }
                                else
                                {
                                    osae.AddToLog("Remove Failed Node Failed: Z" + nid.ToString(), true);
                                    m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                                }
                                break;
                            case "RESET CONTROLLER":
                                osae.AddToLog("Resetting Controller and deleting all ZWave objects", true);
                                m_manager.ResetController(m_homeId);
                                //DataSet ds = osae.GetObjectsByType("ZWAVE DIMMER");
                                //foreach (DataRow dr in ds.Tables[0].Rows)
                                //    osae.ObjectDelete(dr["object_name"].ToString());
                                //ds = osae.GetObjectsByType("ZWAVE BINARY SWITCH");
                                //foreach (DataRow dr in ds.Tables[0].Rows)
                                //    osae.ObjectDelete(dr["object_name"].ToString());
                                //ds = osae.GetObjectsByType("ZWAVE THERMOSTAT");
                                //foreach (DataRow dr in ds.Tables[0].Rows)
                                //    osae.ObjectDelete(dr["object_name"].ToString());
                                break;
                            case "NODE NEIGHBOR UPDATE":
                                osae.AddToLog("Requesting Node Neighbor Update: Z" + nid.ToString(), true);
                                m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                                if (!m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.RequestNodeNeighborUpdate, false, nid))
                                {
                                    osae.AddToLog("Request Node Neighbor Update Failed: Z" + nid.ToString(), true);
                                    m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                                }
                                break;
                            case "NETWORK UPDATE":
                                osae.AddToLog("Requesting Network Update", true);
                                m_manager.OnControllerStateChanged += m_controllerStateChangedHandler;
                                if (!m_manager.BeginControllerCommand(m_homeId, ZWControllerCommand.RequestNetworkUpdate, false, nid))
                                {
                                    osae.AddToLog("Request Network Update Failed: Z" + nid.ToString(), true);
                                    m_manager.OnControllerStateChanged -= m_controllerStateChangedHandler;
                                }
                                break;
                            case "ENABLE POLLING":
                                enablePolling(nid);
                                break;
                        }

                    }
                    catch (Exception ex)
                    {
                        osae.AddToLog("Controller command failed (" + method.MethodName + "): " + ex.Message + " -- " + ex.StackTrace
                            + " -- " + ex.InnerException, true);
                    }
                    #endregion
                }

            }
            catch (Exception ex)
            {
                osae.AddToLog("Error Processing Command - " + ex.Message + " -" + ex.InnerException, true);
            }
        }
 /// <summary>
 /// Stops a plugin based on a method
 /// </summary>
 /// <param name="method">The method containing the information of the plugin to stop</param>
 private void StopPlugin(OSAEMethod method)
 {
     foreach (Plugin p in plugins)
     {
         if (p.PluginName == method.Parameter1)
         {
             OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName);
             if (obj != null)
             {
                 disablePlugin(p);
                 UDPConnection.SendObject("Plugin", p.PluginName + " | " + p.Enabled.ToString() + " | " + p.PluginVersion + " | Stopped | " + p.LatestAvailableVersion + " | " + p.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10000));
             }
         }
     }
 }
 public override void ProcessCommand(OSAEMethod method)
 {
     // No commands
 }
        public override void ProcessCommand(OSAEMethod method)
        {
            logging.AddToLog("--------------Processing Command---------------", false);
            logging.AddToLog("Command: " + method.MethodName, false);

            OSAEObject obj = OSAEObjectManager.GetObjectByName(method.ObjectName);
            logging.AddToLog("Object Name: " + obj.Name, false);
            logging.AddToLog("Object Type: " + obj.Type, false);
            logging.AddToLog("Object Adress: " + obj.Address, false);

            try
            {
                byte[] kar;

                switch (obj.Type)
                {
                    #region Lighting 1

                    case "X10 RELAY":
                    case "ARC BINARY SWITCH":
                    case "ELRO BINARY SWITCH":
                    case "WAVEMAN BINARY SWITCH":
                    case "EMW200 BINARY SWITCH":
                    case "RISING SUN BINARY SWITCH":
                    case "IMPULS BINARY SWITCH":
                        logging.AddToLog("Executing Lighting1 command", false);

                        kar = new byte[(byte)LIGHTING1.size + 1];
                        byte type_l1 = 0;

                        switch (obj.Type)
                        {
                            case "X10 RELAY":
                                type_l1 = (byte)LIGHTING1.sTypeX10;
                                break;
                            case "ARC BINARY SWITCH":
                                type_l1 = (byte)LIGHTING1.sTypeARC;
                                break;
                            case "ELRO BINARY SWITCH":
                                type_l1 = (byte)LIGHTING1.sTypeAB400D;
                                break;
                            case "WAVEMAN BINARY SWITCH":
                                type_l1 = (byte)LIGHTING1.sTypeWaveman;
                                break;
                            case "EMW200 BINARY SWITCH":
                                type_l1 = (byte)LIGHTING1.sTypeEMW200;
                                break;
                            case "IMPULS BINARY SWITCH":
                                type_l1 = (byte)LIGHTING1.sTypeIMPULS;
                                break;
                            case "RISING SUN BINARY SWITCH":
                                type_l1 = (byte)LIGHTING1.sTypeRisingSun;
                                break;
                        }

                        kar[(byte)LIGHTING1.packetlength] = (byte)LIGHTING1.size;
                        kar[(byte)LIGHTING1.packettype] = (byte)LIGHTING1.pType;
                        kar[(byte)LIGHTING1.subtype] = type_l1;
                        kar[(byte)LIGHTING1.seqnbr] = bytSeqNbr;
                        kar[(byte)LIGHTING1.housecode] = (byte)Convert.ToInt32(obj.Address.Substring(0, 1));
                        kar[(byte)LIGHTING1.unitcode] = (byte)Convert.ToInt32(obj.Address.Substring(1));
                        switch (method.MethodName)
                        {
                            case "OFF":
                                kar[(byte)LIGHTING1.cmnd] = (byte)LIGHTING1.sOff;
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", pName);
                                break;
                            case "ON":
                                kar[(byte)LIGHTING1.cmnd] = (byte)LIGHTING1.sOn;
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", pName);
                                break;
                            case "ALL OFF":
                                kar[(byte)LIGHTING1.cmnd] = (byte)LIGHTING1.sAllOff;
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", pName);
                                break;
                            case "ALL ON":
                                kar[(byte)LIGHTING1.cmnd] = (byte)LIGHTING1.sAllOn;
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", pName);
                                break;
                            case "CHIME":
                                kar[(byte)LIGHTING1.cmnd] = (byte)LIGHTING1.sChime;
                                kar[(byte)LIGHTING1.unitcode] = 8;
                                break;
                        }
                        kar[(byte)LIGHTING1.filler] = 0;

                        WriteCom(kar);
                        string command = "";
                        foreach (byte bt in kar)
                        {
                            command += ("0" + bt.ToString()).Substring(("0" + bt.ToString()).Length - 2) + " ";
                        }
                        logging.AddToLog("Lighting1 command:" + command, false);

                        break;
                    #endregion

                    #region Lighting 2

                    case "AC DIMMER SWITCH":
                    case "HEU DIMMER SWITCH":
                    case "ANSLUT DIMMER SWITCH":
                        logging.AddToLog("Executing Lighting2 command", false);

                        kar = new byte[(byte)LIGHTING2.size + 1];
                        string[] addr = obj.Address.Split('-');

                        byte type_l2 = 0;

                        switch (obj.Type)
                        {
                            case "AC DIMMER SWITCH":
                                type_l2 = (byte)LIGHTING2.sTypeAC;
                                break;
                            case "HEU DIMMER SWITCH":
                                type_l2 = (byte)LIGHTING2.sTypeHEU;
                                break;
                            case "ANSLUT DIMMER SWITCH":
                                type_l2 = (byte)LIGHTING2.sTypeANSLUT;
                                break;
                        }

                        kar[(byte)LIGHTING2.packetlength] = (byte)LIGHTING2.size;
                        kar[(byte)LIGHTING2.packettype] = (byte)LIGHTING2.pType;
                        kar[(byte)LIGHTING2.subtype] = type_l2;
                        kar[(byte)LIGHTING2.seqnbr] = bytSeqNbr;
                        kar[(byte)LIGHTING2.id1] = (byte)Int32.Parse(addr[0], System.Globalization.NumberStyles.HexNumber);
                        kar[(byte)LIGHTING2.id2] = (byte)Int32.Parse(addr[1], System.Globalization.NumberStyles.HexNumber);
                        kar[(byte)LIGHTING2.id3] = (byte)Int32.Parse(addr[2], System.Globalization.NumberStyles.HexNumber);
                        kar[(byte)LIGHTING2.id4] = (byte)Int32.Parse(addr[3], System.Globalization.NumberStyles.HexNumber);
                        kar[(byte)LIGHTING2.unitcode] = (byte)Int32.Parse(addr[4]);

                        switch (method.MethodName)
                        {
                            case "OFF":
                                kar[(byte)LIGHTING2.cmnd] = (byte)LIGHTING2.sOff;
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", pName);
                                break;
                            case "ON":
                                if (method.Parameter1 != "")
                                {
                                    kar[(byte)LIGHTING2.cmnd] = (byte)LIGHTING2.sOn;
                                    kar[(byte)LIGHTING2.level] = (byte)0;
                                }
                                else
                                {
                                    kar[(byte)LIGHTING2.cmnd] = (byte)LIGHTING2.sOn;
                                    //kar[(byte)LIGHTING2.level] = (byte)Math.Round((double)Int32.Parse(method.Parameter1) / 7, 0);
                                }
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", pName);

                                break;
                        }

                        kar[(byte)LIGHTING2.filler] = 0;

                        logging.AddToLog("Writing command. len: " + kar.Length.ToString(), false);
                        WriteCom(kar);
                        string command_l2 = "";
                        foreach (byte bt in kar)
                        {
                            command_l2 += ("0" + bt.ToString("X")).Substring(("0" + bt.ToString("X")).Length - 2) + " ";
                        }
                        logging.AddToLog("Lighting2 command:" + command_l2, false);
                        break;

                    #endregion

                    #region Lighting 5

                    case "LIGHTWAVERF DIMMER SWITCH":
                    case "EMW100 BINARY SWITCH":
                        logging.AddToLog("Executing Lighting5 command", false);

                        kar = new byte[(byte)LIGHTING5.size + 1];
                        logging.AddToLog("Lighting 5 device", false);

                        if (bytFWversion < 29)
                        {
                            logging.AddToLog("RFXtrx433 firmware version must be > 28, flash your RFXtrx433 with the latest firmware", true);
                            return;
                        }

                        string[] l5_addr = obj.Address.Split('-');
                        if (l5_addr.Length != 4)
                        {
                            logging.AddToLog("invalid unit address", true);
                            break;
                        }
                        else
                        {
                            byte subtype = (byte)0;
                            if (obj.Type == "LIGHTWAVERF DIMMER SWITCH")
                            {
                                subtype = (byte)0;
                            }
                            else if (obj.Type == "EMW100 BINARY SWITCH")
                            {
                                subtype = (byte)1;
                            }
                            kar[(byte)LIGHTING5.packetlength] = (byte)LIGHTING5.size;
                            logging.AddToLog("kar[(byte)LIGHTING5.packetlength]: " + kar[(byte)LIGHTING5.packetlength].ToString(), false);
                            kar[(byte)LIGHTING5.packettype] = (byte)LIGHTING5.pType;
                            logging.AddToLog("kar[(byte)LIGHTING5.packettype]: " + kar[(byte)LIGHTING5.packettype].ToString(), false);
                            kar[(byte)LIGHTING5.subtype] = subtype;
                            logging.AddToLog("kar[(byte)LIGHTING5.subtype]: " + subtype.ToString(), false);
                            kar[(byte)LIGHTING5.seqnbr] = bytSeqNbr;
                            logging.AddToLog("kar[(byte)LIGHTING5.seqnbr]: " + bytSeqNbr.ToString(), false);
                            kar[(byte)LIGHTING5.id1] = (byte)Int32.Parse(l5_addr[0]);
                            logging.AddToLog("kar[(byte)LIGHTING5.id1]: " + l5_addr[0], false);
                            kar[(byte)LIGHTING5.id2] = (byte)Int32.Parse(l5_addr[1]);
                            logging.AddToLog("kar[(byte)LIGHTING5.id2]: " + l5_addr[1], false);
                            kar[(byte)LIGHTING5.id3] = (byte)Int32.Parse(l5_addr[2]);
                            logging.AddToLog("kar[(byte)LIGHTING5.id3]: " + l5_addr[2], false);
                            kar[(byte)LIGHTING5.unitcode] = (byte)Int32.Parse(l5_addr[3]);
                            logging.AddToLog("kar[(byte)LIGHTING5.unitcode]: " + l5_addr[3], false);

                            switch (method.MethodName)
                            {
                                case "OFF":
                                    kar[(byte)LIGHTING5.cmnd] = (byte)LIGHTING5.sOff;
                                    logging.AddToLog("kar[(byte)LIGHTING5.cmnd]: " + kar[(byte)LIGHTING5.cmnd].ToString(), false);
                                    OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF",pName);
                                    break;
                                case "ON":
                                    if (method.Parameter1 == "")
                                    {
                                        kar[(byte)LIGHTING5.cmnd] = (byte)LIGHTING5.sOn;
                                        logging.AddToLog("kar[(byte)LIGHTING5.cmnd]: " + kar[(byte)LIGHTING5.cmnd].ToString(), false);
                                        kar[(byte)LIGHTING5.level] = 0;
                                        logging.AddToLog("kar[(byte)LIGHTING5.level]: " + kar[(byte)LIGHTING5.level].ToString(), false);
                                    }
                                    else
                                    {
                                        kar[(byte)LIGHTING5.cmnd] = (byte)LIGHTING5.sSetLevel;
                                        logging.AddToLog("kar[(byte)LIGHTING5.cmnd]: " + kar[(byte)LIGHTING5.cmnd].ToString(), false);
                                        kar[(byte)LIGHTING5.level] = (byte)Math.Round((double)Int32.Parse(method.Parameter1) / 3, 0);
                                        logging.AddToLog("kar[(byte)LIGHTING5.level]: " + kar[(byte)LIGHTING5.level].ToString(), false);
                                    }
                                    OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON",pName);

                                    break;
                            }

                            kar[(byte)LIGHTING5.filler] = 0;
                            logging.AddToLog("kar[(byte)LIGHTING5.filler]: " + kar[(byte)LIGHTING5.filler].ToString(), false);

                            //not used commands
                            if (kar[(byte)LIGHTING5.cmnd] == 8 | kar[(byte)LIGHTING5.cmnd] == 9)
                            {
                                logging.AddToLog("not used command", true);
                                return;
                            }

                            if (kar[(byte)LIGHTING5.id1] == 0 & kar[(byte)LIGHTING5.id2] == 0 & kar[(byte)LIGHTING5.id3] == 0)
                            {
                                logging.AddToLog("invalid unit address", true);
                                return;
                            }
                            logging.AddToLog("Writing command to port", true);
                            WriteCom(kar);
                            logging.AddToLog("Lighting5 command:", true);
                            string command_l5 = "";
                            foreach (byte bt in kar)
                            {
                                command_l5 += ("0" + bt.ToString()).Substring(("0" + bt.ToString()).Length - 2) + " ";
                            }
                            logging.AddToLog("Lighting5 command:" + command_l5, true);

                        }
                        break;

                    #endregion

                }
            }
            catch (Exception ex)
            {
                logging.AddToLog("Error processing command: " + ex.Message, true);
            }
            logging.AddToLog("-----------------------------------------------", false);
        }