|
|
|
@ -5,6 +5,7 @@ using CriticalPathAnalyzer.Shared.Packets.S2C;
|
|
|
|
|
using EccsLogicWorldAPI.Server;
|
|
|
|
|
using EccsLogicWorldAPI.Shared.AccessHelper;
|
|
|
|
|
using LogicAPI.Data;
|
|
|
|
|
using LogicAPI.Server.Components;
|
|
|
|
|
using LogicAPI.Services;
|
|
|
|
|
using LogicWorld.Server.Circuitry;
|
|
|
|
|
|
|
|
|
@ -43,6 +44,8 @@ namespace CriticalPathAnalyzer.Server {
|
|
|
|
|
) {
|
|
|
|
|
response = null;
|
|
|
|
|
|
|
|
|
|
var clusterTime = new Dictionary<Cluster, int>();
|
|
|
|
|
|
|
|
|
|
CriticalPathAnalyzerServer.LoggerInstance.Info("Trace start");
|
|
|
|
|
|
|
|
|
|
// Validate, that the peg is actually existing:
|
|
|
|
@ -54,10 +57,9 @@ namespace CriticalPathAnalyzer.Server {
|
|
|
|
|
// An input peg, only has a single cluster.
|
|
|
|
|
// An output peg however can be connected to multiple clusters.
|
|
|
|
|
// It only makes sense to then select all these clusters as primary cluster.
|
|
|
|
|
if (!CollectMainClusters(start, out HashSet<Cluster> collectedClusters)) {
|
|
|
|
|
return false; // Whoops, cannot collect the primary clusters, probably probing an output peg.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var collectedClusters = new HashSet<Cluster>();
|
|
|
|
|
CollectMainClusters(start, collectedClusters);
|
|
|
|
|
|
|
|
|
|
CriticalPathAnalyzerServer.LoggerInstance.Info("collected main clusters");
|
|
|
|
|
|
|
|
|
|
// Collect clusters that get powered by the original cluster by fast buffers
|
|
|
|
@ -65,31 +67,38 @@ namespace CriticalPathAnalyzer.Server {
|
|
|
|
|
foreach (Cluster cluster in collectedClusters) {
|
|
|
|
|
GetLinkedClusters(cluster, collectedDrains, GetFollowers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
collectedClusters.UnionWith(collectedDrains);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CriticalPathAnalyzerServer.LoggerInstance.Info("collected linked clusters");
|
|
|
|
|
|
|
|
|
|
var perimeterComponents = new HashSet<ComponentAddress>();
|
|
|
|
|
var collectedNextClusters = new HashSet<Cluster>();
|
|
|
|
|
foreach (Cluster cluster in collectedClusters) {
|
|
|
|
|
foreach (InputPeg inputPeg in cluster.ConnectedInputs) {
|
|
|
|
|
if (inputPeg.LogicComponent == null) {
|
|
|
|
|
// These are regular pegs, they are not attached to any logic component, skip them
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
perimeterComponents.Add(inputPeg.LogicComponent.Address);
|
|
|
|
|
|
|
|
|
|
foreach (IOutputPeg outputPeg in inputPeg.LogicComponent.Outputs) {
|
|
|
|
|
CollectMainClusters(outputPeg.Address, collectedNextClusters);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CriticalPathAnalyzerServer.LoggerInstance.Info("collected perimeter components");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Collect information about each cluster:
|
|
|
|
|
response = new AnalyzePathResponse() {
|
|
|
|
|
RequestGuid = requestGuid,
|
|
|
|
|
Clusters = collectedClusters.Select(CollectClusterInformation).ToList(),
|
|
|
|
|
PerimeterComponents = perimeterComponents.ToList()
|
|
|
|
|
PerimeterComponents = perimeterComponents.ToList(),
|
|
|
|
|
NextClusters = collectedNextClusters.Select(CollectClusterInformation).ToList(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CriticalPathAnalyzerServer.LoggerInstance.Info("Trace end");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
@ -128,14 +137,13 @@ namespace CriticalPathAnalyzer.Server {
|
|
|
|
|
return linker != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool CollectMainClusters(PegAddress pegAddress, out HashSet<Cluster> primaryClusters) {
|
|
|
|
|
primaryClusters = new HashSet<Cluster>();
|
|
|
|
|
private static void CollectMainClusters(PegAddress pegAddress, HashSet<Cluster> primaryClusters) {
|
|
|
|
|
if (pegAddress.IsInputAddress(out InputAddress inputAddress)) {
|
|
|
|
|
primaryClusters.Add(GetClusterAt(inputAddress));
|
|
|
|
|
} else {
|
|
|
|
|
HashSet<WireAddress> wires = World.LookupPegWires(pegAddress);
|
|
|
|
|
if (wires == null) {
|
|
|
|
|
return true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (WireAddress wireAddress in wires) {
|
|
|
|
@ -146,15 +154,13 @@ namespace CriticalPathAnalyzer.Server {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PegAddress otherSide = wire.Point1 == pegAddress ? wire.Point2 : wire.Point1;
|
|
|
|
|
if (!otherSide.IsInputAddress(out var otherSideInputAddress)) {
|
|
|
|
|
continue; //Not supported, this wire would be invalid anyway.
|
|
|
|
|
if (!otherSide.IsInputAddress(out InputAddress otherSideInputAddress)) {
|
|
|
|
|
continue; // Not supported, this wire would be invalid anyway.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
primaryClusters.Add(GetClusterAt(otherSideInputAddress));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void GetLinkedClusters(
|
|
|
|
|