Пример #1
0
def QUAPNT(lookup_type, name):
    return [{
        'instruction':
        SY('LOWACC01'),
        'rules': (MSCompare('QUAPOS', '1', MSCompare.OP.GT)
                  & MSCompare('QUAPOS', '10', MSCompare.OP.LT))
    }]
Пример #2
0
def DEPARE(lookup_type, name):

    # These values are normally passed by the mariner
    # safety_contour = 10
    # shallow_contour = 20
    # deep_contour = 30

    # Basic implementation of DEPARE constructed symbol.
    # We are missing all the line and fill symbology
    return [{
        'instruction': AC('DEPIT'),
        'rules': MSCompare('DRVAL2', '0', MSCompare.OP.LE),
    }, {
        'instruction': AC('DEPVS'),
        'rules': MSCompare('DRVAL2', '10', MSCompare.OP.LT),
    }, {
        'instruction': AC('DEPMS'),
        'rules': MSCompare('DRVAL2', '20', MSCompare.OP.LT),
    }, {
        'instruction': AC('DEPMD'),
        'rules': MSCompare('DRVAL2', '30', MSCompare.OP.LT),
    }, {
        'instruction': AC('DEPDW'),
        'rules': MSNoRules(),
    }]
Пример #3
0
def QUALIN(lookuptype, name):
    common_rule = [{
        '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))
    }]

    if name == 'COALNE':
        return common_rule + [{
            'instruction': LS('SOLD', 1, 'CSTLN'),
            'rules': MSNoRules()
        }]
    else:
        return common_rule + [
            {
                'instruction':
                [LS('SOLD', 3, 'CHMGF'),
                 LS('SOLD', 1, 'CSTLN')],
                'rules': MSCompare('CONRAD', '1')
            },
            {
                # CONRAD missing and CONRAD != 1 both lead here
                'instruction': LS('SOLD', 1, 'CSTLN'),
                'rules': MSNoRules()
            }
        ]
Пример #4
0
def DEPCNT(lookup_type, name):
    return [{
        'rules': (MSCompare('QUAPOS', '1', MSCompare.OP.GT)
                  & MSCompare('QUAPOS', '10', MSCompare.OP.LT)),
        'instruction':
        LS('DASH', 1, 'DEPCN'),
    }, {
        'rules': MSNoRules(),
        'instruction': LS('SOLD', 1, 'DEPCN'),
    }]
Пример #5
0
def WRECKS_other(lookup_type, name):
    # TODO: add rules for background
    return [{
        'rules': (MSCompare('QUAPOS', '1', MSCompare.OP.GT)
                  & MSCompare('QUAPOS', '10', MSCompare.OP.LT)),
        'instruction':
        LC('LOWACC41')
    }, {
        'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
        'instruction': LS('DASH', 2, 'CHBLK')
    }, {
        'rules': MSHasValue('VALSOU'),
        'instruction': LS('DOTT', 2, 'CHBLK')
    }, {
        'rules': MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'),
        'instruction': [LS('SOLD', 2, 'CSTLN'),
                        AC('CHBRN')]
    }, {
        'rules': MSCompare('WATLEV', '4'),
        'instruction': [LS('DASH', 2, 'CSTLN'),
                        AC('DEPIT')]
    }, {
        'rules': MSCompare('WATLEV', '3') | MSCompare('WATLEV', '5'),
        'instruction': [LS('DOTT', 2, 'CSTLN'),
                        AC('DEPVS')]
    }, {
        'rules': MSNoRules(),
        'instruction': [LS('DOTT', 2, 'CSTLN'),
                        AC('DEPVS')]
    }]
Пример #6
0
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'),
    }]
Пример #7
0
def OBSTRN_area(name):
    return [{
        'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
        'instruction': LS('DASH', 2, 'CHGRD')
    }, {
        'rules': MSHasValue('VALSOU'),
        'instruction': LS('DOTT', 2, 'CHBLK')
    }, {
        'rules': MSCompare('CATOBS', '6'),
        'instruction': [AP('FOULAR01'), LS('DOTT', 2, 'CHBLK')]
    }, {
        'rules': MSCompare('WATLEV', '1') | MSCompare('WATLEV', '2'),
        'instruction': [AC('CHBRN'), LS('SOLD', 2, 'CSTLN')]
    }, {
        'rules': MSCompare('WATLEV', '4'),
        'instruction': [AC('DEPIT'), LS('DASH', 2, 'CSTLN')]
    }, {
        'rules': MSNoRules(),
        'instruction': [AC('DEPVS'), LS('DOTT', 2, 'CHBLK')]
    }]
Пример #8
0
def OBSTRN_line(name):
    return [
        {
            'rules': MSCompare('VALSOU', '30', MSCompare.OP.GT),
            'instruction': LS('DASH', 2, 'CHBLK')
        },
        {
            # VALSOU missing and <= SAFETY_DEPTH both lead here
            'rules': MSNoRules(),
            'instruction': LS('DOTT', 2, 'CHBLK')
        }
    ]
Пример #9
0
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(),
            }]
Пример #10
0
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')
    }]
Пример #11
0
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()
        }
    ]
Пример #12
0
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')
            }
        ]
Пример #13
0
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')),
        }
    ]