Decentralized Environmental Notification (DEN) Service
The DEN service implements ETSI TS 103 831 V2.3.1. Applications use it to send and receive Decentralized Environmental Notification Messages (DENMs): event-driven warnings about road hazards (stationary vehicles, accidents, roadworks, emergency vehicles, adverse weather, …), sent by GeoBroadcast to a relevance area.
Architecture
DecentralizedEnvironmentalNotificationService contains:
The DEN protocol engine: one entry per event, identified by its
ActionId(station ID and sequence number), with its state (active, cancelled, negated).Transmission management: triggering, update and termination of events, repetition, and keep-alive forwarding (optional).
Reception management: the receiving message table, which discards outdated and duplicate DENMs, and the delivery of the others to the applications and to the LDM.
A scheduler thread drives repetitions and expiries; it is started with the service (start_scheduler=True, the default).
Creating the Service
from flexstack.facilities.ca_basic_service.cam_transmission_management import VehicleData
from flexstack.facilities.decentralized_environmental_notification_service.den_service import (
DecentralizedEnvironmentalNotificationService,
)
den_service = DecentralizedEnvironmentalNotificationService(
btp_router=btp_router,
vehicle_data=VehicleData(station_id=42, station_type=5),
ldm=ldm,
)
Triggering, Updating and Terminating an Event
An event is described by a DENMRequest with the fields of the DENM containers (event_position, situation, location, …) as dictionaries of the ASN.1 module, and optional repetition parameters in milliseconds:
from flexstack.facilities.decentralized_environmental_notification_service.den_protocol import DENMRequest
event_position = {
"latitude": 415520000, # 0.1 microdegree
"longitude": 21340000,
"positionConfidenceEllipse": {"semiMajorConfidence": 4095, "semiMinorConfidence": 4095,
"semiMajorOrientation": 3601},
"altitude": {"altitudeValue": 800001, "altitudeConfidence": "unavailable"},
}
situation = {"informationQuality": 3, "eventType": {"ccAndScc": ("accident2", 0)}}
result = den_service.trigger_denm(
DENMRequest(event_position, situation=situation,
repetition_interval=1000, repetition_duration=10000)
)
action_id = result.action_id
den_service.update_denm(action_id, request) updates the event and den_service.terminate_denm(action_id, request) cancels it; the ActionId stays the same for the whole life of the event.
Receiving DENMs
def on_denm(received) -> None:
print(received.state, received.denm["denm"]["management"]["actionId"])
den_service.add_application_callback(on_denm)
Every new or updated DENM accepted by the receiving message table is passed to the callbacks as a ReceivedDENM (the decoded message and the event state).
Application Example: Emergency Vehicle Approaching
flexstack.applications contains a Road Hazard Signalling application that sends the “emergency vehicle approaching” warning of ETSI TS 101 539-1 for a given duration:
from flexstack.applications.road_hazard_signalling_service.emergency_vehicle_approaching_service import (
EmergencyVehicleApproachingService,
)
from flexstack.utils.static_location_service import generate_tpv_dict_with_current_timestamp
eva = EmergencyVehicleApproachingService(den_service=den_service, duration=5000)
eva.trigger_denm_sending(generate_tpv_dict_with_current_timestamp(41.386931, 2.112104))