def on_pre_enter(self): dices = store.get_store("dices.pickle") self.dicesnames = [ dicename for dicename in dices ] + ["default"] self.dicessets = store.get_store("dicessets.pickle") dicessetsnames = [ dicesetname for dicesetname in self.dicessets ] + ["default"] self.ids.diceset_model_spinner.values = dicessetsnames self.adddice = DiceButton(id="adddice", text="Add Dice", on_release=self.add_dice) self.deldice = DiceButton(id="deldice", text="Del Dice", on_release=self.del_dice) if self.ids.diceset_model_spinner.text == "default": self.create_default() else: self.load_diceset()
def show_popup(self, diceset): self.title = diceset+" Result" dices = store.get_store("dices.pickle") dicesets = store.get_store("dicessets.pickle") ldices = dicesets.get(diceset)["data"]["dices"] self.ids.inlayout.rows = len(ldices) for dice in ldices: dice = dices.get(dice)["data"] color = dice["color"] faces = dice["faces"] face = random.choice(faces) res = add_color(face, color) facelabel = DiceLabel(text=res) self.ids.inlayout.add_widget(facelabel) self.open()
def show_flow_results(self): '''Launch when clicked on result Compute, store the computation and lauch a popup ''' store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Idiameter', value=float(self.ids.Idiameter.text), unit=self.ids.IdiameterUnit.text) store.put('Voltage', value=float(self.ids.Voltage.text), unit=self.ids.VoltageUnit.text) store.put('Electroosmosis', value=float(self.ids.Electroosmosis.text), unit=self.ids.ElectroosmosisUnit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #get and save errors and value capillary_manager = capillarymanager.CapillaryManager() errcode, errtext = capillary_manager.save_flow_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = FlowPopup() self._popup.show_popup(data)
def show_viscosity_results(self): '''Launch when clicked on result Compute, store the computation and lauch a popup ''' #save data store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Idiameter', value=float(self.ids.Idiameter.text), unit=self.ids.IdiameterUnit.text) store.put('Pressure', value=float(self.ids.Pressure.text), unit=self.ids.PressureUnit.text) store.put('Detectiontime', value=float(self.ids.Detectiontime.text), unit=self.ids.DetectiontimeUnit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #get and use error codes capillary_manager = capillarymanager.CapillaryManager() errcode, errtext = capillary_manager.save_vicosity_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = ViscosityPopup() self._popup.show_popup(data)
def show_popup(self, data): '''Get and show Flows results from the store. ''' store = get_store() self.ids.inlayout.rows = 4 #Field strength self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("Field strength :", "FFFFFF"))) value = round(store.get('Fieldstrength')["value"], 2) value = str(value)+" "+store.get('Fieldstrength')["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(value, "FFFFFF"))) #µEOF self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("µEOF :","BFBFBF"))) value = "{:.2E}".format(store.get('MicroEOF')["value"]) value = value +" "+store.get('MicroEOF')["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(value,"BFBFBF"))) #Length per min self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("Length per min :", "FFFFFF"))) value = round(store.get('Lengthpermin')["value"], 2) value = str(value)+" "+store.get('Lengthpermin')["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(value,"FFFFFF"))) #Flow rate self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("Flow rate :", "BFBFBF"))) value = round(store.get('Flowrate')["value"], 2) value = str(value)+" "+store.get('Flowrate')["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(value,"BFBFBF"))) #open the popup self.open()
def add_line(self, buttoninstance): '''Add a line of timecompount @param buttoninstance: the instance of the button (not used) ''' #del and create again to respect the order self.ids.inlayout.remove_widget(self.add_button) self.ids.inlayout.remove_widget(self.del_button) #create the new line store = get_store() lastval = store.get('Nbtimecompound')["value"] store.put('Nbtimecompound', value=1+lastval) self.ids.inlayout.rows = 5 + store.get('Nbtimecompound')["value"] #add the widget newval = str(store.get('Nbtimecompound')["value"]) timecompount = CEToolBoxLabel(text="Time compound "+newval) timecompountvalue = CEToolBoxTextInput(text=str(1.0), id='Timecompound'+newval) timecompountunit = CEToolBoxSpinner(text=u"min", id='Timecompound'+newval+'Unit', values=["s", "min"]) store.put('Timecompound'+newval, value=1.0, unit="min") self.ids.inlayout.add_widget(timecompount) self.ids.inlayout.add_widget(timecompountvalue) self.ids.inlayout.add_widget(timecompountunit) tosave = [timecompount, timecompountvalue, timecompountunit] self.timecompoundlist.append(tosave) #recreate the button self.add_button = CEToolBoxButton(text="Add", id="addbutton", on_release=self.add_line) self.ids.inlayout.add_widget(self.add_button) self.del_button = CEToolBoxButton(text="Del", id="delbutton", on_release=self.del_line) self.ids.inlayout.add_widget(self.del_button) self.ids.inlayout.rows = 6 + store.get('Nbtimecompound')["value"] #force the good size self.ids.tscrollview.change_child_height(self.ids.tscrollview.height)
def reset(self): """ executed when cliqued on the reset button set the value of nbtimecompound at 1 and delete lines""" store = get_store() nbval = store.get('Nbtimecompound')["value"] for i in range(1, nbval): self.del_line(1)
def show_conductivity_results(self): """ lauch when clicked on result Compute, store the computation and lauch a popup""" store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Idiameter', value=float(self.ids.Idiameter.text), unit=self.ids.IdiameterUnit.text) store.put('Voltage', value=float(self.ids.Voltage.text), unit=self.ids.VoltageUnit.text) store.put('Electriccurrent', value=float(self.ids.Electriccurrent.text), unit=self.ids.ElectriccurrentUnit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #get and save error code computation = Capillary() errcode, errtext = computation.save_conductivy_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = ConductivityPopup() self._popup.show_popup(data)
def save_mobility_result(self): '''Compute and save the result for the mobility result ''' store = get_store() if self.electro_osmosis_time == 0: self.electro_osmosis_time = 1000000 self.capillary = Capillary(self.total_length, self.to_window_length, self.diameter, self.pressure, self.duration, self.viscosity, self.molweight, self.concentration, self.voltage, self.electric_current, self.detection_time, self.electro_osmosis_time) self.electro_osmosis_time = 0.0 try : microeof = self.micro_eof() except ZeroDivisionError: if self.voltage == 0: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("MicroEOF", value=microeof, unit="cm²/V/s") for i in range(1, store.get('Nbtimecompound')["value"]+1): keystore = "Timecompound"+str(i) time = TimeUnits.convert_unit(float(store.get(keystore)["value"]), store.get(keystore)["unit"], u"s") if time == 0: return 1, "The time for compound " + str(i) + " cannot be null" microep = self.micro_ep(time) store.put("MicroEP"+str(i), value=microep, unit="cm²/V/s") return 0, ""
def del_diceset(self): try: store.del_data("dicessets.pickle", self.ids.diceset_name.text) except store.StoreException: self.create_error_popup() self.dicessets = store.get_store("dicessets.pickle") dicessetsnames = [ dicesetname for dicesetname in self.dicessets ] + ["default"] self.ids.dice_model_spinner.values = dicesnames
def show_popup(self, data): """ get and show the viscosity result from the store """ store = get_store() self.ids.inlayout.rows = 1 self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("Viscosity :", "FFFFFF"))) value = round(store.get('Viscosity')["value"], 2) viscotext = str(value)+" "+store.get('Viscosity')["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(viscotext, "FFFFFF"))) self.open()
def auth_login(email, password): ''' Login a user''' store = get_store() email, password = arg_helper.strip_all_args((email, password)) arg_helper.check_no_white_space((email, password)) email_helper.validate_new_email(email)
def edit_dice(self): data = {"faces" : [], "color" : self.ids.dice_color.text} for (facelabel, facename) in self.faces: data["faces"].append(facename.text) try: store.edit_data("dices.pickle", self.ids.dice_name.text, data) except store.StoreException: self.create_error_popup() self.dices = store.get_store("dices.pickle")
def show_popup(self, data): '''Get and show the conductivity result from the store. ''' store = get_store() self.ids.inlayout.rows = 1 self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("Conductivity :", "FFFFFF"))) value = round(store.get('Conductivity')["value"], 2) conductivitytext = str(value)+" "+store.get('Conductivity')["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(conductivitytext, "FFFFFF"))) self.open()
def is_h_id_in_use(h_id): ''' Checks if the household id is in use Returns True or False ''' for household in get_store().get_households_list(): if h_id == household['h_id']: return True return False
def is_u_id_in_use(u_id): ''' Checks if the user id is in use Returns True or False ''' for user in get_store().get_users_list(): if u_id == user['u_id']: return True return False
def new_dice(self): data = {"faces" : [], "color" : self.ids.dice_color.text} for (facelabel, facename) in self.faces: data["faces"].append(facename.text) try: store.add_data("dices.pickle", self.ids.dice_name.text, data) except store.StoreException: self.create_error_popup() self.dices = store.get_store("dices.pickle") dicesnames = [ dicename for dicename in self.dices ] + ["default"] self.ids.dice_model_spinner.values = dicesnames
def is_email_in_use(email): ''' Returns True or False if email is already in use ''' store = get_store() users = store.get_all_users() for user in users: if user.get_email() == email: return True return False
def __init__(self): """ Get all needed values from the store""" store = get_store() # The length of the capillary (centimeter) self.total_length = LengthUnits.convert_unit(float(store.get('Capillary')["value"]), store.get('Capillary')["unit"], u"cm") # The window length (centimeter) self.to_window_length = LengthUnits.convert_unit(float(store.get('Towindow')["value"]), store.get('Towindow')["unit"], u"cm") # The capillary inside diameter (micrometer) #PROBLEM WITH UNICODE NON ASCII self.diameter = LengthUnits.convert_unit(float(store.get('Idiameter')["value"]), store.get('Idiameter')["unit"], u"µm") # The pressure drop across the capillary (mbar) self.pressure = PressureUnits.convert_unit(float(store.get('Pressure')["value"]), store.get('Pressure')["unit"], u"mbar") # The time the pressure is applied (second) self.duration = TimeUnits.convert_unit(float(store.get('Time')["value"]), store.get('Time')["unit"], u"s") # The buffer viscosity (cp) self.viscosity = float(store.get('Viscosity')["value"]) #molecular weight (g/mol) self.molweight = float(store.get("Molweight")["value"]) # Analyte concentration (g/L) if store.get('Concentration')["unit"] == u"mmol/L": tmpconcetration = MolConcentrationUnits.convert_unit(float(store.get('Concentration')["value"]), store.get('Concentration')["unit"], u"mol/L") self.concentration = self.molweight * tmpconcetration else: self.concentration = float(store.get('Concentration')["value"]) # The voltage applied to the capillary (volt) self.voltage = VoltUnits.convert_unit(float(store.get('Voltage')["value"]), store.get('Voltage')["unit"], u"V") # The current applied to the capillary (microampere) self.electric_current = float(store.get('Electriccurrent')["value"]) # The detection time (s) self.detection_time = TimeUnits.convert_unit(float(store.get('Detectiontime')["value"]), store.get('Detectiontime')["unit"], u"s") # The electro-osmosis time (s) self.electro_osmosis_time = TimeUnits.convert_unit(float(store.get('Electroosmosis')["value"]), store.get('Electroosmosis')["unit"], u"s")
def edit_diceset(self): data = {"dices" : []} if len(self.dices) == 0: raise store.StoreException("Cannot save an empty diceset") for (dicelabel, dicename) in self.dices: data["dices"].append(dicename.text) if dicename.text == "default": raise store.StoreException("Cannot use default dice in a diceset") try: store.edit_data("dicessets.pickle", self.ids.diceset_name.text, data) except store.StoreException: self.create_error_popup() self.dicessets = store.get_store("dicessets.pickle")
def change_dice(self): dices = store.get_store("dices.pickle") #delete everything that belong to the other dice self.ids.inlayout.remove_widget(self.addface) self.ids.inlayout.remove_widget(self.delface) for flabel, fname in self.faces: self.ids.inlayout.remove_widget(flabel) self.ids.inlayout.remove_widget(fname) self.faces = [] #set the number of rows if self.ids.dice_model_spinner.text == "default": self.create_default() else: self.load_dice()
def save_vicosity_result(self): """ compute and save the results for the vicosity screen """ store = get_store() try: viscosity = self.compute_viscosity() except ZeroDivisionError: if self.total_length == 0: return 1, "The capillary length cannot be null" else: return 1, "The window length cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put('Viscosity', value=viscosity, unit="cp") return 0, ""
def save_conductivy_result(self): """ compute and save the result for the conductivy screen """ store = get_store() try: conductivity = self.compute_conductivity() except ZeroDivisionError: if self.voltage == 0: return 1, "The voltage cannot be null" else: return 1, "The diameter cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" store.put('Conductivity', value=conductivity, unit="S/m") return 0, ""
def new_diceset(self): data = {"dices" : []} if len(self.dices) == 0: raise store.StoreException("Cannot create an empty diceset") for (dicelabel, dicename) in self.dices: data["dices"].append(dicename.text) if dicename.text == "default": raise store.StoreException("Cannot use default dice in a diceset") try: store.add_data("dicessets.pickle", self.ids.diceset_name.text, data) except store.StoreException: self.create_error_popup() self.dicessets = store.get_store("dicessets.pickle") dicessetsnames = [ dicesetname for dicesetname in self.dicessets ] + ["default"] self.ids.diceset_model_spinner.values = dicessetsnames
def on_pre_enter(self): '''This special function launch at the clic of the button to go on the FlowScreen this value comes from the json file where we keep it ''' store = get_store() self.ids.Capillary.text = str(store.get('Capillary')["value"]) self.ids.CapillaryUnit.text = store.get('Capillary')["unit"] self.ids.Towindow.text = str(store.get('Towindow')["value"]) self.ids.TowindowUnit.text = store.get('Towindow')["unit"] self.ids.Idiameter.text = str(store.get('Idiameter')["value"]) self.ids.IdiameterUnit.text = store.get('Idiameter')["unit"] self.ids.Voltage.text = str(store.get('Voltage')["value"]) self.ids.VoltageUnit.text = store.get('Voltage')["unit"] self.ids.Electroosmosis.text = str(store.get('Electroosmosis')["value"]) self.ids.ElectroosmosisUnit.text = store.get('Electroosmosis')["unit"]
def on_pre_enter(self): '''Special function lauch at the clic of the button to go on the ViscosityScreen this value comes from the json file where we keep it ''' store = get_store() self.ids.Capillary.text = str(store.get('Capillary')["value"]) self.ids.CapillaryUnit.text = store.get('Capillary')["unit"] self.ids.Towindow.text = str(store.get('Towindow')["value"]) self.ids.TowindowUnit.text = store.get('Towindow')["unit"] self.ids.Idiameter.text = str(store.get('Idiameter')["value"]) self.ids.IdiameterUnit.text = unicode(store.get('Idiameter')["unit"]) self.ids.Pressure.text = str(store.get('Pressure')["value"]) self.ids.PressureUnit.text = store.get('Pressure')["unit"] self.ids.Detectiontime.text = str(store.get('Detectiontime')["value"]) self.ids.DetectiontimeUnit.text = store.get('Detectiontime')["unit"]
def on_pre_enter(self): '''Special function lauch at the clic of the button to go on the ConductivityScreen this value comes from the json file where we keep it ''' store = get_store() self.ids.Capillary.text = str(store.get('Capillary')["value"]) self.ids.CapillaryUnit.text = store.get('Capillary')["unit"] self.ids.Towindow.text = str(store.get('Towindow')["value"]) self.ids.TowindowUnit.text = store.get('Towindow')["unit"] self.ids.Idiameter.text = str(store.get('Idiameter')["value"]) self.ids.IdiameterUnit.text = store.get('Idiameter')["unit"] self.ids.Voltage.text = str(store.get('Voltage')["value"]) self.ids.VoltageUnit.text = store.get('Voltage')["unit"] self.ids.Electriccurrent.text = str(store.get('Electriccurrent')["value"]) self.ids.ElectriccurrentUnit.text = store.get('Electriccurrent')["unit"]
def show_injection_results(self): '''Launch when clicked on result. Compute, store the computation and lauch a popup ''' #save data store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Idiameter', value=float(self.ids.Idiameter.text), unit=self.ids.IdiameterUnit.text) store.put('Pressure', value=float(self.ids.Pressure.text), unit=self.ids.PressureUnit.text) store.put('Time', value=float(self.ids.Time.text), unit=self.ids.TimeUnit.text) store.put('Viscosity', value=float(self.ids.Viscosity.text), unit=self.ids.ViscosityUnit.text) store.put('Concentration', value=float(self.ids.Concentration.text), unit=self.ids.ConcentrationUnit.text) store.put('Molweight', value=float(self.ids.Molweight.text), unit=self.ids.MolweightUnit.text) store.put('Voltage', value=float(self.ids.Voltage.text), unit=self.ids.VoltageUnit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return # Add data capillary_manager = capillarymanager.CapillaryManager() # set default data to capillary errcode, errtext = capillary_manager.save_injection_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = InjectionPopup() self._popup.show_popup(data)
def del_line(self, buttoninstance): """ delete a line of timecompound (do nothing if there is only one timecompound line) @param buttoninstance: the instance of the button (not used) """ try: widgets = self.timecompoundlist.pop() except IndexError: return for w in widgets: self.ids.inlayout.remove_widget(w) #del the line in the jsonfile store = get_store() lastval = store.get('Nbtimecompound')["value"] store.delete('Timecompound'+str(lastval)) store.put('Nbtimecompound', value=lastval-1) self.ids.inlayout.rows = 5 + store.get('Nbtimecompound')["value"] #force the good size self.ids.tscrollview.change_child_height(self.ids.tscrollview.height)
def register(email, password, name_first, name_last): ''' Registers a new user Input: Email, password, first name, last name Returns: Dictionary of User ID and a current session token ''' store = get_store() # Error Checking # Generate a u_id u_id = 1 # Generate a token token = encryption_helper.generate_token() store.add_user(u_id, email, password, name_first, name_last, token) return {'u_id': u_id, 'token': token}
def show_popup(self, data): """ get and show Mobility results from the store. """ store = get_store() self.ids.inlayout.rows = 1 + store.get('Nbtimecompound')["value"] #the first µEOF self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("µEOF :","FFFFFF"))) value = "{:.2E}".format(store.get('MicroEOF')["value"]) value = value+" "+store.get('MicroEOF')["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(value,"FFFFFF"))) #add all the µEP for i in range(1, store.get('Nbtimecompound')["value"]+1): if i%2 != 0: color = "BFBFBF" else: color = "FFFFFF" self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color("µEP"+str(i)+" :", color))) value = "{:.2E}".format(store.get('MicroEP'+str(i))["value"]) value = value +" "+store.get('MicroEP'+str(i))["unit"] self.ids.inlayout.add_widget(CEToolBoxLabel(text=add_color(value,color))) #open the popup self.open()
def on_pre_enter(self): '''Special function lauch at the clic of the button to go on the MobilityScreen this value comes from the json file where we keep it ''' store = get_store() self.ids.Capillary.text = str(store.get('Capillary')["value"]) self.ids.CapillaryUnit.text = store.get('Capillary')["unit"] self.ids.Towindow.text = str(store.get('Towindow')["value"]) self.ids.TowindowUnit.text = store.get('Towindow')["unit"] self.ids.Voltage.text = str(store.get('Voltage')["value"]) self.ids.VoltageUnit.text = store.get('Voltage')["unit"] self.ids.Electroosmosis.text = str(store.get('Electroosmosis')["value"]) self.ids.ElectroosmosisUnit.text = store.get('Electroosmosis')["unit"] self.ids.Timecompound1.text = str(store.get('Timecompound1')["value"]) self.ids.Timecompound1Unit.text = store.get('Timecompound1')["unit"] #set the number of rows self.ids.inlayout.rows = 6 + store.get('Nbtimecompound')["value"] #force the good size self.ids.tscrollview.change_child_height(self.ids.tscrollview.height) #set the rest of the time compound self.timecompoundlist = [] for i in range(2, store.get('Nbtimecompound')["value"]+1): timecompount = CEToolBoxLabel(text="Time compound "+str(i)) timecompountvalue = CEToolBoxTextInput(text=str(store.get('Timecompound'+str(i))["value"]), id='Timecompound'+str(i)) timecompountunit = CEToolBoxSpinner(text=store.get('Timecompound'+str(i))["unit"], id='Timecompound'+str(i)+'Unit', values=["s", "min"]) self.ids.inlayout.add_widget(timecompount) self.ids.inlayout.add_widget(timecompountvalue) self.ids.inlayout.add_widget(timecompountunit) tosave = [timecompount, timecompountvalue, timecompountunit] self.timecompoundlist.append(tosave) #create the button add and del self.add_button = CEToolBoxButton(text="Add", id="addbutton", on_release=self.add_line) self.ids.inlayout.add_widget(self.add_button) self.del_button = CEToolBoxButton(text="Del", id="delbutton", on_release=self.del_line) self.ids.inlayout.add_widget(self.del_button)
def show_mobility_results(self): '''Launch when clicked on result Compute, store the computation and lauch a popup ''' store = get_store() try: store.put('Capillary', value=float(self.ids.Capillary.text), unit=self.ids.CapillaryUnit.text) store.put('Towindow', value=float(self.ids.Towindow.text), unit=self.ids.TowindowUnit.text) store.put('Voltage', value=float(self.ids.Voltage.text), unit=self.ids.VoltageUnit.text) store.put('Electroosmosis', value=float(self.ids.Electroosmosis.text), unit=self.ids.ElectroosmosisUnit.text) store.put('Timecompound1', value=float(self.ids.Timecompound1.text), unit=self.ids.Timecompound1Unit.text) except ValueError: data = {} data["errcode"] = 1 data["errtext"] = "Empty field not allowed" self._popup = ErrorPopup() self._popup.show_popup(data) return #save all the timecompound for sublist in self.timecompoundlist: store.put(sublist[1].id, value=float(sublist[1].text), unit=sublist[2].text) #get and save error and values capillary_manager = capillarymanager.CapillaryManager() errcode, errtext = capillary_manager.save_mobility_result() data = {} data["errcode"] = errcode data["errtext"] = errtext if data["errcode"] == 1: self._popup = ErrorPopup() else: self._popup = MobilityPopup() self._popup.show_popup(data)
def save_mobility_result(self): """ compute and save the result for the mobility result """ store = get_store() try : microeof = self.micro_eof() except ZeroDivisionError: if self.electro_osmosis_time == 0: return 1, "The EOF Time cannot be null" else: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("MicroEOF", value=microeof, unit="cm²/V/s") for i in range(1, store.get('Nbtimecompound')["value"]+1): keystore = "Timecompound"+str(i) time = TimeUnits.convert_unit(float(store.get(keystore)["value"]), store.get(keystore)["unit"], u"s") microep = self.micro_ep(time) store.put("MicroEP"+str(i), value=microep, unit="cm²/V/s") return 0, ""
def save_flow_result(self): """ compute and save the result for the flow screen """ store = get_store() try: strengh = self.field_strength() microeof = self.micro_eof() lpermin = self.length_per_minute() flowrate = self.flow_rate_flow() except ZeroDivisionError: if self.total_length == 0: return 1, "The capillary length cannot be null" elif self.electro_osmosis_time: return 1, "The EOF Time cannot be null" else: return 1, "The voltage cannot be null" if self.to_window_length > self.total_length: return 1, "The length to window cannot be greater than the capillary length" #saving store.put("Fieldstrength", value=strengh, unit="V/cm") store.put("MicroEOF", value=microeof, unit="cm²/V/s") store.put("Lengthpermin", value=LengthUnits.convert_unit(lpermin, u'm', u'cm'), unit="cm") store.put("Flowrate", value=flowrate, unit="nL/min") return 0, ""