def upload_file(): if request.method == 'POST': if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] vendors = request.files['vendors'] if vendors.filename == '': return send_file( os.path.join(app.config['UPLOAD_FOLDER'], 'novendors.txt')) if file.filename == '': flash('No selected file') return send_file( os.path.join(app.config['UPLOAD_FOLDER'], 'novendors.txt')) if file and vendors: vendor_filename = secure_filename(vendors.filename) filename = secure_filename(file.filename) vendors.save( os.path.join(app.config['UPLOAD_FOLDER'], vendor_filename)) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) excel.main( os.path.join(app.config['UPLOAD_FOLDER'], filename), os.path.join(app.config['UPLOAD_FOLDER'], vendor_filename)) return send_file('/var/www/FlaskApp/FlaskApp/export.xlsx', attachment_filename='export.xlsx') return redirect(request.url)
def main(): #global Pred i = 0 #thread.start_new_thread(adquisicion2,(i,)) while True: n = excel.main(float(16), 0) n = int(n) mcpras.set_value(n) time.sleep(0.2) # P1=Node611.sensorm() # try: Pred = adquisicion2() # # except: # time.sleep(0.1) # Pred=adquisicion2() # # # result = client.read_holding_registers(11729, 2, unit=1)#Current A 1100 # decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big ) # print(result.registers) # print(decoder.decode_32bit_float()) # result.registers=0 #archivo.write(str(Pred)+'\n') print(Pred) i = i + 1
def main(): #global Pred v = 14.5 i = 0 k = 1 j = 1 #thread.start_new_thread(adquisicion2,(i,)) while True: n = excel.main(float(v), 0) n = int(n) mcpras.set_value(n) time.sleep(0.3) # P1=Node611.sensorm() Psol = n611_adquisicion.adquisicion() try: Pred = adquisicion2() except: time.sleep(1) Pred = adquisicion2() Pload = Psol * 0.76 + Pred * 0.56 hoja.write(j, 0, str(k)) hoja.write(j, 1, time.strftime("%X")) hoja.write(j, 2, str(v)) hoja.write(j, 3, str(Pred)) hoja.write(j, 4, str(Psol)) hoja.write(j, 5, str(Pload)) # result = client.read_holding_registers(11729, 2, unit=1)#Current A 1100 # decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big ) # print(result.registers) # print(decoder.decode_32bit_float()) # result.registers=0 #archivo.write(str(Pred)+'\n') print(Pred) print(Psol) print(v) v = v + 0.1 i = i + 1 j = j + 1 if i == 35: k = k + 1 i = 0 v = 14.5
def main(): count = 1 get_absentee_list(get_yesterday()) if datetime.today().weekday() == 0: get_absentee_list(get_days_ago(2)) get_absentee_list(get_days_ago(3)) count = 3 get_email_list() data, emails = excel.main(count) #create_emails(data, emails) #for key in data: # send_email.send_mail(get_creds(), emails[key], 'Test', str(data[key])) print("Done")
Vrefd['Z'] = fuzz.trimf(Vrefd.universe, [-0.01, 0, 0.01]) ##Rules rule1 = ctrl.Rule(Pdif['P'], Vrefd['P']) rule2 = ctrl.Rule(Pdif['N'], Vrefd['N']) rule3 = ctrl.Rule(Pdif['Z'], Vrefd['Z']) vref_ctrl = ctrl.ControlSystem([rule1, rule2, rule3]) vrefout = ctrl.ControlSystemSimulation(vref_ctrl) i = True v = 17 while True: n = excel.main(float(v), 0) n = int(n) mcpras.set_value(n) P1 = Node611.sensorm() time.sleep(1) n = excel.main(float(v), 0) n = int(n) mcpras.set_value(n) P2 = Node611.sensorm() Pdif = P2 - P1 vrefout.input['Pdif'] = Pdif vrefout.compute()
def main(default_lane=7, image_files={}, src_folder='', dst_folder='', excel_file='', root=None, progress_str=None): ''' 总的执行函数, 如果失败,返回消息字符串,否则返回True ''' inplace = src_folder == dst_folder # os.path.samefile在Win7_32中好像会出错 inplace_OK = True if inplace: inplace_OK = messagebox.askyesno(title='警告', message='确定要在当前文件夹中修改?') if not inplace_OK: return '操作被取消' # # 提取所需数据 # update_progress(root, progress_str, '正在获取文件信息...') # inplace = os.path.samefile(src_folder, dst_folder) file2datetimes = extract_from_images(image_files) car_datetimes = generate_car_datetimes(file2datetimes) # 此时才能判断是否可正确提取元数据 can_extract_ctime = validate.image_file(file2datetimes[0][0]) if isinstance(can_extract_ctime, str): update_progress(root, progress_str, '') return can_extract_ctime not_edited = get_not_edited(car_datetimes) edited_and_row_start = excel.get_edited_and_row_start( excel_file, car_datetimes[0]) edited = edited_and_row_start[0] row_start = edited_and_row_start[1] # for pair in file2datetimes: # print(pair[0], ' -> ', pair[1]) # print(''' # inplace: {}, # car_datetimes: {}, # edited: {}, # not_edited: {}, # row_start: {}, # '''.format(inplace, # car_datetimes, # edited, not_edited, # row_start)) # return True # 照片重命名 # update_progress(root, progress_str, '正在重命名图片....') result = rename.main(file2datetimes, dst_folder, edited=edited, inplace=inplace) if isinstance(result, str): update_progress(root, progress_str, '') return result # print('重命名照片结束') # # 操作excel文件 # update_progress(root, progress_str, '正在写入Excel文件....') result = excel.main(excel_file, car_datetimes, row_start, default_lane=default_lane, edited=edited, not_edited=not_edited) if isinstance(result, str): update_progress(root, progress_str, '') return result update_progress(root, progress_str, '') return True
def main(): i = True #thread.start_new_thread(adquisicion2,(i,)) dired = 0.1 Vdif = 0.2 v2 = 18.6 n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) Ired2 = adquisicion2() while True: vrefout.input['dired'] = dired vrefout.input['Vdif'] = Vdif vrefout.compute() Vrefin = round(vrefout.output['Vrefd'], 2) #if Vrefin==0: #n = excel.main(float(v2),0) #n = int(n) #mcpras.set_value(n) #time.sleep(1) #P2=Node611.sensorm() #n = excel.main(float(v2-0.3),0) #n = int(n) #mcpras.set_value(n) #time.sleep(1) #P1=Node611.sensorm() #Pdif=P2-P1 #Vdif=0.2 #else: v = v2 v2 = v2 + Vrefin Vdif = v2 - v Ired = Ired2 try: n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) except: n = excel.main(float(14.5), 0) n = int(n) mcpras.set_value(n) v2 = 14.5 time.sleep(0.2) Ired2 = adquisicion2() dired = Ired2 - Ired Vdif = round(Vdif, 2) # print("Corriente de la red t= "+str(Ired)) # print("Corriente de la red t+1 = "+str(Ired2)) print("Cambio de corriente =" + str(dired)) # print("Vref1"+str(v)) print("Vref2 = " + str(v2)) # print("diferencia de voltaje v2-v"+str(Vdif)) # print("Cambio de potencia/voltaje = "+str(dpdv)) print("Cambio de voltaje = " + str(Vrefin))
def fuzzy(): i = True #thread.start_new_thread(adquisicion2,(i,)) dIdv = 2 v2 = 18.5 n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) Ired2 = corrienteRed() while True: vrefout.input['dIdv'] = dIdv vrefout.compute() Vrefin = round(vrefout.output['Vrefd'], 3) Vrefinabs = abs(Vrefin) #print("Corriente de la red t= "+str(Ired)) print("Corriente de la red t+1 = " + str(Ired2)) # print("Cambio de corriente ="+str(dired)) # print("Vref1"+str(v)) print("Vref2 = " + str(v2)) # print("diferencia de voltaje v2-v"+str(Vdif)) print("Cambio de corriente/voltaje = " + str(dIdv)) print("Cambio de voltaje = " + str(Vrefin)) if Vrefinabs < 0.1: if v2 < 14.6: v2 = 14.5 elif v2 > 18.5: v2 = 18.5 #dIdv=0 n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) time.sleep(0.2) Ired = corrienteRed() n = excel.main(float(v2 + 0.1), 0) n = int(n) mcpras.set_value(n) time.sleep(0.2) Ired2 = corrienteRed() if Ired <= 1.01 * Ired2 and Ired >= 0.09 * Ired2: dIdv = 2 else: dIdv = 0 #dired=Ired2-Ired else: v2 = v2 + Vrefin Ired = Ired2 if v2 < 14.6: v2 = 14.5 elif v2 > 18.5: v2 = 18.6 n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) time.sleep(0.2) try: Ired2 = corrienteRed() except: try: time.sleep(0.5) Ired2 = corrienteRed() except: time.sleep(0.5) Ired2 = corrienteRed() dired = Ired2 - Ired dIdv = dired / Vrefin if dIdv >= 500: dIdv = 500 elif dIdv <= -500: dIdv = -500
def fuzzy(): sw = 0 i = True #thread.start_new_thread(adquisicion2,(i,)) dpdv = 100 v2 = 18.5 dpred = 0 n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) time.sleep(0.2) Pred2 = potenciaRed() k = 0 while True: if sw == 0: vrefout.input['dpdv'] = dpdv vrefout.compute() Vrefin = round(vrefout.output['Vrefd'], 3) Vrefinabs = abs(Vrefin) elif sw == 1: Vrefin = 0.1 sw = 0 elif sw == 2: Vrefin = -0.1 sw = 0 # print("Corriente de la red t= "+str(Ired)) # print("Corriente de la red t+1 = "+str(Pred2)) # print("Cambio de corriente ="+str(dpred)) # print("Vref1"+str(v)) # print("Vref2 = "+str(v2)) # print("diferencia de voltaje v2-v"+str(Vdif)) # print("Cambio de corriente/voltaje = "+str(dpdv)) print("Cambio de voltaje= " + str(Vrefin) + "\n") k = k + 1 v2 = v2 + Vrefin print("Vref2 = " + str(v2)) print(time.strftime("%X")) Pred = Pred2 hoja1.write(k, 0, str(v2)) hoja1.write(k, 1, time.strftime("%X")) # print(v2) if v2 < 14.6: v2 = 14.5 elif v2 > 18.5: v2 = 18.5 n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) time.sleep(1) # try: Pred2 = potenciaRed() #except: # try: # time.sleep(0.5) # Ired2=corrienteRed() # except: # time.sleep(0.5) # Ired2=corrienteRed() dpred = Pred2 - Pred # try: if Vrefin < 0: dpdv = dpred * -10 elif Vrefin > 0: dpdv = dpred * 10 else: sw = 1 #dpdv=dpred/Vrefin # except: # sw=1 # if dpred>0.05*Pred2: # Predbck=potenciaRed() # if Predbck<0.9*Pred2 and Predbck>1.1*Pred2: # sw=1 # Pred2=Predbck # dpred=Pred2-Pred # else: # sw=1 if abs(Vrefin) < 0.09 and abs(dpdv) > 35: #dIdv=1.5 if dpdv < 0: sw = 1 else: sw = 2 if dpdv >= 500: dpdv = 500 elif dpdv <= -500: dpdv = -500
#rule3=ctrl.Rule(Pdif['Z'],Vrefd['Z']) rule1 = ctrl.Rule(dpdv['N'] & Vdif['P'], Vrefd['N']) rule2 = ctrl.Rule(dpdv['N'] & Vdif['N'], Vrefd['N']) rule3 = ctrl.Rule(dpdv['P'] & Vdif['N'], Vrefd['P']) rule4 = ctrl.Rule(dpdv['P'] & Vdif['P'], Vrefd['P']) rule5 = ctrl.Rule(dpdv['Z'], Vrefd['Z']) vref_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5]) vrefout = ctrl.ControlSystemSimulation(vref_ctrl) i = True dpdv = -1 Vdif = -0.2 v2 = 18.6 n = excel.main(float(v2), 0) n = int(n) mcpras.set_value(n) P2 = Node611.sensorm() while True: if v2 <= 14.6: v2 = 14.5 elif v2 >= 18.5: v2 = 18.6 vrefout.input['dpdv'] = dpdv vrefout.input['Vdif'] = Vdif vrefout.compute() Vrefin = round(vrefout.output['Vrefd'], 2)