Skip to content

Commit 5912a78

Browse files
author
srubio
committed
Port to SimulatorDS
1 parent 7952f0c commit 5912a78

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

gen_simulation.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,36 +200,35 @@ def create_simulators(filein,instance='',path='',domains={},tango_host='controls
200200
print('>'*80)
201201

202202
for d,t in sorted(devs.items()):
203-
klass = 'PyStateComposer' if t.dev_class == 'PyStateComposer' else 'PySignalSimulator'
204-
server = 'DynamicServer'
205-
print(('%s/%s'%(server,instance),server,d))
203+
t.dev_class = t.dev_class or d.split('/')[-1]
204+
klass = 'PyStateComposer' if t.dev_class == 'PyStateComposer' else 'SimulatorDS'
205+
server = 'DynamicDS'
206+
print(('%s/%s'%(server,instance+'-'+t.dev_class),server,d))
206207
its_new = ('/'.join(('dserver',server,instance))).lower() not in all_devs or d.lower() not in all_devs
207-
if its_new:
208-
print('creating ...')
209-
fandango.tango.add_new_device('%s/%s'%(server,instance),klass,d)
210208

211209
if its_new or override:
210+
print('writing ... %s(%s)'%(type(t),d))
211+
fandango.tango.add_new_device('%s/%s-%s'%(server,instance,t.dev_class),klass,d)
212212
for p,v in t.props.items():
213213
if not p.startswith('__'): #p not in ('DynamicCommands','DynamicStates','LoadFromFile','DevicesList') and
214214
fandango.tango.put_device_property(d,p,v)
215215
#Overriding Dynamic* properties
216216
try:
217217
fandango.tango.put_device_property(d,'LoadFromFile',path+'%s_attributes.txt'%t.dev_class)
218-
except: traceback.print_exc()
219-
try:
220218
fandango.tango.put_device_property(d,'DynamicAttributes',filter(bool,map(str.strip,open(path+'%s_attributes.txt'%t.dev_class).readlines())))
221-
except: traceback.print_exc()
222-
try:
223219
fandango.tango.put_device_property(d,'DynamicCommands',filter(bool,map(str.strip,open(path+'%s_commands.txt'%t.dev_class).readlines())))
224-
except: traceback.print_exc()
225-
try:
226220
fandango.tango.put_device_property(d,'DynamicStates',filter(bool,map(str.strip,open(path+'%s_states.txt'%t.dev_class).readlines())))
227-
except: traceback.print_exc()
221+
except:
222+
print('Unable to configure %s(%s) properties '%(d,t.dev_class))
223+
#traceback.print_exc()
228224

229225
fandango.tango.put_device_property(d,'OFFSET',random.randint(0,len(devs)))
230226
done.append(d)
231227

228+
exported = fandango.get_all_devices(exported=True)
229+
print('Checking Devices ...')
232230
for d in done:
231+
if d not in exported: continue
233232
if fandango.check_device(d):
234233
print('Updating %s ...'%d)
235234
try: fandango.get_device(d).updateDynamicAttributes()
@@ -241,7 +240,7 @@ def create_simulators(filein,instance='',path='',domains={},tango_host='controls
241240
def run_dynamic_server(instance):
242241
print('run_dynamic_server:'+str(instance))
243242
from fandango.dynamic import DynamicServer
244-
sys.argv = ['DynamicServer.py',instance,'-v2']
243+
sys.argv = ['DynamicDS.py',instance,'-v2']
245244
print(sys.argv)
246245
pyds = DynamicServer(add_debug=False)
247246
pyds.main()
@@ -272,7 +271,7 @@ def set_push_events(filein,period=3000,diff=1e-5):
272271
def delete_simulators(filein):
273272
#NOTE THIS METHOD SHOUL DELETE ONLY PYSIGNALSIMULATOR INSTANCES, NOT ANYTHING ELSE!
274273
raise 'NotImplementedYet!'
275-
all_sims = fandango.Astor('Py*Simulator/*').get_all_devices()
274+
all_sims = fandango.Astor('*Simulator*/*').get_all_devices()
276275
devs = [d for d in pickle.load(open(filein)) if d in all_sims]
277276
db = PyTango.Database()
278277
for d in devs:
@@ -321,4 +320,4 @@ def main(args):
321320
import sys
322321
args = sys.argv[1:]
323322
main(args)
324-
323+

0 commit comments

Comments
 (0)