From bfe980fbe223fd8320c22216479c59b9d2d5fb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Sim=C3=B3n?= Date: Wed, 9 Sep 2015 15:37:39 +0200 Subject: [PATCH 1/3] Substation code field has been fixed. Substation code is now the substation description instead of its name. --- libcnmc/res_4771/POS.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libcnmc/res_4771/POS.py b/libcnmc/res_4771/POS.py index 967628ee..c92c2523 100644 --- a/libcnmc/res_4771/POS.py +++ b/libcnmc/res_4771/POS.py @@ -40,6 +40,17 @@ def get_sequence(self): return self.connection.GiscedataCtsSubestacionsPosicio.search( search_params, 0, 0, False, {'active_test': False}) + def get_description(self, sub_id): + o = self.connection + sub = o.GiscedataCtsSubestacionsPosicio.read(sub_id, ['subestacio_id']) + descripcio = '' + if sub: + ct_id = sub['subestacio_id'][0] + ct = o.GiscedataCts.read(ct_id, ['descripcio']) + if ct: + descripcio = ct['descripcio'] + return descripcio + def consumer(self): O = self.connection fields_to_read = ['name', 'cini', 'data_pm', 'subestacio_id', @@ -48,7 +59,7 @@ def consumer(self): try: item = self.input_q.get() self.progress_q.put(item) - + o_sub = '' sub = O.GiscedataCtsSubestacionsPosicio.read( item, fields_to_read) if not sub: @@ -93,9 +104,10 @@ def consumer(self): id_comunitat[0], ['codi']) if comunitat_vals: comunitat = comunitat_vals['codi'] + o_sub = self.get_description(sub['subestacio_id'][0]) output = [ - '%s' % sub['name'], + o_sub, sub['cini'] or '', cts['name'] or '', codi, From 6107344afdab84833ba7548df49eb0480bf7f445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Sim=C3=B3n?= Date: Wed, 9 Sep 2015 15:52:35 +0200 Subject: [PATCH 2/3] get_description has been fixed. Function now retrieves correct description from ct. --- libcnmc/res_4771/POS.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libcnmc/res_4771/POS.py b/libcnmc/res_4771/POS.py index c92c2523..06500887 100644 --- a/libcnmc/res_4771/POS.py +++ b/libcnmc/res_4771/POS.py @@ -40,15 +40,18 @@ def get_sequence(self): return self.connection.GiscedataCtsSubestacionsPosicio.search( search_params, 0, 0, False, {'active_test': False}) - def get_description(self, sub_id): + def get_description(self, pos_id): o = self.connection - sub = o.GiscedataCtsSubestacionsPosicio.read(sub_id, ['subestacio_id']) + pos = o.GiscedataCtsSubestacionsPosicio.read(pos_id, ['subestacio_id']) descripcio = '' - if sub: - ct_id = sub['subestacio_id'][0] - ct = o.GiscedataCts.read(ct_id, ['descripcio']) - if ct: - descripcio = ct['descripcio'] + if pos: + sub_id = pos['subestacio_id'][0] + sub = o.GiscedataCtsSubestacions.read(sub_id, ['ct_id']) + if sub: + ct_id = sub['ct_id'][0] + ct = o.GiscedataCts.read(ct_id, ['descripcio']) + if ct: + descripcio = ct['descripcio'] return descripcio def consumer(self): From 32e9691d3c44032abe16a19e0aa22ce955c9fd1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Sim=C3=B3n?= Date: Wed, 9 Sep 2015 15:58:54 +0200 Subject: [PATCH 3/3] get_description has been simplified. --- libcnmc/res_4771/POS.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libcnmc/res_4771/POS.py b/libcnmc/res_4771/POS.py index 06500887..f3266630 100644 --- a/libcnmc/res_4771/POS.py +++ b/libcnmc/res_4771/POS.py @@ -46,12 +46,9 @@ def get_description(self, pos_id): descripcio = '' if pos: sub_id = pos['subestacio_id'][0] - sub = o.GiscedataCtsSubestacions.read(sub_id, ['ct_id']) + sub = o.GiscedataCtsSubestacions.read(sub_id, ['descripcio']) if sub: - ct_id = sub['ct_id'][0] - ct = o.GiscedataCts.read(ct_id, ['descripcio']) - if ct: - descripcio = ct['descripcio'] + descripcio = sub['descripcio'] return descripcio def consumer(self):