@@ -22,67 +22,54 @@ def on_update(value):
2222def on_update_name (value , name ):
2323 print ('on_update' , name , ':' , repr (value ))
2424
25- t_ai = aIn ('AI' , initial_value = 12.34 )
26- t_boolin = boolIn ('BOOLIN' , 'True' , 'False' , initial_value = False )
27- t_longin = longIn ('LONGIN' , initial_value = 33 )
28- t_stringin = stringIn ('STRINGIN' , initial_value = "Testing string" )
29- t_mbbi = mbbIn (
30- 'MBBI' , ('One' , alarm .MAJOR_ALARM ), 'Two' , ('Three' , "MINOR" ),
31- initial_value = 2 )
32-
33- t_ao = aOut ('AO' , initial_value = 12.45 , on_update_name = on_update_name )
34- t_boolout = boolOut (
35- 'BOOLOUT' , 'Zero' , 'One' , initial_value = True , on_update = on_update )
36- t_longout = longOut ('LONGOUT' , initial_value = 2008 , on_update = on_update )
37- t_stringout = stringOut (
38- 'STRINGOUT' , initial_value = 'watevah' , on_update = on_update )
39- t_mbbo = mbbOut (
40- 'MBBO' , 'Ein' , 'Zwei' , 'Drei' , initial_value = 1 )
41-
42- def update_sin_wf (value ):
43- print ('update_sin_wf' , value )
44- sin_wf .set (numpy .sin (
45- numpy .linspace (0 , 2 * numpy .pi * sin_ph .get (), sin_len .get ())))
46- sin_wf = Waveform ('SIN' , datatype = float , length = 1024 )
47- # Check we can update its value before iocInit as per #22
48- sin_wf .set ([1 , 2 , 3 ])
49- sin_len = longOut (
50- 'SINN' , 0 , 1024 , initial_value = 1024 , on_update = update_sin_wf )
51- sin_ph = aOut ('SINP' , initial_value = 0.0 , on_update = update_sin_wf )
52-
53-
54- wf_len = 32
55- wf = numpy .sin (numpy .linspace (0 , 2 * numpy .pi , wf_len ))
56- t_waveform_in = Waveform ('WAVEFORM' , wf )
57- t_waveform_out = WaveformOut ('WAVEFORM_OUT' , wf , on_update = on_update )
58- t_waveform_in2 = Waveform ('WAVEFORM2' , length = 10 )
59-
60- t_longstring_in = longStringIn ('LONGSTRING' , length = 256 )
61-
62-
63- def Update ():
64- t_ai .set (3.14159 )
65- t_boolin .set (True )
66- t_longin .set (365 )
67- t_stringin .set ('Another different string' )
68- t_mbbi .set (0 )
69-
70- def UpdateOut ():
71- t_ao .set (3.14159 )
72- t_boolout .set (True )
73- t_longout .set (365 )
74- t_stringout .set ('Another different string' )
75- t_mbbo .set (2 )
25+ # The publicly accessible records.
26+ t_ai = None
27+ t_ao = None
28+
29+ def create_records ():
30+ global t_ai , t_ao
31+
32+ t_ai = aIn ('AI' , initial_value = 12.34 )
33+
34+ boolIn ('BOOLIN' , 'True' , 'False' , initial_value = False )
35+ longIn ('LONGIN' , initial_value = 33 )
36+ stringIn ('STRINGIN' , initial_value = "Testing string" )
37+ mbbIn (
38+ 'MBBI' , ('One' , alarm .MAJOR_ALARM ), 'Two' , ('Three' , "MINOR" ),
39+ initial_value = 2 )
40+
41+ t_ao = aOut ('AO' , initial_value = 12.45 , on_update_name = on_update_name )
42+
43+ boolOut ('BOOLOUT' , 'Zero' , 'One' , initial_value = True , on_update = on_update )
44+ longOut ('LONGOUT' , initial_value = 2008 , on_update = on_update )
45+ stringOut ('STRINGOUT' , initial_value = 'watevah' , on_update = on_update )
46+ mbbOut ('MBBO' , 'Ein' , 'Zwei' , 'Drei' , initial_value = 1 )
47+
48+ def update_sin_wf (value ):
49+ print ('update_sin_wf' , value )
50+ sin_wf .set (numpy .sin (
51+ numpy .linspace (0 , 2 * numpy .pi * sin_ph .get (), sin_len .get ())))
52+ sin_wf = Waveform ('SIN' , datatype = float , length = 1024 )
53+ # Check we can update its value before iocInit as per #22
54+ sin_wf .set ([1 , 2 , 3 ])
55+ sin_len = longOut (
56+ 'SINN' , 0 , 1024 , initial_value = 1024 , on_update = update_sin_wf )
57+ sin_ph = aOut ('SINP' , initial_value = 0.0 , on_update = update_sin_wf )
58+
59+
60+ wf_len = 32
61+ wf = numpy .sin (numpy .linspace (0 , 2 * numpy .pi , wf_len ))
62+ Waveform ('WAVEFORM' , wf )
63+ WaveformOut ('WAVEFORM_OUT' , wf , on_update = on_update )
64+ Waveform ('WAVEFORM2' , length = 10 )
65+
66+ longStringIn ('LONGSTRING' , length = 256 )
67+
68+ create_records ()
7669
7770softioc .devIocStats (ioc_name )
7871
79- __all__ = [
80- 't_ai' , 't_boolin' , 't_longin' , 't_stringin' , 't_mbbi' ,
81- 't_ao' , 't_boolout' , 't_longout' , 't_stringout' , 't_mbbo' ,
82- 't_waveform_in' , 't_waveform_in2' , 't_waveform_out' , 't_longstring_in' ,
83- 'wf_len' ,
84- 'Update' , 'UpdateOut'
85- ]
72+ __all__ = ['t_ai' , 't_ao' , ]
8673
8774if __name__ == "__main__" :
8875 WriteRecords ("expected_records.db" )
0 commit comments