コード例 #1
0
    def runCalculations(self):
        input_vals = self.validateLimitVals()
        if len(input_vals) == 4:
            ks, kr, gs, gr = input_vals

            test_motor = Motor()
            motor_calc = MotorCalc(test_motor,
                                   limit=0,
                                   kls=ks,
                                   klr=kr,
                                   gs=gs,
                                   gr=gr)
            motor_calc.calculate()
            motor_results = MotorResults(motor_calc)

            self.results_tab = CalcResultsWidget(motor_results)
            self.results_tab.show()

            print(motor_results)
        else:
            print("Nie weszło!")
コード例 #2
0
    def run(self):
        step_count = 10
        step_val = int((self.limit_upper - self.limit_lower) / step_count) or 1
        step_range = range(self.limit_lower, self.limit_upper + 1, step_val)
        for i in step_range:
            motor_calc = MotorCalc(self.motor, limit=i)
            motor_calc.calculate()
            Ps, PAl, Pss, Pp = motor_calc.get_motor_losses()
            self.__Ps.append(Ps)
            self.__PAl.append(PAl)
            self.__Pss.append(Pss)
            self.__Pp.append(Pp)
            self.__limits.append(i)

            if i == step_range[len(step_range) - 1]:
                self._signal.emit(100)
                print("koniec!")
            else:
                val_to_send = (i / step_range[len(step_range) - 1]) * 100
                self._signal.emit(val_to_send)
                print("wysyłanie ", val_to_send)
        print(self.__limits)
コード例 #3
0
                    "value"	REAL NOT NULL,
                    "result_ID"	INTEGER,
                    PRIMARY KEY("ID" AUTOINCREMENT),
                    FOREIGN KEY("result_ID") REFERENCES "MotorResults" ("ID"))
                    '''
            db.execute(stmt)
            # rotor_fluxes
            stmt = '''CREATE TABLE "rotor_fluxes" (
                                "ID"	INTEGER,
                                "order"	INTEGER,
                                "value"	REAL NOT NULL,
                                "result_ID"	INTEGER,
                                PRIMARY KEY("ID" AUTOINCREMENT),
                                FOREIGN KEY("result_ID") REFERENCES "MotorResults" ("ID"))
                                '''
            db.execute(stmt)
        return True


if __name__ == "__main__":
    from data_transfer.db_data_transfer import DBDataTransfer

    motor = Motor()
    motorCalc = MotorCalc(motor, limit=5)
    motorCalc.calculate()

    id_added = DBDataTransfer.export_data(motorCalc)
    losses_Pss, losses_Pp, losses_Ps, losses_PAl = DBDataTransfer.import_data(
        id_added)
    print(losses_Pss)
コード例 #4
0
        :param filename: name of file to be loaded.
        :return: str
        """
        if filename is None:
            raise LoadFileError("Filename is empty!")
        with open(filename, 'r') as f:
            f_cont = f.read()
        return f_cont

    def __str__(self):
        return self.__motor_calc.__str__()


if __name__ == "__main__":
    m = Motor()
    m_calc = MotorCalc(m, limit=15)
    m_calc.calculate()
    m_res = MotorResults(m_calc)

    m_res.save_to_json("test_3")

    # limit, Ps, PAl, Pss, Pp, stator_losses, rotor_losses = \
    #     loaded_json = m_res.load_from_json(r'json/testowy_1.json')

    # loaded_json = OrderedDict(loaded_json)
    # for k, v in loaded_json.items():
    #     print(k, v)

    # print(m_res.load_from_file(r'results/results_25-01-21 21.20.29.txt').splitlines())

    # m_res.save_to_DB()