Add the name and link count to the fake motors

This commit is contained in:
Douglas Clowes
2013-07-01 13:10:46 +10:00
parent a0bf852024
commit 6287e0ba7f
3 changed files with 40 additions and 14 deletions

View File

@@ -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()