Skip to content
Snippets Groups Projects
Commit b82acd13 authored by JuanPi Carbajal's avatar JuanPi Carbajal
Browse files

plotter_single.py: add hostname option, write some more documentation in readme.md

parent 0e614e54
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,9 @@ from matplotlib.animation import FuncAnimation
from collections import deque
from time import time, sleep
from logger_single import TORQUE, SPEED, PORT
class plotter (object):
def __init__ (self, port, key, label, **kwargs):
def __init__ (self, hostname, port, key, label, **kwargs):
print('\n## Wind turbine HSR {} plotter ##'.format(label))
self.key = u'{}'.format(key)
......@@ -47,7 +45,7 @@ class plotter (object):
# Socket to talk to server
self.context = zmq.Context()
self.socket = self.context.socket(zmq.SUB)
addr = 'tcp://localhost:{}'.format(port)
addr = 'tcp://{}:{}'.format(hostname, port)
self.socket.connect(addr)
self.socket.setsockopt_string(zmq.SUBSCRIBE, self.key)
print(' done!')
......@@ -57,11 +55,11 @@ class plotter (object):
sys.stdout.write('Initializing matplotlib figure ...')
sys.stdout.flush()
self.label = label
self.blit = False
self.fig = plt.figure()
self.ax = self.fig.add_subplot(2, 1, 1)
self.ax_text = self.fig.add_subplot(2, 1, 2)
self.label = label
self.blit = False
self.fig = plt.figure()
self.ax = self.fig.add_subplot(2, 1, 1)
self.ax_text = self.fig.add_subplot(2, 1, 2)
print(' done!')
self.start_t = time()
......@@ -192,17 +190,18 @@ class plotter (object):
if __name__ == "__main__":
import getopt
from logger_single import TORQUE, SPEED, PORT
def parse_options (args):
hlp_str = 'plotter.py -d <deque size> -s <sensor : T,W>'
options = {'DSize':1000}
hlp_str = 'plotter.py -d <deque size> -s <sensor : T,W> -H <hostname: hostname or ip>'
options = {'DSize':1000, 'hostname': 'localhost'}
try:
opts, args = getopt.getopt(args,"hd:s:",["dequesize=", 'sensor='])
opts, args = getopt.getopt(args,"hd:s:H:",["dequesize=", 'sensor='])
except getopt.GetoptError:
print (hlp_str)
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
if opt in ("-h", "--help"):
print (hlp_str)
sys.exit()
elif opt in ("-d", "--dequesize"):
......@@ -216,6 +215,8 @@ if __name__ == "__main__":
options['key'] = SPEED
options['label'] = 'Ang. speed'
options['port'] = PORT + SPEED
elif opt in ("-H", "--hostname"):
options['hostname'] = arg
return options
opts = parse_options(sys.argv[1:])
......
......@@ -47,7 +47,7 @@ The data aquisition software is organized as follows:
1. a logger for a single sensor reads a data value and save it to a file, then it publishes the data to a specified port.
2. a plotter reads the specified plot and generates plots of the data.
2. a plotter reads the specified hostname:port and generates plots of the data.
The idea is that the Raspberry will not be used for plotting, just for logging.
An external compter should be used to visualize the current status of the measurements.
......@@ -74,6 +74,7 @@ To run excecute
```
python logger_single.py -s <sensor> -f <frequency> -o <output file>
```
(use option --help to get help)
The logger type is chosen at run time with command line arguments (-s or --sensor). It can be T for unipolar torque, T2 for bipolar torque, and W for rotational speed.
......@@ -92,8 +93,9 @@ See [plotter_single.py](https://gitlab.com/kakila/windturbine_HSR/blob/master/ex
To run excecute
```
python plotter_single.py -s <sensor> -d <deque size>
python plotter_single.py -s <sensor> -d <deque size> -H <hostname or ip>
```
(use option --help to get help)
The plotter type is chosen at run time with command line arguments (-s or --sensor). It can be T for uni/bipolar torque and W for rotational speed.
......@@ -101,4 +103,13 @@ The plots use deques to show the data, the argument -d or --dequesize set the le
For example if a logger publishes data at 10Hz a deque with size 100 will plot of the last 10 seconds of data.
The plotters can be used in the Raspberry Pi, but at risk of reducing the synchronization of the measured and logged data.
We also observed that when all loggers and plotters are active the Pi overheats.
\ No newline at end of file
We also observed that when all loggers and plotters are active the Pi overheats.
To plot from a remote computer (assuming that the ip of the raspberry is reachable and that ports are open. These assumptions are OK if the pia nd the plotting computer are in the same LAN subnet) use the option -H or --hostname. For exmaple
```
python plotter_single.py -s W -d 500 -H 192.168.178.29
```
will plot the data published by a rotation sensor on a machine with ip 192.168.178.29
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment