4 from __future__
import print_function
10 Keeps a list of drawer, variable <---> folder, channel
11 associations and provides information about the available
12 variables and their datatypes.
15 LVPS_AI = (
"/TILE/DCS/",
"AI")
16 LVPS_STATES = (
"/TILE/DCS/",
"STATES")
17 VARS_HV = (
"/TILE/DCS/",
"HV")
18 VARS_HVSET = (
"/TILE/DCS/",
"HVSET")
19 VARS_DAQ = (
"/DAQdummy/",
"/DAQdummy")
20 type_float = (
'f',
'/F')
23 vars_LVPS_STATES = {
"FORDAQ_MB" : [ LVPS_STATES, type_int],
24 "FORDAQ_HV" : [ LVPS_STATES, type_int],
25 "FORDAQ_MBHV" : [ LVPS_STATES, type_int]}
27 vars_LVPS_AI = {
"15VMB_OUTPUT_I" : [ LVPS_AI, type_float],
28 "M5VMB_TEMP2" : [ LVPS_AI, type_float],
29 "M5VMB_SENSES" : [ LVPS_AI, type_float],
30 "M5VMB_OUTPUT_V" : [ LVPS_AI, type_float],
31 "M5VMB_OUTPUT_I" : [ LVPS_AI, type_float],
32 "M5VMB_INPUT_V" : [ LVPS_AI, type_float],
33 "15VHV_INPUT_V" : [ LVPS_AI, type_float],
34 "M15VHV_TEMP3" : [ LVPS_AI, type_float],
35 "M15VHV_TEMP2" : [ LVPS_AI, type_float],
36 "15VHV_OUTPUT_I" : [ LVPS_AI, type_float],
37 "M15VHV_OUTPUT_V" : [ LVPS_AI, type_float],
38 "M15VHV_OUTPUT_I" : [ LVPS_AI, type_float],
39 "M15VHV_INPUT_V" : [ LVPS_AI, type_float],
40 "15VHV_OUTPUT_V" : [ LVPS_AI, type_float],
41 "EXT_TEMP2" : [ LVPS_AI, type_float],
42 "15VMB_TEMP3" : [ LVPS_AI, type_float],
43 "3VDIG_INPUT_V" : [ LVPS_AI, type_float],
44 "3VDIG_OUTPUT_I" : [ LVPS_AI, type_float],
45 "3VDIG_OUTPUT_V" : [ LVPS_AI, type_float],
46 "3VDIG_SENSES" : [ LVPS_AI, type_float],
47 "15VMB_TEMP2" : [ LVPS_AI, type_float],
48 "3VDIG_TEMP2" : [ LVPS_AI, type_float],
49 "3VDIG_TEMP3" : [ LVPS_AI, type_float],
50 "15VMB_SENSES" : [ LVPS_AI, type_float],
51 "5VDIG_INPUT_V" : [ LVPS_AI, type_float],
52 "5VDIG_OUTPUT_I" : [ LVPS_AI, type_float],
53 "5VDIG_OUTPUT_V" : [ LVPS_AI, type_float],
54 "5VDIG_SENSES" : [ LVPS_AI, type_float],
55 "15VMB_OUTPUT_V" : [ LVPS_AI, type_float],
56 "5VDIG_TEMP2" : [ LVPS_AI, type_float],
57 "5VDIG_TEMP3" : [ LVPS_AI, type_float],
58 "M5VMB_TEMP3" : [ LVPS_AI, type_float],
59 "5VHV_INPUT_V" : [ LVPS_AI, type_float],
60 "5VHV_OUTPUT_I" : [ LVPS_AI, type_float],
61 "5VHV_OUTPUT_V" : [ LVPS_AI, type_float],
62 "15VMB_INPUT_V" : [ LVPS_AI, type_float],
64 "5VHV_TEMP2" : [ LVPS_AI, type_float],
65 "5VHV_TEMP3" : [ LVPS_AI, type_float],
66 "15VHV_TEMP3" : [ LVPS_AI, type_float],
67 "5VMB_INPUT_V" : [ LVPS_AI, type_float],
68 "5VMB_OUTPUT_I" : [ LVPS_AI, type_float],
69 "5VMB_OUTPUT_V" : [ LVPS_AI, type_float],
70 "5VMB_SENSES" : [ LVPS_AI, type_float],
71 "15VHV_TEMP2" : [ LVPS_AI, type_float],
72 "5VMB_TEMP2" : [ LVPS_AI, type_float],
73 "5VMB_TEMP3" : [ LVPS_AI, type_float],
74 "EXT_TEMP1" : [ LVPS_AI, type_float]}
79 vars_HV[
"hvOut"+i] = [ VARS_HV, type_float ]
82 vars_HV[
"hvIn"+i] = [ VARS_HV, type_float ]
85 vars_HV[
"volt"+i] = [ VARS_HV, type_float ]
86 vars_HV[
"temp"+i] = [ VARS_HV, type_float ]
91 vars_HVSET[
"Set.hvOut"+i] = [ VARS_HVSET, type_float ]
94 vars_HVSET[
"Set.hvIn"+i] = [ VARS_HVSET, type_float ]
97 vars_HVSET[
"Set.volt"+i] = [ VARS_HVSET, type_float ]
98 vars_HVSET[
"Set.temp"+i] = [ VARS_HVSET, type_float ]
104 vars_DAQ[
"STATE"] = [ VARS_DAQ, type_int]
106 systemID = {
"LBA" : 88 ,
112 partitionID = { 0 :
"EBA",
121 self.
vars[var] = info
123 self.
vars[var] = info
125 self.
vars[var] = info
127 self.
vars[var] = info
129 self.
vars[var] = info
136 lines =
open(filename,
"r").readlines()
139 folder, drawer, channel, oracleId = line.split()
141 keyFolderDrawer = ( folder , drawer)
143 raise Exception (
"trying to generate key twice: ", keyFolderDrawer)
147 keyFolderChannel = ( folder ,
int(channel))
149 raise Exception (
"trying to generate key twice: ", keyFolderChannel)
152 self.
dbstring = {
"DEFAULT":[],
"COOL":[],
"ORACLE":[],
"TESTBEAM":[]}
153 self.
dbstring[
'DEFAULT'] += [dbstring]*3
154 dbstring =
"oracle://ATLAS_COOLPROD;schema=ATLAS_COOLOFL_DCS;dbname=COMP200;"
155 dbstring+=
"user=ATLAS_COOL_READER;password=COOLRED4PRO"
158 self.
dbstring[
'COOL'] += [dbstring.replace(
"COMP200",
"CONDBR2")]
159 self.
dbstring[
'ORACLE'] += [[
"oracle://localhost/ATONR_PVSSPROD",
"ATLAS_PVSS_READER",
"PVSSRED4PRO"]]
160 self.
dbstring[
'ORACLE'] += [[
"oracle://localhost/ATLAS_PVSSPROD",
"ATLAS_PVSS_READER",
"PVSSRED4PRO"]]
161 self.
dbstring[
'ORACLE'] += [[
"oracle://localhost/ATONR_ADG",
"ATLAS_PVSS_READER",
"PVSSRED4PRO"]]
162 self.
dbstring[
'TESTBEAM'] += [[
"oracle://localhost/INTR",
"ATLAS_PVSS_READER",
"PVSSRED4INT"]]*3
171 raise Exception (
"ERROR: drawer not valid: ", drawer)
172 key = (folder, drawer )
174 print (
"get_channel WARNING, can not resolve key: ", key)
180 key = (folder, channel)
182 print (
"get_drawer WARNING, can not resolve key: ", key)
189 For a given DCS variable and drawer, return the complete COOL
190 folder name and the channel number associated to the drawer
192 if variable
not in self.
vars:
193 raise Exception (
"Variable not known: ", variable)
194 partition = drawer[0:3]
196 folderDef = self.
vars[variable][0]
198 if variable==
"STATE":
199 drawer = partition+
"XX"
200 folder = folderDef[0]+partition+folderDef[1]
202 folder = folderDef[0]+folderDef[1]
203 key = (folder, drawer)
205 print (
"WARNING, can not resolve key: ", key)
208 return (folder, channel)
212 Returns the type of a variable
214 if variable
not in self.
vars:
215 raise Exception (
"Variable not known: ", variable)
216 return self.
vars[variable][1]
222 partition = drawer[0:3]
223 drawerNum =
int(drawer[3:5])
224 valid = (
"LBA" ,
"LBC",
"EBA",
"EBC")
225 if partition
not in valid:
227 if drawerNum<1
or drawerNum>64:
233 Return a dictionary listing all folders that need to be
234 accessed as keys and all variables associated to the key folder
238 for var
in variables:
239 if var
not in self.
vars:
240 print (
"Unknown variable, IGNORING IT: ", var)
243 if folder
not in folderDict:
244 folderDict[folder] = [var]
246 folderDict[folder].
extend([var])
250 """the python equivalent to the C++ PathResolver for datafiles.
254 pathlist = os.getenv(
'DATAPATH').
split(os.pathsep)
256 for path
in pathlist:
257 f = os.path.join( path, fname )
258 if os.access( f, access ):