From 10ec878664c5b4959a43e75cedcdb899e76090d0 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 5 Jan 2024 19:23:58 +0100 Subject: [PATCH] WIP --- run_measurements.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/run_measurements.py b/run_measurements.py index b516b3c..437a693 100644 --- a/run_measurements.py +++ b/run_measurements.py @@ -73,15 +73,17 @@ class LXIWrapper: def create_schedule(off_x, off_y): for h in [1.0, 1.5, 2.0, 3.0, 5.0, 10.0, 15.0, 20.0, 30.0]: - for rn, angles in [(range(0, 20, 2), range(0, 360, 15)), - (range(20, 40, 5), range(0, 360, 90)), - (range(40, 60, 10), range(0, 360, 90))]: + for rn in [range(0, 20, 2), range(20, 40, 5), range(40, 60, 10)]: rn = list(rn) for p, q in [(1, 1), (1, -1), (-1, 1), (-1, -1)]: for dx in rn: for dy in rn: for a in angles: - yield off_x+p*dx, off_y+q*dy, a, h + yield off_x+p*dx, off_y+q*dy, 0.0, h + + for a in range(0, 360, 5): + for dy in rn: + yield off_x, off_y+dy, a, h def print_scan(ctx, param, value): @@ -112,12 +114,24 @@ def comma_range(ctx, param, value): class Octoprint: def __init__(self, ip): self.ip = ip + requests.post(f'http://{self.ip}/api/connection', json={ + 'command': 'connect', + }) def home(self): - pass + requests.post(f'http://{self.ip}/api/printer/printhead', json={ + 'command': 'home', + }) def move(self, x, y, z): - pass + requests.post(f'http://{self.ip}/api/printer/printhead', json={ + 'command': 'jog', + 'x': x, + 'y': y, + 'z': z, + 'absolute': True, + 'speed': 20, + }) class Servo: @@ -130,15 +144,15 @@ class Servo: @click.command() @click.option('--scan', is_flag=True, callback=print_scan, expose_value=False, is_eager=True) -@click.option('--tile', type=int, help='Tile number of current measurement') @click.option('-x', type=float, default=0, help='Tile zero X coordinate (mm)') @click.option('-y', type=float, default=0, help='Tile zero Y coordinate (mm)') @click.option('--comment', help='Add comment to measurement run') @click.option('--database', type=click.Path(dir_okay=False, path_type=Path), default='tile_measurements.sqlite3') -@click.option('--voltage', help='IP of voltage measurement multimeter') -@click.option('--current', help='IP of current measurement multimeter') -@click.option('--octoprint', help='IP of octoprint instance') -@click.option('--servo', help='IP of servo control board') +@click.option('--tile', type=int, required=True, help='Tile number of current measurement') +@click.option('--voltage', required=True, help='IP of voltage measurement multimeter') +@click.option('--current', required=True, help='IP of current measurement multimeter') +@click.option('--octoprint', required=True, help='IP of octoprint instance') +@click.option('--servo', required=True, help='IP of servo control board') def cli(voltage, current, octoprint, servo, tile, x, y, comment, database): db = sqlite3.connect(database) db.execute('CREATE TABLE IF NOT EXISTS runs (start_time TEXT DEFAULT CURRENT_TIMESTAMP, end_time TEXT DEFAULT NULL, run_id INTEGER PRIMARY KEY, tile INTEGER, x REAL, y REAL, comment TEXT)')