function fetchNextAction($planList) { //There is a bug in PHP //When trying to process very large objects it side effects the values! //To overcome this we must enforce a copy is made and then use this instead! $localPlanList = array(); $planListSize = sizeof($planList); for ($index = 0; $index < $planListSize; $index++) { $localPlanList[$index] = new graphPlan(); $localPlanList[$index] = $planList[$index]; } $possibleActions = array(); $actionCollection = array(); //We have not reached the goal state if ($possibleActions = planComparison::compareActions($localPlanList, false)) { //We have not reached a decision point if (!planComparison::conditionalAction($possibleActions)) { //This is only one action $currentAction = $possibleActions[0]->getAction(); $nodeData = $currentAction->getData(); array_push($actionCollection, $nodeData[0]); } else { // Conditional action encountered systemMessages::message("Plan decision point encountered"); //Only consider the first packet $currentAction = $possibleActions[0]->getAction(); $nodeData = $currentAction->getData(); array_push($actionCollection, $nodeData[0]); } } else { // Goal node reached systemMessages::message("GoalNode!"); } return array($possibleActions, $actionCollection); }
/** * @return void * @param $planList Array of planCollections * @desc compares Actions */ function compareActions($planList, $updateHistory) { //Find a list of Action Packets $currentActions = planComparison::findNextActions($planList, $updateHistory); // [ACTION, Plan-i] , [ACTION, Plan-i+1] // [ACTION-Plan-i,Plan-i+1] //Merge relevant Action Packets $mergedActionPackets = planComparison::composeActions($currentActions); return $mergedActionPackets; }
function processLoop($planGraphList, $workflowID) { //Find the next Actions $possibleActions = planComparison::compareActions($planGraphList, false); $loopResult = actionPacket::checkActionPacketsForLoop($possibleActions); if ($loopResult['loop']) { //Check to see if we are looping systemMessages::message("Workflow is Looping!"); $planGraphList = graphPlanDatabaseAccess::getPlanState($workflowID, $loopResult['formName']); graphPlanDatabaseAccess::updatePlanGraphList($workflowID, $planGraphList); $possibleActions = planComparison::compareActions($planGraphList, false); } return $possibleActions; }