Exemplo n.º 1
0
def pipe_connector_symbol_handler(node: xml._Element,
                                  ctx: Context) -> svgwrite.container.Group:
    """
    Handler to process Proteus PipeConnectorSymbol node. This is a complex node which contains other nodes
    :param node:
    :param ctx:
    :return:
    """
    ensure_type(node, 'PipeConnectorSymbol')

    pipe_conn_group = create_group(ctx, node)

    cross_page_conn = node.find('CrossPageConnection')
    if cross_page_conn is not None:
        pipe_conn_group.attribs[
            'data-drawing-name'] = cross_page_conn.attrib.get('DrawingName')
        pipe_conn_group.attribs[
            'data-drawing-link-label'] = cross_page_conn.attrib.get(
                'LinkLabel')
        # todo we could also need support for CrossPageConnection with linkedPersistentId

    if node.attrib.get(ATTR_COMP_NAME) is not None:
        shape_reference = ctx.get_from_shape_catalog(
            'PipeConnectorSymbol', node.attrib[ATTR_COMP_NAME])
        process_shape_reference(node, shape_reference, ctx)

    return pipe_conn_group
Exemplo n.º 2
0
def component_handler(node: xml._Element,
                      ctx: Context) -> svgwrite.container.Group:
    """
    Handler to process Proteus Component node. This is a complex node which contains other nodes
    :param node:
    :param ctx:
    :return:
    """
    ensure_type(node, 'Component')
    pn_sys_group = create_group(ctx, node)
    shape_reference = ctx.get_from_shape_catalog(
        'Component', node.attrib.get(ATTR_COMP_NAME))
    process_shape_reference(node, shape_reference, ctx)
    return pn_sys_group
Exemplo n.º 3
0
def instrument_component_handler(node: xml._Element, ctx: Context):
    """
    Handler to process Proteus InstrumentComponent node. This is a complex node which contains other nodes
    and can be referenced in ShapeCatalogue
    :param node:
    :param ctx:
    :return:
    """
    ensure_type(node, 'InstrumentComponent')
    pipe_comp_group = create_group(ctx, node)
    shape_reference = ctx.get_from_shape_catalog(
        'InstrumentComponent', node.attrib.get(ATTR_COMP_NAME))
    process_shape_reference(node, shape_reference, ctx)
    return pipe_comp_group
Exemplo n.º 4
0
def process_instrumentation_function_handler(node: xml._Element, ctx: Context):
    """
    Handler to process Proteus ProcessInstrumentationFunction node. This is a complex node which contains other nodes
    and can be referenced in ShapeCatalogue
    :param node:
    :param ctx:
    :return:
    """
    ensure_type(node, 'ProcessInstrumentationFunction')

    shape_reference = ctx.get_from_shape_catalog(
        'ProcessInstrumentationFunction', node.attrib.get(ATTR_COMP_NAME))
    process_shape_reference(node, shape_reference, ctx)

    return create_group(ctx, node)
Exemplo n.º 5
0
def piping_component_handler(node: xml._Element,
                             ctx: Context) -> svgwrite.container.Group:
    """
    Handler to process Proteus PipingComponent node. This is a complex node which contains other nodes
    and can be referenced in ShapeCatalogue
    :param node: node to process
    :param ctx: drawing context
    :return: svgwrite.container.Group object
    """
    ensure_type(node, 'PipingComponent')
    pipe_comp_group = create_group(ctx, node)
    shape_reference = ctx.get_from_shape_catalog(
        'PipingComponent', node.attrib.get(ATTR_COMP_NAME))
    process_shape_reference(node, shape_reference, ctx)
    return pipe_comp_group
Exemplo n.º 6
0
def label_handler(node: xml._Element,
                  ctx: Context) -> svgwrite.container.Group:
    """
    Handler to process Proteus Label node. This is a complex node which contains other nodes
    and can be referenced in ShapeCatalogue
    :param node:
    :param ctx:
    :return:
    """
    ensure_type(node, 'Label')

    shape_reference = ctx.get_from_shape_catalog(
        'Label', node.attrib.get(ATTR_COMP_NAME))
    process_shape_reference(node, shape_reference, ctx)

    return create_group(ctx, node)
Exemplo n.º 7
0
def nozzle_handler(node: xml._Element,
                   ctx: Context) -> svgwrite.container.Group:
    """
    Handler to process Nozzle object
    :param node: object to process
    :param ctx: drawing context
    :return: SVG group object
    """
    ensure_type(node, 'Nozzle')

    nozzle_group = create_group(ctx, node)

    shape_reference = ctx.get_from_shape_catalog(
        'Nozzle', nozzle_group.attribs[DATA_COMPONENT_NAME])
    process_shape_reference(node, shape_reference, ctx)
    return nozzle_group
Exemplo n.º 8
0
def equipment_handler(node: xml._Element,
                      ctx: Context) -> svgwrite.container.Group:
    """
    Handler to process Equipment object
    :param node: node to process
    :param ctx: model context
    :return: SVG group object where Equipment parts will be added later
    """
    ensure_type(node, 'Equipment')

    eq_group = create_group(ctx, node)

    # fixme this one will work with Comos but what if we get drawing from any other systems?
    # eq_group.attribs[DATA_LABEL] = get_gen_attr_val(node, 'ComosProperties', 'Label')
    # eq_group.attribs[DATA_FULL_LABEL] = get_gen_attr_val(node, 'ComosProperties', 'FullLabel')

    # this it temporary fix for that
    # attributes_to_add_from_origin method should be updated if we get new Proteus data sources
    # probably we could move it into external config file instead of code
    # probably we also need common data-* name's which do not depend on originating system
    for attr in ctx.attributes_to_add_from_origin():
        for attr_value in attr.get('values'):
            key = f'data-{ctx.origin.lower()}-{attr_value.lower()}'
            value = get_gen_attr_val(node, attr['set'], attr_value)
            if value is not None:
                eq_group.attribs[key] = value

    descr_obj = node.find('Description')
    if descr_obj is not None:
        eq_group.attribs['data-description'] = descr_obj.text

    if eq_group.attribs.get(DATA_COMPONENT_NAME) is not None:
        shape_reference = ctx.get_from_shape_catalog(
            'Equipment', eq_group.attribs[DATA_COMPONENT_NAME])
        process_shape_reference(node, shape_reference, ctx)
    return eq_group