示例#1
0
    def _update_weight(self):
        x = self._get_command(10)

        if (x == False):
            pass

        else:
            DataBase.set_value(self.h_scale_raw_actual, str(x))
            ymin = float(DataBase.get_value(self.h_scale_zero))
            ymax = float(DataBase.get_value(self.h_scale_span))
            xmin = float(DataBase.get_value(self.h_scale_raw_zero))
            xmax = float(DataBase.get_value(self.h_scale_raw_span))

            try:
                m = (ymax - ymin) / (xmax - xmin)

            except:
                m = 0.0

            b = ymin - (m * xmin)
            y = (m * x) + b

            decimal = DataBase.get_value(self.h_scale_decimal)
            result = str(y / pow(10, int(decimal)))
            truncated_result = result[0:(result.find('.') + 1 + int(decimal))]
            DataBase.set_value(self.h_scale_actual, truncated_result)

        if (self.read_scale_timer.get_status() == False):
            print('Scale ' + self.scale_number +
                  ' has timed out, manually reconnect.')
示例#2
0
    def update_labels(self):
        ''' Function takes the RAM database and push it out to file.'''
        ''' All label widgets are updated on the screen. '''

        # Get the process time it takes to update the tags.
        self.start_time = time.clock()

        # Send all current tags to database to be saved.
        DataBase.refresh_tag_database()
        DataBase.set_value('h_datetime', time.strftime("%H:%M"))

        for each_widget in self.builder.get_objects():
            try:
                if type(each_widget) == Gtk.Label:
                    if (each_widget.get_name() in DataBase.tags):
                        tagname = str(each_widget.get_name())
                        value = DataBase.get_value(tagname)
                        each_widget.set_label(str(value))
                        # print(tagname + str(value))

            except:
                print(each_widget.get_name() + str(" not found durring window refresh."))

        # Update all Widget Labels on the HMI.
        # for each_tag in DataBase.tags:
        #     try:
        #         widget = self.builder.get_object(each_tag)
        #         tag = DataBase.get_value(str(each_tag))
        #         widget.set_label(str(tag))
        #     except:
                # pass


        # print(self.window_name + " Tags updated: {:.3f} ms.".format((time.clock() - self.start_time)*1000))
        return True
    def run_compressor(self):
        if self.error_state == False:
            self.busy = True
            temp = DataBase.get_value('h_temperature')

            if (temp == 'Error'):
                DataBase.set_value('h_door_switch', 'STOPPED')
                GPIO.output(self.pin_number, 0)

            else:
                temp = float(temp)

                #try:
                if (temp > 4.0):
                    DataBase.set_value('h_door_switch', 'RUNNING')
                    GPIO.output(self.pin_number, 1)

                elif (temp < 2.0):
                    DataBase.set_value('h_door_switch', 'STOPPED')
                    GPIO.output(self.pin_number, 0)

                else:
                    pass
        else:
            print("Compressor is in error state.")

        self.busy = False
示例#4
0
    def __init__(self, tagname):
        print("Creating Keyboard Window...")
        Window.__init__(self, 'keyboard', KeyboardHandler)

        # Create a global variable...not sure handlers can't inherit builder.
        global buffer_label
        buffer_label = self.builder.get_object('l_buffer')

        # Create the local buffer but, leave it blank.
        DataBase.set_local_value('keyboard_buffer', '')

        # Set the label to show the current tag value.
        buffer_label.set_label(DataBase.get_value(tagname.get_name()))

        DataBase.set_local_value('keyboard_shift_pointer', 1)
        DataBase.set_local_value('keyboard_variable', tagname.get_name())