def build_settings(self): settings = tk.Toplevel() settings.title("Settings") settings.resizable(width=False, height=False) self.topSet = settings # external reference tk.Label(settings, text="Channel").grid(row=1, column=0) tk.Label(settings, text="Multiplyer").grid(row=1, column=1) tk.Label(settings, text="Divider").grid(row=1, column=2) tk.Label(settings, text="AC-Voltage").grid(row=2, column=0) self.ac_v_multi = tk.Entry(settings, width=10) self.ac_v_multi.grid(row=2, column=1) self.ac_v_multi.insert(0, myConfig.get('ac_v_multi')) self.ac_v_divi = tk.Entry(settings, width=10) self.ac_v_divi.grid(row=2, column=2) self.ac_v_divi.insert(0, myConfig.get('ac_v_divi')) tk.Label(settings, text="AC-Current").grid(row=3, column=0) self.ac_c_multi = tk.Entry(settings, width=10) self.ac_c_multi.grid(row=3, column=1) self.ac_c_multi.insert(0, myConfig.get('ac_c_multi')) self.ac_c_divi = tk.Entry(settings, width=10) self.ac_c_divi.grid(row=3, column=2) self.ac_c_divi.insert(0, myConfig.get('ac_c_divi')) tk.Label(settings, text="DC-Voltage").grid(row=4, column=0) self.dc_v_multi = tk.Entry(settings, width=10) self.dc_v_multi.grid(row=4, column=1) self.dc_v_multi.insert(0, myConfig.get('dc_v_multi')) self.dc_v_divi = tk.Entry(settings, width=10) self.dc_v_divi.grid(row=4, column=2) self.dc_v_divi.insert(0, myConfig.get('dc_v_divi')) tk.Label(settings, text="DC-Current").grid(row=5, column=0) self.dc_c_multi = tk.Entry(settings, width=10) self.dc_c_multi.grid(row=5, column=1) self.dc_c_multi.insert(0, myConfig.get('dc_c_multi')) self.dc_c_divi = tk.Entry(settings, width=10) self.dc_c_divi.grid(row=5, column=2) self.dc_c_divi.insert(0, myConfig.get('dc_c_divi')) tk.Label(settings, text="Torque").grid(row=6, column=0) self.torque_multi = tk.Entry(settings, width=10) self.torque_multi.grid(row=6, column=1) self.torque_multi.insert(0, myConfig.get('torque_multi')) self.torque_divi = tk.Entry(settings, width=10) self.torque_divi.grid(row=6, column=2) self.torque_divi.insert(0, myConfig.get('torque_divi')) saveBtn = tk.Button(settings, text="Save", command=self.save_settings, height=1, width=15) saveBtn.grid(row=7, column=0) saveBtn = tk.Button(settings, text="Abbrechen", command=settings.destroy, height=1, width=15) saveBtn.grid(row=7, column=3)
def build_settings(self): settings = tk.Toplevel() settings.title("Einstellungen") #settings.geometry("500x150+300+300") settings.resizable(width=False, height=False) self.topSet = settings #external Reference settings.columnconfigure(1, pad = 10) settings.columnconfigure(0, pad = 10) settings.rowconfigure(3, pad = 10) frameWidth = 550 excelPathFrame = tk.Frame(settings, relief='groove', borderwidth=2, width = frameWidth, height = 40) excelPathFrame.grid(row=1, column=1, padx=10, pady=5, columnspan=2) excelPathFrame.grid_propagate(False) excelPathFrame.columnconfigure(2, weight=10) info = tk.Label(excelPathFrame, text="Pfad für\n Excel-Output") info.grid(column=1, row = 1) input = tk.Entry(excelPathFrame, relief='sunken') input.grid(column=2, row = 1, sticky='w', pady=5, padx=10) input.config(width=380) self.pfadEntry = input #External Reference input.insert(0,myConfig.get('outputExcel')) browseBtn = tk.Button(excelPathFrame, text="Suchen", command = self.browse_for_file, height=1, width=5) browseBtn.grid(column=3, row = 1, padx=5, sticky = "w") gsNameFrame = tk.Frame(settings, relief='groove', borderwidth=2, width = frameWidth, height = 40) gsNameFrame.grid(row=2, column=1, padx=10, pady=5, columnspan=2) gsNameFrame.grid_propagate(False) gsNameFrame.columnconfigure(2, weight=10) info2 = tk.Label(gsNameFrame, text="Name\n Google-Spread") info2.grid(column=1, row = 1) input2 = tk.Entry(gsNameFrame, relief='sunken') input2.grid(column=2, row = 1, sticky='w', pady=5, padx=10) input2.config(width=380) self.gsNameEntry = input2 #External Reference input2.insert(0,myConfig.get('planungSpread')) saveBtn = tk.Button(settings, text="Speichern", command = self.save_settings, height=1, width=15) saveBtn.grid(column=1, row = 3, padx=10, sticky = "nw") saveBtn = tk.Button(settings, text="Abbrechen", command = settings.destroy, height=1, width=15) saveBtn.grid(column=2, row = 3, padx=10, sticky = "nw")
def __init__(self): self.ac_v_factor = float(myConfig.get("ac_v_multi"))/float(myConfig.get("ac_v_divi")) self.ac_c_factor = float(myConfig.get("ac_c_multi"))/float(myConfig.get("ac_c_divi")) self.dc_v_factor = float(myConfig.get("dc_v_multi"))/float(myConfig.get("dc_v_divi")) self.dc_c_factor = float(myConfig.get("dc_c_multi"))/float(myConfig.get("dc_c_divi")) self.torque_factor = float(myConfig.get("torque_multi"))/float(myConfig.get("torque_divi")) self.headers = ['time', 'current_1', 'current_3', '_voltage_1', '_voltage_3', 'frequency_2', 'current_2', 'current_dc', '_voltage_2', 'voltage_dc', 'torque', 'frequency_1' ]
def get_planungsdaten(self): self.get_credentials() gSheet = myConfig.get('planungSpread') GSpread = gspread.authorize(self.credentials) act_sh = GSpread.open(gSheet) wks = act_sh.sheet1 planungsdaten = wks.get_all_records(empty2zero=True, head=2) planungsdaten = self.clean_data(planungsdaten) self.session_planungsdaten = planungsdaten return planungsdaten
def get_formatted_data(self, filename, mps): """ load file-->change headers to be easier to identify-->add appropriate types (float, date) -->multiply with factors """ df = self.load_measurements(filename) df = self.change_header_names(df) df['time']=pd.to_datetime(df['time'], format='%d.%m.%Y %H:%M:%S,%f') df = self.fix_dots(df) df = self.apply_factors(df) df = self.apply_star_thing(df) df = self.add_new_cols(df) df_list = self.split_at_gaps(df) new_df = df[0:0] datas = [new_df,] ps_shapes = [] ps_annos = [] amp_shapes = [] amp_annos = [] for _df in df_list: _df.iloc[0]=np.nan _df = self.calc_frequency(_df, "frequency_1", "frequency_2", mps) _df.rpm = _df.frequency*60 #_df['g_frequency']=_df['frequency']*NUMBER_OF_MAGNET_PAIRS # _df['period']= 1/_df.g_frequency ### Find zero-crossings zeros_v_1 = np.trim_zeros(np.where(np.diff(np.signbit(_df.voltage_1)))[0]) zeros_v_2 = np.trim_zeros(np.where(np.diff(np.signbit(_df.voltage_2)))[0]) zeros_v_3 = np.trim_zeros(np.where(np.diff(np.signbit(_df.voltage_3)))[0]) """ find zero-crossings of different phases and calculate the shift one cycle is the range between a zero crossing and the next next one the difference between the zero-crossings of different phases divided by the cycle length * 360° defines the phase shift The looping is necessary, because its not always the first phase that has the first zero_crossing """ i=0 j=0 while True: i+=1 try: cycle_1 = zeros_v_1[i+1]-zeros_v_1[i-1] except: pass try: while zeros_v_2[j+1]<zeros_v_1[i]: j+=1 time1= _df.time.iloc[zeros_v_1[i]] time2= _df.time.iloc[zeros_v_2[j]] ps_shapes.append(Plotter().make_vert_shape(time1,'blue', 'top')) ps_shapes.append(Plotter().make_vert_shape(time2,'blue', 'top')) ps_shapes.append(Plotter().make_hor_shape(time1,time2,'blue')) diffe_12 = zeros_v_1[i]-zeros_v_2[j] shift = 360*diffe_12/cycle_1 mid = np.floor(zeros_v_2[j]+diffe_12/2) mid_time = _df.time.iloc[int(mid)] ps_annos.append(Plotter().add_text_to_shape(mid_time, "{0:.2f}°".format(shift), 'blue', 'top')) except IndexError: break except KeyError as e: print(str(e)) continue i=0 k=0 while True: i+=1 try: cycle_1 = zeros_v_1[i+1]-zeros_v_1[i-1] except: pass try: while zeros_v_3[k]<zeros_v_1[i]: k+=1 time1= _df.time.iloc[zeros_v_3[k]] time2= _df.time.iloc[zeros_v_1[i]] ps_shapes.append(Plotter().make_vert_shape(time1,'green', 'bottom')) ps_shapes.append(Plotter().make_vert_shape(time2,'green', 'bottom')) ps_shapes.append(Plotter().make_hor_shape(time1,time2,'green')) diffe_13 = zeros_v_3[k]-zeros_v_1[i] shift = 360*diffe_13/cycle_1 mid = np.floor(zeros_v_1[i]+diffe_13/2) mid_time = _df.time.iloc[int(mid)] ps_annos.append(Plotter().add_text_to_shape(mid_time, "{0:.2f}°".format(shift), 'green', 'bottom')) except IndexError: break except KeyError as e: print(str(e)) continue """ Adding Lines to show the amplitude """ """ Calculation of the effective current and voltage is done with the root mean square of one whole cycle. """ for i in range(len(zeros_v_1)-2): x= _df.voltage_1[zeros_v_1[i]:zeros_v_1[i+2]] _df.eff_volt_1.iloc[zeros_v_1[i]:zeros_v_1[i+2]] = np.sqrt(np.mean(np.square(x))) for i in range(len(zeros_v_2)-2): x = _df.voltage_2[zeros_v_2[i]:zeros_v_2[i+2]] _df.eff_volt_2.iloc[zeros_v_2[i]:zeros_v_2[i+2]] = np.sqrt(np.mean(np.square(x))) for i in range(len(zeros_v_3)-2): x= _df.voltage_3[zeros_v_3[i]:zeros_v_3[i+2]] _df.eff_volt_3.iloc[zeros_v_3[i]:zeros_v_3[i+2]] = np.sqrt(np.mean(np.square(x))) _df.eff_volt_dc = _df.voltage_dc.mean() zeros_c_1 = np.trim_zeros(np.where(np.diff(np.signbit(_df.current_1)))[0]) zeros_c_2 = np.trim_zeros(np.where(np.diff(np.signbit(_df.current_2)))[0]) zeros_c_3 = np.trim_zeros(np.where(np.diff(np.signbit(_df.current_3)))[0]) for i in range(len(zeros_c_1)-2): x= _df.current_1[zeros_c_1[i]:zeros_c_1[i+2]] _df.eff_curr_1.iloc[zeros_c_1[i]:zeros_c_1[i+2]] = np.sqrt(np.mean(np.square(x))) for i in range(len(zeros_c_2)-2): x = _df.current_2[zeros_c_2[i]:zeros_c_2[i+2]] _df.eff_curr_2.iloc[zeros_c_2[i]:zeros_c_2[i+2]] = np.sqrt(np.mean(np.square(x))) for i in range(len(zeros_c_3)-2): x= _df.current_3[zeros_c_3[i]:zeros_c_3[i+2]] _df.eff_curr_3.iloc[zeros_c_3[i]:zeros_c_3[i+2]] = np.sqrt(np.mean(np.square(x))) _df.eff_curr_dc = _df.current_dc.mean() _df.output = self.calc_output(_df)#_df.eff_curr_1.multiply(_df.eff_volt_1).multiply(3) _df.output_dc = _df.eff_volt_dc*_df.eff_curr_dc _df.input = _df.frequency*_df.torque*2*np.pi _df.efficiency = np.where(_df.output.isnull(), None, _df.output/_df.input) datas.append(_df) if myConfig.get("t_amp"): sh = int(np.floor(mps/200)) max_1 = indexes(df.voltage_1, thres=0.95, min_dist=sh) min_1 = indexes(-df.voltage_1, thres=0.95, min_dist=sh) if myConfig.get("t_v_ac_1"): for i in max_1: if i-sh<0: mini=1 else: mini = i-sh maxi = i+sh try: time = df.time.iloc[i] time1 = time + datetime.timedelta(milliseconds=sh*10) time2 = time + datetime.timedelta(milliseconds=sh*10) voltage = df.voltage_1.iloc[i] amp_shapes.append(Plotter().make_hor_shape(time1,time2,'grey', y=voltage)) amp_annos.append(Plotter().add_text_to_shape(time, "{0:.2f} V".format(voltage),'grey', 'top',y=voltage)) except: continue for i in min_1: if i-sh<0: mini=1 else: mini = i-sh maxi = i+sh try: time = df.time.iloc[i] time1 = time + datetime.timedelta(milliseconds=sh*10) time2 = time + datetime.timedelta(milliseconds=sh*10) voltage = df.voltage_1.iloc[i] amp_shapes.append(Plotter().make_hor_shape(time1,time2,'grey', y=voltage)) amp_annos.append(Plotter().add_text_to_shape(time, "{0:.2f} V".format(voltage),'grey', 'bottom',y=voltage)) except: continue if myConfig.get("t_v_ac_2"): max_2 = indexes(df.voltage_2, thres=0.95, min_dist=sh) min_2 = indexes(-df.voltage_2, thres=0.95, min_dist=sh) for i in min_2: if i-sh<0: mini=1 else: mini = i-sh maxi = i+sh try: time = df.time.iloc[i] time1 = time + datetime.timedelta(milliseconds=sh*10) time2 = time + datetime.timedelta(milliseconds=sh*10) voltage = df.voltage_2.iloc[i] amp_shapes.append(Plotter().make_hor_shape(time1,time2,'grey', y=voltage)) amp_annos.append(Plotter().add_text_to_shape(time, "{0:.2f} V".format(voltage),'grey', 'bottom',y=voltage)) except: continue for i in max_2: if i-sh<0: mini=1 else: mini = i-sh maxi = i+sh try: time = df.time.iloc[i] time1 = time + datetime.timedelta(milliseconds=sh*10) time2 = time + datetime.timedelta(milliseconds=sh*10) voltage = df.voltage_2.iloc[i] amp_shapes.append(Plotter().make_hor_shape(time1,time2,'grey', y=voltage)) amp_annos.append(Plotter().add_text_to_shape(time, "{0:.2f} V".format(voltage),'grey', 'top',y=voltage)) except: continue if myConfig.get("t_v_ac_3"): max_3 = indexes(df.voltage_3, thres=0.95, min_dist=sh) min_3 = indexes(-df.voltage_3, thres=0.95, min_dist=sh) for i in max_3: if i-sh<0: mini=1 else: mini = i-sh maxi = i+sh try: time = df.time.iloc[i] time1 = time + datetime.timedelta(milliseconds=sh*10) time2 = time + datetime.timedelta(milliseconds=sh*10) voltage = df.voltage_3.iloc[i] amp_shapes.append(Plotter().make_hor_shape(time1,time2,'grey', y=voltage)) amp_annos.append(Plotter().add_text_to_shape(time, "{0:.2f} V".format(voltage),'grey', 'top',y=voltage)) except: continue for i in min_3: if i-sh<0: mini=1 else: mini = i-sh maxi = i+sh try: time = df.time.iloc[i] time1 = time + datetime.timedelta(milliseconds=sh*10) time2 = time + datetime.timedelta(milliseconds=sh*10) voltage = df.voltage_3.iloc[i] amp_shapes.append(Plotter().make_hor_shape(time1,time2,'grey', y=voltage)) amp_annos.append(Plotter().add_text_to_shape(time, "{0:.2f} V".format(voltage),'grey', 'bottom',y=voltage)) except: continue return datas, ps_shapes, ps_annos, amp_shapes, amp_annos
def process_data(self): calc = Calculator() plotter = Plotter() rpm_data = [] rpm_str = [] for filename in self.file_list: print(filename) _filename = filename.replace(".txt", "").split("/")[-1] day, time, id, iteration = _filename.split('_') df_list, ps_shapes, ps_annos, amp_shapes, amp_annos = calc.get_formatted_data( filename, 10000) filename = filename.replace(".txt", "") time_data = [] shapes = [] annos = [] df = pd.concat(df_list) if myConfig.get("t_c_dc"): time_data.append( plotter.make_graph(df, "time", "current_dc", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_curr_dc", " {}|{}".format(id, iteration))) if myConfig.get("t_v_dc"): time_data.append( plotter.make_graph(df, "time", "voltage_dc", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_volt_dc", " {}|{}".format(id, iteration))) if myConfig.get("t_c_ac_1"): time_data.append( plotter.make_graph(df, "time", "current_1", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_curr_1", " {}|{}".format(id, iteration))) if myConfig.get("t_c_ac_2"): time_data.append( plotter.make_graph(df, "time", "current_2", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_curr_2", " {}|{}".format(id, iteration))) if myConfig.get("t_c_ac_3"): time_data.append( plotter.make_graph(df, "time", "current_3", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_curr_3", " {}|{}".format(id, iteration))) if myConfig.get("t_v_ac_1"): time_data.append( plotter.make_graph(df, "time", "voltage_1", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_volt_1", " {}|{}".format(id, iteration))) if myConfig.get("t_v_ac_2"): time_data.append( plotter.make_graph(df, "time", "voltage_2", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_volt_2", " {}|{}".format(id, iteration))) if myConfig.get("t_v_ac_3"): time_data.append( plotter.make_graph(df, "time", "voltage_3", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "eff_volt_3", " {}|{}".format(id, iteration))) if myConfig.get("t_rpm"): time_data.append( plotter.make_graph(df, "time", "rpm", " {}|{}".format(id, iteration))) if myConfig.get("t_torque"): time_data.append( plotter.make_graph(df, "time", "torque", " {}|{}".format(id, iteration))) if myConfig.get("t_input"): time_data.append( plotter.make_graph(df, "time", "input", " {}|{}".format(id, iteration))) if myConfig.get("t_output"): time_data.append( plotter.make_graph(df, "time", "output", " {}|{}".format(id, iteration))) if myConfig.get("t_output_dc"): time_data.append( plotter.make_graph(df, "time", "output_dc", " {}|{}".format(id, iteration))) if myConfig.get("t_eff"): time_data.append( plotter.make_graph(df, "time", "efficiency", " {}|{}".format(id, iteration))) if myConfig.get("t_amp"): shapes += amp_shapes annos += amp_annos if myConfig.get("t_ps"): shapes += ps_shapes annos += ps_annos if myConfig.get("t_volt_orig"): time_data.append( plotter.make_graph(df, "time", "_voltage_1", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "_voltage_2", " {}|{}".format(id, iteration))) time_data.append( plotter.make_graph(df, "time", "_voltage_3", " {}|{}".format(id, iteration))) if myConfig.get("rpm_c_dc"): rpm_data.append( plotter.make_graph(df, "rpm", "current_dc", " {}|{}".format(id, iteration))) if myConfig.get("rpm_v_dc"): rpm_data.append( plotter.make_graph(df, "rpm", "voltage_dc", " {}|{}".format(id, iteration))) if myConfig.get("rpm_c_ac_1"): rpm_data.append( plotter.make_graph(df, "rpm", "current_1", " {}|{}".format(id, iteration))) if myConfig.get("rpm_c_ac_2"): rpm_data.append( plotter.make_graph(df, "rpm", "current_2", " {}|{}".format(id, iteration))) if myConfig.get("rpm_c_ac_3"): rpm_data.append( plotter.make_graph(df, "rpm", "current_3", " {}|{}".format(id, iteration))) if myConfig.get("rpm_v_ac_1"): rpm_data.append( plotter.make_graph(df, "rpm", "voltage_1", " {}|{}".format(id, iteration))) if myConfig.get("rpm_v_ac_2"): rpm_data.append( plotter.make_graph(df, "rpm", "voltage_2", " {}|{}".format(id, iteration))) if myConfig.get("rpm_v_ac_3"): rpm_data.append( plotter.make_graph(df, "rpm", "voltage_3", " {}|{}".format(id, iteration))) if myConfig.get("rpm_torque"): rpm_data.append( plotter.make_graph(df, "rpm", "torque", " {}|{}".format(id, iteration))) if myConfig.get("rpm_input"): rpm_data.append( plotter.make_graph(df, "rpm", "input", " {}|{}".format(id, iteration))) if myConfig.get("rpm_output"): rpm_data.append( plotter.make_graph(df, "rpm", "output", " {}|{}".format(id, iteration))) if myConfig.get("rpm_output_dc"): time_data.append( plotter.make_graph(df, "time", "output_dc", " {}|{}".format(id, iteration))) if myConfig.get("rpm_eff"): rpm_data.append( plotter.make_graph(df, "rpm", "efficiency", " {}|{}".format(id, iteration))) if time_data: i = 0 htmlname = _filename while True: if glob.glob("graphs/{}.{}".format(htmlname, ".html")): i += 1 htmlname = htmlname.replace("({})".format(i - 1), "") + "({})".format(i) continue break plotter.plot_it(time_data, "graphs/{}.{}".format(htmlname, "html"), shapes, annos) i = 0 excelname = _filename while True: if glob.glob("excels/{}.{}".format(excelname, "xlsx")): i += 1 excelname = excelname.replace("({})".format(i - 1), "") + "({})".format(i) continue break writer = pd.ExcelWriter("excels/{}.{}".format(excelname, "xlsx")) df.to_excel(writer) writer.save() rpm_str.append("{}-{}".format(id, iteration)) if rpm_data: i = 0 rpmname = "RPM " + "_".join(rpm_str) while True: if glob.glob("graphs/{}.".format(rpmname, "html")): i += 1 rpmname = rpmname.replace("({})".format(i - 1), "") + "({})".format(i) continue break plotter.plot_it(rpm_data, "graphs/{}.{}".format(rpmname, "html"), shapes, annos)
def build_settings_2(self): settings = tk.Toplevel() settings.title("Data-Choice") settings.resizable(width=False, height=False) self.topSet_2 = settings # external reference tk.Label(settings, text="Variable").grid(row=1, column=0) tk.Label(settings, text="Zeit").grid(row=1, column=1) tk.Label(settings, text="RPM").grid(row=1, column=2) tk.Label(settings, text="DC Current").grid(row=2, column=0) self.t_c_dc = tk.IntVar() #Current DC über Zeit self.t_c_dc.set(myConfig.get("t_c_dc")) tk.Checkbutton(settings, variable=self.t_c_dc).grid(row=2, column=1) self.rpm_c_dc = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_c_dc).grid(row=2, column=2) self.rpm_c_dc.set(myConfig.get("rpm_c_dc")) tk.Label(settings, text="DC Voltage").grid(row=3, column=0) self.t_v_dc = tk.IntVar() #Current DC über Zeit self.t_v_dc.set(myConfig.get("t_v_dc")) tk.Checkbutton(settings, variable=self.t_v_dc).grid(row=3, column=1) self.rpm_v_dc = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_v_dc).grid(row=3, column=2) self.rpm_v_dc.set(myConfig.get("rpm_v_dc")) tk.Label(settings, text="AC Current 1").grid(row=4, column=0) self.t_c_ac_1 = tk.IntVar() #Current DC über Zeit self.t_c_ac_1.set(myConfig.get("t_c_ac_1")) tk.Checkbutton(settings, variable=self.t_c_ac_1).grid(row=4, column=1) self.rpm_c_ac_1 = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_c_ac_1).grid(row=4, column=2) self.rpm_c_ac_1.set(myConfig.get("rpm_c_ac_1")) tk.Label(settings, text="AC Current 2").grid(row=5, column=0) self.t_c_ac_2 = tk.IntVar() #Current DC über Zeit self.t_c_ac_2.set(myConfig.get("t_c_ac_2")) tk.Checkbutton(settings, variable=self.t_c_ac_2).grid(row=5, column=1) self.rpm_c_ac_2 = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_c_ac_2).grid(row=5, column=2) self.rpm_c_ac_2.set(myConfig.get("rpm_c_ac_2")) tk.Label(settings, text="AC Current 3").grid(row=6, column=0) self.t_c_ac_3 = tk.IntVar() #Current DC über Zeit self.t_c_ac_3.set(myConfig.get("t_c_ac_3")) tk.Checkbutton(settings, variable=self.t_c_ac_3).grid(row=6, column=1) self.rpm_c_ac_3 = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_c_ac_3).grid(row=6, column=2) self.rpm_c_ac_3.set(myConfig.get("rpm_c_ac_3")) tk.Label(settings, text="AC Voltage 1").grid(row=7, column=0) self.t_v_ac_1 = tk.IntVar() #Current DC über Zeit self.t_v_ac_1.set(myConfig.get("t_v_ac_1")) tk.Checkbutton(settings, variable=self.t_v_ac_1).grid(row=7, column=1) self.rpm_v_ac_1 = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_v_ac_1).grid(row=7, column=2) self.rpm_v_ac_1.set(myConfig.get("rpm_v_ac_1")) tk.Label(settings, text="AC Voltage 2").grid(row=8, column=0) self.t_v_ac_2 = tk.IntVar() #Current DC über Zeit self.t_v_ac_2.set(myConfig.get("t_v_ac_2")) tk.Checkbutton(settings, variable=self.t_v_ac_2).grid(row=8, column=1) self.rpm_v_ac_2 = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_v_ac_2).grid(row=8, column=2) self.rpm_v_ac_2.set(myConfig.get("rpm_v_ac_2")) tk.Label(settings, text="AC Voltage 3").grid(row=9, column=0) self.t_v_ac_3 = tk.IntVar() #Current DC über Zeit self.t_v_ac_3.set(myConfig.get("t_v_ac_3")) tk.Checkbutton(settings, variable=self.t_v_ac_3).grid(row=9, column=1) self.rpm_v_ac_3 = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_v_ac_3).grid(row=9, column=2) self.rpm_v_ac_3.set(myConfig.get("rpm_v_ac_3")) tk.Label(settings, text="Input").grid(row=10, column=0) self.t_input = tk.IntVar() #Current DC über Zeit self.t_input.set(myConfig.get("t_input")) tk.Checkbutton(settings, variable=self.t_input).grid(row=10, column=1) self.rpm_input = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_input).grid(row=10, column=2) self.rpm_input.set(myConfig.get("rpm_input")) tk.Label(settings, text="Output").grid(row=11, column=0) self.t_output = tk.IntVar() #Current DC über Zeit self.t_output.set(myConfig.get("t_output")) tk.Checkbutton(settings, variable=self.t_output).grid(row=11, column=1) self.rpm_output = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_output).grid(row=11, column=2) self.rpm_output.set(myConfig.get("rpm_output")) tk.Label(settings, text="Output DC").grid(row=12, column=0) self.t_output_dc = tk.IntVar() #Current DC über Zeit self.t_output_dc.set(myConfig.get("t_output_dc")) tk.Checkbutton(settings, variable=self.t_output_dc).grid(row=12, column=1) self.rpm_output_dc = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_output_dc).grid(row=12, column=2) self.rpm_output_dc.set(myConfig.get("rpm_output_dc")) tk.Label(settings, text="Efficiency").grid(row=13, column=0) self.t_eff = tk.IntVar() #Current DC über Zeit self.t_eff.set(myConfig.get("t_eff")) tk.Checkbutton(settings, variable=self.t_eff).grid(row=13, column=1) self.rpm_eff = tk.IntVar() #current DC über RPM tk.Checkbutton(settings, variable=self.rpm_eff).grid(row=13, column=2) self.rpm_eff.set(myConfig.get("rpm_eff")) tk.Label(settings, text="Amplitude (V)").grid(row=14, column=0) self.t_amp = tk.IntVar() #Current DC über Zeit self.t_amp.set(myConfig.get("t_amp")) tk.Checkbutton(settings, variable=self.t_amp).grid(row=14, column=1) tk.Label(settings, text="Phaseshift (V)").grid(row=15, column=0) self.t_ps = tk.IntVar() #Current DC über Zeit self.t_ps.set(myConfig.get("t_ps")) tk.Checkbutton(settings, variable=self.t_ps).grid(row=15, column=1) tk.Label(settings, text="Volt(only factors)").grid(row=16, column=0) self.t_volt_orig = tk.IntVar() #Current DC über Zeit self.t_volt_orig.set(myConfig.get("t_volt_orig")) tk.Checkbutton(settings, variable=self.t_volt_orig).grid(row=16, column=1) tk.Label(settings, text="Torque").grid(row=17, column=0) self.t_torque = tk.IntVar() #Current DC über Zeit self.t_torque.set(myConfig.get("t_torque")) tk.Checkbutton(settings, variable=self.t_torque).grid(row=17, column=1) tk.Label(settings, text="RPM").grid(row=18, column=0) self.t_rpm = tk.IntVar() #Current DC über Zeit self.t_rpm.set(myConfig.get("t_rpm")) tk.Checkbutton(settings, variable=self.t_rpm).grid(row=18, column=1) saveBtn = tk.Button(settings, text="Save", command=self.save_settings_2, height=1, width=15) saveBtn.grid(row=19, column=0) saveBtn = tk.Button(settings, text="Abbrechen", command=settings.destroy, height=1, width=15) saveBtn.grid(row=19, column=2)
def write_planungsdaten2excel(self, dbData, planungData): outPath = myConfig.get('outputExcel') try: outWb = pxl.load_workbook(filename=outPath, keep_vba = True) except: print(outPath + " must be closed!") return outWs = outWb.get_sheet_by_name("Daten Installationsbelege Neu") outWs['B5'].value = "" outData = {} #Add planungsdaten for p in planungData: outData[('Bezeichner', p['Nummer MST/STST'])] = p['Nummer MST/STST'] outData[('Datum', p['Nummer MST/STST'])] = p['Datum Installation'] outData[('Uhrzeit', p['Nummer MST/STST'])] = p['Uhrzeit'] outData[('Umfang Messst.', p['Nummer MST/STST'])] = p['Auftrag Messstelle'] outData[('Umfang SSt.', p['Nummer MST/STST'])] = p['Auftrag Steuerstelle'] outData[('Installationspartner', p['Nummer MST/STST'])] = p['Termin angefragt bei'] outData[('Ansprechpartner vor Ort', p['Nummer MST/STST'])] = str(p['Vorname']) + ' ' + str(p['Nachname']) outData[('Telefon 1 ASP', p['Nummer MST/STST'])] = p['Telefon'] outData[('Telefon 2 ASP', p['Nummer MST/STST'])] = p['Mobil'] outData[('Ausbau durch', p['Nummer MST/STST'])] = p['Ausbau Altzähler durch'] outData[('Typenschlüssel', p['Nummer MST/STST'])] = p['Typenschlüssen (Anfang)'] outData[('Nennspannung', p['Nummer MST/STST'])] = p['Spannung'] outData[('Nennstrom', p['Nummer MST/STST'])] = p['Stromtyp'] outData[('Genauigkeit', p['Nummer MST/STST'])] = p['Genauigkeitsklasse'] outData[('Leistungsbegrenzung', p['Nummer MST/STST'])] = p['Leistungsbegrenzung'] outData[('Hilfsspannung', p['Nummer MST/STST'])] = p['Hilfsspannung'] outData[('Impulsausgang', p['Nummer MST/STST'])] = p['Impulsausgang'] outData[('Modem Typ', p['Nummer MST/STST'])] = p['Bezeichnung'] outData[('Modem Info', p['Nummer MST/STST'])] = p['Typenschlüssel'] outData[('Technische Hinweise', p['Nummer MST/STST'])] = p['technische Hinweise Messstelle'] outData[('Steuermodul', p['Nummer MST/STST'])] = p['Steuermodul'] outData[('Sollwertgeber', p['Nummer MST/STST'])] = p['Sollwertgeber'] outData[('Steuerung Infos', p['Nummer MST/STST'])] = p['technische Hinweise Steuerstelle'] outData[('Anfahrtsinfo', p['Nummer MST/STST'])] = p['Anfahrtsinfo'] if p['Auftrag Messstelle'] != 0: outData[('Messstelle', p['Nummer MST/STST'])] = "X" else: outData[('Messstelle', p['Nummer MST/STST'])] = "" if p['Auftrag Steuerstelle'] != 0: outData[('Steuerstelle', p['Nummer MST/STST'])] = "X" else: outData[('Steuerstelle', p['Nummer MST/STST'])] = "" #Add dbDaten for lOuter in dbData: for lInner in lOuter: outData[('Name', lInner[1])] = lInner[0] #outData[('Messstelle', lInner[1])] = lInner[1] #outData[('Steuerstelle', lInner[1])] = lInner[2] outData[('Komplex', lInner[1])] = lInner[3] outData[('Kunde', lInner[1])] = lInner[4] outData[('PLZ', lInner[1])] = lInner[5] outData[('Ort', lInner[1])] = lInner[6] outData[('Straße', lInner[1])] = lInner[7] outData[('HNr', lInner[1])] = lInner[8] outData[('Anlagentyp', lInner[1])] = lInner[9] outData[('Anprechpartner Vertraglich', lInner[1])] = str(lInner[10]) + " " + str(lInner[11]) + " " + str(lInner[12]) outData[('Verteilnetzbetreiber', lInner[1])] = lInner[13] if lInner[15] == 0: outData[('Zählpunkt', lInner[1])] = lInner[14] else: outData[('Zählpunkt', lInner[1])] = lInner[15] outData[('PLZ Messstelle', lInner[1])] = lInner[5] outData[('Ort Messstelle', lInner[1])] = lInner[6] outData[('Straße Messstelle', lInner[1])] = lInner[7] outData[('HNr. Messstelle', lInner[1])] = lInner[8] outData[('Position Zähler', lInner[1])] = lInner[16] outData[('Gerätenummer', lInner[1])] = lInner[17] outData[('MSBA', lInner[1])] = lInner[18] outData[('Wandlerfaktor', lInner[1])] = lInner[19] outData[('Spannung ungewandelt', lInner[1])] = lInner[20] outData[('Spannung gewandelt', lInner[1])] = lInner[21] outData[('Strom ungewandelt', lInner[1])] = lInner[22] outData[('Strom gewandelt', lInner[1])] = lInner[23] outData[('PLZ Steuerstelle', lInner[1])] = lInner[5] outData[('Ort Steuerstelle', lInner[1])] = lInner[6] outData[('Straße Steuerstelle', lInner[1])] = lInner[7] outData[('HNr. Steuerstelle', lInner[1])] = lInner[8] #Add undefined for p in planungData: outData[('Kontakt VNB', p['Nummer MST/STST'])] = "" outData[('Kontakt MSBA', p['Nummer MST/STST'])] = "" outData[('Modem Info', p['Nummer MST/STST'])] = "" outData[('Position Steuerung', p['Nummer MST/STST'])] = "" outData[('Fernwirktechnik', p['Nummer MST/STST'])] = "" #Clear old Data clearRange = outWs['A5':'BJ300'] for row in clearRange: for cell in row: cell.value = "" #Write new Data i_col = 1 i_row = 5 for p in planungData: for feld in self.outDatenfelder: value = outData[(feld, p['Nummer MST/STST'])] if value == 0: value = "" else: outWs.cell(row = i_row, column = i_col).value = value i_col += 1 i_col = 1 i_row +=1 try: outWb.save(filename=outPath) except: print(outPath + " must be closed!") return print("Data sucessfully written to " + outPath)