Commit 6bfac310 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

bliss/controllers/wago.py: indentation

parent 5d547a89
......@@ -91,7 +91,7 @@ MODULES_CONFIG = {
}
def get_module_info(module_name):
return MODULES_CONFIG[module_name]
return MODULES_CONFIG[module_name]
# go through catalogue entries and update 'reading info'
for module_name, module_info in MODULES_CONFIG.iteritems():
......@@ -150,19 +150,19 @@ class _WagoController:
def connect(self):
with self.lock:
# check if we have a coupler or a controller
reply = self.client.read_input_registers(0x2012, 'H')
self.coupler = reply < 800
if not self.coupler:
# get firmware date and version
reply = self.client.read_input_registers(0x2010,'H')
self.firmware['version'] = reply
reply = struct.pack('16H',*self.client.read_input_registers(0x2022,'16H'))
self.firmware['date'] = '/'.join((x for x in reply.split('\x00') if x))
# check if we have a coupler or a controller
reply = self.client.read_input_registers(0x2012, 'H')
self.coupler = reply < 800
if not self.coupler:
# get firmware date and version
reply = self.client.read_input_registers(0x2010,'H')
self.firmware['version'] = reply
reply = struct.pack('16H',*self.client.read_input_registers(0x2022,'16H'))
self.firmware['date'] = '/'.join((x for x in reply.split('\x00') if x))
def close(self):
with self.lock:
self.client.close()
with self.lock:
self.client.close()
def set_mapping(self, mapping_str, ignore_missing=False):
i = 0
......@@ -208,26 +208,26 @@ class _WagoController:
i+=1
def _read_fs(self, raw_value, low=0, high=10, base=32768):
# full-scale conversion
value = ctypes.c_short(raw_value).value
return (value * high / float(base)) + low
# full-scale conversion
value = ctypes.c_short(raw_value).value
return (value * high / float(base)) + low
def _read_ssi(self, raw_value, bits=24):
#reading is two words, 16 bits each
#the return value is 24 bits precision, signed float
value = raw_value[0] + raw_value[1]*(1L<<16)
value &= ((1L<<bits)-1)
if (value & (1L<<(bits-1))):
value -= (1L<<bits)
return [float(value)]
# reading is two words, 16 bits each
# the return value is 24 bits precision, signed float
value = raw_value[0] + raw_value[1]*(1L<<16)
value &= ((1L<<bits)-1)
if (value & (1L<<(bits-1))):
value -= (1L<<bits)
return [float(value)]
def _read_thc(self, raw_value, bits=16):
#the return value is signed float
value = ctypes.c_ushort(raw_value).value
value &= ((1L<<bits)-1)
if (value & (1L<<(bits-1))):
#the return value is signed float
value = ctypes.c_ushort(raw_value).value
value &= ((1L<<bits)-1)
if (value & (1L<<(bits-1))):
value -= (1L<<bits)
return value/10.0
return value/10.0
def _read_value(self, raw_value, read_table):
reading_type = read_table[READING_TYPE]
......@@ -252,6 +252,7 @@ class _WagoController:
module_info = get_module_info(module_name)
except KeyError:
raise RuntimeError("Cannot read module %d: unknown module %r" % (module_index, module_name))
n_digi_in = module_info[DIGI_IN]
n_digi_out = module_info[DIGI_OUT]
n_ana_in = module_info[ANA_IN]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment