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 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, ""
def test_convert_millimeter_to_centimeter(self): value = LengthUnits.convert_unit(10, 'mm', 'cm') self.assertEqual(value, 1)
def test_convert_meter_to_meter(self): value = LengthUnits.convert_unit(10, 'm', 'm') self.assertEqual(value, 10)