Ejemplo n.º 1
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.º 2
0
        void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            try
            {
                // ignore empty messages (events)
                if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error)
                {
                    return;
                }

                oldMmsg = msg;

                DataSet dsResults = new DataSet();  //Build a List of all Users to identify who is sending the message.
                dsResults    = OSAESql.RunSQL("SELECT DISTINCT(object_name) FROM osae_v_object_property WHERE property_name = 'JabberID' and property_value = '" + msg.From.Bare + "' ORDER BY object_name");
                gCurrentUser = dsResults.Tables[0].Rows[0][0].ToString();
                OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gCurrentUser);
                gCurrentAddress = msg.From.Bare;

                RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body);
                if (rr == null)
                {
                    if (gDebug)
                    {
                        Log.Debug("INPUT: No Matching Pattern found!");
                    }
                }
            }
            catch (Exception ex)
            { Log.Error("Error in _OnMessage!", ex); }
        }
Ejemplo n.º 3
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));
            }
        }
        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.º 5
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.º 6
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); }
        }
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     if (ValidateForm("Add"))
     {
         string sName = cntrlName.Text;
         OSAEObjectManager.ObjectAdd(sName, sName, sName, osaeControlType + " " + _pluginName, "", currentScreen, 30, true);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "Control Type", osaeControlType + " " + _pluginName, currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "Object Name", objectsComboBox.Text, currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "X", "100", currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "Y", "100", currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "ZOrder", "1", currentUser);
         if (hasParams == true)
         {
             foreach (objParams op in oParams)
             {
                 OSAEObjectPropertyManager.ObjectPropertySet(sName, op.Name, op.Value, currentUser);
             }
         }
         OSAEScreenControlManager.ScreenObjectAdd(currentScreen, objectsComboBox.Text, sName);
         NotifyParentFinished();
     }
     // else
     //  {
     // Do not save until feilds are correct
     //  }
 }
    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;
    }
    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; }
    }
        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.º 11
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.º 12
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.º 13
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];
     }
 }
    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.º 15
0
        void xmppCon_OnPresence(object sender, agsXMPP.protocol.client.Presence pres)
        {
            string[]             jIDRaw  = pres.From.ToString().Split('/');
            string               jID     = jIDRaw[0];
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID);

            if (objects != null)
            {
                foreach (OSAEObject oObj in objects)
                {
                    Log.Info(String.Format("Received Presence from: {0} show: {1} status: {2}", oObj.Name, pres.Show.ToString(), pres.Status));
                    if (pres.Show.ToString() == "away")
                    {
                        OSAEObjectPropertyManager.ObjectPropertySet(oObj.Name, "JabberStatus", "Idle", "Jabber");
                    }
                    else if (pres.Show.ToString() == "NONE")
                    {
                        OSAEObjectPropertyManager.ObjectPropertySet(oObj.Name, "JabberStatus", "Online", "Jabber");
                    }
                    break;
                }
            }
            else
            {
                Log.Info(String.Format("No object found with address of: {0}", jID, pres.Show.ToString(), pres.Status));
            }
        }
Ejemplo n.º 16
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.º 17
0
        void xmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
        {
            string[]             jIDRaw  = item.Jid.Bare.ToString().Split('/');
            string               jID     = jIDRaw[0];
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID);

            if (objects == null)
            {
                bool dupName = OSAEObjectManager.ObjectExists(item.Name);
                if (dupName)
                {
                    Log.Info(String.Format("Found Object {0} for {1}", item.Name, jID));
                }
                else
                {
                    Log.Info(String.Format("Creating new Object {0} for {1}", item.Name, jID));
                    OSAEObjectManager.ObjectAdd(item.Name, "", "Discovered Jabber contact", "PERSON", "", "Unknown", 10, false);
                }
                Log.Info(String.Format("Updating JabberID for {0}", item.Name));
                OSAEObjectPropertyManager.ObjectPropertySet(item.Name, "JabberID", jID, gAppName);
            }
            else
            {
                Log.Info(String.Format("Found Object {0} for {1}", item.Name, jID));
            }
        }
Ejemplo n.º 18
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();
        }
        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.º 20
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;
        }
 private void btnUpdate_Click(object sender, RoutedEventArgs e)
 {
     if (ValidateForm("Update"))
     {
         sWorkingName = cntrlName.Text;
         OSAE.OSAEObject obj = OSAEObjectManager.GetObjectByName(sOriginalName);
         //We call an object update here in case the Name was changed, then perform the updates against the New name
         OSAEObjectManager.ObjectUpdate(sOriginalName, sWorkingName, obj.Alias, obj.Description, obj.Type, obj.Address, obj.Container, obj.MinTrustLevel, obj.Enabled);
         string sName = cntrlName.Text;
         OSAEObjectManager.ObjectUpdate(sOriginalName, sName, "", sName, osaeControlType + " " + _pluginName, "", currentScreen, 30, true);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "Control Type", osaeControlType + " " + _pluginName, currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "Object Name", objectsComboBox.Text, currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "X", cntrlX.Text, currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "Y", cntrlY.Text, currentUser);
         OSAEObjectPropertyManager.ObjectPropertySet(sName, "ZOrder", cntrlZOrder.Text, currentUser);
         if (hasParams == true)
         {
             foreach (objParams op in oParams)
             {
                 OSAEObjectPropertyManager.ObjectPropertySet(sName, op.Name, op.Value, currentUser);
             }
         }
         OSAEScreenControlManager.ScreenObjectUpdate(currentScreen, objectsComboBox.Text, sName);
         NotifyParentFinished();
     }
     // else
     // {
     // Do not save until feilds are correct
     //  }
 }
Ejemplo n.º 22
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);
                }
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show("Please specify a name for the control");
                return;
            }

            if (img == null)
            {
                MessageBox.Show("Please specify an image for the control");
                return;
            }

            if (string.IsNullOrEmpty(screenComboBox.Text))
            {
                MessageBox.Show("Please specify a target for the control");
                return;
            }


            string sName = "Screen - Nav - " + txtName.Text;

            OSAEObjectManager.ObjectAdd(sName, sName, "CONTROL NAVIGATION IMAGE", "", currentScreen, true);
            OSAEObjectPropertyManager.ObjectPropertySet(sName, "Image", img.Name, "GUI");
            OSAEObjectPropertyManager.ObjectPropertySet(sName, "Screen", screenComboBox.Text, "GUI");
            OSAEObjectPropertyManager.ObjectPropertySet(sName, "X", "100", "GUI");
            OSAEObjectPropertyManager.ObjectPropertySet(sName, "Y", "100", "GUI");
            OSAEObjectPropertyManager.ObjectPropertySet(sName, "Zorder", "1", "GUI");

            OSAEScreenControlManager.ScreenObjectAdd(currentScreen, screenComboBox.Text, sName);

            NotifyParentFinished();
        }
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtScreenName.Text))
            {
                MessageBox.Show("Please specify a name for the screen");
                return;
            }

            if (img == null)
            {
                MessageBox.Show("Please specify an image for the screen");
                return;
            }


            string tempName = "Screen - " + txtScreenName.Text.Replace("Screen - ", "");

            OSAE.OSAEObject obj = OSAEObjectManager.GetObjectByName(sOriginalName);
            //We call an object update here in case the Name was changed, then perform the updates against the New name
            OSAEObjectManager.ObjectUpdate(sOriginalName, tempName, obj.Alias, obj.Description, obj.Type, obj.Address, obj.Container, obj.Enabled);
            OSAEObjectPropertyManager.ObjectPropertySet(tempName, "Background Image", img.Name, "GUI");

            //OnLoadScreen();

            NotifyParentFinished();
        }
Ejemplo n.º 25
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); }
 }
Ejemplo n.º 26
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.º 27
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.º 28
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.º 29
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);
 }
Ejemplo n.º 30
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.");
                }
            }
        }