Untitled
unknown
plain_text
2 years ago
1.7 kB
5
Indexable
/**
* Handle person arrival event.
*
* List of locations are available at main.h.
*/
void person_arrival_at(int location, int event_type) {
// Init person arrival event in specific location and event type
event_schedule(
sim_time + expon(
MEAN_INTERARRIVAL[location],
EVNT_TO_STRM[event_type]
),
event_type
);
// Fill transfer
transfer[RIDX_PERSON_ARRIVAL_TIME] = sim_time;
if (location == LOCN_CAR_RENTAL) {
transfer[RIDX_PERSON_DESTINATION] =
// return 1 or 2
random_integer(DESTINATION_PROBABILITIES, STRM_DESTINATION);
} else {
transfer[RIDX_PERSON_DESTINATION] = LOCN_CAR_RENTAL;
}
// Do transfer Record index of destination distance from each terminal
transfer[RIDX_PERSON_DD_FROM_AIR_TERMINAL_1] = (
(int) transfer[RIDX_PERSON_DESTINATION] - LOCN_AIR_TERMINAL_1
) % 3;
transfer[RIDX_PERSON_DD_FROM_AIR_TERMINAL_2] = (
(int) transfer[RIDX_PERSON_DESTINATION] - LOCN_AIR_TERMINAL_2
) % 3;
transfer[RIDX_PERSON_DD_FROM_CAR_RENTAL] = (
(int) transfer[RIDX_PERSON_DESTINATION] - LOCN_CAR_RENTAL
) % 3;
transfer[RIDX_PERSON_ARRIVAL_LOCN] = location;
// FIFO, so insert last and remove first
list_file(LAST, LOCN_TO_LIST[location]);
printf(
"[%9.4f] PERSON ARRIVED AT LOCATION %d. TOTAL PEOPLE WAITING: %i\n",
sim_time, location, list_size[location]
);
// Cbeck bus is in location or not, if yes safe the schedule load bus
int bus_is_here = location == CURR_BUS_LOCN;
if (bus_is_here && BUS_STOPPED && BUS_ON_STANDBY) {
safe_schedule_load_bus(location);
}
}Editor is loading...
Leave a Comment