protected void Page_Load(object sender, EventArgs e)
    {
        ObjectName = screenObject.Property("Object Name").Value;
        OSAEObjectState os = OSAEObjectStateManager.GetObjectStateValue(ObjectName);

        CurrentState = os.Value;

        OffTimer    = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "OFF TIMER").Value);
        TimeInState = (int)os.TimeInState;

        string sBackColor = screenObject.Property("Back Color").Value;
        string sForeColor = screenObject.Property("Fore Color").Value;
        string sPrefix    = screenObject.Property("Prefix").Value;
        string sSuffix    = screenObject.Property("Suffix").Value;
        string iFontSize  = screenObject.Property("Font Size").Value;

        if (CurrentState == "OFF")
        {
            sValue = os.StateLabel;
        }
        else
        {
            span   = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
            sValue = span.ToString(@"mm\:ss");
        }

        TimerLabel.Text = sValue;
        TimerLabel.Attributes.Add("Style", "position:absolute;top:" + (Int32.Parse(screenObject.Property("Y").Value) + 50).ToString() + "px;left:" + (Int32.Parse(screenObject.Property("X").Value) + 10).ToString() + "px;z-index:" + (Int32.Parse(screenObject.Property("ZOrder").Value) + 10).ToString() + ";");

        if (sBackColor != "")
        {
            try
            {
                TimerLabel.BackColor = Color.FromName(sBackColor);
            }
            catch (Exception)
            {
            }
        }
        if (sForeColor != "")
        {
            try
            {
                TimerLabel.ForeColor = Color.FromName(sForeColor);
            }
            catch (Exception)
            {
            }
        }
        if (iFontSize != "")
        {
            try
            {
                TimerLabel.Font.Size = new FontUnit(iFontSize);
            }
            catch (Exception)
            {
            }
        }
    }
Ejemplo n.º 2
0
 private void imgTodayDay_MouseUp(object sender, MouseButtonEventArgs e)
 {
     try
     {
         //    ControlWidth = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Width").Value);
         //   ControlHeight = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Height").Value);
         maxDays = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Max Days").Value);
     }
     catch (Exception ex)
     { }
     if (sMode == "Max")
     {
         sMode      = "Min";
         this.Width = sizes[0];
         //          bool minimized = Convert.ToBoolean( screenObject.Property("Minimized").Value);
         OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Minimized", "TRUE", gAppName);
         OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Width", sizes[0].ToString(), gAppName);
         ControlWidth = sizes[0];
     }
     else
     {
         sMode      = "Max";
         this.Width = sizes[maxDays];
         OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Minimized", "FALSE", gAppName);
         OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Width", sizes[maxDays].ToString(), gAppName);
         ControlWidth = sizes[maxDays];
         // grdControl.Width = sizes[maxDays];
     }
 }
Ejemplo n.º 3
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); }
        }
Ejemplo n.º 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.");
                }
            }
        }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
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;

            try
            {
                logging.AddToLog("Starting Rest Interface", true);

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

                serviceHost = new WebServiceHost(typeof(OSAERest.api), new Uri("http://localhost:8732/api"));
                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
                    });
                }

                logging.AddToLog("Starting Rest Interface", true);
                serviceHost.Open();
            }
            catch (Exception ex)
            {
                logging.AddToLog("Error starting RESTful web service: " + ex.Message, true);
            }
        }
Ejemplo n.º 7
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            if (OSAEObjectManager.ObjectExists(gAppName))
            {
                Log.Info("Found the Network Monitor plugin's Object (" + gAppName + ")");
            }

            this.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);

            this.updateThread = new Thread(new ThreadStart(update));
            this.updateThread.Start();
        }
Ejemplo n.º 8
0
 public string renameingSys(string fieldData)
 {
     newData = fieldData.Replace("http://", "");
     while (newData.IndexOf("[") != -1)
     {
         int    ss             = newData.IndexOf("[");
         int    es             = newData.IndexOf("]");
         string renameProperty = newData.Substring(ss + 1, (es - ss) - 1);
         string getProperty    = OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Property("Object Name").Value, renameProperty).Value;
         // log any errors
         if (getProperty.Length > 0)
         {
             newData = newData.Replace("[" + renameProperty + "]", getProperty);
         }
         else
         {
             this.Log.Error("Property has NO data");
         }
         if (getProperty == null)
         {
             this.Log.Error("Property: NOT FOUND");
         }
     }
     newData = @"http://" + newData;
     return(newData);
 }
        public override void RunInterface(string pluginName)
        {
            this.Log.Info("*** Running Interface! ***");
            gAppName = pluginName;
            if (OSAEObjectManager.ObjectExists(gAppName))
            {
                Log.Info("Found Bluetooth 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.");
        }
Ejemplo n.º 10
0
        private void WriteData()
        {
            foreach (var item in RealMonitorItems)
            {
                var osaObj         = OSAEObjectPropertyManager.GetObjectPropertyValue(item, "OSAObject");
                var osaProp        = OSAEObjectPropertyManager.GetObjectPropertyValue(item, "OSAObjectProperty");
                var cosmFeed       = OSAEObjectPropertyManager.GetObjectPropertyValue(item, "COSMFeedID");
                var cosmDataStream = OSAEObjectPropertyManager.GetObjectPropertyValue(item, "COSMDataStream");
                var cosmAPIKey     = OSAEObjectPropertyManager.GetObjectPropertyValue(item, "COSMAPIKey");

                var osaCurrValue = OSAEObjectPropertyManager.GetObjectPropertyValue(osaObj.Value, osaProp.Value);
                if (osaCurrValue == null || osaCurrValue.Value.Trim() == string.Empty)
                {
                    Log.Info(string.Format("*** ERROR {0} monitoring OSA Object {1} Property {2} and sending to COSM Feed {3} and DataStream {4} not found or value is empty", item, osaObj.Value, osaProp.Value, cosmFeed.Value, cosmDataStream.Value));
                }
                else
                {
                    Log.Debug(string.Format("Sending {0} monitoring OSA Object {1} Property {2} and sending to COSM Feed {3} and DataStream {4} and Current Value of {5}", item, osaObj.Value, osaProp.Value, cosmFeed.Value, cosmDataStream.Value, osaCurrValue.Value));
                }

                var timestamp = DateTime.UtcNow.ToString("s") + "Z";
                var bulk      = string.Format("{0},{1}", timestamp, osaCurrValue.Value);
                cosmTest.Send(cosmAPIKey.Value, cosmFeed.Value, cosmDataStream.Value, bulk);
            }
        }
Ejemplo n.º 11
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));
            }
        }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"] == null)
        {
            Response.Redirect("~/Default.aspx?ReturnUrl=config.aspx");
        }
        int objSet = OSAEAdminManager.GetAdminSettingsByName("Config Trust");
        int tLevel = Convert.ToInt32(Session["TrustLevel"].ToString());

        if (tLevel < objSet)
        {
            Response.Redirect("~/permissionError.aspx");
        }
        SetSessionTimeout();
        if (!IsPostBack)
        {
            lblVersion.Text = OSAEObjectPropertyManager.GetObjectPropertyValue("SYSTEM", "DB Version").Value;
            if (OSAEObjectPropertyManager.GetObjectPropertyValue("SYSTEM", "Debug").Value == "TRUE")
            {
                ddlDebug.SelectedIndex = 0;
            }
            else
            {
                ddlDebug.SelectedIndex = 1;
            }
            CheckServiceStatus();
            GetDBSize();
            GetTableSizes();
            checkForUpdates();
        }
    }
Ejemplo n.º 13
0
        private void connect()
        {
            Jid jidUser = new Jid(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Username").Value);

            xmppCon.Username = jidUser.User;
            xmppCon.Server   = jidUser.Server;
            xmppCon.Password = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Password").Value;
            xmppCon.AutoResolveConnectServer = true;
            Log.Info("Connecting to: " + xmppCon.Server + " as user: "******"ID: " + xmppCon.MyJID.ToString());
                }
                if (gDebug)
                {
                    Log.Debug("Authenticated: " + xmppCon.Authenticated.ToString());
                }
            }
            catch (Exception ex)
            { Log.Error("Error connecting: ", ex); }
        }
Ejemplo n.º 14
0
        private void GetMatches(OSAEObjectCollection collection)
        {
            logging.AddToLog("Watching for the following Messages:", false);
            foreach (OSAEObject obj in collection)
            {
                SysLogObject sysLogObj = new SysLogObject();

                sysLogObj.TriggerString = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Trigger String").Value;
                sysLogObj.Source        = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Source IP").Value;
                sysLogObj.ExactMatch    = bool.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Exact Match").Value);
                sysLogObj.OsaObjectName = obj.Name;

                lookup.Add(sysLogObj);
                logging.AddToLog("Source IP is: " + sysLogObj.Source, false);

                if (sysLogObj.ExactMatch)
                {
                    logging.AddToLog("Message exactly matches: " + sysLogObj.TriggerString, false);
                }
                else
                {
                    logging.AddToLog("Message Contains: " + sysLogObj.TriggerString, false);
                }
            }
        }
Ejemplo n.º 15
0
        public VideoStreamViewer(string url, OSAEObject obj)
        {
            InitializeComponent();
            screenObject       = obj;
            _mjpeg             = new MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error      += _mjpeg_Error;
            var imgsWidth  = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Width").Value;
            var imgsHeight = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Height").Value;

            streamURI = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
            if (imgsWidth != "")
            {
                imgWidth = Convert.ToDouble(imgsWidth);
            }
            if (imgsHeight != "")
            {
                imgHeight = Convert.ToDouble(imgsHeight);
            }
            this.Width   = imgWidth;
            this.Height  = imgHeight;
            image.Width  = imgWidth;
            image.Height = imgHeight;
            if (streamURI == null)
            {
                this.Log.Error("Stream Path Not Found: " + streamURI);
                message.Content = "Can Not Open: " + streamURI;
            }
            else
            {
                streamURI = renameingSys(streamURI);
                this.Log.Info("Streaming: " + streamURI);
                _mjpeg.ParseStream(new Uri(streamURI));
            }
        }
Ejemplo n.º 16
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();
        }
Ejemplo n.º 17
0
        public void loadData(string objectName)
        {
            device_id             = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Id").Value;
            name                  = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Name").Value;
            name_long             = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Name Long").Value;
            battery_health        = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Battery Health").Value;
            co_alarm_state        = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "CO Alarm State").Value;
            smoke_alarm_state     = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Smoke Alarm State").Value;
            last_manual_test_time = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Last Manual Test").Value;
            ui_color_state        = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "UI Color State").Value;
            locale                = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Locale").Value;
            software_version      = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Software Version").Value;
            structure_id          = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Structure ID").Value;

            //convert _lastConnection to standard format for comparison
            DateTime _lastConnection;

            last_connection = OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Last Connection").Value;

            if (!DateTime.TryParse(last_connection, out _lastConnection))
            {
                last_connection = "";
            }
            else
            {
                last_connection = _lastConnection.ToString("G"); // 1/29/2015 8:43:16 PM
            }
            bool _is_manual_test_active, _is_online;

            bool.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Manual Test Active").Value, out _is_manual_test_active);
            is_manual_test_active = _is_manual_test_active;
            bool.TryParse(OSAEObjectPropertyManager.GetObjectPropertyValue(objectName, "Is Online").Value, out _is_online);
            is_online = _is_online;
        }
Ejemplo n.º 18
0
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;

            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("WEATHER");

            if (objects.Count == 0)
            {
                OSAEObjectManager.ObjectAdd("Weather Data", "Weather Data", "WEATHER", "", "SYSTEM", true);
            }
            if (!Directory.Exists(Common.ApiPath + "/Images/Weather"))
            {
                DirectoryInfo di = Directory.CreateDirectory(Common.ApiPath + "/Images/Weather");
            }

            logging.AddToLog("Running Interface!", true);
            Clock          = new System.Timers.Timer();
            Clock.Interval = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Update Interval").Value) * 60000;
            Clock.Start();
            Clock.Elapsed += new ElapsedEventHandler(Timer_Tick);

            Clock2          = new System.Timers.Timer();
            Clock2.Interval = 24 * 60 * 60000;
            Clock2.Start();
            Clock2.Elapsed += new ElapsedEventHandler(Timer_Tick);

            this.SunriseSunsetThread = new Thread(new ThreadStart(SunriseSunset));
            this.SunriseSunsetThread.Start();

            this.updateThread = new Thread(new ThreadStart(update));
            this.updateThread.Start();
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"] == null)
        {
            Response.Redirect("~/Default.aspx");
        }
        int objSet = OSAEAdminManager.GetAdminSettingsByName("Screen Trust");
        int tLevel = Convert.ToInt32(Session["TrustLevel"].ToString());

        if (tLevel < objSet)
        {
            Response.Redirect("~/permissionError.aspx");
        }

        getRestPort();
        hdnUserTrust.Value = Session["TrustLevel"].ToString();
        debuglabel.Text    = Session["TrustLevel"].ToString();
        gScreen            = Request.QueryString["id"];
        try
        {
            OSAEObject screen = OSAEObjectManager.GetObjectByName(gScreen);
            //List<OSAEScreenControl> controls = OSAEScreenControlManager.GetScreenControls(gScreen);
            OSAEObjectCollection screenObjects = OSAEObjectManager.GetObjectsByContainer(gScreen);
            string    sImg = OSAEObjectPropertyManager.GetObjectPropertyValue(gScreen, "Background Image").Value.ToString();
            OSAEImage img  = imgMgr.GetImage(sImg);
            imgBackground.ImageUrl = "~/ImageHandler.ashx?id=" + img.ID;
            foreach (OSAEObject obj in screenObjects)
            {
                LoadControl(obj);
            }
        }
        catch
        { return; }
    }
    protected void imgSubmit_Click(object sender, EventArgs e)
    {
        OSAEObject obj = OSAEObjectManager.GetObjectByName(txtUserName.Text);

        if (obj != null)
        {
            string pass = obj.Property("Password").Value;
            if (pass == txtPassword.Text)
            {
                if (pass != "")
                {
                    // Success, create non-persistent authentication cookie.
                    FormsAuthentication.SetAuthCookie(txtUserName.Text.Trim(), false);
                    Int32 cto = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue("Web Server", "Timeout").Value);
                    FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket(txtUserName.Text.Trim(), true, cto);
                    HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1));
                    Response.Cookies.Add(cookie1);
                    Session["UserName"]      = OSAEObjectManager.GetObjectByName(this.txtUserName.Text.Trim()).Name;
                    Session["TrustLevel"]    = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Trust Level").Value;
                    Session["SecurityLevel"] = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Security Level").Value;
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(txtUserName.Text.Trim(), false);
                    Int32 cto = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue("Web Server", "Timeout").Value);
                    FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket(txtUserName.Text.Trim(), true, cto);
                    HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1));
                    Response.Cookies.Add(cookie1);
                    Session["UserName"]      = OSAEObjectManager.GetObjectByName(this.txtUserName.Text.Trim()).Name;
                    Session["TrustLevel"]    = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Trust Level").Value;
                    Session["SecurityLevel"] = OSAEObjectPropertyManager.GetObjectPropertyValue(this.txtUserName.Text.Trim(), "Security Level").Value;
                }
                // 4. Do the redirect.
                string    returnUrl1;
                OSAEAdmin adSet  = OSAEAdminManager.GetAdminSettings();
                int       tLevel = Convert.ToInt32(Session["TrustLevel"].ToString());
                if (Session["SecurityLevel"].ToString() != "Admin" & tLevel < adSet.ObjectsTrust)
                {
                    returnUrl1 = "screens.aspx?id=" + adSet.defaultScreen;
                }
                else
                {
                    if (Request.QueryString["ReturnUrl"] == null)
                    {
                        returnUrl1 = "objects.aspx";                                            // the login is successful
                    }
                    else
                    {
                        returnUrl1 = Request.QueryString["ReturnUrl"];   //login not unsuccessful
                    }
                }
                Response.Redirect(returnUrl1);
            }
            else
            {
                lblError.Visible = true;
            }
        }
        lblError.Visible = true;
    }
        private void oRecognizer_StateChanged(object sender, System.Speech.Recognition.AudioStateChangedEventArgs e)
        {
            switch (oRecognizer.AudioState.ToString())
            {
            case "Stopped":
                lblAudioState.Content = "I hear silence.";
                break;

            case "Speech":
                // gSpeechPlugin;
                String temp = OSAEObjectPropertyManager.GetObjectPropertyValue(gSpeechPlugin, "Speaking").Value.ToString().ToLower();

                if (temp.ToLower() == "true")
                {
                    lblAudioState.Content = "I hear myself.";
                }
                else
                {
                    lblAudioState.Content = "I hear talking.";
                }
                break;

            case "Silence":
                lblAudioState.Content = "I hear silence.";
                break;
            }
        }
Ejemplo n.º 22
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); }
        }
Ejemplo n.º 23
0
        public override void RunInterface(string pluginName)
        {
            gAppName = pluginName;
            if (OSAEObjectManager.ObjectExists(gAppName))
            {
                Log.Info("Found the Jabber plugin's Object (" + 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();

            // 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();
        }
Ejemplo n.º 24
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); }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Uri uri         = new Uri("pack://siteoforigin:,,,/OSA.png");
            var bitmapImage = new BitmapImage(uri);


            canGUI.Background = new ImageBrush(bitmapImage);
            canGUI.Height     = bitmapImage.Height;
            canGUI.Width      = bitmapImage.Width;
            canGUI.Background = new ImageBrush(bitmapImage);
            canGUI.Height     = bitmapImage.Height;
            canGUI.Width      = bitmapImage.Width;

            Load_App_Name();
            gCurrentScreen = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Default Screen").Value;
            if (gCurrentScreen == "")
            {
                Set_Default_Screen();
            }
            Load_Screen(gCurrentScreen);

            Thread thread = new Thread(() => Update_Objects());

            thread.Start();

            this.canGUI.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(DragSource_PreviewMouseLeftButtonDown);
            this.canGUI.Drop += new DragEventHandler(DragSource_Drop);
        }
Ejemplo n.º 26
0
        UInt32 pollInterval = 250; // 4x a second
        #endregion

        private void AddIO(string address, Direction dir, string serial, byte id)
        {
            if (OSAEObjectManager.GetObjectByAddress(address) == null)
            {
                if (dir == Direction.Input)
                {
                    OSAEObjectManager.ObjectAdd("J-Works-I" + address, "", "J -Works input", "JWORKS INPUT", address, "", 30, true);
                }
                else
                {
                    OSAEObjectManager.ObjectAdd("J-Works-0" + address, "", "J-Works output", "JWORKS OUTPUT", address, "", 30, true);
                }

                OSAEObjectPropertyManager.ObjectPropertySet(address, "Serial", serial, pName);
                OSAEObjectPropertyManager.ObjectPropertySet(address, "Id", Convert.ToString(id), pName);
                OSAEObjectPropertyManager.ObjectPropertySet(address, "Invert", "FALSE", pName);
            }

            OSAEObject obj = OSAEObjectManager.GetObjectByAddress(address);

            bool invert = (OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Invert").Value == "TRUE");

            // initial state is 0; interpret that in light of Invert setting
            OSAEObjectStateManager.ObjectStateSet(obj.Name, invert ? "ON" : "OFF", pName);
        }
Ejemplo n.º 27
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Load_App_Name();
            try
            {
                oRecognizer.SpeechRecognized  += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized);
                oRecognizer.AudioStateChanged += new EventHandler <AudioStateChangedEventArgs>(oRecognizer_StateChanged);
                AudioState state = oRecognizer.AudioState;  // This shows AudioState.Stopped
            }
            catch (Exception ex)
            {
                AddToLog("Unable to configure oRecognizer");
                AddToLog("Error: " + ex.Message);
            }

            Load_Settings();
            Load_Grammer();
            Load_Grammer_With_Substitutions();
            try
            {
                oRecognizer.SetInputToDefaultAudioDevice();
                AddToLog("Recognizer Settings: ");
                AddToLog("--  Level: " + oRecognizer.AudioLevel.ToString());
                AddToLog("--  End Silence Timeout: " + oRecognizer.EndSilenceTimeout);
                AddToLog("--  Recognition Babble Timeout: " + oRecognizer.BabbleTimeout);
                AddToLog("Audio Format Settings: ");
                AddToLog("--  EncodingFormat: " + oRecognizer.AudioFormat.EncodingFormat);
                AddToLog("--  Channel Count: " + oRecognizer.AudioFormat.ChannelCount);
                AddToLog("--  Bits Per Sample: " + oRecognizer.AudioFormat.BitsPerSample);
                AddToLog("--  Samples Per Second: " + oRecognizer.AudioFormat.SamplesPerSecond);
                AddToLog("--  Average Bytes Per Second: " + oRecognizer.AudioFormat.AverageBytesPerSecond);
                gSpeechPlugin = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Can Hear this Plugin").Value.ToString();
                if (gSpeechPlugin == "")
                {
                    gSpeechPlugin = "Speech";
                    OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Can Hear this Plugin", "Speech", "VR Client");
                }
                AddToLog("--  I will ignore speech from: " + gSpeechPlugin);
                Thread t1 = new Thread(delegate()
                {
                    oRecognizer.SetInputToDefaultAudioDevice();
                    oRecognizer.RecognizeAsync();
                    while (!gAppClosing)
                    {
                        Thread.Sleep(333);
                    }
                });
                t1.Start();

                //oRecognizer.RecognizeAsync();

                AddToLog("Finished Loading, Recognition Started...");
            }
            catch (Exception ex)
            {
                AddToLog("Unable to set Default Audio Device.  Check Sound Card.");
                AddToLog("Error: " + ex.Message);
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Load_App_Name();

            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)
            {
                AddToLog("Unable to configure oRecognizer");
                AddToLog("Error: " + ex.Message);
            }

            Load_Settings();
            Common.CheckComputerObject(gAppName);
            oRecognizer = OSAEGrammar.Load_User_Grammar(oRecognizer);
            try
            {
                gSpeechPlugin = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Can Hear this Plugin").Value.ToString();
                if (gSpeechPlugin == "")
                {
                    gSpeechPlugin = "Speech";
                    OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Can Hear this Plugin", "Speech", "VR Client");
                }
                AddToLog("--  I will ignore speech from: " + gSpeechPlugin);

                oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer);
                oRecognizer = OSAEGrammar.Load_Voice_Grammars(oRecognizer);
                SaveGrammars();

                AddToLog("Finished Loading...");
                AddToLog("_______________________________________________");
                AddToLog("Who are you?");

                Thread t1 = new Thread(delegate()
                {
                    oRecognizer.SetInputToDefaultAudioDevice();
                    oRecognizer.RecognizeAsync(RecognizeMode.Multiple);
                    while (!gAppClosing)
                    {
                        Thread.Sleep(333);
                    }
                });
                t1.Start();
            }
            catch (Exception ex)
            {
                AddToLog("Unable to set Default Audio Device.  Check Sound Card.");
                AddToLog("Error: " + ex.Message);
            }
        }
Ejemplo n.º 29
0
        private void Load_Settings()
        {
            try
            {
                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);
                gSelectedVoice = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Voice").Value;
                OSAEObjectPropertyManager.ObjectPropertyArrayDeleteAll(gAppName, "Voices");
                foreach (System.Speech.Synthesis.InstalledVoice i in oSpeech.GetInstalledVoices())
                {
                    if (gSelectedVoice == "")
                    {
                        gSelectedVoice = i.VoiceInfo.Name;
                        OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Voice", gSelectedVoice, "SPEECH");
                        Log.Info("Default Voice Set to " + gSelectedVoice);
                    }
                    Log.Info("Adding Voice: " + i.VoiceInfo.Name);
                    OSAEObjectPropertyManager.ObjectPropertyArrayAdd(gAppName, "Voices", i.VoiceInfo.Name, "Voice");
                }

                if (gSelectedVoice != "")
                {
                    oSpeech.SelectVoice(gSelectedVoice);
                    Log.Info("Current Voice Set to " + gSelectedVoice);
                }

                // Load the speech rate, which must be -10 to 10, and set it to 0 if it is not valid.
                Int16 iTTSRate = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Rate").Value);
                if (iTTSRate < -10 || iTTSRate > 10)
                {
                    iTTSRate = 0;
                    OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "TTS Rate", iTTSRate.ToString(), gAppName);
                    Log.Info("TTS Rate was invalid! I changed it to " + iTTSRate.ToString());
                }
                Log.Info("TTS Rate Set to " + iTTSRate.ToString());
                oSpeech.Rate = iTTSRate;

                Int16 iTTSVolume = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Volume").Value);
                if (iTTSVolume < -10 || iTTSVolume > 10)
                {
                    iTTSVolume = 0;
                    OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "TTS Volume", iTTSVolume.ToString(), gAppName);
                    Log.Info("TTS Volume was invalid! I changed it to " + iTTSVolume.ToString());
                }
                oSpeech.Rate = iTTSVolume;
                Log.Info("TTS Volume Set to " + iTTSVolume.ToString());
            }
            catch (Exception ex)
            {
                Log.Error("Error in Load_Settings!", ex);
            }
        }
Ejemplo n.º 30
0
        private void cboUsers_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (loadingFlag)
            {
                return;
            }

            _CurrentUser      = "";
            _CurrentUserTrust = 0;
            _pwbuff           = "";
            _usersPIN         = "";
            lblPIN.Content    = "";
            if (cboUsers.SelectedIndex == 1)
            {
                userGrid.Height = cboUsers.Height;
                lock_Red();
                OSAE.OSAEObjectPropertyManager.ObjectPropertySet(_AppName, "Current User", "", "SYSTEM");
                cboUsers.ContextMenu = null;
                OSAE.OSAEObjectPropertyManager.ObjectPropertySet(_AppName, "LogOut on Close", "TRUE", _CurrentUser);
            }
            else
            {
                //Load user's PIN
                _usersPIN = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(cboUsers.SelectedItem.ToString(), "PIN").Value;
                if (_usersPIN == "")
                {
                    userGrid.Height = 184;
                    lock_Green();
                    _CurrentUserTrust = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(cboUsers.SelectedItem.ToString(), "Trust Level").Value);
                    _CurrentUser      = cboUsers.SelectedItem.ToString();
                    OSAE.OSAEObjectPropertyManager.ObjectPropertySet(_AppName, "Current User", _CurrentUser, "SYSTEM");

                    // Add Remember me option
                    ContextMenu ctmRembMe = new ContextMenu();
                    MenuItem    miRembMe  = new MenuItem();
                    miRembMe.Name        = "rememberMode";
                    miRembMe.IsCheckable = true;
                    miRembMe.Checked    += rememberMode_Checked;
                    miRembMe.Unchecked  += rememberMode_Unchecked;
                    miRembMe.Header      = "LogOut on Close";
                    string remUser = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(_AppName, "LogOut on Close").Value;
                    bool   loUser  = Convert.ToBoolean(remUser);
                    if (loUser == true)
                    {
                        miRembMe.IsChecked = true;
                    }
                    else
                    {
                        miRembMe.IsChecked = false;
                    }
                    ctmRembMe.Items.Add(miRembMe);
                    cboUsers.ContextMenu = ctmRembMe;
                }
                else
                {
                    userGrid.Height = 184;
                }
            }
        }