Add the name and link count to the fake motors
This commit is contained in:
@ -21,7 +21,7 @@ def device_iterator():
|
|||||||
now = time.time()
|
now = time.time()
|
||||||
|
|
||||||
def display_iterator():
|
def display_iterator():
|
||||||
global screen, devices
|
global screen, devices, factories
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rows, cols = screen.stdscr.getmaxyx()
|
rows, cols = screen.stdscr.getmaxyx()
|
||||||
@ -29,14 +29,23 @@ def display_iterator():
|
|||||||
for idx in sorted(devices.keys()):
|
for idx in sorted(devices.keys()):
|
||||||
line = 0;
|
line = 0;
|
||||||
col += 1
|
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()):
|
for mtr in sorted(devices[idx].motors.keys()):
|
||||||
line += 1
|
screen.stdscr.addstr(line, 0, "%1s:" % mtr)
|
||||||
screen.stdscr.addstr(line, 13 * (col - 1), "%1s:%8.3f" % (mtr, devices[idx].motors[mtr].getPosition()))
|
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"):
|
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:
|
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:
|
except:
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
@ -67,7 +76,7 @@ class MyScreen(Screen):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def main(**kwargs):
|
def main(**kwargs):
|
||||||
global screen, devices
|
global screen, devices, factories
|
||||||
parser = argparse.ArgumentParser( description="Generates fake Galil controllers for testing SICS" )
|
parser = argparse.ArgumentParser( description="Generates fake Galil controllers for testing SICS" )
|
||||||
parser.add_argument("instrument", help="The instrument name")
|
parser.add_argument("instrument", help="The instrument name")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -79,11 +88,13 @@ def main(**kwargs):
|
|||||||
#log.startLogging(sys.stdout)
|
#log.startLogging(sys.stdout)
|
||||||
log.startLogging(open(("/tmp/Fake_Galil_%d.log" % basePort[args.instrument]), "w"))
|
log.startLogging(open(("/tmp/Fake_Galil_%d.log" % basePort[args.instrument]), "w"))
|
||||||
devices = {}
|
devices = {}
|
||||||
|
factories = {}
|
||||||
for dev in range(0, 6):
|
for dev in range(0, 6):
|
||||||
port = basePort[args.instrument] + dev
|
port = basePort[args.instrument] + dev
|
||||||
controllerName = "mc%d" % (dev + 1)
|
controllerName = "mc%d" % (dev + 1)
|
||||||
factory = GalilFactory(port)
|
factory = GalilFactory(port)
|
||||||
devices[controllerName] = factory.device
|
devices[controllerName] = factory.device
|
||||||
|
factories[controllerName] = factory
|
||||||
reactor.listenTCP(port, factory)
|
reactor.listenTCP(port, factory)
|
||||||
|
|
||||||
stdscr = curses.initscr()
|
stdscr = curses.initscr()
|
||||||
|
@ -57,7 +57,7 @@ def device_iterator():
|
|||||||
s2.doIteration(now)
|
s2.doIteration(now)
|
||||||
|
|
||||||
def display_iterator():
|
def display_iterator():
|
||||||
global screen, devices
|
global screen, devices, factories
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rows, cols = screen.stdscr.getmaxyx()
|
rows, cols = screen.stdscr.getmaxyx()
|
||||||
@ -65,14 +65,23 @@ def display_iterator():
|
|||||||
for idx in sorted(devices.keys()):
|
for idx in sorted(devices.keys()):
|
||||||
line = 0;
|
line = 0;
|
||||||
col += 1
|
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()):
|
for mtr in sorted(devices[idx].motors.keys()):
|
||||||
line += 1
|
screen.stdscr.addstr(line, 0, "%1s:" % mtr)
|
||||||
screen.stdscr.addstr(line, 13 * (col - 1), "%1s:%8.3f" % (mtr, devices[idx].motors[mtr].getPosition()))
|
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"):
|
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:
|
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:
|
except:
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
@ -103,7 +112,7 @@ class MyScreen(Screen):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
global screen, devices
|
global screen, devices, factories
|
||||||
|
|
||||||
basePort = 62034 # Echidna
|
basePort = 62034 # Echidna
|
||||||
basePort = 62134 # Wombat
|
basePort = 62134 # Wombat
|
||||||
@ -119,11 +128,13 @@ if __name__ == "__main__":
|
|||||||
nickel = CubicPowderSample()
|
nickel = CubicPowderSample()
|
||||||
|
|
||||||
devices = {}
|
devices = {}
|
||||||
|
factories = {}
|
||||||
for dev in range(0, 6):
|
for dev in range(0, 6):
|
||||||
port = basePort + dev
|
port = basePort + dev
|
||||||
controllerName = "mc%d" % (dev + 1)
|
controllerName = "mc%d" % (dev + 1)
|
||||||
factory = GalilFactory(port)
|
factory = GalilFactory(port)
|
||||||
devices[controllerName] = factory.device
|
devices[controllerName] = factory.device
|
||||||
|
factories[controllerName] = factory
|
||||||
reactor.listenTCP(port, factory)
|
reactor.listenTCP(port, factory)
|
||||||
|
|
||||||
s2 = devices["mc2"].motors["F"]
|
s2 = devices["mc2"].motors["F"]
|
||||||
|
@ -10,6 +10,7 @@ class GalilMotor(object):
|
|||||||
|
|
||||||
def __init__(self, theAxis):
|
def __init__(self, theAxis):
|
||||||
print "GalilMotor ctor: %s" % theAxis
|
print "GalilMotor ctor: %s" % theAxis
|
||||||
|
self.name = None
|
||||||
self.axis = theAxis
|
self.axis = theAxis
|
||||||
self.motorState = "OFF"
|
self.motorState = "OFF"
|
||||||
self.stepsPerX = 25000.0
|
self.stepsPerX = 25000.0
|
||||||
@ -76,6 +77,9 @@ class GalilMotor(object):
|
|||||||
self.hasAbsEnc = False
|
self.hasAbsEnc = False
|
||||||
self.motorHome = float(rh)
|
self.motorHome = float(rh)
|
||||||
self.configDone = True
|
self.configDone = True
|
||||||
|
elif lh == "NAM":
|
||||||
|
self.name = rh[1:-1]
|
||||||
|
self.configDone = True
|
||||||
else:
|
else:
|
||||||
print "Unrecognized config item \"%s\" in \"%s\"" % (lh, arg)
|
print "Unrecognized config item \"%s\" in \"%s\"" % (lh, arg)
|
||||||
if self.configDone and not configDoneAlready:
|
if self.configDone and not configDoneAlready:
|
||||||
|
Reference in New Issue
Block a user