本文整理汇总了Python中volttron.platform.get_services_core函数的典型用法代码示例。如果您正苦于以下问题:Python get_services_core函数的具体用法?Python get_services_core怎么用?Python get_services_core使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_services_core函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: agent
def agent(request, volttron_instance):
"""Build MasterDriverAgent and add DNP3 driver config to it."""
def update_config(agent_id, name, value, cfg_type):
test_agent.vip.rpc.call('config.store', 'manage_store', agent_id, name, value, config_type=cfg_type)
test_agent = volttron_instance.build_agent()
# Build and start DNP3Agent
dnp3_agent_uuid = volttron_instance.install_agent(agent_dir=get_services_core("DNP3Agent"),
config_file=DNP3_AGENT_CONFIG,
vip_identity=DNP3_AGENT_ID,
start=True)
# Build and start MasterDriverAgent
test_agent.vip.rpc.call('config.store', 'manage_delete_store', MASTER_DRIVER_AGENT_ID)
update_config(MASTER_DRIVER_AGENT_ID, 'devices/dnp3', DRIVER_CONFIG_STRING, 'json')
update_config(MASTER_DRIVER_AGENT_ID, 'dnp3.csv', REGISTRY_CONFIG_STRING, 'csv')
master_uuid = volttron_instance.install_agent(agent_dir=get_services_core("MasterDriverAgent"),
config_file={},
start=True)
gevent.sleep(3) # Wait for the agent to start and start the devices
def stop():
volttron_instance.stop_agent(master_uuid)
volttron_instance.stop_agent(dnp3_agent_uuid)
test_agent.core.stop()
request.addfinalizer(stop)
return test_agent
示例2: test_agent
def test_agent(request, get_volttron_instances):
"""
Fixture that initializes VOLTTRON agents for ReferenceAppAgent test cases.
Start a VOLTTRON instance running a web agent,
then install and start an OpenADRVenAgent, a ReferenceAppAgent, a SimulationDriverAgent,
an ActuatorAgent, and a test agent.
"""
instance = get_volttron_instances(1, should_start=False)
start_wrapper_platform(instance, with_http=True)
# Install and start a WebAgent.
web_agent = _build_web_agent(instance.volttron_home)
gevent.sleep(1)
web_agent_uuid = instance.install_agent(agent_dir=web_agent)
global web_server_address
web_server_address = instance.bind_web_address
global volttron_home
volttron_home = instance.volttron_home
def issue_config_rpc(test_agt, config_request, *args):
return test_agt.vip.rpc.call('config.store', config_request, SIMULATION_DRIVER_ID, *args).get(timeout=10)
def start_agent(id, dir, config):
return instance.install_agent(vip_identity=id, agent_dir=dir, config_file=config, start=True)
test_agt = instance.build_agent(identity=TEST_AGENT_ID)
issue_config_rpc(test_agt, 'manage_delete_store')
for param_dict in DRIVER_PARAMS:
device_id = param_dict['id']
issue_config_rpc(test_agt, 'manage_store', 'devices/campus1/building1/{}'.format(device_id), param_dict['config'], 'json')
issue_config_rpc(test_agt, 'manage_store', '{}.csv'.format(device_id), param_dict['points'], 'csv')
clock_uuid = start_agent(SIMULATION_CLOCK_ID, 'applications/kisensum/Simulation/SimulationClockAgent', SIMULATION_CLOCK_CONFIG)
sim_driver_uuid = start_agent(SIMULATION_DRIVER_ID, 'applications/kisensum/Simulation/SimulationDriverAgent', {})
actuator_uuid = start_agent(ACTUATOR_ID, get_services_core('ActuatorAgent'), ACTUATOR_CONFIG)
ven_uuid = start_agent(VEN_AGENT_ID, get_services_core('OpenADRVenAgent'), VEN_AGENT_CONFIG)
ref_app_uuid = start_agent(REFERENCE_APP_ID, 'applications/kisensum/ReferenceAppAgent', REFERENCE_APP_CONFIG)
def stop():
instance.stop_agent(actuator_uuid)
instance.stop_agent(ref_app_uuid)
instance.stop_agent(sim_driver_uuid)
instance.stop_agent(ven_uuid)
instance.stop_agent(clock_uuid)
instance.stop_agent(web_agent_uuid)
test_agt.core.stop()
instance.shutdown_platform()
gevent.sleep(10)
request.addfinalizer(stop)
yield test_agt
示例3: failover
def failover(request, get_volttron_instances):
global primary_config
global secondary_config
global primary_failover
global secondary_failover
global vc_uuid
primary, secondary, vc = get_volttron_instances(3)
primary.allow_all_connections()
secondary.allow_all_connections()
vc.allow_all_connections()
# configure vc
vc_uuid = vc.install_agent(
agent_dir=get_services_core("VolttronCentralPlatform"))
# configure primary
primary_platform = primary.install_agent(
agent_dir=get_services_core("VolttronCentralPlatform"))
# register with vc
primary_listener = primary.install_agent(agent_dir=get_examples("ListenerAgent"),
vip_identity="listener",
start=False)
primary_config["remote_vip"] = tcp_to(secondary)
primary_failover = primary.install_agent(agent_dir=get_services_core("FailoverAgent"),
config_file=primary_config)
# configure secondary
secondary_platform = secondary.install_agent(agent_dir=get_services_core("VolttronCentralPlatform"))
# register with vc
secondary_listener = secondary.install_agent(agent_dir=get_examples("ListenerAgent"),
vip_identity="listener",
start=False)
secondary_config["remote_vip"] = tcp_to(primary)
secondary_failover = secondary.install_agent(agent_dir=get_services_core("FailoverAgent"),
config_file=secondary_config)
def stop():
vc.stop_agent(vc_uuid)
vc.shutdown_platform()
primary.stop_agent(primary_failover)
primary.stop_agent(primary_platform)
primary.stop_agent(primary_listener)
primary.shutdown_platform()
secondary.stop_agent(secondary_failover)
secondary.stop_agent(secondary_platform)
secondary.stop_agent(secondary_listener)
secondary.shutdown_platform()
request.addfinalizer(stop)
return primary, secondary, vc
示例4: agent
def agent(request, volttron_instance_module_web):
test_agent = volttron_instance_module_web.build_agent()
# Configure a SEP2 device in the Master Driver
test_agent.vip.rpc.call('config.store', 'manage_delete_store', 'platform.driver').get(timeout=10)
test_agent.vip.rpc.call('config.store', 'manage_store', 'platform.driver',
'devices/{}'.format(DRIVER_NAME),
"""{
"driver_config": {
"sfdi": "097935300833",
"sep2_agent_id": "test_sep2agent"
},
"campus": "campus",
"building": "building",
"unit": "sep2",
"driver_type": "sep2",
"registry_config": "config://sep2.csv",
"interval": 15,
"timezone": "US/Pacific",
"heart_beat_point": "Heartbeat"
}""",
'json').get(timeout=10)
test_agent.vip.rpc.call('config.store', 'manage_store', 'platform.driver',
'sep2.csv',
REGISTRY_CONFIG_STRING,
'csv').get(timeout=10)
# Install and start a SEP2Agent
sep2_id = volttron_instance_module_web.install_agent(agent_dir=get_services_core("SEP2Agent"),
config_file=TEST_SEP2_CONFIG,
vip_identity='test_sep2agent',
start=True)
print('sep2 agent id: ', sep2_id)
# Install and start a MasterDriverAgent
md_id = volttron_instance_module_web.install_agent(agent_dir=get_services_core("MasterDriverAgent"),
config_file={},
start=True)
print('master driver agent id: ', md_id)
global web_address
web_address = volttron_instance_module_web.bind_web_address
def stop():
volttron_instance_module_web.stop_agent(md_id)
volttron_instance_module_web.stop_agent(sep2_id)
test_agent.core.stop()
gevent.sleep(3) # wait for agents and devices to start
request.addfinalizer(stop)
return test_agent
示例5: test_resinstall_agent
def test_resinstall_agent(volttron_instance):
mysql_config = {
"connection": {
"type": "mysql",
"params": {
"host": "localhost",
"port": 3306,
"database": "test_historian",
"user": "historian",
"passwd": "historian"
}
}
}
for i in range(0,50):
print("Counter: {}".format(i))
# auuid = volttron_instance.install_agent(
# agent_dir=get_examples("ListenerAgent",
# vip_identity='test_listener',
# start=True)
auuid = volttron_instance.install_agent(
agent_dir=get_services_core("SQLHistorian"),
config_file=mysql_config,
start=True,
vip_identity='test_historian')
assert volttron_instance.is_agent_running(auuid)
volttron_instance.remove_agent(auuid)
示例6: test_poll_valid
def test_poll_valid(volttron_instance, publish_agent, locations, result_topics):
global publish_agent_v2, API_KEY
uuid = None
try:
config = {
"operation_mode": 2,
"wu_api_key": API_KEY,
"locations": locations,
"poll_time": 20
}
uuid = volttron_instance.install_agent(
vip_identity='weather_agent',
agent_dir=get_services_core("WeatherAgent"),
config_file=config,
start=False)
# reset mock to ignore any previous callback
publish_agent.process_poll_result.reset_mock()
publish_agent.process_error.reset_mock()
volttron_instance.start_agent(uuid)
gevent.sleep(10)
assert publish_agent.process_poll_result.call_count == len(locations)
assert publish_agent.process_error.call_count == 0
call_args_list = publish_agent.process_poll_result.call_args_list
i = 0
for args in call_args_list:
assert args[0][3] == result_topics[i]
assert_weather_response(args[0])
i += 1
finally:
if uuid:
volttron_instance.remove_agent(uuid)
示例7: add_forward_historian
def add_forward_historian(wrapper, config={}, **kwargs):
agent_uuid = wrapper.install_agent(
config_file=config,
agent_dir=get_services_core("ForwardHistorian"),
**kwargs
)
return agent_uuid
示例8: test_reconnect_forwarder
def test_reconnect_forwarder(get_volttron_instances):
from_instance, to_instance = get_volttron_instances(2, True)
to_instance.allow_all_connections()
publisher = from_instance.build_agent()
receiver = to_instance.build_agent()
forwarder_config = deepcopy(BASE_FORWARD_CONFIG)
#forwardtoaddr = build_vip_address(to_instance, receiver)
#print("FORWARD ADDR: {}".format(forwardtoaddr))
forwarder_config['destination-vip'] = to_instance.vip_address
forwarder_config['destination-serverkey'] = to_instance.keystore.public
fuuid = from_instance.install_agent(
agent_dir=get_services_core("ForwardHistorian"),start=True,
config_file=forwarder_config)
assert from_instance.is_agent_running(fuuid)
print('Before Subscribing')
receiver.vip.pubsub.subscribe('pubsub', '', callback=onmessage)
publisher.vip.pubsub.publish('pubsub', 'stuff', message='Fuzzy')
gevent.sleep(.2)
num_messages = 5
for i in range(num_messages):
do_publish(publisher)
for i in range(len(publishedmessages)):
assert allforwardedmessage[i] == publishedmessages[i]
示例9: agent
def agent(request, volttron_instance):
"""Build the test agent for rpc call."""
test_agent = volttron_instance.build_agent()
add_definitions_to_config_store(test_agent)
print('Installing Mesa Agent')
os.environ['AGENT_MODULE'] = 'dnp3.mesa.agent'
agent_id = volttron_instance.install_agent(agent_dir=get_services_core("DNP3Agent"),
config_file=MESA_AGENT_CONFIG,
vip_identity=MESA_AGENT_ID,
start=True)
# Subscribe to MESA functions
test_agent.vip.pubsub.subscribe(peer='pubsub',
prefix='mesa/function',
callback=onmessage)
def stop():
"""Stop test agent."""
if volttron_instance.is_running():
volttron_instance.stop_agent(agent_id)
volttron_instance.remove_agent(agent_id)
test_agent.core.stop()
gevent.sleep(3) # wait for agents and devices to start
request.addfinalizer(stop)
return test_agent
示例10: vc_instance
def vc_instance(request, volttron_instance1_web):
"""
Creates an instance of volttron with a `VolttronCentral` agent
already installed and started.
:returns tuple:
- the PlatformWrapper
- the uuid of the `VolttronCentral` agent.
- the jsonrpc address to be used for communicating with the
`VolttronCentral` agent.
"""
agent_uuid = volttron_instance1_web.install_agent(
agent_dir=get_services_core("VolttronCentral"),
config_file=VC_CONFIG,
start=True
)
rpc_addr = volttron_instance1_web.jsonrpc_endpoint
# Allow all incoming connections that are encrypted.
volttron_instance1_web.allow_all_connections()
def cleanup():
print('Cleanup vc_instance')
volttron_instance1_web.remove_agent(agent_uuid)
print_log(volttron_instance1_web.volttron_home)
request.addfinalizer(cleanup)
return volttron_instance1_web, agent_uuid, rpc_addr
示例11: forwarder
def forwarder(request, volttron_instances):
#print "Fixture forwarder"
global volttron_instance1, volttron_instance2
global forwarder_uuid, forwarder_config
# 1. Update destination address in forwarder configuration
volttron_instance1.allow_all_connections()
volttron_instance2.allow_all_connections()
# setup destination address to include keys
known_hosts_file = os.path.join(volttron_instance1.volttron_home, 'known_hosts')
known_hosts = KnownHostsStore(known_hosts_file)
known_hosts.add(volttron_instance2.vip_address, volttron_instance2.serverkey)
forwarder_config["destination-vip"] = volttron_instance2.vip_address
forwarder_config["destination-serverkey"] = volttron_instance2.serverkey
# 1: Install historian agent
# Install and start sqlhistorian agent in instance2
forwarder_uuid = volttron_instance1.install_agent(
agent_dir=get_services_core("ForwardHistorian"),
config_file=forwarder_config,
start=True)
print("forwarder agent id: ", forwarder_uuid)
示例12: simple_failover
def simple_failover(request, get_volttron_instances):
global simple_primary_config
global simple_secondary_config
global uuid_primary
global uuid_secondary
global listener_primary
primary, secondary = get_volttron_instances(2)
primary.allow_all_connections()
secondary.allow_all_connections()
# configure primary
listener_primary = primary.install_agent(agent_dir=get_examples("ListenerAgent"),
vip_identity="listener",
start=False)
simple_primary_config["remote_vip"] = secondary.vip_address
simple_primary_config["remote_serverkey"] = secondary.serverkey
uuid_primary = primary.install_agent(agent_dir=get_services_core("FailoverAgent"),
config_file=simple_primary_config)
# configure secondary
listener_secondary = secondary.install_agent(agent_dir=get_examples("ListenerAgent"),
vip_identity="listener",
start=False)
simple_secondary_config["remote_vip"] = primary.vip_address
simple_secondary_config["remote_serverkey"] = primary.serverkey
uuid_secondary = secondary.install_agent(agent_dir=get_services_core("FailoverAgent"),
config_file=simple_secondary_config)
gevent.sleep(SLEEP_TIME)
assert all_agents_running(primary)
assert not all_agents_running(secondary)
def cleanup():
primary.stop_agent(uuid_primary)
primary.stop_agent(listener_primary)
primary.shutdown_platform()
secondary.stop_agent(uuid_secondary)
secondary.stop_agent(listener_secondary)
secondary.shutdown_platform()
request.addfinalizer(cleanup)
return primary, secondary
示例13: add_volttron_central_platform
def add_volttron_central_platform(wrapper, config={}, **kwargs):
print('Adding vcp to {}'.format(wrapper.vip_address))
agent_uuid = wrapper.install_agent(
config_file=config,
agent_dir=get_services_core("VolttronCentralPlatform"),
vip_identity=VOLTTRON_CENTRAL_PLATFORM
)
return agent_uuid
示例14: add_mongohistorian
def add_mongohistorian(wrapper, config, vip_identity='platform.historian',
**kwargs):
agent_uuid = wrapper.install_agent(
config_file=config,
agent_dir=get_services_core("MongodbHistorian"),
vip_identity=vip_identity,
**kwargs
)
return agent_uuid
示例15: add_listener
def add_listener(wrapper, config={}, vip_identity=None, **kwargs):
print("Adding to {wrapper} a listener agent".format(wrapper=wrapper))
agent_uuid = wrapper.install_agent(
config_file=config,
vip_identity=vip_identity,
agent_dir=get_services_core("ListenerAgent"),
**kwargs
)
return agent_uuid