From d687c114308d65a000933c08c1b014c3239e64a2 Mon Sep 17 00:00:00 2001
From: Sebastian <seb.miksch@aon.at>
Date: Mon, 4 Oct 2021 17:10:19 +0200
Subject: [PATCH] changed get_tm_id added get_data_pool_items

---
 Ccs/ccs_function_lib.py | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/Ccs/ccs_function_lib.py b/Ccs/ccs_function_lib.py
index b022f46..36e388a 100644
--- a/Ccs/ccs_function_lib.py
+++ b/Ccs/ccs_function_lib.py
@@ -2688,10 +2688,11 @@ def get_tc_calibration_and_parameters(ccf_descr=None):
 
     return calibrations_dict
 
-def get_tm_id(ccf_descr=None):
-    if ccf_descr is None:
+def get_tm_id(pcf_descr=None):
+    if pcf_descr is None:
         tms = scoped_session_idb.execute('SELECT pid_type, pid_stype, pid_apid, pid_pi1_val, pid_descr, pid_tpsd, '
-                                         'pid_spid, pcf_name, pcf_descr, pcf_curtx, txp_from, txp_altxt, plf_offby '
+                                         'pid_spid, pcf_name, pcf_descr, pcf_curtx, txp_from, txp_altxt, plf_offby,'
+                                         'pcf_ptc, pcf_pfc '
                                          'FROM pid '
                                          'LEFT JOIN plf '
                                          'ON pid_spid = plf_spid AND pid_tpsd = -1 '
@@ -2706,7 +2707,8 @@ def get_tm_id(ccf_descr=None):
 
     else:
         tms = scoped_session_idb.execute('SELECT pid_type, pid_stype, pid_apid, pid_pi1_val, pid_descr , pid_tpsd, '
-                                         'pid_spid, pcf_name, pcf_descr, pcf_curtx, txp_from, txp_altxt, plf_offby '
+                                         'pid_spid, pcf_name, pcf_descr, pcf_curtx, txp_from, txp_altxt, plf_offby,'
+                                         'pcf_ptc, pcf_pfc '
                                          'FROM pid '
                                          'LEFT JOIN plf '
                                          'ON pid_spid = plf_spid AND pid_tpsd = -1 '
@@ -2730,6 +2732,25 @@ def get_tm_id(ccf_descr=None):
 
     return tms_dict
 
+def get_data_pool_items(pcf_descr = None):
+    if pcf_descr is None:
+        data_pool = scoped_session_idb.execute('SELECT pcf_pid, pcf_descr, pcf_ptc, pcf_pfc '
+                                         'FROM pcf').fetchall()
+
+    else:
+        data_pool = scoped_session_idb.execute('SELECT pcf_pid, pcf_descr, pcf_ptc, pcf_pfc '
+                                         'FROM pcf'.format(ccf_descr)).fetchall()
+
+    scoped_session_idb.close()
+
+    data_pool_dict = {}
+
+    for row in data_pool:
+        data_pool_dict.setdefault(row[0:4], []).append(row[5:])
+
+
+    return data_pool_dict
+
 
 
 def make_tc_template(ccf_descr, pool_name='LIVE', preamble='cfl.Tcsend_DB', options='', comment=True, add_parcfg=False):
-- 
GitLab