@@ -139,6 +139,7 @@ def __init__(self, pdef=None, model=None, group=None, model_offset=0, data=None,
139
139
self .read_func_arg = None # the argument passed to the read_func
140
140
self .write_func = None # function to be called on write
141
141
self .write_func_arg = None # the argument passed to the write_func
142
+ self .static = None
142
143
143
144
if pdef :
144
145
self .sf_required = (pdef .get (mdef .SF ) is not None )
@@ -158,6 +159,10 @@ def __init__(self, pdef=None, model=None, group=None, model_offset=0, data=None,
158
159
if data is not None :
159
160
self ._set_data (data = data , offset = data_offset )
160
161
162
+ static = pdef .get ('static' , None )
163
+ if static and static == 'S' :
164
+ self .static = True
165
+
161
166
def __str__ (self ):
162
167
return self .disp ()
163
168
@@ -203,7 +208,7 @@ def get_value(self, computed=False):
203
208
v = self ._value
204
209
if computed and v is not None :
205
210
if self .sf_required :
206
- if self .sf_value is None :
211
+ if self .sf_value is None or not self . static :
207
212
if self .sf :
208
213
sf = self .group .points .get (self .sf )
209
214
if sf is None :
@@ -224,7 +229,7 @@ def set_value(self, data=None, computed=False, dirty=None):
224
229
self .dirty = dirty
225
230
if computed :
226
231
if self .sf_required :
227
- if self .sf_value is None :
232
+ if self .sf_value is None or not self . static :
228
233
if self .sf :
229
234
sf = self .group .points .get (self .sf )
230
235
if sf is None :
@@ -263,7 +268,7 @@ def get_mb(self, computed=False):
263
268
data = err = None
264
269
if computed and v is not None :
265
270
if self .sf_required :
266
- if self .sf_value is None :
271
+ if self .sf_value is None or not self . static :
267
272
if self .sf :
268
273
sf = self .group .points .get (self .sf )
269
274
if sf is None :
@@ -409,32 +414,10 @@ def __init__(self, gdef=None, model=None, model_offset=0, group_len=0, data=None
409
414
410
415
# check if group fits in access region
411
416
if self .len > ACCESS_REGION_REGS :
412
- if self .points_len > ACCESS_REGION_REGS :
413
- index = 0
414
- count = 0
415
- for p , point in self .points .items ():
416
- if count + point .len > ACCESS_REGION_REGS :
417
- self .access_regions .append ((index , count ))
418
- index = count
419
- count = 0
420
- count += point .len
421
- if count > 0 :
422
- self .access_regions .append ((index , count ))
423
- else :
424
- self .access_regions .append ((0 , self .points_len ))
425
- groups_len = self .len - self .points_len
426
- if groups_len > ACCESS_REGION_REGS :
427
- for g , group in self .groups .items ():
428
- if isinstance (group , list ) and len (group ) > 0 :
429
- glen = group [0 ].len
430
- if glen > ACCESS_REGION_REGS :
431
- raise ModelError ('Nested groups too big' )
432
- index = self .points_len
433
- for i in range (len (group )):
434
- self .access_regions .append ((index , glen ))
435
- index += glen
436
- elif group .len > ACCESS_REGION_REGS :
437
- raise ModelError ('Nested single group too big' )
417
+ index , count = self ._init_access (self .access_regions , index = 0 , count = 0 )
418
+ # add last region if pending
419
+ if count > 0 :
420
+ self .access_regions .append ((index , count ))
438
421
439
422
len_point = self .points .get ('L' )
440
423
if len_point :
@@ -446,6 +429,26 @@ def __init__(self, gdef=None, model=None, model_offset=0, group_len=0, data=None
446
429
if id_val :
447
430
id_point .set_value (id_point .pdef ['value' ])
448
431
432
+ def _init_access (self , access_regions , index , count ):
433
+ # add points
434
+ if self .points :
435
+ for p , point in self .points .items ():
436
+ if count + point .len > ACCESS_REGION_REGS :
437
+ access_regions .append ((index , count ))
438
+ index += count
439
+ count = 0
440
+ count += point .len
441
+ # add groups
442
+ if self .groups :
443
+ for g , groups in self .groups .items ():
444
+ if isinstance (groups , list ) and len (groups ) > 0 :
445
+ for group in groups :
446
+ index , count = group ._init_access (access_regions , index , count )
447
+ elif groups .len > ACCESS_REGION_REGS :
448
+ index , count = groups ._init_access (access_regions , index , count )
449
+
450
+ return index , count
451
+
449
452
def __getattr__ (self , attr ):
450
453
v = self .points .get (attr )
451
454
if v is None :
0 commit comments