def RESARE_no_continuation(): return LookupCollection([ Lookup(rules=MSStrCompare.includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22), instruction=SY('INFARE51')), Lookup(rules=MSNoRules(), instruction=SY('RSRDEF51')) ]) @ LookupCollection([ Lookup(instruction=LS('DASH', 2, 'CHMGD'), table='Plain'), Lookup(instruction=LC('CTYARE51'), table='Symbolized') ])
def SYMINS(lookup_type, name): instructions = { 'Point': SY('NEWOBJ01'), 'Line': LC('NEWOBJ01'), 'Area': [SY('NEWOBJ01'), LS('DASH', 2, 'CHMGD')], } return [{ 'rules': MSNoRules(), 'instruction': instructions[lookup_type], }]
def RESARE_continuation_D(): includes = MSStrCompare.includes return LookupCollection([ Lookup(rules=(includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22) | includes('CATREA', 4, 5, 6, 7, 10, 20, 22, 23)), instruction=SY('CTYARE71')), Lookup(instruction=SY('CTYARE51')) ]) @ LookupCollection([ Lookup(instruction=LS('DASH', 2, 'CHMGD'), table='Plain'), Lookup(instruction=LC('CTYARE51'), table='Symbolized') ])
def RESARE_continuation_E(): rule_a = MSStrCompare.includes('CATREA', 1, 8, 9, 12, 14, 18, 19, 21, 24, 25, 26) rule_b = MSStrCompare.includes('CATREA', 4, 5, 6, 7, 10, 20, 22, 23) return LookupCollection([ Lookup(rules=rule_a & rule_b, instruction=SY('CTYARE71')), Lookup(rules=rule_a, instruction=SY('CTYARE51')), Lookup(rules=MSHasValue('CATREA') & rule_b, instruction=SY('INFARE51')), Lookup(instruction=SY('RSRDEF51')) ]) @ LookupCollection([ Lookup(instruction=LS('DASH', 2, 'CHMGD'), table='Plain'), Lookup(instruction=LC('CTYARE51'), table='Symbolized') ])
def RESARE_continuation_C(): includes = MSStrCompare.includes return LookupCollection([ Lookup(rules=(includes('RESTRN', 13, 16, 17, 23, 24, 25, 26, 27) | includes('CATREA', 1, 8, 9, 12, 14, 18, 19, 21, 24, 25, 26)), instruction=SY('FSHRES61')), Lookup(rules=(includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22) | includes('CATREA', 4, 5, 6, 7, 10, 20, 22, 23)), instruction=SY('FSHRES71')), Lookup(instruction=SY('FSHRES51')) ]) @ LookupCollection([ Lookup(instruction=LS('DASH', 2, 'CHMGD'), table='Plain'), Lookup(instruction=LC('FSHRES51'), table='Symbolized') ])
def QUAPNT(lookup_type, name): return [{ 'instruction': SY('LOWACC01'), 'rules': (MSCompare('QUAPOS', '1', MSCompare.OP.GT) & MSCompare('QUAPOS', '10', MSCompare.OP.LT)) }]
def LEGLIN(lookup_type, name): plnspd = TE("'%d kt'", 'plnspd', 3, 2, 2, '15110', 0, 0, 'CHBLK', 50) return [{ 'rules': MSCompare('select', '1') & MSHasValue('plnspd'), 'instruction': [LC('PLNRTE03'), SY('PLNSPD03'), plnspd], }, { 'rules': MSCompare('select', '1'), 'instruction': LC('PLNRTE03'), }, { 'rules': MSHasValue('plnspd'), 'instruction': [LS('DOTT', 2, 'APLRT'), SY('PLNSPD04'), plnspd], }, { 'rules': MSNoRules(), 'instruction': LS('DOTT', 2, 'APLRT'), }]
def TOPMAR(lookup_type, name): if os.environ.get('TOPMAR_FLOAT'): sy_getter = itemgetter(0) else: sy_getter = itemgetter(1) return [{ 'instruction': SY(sy), 'rules': MSCompare('TOPSHP', shp) } for shp, floating, rigid in topshp_to_sy for sy in [sy_getter([floating, rigid])] ] + [{ 'instruction': SY(sy_getter(('TMARDEF2', 'TMARDEF1'))), 'rules': MSHasValue('TOPSHP') }, { 'instruction': SY('QUESMRK1'), 'rules': MSNoRules(), }]
def WRECKS_Point(lookup_type, name): return [{ 'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT), 'instruction': SY('DANGER02') }, { 'rules': MSHasValue('VALSOU'), 'instruction': SY('DANGER01') }, { 'rules': MSCompare('CATWRK', '1') & MSCompare('WATLEV', '3'), 'instruction': SY('WRECKS04') }, { 'rules': MSCompare('CATWRK', '2') & MSCompare('WATLEV', '3'), 'instruction': SY('WRECKS05') }, { 'rules': (MSCompare('CATWRK', '4') | MSCompare('CATWRK', '5') | MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2') | MSCompare('WATLEV', '3') | MSCompare('WATLEV', '4')), 'instruction': SY('WRECKS01') }, { 'rules': MSNoRules(), 'instruction': SY('WRECKS05') }]
def SLCONS(lookup_type, name): return [ { 'instruction': SY('LOWACC01'), 'rules': ( # QUAPOS only has values 1 to 11. QUAPOS not in 1, 10, 11 is # equivalent to the below rules MSCompare('QUAPOS', '1', MSCompare.OP.GT) & MSCompare('QUAPOS', '10', MSCompare.OP.LT)) }, { 'instruction': LC('LOWACC21'), 'rules': ( # QUAPOS only has values 1 to 11. QUAPOS not in 1, 10, 11 is # equivalent to the below rules MSCompare('QUAPOS', '1', MSCompare.OP.GT) & MSCompare('QUAPOS', '10', MSCompare.OP.LT)) }, { 'instruction': LS('DASH', 1, 'CSTLN'), 'rules': MSCompare('CONDTN', '1') | MSCompare('CONDTN', '2') }, { 'instruction': LS('SOLD', 4, 'CSTLN'), 'rules': (MSCompare('CATSLC', '6') | MSCompare('CATSLC', '15') | MSCompare('CATSLC', '16')) }, { 'instruction': LS('DASH', 2, 'CSTLN'), 'rules': MSCompare('WATLEV', '3') | MSCompare('WATLEV', '4') }, { 'instruction': LS('SOLD', 2, 'CSTLN'), 'rules': MSNoRules() } ]
def RESTRN(lookup_type, name): includes = MSStrCompare.includes return [{ 'rules': (includes('RESTRN', 7, 8, 14) & includes('RESTRN', 1, 2, 3, 4, 5, 13, 16, 17, 23, 24, 25, 26, 27)), 'instruction': SY('ENTRES61'), }, { 'rules': (includes('RESTRN', 7, 8, 14) & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)), 'instruction': SY('ENTRES71'), }, { 'rules': includes('RESTRN', 7, 8, 14), 'instruction': SY('ENTRES51'), }, { 'rules': (includes('RESTRN', 1, 2) & includes('RESTRN', 3, 4, 5, 6, 13, 16, 17, 23, 24, 25, 26, 27)), 'instruction': SY('ACHRES61'), }, { 'rules': (includes('RESTRN', 1, 2) & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)), 'instruction': SY('ACHRES71'), }, { 'rules': includes('RESTRN', 1, 2), 'instruction': SY('ACHRES51'), }, { 'rules': (includes('RESTRN', 3, 4, 5, 6, 24) & includes('RESTRN', 13, 16, 17, 23, 25, 26, 27)), 'instruction': SY('FHSRES61') }, { 'rules': (includes('RESTRN', 3, 4, 5, 6, 24) & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)), 'instruction': SY('FHSRES71'), }, { 'rules': includes('RESTRN', 3, 4, 5, 6, 24), 'instruction': SY('FHSRES51'), }, { 'rules': (includes('RESTRN', 13, 16, 17, 23, 25, 26, 27) & includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22)), 'instruction': SY('CTYARE71'), }, { 'rules': includes('RESTRN', 13, 16, 17, 23, 25, 26, 27), 'instruction': SY('CTYARE51'), }, { 'rules': includes('RESTRN', 9, 10, 11, 12, 15, 18, 19, 20, 21, 22), 'instruction': SY('INFARE51'), }, { 'rules': MSNoRules(), 'instruction': SY('RSRDEF51'), }]
def OWNSHP(lookuptype, name): return [{'rules': MSNoRules(), 'instruction': SY('OWNSHP01')}]
def OBSTRN_point(name): common_rule = [{ 'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT), 'instruction': SY('DANGER02') }] if name == 'UWTROC': return common_rule + [{ 'rules': (MSHasValue('VALSOU') & (MSCompare('WATLEV', '4') | MSCompare('WATLEV', '5'))), 'instruction': SY('UWTROC04') }, { 'rules': MSHasValue('VALSOU'), 'instruction': SY('DANGER01') }, { 'rules': MSCompare('WATLEV', '3'), 'instruction': SY('UWTROC03') }, { 'rules': MSNoRules(), 'instruction': SY('UWTROC04') }] else: return common_rule + [ { 'rules': MSHasValue('VALSOU') & MSCompare('CATOBS', '6'), 'instruction': SY('DANGER01') }, { 'rules': (MSHasValue('VALSOU') & (MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'))), 'instruction': SY('OBSTRN11') }, { 'rules': (MSHasValue('VALSOU') & (MSCompare('WATLEV', '4') | MSCompare('WATLEV', '5'))), 'instruction': SY('DANGER03') }, { 'rules': MSHasValue('VALSOU'), 'instruction': SY('DANGER01') }, { 'rules': MSCompare('CATOBS', '6'), 'instruction': SY('OBSTRN01') }, { 'rules': MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'), 'instruction': SY('OBSTRN11') }, { 'rules': MSCompare('WATLEV', '4') | MSCompare('WATLEV', '5'), 'instruction': SY('OBSTRN03') }, { 'rules': MSNoRules(), 'instruction': SY('OBSTRN01') } ]
def LIGHTS(lookup_type, name): return [ { 'instruction': SY('LIGHTS82'), 'rules': MSCompare('CATLIT', '11') | MSCompare('CATLIT', '8'), }, { 'instruction': SY('LIGHTS81'), 'rules': MSCompare('CATLIT', '9'), }, { 'instruction': SY('LIGHTS81'), 'rules': ((MSCompare('CATLIT', '1') | MSCompare('CATLIT', '16')) & MSCompare('ORIENT', 'null')), }, { 'instruction': SY('LIGHTS81'), 'rules': MSCompare('CATLIT', '1') | MSCompare('CATLIT', '16'), }, { 'instruction': [], 'rules': (MSCompare('VALNMR', '10', MSCompare.OP.LT) & MSRawFilter('NOT ("[CATLIT]" ~ "5" OR "[CATLIT]" ~ "6")') & MSCompare('LITCHR', '12', MSCompare.OP.NE)), }, { # TODO: Figure out why a simple SY instruction ends up with a bad # offset 'instruction': _MS(''' STYLE SYMBOL 'LIGHTS11' OFFSET 9 9 END'''), 'rules': MSCompare('COLOUR', '3,1') | MSCompare('COLOUR', '3'), }, { 'instruction': _MS(''' STYLE SYMBOL 'LIGHTS12' OFFSET 9 9 END'''), 'rules': MSCompare('COLOUR', '4,1') | MSCompare('COLOUR', '4') }, { 'instruction': _MS(''' STYLE SYMBOL 'LIGHTS13' OFFSET 9 9 END'''), 'rules': (MSCompare('COLOUR', '11') | MSCompare('COLOUR', '6') | MSCompare('COLOUR', '1')), } ]