From 3a06651ae33083a206fd713b055ec9e2211ec93f Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 26 Jun 2013 14:24:42 +1000 Subject: [PATCH] Add link count and handle screen resize in fake Lakeshores --- .../fakeTempControl/lakeshore/LS336.py | 56 +++++++++++------- .../fakeTempControl/lakeshore/LS340.py | 56 +++++++++++------- .../fakeTempControl/lakeshore/LS370.py | 58 +++++++++++-------- 3 files changed, 102 insertions(+), 68 deletions(-) diff --git a/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS336.py b/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS336.py index c4c5508e..5ced6933 100755 --- a/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS336.py +++ b/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS336.py @@ -52,7 +52,7 @@ class MYDEV(MYBASE): print MYDEV.__name__, "ctor" def device_display(): - global stdscr, myDev, myOpts, myPort + global screen, myDev, myOpts, myPort, myFactory try: myDev.doIteration(); except: @@ -62,33 +62,45 @@ def device_display(): return try: - stdscr.addstr(0, 0, "Random :%8.3f" % myDev.RANDOM) - stdscr.addstr(0, 25, "Identity : %s (%d)" % (myDev.IDN, myPort)) - stdscr.addstr(1, 0, "Sensor :") + rows, cols = screen.stdscr.getmaxyx() + screen.stdscr.addstr(0, 0, "Lnks:%2d" % myFactory.numProtocols) + screen.stdscr.addstr(0, 10, "Rnd:%6.3f" % myDev.RANDOM) + screen.stdscr.addstr(0, 22, "Identity : %s (%d)" % (myDev.IDN, myPort)) + screen.stdscr.addstr(1, 0, "Sensor :") for idx in myDev.CONFIG_SNSRS: - stdscr.addstr(1, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[idx]) - stdscr.addstr(2, 0, "PV :") - stdscr.addstr(3, 0, "Setpoint :") - stdscr.addstr(4, 0, "Diff :") + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(1, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[idx]) + screen.stdscr.addstr(2, 0, "PV :") + screen.stdscr.addstr(3, 0, "Setpoint :") + screen.stdscr.addstr(4, 0, "Diff :") for idx in myDev.CONFIG_LOOPS: - stdscr.addstr(2, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[myDev.LOOPINPUT[idx]]) - stdscr.addstr(3, 12 + (idx - 1) * 12, "%8.3f" % myDev.SETP[idx]) - stdscr.addstr(4, 12 + (idx - 1) * 12, "%8.3f" % (myDev.KRDG[myDev.LOOPINPUT[idx]] - myDev.SETP[idx])) - stdscr.addstr(5, 0, "Target :") - stdscr.addstr(6, 0, "Ramp Rate:") - stdscr.addstr(7, 0, "Ramp On :") - stdscr.addstr(8, 0, "Ramping :") + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(2, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[myDev.LOOPINPUT[idx]]) + screen.stdscr.addstr(3, 12 + (idx - 1) * 12, "%8.3f" % myDev.SETP[idx]) + screen.stdscr.addstr(4, 12 + (idx - 1) * 12, "%8.3f" % (myDev.KRDG[myDev.LOOPINPUT[idx]] - myDev.SETP[idx])) + screen.stdscr.addstr(5, 0, "Target :") + screen.stdscr.addstr(6, 0, "Ramp Rate:") + screen.stdscr.addstr(7, 0, "Ramp On :") + screen.stdscr.addstr(8, 0, "Ramping :") for idx in myDev.CONFIG_RAMPS: - stdscr.addstr(5, 12 + (idx - 1) * 12, "%8.3f" % myDev.TARGET[idx]) - stdscr.addstr(6, 12 + (idx - 1) * 12, "%8.3f" % myDev.RAMP_RATE[idx]) - stdscr.addstr(7, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ON[idx]]) - stdscr.addstr(8, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ST[idx]]) - stdscr.refresh() + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(5, 12 + (idx - 1) * 12, "%8.3f" % myDev.TARGET[idx]) + screen.stdscr.addstr(6, 12 + (idx - 1) * 12, "%8.3f" % myDev.RAMP_RATE[idx]) + screen.stdscr.addstr(7, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ON[idx]]) + screen.stdscr.addstr(8, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ST[idx]]) except: - raise + pass + finally: + try: + screen.stdscr.refresh() + except: + pass if __name__ == "__main__": - global stdscr, myDev, myOpts, myPort + global screen, myDev, myOpts, myPort, myFactory myOpts = MyOptions() try: diff --git a/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS340.py b/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS340.py index b8e2d450..eb5ec23a 100755 --- a/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS340.py +++ b/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS340.py @@ -52,7 +52,7 @@ class MYDEV(MYBASE): print MYDEV.__name__, "ctor" def device_display(): - global stdscr, myDev, myOpts, myPort + global screen, myDev, myOpts, myPort, myFactory try: myDev.doIteration(); except: @@ -62,33 +62,45 @@ def device_display(): return try: - stdscr.addstr(0, 0, "Random :%8.3f" % myDev.RANDOM) - stdscr.addstr(0, 25, "Identity : %s (%d)" % (myDev.IDN, myPort)) - stdscr.addstr(1, 0, "Sensor :") + rows, cols = screen.stdscr.getmaxyx() + screen.stdscr.addstr(0, 0, "Lnks:%2d" % myFactory.numProtocols) + screen.stdscr.addstr(0, 10, "Rnd:%6.3f" % myDev.RANDOM) + screen.stdscr.addstr(0, 22, "Identity : %s (%d)" % (myDev.IDN, myPort)) + screen.stdscr.addstr(1, 0, "Sensor :") for idx in myDev.CONFIG_SNSRS: - stdscr.addstr(1, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[idx]) - stdscr.addstr(2, 0, "PV :") - stdscr.addstr(3, 0, "Setpoint :") - stdscr.addstr(4, 0, "Diff :") + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(1, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[idx]) + screen.stdscr.addstr(2, 0, "PV :") + screen.stdscr.addstr(3, 0, "Setpoint :") + screen.stdscr.addstr(4, 0, "Diff :") for idx in myDev.CONFIG_LOOPS: - stdscr.addstr(2, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[myDev.LOOPINPUT[idx]]) - stdscr.addstr(3, 12 + (idx - 1) * 12, "%8.3f" % myDev.SETP[idx]) - stdscr.addstr(4, 12 + (idx - 1) * 12, "%8.3f" % (myDev.KRDG[myDev.LOOPINPUT[idx]] - myDev.SETP[idx])) - stdscr.addstr(5, 0, "Target :") - stdscr.addstr(6, 0, "Ramp Rate:") - stdscr.addstr(7, 0, "Ramp On :") - stdscr.addstr(8, 0, "Ramping :") + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(2, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[myDev.LOOPINPUT[idx]]) + screen.stdscr.addstr(3, 12 + (idx - 1) * 12, "%8.3f" % myDev.SETP[idx]) + screen.stdscr.addstr(4, 12 + (idx - 1) * 12, "%8.3f" % (myDev.KRDG[myDev.LOOPINPUT[idx]] - myDev.SETP[idx])) + screen.stdscr.addstr(5, 0, "Target :") + screen.stdscr.addstr(6, 0, "Ramp Rate:") + screen.stdscr.addstr(7, 0, "Ramp On :") + screen.stdscr.addstr(8, 0, "Ramping :") for idx in myDev.CONFIG_RAMPS: - stdscr.addstr(5, 12 + (idx - 1) * 12, "%8.3f" % myDev.TARGET[idx]) - stdscr.addstr(6, 12 + (idx - 1) * 12, "%8.3f" % myDev.RAMP_RATE[idx]) - stdscr.addstr(7, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ON[idx]]) - stdscr.addstr(8, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ST[idx]]) - stdscr.refresh() + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(5, 12 + (idx - 1) * 12, "%8.3f" % myDev.TARGET[idx]) + screen.stdscr.addstr(6, 12 + (idx - 1) * 12, "%8.3f" % myDev.RAMP_RATE[idx]) + screen.stdscr.addstr(7, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ON[idx]]) + screen.stdscr.addstr(8, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ST[idx]]) except: - raise + pass + finally: + try: + screen.stdscr.refresh() + except: + pass if __name__ == "__main__": - global stdscr, myDev, myOpts, myPort + global screen, myDev, myOpts, myPort, myFactory myOpts = MyOptions() try: diff --git a/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS370.py b/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS370.py index 9fd43318..b7104c26 100755 --- a/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS370.py +++ b/site_ansto/instrument/TEST_SICS/fakeTempControl/lakeshore/LS370.py @@ -52,7 +52,7 @@ class MYDEV(MYBASE): print MYDEV.__name__, "ctor" def device_display(): - global stdscr, myDev, myOpts, myPort + global screen, myDev, myOpts, myPort, myFactory try: myDev.doIteration(); except: @@ -62,35 +62,45 @@ def device_display(): return try: - stdscr.addstr(0, 0, "Random :%8.3f" % myDev.RANDOM) - stdscr.addstr(0, 25, "Identity : %s (%d)" % (myDev.IDN, myPort)) - stdscr.addstr(1, 0, "Sensor :") + rows, cols = screen.stdscr.getmaxyx() + screen.stdscr.addstr(0, 0, "Lnks:%2d" % myFactory.numProtocols) + screen.stdscr.addstr(0, 10, "Rnd:%6.3f" % myDev.RANDOM) + screen.stdscr.addstr(0, 22, "Identity : %s (%d)" % (myDev.IDN, myPort)) + screen.stdscr.addstr(1, 0, "Sensor :") for idx in myDev.CONFIG_SNSRS: - if idx > 4: - continue - stdscr.addstr(1, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[idx]) - stdscr.addstr(2, 0, "PV :") - stdscr.addstr(3, 0, "Setpoint :") - stdscr.addstr(4, 0, "Diff :") + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(1, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[idx]) + screen.stdscr.addstr(2, 0, "PV :") + screen.stdscr.addstr(3, 0, "Setpoint :") + screen.stdscr.addstr(4, 0, "Diff :") for idx in myDev.CONFIG_LOOPS: - stdscr.addstr(2, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[myDev.LOOPINPUT[idx]]) - stdscr.addstr(3, 12 + (idx - 1) * 12, "%8.3f" % myDev.SETP[idx]) - stdscr.addstr(4, 12 + (idx - 1) * 12, "%8.3f" % (myDev.KRDG[myDev.LOOPINPUT[idx]] - myDev.SETP[idx])) - stdscr.addstr(5, 0, "Target :") - stdscr.addstr(6, 0, "Ramp Rate:") - stdscr.addstr(7, 0, "Ramp On :") - stdscr.addstr(8, 0, "Ramping :") + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(2, 12 + (idx - 1) * 12, "%8.3f" % myDev.KRDG[myDev.LOOPINPUT[idx]]) + screen.stdscr.addstr(3, 12 + (idx - 1) * 12, "%8.3f" % myDev.SETP[idx]) + screen.stdscr.addstr(4, 12 + (idx - 1) * 12, "%8.3f" % (myDev.KRDG[myDev.LOOPINPUT[idx]] - myDev.SETP[idx])) + screen.stdscr.addstr(5, 0, "Target :") + screen.stdscr.addstr(6, 0, "Ramp Rate:") + screen.stdscr.addstr(7, 0, "Ramp On :") + screen.stdscr.addstr(8, 0, "Ramping :") for idx in myDev.CONFIG_RAMPS: - stdscr.addstr(5, 12 + (idx - 1) * 12, "%8.3f" % myDev.TARGET[idx]) - stdscr.addstr(6, 12 + (idx - 1) * 12, "%8.3f" % myDev.RAMP_RATE[idx]) - stdscr.addstr(7, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ON[idx]]) - stdscr.addstr(8, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ST[idx]]) - stdscr.refresh() + if 12 + (idx - 1) * 12 > cols - 1: + break + screen.stdscr.addstr(5, 12 + (idx - 1) * 12, "%8.3f" % myDev.TARGET[idx]) + screen.stdscr.addstr(6, 12 + (idx - 1) * 12, "%8.3f" % myDev.RAMP_RATE[idx]) + screen.stdscr.addstr(7, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ON[idx]]) + screen.stdscr.addstr(8, 12 + (idx - 1) * 12, "%8s" % ["No", "Yes"][myDev.RAMP_ST[idx]]) except: - raise + pass + finally: + try: + screen.stdscr.refresh() + except: + pass if __name__ == "__main__": - global stdscr, myDev, myOpts, myPort + global screen, myDev, myOpts, myPort, myFactory myOpts = MyOptions() try: