Abfrage dazu, ob die Paarung Sensor und Distributor gefunden wurde
This commit is contained in:
+12
-5
@@ -357,7 +357,10 @@ class Anlage():
|
|||||||
self.add_sensor(sname, pos)
|
self.add_sensor(sname, pos)
|
||||||
|
|
||||||
def get_sensor_point(self, sname:str) -> Point:
|
def get_sensor_point(self, sname:str) -> Point:
|
||||||
|
if sname in self._sensors:
|
||||||
return self._sensors[sname]
|
return self._sensors[sname]
|
||||||
|
raise Exception("Sensor not found")
|
||||||
|
|
||||||
|
|
||||||
def connect_sensors_to_racks(self) -> list:
|
def connect_sensors_to_racks(self) -> list:
|
||||||
'''verbindet die Sensoren mit den Racks.
|
'''verbindet die Sensoren mit den Racks.
|
||||||
@@ -373,7 +376,9 @@ class Anlage():
|
|||||||
self.add_distributor(dname, pos)
|
self.add_distributor(dname, pos)
|
||||||
|
|
||||||
def get_distributor_point(self, dname:str) -> Point:
|
def get_distributor_point(self, dname:str) -> Point:
|
||||||
|
if dname in self._distributors:
|
||||||
return self._distributors[dname]
|
return self._distributors[dname]
|
||||||
|
raise Exception("Distributor not found")
|
||||||
|
|
||||||
def connect_distributor_to_racks(self) -> list:
|
def connect_distributor_to_racks(self) -> list:
|
||||||
'''verbindet die Unterverteiler mit den Racks
|
'''verbindet die Unterverteiler mit den Racks
|
||||||
@@ -406,15 +411,13 @@ class Anlage():
|
|||||||
|
|
||||||
candidates = [self._rack_lines[idx] for idx in candidates]
|
candidates = [self._rack_lines[idx] for idx in candidates]
|
||||||
best_dist = max_dist
|
best_dist = max_dist
|
||||||
|
best_line = candidates[0]
|
||||||
for line in candidates:
|
for line in candidates:
|
||||||
dist = sensor.distance(line)
|
dist = sensor.distance(line)
|
||||||
if dist < best_dist:
|
if dist < best_dist:
|
||||||
best_dist = dist
|
best_dist = dist
|
||||||
best_line = line
|
best_line = line
|
||||||
|
|
||||||
if best_dist > max_dist:
|
|
||||||
raise LookupError("no line in correct distance found")
|
|
||||||
|
|
||||||
rack_name = self._rack_map[best_line]
|
rack_name = self._rack_map[best_line]
|
||||||
nearest_point = best_line.interpolate(best_line.project(sensor))
|
nearest_point = best_line.interpolate(best_line.project(sensor))
|
||||||
return nearest_point, rack_name
|
return nearest_point, rack_name
|
||||||
@@ -603,10 +606,15 @@ class Anlage():
|
|||||||
def create_cable_paths(self, G) -> dict:
|
def create_cable_paths(self, G) -> dict:
|
||||||
pfade = dict()
|
pfade = dict()
|
||||||
pfade["kabel"] = list()
|
pfade["kabel"] = list()
|
||||||
|
pfade["errors"] = list()
|
||||||
for sname, dname in self._sensor2dist.items():
|
for sname, dname in self._sensor2dist.items():
|
||||||
|
try:
|
||||||
pfad_nodes, pfad_length = self.create_cable_path(G, sname, dname)
|
pfad_nodes, pfad_length = self.create_cable_path(G, sname, dname)
|
||||||
|
except:
|
||||||
|
pfade["errors"].append((sname, dname))
|
||||||
|
continue
|
||||||
pfad_coords = self._nodeids.get_points(pfad_nodes)
|
pfad_coords = self._nodeids.get_points(pfad_nodes)
|
||||||
tuplecoords = [(p.x, p.y) for p in pfad_coords]
|
#tuplecoords = [(p.x, p.y) for p in pfad_coords]
|
||||||
ld = dict()
|
ld = dict()
|
||||||
ld['id'] = f"{dname}-{sname}"
|
ld['id'] = f"{dname}-{sname}"
|
||||||
ld["coords"]= [{"x":round(p.x,1), "y":round(p.y,1)} for p in pfad_coords]
|
ld["coords"]= [{"x":round(p.x,1), "y":round(p.y,1)} for p in pfad_coords]
|
||||||
@@ -944,7 +952,6 @@ if __name__ == '__main__':
|
|||||||
suite.addTest(TestPlant('test_add_point_interim'))
|
suite.addTest(TestPlant('test_add_point_interim'))
|
||||||
suite.addTest(TestPlant('test_add_sensor'))
|
suite.addTest(TestPlant('test_add_sensor'))
|
||||||
suite.addTest(TestPlant('test_add_equipment_w_tree'))
|
suite.addTest(TestPlant('test_add_equipment_w_tree'))
|
||||||
suite.addTest(TestPlant('test_add_equipment_w_tree_batch'))
|
|
||||||
suite.addTest(TestPlant('test_wegsuche_str_tree'))
|
suite.addTest(TestPlant('test_wegsuche_str_tree'))
|
||||||
suite.addTest(TestPlant('test_wegsuche_w_tree'))
|
suite.addTest(TestPlant('test_wegsuche_w_tree'))
|
||||||
suite.addTest(TestPlant('test_generate_graph'))
|
suite.addTest(TestPlant('test_generate_graph'))
|
||||||
|
|||||||
Reference in New Issue
Block a user