//Process all edgeProgression actions //Fetch the action packets $actionPackets = $plannerProgress[0]; //Check the edgeprogression action has been matched $edgeProgressionPacket = planningAgent::action($actionPackets, $_POST); //Retreive whether the edge progression test was passed $edgeProgressionResult = $edgeProgressionPacket['match']; //Retrive the selected action packet $selectedActionPacket = $edgeProgressionPacket['actionPacket']; if ($edgeProgressionResult) { //The edgeprogression test succeded //Check the chosen action packet if ($selectedActionPacket->atGoal()) { //At goal node $goal = true; planArchieving::archive($_POST['workflowID']); systemMessages::message("Goal node reached!"); } else { //Only one action packet should be returned $plans = $selectedActionPacket->getPlans(); $newPlannerProgress = planAction::fetchNextAction($plans); $action = node::getNodeData($newPlannerProgress[1]); if ($action->getPredicateName() != 'edgeProgression') { $match = true; } else { } $plannerProgress = $newPlannerProgress; $newPlannerProgress = array(); } } }
function actionTest($planList, $messages, $conditionID, $conditionMode) { $IDPosition = 0; $modePosition = 1; $valuePosition = 2; $match = false; $index = -1; while ($index < sizeof($planList) - 1 && !$match) { $index++; $actionNode = $planList[$index]->getAction(); $actionNodeData = $actionNode->getData(); $edgeProgression = $actionNodeData[0]; $edgeActionValues = $edgeProgression->getPredicateValues(); //$condition = $edgeActionValues[sizeof($edgeActionValues)-1]; //$conditionValues = $condition->getPredicateValues(); $conditionValue = $edgeActionValues[$valuePosition]->toString(); //Examine the message $message = planningAgent::see($messages, $conditionID); //Finding the matching action packet $match = planningAgent::doit($planList[$index], $conditionMode, $conditionValue, $messages, $message, $conditionID); } if (!$match) { errors::errorMessage("No progression was found!"); } else { //Check the chosen action packet if ($planList[$index]->atGoal()) { //At goal node planArchieving::archive($_POST['workflowID']); systemMessages::message("Goal Node reached!"); } } return $planList[$index]; }