#my imports from config3 import Config import adafruit_fxos8700_microSWIFT import adafruit_fxas21002c_microSWIFT #--------------------------------------------------------------- configDat = sys.argv[1] configFilename = configDat #Load config file/parameters needed config = Config() # Create object and load file ok = config.loadFile(configFilename) if (not ok): sys.exit(0) #set up logging logDir = config.getString('Loggers', 'logDir') LOG_LEVEL = config.getString('Loggers', 'DefaultLogLevel') #format log messages (example: 2020-11-23 14:31:00,578, recordIMU - info - this is a log message) #NOTE: TIME IS SYSTEM TIME LOG_FORMAT = ('%(asctime)s, %(filename)s - [%(levelname)s] - %(message)s') #log file name (example: home/pi/microSWIFT/recordIMU_23Nov2020.log) LOG_FILE = (logDir + '/' + 'recordIMU' + '_' + datetime.strftime(datetime.now(), '%d%b%Y') + '.log') logger = getLogger('system_logger') logger.setLevel(LOG_LEVEL) logFileHandler = FileHandler(LOG_FILE) logFileHandler.setLevel(LOG_LEVEL) logFileHandler.setFormatter(Formatter(LOG_FORMAT)) logger.addHandler(logFileHandler) #load parameters from Config.dat
# Change to Importing Python GPSwaves try: from GPSwaves import GPSwaves except Exception as e: logger.info('error importing GPSwaves.py') logger.info(e) #load config file and get parameters configFilename = sys.argv[1] #Load config file/parameters needed config = Config() # Create object and load file ok = config.loadFile( configFilename ) if( not ok ): logger.info ('Error loading config file: "%s"' % configFilename) sys.exit(1) dataDir = config.getString('System', 'dataDir') floatID = os.uname()[1] sensor_type = config.getInt('System', 'sensorType') badValue = config.getInt('System', 'badValue') port = config.getInt('System', 'port') payload_type = config.getInt('System', 'payloadType') burst_seconds = config.getInt('System', 'burst_seconds') gps_freq = config.getInt('GPS', 'GPS_frequency') #currently not used, hardcoded at 4 Hz (see init_gps function) #inputs are u,v,z arrays, last lat/lon, sampling rate (Hz), burst duration (secs), #bad value, payload type, sensor type, and port number from recordGPS.py def main(u,v,z,lat,lon): #check the number of u,v,z samples matches expected and 1 Hz minimum pts_expected = gps_freq * burst_seconds
from time import sleep #my imports from config3 import Config import process_data #load config file and get parameters configFilename = sys.argv[1] #Load config file/parameters needed config = Config() # Create object and load file ok = config.loadFile(configFilename) if (not ok): logger.info('Error loading config file: "%s"' % configFilename) sys.exit(1) #system parameters dataDir = config.getString('System', 'dataDir') floatID = os.uname()[1] #floatID = config.getString('System', 'floatID') sensor_type = config.getInt('System', 'sensorType') badValue = config.getInt('System', 'badValue') numCoef = config.getInt('System', 'numCoef') port = config.getInt('System', 'port') payload_type = config.getInt('System', 'payloadType') burst_seconds = config.getInt('System', 'burst_seconds') burst_time = config.getInt('System', 'burst_time') burst_int = config.getInt('System', 'burst_interval') call_int = config.getInt('Iridium', 'call_interval') call_time = config.getInt('Iridium', 'call_time') #GPS parameters gps_port = config.getString('GPS', 'port')
#initialize gpio pin 21 as modem on/off control GPIO.setmode(GPIO.BCM) #--------------------------------------------------------------- configDat = sys.argv[1] configFilename = configDat #Load config file/parameters needed config = Config() # Create object and load file ok = config.loadFile(configFilename) if (not ok): sys.exit(0) #set parameters burstInterval = config.getInt('Iridium', 'burstInt') burstNum = config.getInt('Iridium', 'burstNum') dataDir = config.getString('LogLocation', 'dataDir') logDir = config.getString('LogLocation', 'logDir') floatID = config.getString('System', 'floatID') bad = config.getInt('System', 'badValue') projectName = config.getString('System', 'projectName') imuFreq = config.getInt('IMU', 'imuFreq') numSamplesConst = config.getInt('System', 'numSamplesConst') imuNumSamples = imuFreq * numSamplesConst maxHours = config.getInt('IMU', 'maxHours') imuGpio = config.getInt('IMU', 'imuGpio') recRate = config.getInt('IMU', 'recRate') recRate = 1. / recRate #turn imu on for script recognizes i2c address
valve2En = config.getInt('Valves', 'Valve2En') valve2 = config.getInt('Valves', 'Valve2') valve2Gnd = config.getInt('Valves', 'Valve2Gnd') valve3En = config.getInt('Valves', 'Valve3En') valve3 = config.getInt('Valves', 'Valve3') valve3Gnd = config.getInt('Valves', 'Valve3Gnd') valve4En = config.getInt('Valves', 'Valve4En') valve4 = config.getInt('Valves', 'Valve4') valve4Gnd = config.getInt('Valves', 'Valve4Gnd') #PRESSURE recordRate = config.getInt('PressureSensor', 'recordRate') recordingInterval = 1. / recordRate diffPressCh = config.getInt('PressureSensor', 'DiffCh') diffGain = config.getFloat('PressureSensor', 'gain') adcBus = config.getString('Params', 'ADCBus') adc = Adafruit_ADS1x15.ADS1115(address=0x48, busnum=adcBus) #FLOW flowGPIO = config.getInt('FlowSensor', 'Flow') #LED ledGPIO = config.getInt('LED', 'ledGPIO') #GPIO output initializeGPIO(ledGPIO, flowGPIO, waterPump, soluPump, valve1En, valve1, valve1Gnd, valve2En, valve2, valve2Gnd, valve3En, valve3, valve3Gnd, valve4En, valve4, valve4Gnd) GPIO.setup(primeValve, GPIO.OUT) #LOG FILES
valve1 = config.getInt('Valves', 'Valve1') valve1Gnd = config.getInt('Valves', 'Valve1Gnd') valve2En = config.getInt('Valves', 'Valve2En') valve2 = config.getInt('Valves', 'Valve2') valve2Gnd = config.getInt('Valves', 'Valve2Gnd') valve3En = config.getInt('Valves', 'Valve3En') valve3 = config.getInt('Valves', 'Valve3') valve3Gnd = config.getInt('Valves', 'Valve3Gnd') valve4En = config.getInt('Valves', 'Valve4En') valve4 = config.getInt('Valves', 'Valve4') valve4Gnd = config.getInt('Valves', 'Valve4Gnd') #PRESSURE diffPressCh = config.getInt('PressureSensor', 'DiffCh') diffGain = config.getFloat('PressureSensor', 'gain') adcBus = config.getString('Params', 'ADCBus') adc = Adafruit_ADS1x15.ADS1115(address=0x48,busnum=adcBus) #FLOW flowGPIO = config.getInt('FlowSensor', 'Flow') #LED ledGPIO = config.getInt('LED', 'ledGPIO') #GPIO output initializeGPIO(ledGPIO,flowGPIO, waterPump,soluPump, valve1En,valve1,valve1Gnd, valve2En,valve2,valve2Gnd, valve3En,valve3,valve3Gnd, valve4En,valve4,valve4Gnd)