wiki:AdvancedApplicationDesign/ruta

Старт на инстанца на линија

Инстанца на линија може да стартува само Возач.

Симулација на real-time сигнал од автобус

При старт на инстанца се испалува евент:

return instancaNaLinijaRepository
            .save(instanca)
            .let {
                publisher.publishEvent(StartRouteEvent(it))
                dtoMapper.toRouteInstanceResponse(it)
            }

Евентот се слуша овде:

@Async
    @EventListener
    fun startRouteEvent(event: StartRouteEvent) {
        println(event)
        println(event)
        val instance = event.source as InstancaNaLinija
        val line = instance.linija
        val direction = instance.pravec
        val stations = stationService.findStationsByLineIdAndDirectionId(line.id, direction.id)

        simulator.simulate(instance, stations)
    }

    @Async
    @EventListener
    fun routeInstanceOnStation(event: RouteInstanceOnStationEvent) {
        println("------------------------------------------------")
        println(event)
        val source = event.source as RouteInstanceOnStation
        routeInstanceOnStationService.create(source.instance.id, source.station.id, source.timestamp)
        // todo: publish event to the websocket so that the user gets notified
        webSocketService.sendMessage("routes", "Updated routes")
    }

    @EventListener
    fun stopRouteEvent(event: StopRouteInstanceEvent) {
        val instance = event.source as InstancaNaLinija
        routeInstanceService.stop(instance.id)
    }

Се стартува симулатор кој симулира пингови од GPS на автобус.

Last modified 3 months ago Last modified on 08/20/24 19:11:45

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.