Toleranz Schritte entfernt, da nicht mehr benötigt. Errors_routing umbenannt. Weitere Kleinigkeiten im kommentierungen, etc.
This commit is contained in:
+14
-16
@@ -81,12 +81,12 @@ class NodeIDs():
|
||||
|
||||
def get_id(self, point:Point) -> int:
|
||||
if f"{point.x} {point.y}" not in self._cord2id:
|
||||
raise Exception(f"Punkt nicht vorhanden!, {point.x},{point.y}")
|
||||
raise Exception(f"Point not found!, {point.x},{point.y}")
|
||||
return self._cord2id[f"{point.x} {point.y}"]
|
||||
|
||||
def get_point(self, nid:int) -> Point:
|
||||
if nid not in self._id2cord:
|
||||
raise Exception(f"NodeID nicht vorhanden! {nid}")
|
||||
raise Exception(f"NodeID nnot found! {nid}")
|
||||
return self._id2cord[nid]
|
||||
|
||||
def get_ids(self, points:list[Point]) -> list[int]:
|
||||
@@ -279,7 +279,7 @@ class Anlage():
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, tol_snap=200.0, snap_step=10.0, tol_connect=5000.0, tol_connect_step=50.0):
|
||||
def __init__(self, tol_snap=200.0, tol_connect=5000.0):
|
||||
# Container für alle Racks
|
||||
self._racks = RackIDs(tol_snap=tol_snap)
|
||||
# zuordnung zwischen KnotenID und Punkt
|
||||
@@ -298,10 +298,8 @@ class Anlage():
|
||||
self._sensor2dist = dict()
|
||||
# Toleranzen zur Rack anbindung aneinander (Rack Snap)
|
||||
self._tol_snap = tol_snap
|
||||
self._snap_step = snap_step
|
||||
# Toleranzen zur Anbindung von Sensoren / Verteilern zu Racks
|
||||
self._tol_connect = tol_connect
|
||||
self._connect_step = tol_connect_step
|
||||
# Infos zum zeichnen des Graphen
|
||||
self._node_positions = dict()
|
||||
|
||||
@@ -412,7 +410,7 @@ class Anlage():
|
||||
def get_tunnel_length(self, tname: str):
|
||||
if tname in self._tunnels:
|
||||
return float(self._tunnel_lengths[tname])
|
||||
raise Exception("Tunnel not found")
|
||||
raise Exception("Tunnel-Length not found")
|
||||
|
||||
def add_tunnels(self, tunnels:dict):
|
||||
for tname,pos in tunnels.items():
|
||||
@@ -454,11 +452,11 @@ class Anlage():
|
||||
def join_racks(self):
|
||||
self._racks.join_racks_str()
|
||||
|
||||
def find_nearest_rack_from_point_STR_bbox(self, max_dist, sensor:Point) -> tuple[Point, str]:
|
||||
def find_nearest_rack_from_point_STR_bbox(self, max_dist, pt:Point) -> tuple[Point, str]:
|
||||
if self._racks._rack_tree is None:
|
||||
self._racks._build_rack_strtree()
|
||||
|
||||
minx, miny, maxx, maxy = sensor.x - max_dist, sensor.y - max_dist, sensor.x + max_dist, sensor.y + max_dist
|
||||
minx, miny, maxx, maxy = pt.x - max_dist, pt.y - max_dist, pt.x + max_dist, pt.y + max_dist
|
||||
bbox = box(minx, miny, maxx, maxy)
|
||||
|
||||
candidates = self._racks._rack_tree.query(bbox)
|
||||
@@ -469,19 +467,19 @@ class Anlage():
|
||||
best_dist = max_dist
|
||||
best_line = candidates[0]
|
||||
for line in candidates:
|
||||
dist = sensor.distance(line)
|
||||
dist = pt.distance(line)
|
||||
if dist < best_dist:
|
||||
best_dist = dist
|
||||
best_line = line
|
||||
|
||||
rack_name = self._racks._rack_map[best_line]
|
||||
nearest_point = best_line.interpolate(best_line.project(sensor))
|
||||
nearest_point = best_line.interpolate(best_line.project(pt))
|
||||
return nearest_point, rack_name
|
||||
|
||||
def connect_equipment_to_racks(self, equipment: dict, onpoints: dict) -> list:
|
||||
'''Verbindet Peripherie (Sensoren / Aktoren/ Unterverteiler) mit dem nächsten Rack.
|
||||
Eingabe: Dict des Equipments (Sensoren o. Dists), Dict der Aufpunkte von Sensoren o. Dists
|
||||
Rückgabe: Liste der nicht zugeordneten Geräte
|
||||
'''Verbindet Peripherie (Sensoren / Aktoren / Unterverteiler) mit dem nächsten Rack.
|
||||
Eingabe: Dict des Equipments ({'Name': Point}), Dict der Aufpunkte von Sensoren o. Dists (zu Beginn leer)
|
||||
Rückgabe: Liste der nicht mit Racks verbundenen Geräte (z.B. Entfernung zu groß)
|
||||
'''
|
||||
errors = []
|
||||
for name, pos in equipment.items():
|
||||
@@ -489,7 +487,7 @@ class Anlage():
|
||||
onpoint, rackname = self.find_nearest_rack_from_point_STR_bbox(self._tol_connect, pos)
|
||||
onpoints[name] = (onpoint, rackname)
|
||||
except LookupError:
|
||||
errors.append((name, pos))
|
||||
errors.append((name, (pos.x, pos.y))) # Name des fehlgeschlagenenen und Position als Koodinaten zurückgeben
|
||||
continue
|
||||
self.add_point_to_rack(onpoint, rackname)
|
||||
|
||||
@@ -584,12 +582,12 @@ class Anlage():
|
||||
def create_cable_paths(self, G) -> dict:
|
||||
pfade = dict()
|
||||
pfade["kabel"] = list()
|
||||
pfade["errors"] = list()
|
||||
pfade["errors_routing"] = list() # Fehler Liste für fehlgeschlagene Kabelverbindungen
|
||||
for sname, dname in self._sensor2dist.items():
|
||||
try:
|
||||
pfad_nodes, pfad_length = self.create_cable_path(G, sname, dname)
|
||||
except:
|
||||
pfade["errors"].append((sname, dname))
|
||||
pfade["errors_routing"].append((sname, dname))
|
||||
continue
|
||||
pfad_coords = self._nodeids.get_points(pfad_nodes)
|
||||
#tuplecoords = [(p.x, p.y) for p in pfad_coords]
|
||||
|
||||
Reference in New Issue
Block a user