volttron.platform.vip.agent.subsystems package¶
-
class
volttron.platform.vip.agent.subsystems.
PeerList
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
class
volttron.platform.vip.agent.subsystems.
Ping
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
class
volttron.platform.vip.agent.subsystems.
RPC
(core, owner)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
allow
(capabilities)[source]¶ Decorator specifies required agent capabilities to call a method.
This is designed to be used with the export decorator:
@RPC.export @RPC.allow('can_read_status') def get_status(): ...
Multiple capabilies can be provided in a list: .. code-block:: python
@RPC.allow([‘can_read_status’, ‘can_call_my_methods’])
-
-
class
volttron.platform.vip.agent.subsystems.
Hello
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
The hello subsystem allows an agent to determine its identity.
The identity is possibly a dynamically generated uuid from which the executing agent does not know. This subsystem allows the agent to be able to determine it’s identity from a peer. By default that peer is the connected router, however this could be another agent.
-
hello
(peer='')[source]¶ Receives a welcome message from the peer (default to ‘’ router)
The welcome message will respond with a 3 element list:
- The vip version (default 1.0)
- The peer who responded (should be the same as peer argument to this function.
- The id of the requester (i.e. this object). This will be the identity when the agent connects to the router or the specified identity when the Agent is constructed.
Parameters: peer – The peer to receive the response from. Returns: [version, peer, identity]
-
-
class
volttron.platform.vip.agent.subsystems.
PubSub
(core, rpc_subsys, peerlist_subsys, owner)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
list
(peer, prefix='', bus='', subscribed=True, reverse=False, all_platforms=False)[source]¶ Gets list of subscriptions matching the prefix and bus for the specified peer. param peer: peer type peer: str param prefix: prefix of a topic type prefix: str param bus: bus type bus: bus param subscribed: subscribed or not type subscribed: boolean param reverse: reverse type reverse: :returns: List of subscriptions, i.e, list of tuples of bus, topic and flag to indicate if peer is a subscriber or not :rtype: list of tuples
Return Values: List of tuples [(topic, bus, flag to indicate if peer is a subscriber or not)]
-
publish
(peer, topic, headers=None, message=None, bus='')[source]¶ Publish a message to a given topic via a peer.
Publish headers and message to all subscribers of topic on bus. If peer is None, use self. Adds volttron platform version compatibility information to header as variables min_compatible_version and max_compatible version param peer: peer type peer: str param topic: topic for the publish message type topic: str param headers: header info for the message type headers: None or dict param message: actual message type message: None or any param bus: bus type bus: str return: Number of subscribers the message was sent to. :rtype: int
Return Values: Number of subscribers
-
unsubscribe
(peer, prefix, callback, bus='', all_platforms=False)[source]¶ Unsubscribe and remove callback(s).
Remove all handlers matching the given info - peer, callback and bus, which was used earlier to subscribe as well. If all handlers for a topic prefix are removed, the topic is also unsubscribed. param peer: peer type peer: str param prefix: prefix that needs to be unsubscribed type prefix: str param callback: callback method type callback: method param bus: bus type bus: bus return: success or not :rtype: boolean
Return Values: success or not
-
-
class
volttron.platform.vip.agent.subsystems.
Channel
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
ADDRESS
= 'inproc://subsystem/channel'¶
-
-
class
volttron.platform.vip.agent.subsystems.
Heartbeat
(owner, core, rpc, pubsub, heartbeat_autostart, heartbeat_period)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
restart
()[source]¶ RPC method
Restart the heartbeat with the current period. The heartbeat will be immediately sending the heartbeat to the message bus.
-
set_period
(period)[source]¶ RPC method
Set heartbeat period.
Parameters: period – Time in seconds between publishes.
-
-
class
volttron.platform.vip.agent.subsystems.
Health
(owner, core, rpc)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
add_status_callback
(fn)[source]¶ Add callbacks to the passed function. The function must have the following interface
Parameters: - fn – The method to be executed when status is changed.
- fn – callable
-
get_status
()[source]¶ “RPC method
Returns the last updated status from the object with the context.
The minimum output from the status would be:
- {
- “status”: “GOOD”, “context”: None, “utc_last_update”: “2016-03-31T15:40:32.685138+0000”
}
-
get_status_json
()[source]¶ “RPC method
Returns the last updated status from the object with the context.
The minimum output from the status would be:
- {
- “status”: “GOOD”, “context”: None, “utc_last_update”: “2016-03-31T15:40:32.685138+0000”
}
-
-
class
volttron.platform.vip.agent.subsystems.
ConfigStore
(owner, core, rpc)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
delete
(config_name, trigger_callback=False, send_update=True)[source]¶ - Delete a configuration by name. May not be called from a callback as this will cause
- deadlock with the platform. Will produce a runtime error if done so.
Parameters:
-
delete_default
(config_name)[source]¶ Called to delete the contents of a default configuration file.
May not be called after the onsetup phase of an agents lifetime. Will produce a runtime error if done so.
Parameters: config_name (str) – Configuration to remove from store.
-
get
(config_name='config')[source]¶ Returns the contents of a configuration.
Parameters: config_name (str) – Name of configuration to add to store. Returns: Configuration contents Return type: dict, list, or string Return Values: The contents of the configuration specified.
-
list
()[source]¶ Returns a list of configuration names for this agent.
Returns: Configuration names Return type: list Return Values: A list of all the configuration names available for this agent.
-
set
(config_name, contents, trigger_callback=False, send_update=True)[source]¶ Called to set the contents of a configuration.
May not be called before the onstart phase of an agents lifetime.
May not be called from a configuration callback. Will produce a runtime error if done so.
Parameters:
-
set_default
(config_name, contents)[source]¶ Called to set the contents of a default configuration file. Default configurations are used if the configuration store does not contain a configuration with that name.
May not be called after the onsetup phase of an agents lifetime. Will produce a runtime error if done so.
Parameters:
-
subscribe
(callback, actions=set(['NEW', 'UPDATE', 'DELETE']), pattern='*')[source]¶ Subscribe to changes to a configuration.
Parameters: - callback (str) – Function to call in response to changes to a configuration.
- actions (str or list) – Change actions to respond to. Valid values are “NEW”, “UPDATE”, and “DELETE”. May be a single action or a list of actions.
- pattern (str) – Configuration name pattern to match to. Uses Unix style filename pattern matching.
-
-
class
volttron.platform.vip.agent.subsystems.
Auth
(owner, core, rpc)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
class
volttron.platform.vip.agent.subsystems.
FNCS
(owner, core, pubsub)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
The fncs subsystem allows an integration point between VOLTTRON and FNCS.
-
current_simulation_step
¶ returns the current fncs timestep.
Returns:
-
current_values
¶
-
fncs_installed
¶ Allows caller to determine if the fncs module is available.
-
fncs_version
¶
-
initialize
(sim_start_time, sim_length, topic_maping, work_callback, federate_name=None, broker_location='tcp://localhost:5570', time_delta='1s', stop_agent_when_sim_complete=False)[source]¶ Configure the agent to act as a federated connection to FNCS
- sim_start_time - Wall clock time for the simulation start time (This is not used at present time other
- than to be available)
sim_length - Time for the simulation to run. Should be formatted as <number><unit> i.e. 60s.
topic_mapping - Maps fncs topics onto volttron topics.
- federate_name - MUST be unique to the broker. If None, then will be the
- identity of the current agent process.
broker - tcp location of the fncs broker (defaults to tcp://localhost:5570)
time_delta - Minimum timestep supported for the federate.
stop_agent_when_sim_complete - Should we stop the agent when the simulation is completed.
Parameters: - sim_start_time –
- sim_length –
- topic_maping –
- work_callback –
- federate_name –
- broker_location –
- time_delta –
- poll_timeout –
Returns:
-
parse_time
(time_string)[source]¶ Parses a <number><unit> i.e. 60s to a fncs timestep number.
Parameters: time_string – Returns:
-
publish
(topic, message)[source]¶ publish a topic to the fncs bus.
The publish will only be sent if there is a federate subscribed to the topic that is being published.
Parameters: - topic –
- message –
Returns:
-
publish_anon
(topic, message)[source]¶ publish an anonymous topic to the fncs bus.
Parameters: - topic –
- message –
Returns:
-
simulation_complete
¶
-
simulation_running
¶
-
simulation_started
¶
-
Submodules¶
volttron.platform.vip.agent.subsystems.auth module¶
-
class
volttron.platform.vip.agent.subsystems.auth.
Auth
(owner, core, rpc)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
volttron.platform.vip.agent.subsystems.base module¶
volttron.platform.vip.agent.subsystems.channel module¶
volttron.platform.vip.agent.subsystems.configstore module¶
-
class
volttron.platform.vip.agent.subsystems.configstore.
ConfigStore
(owner, core, rpc)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
delete
(config_name, trigger_callback=False, send_update=True)[source]¶ - Delete a configuration by name. May not be called from a callback as this will cause
- deadlock with the platform. Will produce a runtime error if done so.
Parameters:
-
delete_default
(config_name)[source]¶ Called to delete the contents of a default configuration file.
May not be called after the onsetup phase of an agents lifetime. Will produce a runtime error if done so.
Parameters: config_name (str) – Configuration to remove from store.
-
get
(config_name='config')[source]¶ Returns the contents of a configuration.
Parameters: config_name (str) – Name of configuration to add to store. Returns: Configuration contents Return type: dict, list, or string Return Values: The contents of the configuration specified.
-
list
()[source]¶ Returns a list of configuration names for this agent.
Returns: Configuration names Return type: list Return Values: A list of all the configuration names available for this agent.
-
set
(config_name, contents, trigger_callback=False, send_update=True)[source]¶ Called to set the contents of a configuration.
May not be called before the onstart phase of an agents lifetime.
May not be called from a configuration callback. Will produce a runtime error if done so.
Parameters:
-
set_default
(config_name, contents)[source]¶ Called to set the contents of a default configuration file. Default configurations are used if the configuration store does not contain a configuration with that name.
May not be called after the onsetup phase of an agents lifetime. Will produce a runtime error if done so.
Parameters:
-
subscribe
(callback, actions=set(['NEW', 'UPDATE', 'DELETE']), pattern='*')[source]¶ Subscribe to changes to a configuration.
Parameters: - callback (str) – Function to call in response to changes to a configuration.
- actions (str or list) – Change actions to respond to. Valid values are “NEW”, “UPDATE”, and “DELETE”. May be a single action or a list of actions.
- pattern (str) – Configuration name pattern to match to. Uses Unix style filename pattern matching.
-
volttron.platform.vip.agent.subsystems.health module¶
-
class
volttron.platform.vip.agent.subsystems.health.
Health
(owner, core, rpc)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
add_status_callback
(fn)[source]¶ Add callbacks to the passed function. The function must have the following interface
Parameters: - fn – The method to be executed when status is changed.
- fn – callable
-
get_status
()[source]¶ “RPC method
Returns the last updated status from the object with the context.
The minimum output from the status would be:
- {
- “status”: “GOOD”, “context”: None, “utc_last_update”: “2016-03-31T15:40:32.685138+0000”
}
-
get_status_json
()[source]¶ “RPC method
Returns the last updated status from the object with the context.
The minimum output from the status would be:
- {
- “status”: “GOOD”, “context”: None, “utc_last_update”: “2016-03-31T15:40:32.685138+0000”
}
-
volttron.platform.vip.agent.subsystems.heartbeat module¶
-
class
volttron.platform.vip.agent.subsystems.heartbeat.
Heartbeat
(owner, core, rpc, pubsub, heartbeat_autostart, heartbeat_period)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
restart
()[source]¶ RPC method
Restart the heartbeat with the current period. The heartbeat will be immediately sending the heartbeat to the message bus.
-
set_period
(period)[source]¶ RPC method
Set heartbeat period.
Parameters: period – Time in seconds between publishes.
-
volttron.platform.vip.agent.subsystems.hello module¶
-
class
volttron.platform.vip.agent.subsystems.hello.
Hello
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
The hello subsystem allows an agent to determine its identity.
The identity is possibly a dynamically generated uuid from which the executing agent does not know. This subsystem allows the agent to be able to determine it’s identity from a peer. By default that peer is the connected router, however this could be another agent.
-
hello
(peer='')[source]¶ Receives a welcome message from the peer (default to ‘’ router)
The welcome message will respond with a 3 element list:
- The vip version (default 1.0)
- The peer who responded (should be the same as peer argument to this function.
- The id of the requester (i.e. this object). This will be the identity when the agent connects to the router or the specified identity when the Agent is constructed.
Parameters: peer – The peer to receive the response from. Returns: [version, peer, identity]
-
volttron.platform.vip.agent.subsystems.peerlist module¶
-
class
volttron.platform.vip.agent.subsystems.peerlist.
PeerList
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
volttron.platform.vip.agent.subsystems.ping module¶
-
class
volttron.platform.vip.agent.subsystems.ping.
Ping
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
volttron.platform.vip.agent.subsystems.pubsub module¶
-
class
volttron.platform.vip.agent.subsystems.pubsub.
PubSub
(core, rpc_subsys, peerlist_subsys, owner)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
list
(peer, prefix='', bus='', subscribed=True, reverse=False, all_platforms=False)[source]¶ Gets list of subscriptions matching the prefix and bus for the specified peer. param peer: peer type peer: str param prefix: prefix of a topic type prefix: str param bus: bus type bus: bus param subscribed: subscribed or not type subscribed: boolean param reverse: reverse type reverse: :returns: List of subscriptions, i.e, list of tuples of bus, topic and flag to indicate if peer is a subscriber or not :rtype: list of tuples
Return Values: List of tuples [(topic, bus, flag to indicate if peer is a subscriber or not)]
-
publish
(peer, topic, headers=None, message=None, bus='')[source]¶ Publish a message to a given topic via a peer.
Publish headers and message to all subscribers of topic on bus. If peer is None, use self. Adds volttron platform version compatibility information to header as variables min_compatible_version and max_compatible version param peer: peer type peer: str param topic: topic for the publish message type topic: str param headers: header info for the message type headers: None or dict param message: actual message type message: None or any param bus: bus type bus: str return: Number of subscribers the message was sent to. :rtype: int
Return Values: Number of subscribers
-
unsubscribe
(peer, prefix, callback, bus='', all_platforms=False)[source]¶ Unsubscribe and remove callback(s).
Remove all handlers matching the given info - peer, callback and bus, which was used earlier to subscribe as well. If all handlers for a topic prefix are removed, the topic is also unsubscribed. param peer: peer type peer: str param prefix: prefix that needs to be unsubscribed type prefix: str param callback: callback method type callback: method param bus: bus type bus: bus return: success or not :rtype: boolean
Return Values: success or not
-
volttron.platform.vip.agent.subsystems.query module¶
-
class
volttron.platform.vip.agent.subsystems.query.
Query
(core)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
volttron.platform.vip.agent.subsystems.rpc module¶
-
class
volttron.platform.vip.agent.subsystems.rpc.
RPC
(core, owner)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
-
allow
(capabilities)[source]¶ Decorator specifies required agent capabilities to call a method.
This is designed to be used with the export decorator:
@RPC.export @RPC.allow('can_read_status') def get_status(): ...
Multiple capabilies can be provided in a list: .. code-block:: python
@RPC.allow([‘can_read_status’, ‘can_call_my_methods’])
-
volttron.platform.vip.agent.subsystems.volttronfncs module¶
-
class
volttron.platform.vip.agent.subsystems.volttronfncs.
FNCS
(owner, core, pubsub)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
The fncs subsystem allows an integration point between VOLTTRON and FNCS.
-
current_simulation_step
¶ returns the current fncs timestep.
Returns:
-
current_values
¶
-
fncs_installed
¶ Allows caller to determine if the fncs module is available.
-
fncs_version
¶
-
initialize
(sim_start_time, sim_length, topic_maping, work_callback, federate_name=None, broker_location='tcp://localhost:5570', time_delta='1s', stop_agent_when_sim_complete=False)[source]¶ Configure the agent to act as a federated connection to FNCS
- sim_start_time - Wall clock time for the simulation start time (This is not used at present time other
- than to be available)
sim_length - Time for the simulation to run. Should be formatted as <number><unit> i.e. 60s.
topic_mapping - Maps fncs topics onto volttron topics.
- federate_name - MUST be unique to the broker. If None, then will be the
- identity of the current agent process.
broker - tcp location of the fncs broker (defaults to tcp://localhost:5570)
time_delta - Minimum timestep supported for the federate.
stop_agent_when_sim_complete - Should we stop the agent when the simulation is completed.
Parameters: - sim_start_time –
- sim_length –
- topic_maping –
- work_callback –
- federate_name –
- broker_location –
- time_delta –
- poll_timeout –
Returns:
-
parse_time
(time_string)[source]¶ Parses a <number><unit> i.e. 60s to a fncs timestep number.
Parameters: time_string – Returns:
-
publish
(topic, message)[source]¶ publish a topic to the fncs bus.
The publish will only be sent if there is a federate subscribed to the topic that is being published.
Parameters: - topic –
- message –
Returns:
-
publish_anon
(topic, message)[source]¶ publish an anonymous topic to the fncs bus.
Parameters: - topic –
- message –
Returns:
-
simulation_complete
¶
-
simulation_running
¶
-
simulation_started
¶
-
volttron.platform.vip.agent.subsystems.web module¶
-
class
volttron.platform.vip.agent.subsystems.web.
WebSubSystem
(owner, core, rpc)[source]¶ Bases:
volttron.platform.vip.agent.subsystems.base.SubsystemBase
The web subsystem handles the agent side of routing web data from the
volttron.platform.web.MasterWebService
.-
register_endpoint
(endpoint, callback, res_type='jsonrpc')[source]¶ The
register_endpoint()
method registers an endpoint with thevolttron.platform.web.MasterWebService
on the VOLTTRON instance.Each endpoint can map to at most one callback function. The callback function must support the following interface
def callback(self, env, data): print('The environmental variables {}'.format(env)) print('The data sent {}'.format(data))
New in version VOLTTRON: 4.0.1
Parameters: - endpoint (str) – Http endpoint matching the PATH_INFO environmental variable
- callback (function) – Agent method to be called with the env and data.
-
register_path
(prefix, static_path)[source]¶ The
register_path()
method registers a prefix that can be used for routing static files.New in version VOLTTRON: 4.0.1
Parameters: - prefix (str) –
- static_path (str) – An existing path available to the
volttron.platform.web.MasterWebService
-
register_websocket
(endpoint, opened=None, closed=None, received=None)[source]¶ The
register_websocket()
method registers a websocket endpoint that can be connected to through thevolttron.platform.web.MasterWebService
.The parameters opened and closed can be specified as callback events with the following signature:
def ws_opened(self, endpoint): print('ws_opened endpoint {}'.format(endpoint)) def ws_closed(self, endpoint): print('ws_closed endpoint {}'.format(endpoint))
The received event is triggered when the websocket is writtent to fro the client. The received event must have a signature such as the following interface:
def ws_received(self, endpoint, message): print('ws_received endpoint {} message: {}'.format(endpoint, message))
New in version VOLTTRON: 4.0.1
Parameters: - endpoint (str) – The endpoint of the websocket event occurred on.
- opened (function) – An event triggered when a client is connected to the endpoint.
- closed (function) – An event triggered when a client is closed or disconnected from the endpoint.
- received (function) – An event triggered when data comes in on the endpoint’s websocket.
-