コード例 #1
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            Log = new General.OSAELog(gAppName);
            Log.Info("*** Running Interface! ***");
            OwnTypes();

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            { Log.Error("I think the Debug property is missing from the Speech object type!"); }

            Log.Info("Debug Mode Set to " + gDebug);

            int iScanInterval = int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Scan Interval").Value);
            Log.Info("Scan Interval Set to " + iScanInterval);

            Clock = new System.Timers.Timer();
            Clock.Interval = iScanInterval * 1000;
            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);

            search_thread = new Thread(new ThreadStart(search));
            search_thread.Start();
            Log.Info("Bluetooth Plugin is now scanning for devices.");
        }
コード例 #2
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);

            _oAuth.OAuthToken = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Auth Token").Value;
            _oAuth.PIN = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Pin").Value;
            _oAuth.Token = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Token").Value;
            _oAuth.TokenSecret = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Token Secret").Value;
            _oAuth.ConsumerKey = "g3QfE1xOc3AQQnvRaRqzQ";
            _oAuth.ConsumerSecret = "yYj3J2u3CtXwwmn98m4VBFUdYDopduv4NOSn6E1aQ";

            try
            {
                if (_oAuth.Token != "" && _oAuth.TokenSecret != "" && _oAuth.PIN != "" && _oAuth.OAuthToken != "")
                {
                    //We are already authenticated
                    Log.Info("Acount authenticated.  Ready for tweeting");
                }
                else
                {
                    // Each Twitter application has an authorization page where the user can specify
                    // 'yes, allow this application' or 'no, deny this application'. The following
                    // call obtains the URL to that page. Authorization link will look something like this:
                    // http://twitter.com/oauth/authorize?oauth_token=c8GZ6vCDdgKO4gTx0ZZXzvjZ76auuvlD1hxoLeiWc
                    string authLink = _oAuth.AuthorizationLinkGet();
                    Log.Info("Here is the Twitter Authorization Link.  Copy and paste into your browser to authorize OSA to use your twitter account.  \nCopy the PIN you are given and put it into the PIN property for the Twitter plugin object and then execute the Authorize method: \n" + authLink);
                }
            }
            catch(Exception ex)
            { Log.Error("Error running interface", ex); }
        }
コード例 #3
0
        public ClientService()
        {
            serviceObject = "SERVICE-" + Common.ComputerName;
            Log = new OSAE.General.OSAELog(serviceObject);
            bool found = OSAEObjectManager.ObjectExists(serviceObject);
            if (!found)
                OSAEObjectManager.ObjectAdd(serviceObject, "", "SERVICE", "SERVICE", "", Common.ComputerName, 50, true);
            else
            {
                OSAEObject obj = OSAEObjectManager.GetObjectByName(serviceObject);
                OSAEObjectManager.ObjectUpdate(serviceObject, serviceObject, "", obj.Description, obj.Type, "", Common.ComputerName, obj.MinTrustLevel, obj.Enabled);
            }

            OSAE.OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject);
          
            Log.Info("ClientService Starting");

            try
            {
                if (!EventLog.SourceExists("OSAEClient"))
                    EventLog.CreateEventSource("OSAEClient", "Application");
            }
            catch (Exception ex)
            { Log.Error("CreateEventSource error", ex); }
            ServiceName = "OSAEClient";
            EventLog.Source = "OSAEClient";
            EventLog.Log = "Application";

            // These Flags set whether or not to handle that specific
            //  type of event. Set to true if you need it, false otherwise.
            CanStop = true;
        }
コード例 #4
0
        /// <summary>
        /// Public Constructor for WindowsService.
        /// - Put all of your Initialization code here.
        /// </summary>
        public OSAEService()
        {
            serviceObject = CheckServiceObject();
            if (serviceObject == null)
            {
                Log = new General.OSAELog("Faulted Service");
                Log.Fatal("Failed to retrieve Service's Object!");
            }
            //else
             //   OSAE.OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject);

            Log = new General.OSAELog(serviceObject);
            Log.Info("Service Starting");

            Common.CheckComputerObject(serviceObject);
            OSAEObject obj = OSAEObjectManager.GetObjectByName(serviceObject);
            OSAEObjectManager.ObjectUpdate(serviceObject, serviceObject, obj.Address, obj.Description, obj.Type, obj.Address, Common.ComputerName, obj.MinTrustLevel, obj.Enabled);

            InitialiseOSAInEventLog();

            // These Flags set whether or not to handle that specific type of event. Set to true if you need it, false otherwise.

            CanStop = true;
            CanShutdown = true;
        }
コード例 #5
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            Log.Info("Running Interface!");
            Clock          = new System.Timers.Timer();
            Clock.Interval = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Update Interval").Value) * 60000;
            Log.Info(updateInterval.ToString());
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);
            Log.Info(Clock.Interval.ToString());
            Clock.Start();

            Log.Info("Starting timer");
            updateThread = new Thread(new ThreadStart(updateFeeds));
            updateThread.Start();
        }
コード例 #6
0
        public VideoStreamViewer(string url, OSAEObject obj, string appName)
        {
            InitializeComponent();
            Log                = new General.OSAELog(appName);
            screenObject       = obj;
            _mjpeg             = new MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error      += _mjpeg_Error;
            imgWidth           = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Width").Value);
            imgHeight          = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Height").Value);
            ControlWidth       = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Width").Value);
            imgRatio           = ControlWidth / imgWidth;
            ControlHeight      = Convert.ToDouble(imgHeight * imgRatio);
            streamURI          = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
            //  if (imgWidth > 0) { imgWidth = imgWidth); }
            // if (imgHeight > 0) { imgHeight = Convert.ToDouble(imgHeight); }
            this.Width  = ControlWidth;
            this.Height = ControlHeight;

            image.Width  = ControlWidth;
            image.Height = ControlHeight;
            if (streamURI == null)
            {
                Log.Error("Stream Path Not Found: " + streamURI);
                message.Content = "Can Not Open: " + streamURI;
            }
            else
            {
                streamURI = renameingSys(streamURI);
                Log.Info("Streaming: " + streamURI);
                _mjpeg.ParseStream(new Uri(streamURI));
            }
        }
コード例 #7
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            Log      = new General.OSAELog(gAppName);
            OwnTypes();

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            { Log.Error("I think the Debug property is missing from the Speech object type!"); }

            Log.Info("Running Interface!");
            int  interval;
            bool isNum = int.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Poll Interval").Value, out interval);

            Clock = new System.Timers.Timer();
            if (isNum)
            {
                Clock.Interval = interval * 1000;
            }
            else
            {
                Clock.Interval = 30000;
            }

            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);

            updateThread = new Thread(new ThreadStart(update));
            updateThread.Start();
        }
        public VideoStreamViewer(string url, OSAEObject obj, string appName)
        {
            InitializeComponent();
            Log = new General.OSAELog(appName);
            screenObject = obj;
            _mjpeg = new MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error += _mjpeg_Error;
            imgWidth = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Width").Value);
            imgHeight = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Height").Value);
            ControlWidth = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Width").Value);
            imgRatio = ControlWidth / imgWidth;
            ControlHeight = Convert.ToDouble(imgHeight * imgRatio);
            streamURI = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
              //  if (imgWidth > 0) { imgWidth = imgWidth); }
               // if (imgHeight > 0) { imgHeight = Convert.ToDouble(imgHeight); }
            this.Width = ControlWidth;
            this.Height = ControlHeight;

            image.Width = ControlWidth;
            image.Height = ControlHeight;
            if (streamURI == null)
            {
                Log.Error("Stream Path Not Found: " + streamURI);
                message.Content = "Can Not Open: " + streamURI;
            }
            else
            {
                streamURI = renameingSys(streamURI);
                Log.Info("Streaming: " + streamURI);
                _mjpeg.ParseStream(new Uri(streamURI));
            }
        }
コード例 #9
0
        /// <summary>
        /// Public Constructor for WindowsService.
        /// - Put all of your Initialization code here.
        /// </summary>
        public OSAEService()
        {
            serviceObject = CheckServiceObject();
            if (serviceObject == null)
            {
                Log = new General.OSAELog("Faulted Service");
                Log.Fatal("Failed to retrieve Service's Object!");
            }
            //else
            //   OSAE.OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject);

            Log = new General.OSAELog(serviceObject);
            Log.Info("Service Starting");

            Common.CheckComputerObject(serviceObject);
            OSAEObject obj = OSAEObjectManager.GetObjectByName(serviceObject);

            OSAEObjectManager.ObjectUpdate(serviceObject, serviceObject, obj.Address, obj.Description, obj.Type, obj.Address, Common.ComputerName, obj.MinTrustLevel, obj.Enabled);

            InitialiseOSAInEventLog();

            // These Flags set whether or not to handle that specific type of event. Set to true if you need it, false otherwise.

            CanStop     = true;
            CanShutdown = true;
        }
コード例 #10
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            Log = new General.OSAELog(gAppName);
            OwnTypes();

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            { Log.Error("I think the Debug property is missing from the Speech object type!"); }

            Log.Info("Running Interface!");
            int interval;
            bool isNum = int.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Poll Interval").Value, out interval);
            Clock = new System.Timers.Timer();
            if(isNum)
                Clock.Interval = interval * 1000;
            else
                Clock.Interval = 30000;

            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);

            updateThread = new Thread(new ThreadStart(update));
            updateThread.Start();
        }
コード例 #11
0
        /// <summary>
        /// Surveys the configured plugin path and returns the the set of types that qualify as plugin classes.
        /// </summary>
        /// <remarks>
        /// Since this method loads assemblies, it must be called from within a dedicated application domain that is subsequently unloaded.
        /// </remarks>
        public IEnumerable <TypeLocator> Find()
        {
            var result = new List <TypeLocator>();

            foreach (var file in Directory.GetFiles(Common.ApiPath + "\\" + PluginPath, "*.dll", SearchOption.AllDirectories))
            {
                //this.Log.Debug("DLL Found while loading Plugins: " + file);
                Log.Info("DLL found: " + file);
                try
                {
                    var assembly = Assembly.LoadFrom(file);

                    foreach (var type in assembly.GetExportedTypes())
                    {
                        if (!type.Equals(_pluginBaseType) && _pluginBaseType.IsAssignableFrom(type))
                        {
                            Log.Debug(type.FullName + ": Exposed Assembly (" + assembly.FullName + ")");
                            result.Add(new TypeLocator(assembly.FullName, type.FullName, file));
                        }
                    }
                }
                catch (Exception ex)
                {
                    // This method is called in its own App Domain so will not have access to the calling logger
                    Log.Error("An assembly was not found for file! (" + file + ")", ex);
                }
            }
            return(result);
        }
コード例 #12
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Info("Running Interface!");
            Clock = new System.Timers.Timer();
            Clock.Interval = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Update Interval").Value) * 60000;
            Log.Info(updateInterval.ToString());
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);
            Log.Info(Clock.Interval.ToString());
            Clock.Start();

            Log.Info("Starting timer");
            updateThread = new Thread(new ThreadStart(updateFeeds));
            updateThread.Start();
        }
コード例 #13
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));
     }
 }
コード例 #14
0
        public override void RunInterface(string pluginName)
        {
            Log.Info("Starting Android plugin");
            pName = pluginName;

            OSAEObjectTypeManager.ObjectTypeUpdate("Android Device", "Android Device", "Android Device", pluginName, "Android Device", false, false, false, true);

            //connect to devices
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("Android Device");

            foreach (OSAEObject obj in objects)
            {
                createdevice(obj);
            }

            Log.Debug("Run Interface Complete");
        }
コード例 #15
0
        public override void ProcessCommand(OSAEMethod method)
        {
            Log.Info("Running Command: " + method.ObjectName + " " + 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;
                }
            }
        }
コード例 #16
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            Log      = new General.OSAELog(gAppName);

            Log.Info("Email Plugin is Starting...");

            OwnTypes();
        }
コード例 #17
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Info("Running Interface!");

            OSAEObjectType objt = OSAEObjectTypeManager.ObjectTypeLoad("RADIO THERMOSTAT DEVICE");
            OSAEObjectTypeManager.ObjectTypeUpdate(objt.Name, objt.Name, "Radio Thermostat Device", pName, "RADIO THERMOSTAT DEVICE", objt.Owner, objt.SysType, objt.Container, objt.HideRedundant);
            OSAEObjectCollection devices = OSAEObjectManager.GetObjectsByType("RADIO THERMOSTAT DEVICE");

            foreach (OSAEObject obj in devices)
            {
                ThermostatLib.SystemInfo si = ThermostatLib.SystemInfo.Load(obj.Address);
                Log.Info("---------------------------------");
                Log.Info("Device Name: " + ThermostatLib.SystemInfo.LoadSystemName(obj.Address));
                Log.Info("API Version: " + si.ApiVersion.ToString());
                Log.Info("Firmware Version: " + si.FirmwareVersion);
                Log.Info("UUID: " + si.UUID);
                Log.Info("WLAN Version: " + si.WlanFirmwareVersion);
                Log.Info("Model: " + ThermostatLib.SystemInfo.LoadModelName(obj.Address));
                Log.Info("Operating Mode: " + ThermostatLib.SystemInfo.LoadOperatingMode(obj.Address));

                ThermostatLib.Services services = ThermostatLib.Services.Load(obj.Address);
                string service = "";
                foreach (ThermostatLib.HttpdHandler handler in services.Handlers)
                {
                    service = "";
                    service += handler.Url + " (";
                    if (handler.AllowsGet && handler.AllowsPost) service += "GET, POST";
                    else
                    {
                        if (handler.AllowsGet) service += "GET";
                        if (handler.AllowsPost) service += "POST";
                    }
                    service += ")";
                    Log.Info("Service: " + service);
                }
            }
            Clock = new System.Timers.Timer();
            Clock.Interval = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Poll Interval").Value) * 60000;
            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);
        }
コード例 #18
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            Log      = new General.OSAELog(gAppName);

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            { Log.Info("The JABBER Object Type seems to be missing the Debug Property!"); }
            Log.Info("Debug Mode Set to " + gDebug);

            OwnTypes();

            try
            {
                oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized);
                //oRecognizer.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(oRecognizer_StateChanged);
            }
            catch (Exception ex)
            { Log.Error("Unable to configure oRecognizer", ex); }

            oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer);
            Log.Info("Load_Direct_Grammar completed");
            oRecognizer = OSAEGrammar.Load_Voice_Grammars(oRecognizer);
            Log.Info("Load_Voice_Grammars completed");
            oRecognizer = OSAEGrammar.Load_Text_Only_Grammars(oRecognizer);
            Log.Info("Load_Text_Only_Grammars completed");
            // Subscribe to Events
            xmppCon.OnLogin       += new ObjectHandler(xmppCon_OnLogin);
            xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
            xmppCon.OnRosterEnd   += new ObjectHandler(xmppCon_OnRosterEnd);
            xmppCon.OnRosterItem  += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
            xmppCon.OnPresence    += new agsXMPP.protocol.client.PresenceHandler(xmppCon_OnPresence);
            xmppCon.OnAuthError   += new XmppElementHandler(xmppCon_OnAuthError);
            xmppCon.OnError       += new ErrorHandler(xmppCon_OnError);
            xmppCon.OnClose       += new ObjectHandler(xmppCon_OnClose);
            xmppCon.OnMessage     += new agsXMPP.protocol.client.MessageHandler(xmppCon_OnMessage);

            connect();
        }
コード例 #19
0
        /// <summary>
        /// OSA Plugin Interface - called on start up to allow plugin to do any tasks it needs
        /// </summary>
        /// <param name="pluginName">The name of the plugin from the system</param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            try
            {
                Log.Info("Starting EventGhost...");

                OwnTypes();

                // on startup ensure that there is at least one computer setup to receive eventghost commands
                OSAEObjectCollection computers = OSAEObjectManager.GetObjectsByType("COMPUTER");

                // check to make sure that the Compuer Objecttype has the needed property
                //add eventghost property to the computer object type
                // need to implement check before i use the method below
                // OSAEObjectTypeManager.ObjectTypePropertyAdd("EventGhost Port", "String", "", "Computer", false);

                foreach (OSAEObject acomputer in computers)
                {
                    string computerName   = acomputer.Name;
                    string IPAddress      = acomputer.Address;
                    string eventGhostPort = (OSAEObjectPropertyManager.GetObjectPropertyValue(computerName, "EventGhost Port").Value);

                    //if no port for property indicate that the default port of 333333 will be used
                    if (eventGhostPort.Equals("", StringComparison.Ordinal))
                    {
                        Log.Info("There is no port information for " + acomputer.Name + " the default port of 33333 will be used when this computer is called");
                    }

                    //check to see if computer has address, if no log that "local host will be used"
                    if ((acomputer.Address).Equals("", StringComparison.Ordinal))
                    {
                        Log.Info("There is no address information for " + acomputer.Name + "localhost will be used for this location");
                    }
                }
            }
            catch (Exception ex)
            { Log.Error("Error during RunInterface!", ex); }
        }
コード例 #20
0
        /// <summary>
        /// OSA Plugin Interface - called on start up to allow plugin to do any tasks it needs
        /// </summary>
        /// <param name="pluginName">The name of the plugin from the system</param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            OwnTypes();
            try
            {
                this.Log.Info("Starting Rest Interface");

                bool showHelp = bool.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Show Help").Value);
                int  restPort = 8732;

                if (!OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "REST Port").Id.Equals(String.Empty))
                {
                    try
                    {
                        restPort = int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "REST Port").Value);
                        Log.Info("Rest Port read in as: " + restPort);
                    }
                    catch (FormatException ex)
                    { Log.Error("Error pulling REST port from property (not a valid number)", ex); }
                    catch (OverflowException ex)
                    { Log.Error("Error pulling REST port from property (too large)", ex); }
                    catch (ArgumentNullException ex)
                    { Log.Error("Error pulling REST port from property (null)", ex); }
                }

                String restUrl = "http://localhost:" + restPort.ToString() + "/api";
                serviceHost = new WebServiceHost(typeof(OSAERest.api), new Uri(restUrl));

                WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.None);
                binding.CrossDomainScriptAccessEnabled = true;

                var endpoint = serviceHost.AddServiceEndpoint(typeof(IRestService), binding, "");

                ServiceDebugBehavior sdb = serviceHost.Description.Behaviors.Find <ServiceDebugBehavior>();
                sdb.HttpHelpPageEnabled = false;
                if (showHelp)
                {
                    serviceHost.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior {
                        HelpEnabled = true
                    });
                }


                checkAPIKey();
                checkSecurityKey();
                serviceHost.Open();
            }
            catch (Exception ex)
            { Log.Error("Error starting RESTful web service", ex); }
        }
コード例 #21
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Info("Current Environment Version: " + Environment.Version.Major.ToString());
            if (Environment.Version.Major >= 4)
            {
                string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"Microsoft.NET\Framework64\v2.0.50727");
                if (!Directory.Exists(folder))
                    folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"Microsoft.NET\Framework\v2.0.50727");

                Log.Debug("vjsnativ.dll path: " + folder);
                folder = Path.GetFullPath(folder);
                LoadLibrary(Path.Combine(folder, "vjsnativ.dll"));
            }

            string adapterProp = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Adapter").Value;
            string port = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Port").Value;
            uom = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Unit of Measure").Value;
            Log.Debug("adapterProp: " + adapterProp + ", port: " + port + ", uom: " + uom);
            try
            {
                adapter = OneWireAccessProvider.getAdapter(adapterProp, "COM" + port);
            }
            catch (Exception ex)
            { Log.Error("Failed to GetAdapter ", ex); }

            if (adapter.adapterDetected())
            {
                Log.Info("Adapter Detected");
                adapter.setSearchAllDevices();

                Clock = new System.Threading.Timer(poll, null, 0, 10000);

                if (restarting) restarting = false;
            }
            else
                Log.Info("Adapter(" + adapterProp + ") not found on port " + port);
        }
コード例 #22
0
        public override void RunInterface(string pluginName)
        {
            Log.Info("Starting MediaCenter Plugin");
            pName = pluginName;
            OSAEObjectTypeManager.ObjectTypeUpdate("MediaCenter Device", "MediaCenter Device", "MediaCenter Device", pluginName, "MediaCenter Device", false, false, false, true);

            //heartbeat to check online devices
            int interval;

            bool isNum = Int32.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Poll Interval").Value, out interval);

            Clock = new System.Timers.Timer();
            if (isNum)
            {
                Clock.Interval = interval * 1000;
            }
            else
            {
                Clock.Interval = 60000;
            }
            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);


            //connect to devices
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("MediaCenter Device");

            foreach (OSAEObject obj in objects)
            {
                createdevice(obj);
            }


            this.updateThread = new Thread(new ThreadStart(update));
            this.updateThread.Start();

            Log.Debug("Run Interface Complete");
        }
コード例 #23
0
 public bool Shutdown()
 {
     try
     {
         Log.Info("Shutting down " + UserControlName);
         AppDomain.Unload(_domain);
         return(true);
     }
     catch (Exception ex)
     {
         Log.Error(UserControlName + " - Shutdown Error", ex);
         return(false);
     }
 }
コード例 #24
0
        /// <summary>
        /// The service control manager has requested us to start
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            Log.Debug("OnStart subroutine Starting...");
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptions);

            var dbConnectionStatus = Common.TestConnection();

            if (dbConnectionStatus.Success)
            {
                Log.Info("Verified successful connection to database.");
            }
            else
            {
                Log.Fatal("Unable to connect to database: " + dbConnectionStatus.CaughtException.Message);
                return;
            }

            try
            {
                string externalip = new System.Net.WebClient().DownloadString("https://api.ipify.org");
                OSAEObjectPropertyManager.ObjectPropertySet("SYSTEM", "WAN IP", externalip, "SERVICE");
            }
            catch (Exception ex)
            { Log.Fatal("Error getting registry settings and/or deleting logs: " + ex.Message, ex); }

            try
            {
                Common.InitialiseLogFolder();
                DeleteStoreFiles();
            }
            catch (Exception ex)
            { Log.Fatal("Error getting registry settings and/or deleting logs: " + ex.Message, ex); }

            Log.Info("Removing Orphaned Methods");
            OSAEMethodManager.ClearMethodQueue();

            try
            {
                OSAE.OSAESql.RunSQL("SET GLOBAL event_scheduler = ON;");
            }
            catch (Exception ex)
            { Log.Fatal("Error setting the event scheduler: " + ex.Message, ex); }

            checkLog          = new System.Timers.Timer(60000);
            checkLog.Elapsed += checkLogEvent;
            checkLog.Enabled  = true;

            // Start the network service so messages can be
            // received by the service
            StartNetworkListener();

            // Start the threads that monitor the plugin
            // updates check the method queue and so on
            StartThreads(serviceObject);
        }
コード例 #25
0
        /// <summary>
        /// Set up the powershell plugin ready to process commands
        /// </summary>
        /// <param name="pluginName"></param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Info("Running Interface!");

            if (PluginRegistered())
                Log.Debug("Powershell Plugin already registered");
            else
            {
                Log.Debug("Powershell Plugin needs registering");
                Register(false);
            }
            OwnTypes();
        }
コード例 #26
0
        /// <summary>
        /// Decrypts an OSAE Security encrypted Authentication string.
        /// Used to verify User to use in POST request.
        /// </summary>
        /// <param name="authkey">An OSAE Security encrypted String</param>
        /// <returns>Returns the Username, if criteria matches</returns>
        public static string DecryptUser(string authkey)
        {
            Log.Info("OSAE Security is Decoding an AuthKey");
            string uName            = null;
            string decryptedAuthKey = DecryptString(authkey);

            string[] user = decryptedAuthKey.Split(':');
            try
            {
                OSAEObject ouser = OSAE.OSAEObjectManager.GetObjectByName(user[0]);
                Log.Debug("Found User: "******"Password").Value)
                {
                    DateTime authDate = new DateTime();
                    try
                    {
                        authDate = Convert.ToDateTime(user[1].Substring(0, 4) + "-" + user[1].Substring(4, 2) + "-" + user[1].Substring(6, 2) + " " + user[1].Substring(8, 2) + ":" + user[1].Substring(10, 2) + ":" + user[1].Substring(12, 2));
                    }
                    catch
                    {
                        Log.Debug("Could not resolve TimeStamp: FAILED");
                        return(uName);
                    }
                    Log.Debug("Auth Date and Time: " + authDate.ToString());
                    //DateTime nowAuth = DateTime.Now;
                    DateTime sDate = DateTime.Now.AddSeconds(timeSplit - (timeSplit * 2));
                    DateTime eDate = DateTime.Now.AddSeconds(timeSplit);
                    if (authDate > sDate && authDate < eDate)
                    {
                        Log.Debug("Authintication: PASSED");
                        uName = ouser.Name;
                    }
                    else
                    {
                        Log.Debug("Authintication: FAILED");
                    }
                }
                else
                {
                    Log.Debug("Authintication: FAILED");
                }
            }
            catch
            {
                Log.Debug("Invalid Authintication key: FAILED");
            }
            return(uName);
        }
コード例 #27
0
        public bool Connect()
        {
            Log.Info("Attempting connection: " + Name + " (" + _ip + ":" + _port + ", user="******")");
            try
            {
                _pinging    = true;
                _xbmcSystem = new Client(_ip, _port, _username, _password);
                var task = Task.Run(async() =>
                {
                    return(await _xbmcSystem.JSONRPC.Ping());
                });
                if (task.Result == "pong")
                {
                    Log.Info("Client connected");

                    try
                    {
                        _Debug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(Name, "Debug").Value);
                    }
                    catch
                    {
                        Log.Info("The XBMC Object Type seems to be missing the Debug Property!");
                    }
                    Log.Info("Debug Mode Set to " + _Debug);

                    _xbmcSystem.Player.OnPlay  += Player_OnPlay;
                    _xbmcSystem.Player.OnStop  += Player_OnStop;
                    _xbmcSystem.Player.OnPause += Player_OnPause;

                    _xbmcSystem.StartNotificationListener();
                    if (_Debug)
                    {
                        Log.Debug("Events wired up");
                    }
                    _pinging = false;
                    return(true);
                }
                else
                {
                    _pinging = false;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error connecting to XBMC system" + Name + " (" + _ip + ":" + _port + ", user="******")", ex);
                _pinging = false;
                return(false);
            }
        }
コード例 #28
0
 public bool Shutdown()
 {
     try
     {
         Log.Info(PluginName + ":  Shutting down...");
         _plugin.Shutdown();
         _running = false;
         AppDomain.Unload(_domain);
         return(true);
     }
     catch (Exception ex)
     {
         Log.Error(PluginName + " - Shutdown Error", ex);
         return(false);
     }
 }
コード例 #29
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            Log.Info("Starting Android plugin");
            OwnTypes();

            //connect to devices
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("ANDROID DEVICE");

            foreach (OSAEObject obj in objects)
            {
                createdevice(obj);
            }

            Log.Debug("Run Interface Complete");
        }
コード例 #30
0
        /// <summary>
        /// Set up the powershell plugin ready to process commands
        /// </summary>
        /// <param name="pluginName"></param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            Log.Info("Running Interface!");

            if (PluginRegistered())
            {
                Log.Debug("Powershell Plugin already registered");
            }
            else
            {
                Log.Debug("Powershell Plugin needs registering");
                Register(false);
            }
            OwnTypes();
        }
コード例 #31
0
 public override void RunInterface(string pluginName)
 {
     Log.Info("Loading COSMUpdater..");
     cosmTest = new COSMWriter();
     pName = pluginName;
     Log = new General.OSAELog(pName);
     try
     {
         pollInterval = int.Parse("0" + OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "PollRate").Value);
         if (!ReportAndCheckUsage()) return;
         SetUpPoller();
         enabled = true;
         Log.Info("Started COSMUpdater...");
     }
     catch (Exception ex)
     { Log.Error("COSMUpdater Exception in RunInterface. ", ex); }
 }
コード例 #32
0
        /// <summary>
        /// OSA Plugin Interface - called on start up to allow plugin to do any tasks it needs
        /// </summary>
        /// <param name="pluginName">The name of the plugin from the system</param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            OwnTypes();
            try
            {
                this.Log.Info("Starting Rest Interface");

                bool showHelp = bool.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Show Help").Value);
                int restPort = 8732;

                if (!OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "REST Port").Id.Equals(String.Empty))
                {
                    try
                    {
                        restPort = int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "REST Port").Value);
                        Log.Info("Rest Port read in as: " + restPort);
                    }
                    catch (FormatException ex)
                    { Log.Error("Error pulling REST port from property (not a valid number)", ex); }
                    catch (OverflowException ex)
                    { Log.Error("Error pulling REST port from property (too large)", ex); }
                    catch (ArgumentNullException ex)
                    { Log.Error("Error pulling REST port from property (null)", ex); }
                }

                String restUrl = "http://localhost:"+restPort.ToString()+"/api";
                serviceHost = new WebServiceHost(typeof(OSAERest.api), new Uri(restUrl));

                WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.None);
                binding.CrossDomainScriptAccessEnabled = true;
                var endpoint = serviceHost.AddServiceEndpoint(typeof(IRestService), binding, "");

                ServiceDebugBehavior sdb = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
                sdb.HttpHelpPageEnabled = false;
                if (showHelp) serviceHost.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior { HelpEnabled = true });

                Log.Info("Starting RESTful Interface");
                serviceHost.Open();
            }
            catch (Exception ex)
            { Log.Error("Error starting RESTful web service", ex); }
        }
コード例 #33
0
        public bool ActivatePlugin()
        {
            Log = new OSAE.General.OSAELog(PluginName);
            try
            {
                Log.Info(PluginName + ":  Starting Plugin...");
                _plugin = (OSAEPluginBase)_domain.CreateInstanceAndUnwrap(_assemblyName, _assemblyType);
                _plugin.InitializeLifetimeService();
                _running = true;

                _domain.UnhandledException += Domain_UnhandledException;
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error("Error Starting Plugin (" + PluginName + ")", ex);
                _enabled = false;
                return(false);
            }
        }
コード例 #34
0
 public override void RunInterface(string pluginName)
 {
     Log.Info("Loading COSMUpdater..");
     cosmTest = new COSMWriter();
     pName    = pluginName;
     Log      = new General.OSAELog(pName);
     try
     {
         pollInterval = int.Parse("0" + OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "PollRate").Value);
         if (!ReportAndCheckUsage())
         {
             return;
         }
         SetUpPoller();
         enabled = true;
         Log.Info("Started COSMUpdater...");
     }
     catch (Exception ex)
     { Log.Error("COSMUpdater Exception in RunInterface. ", ex); }
 }
コード例 #35
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            Log.Info("Initializing Plugin");
            OSAEObjectType objt = OSAEObjectTypeManager.ObjectTypeLoad("SQUEEZEBOX");

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

            sbsAddress = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Server Address").Value;
            sbsPort    = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "CLI Port").Value);
            ttsSave    = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "TTS Save Path").Value;
            ttsPlay    = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "TTS Play Path").Value;

            Log.Info("address: " + sbsAddress);
            Log.Info("port: " + sbsPort);
            sbs.mHost = sbsAddress;
            sbs.mPort = sbsPort;
            StringCollection     players = sbs.GetPlayers();
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("SQUEEZEBOX");

            Log.Info("Found " + sbs.GetPlayerCount().ToString() + " players");
            foreach (string player in players)
            {
                Log.Info("Found player: " + player);
                string[] sb    = player.Split(' ');
                bool     found = false;
                foreach (OSAEObject obj in objects)
                {
                    if (obj.Address == sb[0])
                    {
                        Log.Info("Found matching object: " + obj.Name);
                        found = true;
                    }
                }

                if (!found)
                {
                    Log.Info("No object found.  Adding to OSA");
                    OSAEObjectManager.ObjectAdd(sb[1], "", sb[1], "SQUEEZEBOX", sb[0], "", 30, true);
                }
            }
        }
コード例 #36
0
        public ClientService()
        {
            serviceObject = "SERVICE-" + Common.ComputerName;
            Log           = new OSAE.General.OSAELog(serviceObject);
            bool found = OSAEObjectManager.ObjectExists(serviceObject);

            if (!found)
            {
                OSAEObjectManager.ObjectAdd(serviceObject, "", "SERVICE", "SERVICE", "", Common.ComputerName, 50, true);
            }
            else
            {
                OSAEObject obj = OSAEObjectManager.GetObjectByName(serviceObject);
                OSAEObjectManager.ObjectUpdate(serviceObject, serviceObject, "", obj.Description, obj.Type, "", Common.ComputerName, obj.MinTrustLevel, obj.Enabled);
            }

            OSAE.OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject);

            Log.Info("ClientService Starting");

            try
            {
                if (!EventLog.SourceExists("OSAEClient"))
                {
                    EventLog.CreateEventSource("OSAEClient", "Application");
                }
            }
            catch (Exception ex)
            { Log.Error("CreateEventSource error", ex); }
            ServiceName     = "OSAEClient";
            EventLog.Source = "OSAEClient";
            EventLog.Log    = "Application";

            // These Flags set whether or not to handle that specific
            //  type of event. Set to true if you need it, false otherwise.
            CanStop = true;
        }
コード例 #37
0
        public override void RunInterface(string pluginName)
        {
            this.Log.Info("*** Running Interface! ***");
            gAppName = pluginName;
            if (OSAEObjectManager.ObjectExists(gAppName))
            {
                Log.Info("Found Speech Client's Object (" + gAppName + ")");
            }
            else
            {
                Log.Info("Could Not Find Speech Client's Object!!! (" + gAppName + ")");
            }

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            {
                Log.Error("I think the Debug property is missing from the Speech object type!");
            }
            Log.Info("Debug Mode Set to " + gDebug);

            int iScanInterval = int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Scan Interval").Value);

            Log.Info("Scan Interval Set to " + iScanInterval);

            Clock          = new System.Timers.Timer();
            Clock.Interval = iScanInterval * 1000;
            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);

            this.search_thread = new Thread(new ThreadStart(search));
            this.search_thread.Start();
            Log.Info("Bluetooth Plugin is now scanning for devices.");
        }
コード例 #38
0
        public override void RunInterface(string pluginName)
        {
            Log.Info("Running interface");
            gAppName = pluginName;
            Log = new General.OSAELog(gAppName);
            if (OSAEObjectManager.ObjectExists(gAppName))
                Log.Info("Found the XBMC plugin's Object (" + gAppName + ")");
            else
                Log.Info("Could Not Find the XBMC plugin's Object!!! (" + gAppName + ")");

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            { Log.Info("The XBMC Object Type seems to be missing the Debug Property!"); }
            Log.Info("Debug Mode Set to " + gDebug);


            OwnTypes();
            //OSAEObjectTypeManager.ObjectTypeUpdate("XBMC SYSTEM", "XBMC SYSTEM", "XBMC System", pluginName, "XBMC SYSTEM", 0, 0, 0, 1);

            OSAEObjectCollection XBMCInstances = OSAEObjectManager.GetObjectsByType("XBMC System");
            foreach (OSAEObject obj in XBMCInstances)
            {
                string ip = "", username = "", password = "";
                int port = 0;

                foreach (OSAEObjectProperty p in obj.Properties)
                {
                    switch (p.Name)
                    {
                        case "IP":
                            ip = p.Value;
                            break;
                        case "Port":
                            port = Int32.Parse(p.Value);
                            break;
                        case "Username":
                            username = p.Value;
                            break;
                        case "Password":
                            password = p.Value;
                            break;
                    }
                }
                Log.Info("Creating new XBMC System connection: " + obj.Name + " (" + ip + ":" + port + ", user="******")");
                try
                {
                    XBMCSystem system = new XBMCSystem(obj.Name, ip, port, username, password);
                    if (system.Connect())
                    {
                        Systems.Add(system);
                        Log.Info("XBMC System connection Successfull for: " + obj.Name);
                    }
                }
                catch (Exception ex)
                { Log.Error("Error connecting to XBMC system",ex); }
            }

            try
            {
                Clock = new System.Timers.Timer();
                Clock.Interval = 10000;

                Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);
                Clock.Start();
                if (gDebug) Log.Debug("Timers Started");
            }
            catch (Exception ex)
            { Log.Error("Error starting timers ", ex); }
        }
コード例 #39
0
        public bool ActivatePlugin()
        {
            Log = new OSAE.General.OSAELog(PluginName);
            try
            {
                Log.Info(PluginName + ":  Starting Plugin...");
                _plugin = (OSAEPluginBase)_domain.CreateInstanceAndUnwrap(_assemblyName, _assemblyType);
                _plugin.InitializeLifetimeService();
                _running = true;

                _domain.UnhandledException += Domain_UnhandledException;
                return true;
            }
            catch (Exception ex)
            {
                Log.Error("Error Starting Plugin (" + PluginName + ")", ex);
                _enabled = false;
                return false;
            }
        }
コード例 #40
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Info("Starting J-Works plugin");
            if (OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Inverval").Value != "")
                pollInterval = UInt32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Interval").Value);

            // point subobject classes at this instance (I think)
            OSAEObjectTypeManager.ObjectTypeUpdate("JWORKS INPUT", "JWORKS INPUT", "J-Works Input", pName, "JWORKS INPUT", false, false, false, true);
            OSAEObjectTypeManager.ObjectTypeUpdate("JWORKS OUTPUT", "JWORKS OUTPUT", "J-Works Output", pName, "JWORKS OUTPUT", false, false, false, true);

            // enumerate JSB34x inputs and outputs
            short numDevs = Jsb34xNumberOfModules();
            StringBuilder sb = new StringBuilder(32);
            Jsb34xDllVersion(sb, 32);
            string DllVersion = sb.ToString();
            for (short dev = 1; dev <= numDevs; ++dev)
            {
                sb.Clear();
                Jsb34xSerialNumber(dev, sb, 32);
                String serial = sb.ToString();
                sb.Clear();
                Jsb34xFirmwareVersion(serial, sb, 32);
                string firmwareVersion = sb.ToString();
                sb.Clear();
                Jsb34xDriverVersion(serial, sb, 32);
                string driverVersion = sb.ToString();

                Jsb34xOpenAllRelays(serial);
                JSB34Xs.Add(serial);
                JSB34XState.Add(0);

                byte numInputs = Jsb34xMaxInputs(serial);
                byte numOutputs = Jsb34xMaxRelays(serial);
                Log.Info("Found JSB34x device " + serial + " " + driverVersion + " " + DllVersion + " " + firmwareVersion + " with " + numInputs + " inputs, " + numOutputs + " outputs.");
                for (byte inp = 1; inp <= numInputs; ++inp)
                    AddIO(serial + "_I" + inp, Direction.Input, serial, inp);
                for (byte outp = 1; outp <= numOutputs; ++outp)
                    AddIO(serial + "_O" + outp, Direction.Output, serial, outp);
            }

            // enumerate JSB38x /39x inputs
            numDevs = Jsb383NumberOfModules();
            sb.Clear();
            Jsb383DllVersion(sb, 32);
            DllVersion = sb.ToString();
            for (short dev = 1; dev <= numDevs; ++dev)
            {
                sb.Clear();
                Jsb383SerialNumber(dev, sb, 32);
                String serial = sb.ToString();
                sb.Clear();
                Jsb383FirmwareVersion(serial, sb, 32);
                string firmwareVersion = sb.ToString();
                sb.Clear();
                Jsb383DriverVersion(serial, sb, 32);
                string driverVersion = sb.ToString();

                JSB383s.Add(serial);
                JSB383State.Add(0);

                byte numInputs = Jsb383MaxInputs(serial);
                Log.Info("Found JSB38x / JSB39x device " + serial + " " + driverVersion + " " + DllVersion + " " + firmwareVersion + " with " + numInputs + " inputs.");
                for (byte inp = 1; inp <= numInputs; ++inp)
                    AddIO(serial + "_I" + inp, Direction.Input, serial, inp);
            }

            if (pollInterval > 0)
            {
                timer.Interval = pollInterval;
                timer.Elapsed += new ElapsedEventHandler(Poll);
                timer.Start();
            }
        }
コード例 #41
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            Log = new General.OSAELog(gAppName);

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            { Log.Info("The JABBER Object Type seems to be missing the Debug Property!"); }
            Log.Info("Debug Mode Set to " + gDebug);

            OwnTypes();

            OSAE.OSAEObject tempAlias = OSAE.OSAEObjectManager.GetObjectByName(gSystemName);
            if (tempAlias.Alias.Length > 0) gSystemName = tempAlias.Alias;

            try
            {
                oRecognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized);
                //oRecognizer.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(oRecognizer_StateChanged);
            }
            catch (Exception ex)
            { Log.Error("Unable to configure oRecognizer", ex); }

            oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer);
            Log.Info("Load_Direct_Grammar completed");
            oRecognizer = OSAEGrammar.Load_Voice_Grammars(oRecognizer);
            Log.Info("Load_Voice_Grammars completed");
            oRecognizer = OSAEGrammar.Load_Text_Only_Grammars(oRecognizer);
            Log.Info("Load_Text_Only_Grammars completed");
            // Subscribe to Events
            xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);
            xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
            xmppCon.OnRosterEnd += new ObjectHandler(xmppCon_OnRosterEnd);
            xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
            xmppCon.OnPresence += new agsXMPP.protocol.client.PresenceHandler(xmppCon_OnPresence);
            xmppCon.OnAuthError += new XmppElementHandler(xmppCon_OnAuthError);
            xmppCon.OnError += new ErrorHandler(xmppCon_OnError);
            xmppCon.OnClose += new ObjectHandler(xmppCon_OnClose);
            xmppCon.OnMessage += new agsXMPP.protocol.client.MessageHandler(xmppCon_OnMessage);

            connect();
        }
コード例 #42
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            Log.Debug("Running interface");

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

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

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

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

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

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

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

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

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

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

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

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

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

                        //Start listening
                        r.Connect();
                    }
                    else if (r.Type == "Serial" && r.ComPort != 0)
                    { //not implemented
                    }
                    else
                    {
                        Log.Info(r.Name + " - Properties not set");
                    }
                }
                catch (Exception ex)
                { Log.Error("Error creating connection to receiver", ex); }
            }
            Log.Info("Run Interface Complete");
        }
コード例 #43
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Debug("Running interface");

            OSAEObjectType objt = OSAEObjectTypeManager.ObjectTypeLoad("ONKYO RECEIVER");
            OSAEObjectTypeManager.ObjectTypeUpdate(objt.Name, objt.Name, objt.Description, pName, "THING", objt.Owner, objt.SysType, objt.Container, objt.HideRedundant);

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

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

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

            foreach (OSAEObject obj in objects)
            {
                Receiver r = new Receiver(obj.Name);
                foreach (OSAEObjectProperty prop in obj.Properties)
                {
                    switch (prop.Name)
                    {
                        case "Communication Type":
                            r.Type = prop.Value;
                            break;
                        case "IP":
                            r.IP = prop.Value;
                            break;
                        case "Network Port":
                            try
                            { r.NetworkPort = Int32.Parse(prop.Value); }
                            catch
                            { r.NetworkPort = 0; }
                            break;
                        case "COM Port":
                            try
                            { r.ComPort = Int32.Parse(prop.Value); }
                            catch
                            { r.ComPort = 0; }
                            break;
                    }
                }

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

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

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

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

                        //Start listening
                        r.Connect();
                    }
                    else if (r.Type == "Serial" && r.ComPort != 0)
                    { //not implemented
                    }
                    else
                        Log.Info(r.Name + " - Properties not set");
                }
                catch (Exception ex)
                { Log.Error("Error creating connection to receiver", ex); }
            }
            Log.Info("Run Interface Complete");
        }
コード例 #44
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Info("Starting Android plugin");
            OwnTypes();

            //connect to devices
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("ANDROID DEVICE");

            foreach (OSAEObject obj in objects)
                createdevice(obj);

            Log.Debug("Run Interface Complete");
        }
コード例 #45
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            Log = new General.OSAELog(gAppName);

            Log.Info("Email Plugin is Starting...");

            OwnTypes();
        }
コード例 #46
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log   = new General.OSAELog(pName);
            Log.Info("Starting J-Works plugin");
            if (OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Inverval").Value != "")
            {
                pollInterval = UInt32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Polling Interval").Value);
            }

            // point subobject classes at this instance (I think)
            OSAEObjectTypeManager.ObjectTypeUpdate("JWORKS INPUT", "JWORKS INPUT", "J-Works Input", pName, "JWORKS INPUT", false, false, false, true);
            OSAEObjectTypeManager.ObjectTypeUpdate("JWORKS OUTPUT", "JWORKS OUTPUT", "J-Works Output", pName, "JWORKS OUTPUT", false, false, false, true);

            // enumerate JSB34x inputs and outputs
            short         numDevs = Jsb34xNumberOfModules();
            StringBuilder sb      = new StringBuilder(32);

            Jsb34xDllVersion(sb, 32);
            string DllVersion = sb.ToString();

            for (short dev = 1; dev <= numDevs; ++dev)
            {
                sb.Clear();
                Jsb34xSerialNumber(dev, sb, 32);
                String serial = sb.ToString();
                sb.Clear();
                Jsb34xFirmwareVersion(serial, sb, 32);
                string firmwareVersion = sb.ToString();
                sb.Clear();
                Jsb34xDriverVersion(serial, sb, 32);
                string driverVersion = sb.ToString();

                Jsb34xOpenAllRelays(serial);
                JSB34Xs.Add(serial);
                JSB34XState.Add(0);

                byte numInputs  = Jsb34xMaxInputs(serial);
                byte numOutputs = Jsb34xMaxRelays(serial);
                Log.Info("Found JSB34x device " + serial + " " + driverVersion + " " + DllVersion + " " + firmwareVersion + " with " + numInputs + " inputs, " + numOutputs + " outputs.");
                for (byte inp = 1; inp <= numInputs; ++inp)
                {
                    AddIO(serial + "_I" + inp, Direction.Input, serial, inp);
                }
                for (byte outp = 1; outp <= numOutputs; ++outp)
                {
                    AddIO(serial + "_O" + outp, Direction.Output, serial, outp);
                }
            }

            // enumerate JSB38x /39x inputs
            numDevs = Jsb383NumberOfModules();
            sb.Clear();
            Jsb383DllVersion(sb, 32);
            DllVersion = sb.ToString();
            for (short dev = 1; dev <= numDevs; ++dev)
            {
                sb.Clear();
                Jsb383SerialNumber(dev, sb, 32);
                String serial = sb.ToString();
                sb.Clear();
                Jsb383FirmwareVersion(serial, sb, 32);
                string firmwareVersion = sb.ToString();
                sb.Clear();
                Jsb383DriverVersion(serial, sb, 32);
                string driverVersion = sb.ToString();

                JSB383s.Add(serial);
                JSB383State.Add(0);

                byte numInputs = Jsb383MaxInputs(serial);
                Log.Info("Found JSB38x / JSB39x device " + serial + " " + driverVersion + " " + DllVersion + " " + firmwareVersion + " with " + numInputs + " inputs.");
                for (byte inp = 1; inp <= numInputs; ++inp)
                {
                    AddIO(serial + "_I" + inp, Direction.Input, serial, inp);
                }
            }

            if (pollInterval > 0)
            {
                timer.Interval = pollInterval;
                timer.Elapsed += new ElapsedEventHandler(Poll);
                timer.Start();
            }
        }
コード例 #47
0
        /// <summary>
        /// OSA Plugin Interface - called on start up to allow plugin to do any tasks it needs
        /// </summary>
        /// <param name="pluginName">The name of the plugin from the system</param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            try
            {
                Log.Info("Starting EventGhost...");

                OwnTypes();

                // on startup ensure that there is at least one computer setup to receive eventghost commands
                OSAEObjectCollection computers = OSAEObjectManager.GetObjectsByType("COMPUTER");

                // check to make sure that the Compuer Objecttype has the needed property
                //add eventghost property to the computer object type
                // need to implement check before i use the method below
                // OSAEObjectTypeManager.ObjectTypePropertyAdd("EventGhost Port", "String", "", "Computer", false);

                foreach (OSAEObject acomputer in computers)
                {
                    string computerName = acomputer.Name;
                    string IPAddress = acomputer.Address;
                    string eventGhostPort = (OSAEObjectPropertyManager.GetObjectPropertyValue(computerName, "EventGhost Port").Value);

                    //if no port for property indicate that the default port of 333333 will be used
                    if (eventGhostPort.Equals("", StringComparison.Ordinal))
                        Log.Info("There is no port information for " + acomputer.Name + " the default port of 33333 will be used when this computer is called");

                    //check to see if computer has address, if no log that "local host will be used"
                    if ((acomputer.Address).Equals("", StringComparison.Ordinal))
                    Log.Info("There is no address information for " + acomputer.Name + "localhost will be used for this location");
                }
            }
            catch (Exception ex)
            { Log.Error("Error during RunInterface!", ex); }
        }
コード例 #48
0
        public override void RunInterface(string pluginName)
        {
            Log.Info("Running interface");
            gAppName = pluginName;
            Log      = new General.OSAELog(gAppName);
            if (OSAEObjectManager.ObjectExists(gAppName))
            {
                Log.Info("Found the XBMC plugin's Object (" + gAppName + ")");
            }
            else
            {
                Log.Info("Could Not Find the XBMC plugin's Object!!! (" + gAppName + ")");
            }

            try
            {
                gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
            }
            catch
            { Log.Info("The XBMC Object Type seems to be missing the Debug Property!"); }
            Log.Info("Debug Mode Set to " + gDebug);


            OwnTypes();
            //OSAEObjectTypeManager.ObjectTypeUpdate("XBMC SYSTEM", "XBMC SYSTEM", "XBMC System", pluginName, "XBMC SYSTEM", 0, 0, 0, 1);

            OSAEObjectCollection XBMCInstances = OSAEObjectManager.GetObjectsByType("XBMC System");

            foreach (OSAEObject obj in XBMCInstances)
            {
                string ip = "", username = "", password = "";
                int    port = 0;

                foreach (OSAEObjectProperty p in obj.Properties)
                {
                    switch (p.Name)
                    {
                    case "IP":
                        ip = p.Value;
                        break;

                    case "Port":
                        port = Int32.Parse(p.Value);
                        break;

                    case "Username":
                        username = p.Value;
                        break;

                    case "Password":
                        password = p.Value;
                        break;
                    }
                }
                Log.Info("Creating new XBMC System connection: " + obj.Name + " (" + ip + ":" + port + ", user="******")");
                try
                {
                    XBMCSystem system = new XBMCSystem(obj.Name, ip, port, username, password);
                    if (system.Connect())
                    {
                        Systems.Add(system);
                        Log.Info("XBMC System connection Successfull for: " + obj.Name);
                    }
                }
                catch (Exception ex)
                { Log.Error("Error connecting to XBMC system", ex); }
            }

            try
            {
                Clock          = new System.Timers.Timer();
                Clock.Interval = 10000;

                Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);
                Clock.Start();
                if (gDebug)
                {
                    Log.Debug("Timers Started");
                }
            }
            catch (Exception ex)
            { Log.Error("Error starting timers ", ex); }
        }
コード例 #49
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);
            Log.Info("Initializing Plugin");
            OSAEObjectType objt = OSAEObjectTypeManager.ObjectTypeLoad("SQUEEZEBOX");
            OSAEObjectTypeManager.ObjectTypeUpdate(objt.Name, objt.Name, objt.Description, pName, "SQUEEZEBOX", objt.Owner, objt.SysType, objt.Container, objt.HideRedundant);

            sbsAddress = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Server Address").Value;
            sbsPort = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "CLI Port").Value);
            ttsSave = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "TTS Save Path").Value;
            ttsPlay = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "TTS Play Path").Value;

            Log.Info("address: " + sbsAddress);
            Log.Info("port: " + sbsPort);
            sbs.mHost = sbsAddress;
            sbs.mPort = sbsPort;
            StringCollection players = sbs.GetPlayers();
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("SQUEEZEBOX");
            Log.Info("Found " + sbs.GetPlayerCount().ToString() + " players");
            foreach (string player in players)
            {
                Log.Info("Found player: " + player);
                string[] sb = player.Split(' ');
                bool found = false;
                foreach (OSAEObject obj in objects)
                {
                    if (obj.Address == sb[0])
                    {
                        Log.Info("Found matching object: " + obj.Name);
                        found = true;
                    }
                }

                if (!found)
                {
                    Log.Info("No object found.  Adding to OSA");
                    OSAEObjectManager.ObjectAdd(sb[1],"", sb[1], "SQUEEZEBOX", sb[0], "", 30, true);
                }
            }
        }
コード例 #50
0
        /// <summary>
        /// OSA Plugin Interface - called on start up to allow plugin to do any tasks it needs
        /// </summary>
        /// <param name="pluginName">The name of the plugin from the system</param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;
            Log = new General.OSAELog(pName);

            //make sure object types are owned by the Nest Plugin
            OSAEObjectTypeManager.ObjectTypeUpdate("NEST STRUCTURE", "NEST STRUCTURE", "Nest Structure", pluginName, "NEST STRUCTURE", false, false, false, true);
            OSAEObjectTypeManager.ObjectTypeUpdate("NEST THERMOSTAT", "NEST THERMOSTAT", "Nest Thermostat", pluginName, "NEST THERMOSTAT", false, false, false, true);
            OSAEObjectTypeManager.ObjectTypeUpdate("NEST PROTECT", "NEST PROTECT", "Nest Protect", pluginName, "NEST PROTECT", false, false, false, true);

            Log.Info("Starting Nest...");

            Ititialize("startup");

            //heartbeat to check online devices
            int interval = 10; //in minutes

            //bool isNum = Int32.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Poll Interval").Value, out interval);
            Clock = new System.Timers.Timer();
            //if (isNum)
            Clock.Interval = interval * 60 * 1000;
            //else
            //    Clock.Interval = 60000;
            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);
            updateThread = new Thread(new ThreadStart(update));
        }
コード例 #51
0
 public override void Shutdown()
 {
     Clock.Stop();
     Log.Info("Service Stopped");
 }
コード例 #52
0
 public override void RunInterface(string pluginName)
 {
     pName = pluginName;
     Log = new OSAE.General.OSAELog(pName);
     Log.Info(pluginName + " is starting...");
     Log.Info("===================================================");
     OwnTypes();
 }
コード例 #53
0
        public void ProcessCommand(String method_name, String parameter_1, String parameter_2)
        {
            string category;
            string level;
            string osaid; //eventually we will use this to keep track on osa side to handle removing notification once it is seen on one of the devices with the same owner, but for now it is not used
            string messagedate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");;

            string payload;
            string strResponse;

            //look up address again in case it changed, but don't update if we get back a null or blank value (this probably means they renamed the object so looking up by the name we have returns nothing)
            //_gcmid = OSAEObjectManager.GetObjectByName(_name).Address;
            if (OSAEObjectPropertyManager.GetObjectPropertyValue(_name, "GCMID").Value != null)
            {
                if (!OSAEObjectPropertyManager.GetObjectPropertyValue(_name, "GCMID").Value.Equals(""))
                {
                    _gcmid = OSAEObjectPropertyManager.GetObjectPropertyValue(_name, "GCMID").Value;
                }
            }

            gcmsender.DeviceToken = _gcmid;


            switch (method_name)
            {
            case "NOTIFY":

                Log.Info("NOTIFY event triggered (" + _name + "), parameter_1=" + parameter_1 + ", parameter_2=" + parameter_2);
                Log.Debug("address = " + _gcmid);

                category = "default";
                level    = "5";
                osaid    = "-1";  //eventually we will use this to keep track on osa side to handle removing notification once it is seen on one of the devices with the same owner, but for now it is not used

                if (parameter_2 != "")
                {
                    string[] parts = parameter_2.Split(',');

                    if (parts.Length > 0)
                    {
                        category = parts[0];
                    }
                    if (parts.Length > 1)
                    {
                        level = parts[1];
                    }
                }


                payload = "\"type\" : \"notification\" \"message\" : \"" + parameter_1 + "\" \"category\" : \"" + category + "\" \"level\" : \"" + level + "\" \"osaid\" : \"" + osaid + "\" \"messagedate\" : \"" + messagedate + "\" ";

                strResponse = gcmsender.Send(payload);
                Log.Debug("GCM response new version = " + strResponse);

                break;

            case "EXECUTE":

                Log.Info("EXECUTE event triggered (" + _name + "), parameter_1=" + parameter_1 + ", parameter_2=" + parameter_2);
                Log.Debug("address = " + _gcmid);

                category = "#taskertask#";
                level    = "5";
                osaid    = "-1";  //eventually we will use this to keep track on osa side to handle removing notification once it is seen on one of the devices with the same owner, but for now it is not used

                payload = "\"type\" : \"taskertask\" \"message\" : \"" + parameter_1 + "\" \"category\" : \"" + category + "\" \"level\" : \"" + level + "\" \"osaid\" : \"" + osaid + "\" \"messagedate\" : \"" + messagedate + "\" ";

                strResponse = gcmsender.Send(payload);
                Log.Debug("GCM response new version = " + strResponse);

                break;
            }
        }
コード例 #54
0
        public override void RunInterface(string pluginName)
        {
            try
            {
                pName = pluginName;
                Log = new General.OSAELog(pName);
                FirstUpdateRun = true;
                FirstForcastRun = true;
                Log.Info("Running Interface");
                OwnTypes();

                OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("WEATHER");
                if (objects.Count == 0)
                {
                    OSAEObjectManager.ObjectAdd("Weather", "", "Weather Data", "WEATHER", "", "", 30, true);
                    WeatherObjName = "Weather";
                }
                else
                    WeatherObjName = objects[0].Name;

                Log.Info("Linked to Weather object to store data.");
                try
                {
                    if (bool.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Metric").Value))
                    {
                        Metric = true;
                        Log.Info("Using metric units");
                    }
                }
                catch {}

                try
                {
                    gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Debug").Value);
                }
                catch
                { Log.Info("The WUnderground Object Type seems to be missing the Debug Property!"); }
                Log.Info("Debug Mode Set to " + gDebug);

                try
                {
                    pKey = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Key").Value;
                    if (pKey.Length < 1)
                        Log.Info("!!! You need an WUnderground Key for full weather feeds !!!");
                    else
                        Log.Info("Found WUnderground Key (" + pKey + ")");
                }
                catch (Exception ex)
                { Log.Error("Error reading your Key.", ex); }

                try
                {
                    pCity = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "City").Value;
                    if (pCity.Length < 1)
                        Log.Info("!!! You need a City for full weather feeds !!!");
                    else
                        Log.Info("Found WUnderground City (" + pCity + ")");
                }
                catch (Exception ex)
                { Log.Error("Error reading your City.", ex); }

                try
                {
                    pState = OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "State").Value;
                    if (pState.Length < 1)
                        Log.Info("!!! You need a State for full weather feeds !!!");
                    else
                        Log.Info("Found State (" + pState + ")");
                }
                catch (Exception ex)
                { Log.Error("Error reading your State.", ex); }

                Conditionsupdatetime = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Conditions Interval").Value);
                if (Conditionsupdatetime > 0)
                {
                    ConditionsUpdateTimer = new System.Timers.Timer();
                    ConditionsUpdateTimer.Interval = Conditionsupdatetime * 60000;
                    ConditionsUpdateTimer.Start();
                    ConditionsUpdateTimer.Elapsed += new ElapsedEventHandler(ConditionsUpdateTime);

                    updateConditionsThread = new Thread(new ThreadStart(updateconditions));
                    updateConditionsThread.Start();

                  //  Thread.Sleep(10000);
                }
                else
                {
                    latitude = OSAEObjectPropertyManager.GetObjectPropertyValue(WeatherObjName, "latitude").Value;
                    longitude = OSAEObjectPropertyManager.GetObjectPropertyValue(WeatherObjName, "longitude").Value;
                    if (gDebug) Log.Debug("Read in properties: Lat=" + latitude + ", Long=" + longitude);
                }

                do
                {
                    Thread.Sleep(5000);
                } while (FirstUpdateRun);

                Forecastupdatetime = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Forecast Interval").Value);
                if (Forecastupdatetime > 0)
                {
                    ForecastUpdateTimer = new System.Timers.Timer();
                    ForecastUpdateTimer.Interval = Forecastupdatetime * 60000;
                    ForecastUpdateTimer.Start();
                    ForecastUpdateTimer.Elapsed += new ElapsedEventHandler(ForecastUpdateTime);

                    updateForecastThread = new Thread(new ThreadStart(updateforecast));
                    updateForecastThread.Start();
                }

                do
                {
                    Thread.Sleep(5000);
                } while (FirstForcastRun);

                Log.Info("Updated " + WeatherObjName + ", setting Weather object to Updated.");
                OSAE.OSAEMethodManager.MethodQueueAdd(WeatherObjName, "Updated", "", "", pName);

                DayNightUpdateTimer = new System.Timers.Timer();
                DayNightUpdateTimer.Interval = DayNightupdatetime;
                DayNightUpdateTimer.Start();
                DayNightUpdateTimer.Elapsed += new ElapsedEventHandler(DayNightUpdateTime);

                updateDayNightThread = new Thread(new ThreadStart(updateDayNight));
                updateDayNightThread.Start();
            }
            catch (Exception ex)
            { Log.Error("Error initializing the plugin ", ex); }
        }