コード例 #1
0
def main():
    bat_temp = [TEMP_BAT_1,TEMP_BAT_2,TEMP_BAT_3,TEMP_BAT_4]
    brd_temp = [TEMP_EPS_BRD, TEMP_CDH_BRD, TEMP_PAYLOAD_BRD]
    payload_temp = [TEMP_PAYLOAD_A, TEMP_PAYLOAD_B]
    chassis_temp = [TEMP_PAYLOAD_CHASSIS, TEMP_END_CAP]

    for sensor in (bat_temp + brd_temp + payload_temp + chassis_temp):
        SensorManager.init_temp_sensor(sensor)
    while True:
        print "\nBattery temperature"
        for sensor in bat_temp:
            print(SensorManager.read_temp_sensor(sensor)),
        print "\nBoard temperatures"
        for sensor in brd_temp:
            print(SensorManager.read_temp_sensor(sensor)),
        """
        print "Chassis temperatures"
        for sensor in brd_temp:
            print(SensorManager.read_temp_sensor(sensor)),
        print "Payload temperatures"
        for sensor in brd_temp:
            print(SensorManager.read_temp_sensor(sensor)),
        """
        print
        sleep(1)
    for sensor in bat_temp:
        SensorManager.stop_temp_sensor(sensor)
コード例 #2
0
ファイル: payload.py プロジェクト: spaceconcordia/csdc3
    def start(self):
        insertDebugLog(NOTICE, "Starting. Runtime: %ds, Actuate time: %ds, Max strain: %d, Sampling Freq: %d." % \
            (self.max_time, self.actuate_time, self.max_loadcell, \
             self.heater_period), PAYLOAD, int(time.time()))
        print("Starting payload...")
        print("Runtime: %ds, Actuate time: %ds, Max strain: %d, Sampling period: %ds" % \
            (self.max_time, self.actuate_time, self.max_loadcell, \
             self.heater_period))

        if not self.check_initial_conditions():
            return False
        self.lock.acquire()
        self.set_power(True)
        self.init_sensors()
        start_time = time.time()
        elapsed = 0
        while True:
            heater_temp = 0
            if elapsed <= self.actuate_time or heater_temp < self.max_temp:
                self.set_heaters(self.experiment, True)
                time.sleep(self.heater_period)
            else:
                print("No longer turning heaters on")
                time.sleep(self.heater_period)
                self.set_heaters(self.experiment, False)
            self.set_heaters(self.experiment, False)
            elapsed = time.time() - start_time
            off_time = time.time()
            print("[" + str(round(elapsed, 3)) + " s] ", end='')
            strain, force, adc_temp = SensorManager.read_adc(self.experiment, ADC)
            heater_temp = SensorManager.read_temp_sensor(self.temp_sensor)
            print(strain, force, adc_temp, heater_temp)
            sleep_time = time.time() - off_time
            elapsed = time.time() - start_time
            time.sleep(abs(self.heater_period - sleep_time))
            elapsed = time.time() - start_time
            strain, force, adc_temp = SensorManager.read_adc(self.experiment, ADC)
            heater_temp = SensorManager.read_temp_sensor(self.temp_sensor)
            print("[" + str(round(elapsed, 3)) + " s] ", end='')
            print(strain, force, adc_temp, heater_temp)

            if self.is_end_condition(strain, elapsed):
                break
        if self.experiment:
            exp = 'B'
        else:
            exp = 'A'
        insertPayloadLog(int(start_time), int(time.time()), exp)
        self.end()
        self.lock.release()
        return True
コード例 #3
0
ファイル: sensor_sweep.py プロジェクト: spaceconcordia/csdc3
def main():
    ds1624 = [TEMP_PAYLOAD_A, TEMP_BAT_1]
    ds18b20 = [PANEL0, PANEL1]
    for temp_sensor in ds1624:
        SensorManager.init_temp_sensor(temp_sensor)
    SensorManager.gpio_output(PSS_HTR_EN_1_GPIO, ON)
    with open("/root/csdc3/src/sensors/temp_log.txt", "a") as f:
        for i in range(1):
            start = time.time()
            temperatures = []
            for temp_sensor in ds1624:
                value = SensorManager.read_temp_sensor(temp_sensor)
                temperatures.append(value)


            for temp_sensor in ds18b20:
                value = SensorManager.get_panel_data(temp_sensor)
                temperatures.append(value)


            readtime = time.time() - start
            temperatures.append(readtime)
            f.write(str(temperatures) + '\n')

    SensorManager.gpio_output(PSS_HTR_EN_1_GPIO, OFF)
    for temp_sensor in ds1624:
        SensorManager.stop_temp_sensor(temp_sensor)
コード例 #4
0
ファイル: cdh_test.py プロジェクト: spaceconcordia/csdc3
 def test_ds1624(self):
     ds1624 = [TEMP_CDH_BRD]
     for sensor in ds1624:
         SensorManager.init_temp_sensor(sensor)
         value = SensorManager.read_temp_sensor(sensor)
         self.assertNotEqual(value, -1)
コード例 #5
0
    def check_health(self):
        """
        Determines whether battery chargers must be set manually
        """

        # Check if sensors are reading data in the system
        # if areSensorsAcquiringData():
        #     return
        print('Threshold voltage:', self.thresholdVoltage)

        # Get temperature inputs
        tempIdentifiers = (TEMP_BAT_1) #, TEMP_BAT_2, TEMP_BAT_3, TEMP_BAT_4)
        tempValues = []
        for iden in tempIdentifiers:
            SensorManager.init_temp_sensor(iden)
            valueList = []
            # Get median of 5 value readings to remove outliers
            for i in range(0,5):
                valueList.append(SensorManager.read_temp_sensor(iden))
            tempValue = median(valueList)
            print('Current temperature:', tempValue)
            SensorManager.stop_temp_sensor(iden)
            # Keep final value of sensor
            tempValues.append(tempValue)

        # Get status identifiers
        statusIdentifiers = (PSS_HTR_STAT_1_GPIO, PSS_HTR_STAT_2_GPIO,\
        PSS_HTR_STAT_3_GPIO, PSS_HTR_STAT_4_GPIO)
        statusValues = []
        for iden in statusIdentifiers:
                statusValues.append(SensorManager.gpio_input(iden,0))

        # Define manual heater identifiers
        heaterIdentifiers = (PSS_HTR_EN_1_GPIO, PSS_HTR_EN_2_GPIO,\
        PSS_HTR_EN_3_GPIO, PSS_HTR_EN_4_GPIO)

        # Check if ShutAllBatteryHeaters is running
        if self.heaterShutDownLock.isLocked():
            # Shut all battery heaters off
            print('Battery heaters must remain shut off')
            self.controlStatus = True
            SensorManager.gpio_output(PSS_HTR_MUX_SEL_GPIO, OFF)
            for heater in heaterIdentifiers:
                SensorManager.gpio_output(heater, OFF)
            return

        # Check if payload is running
        if self.isPayloadAcquiringData():
            # Shut all battery heaters off
            print('Payload is running... shutting off all battery heaters')
            self.controlStatus = True
            SensorManager.gpio_output(PSS_HTR_MUX_SEL_GPIO, OFF)
            for heater in heaterIdentifiers:
                SensorManager.gpio_output(heater, OFF)
            return

        # Take control if required
        for i in range(0,len(tempValues)):
            if self.temp_threshold(tempValues[i], 'GT') and statusValues[i] == 0:
                print('Case 1: [Analog] Heaters are turned on')
                self.controlStatus = False
                SensorManager.gpio_output(PSS_HTR_MUX_SEL_GPIO, ON)
                return
            elif self.temp_threshold(tempValues[i], 'GT') and statusValues[i] == 1:
                print('Case 2: [Digital] Heaters are turned off')
                self.controlStatus = True
                SensorManager.gpio_output(PSS_HTR_MUX_SEL_GPIO, OFF)
                SensorManager.gpio_output(heaterIdentifiers[i], OFF)
                return
            elif self.temp_threshold(tempValues[i], 'LT') and statusValues[i] == 0:
                print('Case 3: [Digital] Heaters are turned on')
                self.controlStatus = True
                SensorManager.gpio_output(PSS_HTR_MUX_SEL_GPIO, OFF)
                if self.is_battery_safe():
                    SensorManager.gpio_output(heaterIdentifiers[i], ON)
                return
            elif self.temp_threshold(tempValues[i], 'LT') and statusValues[i] == 1:
                print('Case 4: [Analog] Heaters are turned off')
                self.controlStatus = False
                SensorManager.gpio_output(PSS_HTR_MUX_SEL_GPIO, ON)
                return
コード例 #6
0
ファイル: sensor_test.py プロジェクト: spaceconcordia/csdc3
 def test_ds1624(self):
     ds1624 = [TEMP_PAYLOAD_A, TEMP_BAT_1]
     for sensor in ds1624:
         SensorManager.init_temp_sensor(sensor)
         value = SensorManager.read_temp_sensor(sensor)
         self.assertNotEqual(value, -1)