//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(); } } } debug::message("edge progression test :" . $edgeProgressionResult);
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]; }
$newstoptime = time::stoptiming() - $stoptime; performance::message("Database updating"); echo '<br><Br>'; systemMessages::message("Plan generation complete!"); systemMessages::message("Number of plans:" . sizeof($planGraphList)); } } else { $workFlowvalues = array(); $workFlowvalues['timestamp'] = $modified = time::ts_unix_mysql(time::timestamp()); //Create a new workflow item $keyinserted = dbs::irrecord('workflow', $workFlowvalues, false); $planGraphList = dbs::selrecord('plan', 'workflowcachingstore', "modelId={$modelId}", 0, 3); savePlans($planGraphList, $keyinserted, false); echo '<br><Br>'; systemMessages::message("Plan generation using caching feature complete!"); systemMessages::message("Number of plans:" . sizeof($planGraphList)); } function savePlans($planGraphList, $workflowKey, $seralise) { $planValues = array(); $dbValues = array(); for ($index = 0; $index < sizeof($planGraphList); $index++) { if ($seralise) { $plan = addslashes(serialize($planGraphList[$index])); } else { $plan = addslashes($planGraphList[$index]); } $planValues['workflowid'] = $workflowKey; $planValues['plan'] = $plan; array_push($dbValues, $planValues); //dbs::irrecord('plans',$planValues, false);
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); }
<?php include_once 'includes/configuration/core_configuration.php'; include_once "includes/commonPages/system_header.php"; $table = 'dtdFiles'; if (!isset($_POST['dtdFile'])) { $_POST['dtdFile'] = false; } if ($_POST['dtdFile']) { include_once 'parseHTMLdtd.php'; generatePrologDTDtyping($_POST['dtdFile']); systemMessages::message('Typing generated successfully'); } ?> <form method="POST" action=""> <table border="0"> <tr> <td width="20"><img src="images/wsb_side.gif" border="0"></td> <td class="formbold" width="550">W3C DTD file<br> <?php $selectdata = formdata::getdata_select('dtdFile', 'dtdFile', $_POST['dtdFile'], $table, 0, 0, 0, 0); formdisplay::display_select($selectdata, 'default'); echo '</td></tr>'; echo '<tr><td> </td><td><br><br>'; $submitButton = formdata::getdata_btn('submit', 'submit', 'change DTD', ''); formdisplay::display_btn($submitButton, 'default'); ?> </tr></td>
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; }