Write option id into driver implementation section when saving the sics_config.ini
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
[12tmagnet_oxford]
|
[12tmagnet_oxford]
|
||||||
desc = "12 Tesla Oxford Magnet"
|
desc = "12 Tesla Oxford Magnet"
|
||||||
driver = "oxford_labview"
|
driver = "oxford_labview"
|
||||||
|
id = 1
|
||||||
imptype = magnetic_field
|
imptype = magnetic_field
|
||||||
ip = 10.157.205.3
|
ip = 10.157.205.3
|
||||||
port = 55001
|
port = 55001
|
||||||
@ -10,11 +11,12 @@ desc = "som will be redefined as the magnet sample insert rotation. Sample stage
|
|||||||
imptype = motion_axis
|
imptype = motion_axis
|
||||||
|
|
||||||
[12tmagnet_setup]
|
[12tmagnet_setup]
|
||||||
cascade = B1:12tmagnet_oxford,sample_stage:12tmagnet_sample_insert,T1:mercury_scpi
|
cascade = B1:12tmagnet_oxford,sample_stage:12tmagnet_sample_insert,T1:mercury_scpi_01
|
||||||
enabled = False
|
enabled = False
|
||||||
|
|
||||||
[B1]
|
[B1]
|
||||||
enabled = False
|
enabled = False
|
||||||
|
id = 1
|
||||||
implementation = 12tmagnet_oxford
|
implementation = 12tmagnet_oxford
|
||||||
name = magnet1
|
name = magnet1
|
||||||
optype = magnetic_field
|
optype = magnetic_field
|
||||||
@ -40,6 +42,7 @@ enabled = True
|
|||||||
[I1]
|
[I1]
|
||||||
datype = I
|
datype = I
|
||||||
enabled = False
|
enabled = False
|
||||||
|
id = 1
|
||||||
implementation = protek_01
|
implementation = protek_01
|
||||||
name = curr1
|
name = curr1
|
||||||
optype = multimeter
|
optype = multimeter
|
||||||
@ -47,39 +50,45 @@ optype = multimeter
|
|||||||
[I2]
|
[I2]
|
||||||
datype = I
|
datype = I
|
||||||
enabled = False
|
enabled = False
|
||||||
|
id = 2
|
||||||
implementation = protek_02
|
implementation = protek_02
|
||||||
name = curr2
|
name = curr2
|
||||||
optype = multimeter
|
optype = multimeter
|
||||||
|
|
||||||
[T1]
|
[T1]
|
||||||
enabled = False
|
enabled = False
|
||||||
implementation = mercury_scpi
|
id = 1
|
||||||
|
implementation = mercury_scpi_01
|
||||||
name = tc1
|
name = tc1
|
||||||
optype = temperature
|
optype = temperature
|
||||||
|
|
||||||
[T2]
|
[T2]
|
||||||
enabled = False
|
enabled = False
|
||||||
implementation = ls336_02
|
id = 2
|
||||||
|
implementation = ls340_01
|
||||||
name = tc2
|
name = tc2
|
||||||
optype = temperature
|
optype = temperature
|
||||||
|
|
||||||
[T3]
|
[T3]
|
||||||
enabled = False
|
enabled = False
|
||||||
implementation = ls336_04
|
id = 3
|
||||||
|
implementation = ls340_02
|
||||||
name = tc3
|
name = tc3
|
||||||
optype = temperature
|
optype = temperature
|
||||||
|
|
||||||
[V1]
|
[V1]
|
||||||
datype = V
|
datype = V
|
||||||
enabled = False
|
enabled = False
|
||||||
implementation = protek_01
|
id = 1
|
||||||
|
implementation = none
|
||||||
name = volts1
|
name = volts1
|
||||||
optype = multimeter
|
optype = multimeter
|
||||||
|
|
||||||
[V2]
|
[V2]
|
||||||
datype = V
|
datype = V
|
||||||
enabled = False
|
enabled = False
|
||||||
implementation = protek_02
|
id = 2
|
||||||
|
implementation = none
|
||||||
name = volts2
|
name = volts2
|
||||||
optype = multimeter
|
optype = multimeter
|
||||||
|
|
||||||
@ -150,6 +159,7 @@ tol2 = 1.0
|
|||||||
[ls340_01]
|
[ls340_01]
|
||||||
desc = "tc7: Lakeshore 340 temperature controller"
|
desc = "tc7: Lakeshore 340 temperature controller"
|
||||||
driver = "lakeshore_340"
|
driver = "lakeshore_340"
|
||||||
|
id = 2
|
||||||
imptype = temperature
|
imptype = temperature
|
||||||
ip = 137.157.201.86
|
ip = 137.157.201.86
|
||||||
port = 4001
|
port = 4001
|
||||||
@ -160,6 +170,7 @@ tol2 = 1.0
|
|||||||
[ls340_02]
|
[ls340_02]
|
||||||
desc = "tc8: Lakeshore 340 temperature controller"
|
desc = "tc8: Lakeshore 340 temperature controller"
|
||||||
driver = "lakeshore_340"
|
driver = "lakeshore_340"
|
||||||
|
id = 3
|
||||||
imptype = temperature
|
imptype = temperature
|
||||||
ip = 137.157.201.86
|
ip = 137.157.201.86
|
||||||
port = 4002
|
port = 4002
|
||||||
@ -167,14 +178,28 @@ terminator = \r\n
|
|||||||
tol1 = 1.0
|
tol1 = 1.0
|
||||||
tol2 = 1.0
|
tol2 = 1.0
|
||||||
|
|
||||||
[mercury_scpi]
|
[mercury_scpi_01]
|
||||||
desc = "tc9: Oxford Mercury temperature controller in Mercury mode"
|
desc = "Oxford Mercury temperature controller in Mercury mode"
|
||||||
driver = "mercury_scpi"
|
driver = "mercury_scpi"
|
||||||
|
id = 1
|
||||||
imptype = temperature
|
imptype = temperature
|
||||||
ip = 10.157.205.5
|
ip = 10.157.205.5
|
||||||
|
permlink = LT
|
||||||
port = 7020
|
port = 7020
|
||||||
terminator = \r
|
terminator = \r\n
|
||||||
tol = 2.0
|
tol = 1.0
|
||||||
|
valve_tol = 2
|
||||||
|
|
||||||
|
[mercury_scpi_02]
|
||||||
|
desc = "Oxford Mercury temperature controller in Mercury mode"
|
||||||
|
driver = "mercury_scpi"
|
||||||
|
imptype = temperature
|
||||||
|
ip = 10.157.205.47
|
||||||
|
permlink = LT
|
||||||
|
port = 7020
|
||||||
|
terminator = \r\n
|
||||||
|
tol = 1.0
|
||||||
|
valve_tol = 2
|
||||||
|
|
||||||
[normal_sample_stage]
|
[normal_sample_stage]
|
||||||
desc = "This is the default sample stage configuration with xy translation and phi and chi tilt stages"
|
desc = "This is the default sample stage configuration with xy translation and phi and chi tilt stages"
|
||||||
@ -183,6 +208,7 @@ imptype = motion_axis
|
|||||||
[protek_01]
|
[protek_01]
|
||||||
desc = "Protek Multimeter"
|
desc = "Protek Multimeter"
|
||||||
driver = "protek"
|
driver = "protek"
|
||||||
|
id = 1
|
||||||
imptype = multimeter
|
imptype = multimeter
|
||||||
ip = 10.157.205.36
|
ip = 10.157.205.36
|
||||||
port = 4001
|
port = 4001
|
||||||
@ -190,6 +216,7 @@ port = 4001
|
|||||||
[protek_02]
|
[protek_02]
|
||||||
desc = "Protek Multimeter"
|
desc = "Protek Multimeter"
|
||||||
driver = "protek"
|
driver = "protek"
|
||||||
|
id = 2
|
||||||
imptype = multimeter
|
imptype = multimeter
|
||||||
ip = 10.157.205.37
|
ip = 10.157.205.37
|
||||||
port = 4001
|
port = 4001
|
||||||
|
@ -43,6 +43,10 @@ class InstConfigData:
|
|||||||
# {optype: [impname] }
|
# {optype: [impname] }
|
||||||
imp_dict = defaultdict(list)
|
imp_dict = defaultdict(list)
|
||||||
|
|
||||||
|
# imp2opt_dict: Maps each implementation to an option or None,
|
||||||
|
# {imp: opt/None}
|
||||||
|
imp2opt_dict = {}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -77,16 +81,28 @@ class InstConfigData:
|
|||||||
stateval = False
|
stateval = False
|
||||||
permanent = False
|
permanent = False
|
||||||
|
|
||||||
|
if self.file_parser.has_option(s, 'id'):
|
||||||
|
id = self.file_parser.get(s, 'id')
|
||||||
|
self.opt_dict[s]['id'] = id
|
||||||
|
|
||||||
self.opt_dict[s]['enabled'] = stateval
|
self.opt_dict[s]['enabled'] = stateval
|
||||||
self.opt_dict[s]['permanent'] = permanent
|
self.opt_dict[s]['permanent'] = permanent
|
||||||
self.opt_dict[s]['imptype'] = imptype
|
self.opt_dict[s]['imptype'] = imptype
|
||||||
|
if selected_imp in self.imp2opt_dict:
|
||||||
|
self.opt_dict[s]['selected_imp'] = "none"
|
||||||
|
else:
|
||||||
self.opt_dict[s]['selected_imp'] = selected_imp
|
self.opt_dict[s]['selected_imp'] = selected_imp
|
||||||
|
print 'Add imp2opt_dict[{0}] = {1}'.format(selected_imp,s)
|
||||||
|
self.imp2opt_dict[selected_imp] = s
|
||||||
|
|
||||||
def __get_implementations(self):
|
def __get_implementations(self):
|
||||||
for s in self.file_parser.sections():
|
for s in self.file_parser.sections():
|
||||||
if self.file_parser.has_option(s, 'imptype'):
|
if self.file_parser.has_option(s, 'imptype'):
|
||||||
key = self.file_parser.get(s, 'imptype')
|
key = self.file_parser.get(s, 'imptype')
|
||||||
self.imp_dict[key].append(s)
|
self.imp_dict[key].append(s)
|
||||||
|
if s not in self.imp2opt_dict:
|
||||||
|
print 'Add imp2opt_dict[{0}] = none'.format(s)
|
||||||
|
self.imp2opt_dict[s] = "none"
|
||||||
|
|
||||||
def read_config_file(self, config_filename):
|
def read_config_file(self, config_filename):
|
||||||
self.config_filename = config_filename
|
self.config_filename = config_filename
|
||||||
@ -111,17 +127,25 @@ class InstConfigData:
|
|||||||
enabled = 'Always'
|
enabled = 'Always'
|
||||||
else:
|
else:
|
||||||
enabled = dict['enabled'].__str__()
|
enabled = dict['enabled'].__str__()
|
||||||
|
|
||||||
self.file_parser.set(item, 'enabled', enabled)
|
self.file_parser.set(item, 'enabled', enabled)
|
||||||
self.file_parser.set(item, 'implementation', dict['selected_imp'])
|
self.file_parser.set(item, 'implementation', dict['selected_imp'])
|
||||||
self.file_parser.set(item, 'optype', dict['imptype'])
|
self.file_parser.set(item, 'optype', dict['imptype'])
|
||||||
|
|
||||||
for item,dict in self.configuration_dict.iteritems():
|
for item,dict in self.configuration_dict.iteritems():
|
||||||
enabled = dict['enabled'].__str__()
|
enabled = dict['enabled'].__str__()
|
||||||
self.file_parser.set(item, 'enabled', enabled)
|
self.file_parser.set(item, 'enabled', enabled)
|
||||||
|
|
||||||
|
for imp,opt in self.imp2opt_dict.iteritems():
|
||||||
|
if imp != 'none' and 'id' in self.opt_dict[opt]:
|
||||||
|
self.file_parser.set(imp, 'id', self.opt_dict[opt]['id'])
|
||||||
|
|
||||||
with open(self.config_filename,'w') as cfile:
|
with open(self.config_filename,'w') as cfile:
|
||||||
for section in sorted(self.file_parser.sections()):
|
for section in sorted(self.file_parser.sections()):
|
||||||
cfile.write("[%s]\n" % section)
|
cfile.write("[%s]\n" % section)
|
||||||
for option in sorted(self.file_parser.options(section)):
|
for option in sorted(self.file_parser.options(section)):
|
||||||
cfile.write("%s = %s\n" % (option, self.file_parser.get(section, option)))
|
cfile.write("%s = %s\n" % (option, self.file_parser.get(section, option)))
|
||||||
|
|
||||||
cfile.write("\n")
|
cfile.write("\n")
|
||||||
#self.file_parser.write(cfile)
|
#self.file_parser.write(cfile)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user