Search in sources :

Example 1 with AlarmAction

use of org.onebusaway.transit_data_federation.services.AlarmAction in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureAlarmServiceImpl method registerAlarmForArrivalAndDepartureAtStop.

/**
 **
 * {@link ArrivalAndDepartureAlarmService} Interface
 ***
 */
@Override
public AgencyAndId registerAlarmForArrivalAndDepartureAtStop(ArrivalAndDepartureQuery query, RegisterAlarmQueryBean alarmBean) {
    ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
    if (instance == null)
        throw new ServiceException("no arrival-departure found");
    /**
     * We group alarms by block instance
     */
    BlockInstance blockInstance = instance.getBlockInstance();
    /**
     * Retrieve the alarms for the block instance
     */
    AlarmsForBlockInstance alarms = getAlarmsForBlockInstance(blockInstance);
    /**
     * The effective schedule time is the point in the transit vehicle's
     * schedule run time when the alarm should be fired
     */
    int effectiveScheduleTime = computeEffectiveScheduleTimeForAlarm(alarmBean, instance);
    /**
     * Create and register the alarm
     */
    AlarmAction action = new AlarmAction();
    action.setUrl(alarmBean.getUrl());
    AlarmForBlockInstance alarm = alarms.registerAlarm(action, effectiveScheduleTime, instance);
    _alarmsById.put(alarm.getId(), alarm);
    _log.debug("alarm created: {}", alarm.getId());
    return alarm.getId();
}
Also used : ServiceException(org.onebusaway.exceptions.ServiceException) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) ArrivalAndDepartureInstance(org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance) AlarmAction(org.onebusaway.transit_data_federation.services.AlarmAction)

Aggregations

ServiceException (org.onebusaway.exceptions.ServiceException)1 AlarmAction (org.onebusaway.transit_data_federation.services.AlarmAction)1 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)1 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)1