This commit is contained in:
Garrett K 2021-02-24 05:21:13 +00:00
parent 08c740c64f
commit aa823314e4
2 changed files with 76 additions and 30 deletions

View File

@ -25,7 +25,8 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
// Create $path // Create $path
include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path.php'; include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path.php';
error_log('Debug (path): '.json_encode($path)); include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path2.php';
error_log('Debug (connSet): '.json_encode($connSet));
$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

@ -1,23 +1,57 @@
<?php <?php
$path = array(); $path2 = array();
if($connectorCode39) { if($connectorCode39) {
$connectorID = base_convert($connectorCode39, 36, 10); $connectorID2 = base_convert($connectorCode39, 36, 10);
$rootCable = $qls->App->inventoryByIDArray[$connectorID]; $rootCable2 = $qls->App->inventoryByIDArray[$connectorID2];
$objID = $rootCable['local_object_id']; $objID2 = $rootCable2['local_object_id'];
$objFace = $rootCable['local_object_face']; $objFace2 = $rootCable2['local_object_face'];
$objDepth = $rootCable['local_object_depth']; $objDepth2 = $rootCable2['local_object_depth'];
$objPort = $rootCable['local_object_port']; $objPort2 = $rootCable2['local_object_port'];
} }
$selectedObjID = $objID; $selectedObjID2 = $objID;
$selectedObjFace = $objFace; $selectedObjFace2 = $objFace;
$selectedObjDepth = $objDepth; $selectedObjDepth2 = $objDepth;
$selectedObjPort = $objPort; $selectedObjPort2 = $objPort;
function crawlConnSet($objID, $objFace, $objDepth, $objPort, $connSetID=0, $connSet=array(array(),array())) { $connSet = crawlConnSet($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
function crawlTrunk($connSet) {
}
function detectDivergence($connSet) {
// Detect path divergence
foreach($connSet as $conn) {
foreach($conn 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) {
// Path does not diverge
} else {
// Path does diverge
}
}
}
}
}
function crawlConnSet(&$qls, $objID, $objFace, $objDepth, $objPort, &$connSetID=0, &$connSet=array(array(),array())) {
// Store port details // Store port details
$workingArray = array( $workingArray = array(
@ -27,38 +61,49 @@ function crawlConnSet($objID, $objFace, $objDepth, $objPort, $connSetID=0, $conn
'objPort' => $objPort, 'objPort' => $objPort,
); );
// Verify this node has not been visited already error_log('Debug: '.$objID.'-'.$objFace.'-'.$objDepth.'-'.$objPort);
$alreadySeen = false; error_log('Debug (inventoryArray): '.json_encode($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort]));
foreach($connSet as $conn) {
foreach($conn as $port) {
if($port['objID'] == $objID and $port['objFace'] == $objFace and $port['objDepth'] == $objDepth and $port['objPort'] == $objPort) {
$alreadySeen = true;
}
}
}
// Is local port connected? // Is local port connected?
if(isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort]) and !$alreadySeen) { if(isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) {
// Add port info to connection set // Flip the connection set ID
array_push($connSet[$connSetID], $workingArray); $connSetID = ($connSetID == 0) ? 1 : 0;
error_log('here5');
// Loop over each local port connection // Loop over each local port connection
$inventoryEntry = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort]; $inventoryEntry = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort];
foreach($inventoryEntry as $connection) { foreach($inventoryEntry as $connection) {
error_log('here2');
// Collect remote object data // Collect remote object data
$remoteObjID = $connection['id']; $remoteObjID = $connection['id'];
$remoteObjFace = $connection['face']; $remoteObjFace = $connection['face'];
$remoteObjDepth = $connection['depth']; $remoteObjDepth = $connection['depth'];
$remoteObjPort = $connection['port']; $remoteObjPort = $connection['port'];
// Flip the connection set ID // Verify this node has not been visited already
$connSetID = ($connSetID == 0) ? 1 : 0; $alreadySeen = false;
crawlConnSet($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSetID, $connSet); foreach($connSet as $conn) {
error_log('here3');
foreach($conn as $port) {
error_log('here4');
if($port['objID'] == $remoteObjID and $port['objFace'] == $remoteObjFace and $port['objDepth'] == $remoteObjDepth and $port['objPort'] == $remoteObjPort) {
$alreadySeen = true;
}
}
}
if(!$alreadySeen) {
crawlConnSet($qls, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSetID, $connSet);
}
} }
// Add port info to connection set
error_log('here1');
array_push($connSet[$connSetID], $workingArray);
} }
return $connSet;
} }
?> ?>