volttron.platform.vip.agent package

class volttron.platform.vip.agent.Agent(identity=None, address=None, context=None, publickey=None, secretkey=None, serverkey=None, heartbeat_autostart=False, heartbeat_period=60, volttron_home='/home/docs/.volttron', agent_uuid=None, enable_store=True, enable_web=False, enable_channel=False, reconnect_interval=None, version='0.1', enable_fncs=False)[source]

Bases: object

class Subsystems(owner, core, heartbeat_autostart, heartbeat_period, enable_store, enable_web, enable_channel, enable_fncs)[source]

Bases: object

class volttron.platform.vip.agent.BasicAgent(**kwargs)[source]

Bases: object

Submodules

volttron.platform.vip.agent.compat module

class volttron.platform.vip.agent.compat.CompatPubSub(identity=None, address=None, context=None, peer='pubsub', publish_address='inproc://vip/compat/agent/publish', subscribe_address='inproc://vip/compat/agent/subscribe')[source]

Bases: object

VOLTTRON 2.x compatible agent pub/sub message exchange bus.

Accept multi-part messages from sockets connected to in_addr, which is a PULL socket, and forward them to sockets connected to out_addr, which is a XPUB socket. When subscriptions are added or removed, a message of the form ‘subscriptions/<OP>/<TOPIC>’ is broadcast to the PUB socket where <OP> is either ‘add’ or ‘remove’ and <TOPIC> is the topic being subscribed or unsubscribed. When a message is received of the form ‘subscriptions/list/<PREFIX>’, a multipart message will be broadcast with the first two received frames (topic and headers) sent unchanged and with the remainder of the message containing currently subscribed topics which start with <PREFIX>, each frame containing exactly one topic.

PEER = 'pubsub'
PUBLISH_ADDRESS = 'inproc://vip/compat/agent/publish'
SUBSCRIBE_ADDRESS = 'inproc://vip/compat/agent/subscribe'
forward(peer, sender, bus, topic, headers, message)[source]
in_loop(sender, **kwargs)[source]
out_loop(sender, **kwargs)[source]
setup(sender, **kwargs)[source]
volttron.platform.vip.agent.compat.unpack_legacy_message(headers, message)[source]

Unpack legacy pubsub messages for VIP agents.

Loads JSON-formatted message parts and removes single-frame messages from their containing list. Does not alter headers.

volttron.platform.vip.agent.connection module

class volttron.platform.vip.agent.connection.Connection(address, peer=None, publickey=None, secretkey=None, serverkey=None, volttron_home=None, **kwargs)[source]

Bases: object

A class that manages a connection to a peer and/or server.

address
call(method, *args, **kwargs)[source]
connected_since
is_connected(timeout=30)[source]
is_peer_connected(timeout=30)[source]
kill(*args, **kwargs)[source]
last_publish
last_publish_failed
last_rpc_call
notify(method, *args, **kwargs)[source]
peer
peers(timeout=30)[source]
publish(topic, headers=None, message=None, timeout=30)[source]
server
serverkey
subscribe(prefix, callback)[source]

volttron.platform.vip.agent.core module

class volttron.platform.vip.agent.core.BasicCore(owner)[source]

Bases: object

delay_onstart_signal = False
delay_running_event_set = False
loop(running_event)[source]
periodic(period, args=None, kwargs=None, wait=0)[source]
classmethod receiver(signal)[source]
run(running_event=None)[source]

Entry point for running agent.

schedule(deadline, *args, **kwargs)[source]
send(func, *args, **kwargs)[source]
send_async(func, *args, **kwargs)[source]
setup()[source]
spawn(func, *args, **kwargs)[source]
spawn_in_thread(func, *args, **kwargs)[source]
spawn_later(seconds, func, *args, **kwargs)[source]
stop(timeout=None)[source]
class volttron.platform.vip.agent.core.Core(owner, address=None, identity=None, context=None, publickey=None, secretkey=None, serverkey=None, volttron_home='/home/docs/.volttron', agent_uuid=None, reconnect_interval=None, version='0.1', enable_fncs=False)[source]

Bases: volttron.platform.vip.agent.core.BasicCore

connected
delay_onstart_signal = True
delay_running_event_set = True
handle_error(message)[source]
loop(running_event)[source]
register(name, handler, error_handler=None)[source]
version()[source]
volttron.platform.vip.agent.core.killing(*args, **kwds)[source]

Context manager to automatically kill spawned greenlets.

Allows one to kill greenlets that would continue after a timeout:

with killing(agent.vip.pubsub.subscribe(
‘peer’, ‘topic’, callback)) as subscribe:

subscribe.get(timeout=10)

volttron.platform.vip.agent.decorators module

volttron.platform.vip.agent.decorators.annotate(obj, kind, name, value)[source]
volttron.platform.vip.agent.decorators.annotations(obj, kind, name)[source]
class volttron.platform.vip.agent.decorators.dualmethod(finstance=None, fclass=None, doc=None)[source]

Bases: object

Descriptor to allow class and instance methods of the same name.

This class implements a descriptor that works similar to the classmethod() built-ins and can be used as a decorator, like the property() built-in. Instead of a method being only a class or instance method, two methods can share the same name and be accessed as an instance method or a class method based on the context.

Example:

>>> class Foo(object):
...     @dualmethod
...     def bar(self):
...         print 'instance method for', self
...     @bar.classmethod
...     def bar(cls):
...         print 'class method for', cls
...
>>> Foo.bar()
class method for <class '__main__.Foo'>
>>> Foo().bar()
instance method for <__main__.Foo object at 0x7fcd744f6610>
>>>
classmethod(fclass)[source]

Descriptor to set the class method.

instancemethod(finstance)[source]

Descriptor to set the instance method.

volttron.platform.vip.agent.decorators.spawn(method)[source]

Run a decorated method in its own greenlet, which is returned.

volttron.platform.vip.agent.dispatch module

class volttron.platform.vip.agent.dispatch.Signal[source]

Bases: object

connect(receiver, owner=None)[source]
disconnect(receiver)[source]
receiver(func)[source]
send(sender, **kwargs)[source]
sendby(executor, sender, **kwargs)[source]

volttron.platform.vip.agent.errors module

exception volttron.platform.vip.agent.errors.VIPError(errnum, msg, peer, subsystem, *args)[source]

Bases: exceptions.Exception

classmethod from_errno(errnum, msg, *args)[source]
exception volttron.platform.vip.agent.errors.Unreachable(errnum, msg, peer, subsystem, *args)[source]

Bases: volttron.platform.vip.agent.errors.VIPError

exception volttron.platform.vip.agent.errors.Again(errnum, msg, peer, subsystem, *args)[source]

Bases: volttron.platform.vip.agent.errors.VIPError

exception volttron.platform.vip.agent.errors.UnknownSubsystem(errnum, msg, peer, subsystem, *args)[source]

Bases: volttron.platform.vip.agent.errors.VIPError

volttron.platform.vip.agent.example module

class volttron.platform.vip.agent.example.ExampleAgent(identity=None, address=None, context=None, publickey=None, secretkey=None, serverkey=None, heartbeat_autostart=False, heartbeat_period=60, volttron_home='/home/docs/.volttron', agent_uuid=None, enable_store=True, enable_web=False, enable_channel=False, reconnect_interval=None, version='0.1', enable_fncs=False)[source]

Bases: volttron.platform.vip.agent.Agent

baz()[source]
finish(sender, **kwargs)[source]
foo()[source]
goodbye(name)[source]
hello(name)[source]
onmessage(peer, sender, bus, topic, headers, message)[source]
saybye()[source]
sayhi()[source]
setup(sender, **kwargs)[source]
starting(sender, **kwargs)[source]
stopping(sender, **kwargs)[source]
volttron.platform.vip.agent.example.meh()[source]

volttron.platform.vip.agent.results module

volttron.platform.vip.agent.results.counter(start=None, minimum=0, maximum=18446744073709551615L)[source]
class volttron.platform.vip.agent.results.ResultsDictionary[source]

Bases: weakref.WeakValueDictionary

next()[source]

volttron.platform.vip.agent.utils module

volttron.platform.vip.agent.utils.build_agent(address='ipc://@/home/docs/.volttron/run/vip.socket', identity=None, publickey='iPdbzl2rdC9F3wm8uhzwdxKTEz-OCUTwKYOPeoNM9gA', secretkey='eIXfDeg5TogIlYdwareZ0JjOKKBXrAiRAn1CgJOWuVE', timeout=10, serverkey=None, agent_class=<class 'volttron.platform.vip.agent.Agent'>, **kwargs)[source]

Builds a dynamic agent connected to the specifiedd address.

All key parameters should have been encoded with volttron.platform.vip.socket.encode_key()

Parameters:
  • address (str) – VIP address to connect to
  • identity (str) – Agent’s identity
  • publickey (str) – Agent’s Base64-encoded CURVE public key
  • secretkey (str) – Agent’s Base64-encoded CURVE secret key
  • serverkey (str) – Server’s Base64-encoded CURVE public key
  • agent_class (class) – Class to use for creating the instance
  • timeout (int) – Seconds to wait for agent to start
  • kwargs – Any Agent specific parameters
Returns:

an agent based upon agent_class that has been started

Return type:

agent_class

volttron.platform.vip.agent.utils.build_connection(identity, peer='', address='ipc://@/home/docs/.volttron/run/vip.socket', publickey='iPdbzl2rdC9F3wm8uhzwdxKTEz-OCUTwKYOPeoNM9gA', secretkey='eIXfDeg5TogIlYdwareZ0JjOKKBXrAiRAn1CgJOWuVE', **kwargs)[source]