Skip to content
jhaack edited this page Sep 12, 2014 · 7 revisions

Full code of agent detailed in AgentDevelopment:

import sys

from volttron.lite.agent import BaseAgent, PublishMixin
from volttron.lite.agent import utils, matching
from volttron.lite.messaging import headers as headers_mod

class TestAgent(PublishMixin, BaseAgent):

    @matching.match_start('heartbeat/listeneragent')
    def on_heartbeat_topic(self, topic, headers, message, match):
           print "TestAgent got\nTopic: {topic}, {headers}, Message: {message}".format(topic=topic,
                  headers=headers, message=message)

def main(argv=sys.argv):
    '''Main method called by the eggsecutable.'''
    utils.default_main(TestAgent,
                   description='Test Agent',
                   argv=argv)


if __name__ == '__main__':
    # Entry point for script
    try:
        sys.exit(main())
    except KeyboardInterrupt:
        pass

Contents of setup.py for TestAgent:

from setuptools import setup, find_packages

packages = find_packages('.')
package = packages[0]

setup(
    name = package + 'agent',
    version = "0.1",
    install_requires = ['volttronlite'],
    packages = packages,
    entry_points = {
        'setuptools.installation': [
            'eggsecutable = ' + package + '.agent:main',
        ]
    }
)

Contents of testagent.launch.json

{
    "agent": {
        "exec": "testeragent-0.1-py2.7.egg --config \"%c\" --sub \"%s\" --pub \"%p\""
    },
    "agentid": "Test1",
    "message": "hello"    
}

Arguments for testeragent:

--config_path Agents/TestAgent/testeragent.launch.json --pub ipc:///tmp/volttron-lite-agent-publish --sub ipc:///tmp/volttron-lite-agent-subscribe

Wiki Home

Quick Start Guide

Getting VOLTTRON

VOLTTRON Community

VOLTTRON Core Services

Historians

Drivers

Instance Management

Applications
  • ...
Examples
Developers
HOWTOS

VOLTTRON Versions and Features

Transactional Network Platform Overview

Platform Services

Volttron Restricted

Information Exchange Standards

FAQ

Project Home

Clone this wiki locally