diff --git a/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL.py b/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL.py index 3ec73f0c..1bac84de 100755 --- a/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL.py +++ b/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL.py @@ -21,7 +21,7 @@ def device_iterator(): now = time.time() def display_iterator(): - global screen, devices + global screen, devices, factories try: rows, cols = screen.stdscr.getmaxyx() @@ -29,14 +29,23 @@ def display_iterator(): for idx in sorted(devices.keys()): line = 0; col += 1 - screen.stdscr.addstr(line, 13 * (col - 1), idx) + screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%8s=%d" % (idx, factories[idx].numProtocols)) + line = 1 for mtr in sorted(devices[idx].motors.keys()): - line += 1 - screen.stdscr.addstr(line, 13 * (col - 1), "%1s:%8.3f" % (mtr, devices[idx].motors[mtr].getPosition())) + screen.stdscr.addstr(line, 0, "%1s:" % mtr) + try: + name = devices[idx].motors[mtr].name + if len(name) > 12: + name = name[:12] + screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%12s" % name.rjust(12), curses.A_DIM) + except: + screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%12s" % "") + value = "%12.3f" % devices[idx].motors[mtr].getPosition() if (devices[idx].motors[mtr].motorState == "OFF"): - screen.stdscr.addstr(line, 13 * (col - 1) + 10, " ") + screen.stdscr.addstr(line + 1, 13 * (col - 1) + 2, "%s " % value, curses.A_BOLD) else: - screen.stdscr.addstr(line, 13 * (col - 1) + 10, "*") + screen.stdscr.addstr(line + 1, 13 * (col - 1) + 2, "%s*" % value, curses.A_STANDOUT) + line += 2 except: raise finally: @@ -67,7 +76,7 @@ class MyScreen(Screen): pass def main(**kwargs): - global screen, devices + global screen, devices, factories parser = argparse.ArgumentParser( description="Generates fake Galil controllers for testing SICS" ) parser.add_argument("instrument", help="The instrument name") args = parser.parse_args() @@ -79,11 +88,13 @@ def main(**kwargs): #log.startLogging(sys.stdout) log.startLogging(open(("/tmp/Fake_Galil_%d.log" % basePort[args.instrument]), "w")) devices = {} + factories = {} for dev in range(0, 6): port = basePort[args.instrument] + dev controllerName = "mc%d" % (dev + 1) factory = GalilFactory(port) devices[controllerName] = factory.device + factories[controllerName] = factory reactor.listenTCP(port, factory) stdscr = curses.initscr() diff --git a/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL_taipan.py b/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL_taipan.py index 8e1f268f..e602ee31 100755 --- a/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL_taipan.py +++ b/site_ansto/instrument/TEST_SICS/fakeGalil/SIM_GALIL_taipan.py @@ -57,7 +57,7 @@ def device_iterator(): s2.doIteration(now) def display_iterator(): - global screen, devices + global screen, devices, factories try: rows, cols = screen.stdscr.getmaxyx() @@ -65,14 +65,23 @@ def display_iterator(): for idx in sorted(devices.keys()): line = 0; col += 1 - screen.stdscr.addstr(line, 13 * (col - 1), idx) + screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%8s=%d" % (idx, factories[idx].numProtocols)) + line = 1 for mtr in sorted(devices[idx].motors.keys()): - line += 1 - screen.stdscr.addstr(line, 13 * (col - 1), "%1s:%8.3f" % (mtr, devices[idx].motors[mtr].getPosition())) + screen.stdscr.addstr(line, 0, "%1s:" % mtr) + try: + name = devices[idx].motors[mtr].name + if len(name) > 12: + name = name[:12] + screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%12s" % name.rjust(12), curses.A_DIM) + except: + screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%12s" % "") + value = "%12.3f" % devices[idx].motors[mtr].getPosition() if (devices[idx].motors[mtr].motorState == "OFF"): - screen.stdscr.addstr(line, 13 * (col - 1) + 10, " ") + screen.stdscr.addstr(line + 1, 13 * (col - 1) + 2, "%s " % value, curses.A_BOLD) else: - screen.stdscr.addstr(line, 13 * (col - 1) + 10, "*") + screen.stdscr.addstr(line + 1, 13 * (col - 1) + 2, "%s*" % value, curses.A_STANDOUT) + line += 2 except: raise finally: @@ -103,7 +112,7 @@ class MyScreen(Screen): pass if __name__ == "__main__": - global screen, devices + global screen, devices, factories basePort = 62034 # Echidna basePort = 62134 # Wombat @@ -119,11 +128,13 @@ if __name__ == "__main__": nickel = CubicPowderSample() devices = {} + factories = {} for dev in range(0, 6): port = basePort + dev controllerName = "mc%d" % (dev + 1) factory = GalilFactory(port) devices[controllerName] = factory.device + factories[controllerName] = factory reactor.listenTCP(port, factory) s2 = devices["mc2"].motors["F"] diff --git a/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py b/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py index 5d9fc5e8..c4b3eb37 100644 --- a/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py +++ b/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py @@ -10,6 +10,7 @@ class GalilMotor(object): def __init__(self, theAxis): print "GalilMotor ctor: %s" % theAxis + self.name = None self.axis = theAxis self.motorState = "OFF" self.stepsPerX = 25000.0 @@ -76,6 +77,9 @@ class GalilMotor(object): self.hasAbsEnc = False self.motorHome = float(rh) self.configDone = True + elif lh == "NAM": + self.name = rh[1:-1] + self.configDone = True else: print "Unrecognized config item \"%s\" in \"%s\"" % (lh, arg) if self.configDone and not configDoneAlready: