Пример #1
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                string pattern = Common.MatchPattern(args[0]);
                //this.Log.Info("Processing command: " + args[0] + ", Named Script: " + pattern);
                if (pattern != string.Empty)
                {
                    OSAEScriptManager.RunPatternScript(pattern, "", "OSACL");
                }
            }
            else
            {
                //Debugger.Launch();
#if OSAESERVICECONTROLLER
                if (Environment.UserInteractive)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new OSAEServiceController(new ClientService(), "Client Service Controller"));
                }
                else
                {
                    OSAEServiceBase.Run(new ClientService());
                }
#else
                ServiceBase.Run(new ClientService());
#endif
            }
        }
        public Boolean SendPattern(string pattern)
        {
            string patternName = Common.MatchPattern(pattern);

            if (!string.IsNullOrEmpty(patternName))
            {
                OSAEScriptManager.RunPatternScript(patternName, "", sourceName);
            }
            return(true);
        }
        private void oRecognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            DataSet dsResults = new DataSet();
            String  sPattern  = "";

            try
            {
                if ((e.Result.Text == gWakePhrase) & (gVRMuted == true))
                {
                    gVRMuted          = false;
                    lblStatus.Content = "I am awake";
                }
                else if ((e.Result.Text == gSleepPhrase) & (gVRMuted == false))
                {
                    gVRMuted          = true;
                    lblStatus.Content = "I am sleeping";
                }
                // gSpeechPlugin;
                String temp = OSAEObjectPropertyManager.GetObjectPropertyValue(gSpeechPlugin, "Speaking").Value.ToString().ToLower();

                if (temp.ToLower() == "true")
                {
                    try
                    {
                        AddToLog("Ignored Speech because TTS was talking.");
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    if ((gVRMuted == false) || (e.Result.Text == gSleepPhrase) || (e.Result.Text == gSleepPhrase))
                    {
                        try
                        {
                            string sText = OSAE.Common.MatchPattern(e.Result.Text);
                            OSAEScriptManager.RunPatternScript(sText, "", "VR");
                            AddToLog("Heard: " + e.Result.Text + ", Ran: " + sText);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AddToLog("Error in _SpeechRecognized: " + ex.Message);
            }
        }
Пример #4
0
        public Boolean SendPattern(string match)
        {
            string patternName = Common.MatchPattern(match);

            if (patternName != "")
            {
                OSAEScriptManager.RunPatternScript(patternName, "", "REST Service");
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// The Main Thread: This is where your Service is Run.
 /// </summary>
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         string pattern = Common.MatchPattern(args[0]);
         Logging.AddToLog("Processing command: " + args[0] + ", Named Script: " + pattern, true, "OSACL");
         if (pattern != string.Empty)
         {
             OSAEScriptManager.RunPatternScript(pattern, "", "OSACL");
         }
     }
     else
     {
         ServiceBase.Run(new OSAEService());
     }
 }
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         string pattern = Common.MatchPattern(args[0]);
         //this.Log.Info("Processing command: " + args[0] + ", Named Script: " + pattern);
         if (pattern != string.Empty)
         {
             OSAEScriptManager.RunPatternScript(pattern, "", "OSACL");
         }
     }
     else
     {
         //Debugger.Launch();
         ServiceBase.Run(new ClientService());
     }
 }
Пример #7
0
        void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            // ignore empty messages (events)
            if (msg.Body == null)
            {
                return;
            }

            logging.AddToLog(String.Format("OnMessage from:{0} type:{1}", msg.From.Bare, msg.Type.ToString()), false);
            logging.AddToLog("Message: " + msg.Body, false);
            string pattern = Common.MatchPattern(msg.Body);

            if (pattern != string.Empty)
            {
                OSAEScriptManager.RunPatternScript(pattern, msg.From.Bare, "Jabber");
            }
        }
Пример #8
0
        public static string MatchPattern(string str)
        {
            string ScriptParameter = "";

            try
            {
                DataSet dataset = new DataSet();
                //command.CommandText = "SELECT pattern FROM osae_v_pattern WHERE `match`=@Name";
                //command.Parameters.AddWithValue("@Name", str);
                dataset = OSAESql.RunSQL("SELECT pattern FROM osae_v_pattern WHERE `match`='" + str + "'");

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    //Since we have a match, lets execute the scripts
                    OSAEScriptManager.RunPatternScript(dataset.Tables[0].Rows[0]["pattern"].ToString(), "", "Jabber");
                    return(dataset.Tables[0].Rows[0]["pattern"].ToString());
                }
                else
                {
                    //Replace Words with place holders and retry the pattern match
                    //example  "Please turn the main light on" becomes "Please turn the [OBJECT] [STATE]"

                    //Step 1: Break the Input into an Array to Query the Words for DB matches
                    str = str.ToUpper();
                    string[] words = str.Split(' ');

                    DataSet dsObjects = new DataSet();
                    foreach (String word in words)
                    {
                        dsObjects = OSAE.Common.ObjectNamesStartingWith(word);
                        foreach (DataRow dr in dsObjects.Tables[0].Rows)
                        {
                            if (str.IndexOf(dr["object_name"].ToString()) > -1)
                            //return "Found " + dr["object_name"].ToString();
                            {
                                str              = str.Replace(dr["object_name"].ToString(), "[OBJECT]");
                                ScriptParameter += dr["object_name"].ToString();
                                //Here We have found our Object, so we need to look for an appropriate state afterwards
                                //So we are going to retrieve a state list and compare it to the remainder of the string

                                DataSet dsStates = new DataSet();
                                dsStates = OSAEObjectStateManager.ObjectStateListGet(dr["object_name"].ToString());
                                foreach (DataRow drState in dsStates.Tables[0].Rows)
                                {
                                    if (str.IndexOf(drState["state_label"].ToString().ToUpper()) > 0)
                                    {
                                        str              = str.Replace(drState["state_label"].ToString().ToUpper(), "[STATE]");
                                        ScriptParameter += ", " + drState["state_label"].ToString();

                                        //Now that we have replaced the Object and State, Lets check for a match again
                                        //DataSet dataset = new DataSet();
                                        //command.CommandText = "SELECT pattern FROM osae_v_pattern WHERE `match`=@Name";
                                        //command.Parameters.AddWithValue("@Name", str);
                                        //dataset = OSAESql.RunQuery(command);
                                        dataset = OSAESql.RunSQL("SELECT pattern FROM osae_v_pattern WHERE `match`='" + str + "'");
                                        if (dataset.Tables[0].Rows.Count > 0)
                                        {
                                            //return dataset.Tables[0].Rows[0]["pattern"].ToString();
                                            //Since we have a match, lets execute the scripts
                                            OSAEScriptManager.RunPatternScript(dataset.Tables[0].Rows[0]["pattern"].ToString(), ScriptParameter, "Jabber");
                                            return(dataset.Tables[0].Rows[0]["pattern"].ToString());
                                        }
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    return(string.Empty);
                    //return string.Empty;
                }
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - MatchPattern error: " + ex.Message, true);
                return(string.Empty);
            }
        }