asterix: adjust to upstream change
Structure change in asterix-specs, revision 3ab3bb3. Rule type is generalized and it now also includes a default value.
This commit is contained in:
parent
e0300eaed8
commit
33c9657365
|
@ -9,7 +9,7 @@ See tools/asterix/README.md for details.
|
|||
|
||||
Data source:
|
||||
https://zoranbosnjak.github.io/asterix-specs
|
||||
git revision: 941f5ce71b19d4659401e84b83b084505dd53e28
|
||||
git revision: 3ab3bb3445a27e0a96636ad8f8c8e3134870511c
|
||||
|
||||
|
||||
*/
|
||||
|
@ -4603,8 +4603,8 @@ static const AsterixField I004_V1_12_120_CN = { FX, 1, 0, 0, &hf_004_V1_12_120_C
|
|||
static int hf_004_V1_12_120_CC;
|
||||
static int hf_004_V1_12_120_CC_TID;
|
||||
static const FieldPart I004_V1_12_120_CC_TID = { 4, 1.0, FIELD_PART_HEX, &hf_004_V1_12_120_CC_TID, NULL };
|
||||
static int hf_004_V1_12_120_CC_CP;
|
||||
static const FieldPart I004_V1_12_120_CC_CP = { 3, 1.0, FIELD_PART_HEX, &hf_004_V1_12_120_CC_CP, NULL };
|
||||
static int hf_004_V1_12_120_CC_CPC;
|
||||
static const FieldPart I004_V1_12_120_CC_CPC = { 3, 1.0, FIELD_PART_HEX, &hf_004_V1_12_120_CC_CPC, NULL };
|
||||
static int hf_004_V1_12_120_CC_CS;
|
||||
static const value_string valstr_004_V1_12_120_CC_CS[] = {
|
||||
{ 0, "LOW" },
|
||||
|
@ -4614,7 +4614,7 @@ static const value_string valstr_004_V1_12_120_CC_CS[] = {
|
|||
static const FieldPart I004_V1_12_120_CC_CS = { 1, 1.0, FIELD_PART_UINT, &hf_004_V1_12_120_CC_CS, NULL };
|
||||
static const FieldPart *I004_V1_12_120_CC_PARTS[] = {
|
||||
&I004_V1_12_120_CC_TID,
|
||||
&I004_V1_12_120_CC_CP,
|
||||
&I004_V1_12_120_CC_CPC,
|
||||
&I004_V1_12_120_CC_CS,
|
||||
NULL
|
||||
};
|
||||
|
@ -5796,8 +5796,8 @@ static const AsterixField I004_120_CN = { FX, 1, 0, 0, &hf_004_120_CN, I004_120_
|
|||
static int hf_004_120_CC;
|
||||
static int hf_004_120_CC_TID;
|
||||
static const FieldPart I004_120_CC_TID = { 4, 1.0, FIELD_PART_HEX, &hf_004_120_CC_TID, NULL };
|
||||
static int hf_004_120_CC_CP;
|
||||
static const FieldPart I004_120_CC_CP = { 3, 1.0, FIELD_PART_HEX, &hf_004_120_CC_CP, NULL };
|
||||
static int hf_004_120_CC_CPC;
|
||||
static const FieldPart I004_120_CC_CPC = { 3, 1.0, FIELD_PART_HEX, &hf_004_120_CC_CPC, NULL };
|
||||
static int hf_004_120_CC_CS;
|
||||
static const value_string valstr_004_120_CC_CS[] = {
|
||||
{ 0, "LOW" },
|
||||
|
@ -5807,7 +5807,7 @@ static const value_string valstr_004_120_CC_CS[] = {
|
|||
static const FieldPart I004_120_CC_CS = { 1, 1.0, FIELD_PART_UINT, &hf_004_120_CC_CS, NULL };
|
||||
static const FieldPart *I004_120_CC_PARTS[] = {
|
||||
&I004_120_CC_TID,
|
||||
&I004_120_CC_CP,
|
||||
&I004_120_CC_CPC,
|
||||
&I004_120_CC_CS,
|
||||
NULL
|
||||
};
|
||||
|
@ -56683,7 +56683,7 @@ void proto_register_asterix (void)
|
|||
{ &hf_004_V1_12_120_CN_AIW, { "AIW", "asterix.004_V1_12_120_CN_AIW", FT_UINT8, BASE_DEC, VALS (valstr_004_V1_12_120_CN_AIW), 0x04, NULL, HFILL } },
|
||||
{ &hf_004_V1_12_120_CC, { "CC, Conflict Classification", "asterix.004_V1_12_120_CC", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
|
||||
{ &hf_004_V1_12_120_CC_TID, { "TID, Identification of Conflict Categories Definition Table", "asterix.004_V1_12_120_CC_TID", FT_UINT8, BASE_DEC, NULL, 0xf0, NULL, HFILL } },
|
||||
{ &hf_004_V1_12_120_CC_CP, { "CP, Conflict Properties Class", "asterix.004_V1_12_120_CC_CP", FT_UINT8, BASE_DEC, NULL, 0x0e, NULL, HFILL } },
|
||||
{ &hf_004_V1_12_120_CC_CPC, { "CPC, Conflict Properties Class", "asterix.004_V1_12_120_CC_CPC", FT_UINT8, BASE_DEC, NULL, 0x0e, NULL, HFILL } },
|
||||
{ &hf_004_V1_12_120_CC_CS, { "CS, Conflict Severity", "asterix.004_V1_12_120_CC_CS", FT_UINT8, BASE_DEC, VALS (valstr_004_V1_12_120_CC_CS), 0x01, NULL, HFILL } },
|
||||
{ &hf_004_V1_12_120_CP, { "CP, Conflict Probability", "asterix.004_V1_12_120_CP", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
|
||||
{ &hf_004_V1_12_120_CP_VALUE, { "Conflict Probability, [%]", "asterix.004_V1_12_120_CP_VALUE", FT_DOUBLE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
|
||||
|
@ -56880,7 +56880,7 @@ void proto_register_asterix (void)
|
|||
{ &hf_004_120_CN_AIW, { "AIW", "asterix.004_120_CN_AIW", FT_UINT8, BASE_DEC, VALS (valstr_004_120_CN_AIW), 0x04, NULL, HFILL } },
|
||||
{ &hf_004_120_CC, { "CC, Conflict Classification", "asterix.004_120_CC", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
|
||||
{ &hf_004_120_CC_TID, { "TID, Identification of Conflict Categories Definition Table", "asterix.004_120_CC_TID", FT_UINT8, BASE_DEC, NULL, 0xf0, NULL, HFILL } },
|
||||
{ &hf_004_120_CC_CP, { "CP, Conflict Properties Class", "asterix.004_120_CC_CP", FT_UINT8, BASE_DEC, NULL, 0x0e, NULL, HFILL } },
|
||||
{ &hf_004_120_CC_CPC, { "CPC, Conflict Properties Class", "asterix.004_120_CC_CPC", FT_UINT8, BASE_DEC, NULL, 0x0e, NULL, HFILL } },
|
||||
{ &hf_004_120_CC_CS, { "CS, Conflict Severity", "asterix.004_120_CC_CS", FT_UINT8, BASE_DEC, VALS (valstr_004_120_CC_CS), 0x01, NULL, HFILL } },
|
||||
{ &hf_004_120_CP, { "CP, Conflict Probability", "asterix.004_120_CP", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
|
||||
{ &hf_004_120_CP_VALUE, { "Conflict Probability, [%]", "asterix.004_120_CP_VALUE", FT_DOUBLE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
|
||||
|
|
|
@ -261,14 +261,12 @@ def reference(cat, edition, path):
|
|||
return('{:03d}_{}'.format(cat, name))
|
||||
return('{:03d}_V{}_{}_{}'.format(cat, edition['major'], edition['minor'], name))
|
||||
|
||||
def get_content(rule):
|
||||
def get_rule(rule):
|
||||
t = rule['type']
|
||||
# Most cases are 'ContextFree', use as specified.
|
||||
if t == 'ContextFree':
|
||||
return rule['content']
|
||||
# Handle 'Dependent' contents as 'Raw'.
|
||||
return rule['value']
|
||||
elif t == 'Dependent':
|
||||
return {'type': "Raw"}
|
||||
return rule['default']
|
||||
else:
|
||||
raise Exception('unexpected type: {}'.format(t))
|
||||
|
||||
|
@ -277,7 +275,7 @@ def get_bit_size(item):
|
|||
if item['spare']:
|
||||
return item['length']
|
||||
else:
|
||||
return item['variation']['size']
|
||||
return get_rule(item['rule'])['size']
|
||||
|
||||
def get_description(item, content=None):
|
||||
"""Return item description."""
|
||||
|
@ -300,12 +298,18 @@ def generate_group(item, variation=None):
|
|||
level2['is_generated'] = True
|
||||
if variation is None:
|
||||
level1 = copy(item)
|
||||
level1['variation'] = {
|
||||
'type': 'Group',
|
||||
'items': [level2],
|
||||
level1['rule'] = {
|
||||
'type': 'ContextFree',
|
||||
'value': {
|
||||
'type': 'Group',
|
||||
'items': [level2],
|
||||
},
|
||||
}
|
||||
else:
|
||||
level2['variation'] = variation['variation']
|
||||
level2['rule'] = {
|
||||
'type': 'ContextFree',
|
||||
'value': variation,
|
||||
}
|
||||
level1 = {
|
||||
'type': "Group",
|
||||
'items': [level2],
|
||||
|
@ -317,15 +321,18 @@ def is_generated(item):
|
|||
|
||||
def ungroup(item):
|
||||
"""Convert group of items of known size to element"""
|
||||
n = sum([get_bit_size(i) for i in item['variation']['items']])
|
||||
n = sum([get_bit_size(i) for i in get_rule(item['rule'])['items']])
|
||||
result = copy(item)
|
||||
result['variation'] = {
|
||||
'rule': {
|
||||
'content': {'type': 'Raw'},
|
||||
'type': 'ContextFree',
|
||||
result['rule'] = {
|
||||
'type': 'ContextFree',
|
||||
'value': {
|
||||
'type': 'Element',
|
||||
'size': n,
|
||||
'rule': {
|
||||
'type': 'ContextFree',
|
||||
'value': {'type': 'Raw'},
|
||||
},
|
||||
},
|
||||
'size': n,
|
||||
'type': 'Element',
|
||||
}
|
||||
return result
|
||||
|
||||
|
@ -363,7 +370,7 @@ def part1(ctx, get_ref, catalogue):
|
|||
if t == 'Element':
|
||||
tell('static int hf_{};'.format(ref))
|
||||
n = variation['size']
|
||||
content = get_content(variation['rule'])
|
||||
content = get_rule(variation['rule'])
|
||||
scaling = get_scaling(content)
|
||||
scaling = scaling if scaling is not None else 1.0
|
||||
fp = get_fieldpart(content)
|
||||
|
@ -421,8 +428,8 @@ def part1(ctx, get_ref, catalogue):
|
|||
if i is None:
|
||||
items.append(i)
|
||||
continue
|
||||
if i.get('variation') is not None:
|
||||
if i['variation']['type'] == 'Group':
|
||||
if i.get('rule') is not None:
|
||||
if get_rule(i['rule'])['type'] == 'Group':
|
||||
i = ungroup(i)
|
||||
items.append(i)
|
||||
|
||||
|
@ -456,7 +463,7 @@ def part1(ctx, get_ref, catalogue):
|
|||
|
||||
# Group is required below this item.
|
||||
if variation['variation']['type'] == 'Element':
|
||||
subvar = generate_group(item, variation)
|
||||
subvar = generate_group(item, variation['variation'])
|
||||
else:
|
||||
subvar = variation['variation']
|
||||
handle_variation(path, subvar)
|
||||
|
@ -489,7 +496,7 @@ def part1(ctx, get_ref, catalogue):
|
|||
comp += ' &IX_SPARE,'
|
||||
continue
|
||||
# Group is required below this item.
|
||||
if i['variation']['type'] == 'Element':
|
||||
if get_rule(i['rule'])['type'] == 'Element':
|
||||
subitem = generate_group(i)
|
||||
else:
|
||||
subitem = i
|
||||
|
@ -509,30 +516,36 @@ def part1(ctx, get_ref, catalogue):
|
|||
return
|
||||
|
||||
# Group is required on the first level.
|
||||
if path == [] and item['variation']['type'] == 'Element':
|
||||
variation = generate_group(item)['variation']
|
||||
if path == [] and get_rule(item['rule'])['type'] == 'Element':
|
||||
variation = get_rule(generate_group(item)['rule'])
|
||||
else:
|
||||
variation = item['variation']
|
||||
variation = get_rule(item['rule'])
|
||||
handle_variation(path + [item['name']], variation)
|
||||
|
||||
for item in catalogue:
|
||||
# adjust 'repetitive fx' item
|
||||
if item['variation']['type'] == 'Repetitive' and item['variation']['rep']['type'] == 'Fx':
|
||||
var = item['variation']['variation'].copy()
|
||||
if get_rule(item['rule'])['type'] == 'Repetitive' and get_rule(item['rule'])['rep']['type'] == 'Fx':
|
||||
var = get_rule(item['rule'])['variation'].copy()
|
||||
if var['type'] != 'Element':
|
||||
raise Exception("Expecting 'Element'")
|
||||
item = item.copy()
|
||||
item['variation'] = {
|
||||
'type': 'Extended',
|
||||
'items': [{
|
||||
'definition': None,
|
||||
'description': None,
|
||||
'name': 'Subitem',
|
||||
'remark': None,
|
||||
'spare': False,
|
||||
'title': 'Subitem',
|
||||
'variation': var,
|
||||
item['rule'] = {
|
||||
'type': 'ContextFree',
|
||||
'value': {
|
||||
'type': 'Extended',
|
||||
'items': [{
|
||||
'definition': None,
|
||||
'description': None,
|
||||
'name': 'Subitem',
|
||||
'remark': None,
|
||||
'spare': False,
|
||||
'title': 'Subitem',
|
||||
'rule': {
|
||||
'type': 'ContextFree',
|
||||
'value': var,
|
||||
},
|
||||
}, None]
|
||||
}
|
||||
}
|
||||
handle_item([], item)
|
||||
tell('')
|
||||
|
@ -647,7 +660,7 @@ def remove_rfs(spec):
|
|||
catalogue = [] # create new catalogue without RFS
|
||||
rfs_items = []
|
||||
for i in spec['catalogue']:
|
||||
if i['variation']['type'] == 'Rfs':
|
||||
if get_rule(i['rule'])['type'] == 'Rfs':
|
||||
rfs_items.append(i['name'])
|
||||
else:
|
||||
catalogue.append(i)
|
||||
|
@ -680,7 +693,7 @@ def is_valid(spec):
|
|||
def check_item(item):
|
||||
if item['spare']:
|
||||
return True
|
||||
return check_variation(item['variation'])
|
||||
return check_variation(get_rule(item['rule']))
|
||||
def check_variation(variation):
|
||||
t = variation['type']
|
||||
if t == 'Element':
|
||||
|
@ -744,13 +757,15 @@ def main():
|
|||
for spec in jsons:
|
||||
is_latest = spec['edition'] == latest_editions[spec['number']]
|
||||
|
||||
ctx.tell('insert1', '/* Category {:03d}, edition {}.{} */'.format(spec['number'], spec['edition']['major'], spec['edition']['minor']))
|
||||
ctx.tell('insert1', '/* Category {:03d}, edition {}.{} */'.format(
|
||||
spec['number'], spec['edition']['major'], spec['edition']['minor']))
|
||||
|
||||
# handle part1
|
||||
get_ref = lambda path: reference(spec['number'], spec['edition'], path)
|
||||
part1(ctx, get_ref, spec['catalogue'])
|
||||
if is_latest:
|
||||
ctx.tell('insert1', '/* Category {:03d}, edition {}.{} (latest) */'.format(spec['number'], spec['edition']['major'], spec['edition']['minor']))
|
||||
ctx.tell('insert1', '/* Category {:03d}, edition {}.{} (latest) */'.format(
|
||||
spec['number'], spec['edition']['major'], spec['edition']['minor']))
|
||||
get_ref = lambda path: reference(spec['number'], None, path)
|
||||
part1(ctx, get_ref, spec['catalogue'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue