This commit is contained in:
Garrett K 2021-02-25 20:32:09 +00:00
parent 27b10e836a
commit 8c66c08f64
2 changed files with 106 additions and 34 deletions

View File

@ -24,9 +24,8 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$objDepth = isset($data['partitionDepth']) ? $data['partitionDepth'] : false; $objDepth = isset($data['partitionDepth']) ? $data['partitionDepth'] : false;
// Create $path // Create $path
include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path2.php'; include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path2.php';
error_log('Debug (connSet): '.json_encode($connSet)); include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path.php';
$validate->returnData['success'] = $qls->App->buildPathFull($path, $connectorCode39); $validate->returnData['success'] = $qls->App->buildPathFull($path, $connectorCode39);
} }
echo json_encode($validate->returnData); echo json_encode($validate->returnData);

View File

@ -17,48 +17,88 @@ $selectedObjFace2 = $objFace;
$selectedObjDepth2 = $objDepth; $selectedObjDepth2 = $objDepth;
$selectedObjPort2 = $objPort; $selectedObjPort2 = $objPort;
$connSet = crawlConnSet($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2); $connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
detectDivergence($connSet);
function crawlTrunk($connSet) { while(count($connSet[0]) or count($connSet[1])){
} $trunkSet = crawlTrunk($qls, $connSet);
detectDivergence($trunkSet);
function detectDivergence($connSet) {
// Detect path divergence foreach($trunkSet as $trunk) {
foreach($connSet as $conn) { foreach($trunk as $port) {
foreach($conn as $portIndex => $port) {
// Identify parent object ID $selectedObjID2 = $port['objID'];
$portObjID = $port['objID']; $selectedObjFace2 = $port['objFace'];
$portObj = $qls->App->objectArray[$portObjID]; $selectedObjDepth2 = $port['objDepth'];
$portObjParentID = $portObj['parent_id']; $selectedObjPort2 = $port['objDepth'];
while($portObjParentID != 0) {
$portObj = $qls->App->objectArray[$portObjParentID];
$portObjParentID = $portObj['parent_id'];
}
// Determine path divergence $workingConnSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
if($portIndex == 0) { detectDivergence($workingConnSet);
$baselineParentID = $portObjParentID;
} else { foreach($workingConnSet as $workingConn) {
if($portObjParentID == $baselineParentID) {
// Path does not diverge
} else {
// Path does diverge
}
} }
} }
} }
} }
function crawlConnSet(&$qls, $objID, $objFace, $objDepth, $objPort, &$connSetID=0, &$connSet=array(array(),array())) { error_log('Debug (connSet): '.json_encode($connSet));
error_log('Debug (trunkSet): '.json_encode($trunkSet));
function crawlTrunk(&$qls, $connSet) {
$trunkSet = array(array(),array());
// Loop over each side of $connSet
foreach($connSet as $connSetID => $conn) {
// Loop over each port of $conn
foreach($conn as $connID => $port) {
// Gather port data
$objID = $port['objID'];
$objFace = $port['objFace'];
$objDepth = $port['objDepth'];
$objPort = $port['objPort'];
// Gather trunk peer data
if(isset($qls->App->peerArray[$objID][$objFace][$objDepth])) {
// Gather trunk peer object
$peer = $qls->App->peerArray[$objID][$objFace][$objDepth];
// Gather trunk peer data
$peerObjID = $peer['peerID'];
$peerObjFace = $peer['peerFace'];
$peerObjDepth = $peer['peerDepth'];
$peerObjPort = $objPort;
// Create a working array for cleanliness
$workingArray = array(
'objID' => $peerObjID,
'objFace' => $peerObjFace,
'objDepth' => $peerObjDepth,
'objPort' => $peerObjPort
);
// Store trunk data
$trunkSet[$connSetID][$connID] = $workingArray;
}
}
}
return $trunkSet;
}
function crawlConn(&$qls, $objID, $objFace, $objDepth, $objPort, $connSetID=0, &$connSet=array(array(),array())) {
// Store port details // Store port details
$workingArray = array( $workingArray = array(
'objID' => $objID, 'objID' => $objID,
'objFace' => $objFace, 'objFace' => $objFace,
'objDepth' => $objDepth, 'objDepth' => $objDepth,
'objPort' => $objPort, 'objPort' => $objPort
); );
// Add port info to connection set // Add port info to connection set
@ -91,16 +131,49 @@ function crawlConnSet(&$qls, $objID, $objFace, $objDepth, $objPort, &$connSetID=
} }
if(!$alreadySeen) { if(!$alreadySeen) {
error_log('Debug: '.$remoteObjID.'-'.$remoteObjFace.'-'.$remoteObjDepth.'-'.$remoteObjPort); crawlConn($qls, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSetID, $connSet);
crawlConnSet($qls, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSetID, $connSet);
} }
} }
} }
return $connSet; return $connSet;
} }
function detectDivergence(&$dataSet) {
$pathDiverges = false;
// Detect path divergence
foreach($dataSet as &$data) {
foreach($data as $portIndex => $port) {
// Identify parent object ID
$portObjID = $port['objID'];
$portObj = $qls->App->objectArray[$portObjID];
$portObjParentID = $portObj['parent_id'];
while($portObjParentID != 0) {
$portObj = $qls->App->objectArray[$portObjParentID];
$portObjParentID = $portObj['parent_id'];
}
// Determine path divergence
if($portIndex == 0) {
$baselineParentID = $portObjParentID;
} else {
if($portObjParentID != $baselineParentID) {
// Flag this path as divergent
$pathDiverges = true;
// Remove divergent connection
unset($data[$portIndex]);
}
}
}
}
unset($data);
return $pathDiverges;
}
?> ?>