getpositions schreibt nur noch eine json Ergebnisdatei raus. Config launch.json und routing.py angepasst; in Requirements networkx aufgenommen.
This commit is contained in:
+10
-2
@@ -170,6 +170,7 @@ if __name__ == '__main__':
|
||||
parser.add_argument('-s', '--sensors', action='store_true', help='fetch all position of sensors, motors, actors')
|
||||
parser.add_argument('-d', '--dists', action='store_true', help='fetch all positions of all subdistributors')
|
||||
parser.add_argument('-r', '--rack', action='store_true', help='fetch all positions of all cable racks')
|
||||
parser.add_argument('-w', '--write', action='store_true', help='write results into a json file')
|
||||
parser.add_argument('-c', '--console', action='store_true', help='print results to output')
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -179,7 +180,8 @@ if __name__ == '__main__':
|
||||
config_dir = os.environ.get("PROJECT_CFG")
|
||||
filename = args.filename
|
||||
|
||||
doc = get_dxf_file(os.path.join(work_dir, filename)) # type: ignore
|
||||
dxf_path = os.path.join(work_dir, filename)
|
||||
doc = get_dxf_file(dxf_path) # type: ignore
|
||||
msp = doc.modelspace()
|
||||
|
||||
res_pos = dict()
|
||||
@@ -190,21 +192,27 @@ if __name__ == '__main__':
|
||||
config = configparser.ConfigParser(allow_no_value=True)
|
||||
config.read(os.path.join(config_dir, "getpositions.cfg"))
|
||||
|
||||
output_results = dict()
|
||||
if args.sensors:
|
||||
res_pos = get_input_positions(msp)
|
||||
output_results['sensors'] = res_pos
|
||||
if args.console:
|
||||
print(to_json(res_pos))
|
||||
write_results(to_json(res_pos), work_dir, "sensors.json")
|
||||
if args.dists:
|
||||
res_dist = get_subdistributor_positions(msp)
|
||||
output_results['distributors'] = res_dist
|
||||
if args.console:
|
||||
print(to_json(res_dist))
|
||||
write_results(to_json(res_dist), work_dir, "subdistributors.json")
|
||||
if args.rack:
|
||||
res_rac = get_rack_positions(msp)
|
||||
output_results['racks'] = res_rac
|
||||
if args.console:
|
||||
print(to_json(res_rac))
|
||||
write_results(to_json(res_rac), work_dir, "racks.json")
|
||||
if args.write:
|
||||
basename = os.path.splitext(args.filename)[0]
|
||||
write_results(to_json(output_results), work_dir, basename+"_positions.json")
|
||||
|
||||
else:
|
||||
parser.print_help()
|
||||
|
||||
Reference in New Issue
Block a user