def update_alarm_displays(self):

        self.editing_alarms = True  # set to true to prevent the UI from updating anything

        # For each sensor, get the latest alarm counts (for both temp and humidity)
        # and display them
        for sensor_num in self.alarm_count_outputs.keys():

            for alarm_field, display in self.alarm_count_outputs[
                    sensor_num].items():

                if (alarm_field == "Temp"):
                    alarm = UI_Helper.getSensorAlarm(sensor_num, 4)['count']
                    display.setText(str(alarm))
                else:
                    alarm = UI_Helper.getSensorAlarm(sensor_num, 5)['count']
                    display.setText(str(alarm))

        # For each sensor, get the latest alarm thresholds (for both temp and humidity)
        # and display them
        for sensor_num in self.alarm_inputs.keys():

            for alarm_field, display in self.alarm_inputs[sensor_num].items():

                if (alarm_field == "Temp"):
                    alarm = UI_Helper.getSensorAlarm(sensor_num, 4)['val']
                    display.setValue(int(alarm))
                else:
                    alarm = UI_Helper.getSensorAlarm(sensor_num, 5)['val']
                    display.setValue(int(alarm))

        self.editing_alarms = False  # allow the UI to update things again
    def alarm_input_handler(self):

        if (not self.editing_alarms
            ):  # check that we're not manually editing the alarms
            # for all the alarms, update the local copy of the alarms with
            # the new values in the UI
            for num in self.alarm_inputs.keys():

                for input_field, sb_obj in self.alarm_inputs[num].items():
                    new_alarm_val = sb_obj.value()

                    if (input_field == 'Temp'):
                        UI_Helper.setSensorAlarmVal(new_alarm_val, num, 4)
                    else:
                        UI_Helper.setSensorAlarmVal(new_alarm_val, num, 5)
コード例 #3
0
    def up_button(self):

        function = UI_Helper.UI_FUNCTIONS[self.functionNumber]

        if (function == 'SensorNumber'):
            if self.currentSensor < NUM_SENSORS:
                self.currentSensor += 1

        elif (function == 'TempAlarmCount' or function == 'HumAlarmCount'):

            alarm = UI_Helper.getSensorAlarm(self.currentSensor,
                                             self.functionNumber)['val']
            alarm += 1
            UI_Helper.setSensorAlarmVal(alarm, self.currentSensor,
                                        self.functionNumber)

        self.updateOutput()
    def disp_format_slider_moved(self):

        lastState = self.monitor.fahrenheit

        if (self.ui.slider_F_C.value() == 0):  # if we want Fahrenheit

            self.monitor.fahrenheit = True
            if (lastState != self.monitor.fahrenheit):
                UI_Helper.convertAlarmVals(self.monitor.fahrenheit)

        else:  # if we want Celcius
            self.monitor.fahrenheit = False
            if (lastState != self.monitor.fahrenheit):
                UI_Helper.convertAlarmVals(self.monitor.fahrenheit)

        # Update all of the data to use the new units and update the display
        self.monitor.read_sensor_data()
        self.updateOutput()
    def update_measurements(self):
        # For each sensor, get the last measurement.
        # Try to round it and display it, but if there was an exception,
        # that means there isn't any valid data yet
        for sensor_num, display in self.measurement_output_displays.items():

            try:
                lastMeasurement = self.monitor.get_last_sensor_data(sensor_num)
                temp = UI_Helper.roundFloat(lastMeasurement['CurrentTemp'])
                hum = UI_Helper.roundFloat(lastMeasurement['CurrentHumidity'])

                if self.monitor.fahrenheit:
                    display_string = str(temp) + " F\n" + str(hum) + "% RH\n"
                else:
                    display_string = str(temp) + " C\n" + str(hum) + "% RH\n"

            except:
                display_string = '888'
                print("No Valid Data Yet")

            display.setText(display_string)
コード例 #6
0
    def read_data(self):
        self.monitor.read_sensor_data()

        # for each sensor, get the last measurement and update the alarm count as needed
        for sensor in range(1, NUM_SENSORS + 1):
            lastMeasurement = self.monitor.get_last_sensor_data(sensor)
            if (lastMeasurement == None):
                return

            TAlarm = UI_Helper.getSensorAlarm(sensor, 4)['val']
            HAlarm = UI_Helper.getSensorAlarm(sensor, 5)['val']

            if (lastMeasurement['CurrentTemp'] > TAlarm
                    and lastMeasurement['CurrentTemp'] != 999):
                UI_Helper.incSensorAlarmCount(sensor, 4)

            if (lastMeasurement['CurrentHumidity'] > HAlarm
                    and lastMeasurement['CurrentHumidity'] != 999):
                UI_Helper.incSensorAlarmCount(sensor, 5)

        self.updateOutput()
    def periodic_update(self):
        self.monitor.read_sensor_data()

        for sensor in self.measurement_output_displays.keys(
        ):  # for all sensors

            # Get the last measurement and set alarms as needed
            lastMeasurement = self.monitor.get_last_sensor_data(sensor)
            if (lastMeasurement == None):
                return

            TAlarm = UI_Helper.getSensorAlarm(sensor, 4)['val']
            HAlarm = UI_Helper.getSensorAlarm(sensor, 5)['val']

            if (lastMeasurement['CurrentTemp'] > TAlarm
                    and lastMeasurement['CurrentTemp'] != 999):
                UI_Helper.incSensorAlarmCount(sensor, 4)

            if (lastMeasurement['CurrentHumidity'] > HAlarm
                    and lastMeasurement['CurrentHumidity'] != 999):
                UI_Helper.incSensorAlarmCount(sensor, 5)

        # update the output
        self.updateOutput()
コード例 #8
0
    def updateOutput(self):
        # get the last measurement
        lastMeasurement = self.monitor.get_last_sensor_data(self.currentSensor)

        ## Ensure there is valid data to display
        if (lastMeasurement == None):
            self.ui.screen_output.setText(" INITIALIZING ")
            return

        neededData = lastMeasurement[UI_Helper.UI_FUNCTIONS[
            self.functionNumber]]

        errorCount = lastMeasurement['ErrorCount']

        # Construct standard part of display
        displayString = "S0" + str(self.currentSensor) + ":"

        # Format the data correctly
        dataString = " "

        function = UI_Helper.UI_FUNCTIONS[self.functionNumber]
        ## Display Temperature
        if (function == 'CurrentTemp'):

            if (self.displayCelcius):
                dataString = str(
                    self.monitor.fahrenheit_to_celsius(neededData)) + " Deg C "
            else:
                dataString = str(UI_Helper.roundFloat(neededData)) + " Deg F "

        elif (function == 'CurrentHumidity'):

            dataString = str(UI_Helper.roundFloat(neededData)) + " % RH  "

        elif (function == 'TempAlarmCount'):

            alarm = UI_Helper.getSensorAlarm(self.currentSensor,
                                             self.functionNumber)

            if (self.displayCelcius):
                dataString = "Thresh:" + str(
                    UI_Helper.roundFloat(
                        self.monitor.fahrenheit_to_celsius(
                            alarm['val']))) + " Deg C, Count:" + str(
                                alarm['count'])
            else:
                dataString = "Thresh:" + str(UI_Helper.roundFloat(
                    alarm['val'])) + " Deg F, Count:" + str(alarm['count'])

        elif (function == 'HumAlarmCount'):

            alarm = UI_Helper.getSensorAlarm(self.currentSensor,
                                             self.functionNumber)

            dataString = "Thresh:" + str(UI_Helper.roundFloat(
                alarm['val'])) + "% RH, Count:" + str(alarm['count'])

        displayString += dataString

        displayString += " Errors: " + str(errorCount)

        self.ui.screen_output.setText(displayString)