Exemplo n.º 1
0
def create_channel(session, station_id, client_id=None, name="TestChannel"):
    channel = Channel()
    channel.station_id = station_id
    channel.name = name
    channel.ecc_id = 159
    channel.frequency = "00917"
    channel.pi = "C00F"
    channel.type_id = "fm"
    if client_id:
        channel.fk_client = client_id
    session.add(channel)
    session.commit()
    time.sleep(config.SPI_GENERATION_INTERVAL * 3)
    return channel
Exemplo n.º 2
0
def create_channel(session, station_id, client_id=None, name="TestChannel"):
    channel = Channel()
    channel.station_id = station_id
    channel.name = name
    channel.ecc_id = 159
    channel.frequency = "00917"
    channel.pi = "C00F"
    channel.type_id = "fm"
    if client_id:
        channel.fk_client = client_id
    session.add(channel)
    session.commit()
    time.sleep(config.SPI_GENERATION_INTERVAL * 3)
    return channel
Exemplo n.º 3
0
def string_to_channel(linedata, station):
    object = Channel()
    object.station_id = station

    # Split line
    data = linedata.split(',')

    if len(data) < 2:
        return None

    # Define Type
    object.name = data[0]
    object.type_id = data[1]

    # FM
    # name	fm	ecc	pid	frequency
    if object.type_id == 'fm':
        if len(data) < 5:
            return None
        # ECC
        cc_obj = Ecc.query.filter_by(iso=data[2].upper()).first()
        if not cc_obj:
            ecc_pi = data[2][:1].upper()
            ecc_ecc = data[2][1:].upper()
            cc_obj = Ecc.query.filter_by(pi=ecc_pi, ecc=ecc_ecc).first()
        if cc_obj:
            object.ecc_id = cc_obj.id
        # PI
        object.pi = data[3]
        object.frequency = data[4]

    # DAB
    # name	dab	ecc	eid	sid	scids	UAType	PA
    elif object.type_id == 'dab':
        if len(data) < 6:
            return None
        # ECC
        cc_obj = Ecc.query.filter_by(iso=data[2].upper()).first()
        if not cc_obj:
            ecc_pi = data[2][:1].upper()
            ecc_ecc = data[2][1:].upper()
            cc_obj = Ecc.query.filter_by(pi=ecc_pi, ecc=ecc_ecc).first()
        if cc_obj:
            object.ecc_id = cc_obj.id
        # eid
        object.eid = data[3]
        object.sid = data[4]
        object.scids = data[5]
        # Optional Elements
        if len(data) >= 7:
            object.appty_uatype = data[6]
        if len(data) >= 8:
            object.pa = data[7]

    # DRM
    # name	drm	sid
    elif object.type_id == 'drm':
        if len(data) < 3:
            return None
        # sid
        object.sid = data[2]

    # AMSS
    elif object.type_id == 'amss':
        if len(data) < 3:
            return None
        # sid
        object.sid = data[2]

    # HD Radio
    # name	hd	cc	tx
    elif object.type_id == 'hd':
        if len(data) < 4:
            return None
        # cc
        object.cc = data[2]
        object.tx = data[3]

    # IP
    # name	ip	fqdn	service id
    elif object.type_id == 'ip':
        if len(data) < 4:
            return None
        # cc
        object.fqdn = data[2]
        object.serviceIdentifier = data[3]

    else:
        return None

    return object