@@ -325,6 +325,100 @@ impl EventTrait for LinkLeaveEvent {
325325 }
326326}
327327
328+ #[ derive( Builder , Debug ) ]
329+ pub struct VehicleEntersTrafficEvent {
330+ pub time : u32 ,
331+ pub vehicle : Id < InternalVehicle > ,
332+ pub link : Id < Link > ,
333+ pub driver : Id < InternalPerson > ,
334+ pub mode : Id < String > ,
335+ #[ builder( default = 1.0 ) ]
336+ pub relative_position_on_link : f64 ,
337+ #[ builder( default ) ]
338+ pub attributes : InternalAttributes ,
339+ }
340+
341+ impl VehicleEntersTrafficEvent {
342+ pub const TYPE : & ' static str = "vehicle enters traffic" ;
343+ pub fn from_proto_event ( event : & MyEvent , time : u32 ) -> Self {
344+ let attrs = InternalAttributes :: from ( & event. attributes ) ;
345+ assert ! ( event. r#type. eq( Self :: TYPE ) ) ;
346+ VehicleEntersTrafficEventBuilder :: default ( )
347+ . time ( time)
348+ . vehicle ( Id :: create ( & event. attributes [ "vehicle" ] . as_string ( ) ) )
349+ . link ( Id :: create ( & event. attributes [ "link" ] . as_string ( ) ) )
350+ . driver ( Id :: create ( & event. attributes [ "driver" ] . as_string ( ) ) )
351+ . mode ( Id :: create ( & event. attributes [ "mode" ] . as_string ( ) ) )
352+ . relative_position_on_link ( event. attributes [ "relative_position_on_link" ] . as_double ( ) )
353+ . attributes ( attrs)
354+ . build ( )
355+ . unwrap ( )
356+ }
357+ }
358+
359+ impl EventTrait for VehicleEntersTrafficEvent {
360+ fn type_ ( & self ) -> & ' static str {
361+ Self :: TYPE
362+ }
363+ fn as_any ( & self ) -> & dyn Any {
364+ self
365+ }
366+ fn time ( & self ) -> u32 {
367+ self . time
368+ }
369+
370+ fn attributes ( & self ) -> & InternalAttributes {
371+ & self . attributes
372+ }
373+ }
374+
375+ #[ derive( Builder , Debug ) ]
376+ pub struct VehicleLeavesTrafficEvent {
377+ pub time : u32 ,
378+ pub vehicle : Id < InternalVehicle > ,
379+ pub link : Id < Link > ,
380+ pub driver : Id < InternalPerson > ,
381+ pub mode : Id < String > ,
382+ #[ builder( default = 1.0 ) ]
383+ pub relative_position_on_link : f64 ,
384+ #[ builder( default ) ]
385+ pub attributes : InternalAttributes ,
386+ }
387+
388+ impl VehicleLeavesTrafficEvent {
389+ pub const TYPE : & ' static str = "vehicle leaves traffic" ;
390+ pub fn from_proto_event ( event : & MyEvent , time : u32 ) -> Self {
391+ let attrs = InternalAttributes :: from ( & event. attributes ) ;
392+ assert ! ( event. r#type. eq( Self :: TYPE ) ) ;
393+ VehicleLeavesTrafficEventBuilder :: default ( )
394+ . time ( time)
395+ . vehicle ( Id :: create ( & event. attributes [ "vehicle" ] . as_string ( ) ) )
396+ . link ( Id :: create ( & event. attributes [ "link" ] . as_string ( ) ) )
397+ . driver ( Id :: create ( & event. attributes [ "driver" ] . as_string ( ) ) )
398+ . mode ( Id :: create ( & event. attributes [ "mode" ] . as_string ( ) ) )
399+ . relative_position_on_link ( event. attributes [ "relative_position_on_link" ] . as_double ( ) )
400+ . attributes ( attrs)
401+ . build ( )
402+ . unwrap ( )
403+ }
404+ }
405+
406+ impl EventTrait for VehicleLeavesTrafficEvent {
407+ fn type_ ( & self ) -> & ' static str {
408+ Self :: TYPE
409+ }
410+ fn as_any ( & self ) -> & dyn Any {
411+ self
412+ }
413+ fn time ( & self ) -> u32 {
414+ self . time
415+ }
416+
417+ fn attributes ( & self ) -> & InternalAttributes {
418+ & self . attributes
419+ }
420+ }
421+
328422#[ derive( Builder , Debug ) ]
329423pub struct PersonEntersVehicleEvent {
330424 pub time : u32 ,
0 commit comments