def __init__(self): """ On initialisation the Bluetooth class retrieves the current Temperature and Humidity from the DataLogger class and sends a notification via Pushbullet with a message stating that a Bluetooth connection has been made aswell as the current Temperature and Humidity. """ #declare variables that handle interactions with other classes self.__bluetooth = BluetoothManager() self.__dataLogger = DataLogger() #declare variables that store the current temperature and humidity to 1 decimal point self.__currentTemperature = round(self.__dataLogger.getTemperature(), 1) self.__currentHumidity = round(self.__dataLogger.getHumidity(), 1) # using the bluetoothManager initialisation to create a message for the current temperature and humidity self.__bluetooth.createMessage(self.__currentTemperature, self.__currentHumidity) # self.__deviceName = input("Please enter your device' name: ") #Hardcode the device that bluetooth will search for self.__deviceName = "Yonas" #search for the device that needs to be connected once found print on cmd line that it is, if not found continue searching self.__bluetooth.connectToNearByDevice(self.__deviceName) #once that device has been connected send a pushbullet notifcation with the message self.__bluetooth.sendMessage()
def __init__(self): """ On initialisation the MonitorAndNotify class reads the current data and inserts into the datbase every minute and only sends a notification once a day """ # Scheduler = Schedule() # Instantiate all relevant classes data = DataLogger() dataManager = DatabaseManager(data) monitor = Monitor() weather = Weather(data, dataManager, monitor) sense = VirtualSenseHat.getSenseHat() # Scheduler.createSchedule() # verify if the temperature is within the range weather.verifyTemperature() # verify if the humidity is within the range weather.verifyHumidity() # close the connection to the database dataManager.closeDBConnection() # clear anything displayed on the sense hat sense.clear()
def __init__(self, config, log_market=False): self.config = config self.log = logging.getLogger('DataFeed') self.addr = str(config['Subscriptions']['Socket']) self.pairs = [str(p) for p in config['Subscriptions']['Symbols']] self.channels = [ str(c) for c in config['Subscriptions']['Channels'].keys() if not str(c).startswith('--') ] self.subbed_messages = [ str(m) for m in config['Subscriptions']['Messages'] ] for ch in self.channels: for msg in config['Subscriptions']['Channels'][ch]: self.subbed_messages.append(str(msg)) self.dataLogger = DataLogger(self.pairs, self.subbed_messages, log_market) self._endpoint = ws.create_connection(str(self.addr), max_size=None) self._msgQ = Queue() self._handleThread = Thread(\ target = self._handle_q,\ name = 'Message_Handler_Thread') self._handleThread.daemon = True self._listenThread = Thread(\ target = self._recvLoop,\ name = 'Listener_Thread') self._listenThread.daemon = True self._isRunning = False self.pendingException = None self.log.debug('Initialized DataFeed!')
def main(): state = { "should_exit": False, "is_manual_mode": True, "is_cruise_mode": False, } dm, js, cam = hardware_setup() ws_server = start_ws() dl = DataLogger(LOG_PATH + "/data.csv") logging.info("All services up and running") last_ws_ts = time.time() last_sync_ts = time.time() while not state["should_exit"]: event = js.get_event() # dispatch control command if state["is_manual_mode"]: if state["is_cruise_mode"]: if "direction" in event: event["direction"] = state["direction"] if "throttle" in event: event["throttle"] = state["throttle"] dm.batch_update(event) else: ai_command = fetch_ai_command() state.update(ai_command) event.update(ai_command) dm.batch_update(ai_command) state.update(event) if state["should_exit"]: continue ts = time.time() # broadcast state/event to client if ts - last_sync_ts > 0.5: # sync state every 0.5s state.update(dm.get_state()) ws_server.broadcast(state) last_sync_ts = time.time() if ts - last_ws_ts > 0.1: # push delta only every 0.1s if there is any event.update(dm.get_event()) if len(event) > 0: ws_server.broadcast(event) last_ws_ts = time.time() #logging image_file_name = ('%.6f' % ts) + ".jpg" state.update({"timestamp": ts, "image_file_name": image_file_name}) cam.capture_and_mark(image_file_name) dl.write(state)
from writers.csv import csv from DataLogger import DataLogger from time import sleep from devices.ArduinoDevice import ArduinoDevice writer = csv('testLog') logger = DataLogger(writer) logger.add_device(ArduinoDevice()) logger.start() try: while True: print("hi") sleep(1) finally: logger.end()
#! /usr/bin/env python3 import argparse from DataLogger import DataLogger parser = argparse.ArgumentParser() parser.add_argument( "--clear", action="store_true", help= "Clear all data stored on Solar Light UV Radiometer internal data logger.") args = parser.parse_args() dataLogger = DataLogger(args.clear) dataLogger.start()
def start_data_logging(): from DataLogger import DataLogger DataLogger()
import os import time from DataLogger import DataLogger def get_image_file_name(): ts = time.time() return ts, ('%.6f' % ts) + ".jpg" state = { "direction": 130.32, "throttle": 0.8, "lat": 123.21123234, "is_manual_mode": False } state["timestamp"], state["image_file_name"] = get_image_file_name() dl = DataLogger(os.getcwd() + "/demo.csv") dl.write(state) state["timestamp"], state["image_file_name"] = get_image_file_name() dl.write(state) state["timestamp"], state["image_file_name"] = get_image_file_name() dl.write(state)
#!/usr/bin/env python """This is to run a third instance of the 'DataLogger' application Friedrich Schotte, 18 Jun 2011""" from DataLogger import DataLogger import wx app = wx.PySimpleApp(0) win = DataLogger(name="DataLogger3") app.MainLoop()
rancilio_temperature_status_handler() Rancilio.update() rancilio_heater_status_handler() rancilio_ready_handler() time.sleep(1) # stop event is set Rancilio.setHeaterOutput(0) configs = Configurator.instance() # Threading stuff stopEvent = Event() error_in_method_event = Event() dataLogger = DataLogger(stopEvent, error_in_method_event) dataLogger.addTemperatureSensor('boiler', configs.boilerTempSensor1) dataLogger.addTemperatureSensor('boiler', configs.boilerTempSensor2) configs.dataLogger = dataLogger temperatureAcquisitionProcess = Thread(target=dataLogger.acquireData) temperatureAcquisitionProcess.start() Rancilio = RancilioSilvia() configs.Rancilio = Rancilio rancilioError = RancilioError.instance() rancilioError.blynkShutDownFcn = blynk_shut_down rancilioError.blynkAliveFcn = blynk_check_live_connection shm = SystemHealthMonitor() shm.stopEvent = stopEvent
print("Setting sample frequency to 50") mainBoard.setSampleFrequency(50) print("Sample frequency set. Message from board: " + mainBoard.readLine()) print("Setting sample average size to 1") mainBoard.setSampleAverageSize(1) print("Sample average set. Message from board: " + mainBoard.readLine()) print("Setting device report rate to 1000") mainBoard.setDeviceReportFrequency(1000) print("Device report rate set. Message from board: " + mainBoard.readLine()) print("Setting device sample enabled bit to 1") mainBoard.setSampleEnable(1) print("Device sample enabled set. Message from board: " + mainBoard.readLine()) print() print("Starting board read: ") print() headers = ['A0', 'A1', 'A2', 'A3', 'A4', 'A5'] logger = DataLogger('run1.xlsx', 7, headers) sampleRun = Run.Run(mainBoard, logger) sampleRun.start() time.sleep(16) print("Run Successful!") print("Number of Samples: " + str(sampleRun.stop()))
#!/usr/bin/env python """This is to run a second instance of the 'DataLogger' application Friedrich Schotte, 18 Jun 2011-30 Mar 2014""" __version__ = "1.1" from DataLogger import DataLogger import wx app = wx.App(redirect=False) win = DataLogger(name="DataLogger2") app.MainLoop()
def start_data_logging(): DataLogger("test.csv")