Example #1
0
    def quit(self):
        if self.already_quit:
            return

        self.already_quit = True
        self.command.sigint_handler()
        qt.quit()
Example #2
0
    def process_data_and_quit(self):
        v, i = zip(*self.data)

        v_offset = round(sum(v) / len(v))
        i_offset = round(sum(i) / len(i))

        self.config.calibration("voltage_offset", v_offset)
        self.config.calibration("current_offset", i_offset)
        self.config.save()

        quit()
Example #3
0
    def process_data_and_quit(self):
        v, i, p = zip(*self.data)

        v_mean = sum(v) / len(v)
        i_mean = sum(i) / len(i)
        p_mean = sum(p) / len(p)

        v_gain = self.mains_voltage / v_mean
        p_gain = self.device_power / p_mean
        i_gain = p_gain / v_gain

        self.config.calibration("voltage_gain", v_gain)
        self.config.calibration("current_gain", i_gain)
        self.config.calibration("real_power_gain", p_gain)
        self.config.save()

        quit()
Example #4
0
    def status_init(self):
        try:
            with open(self.signature_file, 'r') as f:
                file_content = json.loads(f.read())
        except (IOError, ValueError):
            file_content = {}

        try:
            del file_content[raw_input("Nome: ")]
        except KeyError:
            print u"Assinatura não encontrada"
            qt.quit()

        with open(self.signature_file, 'w') as f:
                f.write(json.dumps(file_content))

        qt.quit()
Example #5
0
    def button_save_clicked(self):
        try:
            with open(self.signature_file, 'r') as f:
                file_content = json.loads(f.read())
        except (IOError, ValueError):
            file_content = {}

        states = {}
        for i, prot in enumerate(self.prototypes):
            states[self.labels[i]] = prot

        file_content[self.appliance_name] = {
            "states": states,
            "transitions": self.transitions
        }

        with open(self.signature_file, 'w') as f:
                f.write(json.dumps(file_content))

        qt.quit()
Example #6
0
    def status_init(self):
        try:
            with open(self.signature_file, 'r') as f:
                file_content = json.loads(f.read())
        except (IOError, ValueError):
            file_content = {}

        for k, v in file_content.iteritems():
            print k
            states = v["states"]
            transitions = v["transitions"]

            for n, pos in states.iteritems():
                print "  ", n, pos

            print
            for t in transitions:
                print "  ", t[0], "-->", t[1], ":", t[2]
            print "-----------------------------"

        qt.quit()