Example #1
0
        private ArrayList _history; // store the previous agenda items

        public PlanGraph(SQLiteKBase kbase, Executor exec)
        {
            this._kbase = kbase;
            this._exec = exec;
            this._root = null;
            this._currDlgAct = null;
            this._agenda = new ArrayList();
            this._history = new ArrayList();
            this._respList = new ArrayList();
        }
Example #2
0
 public void Close()
 {
     this._exec = null;
     this._kbase.Close();
     this._root = null;
     this._currDlgAct = null;
     this._agenda.Clear();
     this._history.Clear();
     this._respList.Clear();
 }
Example #3
0
 private bool _explainAffOrNeg(PlanNode planNode, DialogueAct dlgAct, string indent)
 {
     Console.WriteLine(indent + "Dialogue.PlanGraph  _explainAffOrNeg  " + planNode.Name);
     if (planNode is ActionNode)
     {
         ActionNode actNode = (ActionNode)planNode;
         if (actNode.ActType == "ID" && actNode.ActState == ActionState.Executing)
         {
             if (actNode.Parent != null && actNode.Parent is ParamNode)
             {
                 ParamNode paramNode = actNode.Parent as ParamNode;
                 if (paramNode.ParamType == "boolean")
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Example #4
0
 private ActionNode _explainAction(Hashtable tempAct, DialogueAct dlgAct, string indent)
 {
     Console.WriteLine(indent + "Dialogue.PlanGraph  _explainAction  ");
     if (this._root == null)
     {
         // todo: check the top actions before assign it to the root node
         this._root = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], null);
         ((ActionNode)this._root).Agents.Add(dlgAct.Agent);
         ((ActionNode)this._root).ActState = ActionState.Initiated;
         return(this._root);
     }
     else if (this._agenda.Count > 0)
     {
         foreach (PlanNode planNode in this._agenda.ToArray())
         {
             ActionNode actNode = this._explainActionFromNode(planNode, tempAct, dlgAct, indent + "  ");
             if (actNode != null)
             {
                 return(actNode);
             }
         }
     }
     return(this._explainActionFromNode(this._root, tempAct, dlgAct, indent + "  "));
 }
Example #5
0
 private ActionNode _explainAction(Hashtable tempAct, DialogueAct dlgAct)
 {
     if (this._root == null)
     {
         // todo: check the top actions before assign it to the root node
         this._root = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], null);
         ((ActionNode)this._root).Agents.Add(dlgAct.Agent);
         ((ActionNode)this._root).ActState = ActionState.Initiated;
         return this._root;
     }
     else if (this._agenda.Count > 0)
     {
         foreach (PlanNode planNode in this._agenda.ToArray())
         {
             ActionNode actNode = this._explainActionFromNode(planNode, tempAct, dlgAct);
             if (actNode != null)
             {
                 return actNode;
             }
         }
     }
     return this._explainActionFromNode(this._root, tempAct, dlgAct);
 }
Example #6
0
        private ArrayList ChooseAnalyticFunctions(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: ChooseAnalyticFunctions"));
            ActionNode parentNode = ((ActionNode)(actionNode.Parent));
            bool multiple = false;
            bool need_summary = false;
            bool partiality = false;
            foreach (ParamNode param in parentNode.Params)
            {
                if (param.Name == "region.multiple")
                {
                    if (param.Values.Count > 0)
                    {
                        multiple = ((bool)param.Values[0]);
                    }
                }
                else if (param.Name == "need_summary")
                {
                    if (param.Values.Count > 0)
                    {
                        need_summary = ((bool)param.Values[0]);
                    }
                }
                else if (param.Name == "partiality")
                {
                    if (param.Values.Count > 0)
                    {
                        partiality = ((bool)param.Values[0]);
                    }
                }

            }
            string chosenActionName = ""; 
            if (need_summary == true)
            {
                if (partiality == false)
                {
                    // select features in the region
                    chosenActionName = "Select Features Inside Region";
                }
                else
                {
                    // overlay features with the region
                    chosenActionName = "Overlay Features and Region";
                }
            }
            respList.Add(new DialogueResponse(DialogueResponseType.newAgendaItem, chosenActionName));
            
            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #7
0
        private ArrayList DrawRegion(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: generate the candiate list           
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: DrawRegion"));
                respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "Please adjust the map so that you can see the whole region of your interest."));
                respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "Ask me for a drawing tool when you are ready."));
                return respList;
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                if (currDlgAct.DlgActType == DialogueActType.Intend)
                {
                    respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Start drawing the region"));
                    respList.Add(new DialogueResponse(DialogueResponseType.drawPolygonStarted, "Region 1"));
                    respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "Use the mouse to draw the region, double click when you want to finish drawing."));
                    
                    return respList;
                }
                else if (currDlgAct.DlgActType == DialogueActType.Feedback)
                {
                    // find the parameter node from the ancestor
                    PlanNode parent = actionNode.Parent;
                    ParamNode paramNode = null;
                    while (parent != null)
                    {
                        if (parent.Parent is ParamNode)
                        {
                            paramNode = parent.Parent as ParamNode;
                            break;
                        }
                        else if (parent.Parent is ActionNode)
                        {
                            parent = parent.Parent;
                        }
                    }

                    if (paramNode != null)
                    {
                        foreach (string phrase in currDlgAct.SpeechContext.Keys)
                        {
                            if (phrase.ToLower() == actionNode.Name.ToLower())
                            {
                                object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                                if (newValue != null)
                                {
                                    this._addValueToParam(paramNode, newValue);

                                    // change its own state
                                    actionNode.ActState = ActionState.Complete;

                                    // generate response 
                                    if (paramNode.ParamType == "geometry_polygon")
                                    {
                                        // fixed at the moment
                                        respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "Thanks, you may refer to this region as " + newValue.ToString()));
                                        return respList;
                                    }
                                }
                            }
                        }
                    }
                    
                }
            }
            
            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #8
0
        private ArrayList AskForPartiality(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: generate the candiate list           
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: AskForPartiality"));

                ParamNode paramNode = (ParamNode)actionNode.Parent;

                if (paramNode.Name == "partiality")
                {
                    // only respond if the need_summary is true
                    ActionNode parentNode = ((ActionNode)(paramNode.Parent));
                    bool need_summary = false;
                    foreach (ParamNode param in parentNode.Params)
                    {
                        if (param.Name == "need_summary")
                        {
                            if (param.Values.Count > 0)
                            {
                                need_summary = ((bool)param.Values[0]);
                            }
                        }
                    }
                    if (need_summary == true)
                    {
                        // fixed at the moment
                        OptionWithExampleListData respContent = new OptionWithExampleListData();
                        respContent.Opening = this._generateQuestionString(paramNode);
                        respContent.Opening = "Do you want to map them partially or fully inside? The comparison of difference between partially and fully inside are shown in the popup window.";
                        respContent.AddOption(new OptionWithExampleItemData("the parts inside", "Only the parts of features inside the region should be taken into account", "/CAGA;component/Images/partial2.png"));
                        respContent.AddOption(new OptionWithExampleItemData("the features as a whole", "The inside features as a whole should be taken into account", "/CAGA;component/Images/full2.png"));
                        respList.Add(new DialogueResponse(DialogueResponseType.listOptionsWithExamples, respContent));
                        return respList;
                    }                    
                }
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                ParamNode paramNode = (ParamNode)actionNode.Parent;
                foreach (string phrase in currDlgAct.SpeechContext.Keys)
                {
                    if (phrase.ToLower() == paramNode.Name.ToLower())
                    {
                        object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                        if (newValue != null)
                        {
                            this._addValueToParam(paramNode, newValue);

                            // change its own state
                            actionNode.ActState = ActionState.Complete;
                            return respList;
                        }
                    }
                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #9
0
        private ArrayList SpecifyRegionByAttributes(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: generate the candiate list           
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: SpecifyRegionByAttributes"));
                respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "Please specify the region by filtering out the attributes."));
                respList.Add(new DialogueResponse(DialogueResponseType.selectByAttributes, null));
                return respList;
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                if (currDlgAct.DlgActType == DialogueActType.Feedback)
                {
                    // find the parameter node from the ancestor
                    PlanNode parent = actionNode.Parent;
                    ParamNode paramNode = null;
                    while (parent != null)
                    {
                        if (parent.Parent is ParamNode)
                        {
                            paramNode = parent.Parent as ParamNode;
                            break;
                        }
                        else if (parent.Parent is ActionNode)
                        {
                            parent = parent.Parent;
                        }
                    }

                    if (paramNode != null)
                    {
                        foreach (string phrase in currDlgAct.SpeechContext.Keys)
                        {
                            if (phrase.ToLower() == actionNode.Name.ToLower())
                            {
                                object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                                if (newValue != null)
                                {
                                    Hashtable v = new Hashtable();
                                    v.Add("type", "features");
                                    v.Add("value", newValue);
                                    this._addValueToParam(paramNode, v);

                                    // change its own state
                                    actionNode.ActState = ActionState.Complete;

                                    // generate response 
                                    if (paramNode.ParamType == "geometry_polygon")
                                    {
                                        // fixed at the moment
                                        respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The region is identified as a set of features in the layer " + newValue.ToString()));
                                        return respList;
                                    }
                                }
                            }
                        }
                    }

                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #10
0
        private ArrayList PerformOverlay(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: PerformOverlay"));

            ParamNode paramNode = (ParamNode)actionNode.Parent;
            ActionNode parentNode = ((ActionNode)(actionNode.Parent.Parent));
            string featureClass = "";
            Hashtable region = null;

            foreach (ParamNode param in parentNode.Params)
            {
                if (param.ParamState == ParamState.Ready && param.Name == "region")
                {
                    region = param.Values[0] as Hashtable;
                }
                else if (param.ParamState == ParamState.Ready && param.Name == "feature_class")
                {
                    featureClass = param.Values[0].ToString();
                }
            }

            
            if (region != null && featureClass != "")
            {
                if (region["type"].ToString() == "drawing")
                {
                    string graphicsName = region["value"].ToString();
                    //this._mapMgr.SelectFeaturesByGraphics(graphicsName);
                    //respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The " + featureClass + " within " + graphicsName + "are highlighted in the map!"));
                    //int count = this._mapMgr.GetTotalSelectedFeaturesInLayer(featureClass);
                    //respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "There are total of " + count + " " + featureClass + " selected."));
                    respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "overlay " + featureClass + " and " + graphicsName));
                }
                else if (region["type"].ToString() == "features")
                {
                    string in_layer = featureClass;
                    string select_features = region["value"].ToString();

                    ArrayList inputLayers = new ArrayList();
                    inputLayers.Add(in_layer);
                    inputLayers.Add(select_features);

                    // use cached output file for demo purpose, reduce the time to calculate the overlay
                    string cachedOutputFile = in_layer + "_" + select_features + "_overlay";
                    string outputFile = this._mapMgr.Overlay(inputLayers, cachedOutputFile);
                    if (outputFile.Length > 0)
                    {
                        this._addValueToParam(paramNode, cachedOutputFile);
                        respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The overlay of " + featureClass + " and " + select_features + "is added in the map!"));
                        respList.Add(new DialogueResponse(DialogueResponseType.mapLayerAdded, outputFile));
                        respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "overlay " + featureClass + " and " + select_features));
                        // change its own state
                        actionNode.ActState = ActionState.Complete;
                        return respList;
                    }

                    //this._mapMgr.SelectFeaturesByLocation(in_layer, select_features);
                    //respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The " + featureClass + " within " + select_features + "are highlighted in the map!"));
                    //int count = this._mapMgr.GetTotalSelectedFeaturesInLayer(featureClass);
                    //respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "There are total of " + count + " " + featureClass + " selected."));
                    
                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #11
0
        private ArrayList PerformSelection(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: PerformSelection"));

            ActionNode parentNode = ((ActionNode)(actionNode.Parent));
            string featureClass = "";
            Hashtable region = null;

            foreach (ParamNode param in parentNode.Params)
            {
                if (param.ParamState == ParamState.Ready && param.ParamType == "geometry_polygon")
                {
                    region = param.Values[0] as Hashtable;
                }
                else if (param.ParamState == ParamState.Ready && param.ParamType == "feature_class")
                {
                    featureClass = param.Values[0].ToString();
                }
            }

            
            if (region != null && featureClass != "")
            {
                if (region["type"].ToString() == "drawing")
                {
                    string graphicsName = region["value"].ToString();
                    this._mapMgr.SelectFeaturesByGraphics(graphicsName);
                    respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The " + featureClass + " within " + graphicsName + "are highlighted in the map!"));
                    int count = this._mapMgr.GetTotalSelectedFeaturesInLayer(featureClass);
                    respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "There are total of " + count + " " + featureClass + " selected."));
                    respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "selecting by drawing"));
                }
                else if (region["type"].ToString() == "features")
                {
                    string in_layer = featureClass;
                    string select_features = region["value"].ToString();
                    this._mapMgr.SelectFeaturesByLocation(in_layer, select_features);
                    respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The " + featureClass + " within " + select_features + "are highlighted in the map!"));
                    int count = this._mapMgr.GetTotalSelectedFeaturesInLayer(featureClass);
                    respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "There are total of " + count + " " + featureClass + " selected."));
                    respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "selecting by attributes"));
                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #12
0
        /// <summary>
        /// When Completed, Update Parent recursively
        /// </summary>
        /// <param name="planNode"></param>
        /// <param name="indent"></param>
        private void _updateParentState(PlanNode planNode, string indent)
        {
            Console.WriteLine(indent + "Dialogue.PlanGraph _updateParentState " + planNode.Name);
            if (planNode.Parent != null)
            {
                Console.WriteLine(indent + "Parent: " + planNode.Parent.Name);
                if (planNode.Parent is ActionNode)
                {
                    ActionNode parent = (ActionNode)planNode.Parent;
                    foreach (ParamNode param in parent.Params)
                    {
                        if (param.ParamState != ParamState.Ready)
                        {
                            Console.WriteLine(indent + "ActionNode Parent not Completed becasue of param " + param.Name + " " + param.ParamState.ToString());
                            return;
                        }
                    }
                    foreach (ActionNode subAct in parent.SubActions)
                    {
                        if (subAct.Optional == false && subAct.ActState != ActionState.Complete)
                        {
                            Console.WriteLine(indent + "ActionNode Parent not Completed becasue of subAct " + subAct.Name + " " + subAct.ActState.ToString() + " Optional=false");
                            return;
                        }
                        if (subAct.Optional == true && subAct.ActState != ActionState.Complete && subAct.ActState != ActionState.Unknown)
                        {
                            Console.WriteLine(indent + "ActionNode Parent not Completed becasue of subAct " + subAct.Name + " " + subAct.ActState.ToString() + " Optional=ture");
                            return;
                        }
                    }
                    parent.ActState = ActionState.Complete;
                    Console.WriteLine(indent + "ActionNode Parent Completed");
                    this._updateParentState(parent, indent + "  ");
                }
                else if (planNode.Parent is ParamNode)
                {
                    ParamNode parent = (ParamNode)planNode.Parent;
                    if (parent.Values.Count == 0)
                    {
                        Console.WriteLine(indent + "ParamNode Parent notReady becasue of 0 value");
                        return;
                    }
                    else
                    {
                        foreach (object obj in parent.Values)
                        {
                            if (obj is string)
                            {
                                Console.WriteLine(indent + "******string******");
                                Console.WriteLine(indent + "obj=" + obj);
                            }
                            else if (obj is Hashtable)
                            {
                                Console.WriteLine(indent + "******hashtable******");
                                foreach (DictionaryEntry item in (Hashtable)obj)
                                {
                                    Console.WriteLine(indent + "key=" + item.Key + ",value=" + item.Value);
                                }
                            }
                        }
                    }

                    // assume the parameter is ready as long as it has values
                    // it might be extended to consider the conditions on the parameter
                    parent.ParamState = ParamState.Ready;
                    this._updateParentState(parent, indent + "  ");
                }
            }
        }
Example #13
0
        private bool _parseRecipeXML(string recipeXML, ActionNode actionNode, string indent)
        {
            Console.WriteLine(indent + "Dialogue/PlanGraph _parseRecipeXML " + actionNode.Name);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(recipeXML);
            XmlNodeList paramList = doc.GetElementsByTagName("PARA");

            foreach (XmlNode param in paramList)
            {
                string name      = param.Attributes["Name"].Value;
                string paramType = param.Attributes["Type"].Value;
                bool   multiple  = true;
                if (param.Attributes["Multiple"] != null && param.Attributes["Multiple"].Value.ToLower() == "false")
                {
                    multiple = false;
                }
                string description = "";
                if (param.Attributes["Description"] != null)
                {
                    description = param.Attributes["Description"].Value;
                }
                ParamNode paramNode = new ParamNode(name, paramType, multiple, description, actionNode);

                bool hasParam = false;
                foreach (ParamNode tmpParam in actionNode.Params)
                {
                    //Console.WriteLine(indent + "tmpParam= " + tmpParam.Name + ",paramNode=" + paramNode.Name);
                    if (paramNode.Name == tmpParam.Name)
                    {
                        hasParam       = true;
                        paramNode.Flag = true;
                    }
                }
                if (!hasParam)
                {
                    foreach (XmlNode node in param.ChildNodes)
                    {
                        if (node.Name == "ID_PARAS")
                        {
                            foreach (XmlNode subAct in node.ChildNodes)
                            {
                                if (subAct.Name == "ID_PARA")
                                {
                                    Hashtable tempAct = this._kbase.SearchAction(subAct.Attributes["Name"].Value);
                                    Console.WriteLine("name=" + (string)tempAct["name"]);
                                    //Console.WriteLine("act_type=" + (string)tempAct["act_type"]);
                                    //Console.WriteLine("complexity=" + (string)tempAct["complexity"]);
                                    //Console.WriteLine("description=" + (string)tempAct["description"]);
                                    ActionNode subActNode = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], paramNode);
                                    if (subAct.Attributes["Optional"] != null && subAct.Attributes["Optional"].Value.ToString().ToLower() == "true")
                                    {
                                        subActNode.Optional = true;
                                    }
                                    paramNode.Flag = true;
                                    paramNode.SubActions.Add(subActNode);
                                }
                            }
                        }
                    }
                    actionNode.Params.Add(paramNode);
                }
            }

            for (int index = actionNode.Params.Count - 1; index >= 0; index--)
            {
                // Get the item.
                ParamNode tmpParam = (ParamNode)actionNode.Params[index];

                // Check to remove.
                if (tmpParam.Flag == false)
                {
                    Console.WriteLine("what deleted is " + tmpParam.Name);
                    // Remove.
                    actionNode.Params.RemoveAt(index);
                }
            }

            XmlNodeList actionList = doc.GetElementsByTagName("SUBACT");

            foreach (XmlNode action in actionList)
            {
                Hashtable  tempAct    = this._kbase.SearchAction(action.Attributes["Name"].Value);
                ActionNode subActNode = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], actionNode);
                if (action.Attributes["Optional"] != null && action.Attributes["Optional"].Value.ToString().ToLower() == "true")
                {
                    subActNode.Optional = true;
                }

                bool hasAction = false;
                foreach (ActionNode tmpActNode in actionNode.SubActions)
                {
                    Console.WriteLine("tmpActNode.Name=" + tmpActNode.Name + ",subActNode.Name" + subActNode.Name);
                    if (tmpActNode.Name == subActNode.Name)
                    {
                        hasAction = true;
                    }
                }
                if (!hasAction)
                {
                    actionNode.SubActions.Add(subActNode);
                }
            }
            return(true);
        }
Example #14
0
        private void _elaborateFromActionNode(ActionNode actionNode, string indent)
        {
            Console.WriteLine(indent + "Dialogue/PlanGraph _elaborateFromActionNode " + actionNode.Name);
            // check the parameters and constraints
            bool paramsRdy = this._parentParamsRdy(actionNode, indent + "  "); // check whether the params are ready

            Console.WriteLine(indent + "paramsRdy = " + paramsRdy);
            if (paramsRdy == false)
            {
                return;
            }

            // If the action is a basic one and can be executed, then execute it
            if (actionNode.Complexity == "basic")
            {
                Console.WriteLine(indent + actionNode.Name + " is Basic");
                // check the state of the action
                if (actionNode.ActState == ActionState.Initiated || actionNode.ActState == ActionState.Executing)
                {
                    Console.WriteLine(indent + "actionNode.ActState before: " + actionNode.ActState);

                    //// perform the task
                    ArrayList execResp = this._exec.Execute(actionNode, this._currDlgAct, indent + "  ");
                    Console.WriteLine(indent + "");
                    if ((actionNode.Parent != null) && (actionNode.Parent is ActionNode))
                    {
                        _actionNodeStack.Push((ActionNode)actionNode.Parent);
                    }

                    // add the execution response to the response list
                    ArrayList newAgendaItems = new ArrayList();
                    foreach (DialogueResponse resp in execResp)
                    {
                        if (resp.DlgRespType == DialogueResponseType.newAgendaItem)
                        {
                            newAgendaItems.Add(resp.RespContent);
                        }
                        else
                        {
                            this._respList.Add(resp);
                        }
                    }
                    Console.WriteLine(indent + "actionNode.ActState after: " + actionNode.ActState);
                    // remove the running/complete action from the agenda;
                    if (actionNode.ActState == ActionState.Complete)
                    {
                        this.RemoveFromAgenda(actionNode, indent + "  ");
                    }
                    // check whether the parent's state is also complete if the action is complete
                    if (actionNode.ActState == ActionState.Complete)
                    {
                        this._updateParentState(actionNode, indent + "  ");
                    }

                    // perform the new agenda item
                    foreach (string actionName in newAgendaItems)
                    {
                        if (actionName != "")
                        {
                            // only search parent level at the moment
                            ActionNode parentNode = (ActionNode)actionNode.Parent;
                            foreach (ActionNode subAct in parentNode.SubActions)
                            {
                                if (subAct.Name.ToLower() == actionName.ToLower())
                                {
                                    if (subAct.ActState == ActionState.Unknown)
                                    {
                                        subAct.ActState = ActionState.Initiated;
                                        int idx = this.GetIndexInAgenda(actionNode);
                                        this.AddToAgenda(subAct, idx + 1, indent + "  ");
                                        this.ElaborateFromNode(subAct, indent + "  ");
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                Console.WriteLine(indent + "Agenda:");
                foreach (PlanNode planNode in this._agenda.ToArray())
                {
                    Console.WriteLine(indent + "-" + planNode.Name);
                }
                return;
            }

            if (actionNode.Complexity == "complex")
            {
                if (_actionNodeStack.Count != 0)
                {
                    Console.WriteLine(indent + "!!!!!!!!!!!!_prevActionNode is " + _actionNodeStack.Peek().Name);
                    ActionNode tmpAction = _actionNodeStack.Peek();
                    foreach (ParamNode param in tmpAction.Params)
                    {
                        if (param.ParamState == ParamState.Ready)
                        {
                            Console.WriteLine(indent + "param " + param.Name + " is " + param.Values[0].ToString());
                        }
                    }
                }
                Console.WriteLine(indent + actionNode.Name + " is Complex");


                // check the state of the action
                if (actionNode.ActState == ActionState.Initiated)
                {
                    // find and load the recipe
                    this._loadRecipe(actionNode, indent + "  ");
                }
                if (actionNode.ActState == ActionState.Planned)
                {
                    int idx = this.RemoveFromAgenda(actionNode, indent + "  ");
                    foreach (ParamNode param in actionNode.Params)
                    {
                        idx = this.AddToAgenda(param, idx, indent + "  ");
                        idx++;
                    }
                    foreach (ActionNode subAct in actionNode.SubActions)
                    {
                        idx = this.AddToAgenda(subAct, idx, indent + "  ");
                        idx++;
                    }
                    Console.WriteLine(indent + "Agenda:");
                    foreach (PlanNode planNode in this._agenda.ToArray())
                    {
                        Console.WriteLine(indent + "-" + planNode.Name);
                    }

                    // elaborate on the params
                    foreach (ParamNode param in actionNode.Params)
                    {
                        param.ParamState = ParamState.InPreparation;
                        this._elaborateFromParamNode(param, indent + "  ");
                    }

                    foreach (ActionNode subAct in actionNode.SubActions)
                    {
                        if (subAct.Optional == false)
                        {
                            subAct.ActState = ActionState.Initiated;
                            this._elaborateFromActionNode(subAct, indent + "  ");
                        }
                        else
                        {
                            this.RemoveFromAgenda(subAct, indent + "  ");
                        }
                    }
                }
            }
        }
Example #15
0
        private ActionNode _explainActionFromNode(PlanNode planNode, Hashtable tempAct, DialogueAct dlgAct, string indent)
        {
            Console.WriteLine(indent + "Dialogue.PlanGraph  _explainActionFromNode  " + planNode.Name);
            ActionNode pNode     = (ActionNode)planNode;
            ActionNode newAction = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"]);

            if (planNode is ActionNode)
            {
                Console.WriteLine(indent + "IsActionNode  actionNode:" + planNode.Name.ToLower() + "  tempAct" + tempAct["name"].ToString());
                //               ActionNode actionNode = (ActionNode)planNode;
                switch (newAction.ActType)
                {
                case "ACT":
                {
                    if (pNode.Name.ToLower() == tempAct["name"].ToString().ToLower())
                    {
                        // If the action has not been initiated, initiate it and add the agent
                        if (pNode.ActState == ActionState.Unknown)
                        {
                            pNode.ActState = ActionState.Initiated;
                        }
                        if (pNode.SearchAgent(dlgAct.Agent) == null)
                        {
                            pNode.Agents.Add(dlgAct.Agent);
                        }
                        // If the action has been completed, or failed, start a new one, attached it to the same parent
                        if (pNode.ActState == ActionState.Complete || pNode.ActState == ActionState.Failed)
                        {
                            //                       ActionNode newAction = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], actionNode.Parent);
                            newAction.Parent = pNode.Parent;
                            newAction.Agents.Add(dlgAct.Agent);
                            newAction.ActState = ActionState.Initiated;
                            if (pNode.Parent != null)
                            {
                                if (pNode.Parent is ActionNode)
                                {
                                    //There seems to be a logical error, because the newAction is now added as a subaction of pNode.Parent.  This is equivalent to modifying the recipe for pNode.Parent action.  The correct way to handle this should be:
                                    // if the tempAct matches with one of the subactions that has not been initiated (potential intention), then replace that subact with newAction
                                    ActionNode pParent = (ActionNode)(pNode.Parent);
                                    foreach (ActionNode subact in pParent.SubActions)
                                    {
                                        if ((subact.Name == newAction.Name) & (subact.ActState == CAGA.Dialogue.ActionState.Unknown))
                                        {
                                            ((ActionNode)(pNode.Parent)).SubActions.Add(newAction);
                                            newAction.Parent = pParent;
                                            ((ActionNode)(pNode.Parent)).SubActions.Remove(subact);
                                        }
                                    }
                                }
                                else if (pNode.Parent is ParamNode)
                                {
                                    ((ParamNode)(pNode.Parent)).SubActions.Add(newAction);
                                }
                            }
                            return(newAction);
                        }
                        return(pNode);
                    }

                    // search the params and subactions
                    foreach (ParamNode paramNode in pNode.Params)
                    {
                        ActionNode actNode = this._explainActionFromNode(paramNode, tempAct, dlgAct, indent + "  ");
                        if (actNode != null)
                        {
                            return(actNode);
                        }
                    }
                    foreach (ActionNode subActNode in pNode.SubActions)
                    {
                        ActionNode actNode = this._explainActionFromNode(subActNode, tempAct, dlgAct, indent + "  ");
                        if (actNode != null)
                        {
                            return(actNode);
                        }
                    }
                    return(null);
                }

                case "REF":
                    // If the parent is a Action node and the new act is a reference, try to explain it as a parameter of its subaction
                {
                    //
                    return(null);
                }
                }
                return(null);
            }
            else if (planNode is ParamNode)
            {
                switch (newAction.ActType)
                {
                case "ACT":
                {
                    ParamNode paramNode = (ParamNode)planNode;
                    foreach (ActionNode subActNode in paramNode.SubActions)
                    {
                        ActionNode actNode = this._explainActionFromNode(subActNode, tempAct, dlgAct, indent + "  ");
                        if (actNode != null)
                        {
                            return(actNode);
                        }
                    }
                    return(null);
                }

                case "REF":
                {
                    // explain the REF for potential match with the parameter, if the parent still expecting a parameter (paraStatus=unknown)
                    //retrieval the REF type, if it matches with the Parameter type, move forward
                    // Create a RefNode based on the newAction
                    // RefNode has a parant of planNode
                    // RefNode.execute to calculate the referenced entities and set the parameter of the planNode
                    RefNode newRef = new RefNode(newAction);
                    newRef.parent = (ParamNode)planNode;
                    newRef.execute();
                    return(null);
                }
                }
                return(null);
            }
            return(null);
        }
Example #16
0
        private ArrayList GetValueFromInput(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something: parse the value
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: GetValueFromInput"));
            
            ParamNode paramNode = (ParamNode)actionNode.Parent;
            foreach (string phrase in currDlgAct.SpeechContext.Keys)
            {
                if (phrase.ToLower() == paramNode.Name.ToLower())
                {
                    object newValue = _parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                    if (newValue != null)
                    {
                        this._addValueToParam(paramNode, newValue);
                        break;
                    }
                }
            }
            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #17
0
 private bool _parseRecipeXML(string recipeXML, ActionNode actionNode)
 {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(recipeXML);
     XmlNodeList paramList = doc.GetElementsByTagName("PARA");
     foreach (XmlNode param in paramList)
     {
         string name = param.Attributes["Name"].Value;
         string paramType = param.Attributes["Type"].Value;
         bool multiple = true;
         if (param.Attributes["Multiple"] != null && param.Attributes["Multiple"].Value.ToLower() == "false")
         {
             multiple = false;
         }
         string description = "";
         if (param.Attributes["Description"] != null)
         {
             description = param.Attributes["Description"].Value;
         }
         ParamNode paramNode = new ParamNode(name, paramType, multiple, description, actionNode);
         foreach (XmlNode node in param.ChildNodes)
         {
             if (node.Name == "ID_PARAS")
             {
                 foreach (XmlNode subAct in node.ChildNodes)
                 {
                     if (subAct.Name == "ID_PARA")
                     {
                         Hashtable tempAct = this._kbase.SearchAction(subAct.Attributes["Name"].Value);
                         ActionNode subActNode = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], paramNode);
                         if (subAct.Attributes["Optional"] != null && subAct.Attributes["Optional"].Value.ToString().ToLower() == "true")
                         {
                             subActNode.Optional = true;
                         }
                         paramNode.SubActions.Add(subActNode);
                     }
                 }
             }
         }
         actionNode.Params.Add(paramNode);
     }
     XmlNodeList actionList = doc.GetElementsByTagName("SUBACT");
     foreach (XmlNode action in actionList)
     {
         Hashtable tempAct = this._kbase.SearchAction(action.Attributes["Name"].Value);
         ActionNode subActNode = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], actionNode);
         if (action.Attributes["Optional"] != null && action.Attributes["Optional"].Value.ToString().ToLower() == "true")
         {
             subActNode.Optional = true;
         }
         actionNode.SubActions.Add(subActNode);
     }
     return true;
 }
Example #18
0
        private ArrayList CalculateFieldStatistics(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: CalculateFieldStatistics"));
            ActionNode parentNode = ((ActionNode)(actionNode.Parent));

            string featureClass = "";
            // search for overlay first
            ArrayList featureClassValues = this._searchValueFromAncestor(actionNode, "overlay");
            if (featureClassValues.Count == 0)
            {
                featureClassValues = this._searchValueFromAncestor(actionNode, "feature_class");
            }
            if (featureClassValues.Count > 0)
            {
                featureClass = featureClassValues[0].ToString();
            }

            string dataFieldName = "";
            ArrayList dataFieldValues = this._searchValueFromAncestor(actionNode, "data_field");
            if (dataFieldValues.Count > 0)
            {
                dataFieldName = dataFieldValues[0].ToString();
            }

            string statistics = "";
            ArrayList statisticsValues = this._searchValueFromAncestor(actionNode, "statistics");
            if (statisticsValues.Count > 0)
            {
                statistics = statisticsValues[0].ToString();
            }

            // mapping dataField name to field name in the data set
            string dataField = this._dataFieldMapping(dataFieldName);
            
            if (featureClass != "" && dataField != "")
            {
                Hashtable statResults = this._mapMgr.GetFieldStatistics(featureClass, dataField, true);
                respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "Here are the statistic results of " + dataFieldName));
                respList.Add(new DialogueResponse(DialogueResponseType.statisticResults, statResults));
                
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #19
0
        private ArrayList ChooseSpecificationMethod(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: ChooseSpecificationMethod"));

            ActionNode parent = (ActionNode)actionNode.Parent;
            if (parent != null)
            {
                foreach (ParamNode param in parent.Params)
                {
                    if (param.ParamType == "region_type" && param.ParamState == ParamState.Ready)
                    {
                        string region_type = param.Values[0].ToString();
                        respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Region Type:" + region_type));

                        string chosenActionName = ""; 
                        if (region_type == "features")
                        {
                            // select features in the region
                            chosenActionName = "Specify Region By Attributes";
                        }
                        else if (region_type == "drawing")
                        {
                            // select features in the region
                            chosenActionName = "Specify Region By Drawing";
                        }
                        else if (region_type == "buffer")
                        {
                            // select features in the region
                            chosenActionName = "Specify Region By Buffer";
                        }
                        if (chosenActionName != "")
                        {
                            respList.Add(new DialogueResponse(DialogueResponseType.newAgendaItem, chosenActionName));
                        }

                        // change its own state
                        actionNode.ActState = ActionState.Complete;
                        return respList;
                    }
                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #20
0
        private ArrayList CalculateDataSummary(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: CalculateDataSummary"));

            ActionNode parentNode = ((ActionNode)(actionNode.Parent));

            string featureClass = "";
            bool selectedOnly = false;
            // search for overlay first
            ArrayList featureClassValues = this._searchValueFromAncestor(actionNode, "overlay");
            if (featureClassValues.Count == 0)
            {
                featureClassValues = this._searchValueFromAncestor(actionNode, "feature_class");
                selectedOnly = true;
            }
            if (featureClassValues.Count > 0)
            {
                featureClass = featureClassValues[0].ToString();
            }

            string sumFieldName = "";
            ArrayList sumFieldValues = this._searchValueFromAncestor(actionNode, "summarize_field");
            if (sumFieldValues.Count > 0)
            {
                sumFieldName = sumFieldValues[0].ToString();
            }
            sumFieldName = this._dataFieldMapping(sumFieldName);

            string statistics = "";
            ArrayList statisticsValues = this._searchValueFromAncestor(actionNode, "statistics");
            if (statisticsValues.Count > 0)
            {
                statistics = statisticsValues[0].ToString();
            }

            string grpFieldName = "";
            ArrayList grpFieldValues = this._searchValueFromAncestor(actionNode, "group_by_field");
            if (grpFieldValues.Count > 0)
            {
                grpFieldName = grpFieldValues[0].ToString();
            }
            grpFieldName = this._dataFieldMapping(grpFieldName);

            if (featureClass != "" && sumFieldName != "" && grpFieldName != "")
            {
                string summaryFields = "Minimum." + grpFieldName + ", ";
                switch (statistics)
                {
                    case "count":
                        summaryFields += "Count." + sumFieldName;
                        break;
                    case "sum":
                        summaryFields += "Sum." + sumFieldName;
                        break;
                    case "minimum":
                        summaryFields += "Minimum." + sumFieldName;
                        break;
                    case "maximum":
                        summaryFields += "Maximum." + sumFieldName;
                        break;
                    case "mean":
                        summaryFields += "Average." + sumFieldName;
                        break;
                    case "std":
                        summaryFields += "StdDev." + sumFieldName;
                        break;
                    default:
                        summaryFields += "Count." + sumFieldName;
                        summaryFields += ", ";
                        summaryFields += "Sum." + sumFieldName;
                        summaryFields += ", ";
                        summaryFields += "Minimum." + sumFieldName;
                        summaryFields += ", ";
                        summaryFields += "Maximum." + sumFieldName;
                        summaryFields += ", ";
                        summaryFields += "Average." + sumFieldName;
                        summaryFields += ", ";
                        summaryFields += "StdDev." + sumFieldName;
                        break;
                }

                Hashtable sumResults = this._mapMgr.GetDataSummary(featureClass, summaryFields, grpFieldName, selectedOnly);
                respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "Here are the summary of " + sumFieldName + " grouped by " + grpFieldName));
                respList.Add(new DialogueResponse(DialogueResponseType.summaryResults, sumResults));
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #21
0
        private ArrayList SpecifyRegionByBuffer(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "MOCKUP Action: SpecifyRegionByBuffer"));

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #22
0
        private ArrayList BufferOp(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something: calculate the buffer
            ActionNode parentAct = (ActionNode)actionNode.Parent;
            string inputLayer = parentAct.GetParamValue("input_layer")[0].ToString();
            Hashtable distInfo = (Hashtable)(parentAct.GetParamValue("distance")[0]);
            string distString = distInfo["value"].ToString();
            if (distInfo.ContainsKey("unit"))
            {
                distString += " " + distInfo["unit"].ToString();
            }

            // todo: convert the unit if needed
            
            if (inputLayer != "" && distString != "")
            {
                string outLayerFile = ((IGeoProcessor)this._mapMgr).Buffer(inputLayer, distString);
                if (outLayerFile.Length > 0)
                {
                    respList.Add(new DialogueResponse(DialogueResponseType.mapLayerAdded, outLayerFile));
                    // change its own state
                    actionNode.ActState = ActionState.Complete;
                    return respList;
                }
            }
            // change its own state
            actionNode.ActState = ActionState.Failed;
            
            // generate response 
            return respList;
        }
Example #23
0
        private ArrayList GetCurrentMapExtent(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            ParamNode paramNode = (ParamNode)actionNode.Parent;
            object newValue = this._mapMgr.GetMapExtent();
            this._addValueToParam(paramNode, newValue);
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: GetCurrentMapExtent"));

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #24
0
        private ArrayList AskForValue(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            
            // if the action has not been executed, set it to executing, raid the question and return
            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: raise a question to the user
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: AskForValue"));

                ParamNode paramNode = (ParamNode)actionNode.Parent;
                // only ask if there is no value assigned yet
                if (paramNode.Values.Count == 0)
                {
                    respList.Add(new DialogueResponse(DialogueResponseType.speechQuestion, this._generateQuestionString(paramNode)));
                    // change its own state
                    actionNode.ActState = ActionState.Executing;
                    return respList;
                }
                else
                {
                    // change its own state
                    actionNode.ActState = ActionState.Complete;
                    // generate response 
                    return respList;
                }
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                ParamNode paramNode = (ParamNode)actionNode.Parent;
                if (currDlgAct.DlgActType == DialogueActType.Answer)
                {
                    foreach (string phrase in currDlgAct.SpeechContext.Keys)
                    {
                        if (phrase.ToLower() == paramNode.Name.ToLower())
                        {
                            object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                            if (newValue != null)
                            {
                                this._addValueToParam(paramNode, newValue);
                                // change its own state
                                actionNode.ActState = ActionState.Complete;
                                // generate response 
                                return respList;
                            }
                        }
                    } 
                }
                else if (currDlgAct.DlgActType == DialogueActType.Accept && paramNode.ParamType == "boolean")
                {
                    this._addValueToParam(paramNode, true);
                    respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, paramNode.Name + ": true"));
                    actionNode.ActState = ActionState.Complete;
                    return respList;
                }
                else if (currDlgAct.DlgActType == DialogueActType.Accept && paramNode.ParamType == "boolean")
                {
                    this._addValueToParam(paramNode, true);
                    respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, paramNode.Name + ": false"));
                    actionNode.ActState = ActionState.Complete;
                    return respList;
                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #25
0
        private ArrayList InferValueFromOtherParameter(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: InferValueFromOtherParameter"));
            ParamNode paramNode = (ParamNode)actionNode.Parent;
            string [] paramNames = paramNode.Name.Split('.');
            if (paramNames.Length > 1 && paramNames[1] == "multiple" && paramNode.ParamType == "boolean")
            {
                PlanNode parent = paramNode;
                string ancestorParamName = paramNames[0];
                ParamNode matchedParam = null;
                while (parent != null)
                {
                    if (parent.Parent is ParamNode)
                    {
                        ParamNode ancestorParam = parent.Parent as ParamNode;
                        if (ancestorParam.Name.ToLower() == ancestorParamName.ToLower() && ancestorParam.ParamState == ParamState.Ready)
                        {
                            matchedParam = ancestorParam;
                            break;
                        }
                    }
                    else if (parent.Parent is ActionNode)
                    {
                        ActionNode ancestorAction = parent.Parent as ActionNode;
                        foreach (ParamNode ancestorParam in ancestorAction.Params)
                        {
                            if (ancestorParam.Name.ToLower() == ancestorParamName.ToLower() && ancestorParam.ParamState == ParamState.Ready)
                            {
                                matchedParam = ancestorParam;
                                break;
                            }
                        }
                        if (matchedParam != null)
                        {
                            break;
                        }
                    }
                    parent = parent.Parent;
                }

                if (matchedParam != null)
                {
                    if (matchedParam.Values.Count > 1)
                    {
                        this._addValueToParam(paramNode, true);
                        respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, paramNode.Name + ": true"));
                    }
                    else if (matchedParam.Values.Count == 1)
                    {
                        this._addValueToParam(paramNode, false);
                        respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, paramNode.Name + ": false"));
                    }
                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #26
0
 public ArrayList Execute(ActionNode actionNode, DialogueAct currDlgAct)
 {
     if (actionNode.Name.ToLower() == "Get Value From Input".ToLower())
     {
         return this.GetValueFromInput(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Ask For Value".ToLower())
     {
         return this.AskForValue(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Select From Candidates".ToLower())
     {
         return this.SelectFromCandidates(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Get Existing Value From Ancestor".ToLower())
     {
         return this.GetExistingValueFromAncestor(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Ask For More Value".ToLower())
     {
         return this.AskForMoreValue(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Identify Region Type".ToLower())
     {
         return this.IdentifyRegionType(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Choose Specification Method".ToLower())
     {
         return this.ChooseSpecificationMethod(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Specify Region By Attributes".ToLower())
     {
         return this.SpecifyRegionByAttributes(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Specify Region By Drawing".ToLower())
     {
         return this.SpecifyRegionByDrawing(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Specify Region By Buffer".ToLower())
     {
         return this.SpecifyRegionByBuffer(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Ask For Partiality".ToLower())
     {
         return this.AskForPartiality(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Get Current Map Extent".ToLower())
     {
         return this.GetCurrentMapExtent(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Draw Region".ToLower())
     {
         return this.DrawRegion(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Infer Value From Other Parameter".ToLower())
     {
         return this.InferValueFromOtherParameter(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Choose Analytic Functions".ToLower())
     {
         return this.ChooseAnalyticFunctions(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Perform Selection".ToLower())
     {
         return this.PerformSelection(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Perform Overlay".ToLower())
     {
         return this.PerformOverlay(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Calculate Field Statistics".ToLower())
     {
         return this.CalculateFieldStatistics(actionNode, currDlgAct);
     }
     else if (actionNode.Name.ToLower() == "Calculate Data Summary".ToLower())
     {
         return this.CalculateDataSummary(actionNode, currDlgAct);
     }
     return new ArrayList();
 }
Example #27
0
        private ArrayList BasicActionTemplate(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: "));

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #28
0
        private ArrayList SelectFromCandidates(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: generate the candiate list           
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: SelectFromCandidates"));

                ParamNode paramNode = (ParamNode)actionNode.Parent;

                if (paramNode.Name == "admin_area")
                {
                    // fixed at the moment, future work will search the database to generat the list
                    PlainOptionListData respContent = new PlainOptionListData();
                    respContent.Opening = this._generateQuestionString(paramNode);
                    respContent.AddOption(new PlainOptionItemData("City of Oleader", "Matched feature classes: LandUse"));
                    respContent.AddOption(new PlainOptionItemData("City of Rochester", "Matched feature classes: LandUse, Parcels"));
                    respContent.AddOption(new PlainOptionItemData("City of Baltimore", "Matched feature classes: Parcels, Dwelling units"));
                    respList.Add(new DialogueResponse(DialogueResponseType.listPlainOptions, respContent));
                    return respList;
                }                
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                ParamNode paramNode = (ParamNode)actionNode.Parent;
                foreach (string phrase in currDlgAct.SpeechContext.Keys)
                {
                    if (phrase.ToLower() == paramNode.Name.ToLower())
                    {
                        object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                        if (newValue != null)
                        {
                            this._addValueToParam(paramNode, newValue);

                            // change its own state
                            actionNode.ActState = ActionState.Complete;

                            // generate response 
                            
                            if (paramNode.ParamType == "data_source")
                            {
                                // fixed at the moment
                                string dataSourcePath = @"..\..\..\Data\GISLAB\Data\";
                                foreach (string value in paramNode.Values)
                                {
                                    string filePath = System.IO.Path.Combine(dataSourcePath, value + ".mxd");
                                    if (System.IO.File.Exists(filePath))
                                    {
                                        respList.Add(new DialogueResponse(DialogueResponseType.mapDocumentOpened, filePath));
                                        respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The map of " + value + " is loaded!"));
                                        break;
                                    }
                                }
                            }
                            return respList;
                        }
                    }
                }   
            }

            
            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #29
0
        private ActionNode _explainActionFromNode(PlanNode planNode, Hashtable tempAct, DialogueAct dlgAct)
        {
            if (planNode is ActionNode)
            {
                ActionNode actionNode = (ActionNode)planNode;
                if (actionNode.Name.ToLower() == tempAct["name"].ToString().ToLower())
                {
                    // If the action has not been initiated, initiate it and add the agent
                    if (actionNode.ActState == ActionState.Unknown)
                    {
                        actionNode.ActState = ActionState.Initiated;
                    }
                    if (actionNode.SearchAgent(dlgAct.Agent) == null)
                    {
                        actionNode.Agents.Add(dlgAct.Agent);
                    }
                    // If the action has been completed, or failed, start a new one, attached it to the same parent
                    if (actionNode.ActState == ActionState.Complete || actionNode.ActState == ActionState.Failed)
                    {
                        ActionNode newAction = new ActionNode((string)tempAct["name"], (string)tempAct["act_type"], (string)tempAct["complexity"], (string)tempAct["description"], actionNode.Parent);
                        newAction.Agents.Add(dlgAct.Agent);
                        newAction.ActState = ActionState.Initiated;
                        if (actionNode.Parent != null)
                        {
                            if (actionNode.Parent is ActionNode)
                            {
                                ((ActionNode)(actionNode.Parent)).SubActions.Add(newAction);
                            }
                            else if (actionNode.Parent is ParamNode)
                            {
                                ((ParamNode)(actionNode.Parent)).SubActions.Add(newAction);
                            }
                        }
                        return newAction;
                    }
                    return actionNode;
                }

                // search the params and subactions
                foreach (ParamNode paramNode in actionNode.Params)
                {
                    ActionNode actNode = this._explainActionFromNode(paramNode, tempAct, dlgAct);
                    if (actNode != null)
                    {
                        return actNode;
                    }
                }
                foreach (ActionNode subActNode in actionNode.SubActions)
                {
                    ActionNode actNode = this._explainActionFromNode(subActNode, tempAct, dlgAct);
                    if (actNode != null)
                    {
                        return actNode;
                    }
                }
                
            }
            else if (planNode is ParamNode)
            {
                ParamNode paramNode = (ParamNode)planNode;
                foreach (ActionNode subActNode in paramNode.SubActions)
                {
                    ActionNode actNode = this._explainActionFromNode(subActNode, tempAct, dlgAct);
                    if (actNode != null)
                    {
                        return actNode;
                    }
                }   
            }

            return null;
        }
Example #30
0
        private ArrayList GetExistingValueFromAncestor(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();
            // change its own state
            actionNode.ActState = ActionState.Executing;

            // do something:
            respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: GetExistingValueFromAncestor"));
            
            ParamNode paramNode = (ParamNode)actionNode.Parent;
            PlanNode parent = paramNode;
            while (parent != null)
            {
                if (parent.Parent is ParamNode)
                {
                    ParamNode ancestorParam = parent.Parent as ParamNode;
                    if (ancestorParam.ParamType == paramNode.ParamType && ancestorParam.ParamState == ParamState.Ready)
                    {
                        foreach (object value in ancestorParam.Values)
                        {
                            this._addValueToParam(paramNode, value);
                        }
                    }
                }
                else if (parent.Parent is ActionNode)
                {
                    ActionNode ancestorAction = parent.Parent as ActionNode;
                    foreach (ParamNode param in ancestorAction.Params)
                    {
                        if (param != paramNode)
                        {
                            if (param.ParamType == paramNode.ParamType && param.ParamState == ParamState.Ready)
                            {
                                foreach (object value in param.Values)
                                {
                                    this._addValueToParam(paramNode, value);
                                }
                            }
                        }
                    }
                }
                parent = parent.Parent;
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #31
0
        private void _elaborateFromActionNode(ActionNode actionNode)
        {
            // check the parameters and constraints
            bool paramsRdy = this._parentParamsRdy(actionNode); // check whether the params are ready
            if (paramsRdy == false)
            {
                return;
            }

            // If the action is a basic one and can be executed, then execute it
            if (actionNode.Complexity == "basic")
            {
                // check the state of the action
                if (actionNode.ActState == ActionState.Initiated || actionNode.ActState == ActionState.Executing)
                {
                    

                    // perform the task
                    ArrayList execResp = this._exec.Execute(actionNode, this._currDlgAct);
                    // add the execution response to the response list
                    ArrayList newAgendaItems = new ArrayList();
                    foreach (DialogueResponse resp in execResp)
                    {
                        if (resp.DlgRespType == DialogueResponseType.newAgendaItem)
                        {
                            newAgendaItems.Add(resp.RespContent);
                        }
                        else
                        {
                            this._respList.Add(resp);
                        }
                    }

                    // remove the running/complete action from the agenda;
                    if (actionNode.ActState == ActionState.Complete)
                    {
                        this.RemoveFromAgenda(actionNode);
                    }
                    // check whether the parent's state is also complete if the action is complete
                    if (actionNode.ActState == ActionState.Complete)
                    {
                        this._updateParentState(actionNode);
                    }

                    // perform the new agenda item
                    foreach (string actionName in newAgendaItems)
                    {
                        if (actionName != "")
                        {
                            // only search parent level at the moment
                            ActionNode parentNode = (ActionNode)actionNode.Parent;
                            foreach (ActionNode subAct in parentNode.SubActions)
                            {
                                if (subAct.Name.ToLower() == actionName.ToLower())
                                {
                                    if (subAct.ActState == ActionState.Unknown)
                                    {
                                        subAct.ActState = ActionState.Initiated;
                                        int idx = this.GetIndexInAgenda(actionNode);
                                        this.AddToAgenda(subAct, idx + 1);
                                        this.ElaborateFromNode(subAct);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                return;
            }

            if (actionNode.Complexity == "complex")
            {
                // check the state of the action
                if (actionNode.ActState == ActionState.Initiated)
                {
                    // find and load the recipe
                    this._loadRecipe(actionNode);
                    
                }
                if (actionNode.ActState == ActionState.Planned)
                {
                    int idx = this.RemoveFromAgenda(actionNode);
                    foreach (ParamNode param in actionNode.Params)
                    {
                        idx = this.AddToAgenda(param, idx);
                        idx++;
                    }
                    foreach (ActionNode subAct in actionNode.SubActions)
                    {
                        idx = this.AddToAgenda(subAct, idx);
                        idx++;
                    } 

                    // elaborate on the params
                    foreach (ParamNode param in actionNode.Params)
                    {
                        param.ParamState = ParamState.InPreparation;
                        this._elaborateFromParamNode(param);
                    }

                    foreach (ActionNode subAct in actionNode.SubActions)
                    {
                        if (subAct.Optional == false)
                        {
                            subAct.ActState = ActionState.Initiated;
                            this._elaborateFromActionNode(subAct);
                        }
                        else
                        {
                            this.RemoveFromAgenda(subAct);
                        }
                    } 
                    
                }
            }
            
        }
Example #32
0
        private ArrayList AskForMoreValue(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: generate the candiate list           
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: AskForMoreValue"));

                ParamNode paramNode = (ParamNode)actionNode.Parent;

                if (paramNode.Name == "feature_class")
                {
                    // fixed at the moment, future work will search the database to generate the list
                    MapLayerOptionListData respContent = new MapLayerOptionListData();
                    //respContent.Opening = this._generateQuestionString(paramNode);
                    respContent.Opening = "You may want to consider adding the following layers to the map as background:";
                    respContent.AddOption(new MapLayerOptionItemData("Lot boundaries", @"C:\Work\Data\GISLAB\Data\Oleader\Lot Boundaries.lyr"));
                    respContent.AddOption(new MapLayerOptionItemData("Zoning", @"C:\Work\Data\GISLAB\Data\Oleader\Zoning.lyr"));
                    respContent.AddOption(new MapLayerOptionItemData("Flood areas", @"C:\Work\Data\GISLAB\Data\Oleader\Flood Areas.lyr"));
                    
                    respList.Add(new DialogueResponse(DialogueResponseType.listMapLayerOptions, respContent));
                    return respList;
                }
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                ParamNode paramNode = (ParamNode)actionNode.Parent;
                foreach (string phrase in currDlgAct.SpeechContext.Keys)
                {
                    if (phrase.ToLower() == paramNode.Name.ToLower())
                    {
                        object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                        if (newValue != null)
                        {
                            this._addValueToParam(paramNode, newValue);

                            // change its own state
                            actionNode.ActState = ActionState.Complete;
                            // generate response 
                            if (paramNode.ParamType == "feature_class")
                            {
                                // fixed at the moment
                                string dataSourcePath = @"C:\Work\Data\GISLAB\Data\Oleader\";
                                string filePath = System.IO.Path.Combine(dataSourcePath + (string)newValue + ".lyr");
                                if (System.IO.File.Exists(filePath))
                                {
                                    respList.Add(new DialogueResponse(DialogueResponseType.mapLayerAdded, filePath));
                                }
                            }
                            return respList;
                        }
                    }
                }
            }
            
            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #33
0
 private void _loadRecipe(ActionNode actionNode)
 {
     ArrayList recipeList = this._kbase.SearchRecipe(actionNode.Name);
     if (recipeList.Count == 0)
     {
         this._respList.Add(new DialogueResponse(DialogueResponseType.speechError, "There is no recipe for action " + actionNode.Name + " in the knowledge base!"));
         return;
     }
     // todo: select from multiple recipes?
     // load the first one atm
     Hashtable recipeInfo = (Hashtable)recipeList[0];
     string recipeXMl = recipeInfo["content"].ToString();
     bool parsed = this._parseRecipeXML(recipeXMl, actionNode);
     // if succeed, set the action state to planned, set the states of children, remove the node from the agenda
     if (parsed == true)
     {
         actionNode.ActState = ActionState.Planned;
     }
 }
Example #34
0
        private ArrayList IdentifyRegionType(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: generate the candiate list           
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: IdentifyRegionType"));

                ParamNode paramNode = (ParamNode)actionNode.Parent;

                if (paramNode.Name == "region_type")
                {
                    // fixed at the moment
                    OptionWithExampleListData respContent = new OptionWithExampleListData();
                    respContent.Opening = this._generateQuestionString(paramNode);
                    respContent.Opening = "Please describe exactly the region you are interested in. You may choose one of the three methods:";
                    respContent.AddOption(new OptionWithExampleItemData("Draw the region manually on the map", "The region is drawn manually", "/CAGA;component/Images/region_drawing.png"));
                    respContent.AddOption(new OptionWithExampleItemData("Define a region from selection of area features", "The region is a set of areal features", "/CAGA;component/Images/region_attributes.png"));
                    respContent.AddOption(new OptionWithExampleItemData("Define region from neighborhood of selected features", "The region is a buffer zone around some feature", "/CAGA;component/Images/region_buffer.png"));
                    respList.Add(new DialogueResponse(DialogueResponseType.listOptionsWithExamples, respContent));
                    return respList;
                }
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                ParamNode paramNode = (ParamNode)actionNode.Parent;
                foreach (string phrase in currDlgAct.SpeechContext.Keys)
                {
                    if (phrase.ToLower() == paramNode.Name.ToLower())
                    {
                        object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                        if (newValue != null)
                        {
                            this._addValueToParam(paramNode, newValue);

                            // change its own state
                            actionNode.ActState = ActionState.Complete;
                            return respList;
                        }
                    }
                }
            }

            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }
Example #35
0
 public RefNode(ActionNode tmpAct)
 {
     // set the properties of the refnode based on the recipe retrieved for tmpAct
     // check for readiness of the node for execution, if yes, turn status to be ready
 }
Example #36
0
        public bool Explain(DialogueAct dlgAct)
        {
            string indent = "";

            Console.WriteLine(indent + "Dialogue.PlanGraph Explain " + dlgAct.DlgActType);
            bool isExplained = false;

            if (dlgAct.DlgActType == DialogueActType.Intend)
            {
                // search the actions from knowledge base
                // the simplest way: search based on name matching
                ArrayList  tempActions   = new ArrayList();
                SortedList tmpSortedList = new SortedList();
                foreach (object phrase in dlgAct.SpeechContext.Values)
                {
                    if (phrase is string)
                    {
                        Console.WriteLine(indent + "string:" + phrase);
                        Hashtable tempAct = this._kbase.SearchAction((string)phrase);
                        if (tempAct != null)
                        {
                            tempActions.Add(tempAct);
                        }
                    }
                    else if (phrase is SortedList)
                    {
                        foreach (DictionaryEntry item in (SortedList)phrase)
                        {
                            tmpSortedList.Add(item.Key, item.Value);
                            Console.WriteLine(indent + "key:" + item.Key + ",value=" + item.Value);
                        }
                    }
                }
                foreach (DictionaryEntry item in tmpSortedList)
                {
                    dlgAct.SpeechContext.Add(item.Key, item.Value);
                }
                // Explain the actions into the plangraph
                ArrayList explainedActs = new ArrayList();
                foreach (Hashtable tempAct in tempActions)
                {
                    ActionNode explainedAct = this._explainAction(tempAct, dlgAct, indent + "  ");
                    if (explainedAct != null)
                    {
                        explainedActs.Add(explainedAct);
                        AddToAgenda(explainedAct, 0, indent + "  ");
                    }
                }
                if (explainedActs.Count > 0)
                {
                    isExplained = true;
                }
            }
            else if (dlgAct.DlgActType == DialogueActType.Answer)
            {
                // the input is an answer to previous question,
                // explain in the agenda
                foreach (PlanNode planNode in this._agenda.ToArray())
                {
                    isExplained = this._explainAnswer(planNode, dlgAct, indent + "  ");
                    if (isExplained == true)
                    {
                        break;
                    }
                }
            }
            else if (dlgAct.DlgActType == DialogueActType.Accept || dlgAct.DlgActType == DialogueActType.Reject)
            {
                // the input is an affirmative or neagtive to previous question,
                // explain in the agenda
                foreach (PlanNode planNode in this._agenda.ToArray())
                {
                    isExplained = this._explainAffOrNeg(planNode, dlgAct, indent + "  ");
                    if (isExplained == true)
                    {
                        break;
                    }
                }
            }
            else if (dlgAct.DlgActType == DialogueActType.Feedback)
            {
                // the input is a feedback to previous action,
                // explain in the agenda
                foreach (PlanNode planNode in this._agenda.ToArray())
                {
                    isExplained = this._explainFeedback(planNode, dlgAct, indent + "  ");
                    if (isExplained == true)
                    {
                        break;
                    }
                }
            }
            else if (dlgAct.DlgActType == DialogueActType.Correct)
            {
                Console.WriteLine("DialogueActType.Correct");

                if (this._actionNodeStack.Count > 0)
                {
                    ActionNode tmpAction = _actionNodeStack.Peek();
                    Console.WriteLine("preAction=" + tmpAction.Name);
                    foreach (ParamNode param in tmpAction.Params)
                    {
                        Console.WriteLine("param=" + param.Name);
                        Console.WriteLine("DialogueActType.Correct");
                        if ((param.ParamState == ParamState.Ready) && (dlgAct.SpeechContext.ContainsKey(param.Name)))
                        {
                            object newValue = _exec._parseValueFromSpeech(param, dlgAct.SpeechContext[param.Name]);
                            if (newValue != null)
                            {
                                _exec._addValueToParam(param, newValue, indent);
                                isExplained = true;
                            }
                        }
                    }
                    if (isExplained == true)
                    {
                        foreach (ActionNode subAct in tmpAction.SubActions)
                        {
                            Console.WriteLine("subAct=" + subAct.Name);
                            subAct.ActState = ActionState.Executing;
                            AddToAgenda(subAct, 0, indent + "  ");
                        }
                        foreach (PlanNode planNode in this._agenda.ToArray())
                        {
                            if (planNode is ActionNode)
                            {
                                ((ActionNode)planNode).ActState = ActionState.Initiated;
                            }
                            if (planNode is ParamNode)
                            {
                                ((ParamNode)planNode).ParamState = ParamState.InPreparation;
                            }
                        }
                    }
                }
            }
            if (isExplained == true)
            {
                this._currDlgAct = dlgAct;
            }

            Console.WriteLine(indent + "Agenda:");
            foreach (PlanNode planNode in this._agenda.ToArray())
            {
                Console.WriteLine(indent + "-" + planNode.Name);
            }
            Console.WriteLine(indent + "IsExplained? " + isExplained);
            return(isExplained);
        }