VILLASframework
Modular co-simulation framework
Lab 12: WebSockets
villas_node_websocket.svg

In this lab we will show you the VILLASnode WebSockets mockup. The mockup is a simple webpage which receives / sends simulation from / to VILLASnode by using low latency WebSockets.

This technique is usefull for live monitoring and user interaction with simulations.

The configuration file

1 nodes = {
2  udp_node1 = {
3  type = "socket",
4  layer = "udp",
5 
6  in = {
7  address = "*:12000"
8 
9  signals = {
10  count = 8,
11  type = "float"
12  }
13  },
14  out = {
15  address = "127.0.0.1:12001"
16  }
17  },
18  web_node1 = {
19  type = "websocket",
20 
21  vectorize = 2,
22  series = (
23  { label = "Random walk", unit = "V" },
24  { label = "Sine", unit = "A" },
25  { label = "Rect", unit = "Var" },
26  { label = "Ramp", unit = "°C" }
27  )
28  }
29 }
30 
31 paths = (
32  {
33  in = [ "udp_node1" ],
34  out = [ "web_node1" ],
35 
36  hooks = (
37  # We dont want to overload the WebBrowsers
38  { type = "decimate", ratio = 2 }
39  )
40  },
41  {
42  in = [ "web_node1" ],
43  out = [ "udp_node1" ]
44 
45  # Web -> UDP does not require decimation
46  }
47 )

Start node and signal generator

$ villas signal -v 4 -r 120 mixed | villas pipe -x lab3.conf udp_node1 &
$ villas node lab12.conf

Web Mockup

web_mockup.png

Go to [lab 13] =>(node-lab-13)