The timers and counters
Overview
API: Timers and Counters
clear_counter(id_or_obj, name)
removes a counter Args: id_or_obj (agent): The agent id or object name (str): The name of the counter
clear_timer(id_or_obj, name)
deactivated a timer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The id or object of the agent that has the timer |
required |
name
|
str
|
Timer name |
required |
delay_app(seconds=0, minutes=0)
creates a Promise that waits for the specified time to elapse this is in app time (i.e. it could NOT get paused)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds
|
int
|
The number of seconds. Defaults to 0. |
0
|
minutes
|
int
|
The number of minutes. Defaults to 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
Promise |
A promise that is done when time has elapsed |
delay_sim(seconds=0, minutes=0)
creates a Promise that waits for the specified time to elapse this is in simulation time (i.e. it could get paused)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds
|
int
|
The number of seconds. Defaults to 0. |
0
|
minutes
|
int
|
The number of minutes. Defaults to 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
Promise |
A promise that is done when time has elapsed |
delay_test(seconds=0, minutes=0)
creates a Promise that waits for the specified time to elapse this is for unit testing and not realtime
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds
|
int
|
The number of seconds. Defaults to 0. |
0
|
minutes
|
int
|
The number of minutes. Defaults to 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
Promise |
A promise that is done when time has elapsed |
format_time_remaining(id_or_obj, name)
Get the remaining time on a timer and return a formatted string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The agent id or object |
required |
name
|
str
|
The timer name |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
A formatted string with the minutes and seconds left on the timer |
get_counter_elapsed_seconds(id_or_obj, name)
returns the number of seconds since the counter started
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The agent id or object |
required |
name
|
str
|
The counter name |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
The number of seconds since the counter started |
get_time_remaining(id_or_obj, name)
The number of seconds remaining for a timer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The agent id or object |
required |
name
|
str
|
The timer name |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
The number of seconds remaining |
is_timer_finished(id_or_obj, name)
check to see if a timer is finished
Note
if the timer is not set. this function returns true.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The id or object of the agent that has the timer |
required |
name
|
str
|
Timer name |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if a timer finished |
is_timer_set(id_or_obj, name)
check to see if a timer is running
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The id or object of the agent that has the timer |
required |
name
|
str
|
Timer name |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if a timer exists |
is_timer_set_and_finished(id_or_obj, name)
check to see if a timer was set and is finished
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The id or object of the agent that has the timer |
required |
name
|
str
|
Timer name |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if a timer finished and was set |
set_timer(id_or_obj, name, seconds=0, minutes=0)
set up a timer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The agent to set the timer for |
required |
name
|
str
|
The name of the timer |
required |
seconds
|
int
|
The number of seconds. Defaults to 0. |
0
|
minutes
|
int
|
The number of minutes. Defaults to 0. |
0
|
start_counter(id_or_obj, name)
starts counting seconds
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
The agent to set the timer for |
required |
name
|
str
|
The name of the timer |
required |
timeout(seconds=0, minutes=0)
creates a Promise that waits for the specified time to elapse this is in simulation time (i.e. it could NOT get paused)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds
|
int
|
The number of seconds. Defaults to 0. |
0
|
minutes
|
int
|
The number of minutes. Defaults to 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
Promise |
A promise that is done when time has elapsed |
timeout_sim(seconds=0, minutes=0)
creates a Promise that waits for the specified time to elapse this is in simulation time (i.e. it could get paused)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds
|
int
|
The number of seconds. Defaults to 0. |
0
|
minutes
|
int
|
The number of minutes. Defaults to 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
Promise |
A promise that is done when time has elapsed |