Пример #1
0
 private void Mainform_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Disconnect from the function event
     ExpressionEvaluation.FunctionEval.AdditionalFunctionEvent -= FunctionEval_AdditionalFunctionEvent;
     // free memory
     _executor_0 = null; _executor_1 = null; _executor_2 = null; _executor_3 = null; _executor_4 = null;
 }
        public FormMain()
        {
            InitializeComponent();

            _executor            = new EZ_Builder.Scripting.Executor("Programming with Pictures");
            _executor.OnCmdExec += _executor_OnCmdExec;
            _executor.OnDone    += _executor_OnDone;
            _executor.OnStart   += _executor_OnStart;
        }
Пример #3
0
 private void Mainform_Load(object sender, EventArgs e)
 {
     /// Create EZ Executors for script execution
     _executor_0 = new EZ_Builder.Scripting.Executor();
     _executor_1 = new EZ_Builder.Scripting.Executor();
     _executor_2 = new EZ_Builder.Scripting.Executor();
     _executor_3 = new EZ_Builder.Scripting.Executor();
     _executor_4 = new EZ_Builder.Scripting.Executor();
     // Set Input Userid to default userid stored in configuration
     EZ_Builder.Invokers.SetText(textBoxUserid, _cf.STORAGE[ConfigurationDictionary._STORAGE_USER_ID].ToString());
     //Create and initialize EZ variables used for Commandcontrol to Synbot
     EZ_Builder.Scripting.VariableManager.SetVariable(variablebotstatus, false.ToString());
     EZ_Builder.Scripting.VariableManager.SetVariable(variablebotevent, string.Empty);
     EZ_Builder.Scripting.VariableManager.SetVariable(variablebotvartype, string.Empty);
     EZ_Builder.Scripting.VariableManager.SetVariable(variablebotvarname, string.Empty);
     EZ_Builder.Scripting.VariableManager.SetVariable(variablebotvarvalue, string.Empty);
     EZ_Builder.Scripting.VariableManager.SetVariable(variablebotusermessage, string.Empty);
     EZ_Builder.Scripting.VariableManager.SetVariable(variablebotuserid, string.Empty);
     // Intercept all unknown functions called from any ez-script globally.
     // If a function is called that doesn't exist in the ez-script library, this event will execute
     ExpressionEvaluation.FunctionEval.AdditionalFunctionEvent += FunctionEval_AdditionalFunctionEvent;
 }
Пример #4
0
        public Synbot(string userid, string botpath, string packagename, string botsavepath, string robottype
                      , EZ_Builder.Scripting.Executor executor, string defautbotname, string language)
        {
            string packageString = "";
            string pathbotpk     = botpath + packagename + ".simlpk";
            string pathbotsource = botpath;

            _executor_bot = executor;
            this.simlBot  = new SimlBot();
            simlBot.Adapters.Add(new EzvarAdapter());
            simlBot.Adapters.Add(new EzcmdAdapter());
            simlBot.Adapters.Add(new CompareAdapter());
            simlBot.Adapters.Add(new VaropAdapter());
            simlBot.Adapters.Add(new LearnAdapter());
            Simladaptators.Simladaptators.adaptators.Add(this.simlBot);
            UserSIMLadaptators.Simladaptators.adaptators.Add(this.simlBot);
            this.botUser = simlBot.MainUser;
            //this.botUser = simlBot.CreateUser(userid);
            // Recreate package

            var elementList = new System.Collections.Generic.List <XDocument>();

            foreach (var simlFile in Directory.GetFiles(pathbotsource, "*.siml"))
            {
                var simlElement = XDocument.Load(simlFile);
                elementList.Add(simlElement);
            }
            string pathsettings = pathbotsource + @"\" + "Settings" + @"\";

            if (Directory.Exists(pathsettings))
            {
                foreach (var simlFile in Directory.GetFiles(pathsettings))
                {
                    var simlElement = XDocument.Load(simlFile);
                    elementList.Add(simlElement);
                }
            }
            var packageref = simlBot.PackageManager.ConvertToPackage(elementList);

            File.WriteAllText(pathbotpk, packageref);

            /// Load SIML Package file
            var t = Task.Run(() => packageString = File.ReadAllText(pathbotpk));

            t.Wait();
            this.simlBot.PackageManager.LoadFromString(packageString);
            this.nomsave     = userid + "-Settings.siml";
            this.useridbot   = userid;
            this.botsavepath = botsavepath;
            refbot           = this;
            path_bot         = botpath;
            // attach event handler for the learning event of the bot
            this.simlBot.Learning += SimlBot_Learning;
            // attach event handler for the memorizing event of the bot
            this.simlBot.Memorizing += simlBot_Memorizing;
            Bot_Load(this.botsavepath);
            /// Extract Bot Name and User Name in settings
            bot_name  = simlBot.Settings["Name"].Value;
            user_name = botUser.Settings["Name"].Value;
            /// Set Bot settings for robot type parameter
            botUser.Settings[botrobottype_variable].Value = robottype;
            /// Set Bot settings for language parameter
            botUser.Settings[botlanguage_variable].Value = language.Substring(0, 2);
            if (user_name == null)
            {
                user_name = string.Empty;
                botUser.Settings["Name"].Value = user_name;
            }
            /// If Name is not initialized in  bot settings intialize it to detaut robot name
            if (bot_name == null || bot_name == string.Empty)
            {
                simlBot.Settings["Name"].Value = defautbotname;
                bot_name = defautbotname;
            }
            //Events to detect change in Bot Name and User Name
            //
            simlBot.Settings["Name"].Changed += (sender, args) =>
            {
                Synbot.bot_name = simlBot.Settings["Name"].Value;
            };
            botUser.Settings["Name"].Changed += (sender, args) =>
            {
                Synbot.user_name = botUser.Settings["Name"].Value;
            };
        }