Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit bbe9d067 authored by Markus Mirz's avatar Markus Mirz
Browse files

add villas config python files


Signed-off-by: Markus Mirz's avatarMarkus Mirz <mmirz@eonerc.rwth-aachen.de>
parent fa8a4daa
#build/Examples/Cxx/Shmem_CIGRE_MV_PowerFlowTest_LoadProfiles
#villas-node Configs/shmem_CIGRE_MV_PF/Shmem_CIGRE_MV.conf
import asyncio
import time
async def run(cmd):
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
time.sleep(30)
proc.kill()
stdout, stderr = await proc.communicate()
print(f'[{cmd!r} exited with {proc.returncode}]')
if stdout:
print(f'[stdout]\n{stdout.decode()}')
if stderr:
print(f'[stderr]\n{stderr.decode()}')
async def main():
await asyncio.gather(
run('villas-node villas-node.conf'),
run('sleep 1; echo "hello"'))
villas_conf = """
nodes = {
broker1 = {
type = "mqtt"
format = "json"
host = "172.17.0.1"
in = {
subscribe = "/powerflow-dpsim"
}
out = {
publish = "/dpsim-powerflow"
}
}
dpsim1 = {
type = "shmem"
in = {
name = "/dpsim1-villas", # Name of shared memory segment for sending side
hooks = (
{
type = "stats"
}
),
signals = {
count = 30
type = "float"
}
},
out = {
name = "/villas-dpsim1" # Name of shared memory segment for receiving side
}
}
}
paths = (
{
in = "dpsim1"
out = "broker1"
hooks = (
{
type = "limit_rate"
rate = 50
}
)
}
)"""
with open("villas-node.conf", "w") as text_file:
text_file.write("%s" % villas_conf)
#asyncio.run(main())
import time
from villas.node.node import Node as VILLASnode
# This could be moved to the DPsim Python code later
def get_dpsim_shmem_interface_config():
return {
'type': 'shmem',
'in': {
'name': '/dpsim1-villas',
'hooks': [
{'type': 'stats'}
],
'signals': {
'count': 30,
'type': 'float'
}
},
'out': {
'name': '/villas-dpsim1'
}
}
def get_villas_config():
return {
'nodes': {
'broker1': {
'type': 'mqtt',
'format': 'json',
'host': '172.17.0.1',
'in': {
'subscribe': '/powerflow-dpsim'},
'out': {
'publish': '/dpsim-powerflow'
}
},
'dpsim1': get_dpsim_shmem_interface_config(),
},
'paths': [
{
'in': 'dpsim1',
'out': 'broker1',
'hooks': [
{
'type': 'limit_rate',
'rate': 50
}
]
}
]
}
def main():
node = VILLASnode(
config=get_villas_config()
)
node.start() # VILLASnode starts running in the background from here..
# Some infos from the running VILLASnode instance queried via its REST API
print('VILLASnode running?: ', node.is_running())
print('VILLASnode status: ', node.status)
print('VILLASnode nodes: ', node.nodes)
print('VILLASnode paths: ', node.paths)
print('VILLASnode config: ', node.active_config)
print('VILLASnode version: ', node.get_version())
# Load a new config into the running VILLASnode instance (old config will be replaced)
new_config = node.active_config
new_config['paths'].append({
'out': 'dpsim1',
'in': 'broker1'
})
node.load_config(new_config)
time.sleep(100)
node.stop()
if __name__ == '__main__':
main()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment