def __init__(self, sim7600, filemanager, args): self.sim7600 = sim7600 self.filemanager = filemanager self.args = args # Is this the first time the script is running after power cycle self.initial_startup = True # There will be a cron.log file which needs to be deleted IF the cron ran successfully self.delete_cron_log = True # Should data be uploaded self.upload_data = False # Should we get a GPS postion self.get_gps_position = True # How many samples should be taken before the sample upload is done self.sample_size = 120 # Check if required local directories exist, and if they don't creat them self.filemanager.check_directory_requirements() # Save the current time self.current_time = time.time() self.previous_time = self.current_time # Save today's date to check for 24-hour intervals self.today = datetime.now(timezone.utc).strftime('%Y%m%d') # Turn SIM7600 module on self.sim7600.power_on() # Get GPS Coordinates if self.get_gps_position: self.args['coordinates'] = self.sim7600.get_position() # Add variables for wind and rain meter self.args['anemometer'] = 0 self.args['rainGauge'] = 0 # Create an instance of the WeatherSensors object # This is a threaded object that measures wind speed and rain self.weather_sensors = WeatherSensors(self.args) # Turn off Pi-Plates status LED on each plate for i in range(0, 2): DAQC2.setLED(i, 'off') # Counter to send initial upload for connectivity test self.test_counter = 0 # Run program loop while True: self.program_loop()
def __init__(self, addr): super().__init__() self.name = 'DAQC2' self.vendor = 'Pi-Plates' # Note: channel 8 is wired to Vdd so cannot be used for measurements. self.channels = (0, 1, 2, 3, 4, 5, 6, 7, 8) self.addr = addr # Flash light green and then off to indicated found and set up. DAQC2plate.setLED(self.addr, 'green') Vddcheck = float(self.V_oversampchan(8, 1, 5)[0]) self.Vdd = Vddcheck DAQC2plate.setLED(self.addr, 'off')
DP.setLED(addr, 1) elif color == 'yellow': DP.setLED(addr, 0) DP.setLED(addr, 1) else: sys.stderr.write("unsupported LED color: " + color) resp['color'] = color elif (cmd == "setLED" and plate_type == "DAQC2"): color = args['color'] if color in [ 'off', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white' ]: DP2.setLED(addr, color) else: sys.stderr.write("unsupported LED color: " + color) resp['color'] = color else: sys.stderr.write("unknown daqc(2) cmd: " + cmd) print(json.dumps(resp)) elif (plate_type == "MOTOR"): break elif (plate_type == "THERMO"): if (cmd == "getTEMP"): channel = args['channel'] value = TP.getTEMP(addr, channel) resp['channel'] = channel resp['value'] = value
import numpy as np import time import get_data import write_data try: import piplates.DAQC2plate as DAQC except ImportError: print("Failed to import piplates-DAQCplate from python system path") raise ImportError( "Failed to import library from parent folder") ####### zet de LED uit DAQC.setLED(0, 'off') ####### stuur de analoge output aan DAQC.setDAC(0, 1, 2.64) # DAQ 0, adres analog-output 1, voltage 2.64 V ###### stuur 0, 1, 2, 3 volt naar analog-output 1 for i in range(10): volt = i % 4 # i modulo 4 DAQC.setDAC(0, 1, volt) time.sleep(0.1) ####### Lees data van Analoge Input val = DAQC.getADC(0, 1) # DAQC 0, adres Analog-Input 1 print(val) val8 = DAQC.getADCall(0) # lees alle 8 Analog-Inputs
def OSCLED(args): global AD # args is color as string: ‘off’, 'red’, ‘green’, ‘yellow’, ‘blue’, ‘magenta’, ‘cyan’, ‘white’ DAQC2.setLED(AD, args) pass