From ba6988ebf34e6a343db8b66988fecd45f529fbdb Mon Sep 17 00:00:00 2001 From: Matsumoto Takao Date: Tue, 19 Aug 2014 23:14:57 +0900 Subject: [PATCH 1/7] =?UTF-8?q?vacuummonitor=E3=81=AEinterface=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E4=BD=9C=E6=88=90=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pymeasure/device/__init__.py | 1 + .../device/signalgenerator/signalgenerator.py | 2 +- pymeasure/device/vacuum_monitor/__init__.py | 0 .../device/vacuum_monitor/vacuum_monitor.py | 35 ------------------- test/test_devices.py | 8 +++++ 5 files changed, 10 insertions(+), 36 deletions(-) delete mode 100644 pymeasure/device/vacuum_monitor/__init__.py delete mode 100644 pymeasure/device/vacuum_monitor/vacuum_monitor.py diff --git a/pymeasure/device/__init__.py b/pymeasure/device/__init__.py index b38c24c..a686914 100644 --- a/pymeasure/device/__init__.py +++ b/pymeasure/device/__init__.py @@ -4,6 +4,7 @@ import signalgenerator import powermeter import spectrumanalyzer +import vacuummonitor diff --git a/pymeasure/device/signalgenerator/signalgenerator.py b/pymeasure/device/signalgenerator/signalgenerator.py index 6f4149d..e4ef6fc 100644 --- a/pymeasure/device/signalgenerator/signalgenerator.py +++ b/pymeasure/device/signalgenerator/signalgenerator.py @@ -91,7 +91,7 @@ def preset(self): def self_test(self, interval=0.2): wait = lambda: time.sleep(interval) - print('self_tset :: signalgenerator') + print('self_test :: signalgenerator') print('============================') print('model: %s'%(self.model)) print('communicator: %s'%(self.com.method)) diff --git a/pymeasure/device/vacuum_monitor/__init__.py b/pymeasure/device/vacuum_monitor/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pymeasure/device/vacuum_monitor/vacuum_monitor.py b/pymeasure/device/vacuum_monitor/vacuum_monitor.py deleted file mode 100644 index ce3c446..0000000 --- a/pymeasure/device/vacuum_monitor/vacuum_monitor.py +++ /dev/null @@ -1,35 +0,0 @@ -#! /usr/bin/env python -# coding=utf-8 - -import os.path -import sys -sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),'../')) - -import device - -class vacuum_monitor(device.device): - api = {'pressure_get': ''} - pressure = None - - def pressure_get(self): - - self.pressure = self._pressure_get() - return self.pressure - - def _pressure_get(self): - - self.com.open() - self.com.send('%s¥n'%(self.api['pressure_get'])) - pressure = float(self.com.readline()) - self.com.close() - return pressure - - -class dummy(vacuum_monitor): - pressure = None - - def _pressure_get(self): - self.com.open() - self.com.send('%s¥n'%(self.api['pressure_get'])) - self.com.close() - return self.pressure diff --git a/test/test_devices.py b/test/test_devices.py index c7fed00..4e86656 100644 --- a/test/test_devices.py +++ b/test/test_devices.py @@ -30,4 +30,12 @@ def port_generate(index): sa.self_test(0.05) sa.server_stop() +# vacuummonitor +# ========== +com_vm = pymeasure.socket_communicator('127.0.0.1', port_generate(3)) +vm = pymeasure.vacuummonitor.dummy(com_vm) +vm.self_test(0.05) +vm.server_stop() + + From 8f232d170ce15b499a786a8a5cacb9f30281dba3 Mon Sep 17 00:00:00 2001 From: Matsumoto Takao Date: Wed, 20 Aug 2014 18:11:00 +0900 Subject: [PATCH 2/7] =?UTF-8?q?vacuummonitor.py=E3=82=92=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pymeasure/device/vacuummonitor/__init__.py | 4 + .../device/vacuummonitor/vacuummonitor.py | 165 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 pymeasure/device/vacuummonitor/__init__.py create mode 100644 pymeasure/device/vacuummonitor/vacuummonitor.py diff --git a/pymeasure/device/vacuummonitor/__init__.py b/pymeasure/device/vacuummonitor/__init__.py new file mode 100644 index 0000000..097b724 --- /dev/null +++ b/pymeasure/device/vacuummonitor/__init__.py @@ -0,0 +1,4 @@ + +# pymeasure/device/vacuummonitor + +from vacuummonitor import dummy_client as dummy \ No newline at end of file diff --git a/pymeasure/device/vacuummonitor/vacuummonitor.py b/pymeasure/device/vacuummonitor/vacuummonitor.py new file mode 100644 index 0000000..dae1f44 --- /dev/null +++ b/pymeasure/device/vacuummonitor/vacuummonitor.py @@ -0,0 +1,165 @@ +#! /usr/bin/env python +# coding=utf-8 + +import os +import sys +import time +import threading +import socket + +from .. import device + +# ====================== +# Interface Class +# ====================== + +class vacuummonitor(device.device): + #property configuration + # ===================== + pressure = None + + + # constructor + # ============ + def __init__(self, com=None): + device.device.__init__(self, com) + self.press_get() + self.model_check() + pass + + #Interface method + # =============== + def press_get(self): + """ + """ + self.press = self._press_get() + return self.press + + def model_check(self): + self.model = self._model_check() + return + + + + # self test + # ========= + def self_test(self, interval=0.2): + wait = lambda: time.sleep(interval) + + print('self_test :: vacuummonitor') + print('==========================') + print('model: %s'%(self.model)) + print('communicator: %s'%(self.com.method)) + print('--------------------------') + + print('') + print('test start') + print('----------') + print('press_get()') + try: + ret = self.press_get() + if type(ret)!=float: print('!! Bad !!, return in not float') + else: print('OK, %f'%ret) + except: + err = sys.exc_info() + print('!! Error !!, %s, %s'%(err[0].__name__, err[1])) + pass + + wait() + + print('test end') + print('') + return + + + # internal method + # =============== + + def _press_get(self): + return float() + + def _model_check(self): + return str() + + + +# ==================== +# Dummy Server/Client +# ==================== +dummy_api = {'press_get': 'dummy_vm:press_get'} + +# dummy client +# ============ +class dummy_client(vacuummonitor): + def __init__(self, com): + self.server = dummy_server(com.port) + time.sleep(0.05) + vacuummonitor.__init__(self, com) + pass + + def server_stop(self): + self.com.open() + self.com.send('stop\n') + self.com.close() + return + + def _press_get(self): + self.com.open() + self.com.send('%s\n'%(dummy_api['press_get'])) + press = float(self.com.readline()) + self.com.close() + return press + + def _model_check(self): + return 'VacuumMonitor_Dummy' + + + +# dummy server +# ============ +class dummy_server(object): + press = 0 + + def __init__(self, port): + self.port = port + self.start() + pass + + def start(self): + threading.Thread(target=self._start).start() + return + + def _start(self): + server = socket.socket() + server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server.bind(('127.0.0.1', self.port)) + server.listen(1) + + + + while True: + client, client_address = server.accept() + self.client = client + + while True: + data = client.recv(8192) + if len(data)==0: break + if data=='stop\n': return + command =data.strip().split(' ')[0] + params = data.strip().split(' ')[1:] + self.handle(command, params) + continue + + client.close() + continue + return + + def handle(self, command, params): + if command==dummy_api['press_get']: self.press_get(params) + else: print(command, params) + return + + def press_get(self, params): + self.client.send('%.10f\n'%(self.press)) + return + From d093fef450787adbf0dc49fecbf6ffd4a6c33b0c Mon Sep 17 00:00:00 2001 From: Matsumoto Takao Date: Thu, 21 Aug 2014 11:14:03 +0900 Subject: [PATCH 3/7] =?UTF-8?q?vacuummonitor=E3=81=AEinterface=E3=81=AE?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/vacuummonitor/vacuummonitor.py | 146 +++++++++++++++--- 1 file changed, 123 insertions(+), 23 deletions(-) diff --git a/pymeasure/device/vacuummonitor/vacuummonitor.py b/pymeasure/device/vacuummonitor/vacuummonitor.py index dae1f44..1cb7d6d 100644 --- a/pymeasure/device/vacuummonitor/vacuummonitor.py +++ b/pymeasure/device/vacuummonitor/vacuummonitor.py @@ -14,27 +14,47 @@ # ====================== class vacuummonitor(device.device): - #property configuration - # ===================== - pressure = None - + # property configuration + # ====================== + press1 = 0 + press2 = 0 + unit1 = 'None' + unit2 = 'None' + gauge = 0 + press = [] + unit = 'None' # constructor # ============ def __init__(self, com=None): device.device.__init__(self, com) - self.press_get() + self.measure() + self.unit_check() self.model_check() pass - #Interface method - # =============== - def press_get(self): + # Interface method + # ================ + def measure(self): """ """ - self.press = self._press_get() + self.press = self._measure() return self.press + def unit_set(self, gauge, unit): + """ + """ + self._unit_set(gauge, unit) + self.unit = self._unit_check() + return + + def unit_check(self): + """ + """ + self.unit = self._unit_check() + return self.unit + + def model_check(self): self.model = self._model_check() return @@ -55,18 +75,45 @@ def self_test(self, interval=0.2): print('') print('test start') print('----------') - print('press_get()') + print('%-10s'%'measure():'), try: - ret = self.press_get() - if type(ret)!=float: print('!! Bad !!, return in not float') - else: print('OK, %f'%ret) + ret = self.measure() + wait() + if type(ret)!=str: print('!! Bad !!, return is not str') + else: print('OK, %s'%ret) except: err = sys.exc_info() print('!! Error !!, %s, %s'%(err[0].__name__, err[1])) pass + print('%-30s'%'unit_check():'), + try: + ret = self.unit_check() + wait() + if type(ret)!=str: print('!! Bad !!, return is not str') + else: print('OK, %s'%ret) + except: + err = sys.exc_info() + print('!! Error !!, %s %s'%(err[0].__name__, err[1])) + pass + + print('%-30s'%'unit_set():'), + try: + self.unit_set(1, 'torr') + wait() + ret = self.unit_check() + if ret!="['torr', 'None']": print('!! Bad !!, %s'%(ret)) + else: print('OK, %s'%ret) + except: + err = sys.exc_info() + print('!! Error !!, %s %s'%(err[0].__name__, err[1])) + pass + + + wait() + print('') print('test end') print('') return @@ -75,8 +122,14 @@ def self_test(self, interval=0.2): # internal method # =============== - def _press_get(self): - return float() + def _measure(self): + return str() + + def _unit_set(self, gauge, unit): + return None + + def _unit_check(self): + return str() def _model_check(self): return str() @@ -86,11 +139,23 @@ def _model_check(self): # ==================== # Dummy Server/Client # ==================== -dummy_api = {'press_get': 'dummy_vm:press_get'} +dummy_api = {'measure': 'dummy_vm:measure', + 'unit_set': 'dummy_vm:unit_set', + 'unit_check': 'dummy_vm:unit_check'} # dummy client # ============ class dummy_client(vacuummonitor): + + # property configuration + # ====================== + + unit = 'None' + press = [] + + # method + # ====== + def __init__(self, com): self.server = dummy_server(com.port) time.sleep(0.05) @@ -103,13 +168,26 @@ def server_stop(self): self.com.close() return - def _press_get(self): + def _measure(self): self.com.open() - self.com.send('%s\n'%(dummy_api['press_get'])) - press = float(self.com.readline()) + self.com.send('%s\n'%(dummy_api['measure'])) + press = str(self.com.readline().strip().split(' ')) self.com.close() return press + def _unit_set(self, gauge, unit): + self.com.open() + self.com.send('%s %s %s\n'%(dummy_api['unit_set'], gauge, unit)) + self.com.close() + return + + def _unit_check(self): + self.com.open() + self.com.send('%s\n'%(dummy_api['unit_check'])) + unit = str(self.com.readline().strip().split(' ')) + self.com.close() + return unit + def _model_check(self): return 'VacuumMonitor_Dummy' @@ -118,7 +196,12 @@ def _model_check(self): # dummy server # ============ class dummy_server(object): - press = 0 + press1 = 0 + press2 = 0 + unit1 = 'None' + unit2 = 'None' + gauge = 0 + unit = 'None' def __init__(self, port): self.port = port @@ -155,11 +238,28 @@ def _start(self): return def handle(self, command, params): - if command==dummy_api['press_get']: self.press_get(params) + if command==dummy_api['measure']: self.measure(params) + elif command==dummy_api['unit_check']: self.unit_check(params) + elif command==dummy_api['unit_set']: self.unit_set(params) else: print(command, params) return - def press_get(self, params): - self.client.send('%.10f\n'%(self.press)) + def measure(self, params): + self.client.send('%.10f %.10f\n'%(self.press1, self.press2)) + return + + def unit_check(self, params): + self.client.send('%s %s\n'%(self.unit1, self.unit2)) + return + + def unit_set(self, params): + gauge = int(params[0]) + self.unit1 = str(params[1].lower()) return + + + + + + From f161e679d7c9a9746189cdafc92008b20d4341cf Mon Sep 17 00:00:00 2001 From: Matsumoto Takao Date: Thu, 21 Aug 2014 15:05:30 +0900 Subject: [PATCH 4/7] =?UTF-8?q?vacuummonitor=E3=81=AEinterface=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E5=86=8D=E5=BA=A6=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/vacuummonitor/vacuummonitor.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pymeasure/device/vacuummonitor/vacuummonitor.py b/pymeasure/device/vacuummonitor/vacuummonitor.py index 1cb7d6d..fbe984d 100644 --- a/pymeasure/device/vacuummonitor/vacuummonitor.py +++ b/pymeasure/device/vacuummonitor/vacuummonitor.py @@ -21,8 +21,7 @@ class vacuummonitor(device.device): unit1 = 'None' unit2 = 'None' gauge = 0 - press = [] - unit = 'None' + # constructor # ============ @@ -150,8 +149,6 @@ class dummy_client(vacuummonitor): # property configuration # ====================== - unit = 'None' - press = [] # method # ====== @@ -171,7 +168,10 @@ def server_stop(self): def _measure(self): self.com.open() self.com.send('%s\n'%(dummy_api['measure'])) - press = str(self.com.readline().strip().split(' ')) + ret = self.com.readline().strip().split(',') + del ret[1] + del ret[2] + press =str(ret) self.com.close() return press @@ -184,7 +184,10 @@ def _unit_set(self, gauge, unit): def _unit_check(self): self.com.open() self.com.send('%s\n'%(dummy_api['unit_check'])) - unit = str(self.com.readline().strip().split(' ')) + ret = self.com.readline().strip().split(',') + del ret[0] + del ret[1] + unit = str(ret) self.com.close() return unit @@ -201,7 +204,7 @@ class dummy_server(object): unit1 = 'None' unit2 = 'None' gauge = 0 - unit = 'None' + unit = [] def __init__(self, port): self.port = port @@ -245,11 +248,11 @@ def handle(self, command, params): return def measure(self, params): - self.client.send('%.10f %.10f\n'%(self.press1, self.press2)) + self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit1, self.press2, self.unit2)) return def unit_check(self, params): - self.client.send('%s %s\n'%(self.unit1, self.unit2)) + self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit1, self.press2, self.unit2)) return def unit_set(self, params): From 7a80a7b5f7e7a22c179b784e665ffb66a027858a Mon Sep 17 00:00:00 2001 From: Matsumoto Takao Date: Thu, 21 Aug 2014 16:07:52 +0900 Subject: [PATCH 5/7] =?UTF-8?q?vacuummonitor=E3=81=AEinterface=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E6=9B=B8=E3=81=8D=E7=9B=B4?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/vacuummonitor/vacuummonitor.py | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/pymeasure/device/vacuummonitor/vacuummonitor.py b/pymeasure/device/vacuummonitor/vacuummonitor.py index fbe984d..961955f 100644 --- a/pymeasure/device/vacuummonitor/vacuummonitor.py +++ b/pymeasure/device/vacuummonitor/vacuummonitor.py @@ -18,9 +18,7 @@ class vacuummonitor(device.device): # ====================== press1 = 0 press2 = 0 - unit1 = 'None' - unit2 = 'None' - gauge = 0 + unit = 'None' # constructor @@ -40,10 +38,10 @@ def measure(self): self.press = self._measure() return self.press - def unit_set(self, gauge, unit): + def unit_set(self, unit): """ """ - self._unit_set(gauge, unit) + self._unit_set(unit) self.unit = self._unit_check() return @@ -98,10 +96,10 @@ def self_test(self, interval=0.2): print('%-30s'%'unit_set():'), try: - self.unit_set(1, 'torr') + self.unit_set('torr') wait() ret = self.unit_check() - if ret!="['torr', 'None']": print('!! Bad !!, %s'%(ret)) + if ret!="['torr', 'torr']": print('!! Bad !!, %s'%(ret)) else: print('OK, %s'%ret) except: err = sys.exc_info() @@ -124,7 +122,7 @@ def self_test(self, interval=0.2): def _measure(self): return str() - def _unit_set(self, gauge, unit): + def _unit_set(self, unit): return None def _unit_check(self): @@ -146,12 +144,6 @@ def _model_check(self): # ============ class dummy_client(vacuummonitor): - # property configuration - # ====================== - - - # method - # ====== def __init__(self, com): self.server = dummy_server(com.port) @@ -175,9 +167,9 @@ def _measure(self): self.com.close() return press - def _unit_set(self, gauge, unit): + def _unit_set(self, unit): self.com.open() - self.com.send('%s %s %s\n'%(dummy_api['unit_set'], gauge, unit)) + self.com.send('%s %s\n'%(dummy_api['unit_set'], unit)) self.com.close() return @@ -201,10 +193,7 @@ def _model_check(self): class dummy_server(object): press1 = 0 press2 = 0 - unit1 = 'None' - unit2 = 'None' - gauge = 0 - unit = [] + unit = 'None' def __init__(self, port): self.port = port @@ -248,16 +237,15 @@ def handle(self, command, params): return def measure(self, params): - self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit1, self.press2, self.unit2)) + self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit, self.press2, self.unit)) return def unit_check(self, params): - self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit1, self.press2, self.unit2)) + self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit, self.press2, self.unit)) return def unit_set(self, params): - gauge = int(params[0]) - self.unit1 = str(params[1].lower()) + self.unit = str(params[0].lower()) return From 173f4fd66526a4a742581d96c3239af974b8430f Mon Sep 17 00:00:00 2001 From: Matsumoto Takao Date: Fri, 22 Aug 2014 14:18:31 +0900 Subject: [PATCH 6/7] =?UTF-8?q?vacuummonitor=E3=81=AEselftest=E3=82=92?= =?UTF-8?q?=E6=9B=B8=E3=81=8D=E6=8F=9B=E3=81=88=E3=81=BE=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pymeasure/device/vacuummonitor/vacuummonitor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymeasure/device/vacuummonitor/vacuummonitor.py b/pymeasure/device/vacuummonitor/vacuummonitor.py index 961955f..1b19433 100644 --- a/pymeasure/device/vacuummonitor/vacuummonitor.py +++ b/pymeasure/device/vacuummonitor/vacuummonitor.py @@ -72,7 +72,7 @@ def self_test(self, interval=0.2): print('') print('test start') print('----------') - print('%-10s'%'measure():'), + print('%-30s'%'measure():'), try: ret = self.measure() wait() @@ -94,7 +94,7 @@ def self_test(self, interval=0.2): print('!! Error !!, %s %s'%(err[0].__name__, err[1])) pass - print('%-30s'%'unit_set():'), + print('%-30s'%"unit_set('torr'):"), try: self.unit_set('torr') wait() From 364792da5f4ce5895877711b463eef5ee93ecdc4 Mon Sep 17 00:00:00 2001 From: Matsumoto Takao Date: Fri, 22 Aug 2014 23:04:44 +0900 Subject: [PATCH 7/7] =?UTF-8?q?vacuummonitor=E3=81=AEselftest=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AE=8C=E4=BA=86=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/vacuummonitor/vacuummonitor.py | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/pymeasure/device/vacuummonitor/vacuummonitor.py b/pymeasure/device/vacuummonitor/vacuummonitor.py index 1b19433..81a8b4f 100644 --- a/pymeasure/device/vacuummonitor/vacuummonitor.py +++ b/pymeasure/device/vacuummonitor/vacuummonitor.py @@ -41,20 +41,18 @@ def measure(self): def unit_set(self, unit): """ """ - self._unit_set(unit) - self.unit = self._unit_check() + self.unit = self._unit_set(unit) return def unit_check(self): """ """ - self.unit = self._unit_check() return self.unit def model_check(self): self.model = self._model_check() - return + return self.model @@ -76,8 +74,8 @@ def self_test(self, interval=0.2): try: ret = self.measure() wait() - if type(ret)!=str: print('!! Bad !!, return is not str') - else: print('OK, %s'%ret) + if type(ret)!=list: print('!! Bad !!, return is not list') + elif not False in [type(a)==float for a in ret] == True: print('OK, %s'%(ret)) except: err = sys.exc_info() print('!! Error !!, %s, %s'%(err[0].__name__, err[1])) @@ -99,7 +97,7 @@ def self_test(self, interval=0.2): self.unit_set('torr') wait() ret = self.unit_check() - if ret!="['torr', 'torr']": print('!! Bad !!, %s'%(ret)) + if ret!='torr': print('!! Bad !!, %s'%(ret)) else: print('OK, %s'%ret) except: err = sys.exc_info() @@ -120,10 +118,10 @@ def self_test(self, interval=0.2): # =============== def _measure(self): - return str() + return list() def _unit_set(self, unit): - return None + return str() def _unit_check(self): return str() @@ -161,27 +159,22 @@ def _measure(self): self.com.open() self.com.send('%s\n'%(dummy_api['measure'])) ret = self.com.readline().strip().split(',') - del ret[1] - del ret[2] - press =str(ret) + press = [ret[1], ret[3]] self.com.close() return press def _unit_set(self, unit): self.com.open() self.com.send('%s %s\n'%(dummy_api['unit_set'], unit)) + self.unit =str(self.com.readline().strip()) self.com.close() - return + return self.unit def _unit_check(self): self.com.open() self.com.send('%s\n'%(dummy_api['unit_check'])) - ret = self.com.readline().strip().split(',') - del ret[0] - del ret[1] - unit = str(ret) self.com.close() - return unit + return self.unit def _model_check(self): return 'VacuumMonitor_Dummy' @@ -193,6 +186,8 @@ def _model_check(self): class dummy_server(object): press1 = 0 press2 = 0 + status1 = 0 + status2 = 0 unit = 'None' def __init__(self, port): @@ -237,15 +232,14 @@ def handle(self, command, params): return def measure(self, params): - self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit, self.press2, self.unit)) + self.client.send('%s,%.10f,%s,%.10f\n'%(self.status1, self.press1, self.status2, self.press2)) return def unit_check(self, params): - self.client.send('%.10f,%s,%.10f,%s\n'%(self.press1, self.unit, self.press2, self.unit)) return def unit_set(self, params): - self.unit = str(params[0].lower()) + self.client.send('%s\n'%(params[0].lower())) return