osc_generator/helper_functions.py
def layer_setup_maneuvers_and_triggers():
    """
    Set up maneuvers layer (including start and stop triggers)
    """
    root_layer = QgsProject.instance().layerTreeRoot()
    osc_layer = root_layer.findGroup("OpenSCENARIO")
    if osc_layer is None:
        osc_layer = root_layer.addGroup("OpenSCENARIO")

    if not QgsProject.instance().mapLayersByName("Maneuvers"):
        maneuver_layer = QgsVectorLayer("None", "Maneuvers", "memory")
        QgsProject.instance().addMapLayer(maneuver_layer, False)
        osc_layer.addLayer(maneuver_layer)
        # Setup layer attributes
        data_attributes = [
            QgsField("id", QVariant.Int),
            QgsField("Maneuver Type", QVariant.String),
            QgsField("Entity", QVariant.String),
            QgsField("Entity: Maneuver Type", QVariant.String),
            # Global Actions
            QgsField("Global: Act Type", QVariant.String),
            QgsField("Infra: Traffic Light ID", QVariant.Int),
            QgsField("Infra: Traffic Light State", QVariant.String),
            # Start Triggers
            QgsField("Start Trigger", QVariant.String),
            QgsField("Start - Entity: Condition", QVariant.String),
            QgsField("Start - Entity: Ref Entity", QVariant.String),
            QgsField("Start - Entity: Duration", QVariant.Double),
            QgsField("Start - Entity: Value", QVariant.Double),
            QgsField("Start - Entity: Rule", QVariant.String),
            QgsField("Start - Entity: RelDistType", QVariant.String),
            QgsField("Start - Entity: Freespace", QVariant.Bool),
            QgsField("Start - Entity: Along Route", QVariant.Bool),
            QgsField("Start - Value: Condition", QVariant.String),
            QgsField("Start - Value: Param Ref", QVariant.String),
            QgsField("Start - Value: Name", QVariant.String),
            QgsField("Start - Value: DateTime", QVariant.String),
            QgsField("Start - Value: Value", QVariant.Double),
            QgsField("Start - Value: Rule", QVariant.String),
            QgsField("Start - Value: State", QVariant.String),
            QgsField("Start - Value: Sboard Type", QVariant.String),
            QgsField("Start - Value: Sboard Element", QVariant.String),
            QgsField("Start - Value: Sboard State", QVariant.String),
            QgsField("Start - Value: TController Ref", QVariant.String),
            QgsField("Start - Value: TController Phase", QVariant.String),
            QgsField("Start - WorldPos: Tolerance", QVariant.Double),
            QgsField("Start - WorldPos: X", QVariant.Double),
            QgsField("Start - WorldPos: Y", QVariant.Double),
            QgsField("Start - WorldPos: Z", QVariant.Double),
            QgsField("Start - WorldPos: Heading", QVariant.Double),
            # Stop Triggers
            QgsField("Stop Trigger Enabled", QVariant.Bool),
            QgsField("Stop Trigger", QVariant.String),
            QgsField("Stop - Entity: Condition", QVariant.String),
            QgsField("Stop - Entity: Ref Entity", QVariant.String),
            QgsField("Stop - Entity: Duration", QVariant.Double),
            QgsField("Stop - Entity: Value", QVariant.Double),
            QgsField("Stop - Entity: Rule", QVariant.String),
            QgsField("Stop - Entity: RelDistType", QVariant.String),
            QgsField("Stop - Entity: Freespace", QVariant.Bool),
            QgsField("Stop - Entity: Along Route", QVariant.Bool),
            QgsField("Stop - Value: Condition", QVariant.String),
            QgsField("Stop - Value: Param Ref", QVariant.String),
            QgsField("Stop - Value: Name", QVariant.String),
            QgsField("Stop - Value: DateTime", QVariant.String),
            QgsField("Stop - Value: Value", QVariant.Double),
            QgsField("Stop - Value: Rule", QVariant.String),
            QgsField("Stop - Value: State", QVariant.String),
            QgsField("Stop - Value: Sboard Type", QVariant.String),
            QgsField("Stop - Value: Sboard Element", QVariant.String),
            QgsField("Stop - Value: Sboard State", QVariant.String),
            QgsField("Stop - Value: TController Ref", QVariant.String),
            QgsField("Stop - Value: TController Phase", QVariant.String),
            QgsField("Stop - WorldPos: Tolerance", QVariant.Double),
            QgsField("Stop - WorldPos: X", QVariant.Double),
            QgsField("Stop - WorldPos: Y", QVariant.Double),
            QgsField("Stop - WorldPos: Z", QVariant.Double),
            QgsField("Stop - WorldPos: Heading", QVariant.Double)
        ]
        maneuver_layer.dataProvider().addAttributes(data_attributes)
        maneuver_layer.updateFields()

        message = "Maneuvers layer added"
        display_message(message, level="Info")
    else:
        message = "Using existing maneuvers layer"
        display_message(message, level="Info")

    Set up maneuvers layer (including start and stop triggers)
    
Set up maneuvers layer (including start and stop triggers)
Set up maneuvers layer ( including start and stop triggers )
def layer_setup_maneuvers_and_triggers():
    root_layer = QgsProject.instance().layerTreeRoot()
    osc_layer = root_layer.findGroup("OpenSCENARIO")
    if osc_layer is None:
        osc_layer = root_layer.addGroup("OpenSCENARIO")
    if not QgsProject.instance().mapLayersByName("Maneuvers"):
        maneuver_layer = QgsVectorLayer("None", "Maneuvers", "memory")
        QgsProject.instance().addMapLayer(maneuver_layer, False)
        osc_layer.addLayer(maneuver_layer)
        data_attributes = [
            QgsField("id", QVariant.Int),
            QgsField("Maneuver Type", QVariant.String),
            QgsField("Entity", QVariant.String),
            QgsField("Entity: Maneuver Type", QVariant.String),
            QgsField("Global: Act Type", QVariant.String),
            QgsField("Infra: Traffic Light ID", QVariant.Int),
            QgsField("Infra: Traffic Light State", QVariant.String),
            QgsField("Start Trigger", QVariant.String),
            QgsField("Start - Entity: Condition", QVariant.String),
            QgsField("Start - Entity: Ref Entity", QVariant.String),
            QgsField("Start - Entity: Duration", QVariant.Double),
            QgsField("Start - Entity: Value", QVariant.Double),
            QgsField("Start - Entity: Rule", QVariant.String),
            QgsField("Start - Entity: RelDistType", QVariant.String),
            QgsField("Start - Entity: Freespace", QVariant.Bool),
            QgsField("Start - Entity: Along Route", QVariant.Bool),
            QgsField("Start - Value: Condition", QVariant.String),
            QgsField("Start - Value: Param Ref", QVariant.String),
            QgsField("Start - Value: Name", QVariant.String),
            QgsField("Start - Value: DateTime", QVariant.String),
            QgsField("Start - Value: Value", QVariant.Double),
            QgsField("Start - Value: Rule", QVariant.String),
            QgsField("Start - Value: State", QVariant.String),
            QgsField("Start - Value: Sboard Type", QVariant.String),
            QgsField("Start - Value: Sboard Element", QVariant.String),
            QgsField("Start - Value: Sboard State", QVariant.String),
            QgsField("Start - Value: TController Ref", QVariant.String),
            QgsField("Start - Value: TController Phase", QVariant.String),
            QgsField("Start - WorldPos: Tolerance", QVariant.Double),
            QgsField("Start - WorldPos: X", QVariant.Double),
            QgsField("Start - WorldPos: Y", QVariant.Double),
            QgsField("Start - WorldPos: Z", QVariant.Double),
            QgsField("Start - WorldPos: Heading", QVariant.Double),
            QgsField("Stop Trigger Enabled", QVariant.Bool),
            QgsField("Stop Trigger", QVariant.String),
            QgsField("Stop - Entity: Condition", QVariant.String),
            QgsField("Stop - Entity: Ref Entity", QVariant.String),
            QgsField("Stop - Entity: Duration", QVariant.Double),
            QgsField("Stop - Entity: Value", QVariant.Double),
            QgsField("Stop - Entity: Rule", QVariant.String),
            QgsField("Stop - Entity: RelDistType", QVariant.String),
            QgsField("Stop - Entity: Freespace", QVariant.Bool),
            QgsField("Stop - Entity: Along Route", QVariant.Bool),
            QgsField("Stop - Value: Condition", QVariant.String),
            QgsField("Stop - Value: Param Ref", QVariant.String),
            QgsField("Stop - Value: Name", QVariant.String),
            QgsField("Stop - Value: DateTime", QVariant.String),
            QgsField("Stop - Value: Value", QVariant.Double),
            QgsField("Stop - Value: Rule", QVariant.String),
            QgsField("Stop - Value: State", QVariant.String),
            QgsField("Stop - Value: Sboard Type", QVariant.String),
            QgsField("Stop - Value: Sboard Element", QVariant.String),
            QgsField("Stop - Value: Sboard State", QVariant.String),
            QgsField("Stop - Value: TController Ref", QVariant.String),
            QgsField("Stop - Value: TController Phase", QVariant.String),
            QgsField("Stop - WorldPos: Tolerance", QVariant.Double),
            QgsField("Stop - WorldPos: X", QVariant.Double),
            QgsField("Stop - WorldPos: Y", QVariant.Double),
            QgsField("Stop - WorldPos: Z", QVariant.Double),
            QgsField("Stop - WorldPos: Heading", QVariant.Double)
        ]
        maneuver_layer.dataProvider().addAttributes(data_attributes)
        maneuver_layer.updateFields()
        message = "Maneuvers layer added"
        display_message(message, level="Info")
    else:
        message = "Using existing maneuvers layer"
        display_message(message, level="Info")
def layer_setup_maneuvers_and_triggers ( ) : root_layer = QgsProject . instance ( ) . layerTreeRoot ( ) osc_layer = root_layer . findGroup ( "OpenSCENARIO" ) if osc_layer is None : osc_layer = root_layer . addGroup ( "OpenSCENARIO" ) if not QgsProject . instance ( ) . mapLayersByName ( "Maneuvers" ) : maneuver_layer = QgsVectorLayer ( "None" , "Maneuvers" , "memory" ) QgsProject . instance ( ) . addMapLayer ( maneuver_layer , False ) osc_layer . addLayer ( maneuver_layer ) data_attributes = [ QgsField ( "id" , QVariant . Int ) , QgsField ( "Maneuver Type" , QVariant . String ) , QgsField ( "Entity" , QVariant . String ) , QgsField ( "Entity: Maneuver Type" , QVariant . String ) , QgsField ( "Global: Act Type" , QVariant . String ) , QgsField ( "Infra: Traffic Light ID" , QVariant . Int ) , QgsField ( "Infra: Traffic Light State" , QVariant . String ) , QgsField ( "Start Trigger" , QVariant . String ) , QgsField ( "Start - Entity: Condition" , QVariant . String ) , QgsField ( "Start - Entity: Ref Entity" , QVariant . String ) , QgsField ( "Start - Entity: Duration" , QVariant . Double ) , QgsField ( "Start - Entity: Value" , QVariant . Double ) , QgsField ( "Start - Entity: Rule" , QVariant . String ) , QgsField ( "Start - Entity: RelDistType" , QVariant . String ) , QgsField ( "Start - Entity: Freespace" , QVariant . Bool ) , QgsField ( "Start - Entity: Along Route" , QVariant . Bool ) , QgsField ( "Start - Value: Condition" , QVariant . String ) , QgsField ( "Start - Value: Param Ref" , QVariant . String ) , QgsField ( "Start - Value: Name" , QVariant . String ) , QgsField ( "Start - Value: DateTime" , QVariant . String ) , QgsField ( "Start - Value: Value" , QVariant . Double ) , QgsField ( "Start - Value: Rule" , QVariant . String ) , QgsField ( "Start - Value: State" , QVariant . String ) , QgsField ( "Start - Value: Sboard Type" , QVariant . String ) , QgsField ( "Start - Value: Sboard Element" , QVariant . String ) , QgsField ( "Start - Value: Sboard State" , QVariant . String ) , QgsField ( "Start - Value: TController Ref" , QVariant . String ) , QgsField ( "Start - Value: TController Phase" , QVariant . String ) , QgsField ( "Start - WorldPos: Tolerance" , QVariant . Double ) , QgsField ( "Start - WorldPos: X" , QVariant . Double ) , QgsField ( "Start - WorldPos: Y" , QVariant . Double ) , QgsField ( "Start - WorldPos: Z" , QVariant . Double ) , QgsField ( "Start - WorldPos: Heading" , QVariant . Double ) , QgsField ( "Stop Trigger Enabled" , QVariant . Bool ) , QgsField ( "Stop Trigger" , QVariant . String ) , QgsField ( "Stop - Entity: Condition" , QVariant . String ) , QgsField ( "Stop - Entity: Ref Entity" , QVariant . String ) , QgsField ( "Stop - Entity: Duration" , QVariant . Double ) , QgsField ( "Stop - Entity: Value" , QVariant . Double ) , QgsField ( "Stop - Entity: Rule" , QVariant . String ) , QgsField ( "Stop - Entity: RelDistType" , QVariant . String ) , QgsField ( "Stop - Entity: Freespace" , QVariant . Bool ) , QgsField ( "Stop - Entity: Along Route" , QVariant . Bool ) , QgsField ( "Stop - Value: Condition" , QVariant . String ) , QgsField ( "Stop - Value: Param Ref" , QVariant . String ) , QgsField ( "Stop - Value: Name" , QVariant . String ) , QgsField ( "Stop - Value: DateTime" , QVariant . String ) , QgsField ( "Stop - Value: Value" , QVariant . Double ) , QgsField ( "Stop - Value: Rule" , QVariant . String ) , QgsField ( "Stop - Value: State" , QVariant . String ) , QgsField ( "Stop - Value: Sboard Type" , QVariant . String ) , QgsField ( "Stop - Value: Sboard Element" , QVariant . String ) , QgsField ( "Stop - Value: Sboard State" , QVariant . String ) , QgsField ( "Stop - Value: TController Ref" , QVariant . String ) , QgsField ( "Stop - Value: TController Phase" , QVariant . String ) , QgsField ( "Stop - WorldPos: Tolerance" , QVariant . Double ) , QgsField ( "Stop - WorldPos: X" , QVariant . Double ) , QgsField ( "Stop - WorldPos: Y" , QVariant . Double ) , QgsField ( "Stop - WorldPos: Z" , QVariant . Double ) , QgsField ( "Stop - WorldPos: Heading" , QVariant . Double ) ] maneuver_layer . dataProvider ( ) . addAttributes ( data_attributes ) maneuver_layer . updateFields ( ) message = "Maneuvers layer added" display_message ( message , level = "Info" ) else : message = "Using existing maneuvers layer" display_message ( message , level = "Info" )
Set up maneuvers layer (including start and stop triggers)
Set up maneuvers layer ( including start and stop triggers )
"""
    Set up maneuvers layer (including start and stop triggers)
    """ # Setup layer attributes # Global Actions # Start Triggers # Stop Triggers