protected override void ProvideSkillToExecute(ref ExecutableSkill skillWithNoMethod) { //You can throw an exception is something is weird in the provided Skill => your SEE will go in error state //Note that skillWithNoMethod is tested before (in mother class), so it will NOT be null, // and skillWithNoMethod.AmlSkillDescription.Execution.Type is also NOT NULL if (skillWithNoMethod == null) { throw new Exception("The given skill with no method is null"); } //Here, do a big switch case on the Execution's type of the skill. //In our case, all the skills will be the "ProcessWindow" (popup) switch (skillWithNoMethod.AmlSkillDescription.Execution.Type) { case "Type1": //In our case, all the skills will be the "ProcessWindow" (popup) skillWithNoMethod.SkillToExecute = new Skill(ProcessWindow, CloseWindow); //The Skill is the execution of ProcessWindow, followed by CloseWindow break; default: //In our case, all the skills will be the "ProcessWindow" (popup) skillWithNoMethod.SkillToExecute = new Skill(ProcessWindow, CloseWindow); //The Skill is the execution of ProcessWindow, followed by CloseWindow break; } }
protected override void GetOutputsOfExecutedSkill(ExecutableSkill SkillExecuted, OutputParams OutputOfExecution) { //Here you will receive the outputs of the executed skills (in our case, the outputs of "ProcessWindow" or "CloseWindow") //So here you will do everything required specifically to your SEE //like updating a database, displaying something on a human/machine interface, logging, beeping... //but you can also do nothing, if you don't care about the outputs, or maybe you did everyhting in the Skill methods allready //So here is a common way of processing your outputs //Check that your outputs are OK if (SkillExecuted == null) { System.Windows.MessageBox.Show("SkillExecuted is null"); return; } if (SkillExecuted.AmlSkillDescription.Name == null) { System.Windows.MessageBox.Show("Name of SkillExecuted is null"); return; } if (OutputOfExecution == null) { System.Windows.MessageBox.Show("Outputs of skill " + SkillExecuted.AmlSkillDescription.Name + " are null"); return; } //Display the return code of the Skill. System.Windows.MessageBox.Show("Skill " + SkillExecuted.AmlSkillDescription.Name + " returned code " + OutputOfExecution.ReturnCode.ToString()); return; }
protected override void ProvideSkillToExecute(ref ExecutableSkill skillWithNoMethod) { switch (skillWithNoMethod.AmlSkillDescription.Execution.Type) { default: //In our case, whatever the skill type, we will execute the same method skillWithNoMethod.SkillToExecute = new Skill(MethodHelloWorldAndQuestions, MethodStop); break; } }
protected override int ProvideInputDataForSkillExecution(ExecutableSkill SkillToExecute, out InputParams ParametersForTheSkill) { //You can throw an exception, or return an error code is something is weird in the provided Skill => your SEE will go in error state //Note that SkillToExecute is tested before (in mother class), so it will NOT be null, // and SkillToExecute.AmlSkillDescription.Execution.Type is also NOT NULL if (SkillToExecute == null) { ParametersForTheSkill = null; return(-1); } if (string.IsNullOrEmpty(SkillToExecute.AmlSkillDescription.Name)) { //I need the name of the SKill, because I will display it on the Popup Window. //So if the name is not available, I can return a interger!=0 //or I can fire an exception (this way, I can also add a meaningfull error message) ParametersForTheSkill = null; throw new SkillProException("Required SkillToExecute.AmlSkillDescription.Name was NULL or empty"); } //Here, do a big switch case on the Execution's type of the skill. //In our case, since we allways execute the "ProcessWindow" skill (popup), we always have the same input int RandomNumber = _rand.Next(MS_MIN_RANDOM, MS_MAX_RANDOM); InputsForFakeWindow In = new InputsForFakeWindow() { NameOfSkill = SkillToExecute.AmlSkillDescription.Name, ExecutionTimeMs = RandomNumber, RemainingTimeMs = RandomNumber, AlternativePostConditionAvailable = SkillToExecute.AmlSkillDescription.AltPostCondition != null }; switch (SkillToExecute.AmlSkillDescription.Execution.Type) { case "Type1": //In our case, we always have the same input params (because one skill) ParametersForTheSkill = new InputParams(0, (object)In); break; default: //In our case, all the skills will be the "ProcessWindow" (popup) ParametersForTheSkill = new InputParams(0, (object)In); break; } //Return 0 if everything is allright return(0); }
protected override void GetOutputsOfExecutedSkill(ExecutableSkill SkillExecuted, OutputParams OutputOfExecution) { switch (SkillExecuted.AmlSkillDescription.Execution.Type) { default: //In our case, whatever the skill type, we will execute the same method Console.WriteLine("=========================================================================================================="); Console.WriteLine("Returned code of skill " + SkillExecuted.AmlSkillDescription.ID + " is " + OutputOfExecution.ReturnCode); Console.WriteLine("=========================================================================================================="); break; } }
protected override int ProvideInputDataForSkillExecution(ExecutableSkill SkillToExecute, out InputParams ParametersForTheSkill) { switch (SkillToExecute.AmlSkillDescription.Execution.Type) { default: DateTime Now = DateTime.Now; ValuesForSee v = new ValuesForSee() { MessageToDisplay = "Hello world ! Executing Skill " + SkillToExecute.AmlSkillDescription.ID + ". Time is " + Now.ToString("yyyy_MM_dd_hh_mm_ss_") + Now.Millisecond.ToString(), AlternativePostConditionAvailable = SkillToExecute.AmlSkillDescription.AltPostCondition != null }; ParametersForTheSkill = new InputParams(0, (object)v); break; } return(0); }
protected override void ProvideSkillToExecute(ref ExecutableSkill skillWithNoMethod) { //Note that skillWithNoMethod is tested before (in mother class), so it will NOT be null, // and skillWithNoMethod.AmlSkillDescription.Execution.Type is also NOT NULL //Here, do a big switch case on the Execution's type of the skill. //In our case, all the skills will be the "MethodHelloWorld" (console write) switch (skillWithNoMethod.AmlSkillDescription.Execution.Type) { default: //In our case, whatever the skill type, we will execute the same method skillWithNoMethod.SkillToExecute = new Skill(MethodHelloWorld, MethodStop); break; } //You can throw an exeception if something does not suits you => the SEE will NOT execute //the skill and will go in error state }
protected override int ProvideInputDataForSkillExecution(ExecutableSkill SkillToExecute, out InputParams ParametersForTheSkill) { //Note that SkillToExecute is tested before (in mother class), so it will NOT be null, // and SkillToExecute.AmlSkillDescription.Execution.Type is also NOT NULL //Here, do a big switch case on the Execution's type of the skill. //In our case, since we allways execute the "MethodHelloWorld" skill (console write), we always have the same input switch (SkillToExecute.AmlSkillDescription.Execution.Type) { default: //In our case, whatever the skill type, we will execute the same method DateTime Now = DateTime.Now; string message = "Hello world ! Executing Skill " + SkillToExecute.AmlSkillDescription.ID + ". Time is " + Now.ToString("yyyy_MM_dd_hh_mm_ss_") + Now.Millisecond.ToString(); ParametersForTheSkill = new InputParams(0, (object)message); break; } //You can throw an exeception or return !=0 if something does not suits you => the SEE will NOT execute //the skill and will go in error state return(0); }
protected override void GetOutputsOfExecutedSkill(ExecutableSkill SkillExecuted, OutputParams OutputOfExecution) { //Here you will receive the outputs of the executed skills (in our case, the outputs of "MethodHelloWorld" or "MethodStop" //So here you will do everything required specifically to your SEE //like updating a database, displaying something on a human/machine interface, logging, beeping... //but you can also do nothing, if you don't care about the outputs, or maybe you did everyhting in the Skill methods allready //Here, do a big switch case on the Execution's type of the skill. //In our case, just print the returned code of skill switch (SkillExecuted.AmlSkillDescription.Execution.Type) { default: //In our case, whatever the skill type, we will execute the same method Console.WriteLine("=========================================================================================================="); Console.WriteLine("Returned code of skill " + SkillExecuted.AmlSkillDescription.ID + " is " + OutputOfExecution.ReturnCode); Console.WriteLine("=========================================================================================================="); break; } //You can throw an exeception if something does not suits you => the SEE will go in error state }