diff --git a/bin/peas_shell b/bin/peas_shell index a8fed6c..2d4cfa4 100755 --- a/bin/peas_shell +++ b/bin/peas_shell @@ -153,6 +153,18 @@ class PanSensorShell(cmd.Cmd): ################################################################################################## def do_toggle_relay(self, *arg): + """ Toggle a relay + + This will toggle a relay on the on the power board, switching off if on + and on if off. Possible relays include: + + * fan + * camera_box + * weather + * mount + * cam_0 + * cam_0 + """ relay = arg[0] relay_lookup = { 'fan': {'pin': 6, 'board': 'telemetry_board'}, @@ -167,6 +179,7 @@ class PanSensorShell(cmd.Cmd): relay_info = relay_lookup[relay] self.environment.serial_readers[relay_info['board']]['reader'].write("{},9".format(relay_info['pin'])) except Exception as e: + print_warning("Problem toggling relay {}".format(relay)) print_warning(e) def do_toggle_computer(self, *arg): @@ -174,7 +187,7 @@ class PanSensorShell(cmd.Cmd): board = 'telemetry_board' pin = 8 # Special command will toggle off, wait 30 seconds, then toggle on - self.environment.serial_readers[board].write("{},0".format(pin)) + self.environment.serial_readers[board]['reader'].write("{},0".format(pin)) except Exception as e: print_warning(e) diff --git a/config.yaml b/config.yaml index e3c9d13..bd1fde5 100644 --- a/config.yaml +++ b/config.yaml @@ -10,7 +10,7 @@ directories: webcam: '/var/panoptes/webcams' data: '/var/panoptes/data' environment: - auto_detect: True, + auto_detect: True weather: station: mongo aag_cloud: diff --git a/peas/sensors.py b/peas/sensors.py index 02299cf..2457f44 100644 --- a/peas/sensors.py +++ b/peas/sensors.py @@ -83,7 +83,7 @@ def __init__(self, auto_detect=False, *args, **kwargs): def _connect_serial(self, port): if port is not None: self.logger.debug('Attempting to connect to serial port: {}'.format(port)) - serial_reader = SerialData(port=port, threaded=True) + serial_reader = SerialData(port=port, threaded=False) self.logger.debug(serial_reader) try: diff --git a/peas/tests/test_boards.py b/peas/tests/test_boards.py new file mode 100644 index 0000000..1dcb7d9 --- /dev/null +++ b/peas/tests/test_boards.py @@ -0,0 +1,16 @@ +import pytest + +from peas.sensors import ArduinoSerialMonitor + + +@pytest.fixture(scope='module') +def monitor(): + return ArduinoSerialMonitor(auto_detect=True) + + +def test_create(monitor): + assert monitor is not None + + +def test_has_readers(monitor): + assert len(monitor.serial_readers) > 0 diff --git a/scripts/simple_weather_capture.py b/scripts/simple_weather_capture.py index 8607ebd..6eb2818 100644 --- a/scripts/simple_weather_capture.py +++ b/scripts/simple_weather_capture.py @@ -1,15 +1,11 @@ import datetime -import os import pandas -import sys import time from plotly import graph_objs as plotly_go from plotly import plotly from plotly import tools as plotly_tools -sys.path.append(os.getenv('PEAS', '.')) # Append the $PEAS dir - from peas import weather names = [ diff --git a/weather_info.csv b/weather_info.csv deleted file mode 100644 index 74190be..0000000 --- a/weather_info.csv +++ /dev/null @@ -1,106 +0,0 @@ -2017-03-26 02:56:32,False,26.37,26.87,23.75,6557.0,0.0,353.20000,9.77517,Unknown,Unknown,Unknown,Unknown -2017-03-26 02:57:25,False,26.45,26.87,23.85,6556.0,0.0,353.20000,18.96383,Calm,Calm,Very Cloudy,Dry -2017-03-26 02:58:48,False,26.63,26.87,24.05,6554.0,0.0,350.29787,25.90420,Unknown,Unknown,Unknown,Unknown -2017-03-26 02:59:43,False,26.69,26.97,24.05,6554.0,0.0,347.43662,18.96383,Unknown,Unknown,Unknown,Unknown -2017-03-26 03:00:21,False,26.75,26.97,24.15,6554.0,0.0,350.29787,18.96383,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:00:59,False,26.77,26.97,24.25,6553.0,0.0,347.43662,23.94917,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:01:37,False,26.87,26.97,24.25,6552.0,0.0,350.29787,28.93451,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:02:15,False,26.87,27.21,24.35,6551.0,0.0,350.29787,34.99511,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:02:53,False,26.99,26.93,24.45,6551.0,0.0,353.20000,37.92766,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:03:31,False,27.03,26.97,24.45,6550.0,0.0,344.61538,43.98827,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:04:09,False,27.05,27.03,24.55,6550.0,0.0,350.29787,48.97361,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:04:47,False,27.07,27.05,24.55,6548.0,0.0,331.08108,52.98143,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:05:25,False,27.17,27.03,24.65,6548.0,0.0,333.71429,58.94428,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:06:03,False,27.19,27.09,24.65,6548.0,0.0,331.08108,58.94428,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:06:41,False,27.21,27.03,24.65,6548.0,0.0,331.08108,58.94428,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:07:19,False,27.23,27.05,24.75,6548.0,0.0,331.08108,58.94428,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:07:56,False,27.29,27.09,24.85,6548.0,0.0,328.48322,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:08:34,False,27.33,26.99,24.85,6547.0,0.0,331.08108,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:09:12,False,27.35,27.69,24.85,6546.0,0.0,347.43662,58.94428,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:09:50,False,27.45,27.17,24.95,6544.0,0.0,323.39073,58.94428,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:10:28,False,27.47,27.55,24.95,6544.0,0.0,328.48322,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:11:06,False,27.53,28.01,25.05,6544.0,0.0,325.92000,58.94428,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:11:44,False,27.53,26.99,25.05,6544.0,0.0,323.39073,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:12:22,False,27.55,26.97,25.05,6544.0,0.0,328.48322,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:13:00,False,27.57,26.99,25.15,6544.0,0.0,325.92000,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:13:38,False,27.57,27.05,25.15,6543.0,0.0,320.89474,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:14:16,False,27.61,27.37,25.15,6543.0,0.0,320.89474,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:14:54,False,27.63,26.99,25.15,6543.0,0.0,323.39073,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:15:32,False,27.65,26.99,25.25,6543.0,0.0,323.39073,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:16:10,False,27.67,26.99,25.25,6543.0,0.0,328.48322,56.98925,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:16:48,False,27.65,26.99,25.25,6543.0,0.0,325.92000,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:17:26,False,27.71,27.03,25.25,6543.0,0.0,328.48322,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:18:03,False,27.71,27.05,25.25,6543.0,0.0,325.92000,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:18:41,False,27.73,27.75,25.35,6544.0,0.0,333.71429,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:19:19,False,27.77,27.69,25.35,6544.0,0.0,339.08966,56.98925,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:19:57,False,27.79,27.05,25.35,6544.0,0.0,341.83333,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:20:35,False,27.79,27.03,25.45,6544.0,0.0,336.38356,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:21:13,False,27.83,27.05,25.45,6544.0,0.0,341.83333,56.98925,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:21:51,False,27.87,27.09,25.45,6544.0,0.0,339.08966,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:22:29,False,27.83,27.05,25.45,6544.0,0.0,336.38356,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:23:07,False,27.85,27.03,25.45,6544.0,0.0,341.83333,56.98925,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:23:45,False,27.87,27.05,25.45,6544.0,0.0,339.08966,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-26 03:24:23,False,27.87,26.99,25.45,6544.0,0.0,344.61538,57.96676,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:22:16,False,22.81,22.29,24.45,2560.0,0.0,985.60000,9.77517,Unknown,Unknown,Unknown,Unknown -2017-03-27 02:22:54,False,22.85,22.29,25.76,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:23:32,False,22.89,22.29,26.77,2560.0,6.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:24:10,False,22.97,22.31,27.59,2560.0,0.0,967.00000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:25:19,False,22.99,22.29,27.08,2560.0,0.0,967.00000,0.78201,Unknown,Unknown,Unknown,Unknown -2017-03-27 02:25:57,False,23.13,22.29,27.70,2560.0,0.0,967.00000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:26:35,False,23.21,22.23,28.42,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:27:13,False,23.31,22.23,28.94,2560.0,0.0,967.00000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:27:51,False,23.39,22.23,29.46,2560.0,0.0,967.00000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:28:29,False,23.47,22.25,29.77,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 02:29:07,False,23.55,22.23,30.09,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:27:52,False,24.71,22.19,29.88,2560.0,0.0,931.72414,9.77517,Unknown,Unknown,Unknown,Unknown -2017-03-27 03:28:29,False,24.73,22.19,30.51,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:29:07,False,24.73,22.17,30.83,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:29:45,False,24.75,22.17,31.15,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:30:23,False,24.75,22.23,31.36,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:31:01,False,24.77,22.23,31.57,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:31:39,False,24.79,22.19,31.68,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:32:17,False,24.79,22.23,31.89,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:32:55,False,24.85,22.23,32.00,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:33:33,False,24.85,22.25,32.00,2560.0,0.0,967.00000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:34:11,False,24.87,22.23,32.11,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:34:49,False,24.91,22.19,32.22,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:35:27,False,24.93,22.25,32.22,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:36:05,False,24.95,22.23,32.22,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:36:43,False,24.97,22.23,32.32,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:37:21,False,24.97,22.17,32.32,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:37:59,False,24.99,22.19,32.32,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:38:37,False,25.01,22.17,32.32,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:39:14,False,25.05,22.17,32.32,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:39:52,False,25.03,22.13,32.43,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:40:30,False,25.05,22.13,32.43,2560.0,0.0,931.72414,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:41:08,False,25.07,22.11,32.43,2560.0,0.0,1067.29412,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:41:46,False,25.09,22.13,32.43,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:42:24,False,25.09,22.13,32.54,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:43:02,False,25.11,22.17,32.54,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:43:40,False,25.15,22.17,32.54,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:44:18,False,25.15,22.17,32.54,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:44:56,False,25.15,22.13,32.54,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:45:34,False,25.19,22.19,32.54,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:46:12,False,25.19,22.17,32.65,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:46:50,False,25.19,22.13,32.65,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:47:28,False,25.19,22.17,32.65,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:48:06,False,25.21,22.17,32.65,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:48:44,False,25.21,22.17,32.65,2560.0,0.0,1004.88889,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:49:21,False,25.23,22.23,32.65,2560.0,0.0,1089.76000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:49:59,False,25.23,22.19,32.76,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:50:37,False,25.23,22.17,32.65,2560.0,0.0,1004.88889,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:51:15,False,25.27,22.13,32.65,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:51:53,False,25.25,22.19,32.76,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:52:31,False,25.27,22.19,32.76,2560.0,0.0,1004.88889,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:53:09,False,25.27,22.19,32.76,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:53:47,False,25.29,22.29,32.76,2560.0,0.0,1004.88889,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:54:25,False,25.27,22.23,32.76,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:55:03,False,25.29,22.19,32.76,2560.0,0.0,1089.76000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:55:41,False,25.31,22.25,32.76,2560.0,0.0,967.00000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:56:19,False,25.31,22.19,32.76,2560.0,0.0,1113.14286,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:56:57,False,25.33,22.23,32.76,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:57:35,False,25.33,22.19,32.86,2560.0,0.0,1089.76000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:58:13,False,25.31,22.13,32.76,2560.0,0.0,1089.76000,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:58:51,False,25.33,22.17,32.86,2560.0,0.0,949.05263,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 03:59:29,False,25.33,22.17,32.86,2560.0,0.0,1067.29412,9.97067,Calm,Calm,Very Cloudy,Dry -2017-03-27 04:00:07,False,25.31,22.11,32.86,2560.0,0.0,985.60000,9.97067,Calm,Calm,Very Cloudy,Dry