CIM DEFINITIONS AUTOMATIC TAGS ::= BEGIN

EXPORTS CollaborativeInteractionMsg, InteractionInfo;
IMPORTS MinuteOfTheYear FROM DefTime
		MsgCount FROM MsgFrame
		Position3D, PositionConfidenceSet FROM DefPosition
        DSecond, TimeOffset FROM DefTime
        DriveBehavior, PathPlanning FROM VIR
        EquipmentType, DetectedPTCList, DetectedObstacleList, PlanningList FROM SensorSharing
		HeadingConfidence, Speed, Heading, SpeedConfidence FROM DefMotion
		Radius FROM RSI
        Acceleration FROM DefAcceleration
        NodeReferenceID, LaneID, MovementEx FROM Map
		PositionOffsetLLV FROM DefPositionOffset;

    -- 定义交互报文接收方的描述，提供多种描述方式，可以通过TargetID来指定固定的接收方，也可通
    -- 过targetPos、targetRadius及targetType的组合来指定一定范围内、固定设备类型的接收方。
    InteractionTarget ::= SEQUENCE {
        targetID OCTET STRING (SIZE(8..64)) OPTIONAL,
        -- the temporary ID of target
        targetPos PositionOffsetLLV OPTIONAL,
        -- the position of target，if exists
        targetRadius Radius OPTIONAL,
        -- Radius of target, if exists
        targetType EquipmentType OPTIONAL,
        -- type of target, rsu or obu
        description OCTET STRING (SIZE(8..64)) OPTIONAL
        -- Additional description to this event
    }

    -- 定义不同场景下交互报文的数据。包括协同规划的请求及应答，
    -- 协同控制的请求、应答及确认，高精地图更新的请求及应答
    InteractionData ::= CHOICE{
        vehReqInfo VehReqInfo,
        mapUpdateReq MapUpdateReq,
        roadCooRes RoadCooRes,
        roadControlRes RoadControlRes,
        mapUpdateRes MapUpdateRes,
        vehConfirm VehConfirm,
        ...
    }

    -- 定义自动驾驶车辆信息集合。用于AVSM消息中，作为基础安全数据的补充。
    -- 包括自动驾驶车辆的等级、车辆是否处于自动驾驶状态、车辆当前驾驶行为、车辆所允许的最大速
    -- 度及加速度、车辆路线及行为规划等。
    AutonomousVehicleExtensions ::= SEQUENCE {
        autonomousLevel AutonomousLevel,
        ---form L0 to L5
        autonomousStatus AutonomousStatus,
        currentBehavior DriveBehavior,
        -- current driving behavior of the vehicle
        maxSpeedAllowed Speed OPTIONAL,
        maxAcceleration Acceleration OPTIONAL,
        fixedLane LaneID OPTIONAL,
        planningList PlanningList OPTIONAL,
        -- Planning path and behavior for Autonomous Vehicle in a few seconds
        -- real time planning that is shared with neighbors
        ...
    }

    -- 定义车辆请求路侧协同规划或请求路侧接管控制消息，路侧协商应答后，
    -- 则路侧可发送RSC或者RSCV消息
    VehReqInfo ::= SEQUENCE {
        autoVehicleExt AutonomousVehicleExtensions OPTIONAL,
        reason OCTET STRING (SIZE(1..64)) OPTIONAL,
        participants DetectedPTCList OPTIONAL,
        -- All or part of the traffic participants
        obstacles DetectedObstacleList OPTIONAL,
        -- All or part of Obstacles
        ...
    }

    -- 定义高精地图更新请求信息。
    MapUpdateReq ::= SEQUENCE {
        updateRegion MapUpdateRegion,
        updateMode MapUpdateMode,
        maphighPrecision MapHighPrecision,
        ...
    }

    -- 针对车辆发起的请求路侧协同规划消息，路侧发起的应答消息。
    RoadCooRes::= SEQUENCE {
        isCoordination INTEGER (0..10),
        timeBegin TimeOffset OPTIONAL,
        timeEnd TimeOffset OPTIONAL
    }

    -- 针对车辆发起的请求路侧接管控制消息，路侧发起的应答消息
    RoadControlRes::= SEQUENCE {
        isControl INTEGER (0..10),
        -- ackInterval AckIntervel,
        -- the interval for vehicle confirm
        ...
    }

    -- 定义高精地图更新应答信息
    MapUpdateRes::= SEQUENCE {
        total INTEGER(1..65535),
        -- define total messages for this update
        serial INTEGER(1..65535),
        -- define current message number for this update
        updateRegion MapUpdateRegion,
        updateMode MapUpdateMode,
        maphighPrecision MapHighPrecision,
        interactionBlob InteractionBlob OPTIONAL,
        -- define actual map data
        ...
    }

    -- 针对路侧发起的RSCV，车辆发起的确认消息
    VehConfirm::= SEQUENCE {
        isImplement INTEGER (0..10),
        isContinue INTEGER (0..10),
        ...
    }
    
    -- 描述高精地图更新区域，可以进行市、行政区及图幅级别的更新。
    MapUpdateRegion ::= SEQUENCE {
        regionIdOCTET OCTET STRING (SIZE(64)) OPTIONAL,
        updateRadius Radius OPTIONAL
    }

    -- 定义高精地图信息，包括地图提供商、版本信息及描述信息
    MapHighPrecision ::= SEQUENCE {
        serviceProvider OCTET STRING (SIZE(64)),
        mapVersion OCTET STRING (SIZE(64)),
        description OCTET STRING (SIZE(64))
    }

    --- 地图数据或停车说明 
    InteractionBlob::= OCTET STRING (SIZE(1024))
    ---Map data or Parking description

    -- 定义交互场景中的消息内容。
    InteractionInfo ::= SEQUENCE {
        interactionID INTEGER (0..255),
        -- local ID of this interaction
        drivingIntention DriveBehavior OPTIONAL,
        interactionType InteractionType,
        -- define the interaction type
        selfType EquipmentType,
        -- define the generation type of the interaction, 0BU / RSU / VRU
        objective Objective,
        -- objective of this interaction
        interactionTarget InteractionTarget,
        interactionData InteractionData OPTIONAL,
        -- define the data of the interation
        ...
    }

    -- 自动驾驶车辆与路侧之间的协同交互消息。用来进行车路协同规划、车路协同控制及高精地图更新
    -- 等场景的具体交互
    CollaborativeInteractionMsg::= SEQUENCE{
        msgCnt MsgCount,
        id OCTET STRING(SIZE(8)),
        -- temperary idofthesender
        pos Position3D,
        -- real position relates to secMark ofthesender
        accuracy PositionConfidenceSet OPTIONAL,
        secMark DSecond,
        -- time of message generation,
        interationInfo InteractionInfo,
        ...
    }

    -- 定义交互报文的类型，分为请求、应答及确认。
    InteractionType ::= ENUMERATED{
        unavailable (0),
        requese (1),
        response (2),
        confirm (3),
        ...
    }

    -- 定义交互报文的目的，和特定场景对应。
    Objective ::= BIT STRING {
        unavailable (0),
        roadCoordination (1),
        mapUpdate (2),
        roadControl (3)
    } (SIZE (8))

    AutonomousLevel ::= ENUMERATED {
        --the value of the automatic driving level
        -- use the definition when the vehicle leaves the factory
        level0 (0),
        level1 (1),
        level2 (2),
        level3 (3),
        level4 (4),
        level5 (5),
        reserved1 (6),
        reserved2 (7),
        reserved3 (8),
        reserved4 (9),
        reserved5 (10)
    }

    -- 指示自动驾驶车辆的驾驶状态，分为车辆处于自动驾驶状态，车辆处于非自动驾驶状态以及
    -- 车辆处于被路侧控制的状态
    AutonomousStatus ::= ENUMERATED {
        unavailable (0),
        on (1), -- B'01 Autonomous Driving is On
        off (2), -- B'10 Autonomous Driving is Off
        roadsidecontrol (3), -- B'11 Autonomous Vehicle is in Road side control
        ...
    }

    MapUpdateMode ::= ENUMERATED {
        unavailable (0),
        fullupdate (1),
        differentupdate (2)
    }

END