Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new realtime query
        /// </summary>
        /// <param name="query">The core query to base this request on</param>
        /// <param name="slowAndSafe">Should the system try catch each event called?</param>
        /// <param name="runOnMainThread">Shoud the system make sure the events will only be called on the main thread</param>
        /// <param name="parseClient">an override to the parse client</param>
        /// <param name="parseLiveQueryClient">an overide to the live query client</param>
        /// <param name="enterFiresUpdate">when an object enters the query a update event will be called after enter</param>
        public RealtimeQuery(ParseQuery <T> query, bool slowAndSafe = false, bool runOnMainThread = true, ParseClient parseClient = null, ParseLiveQueryClient parseLiveQueryClient = null, bool enterFiresUpdate = true)
        {
            if (!ContextCache.IsInitialized)
            {
                ContextCache.Initialize();
            }

            // Get the collections started
            watchedObjects      = new Dictionary <string, T>();
            OnEnterListeners    = new List <Action <T> >();
            OnCreateListeners   = new List <Action <T> >();
            OnUpdateListeners   = new List <Action <T> >();
            OnLeaveListeners    = new List <Action <T> >();
            OnDeleteListeners   = new List <Action <T> >();
            OnDestroyListenters = new List <Action>();

            this.query            = query;
            this.slowAndSafe      = slowAndSafe;
            this.runOnMainThread  = runOnMainThread;
            this.enterFiresUpdate = enterFiresUpdate;

            // look to see if there is a ParseClientOverride
            if (parseClient == null)
            {
                this.parseClient = ParseClient.Instance;
            }
            else
            {
                this.parseClient = parseClient;
            }

            if (parseLiveQueryClient == null)
            {
                this.parseLiveQueryClient = ParseLiveQueryClient.Instance;
            }
            else
            {
                this.parseLiveQueryClient = parseLiveQueryClient;
            }

            Lifecycle.OnUnityQuit += Destroy;

            Lifecycle.OnUnityFocus += OnFocusChanged;

            // Setup the query
            SetupQuery();
        }
Ejemplo n.º 2
0
        internal void Initialize()
        {
            Galatea.AI.Robotics.SensoryMotorSystem machine = null;
            VisualProcessor vision          = null;
            IRobot          robot           = null;
            ContextCache    newContextCache = null;
            IChatbotManager chatbots        = null;

            // Initialize Foundation Components
            try
            {
                machine = new Galatea.AI.Robotics.Machine();
                machine.Initialize(this);

                vision = new VisualProcessor(Settings.Default.ImagingSettings);
                vision.Initialize(this);

                // Become Self-Aware
                robot           = SelfAwareness.BecomeSelfAware(this, "Skynet");
                newContextCache = new ContextCache();
                newContextCache.Initialize(this.ExecutiveFunctions);
                // Verify that ContextCache is instantiated
                System.Diagnostics.Debug.Assert(ExecutiveFunctions.ContextCache != null);

                // Initialize Language Module
                this.User = new User(Settings.Default.DefaultUserName);
                chatbots  = new ChatbotManager();
                robot.LanguageModel.LoadChatbots(chatbots);

                var substitutions = new List <string>
                {
                    "I ,eye ",
                    ".,.  ",
                    "Ayuh,If you say so|false"
                };
                robot.LanguageModel.LoadSubstitutions(substitutions);

                _ai = robot;
            }
            catch
            {
                if (machine == null)
                {
                    throw new TeaArgumentNullException("machine");
                }
                if (vision == null)
                {
                    throw new TeaArgumentNullException("vision");
                }
                if (robot == null)
                {
                    throw new TeaArgumentNullException("robot");
                }
                if (newContextCache == null)
                {
                    throw new TeaArgumentNullException("newContextCache");
                }
                if (chatbots == null)
                {
                    throw new TeaArgumentNullException("chatbots");
                }
            }

            InitializeDatabase();
        }
Ejemplo n.º 3
0
        private void Initialize()
        {
            IRobot robot = null;

            // Initialize Foundation Components
            try
            {
                machine = new Machine();
                machine.Initialize(this);

                vision = new VisualProcessor(Properties.Settings.Default.ImagingSettings);
                vision.Initialize(this);

                _dataAccessManager.Initialize(this);
                _dataAccessManager.InitializeMemoryBank();

                newContextCache = new ContextCache();
                newContextCache.Initialize(this.ExecutiveFunctions);

                // Verify that ContextCache is instantiated
                System.Diagnostics.Debug.Assert(ExecutiveFunctions.ContextCache != null);
            }
            catch
            {
                machine.Dispose();
                vision.Dispose();
                throw;
            }

            // Become Self-Aware
            robot = SelfAwareness.BecomeSelfAware(this, Properties.Settings.Default.ChatbotName);

            // Initialize Language Module
            this.User = new Galatea.Runtime.Services.User(Properties.Settings.Default.DefaultUserName);
            IChatbotManager chatbots = Gala.Dolly.Chatbots.ChatbotManager.GetChatbots(this.User);

            robot.LanguageModel.LoadChatbots(chatbots);

            var substitutions = new []
            {
                "I ,eye ",
                ".,.  ",
                "Ayuh,If you say so|false"
            };

            robot.LanguageModel.LoadSubstitutions(substitutions);

            speech = new Galatea.Speech.SpeechModule();
            speech.Initialize(robot.LanguageModel);
            speech.StaySilent = Properties.Settings.Default.SpeechIsSilent;

            // Add Text to Speech (even if silent)
            Galatea.Speech.ITextToSpeech tts5 = new Galatea.Speech.TextToSpeech5(speech);
            speech.TextToSpeech = tts5;

            // ********** WIN 10 ZIRA ********** //
            //SpeechLib.SpVoice spV = tts5.GetSpeechObject() as SpeechLib.SpVoice;

            int defaultVoiceIndex = Properties.Settings.Default.TextToSpeechDefaultVoiceIndex;

            try
            {
                Galatea.Speech.IVoice voice = tts5.GetVoice(defaultVoiceIndex);
                tts5.CurrentVoice = voice;
            }
            catch (Galatea.Speech.TeaSpeechException ex)
            {
                string msg = "Error loading Text to Speech.  Silencing Speech Module.";
                Galatea.Speech.TeaSpeechException ex1 = new Galatea.Speech.TeaSpeechException(msg, ex);
                Debugger.HandleTeaException(ex1, speech);

                Program.Console.SendResponse(msg);
                speech.StaySilent = true;
            }

            // Add Memory
            robot.InitializeMemory(_dataAccessManager);
        }