def insertSupport(self): position = self.positionContent.get() selectedType = self.typeContent.get() supportAsset = None supportInstance = None tipX : float = self.master_force.x if position == 0 else self.beamEnd.x tipY : float = self.master_force.y if position == 0 else self.beamEnd.y if selectedType == 0: angle = float(self.angleContent.get()) if len(self.angleContent.get()) != 0 else 0 supportInstance = Support("SIMPLE", angle) supportAsset = ImageTk.PhotoImage(Image.open("assets/simple.png").rotate(angle)) elif selectedType == 1: supportInstance = Support("PINNED") supportAsset = PhotoImage(file = "assets/pinned.png") elif selectedType == 2: supportInstance = Support("FIXED") supportAsset = supportAsset = PhotoImage(file = "assets/fixed.png") if position == 0: self.master_window.system.beams[self.beamID - 1][0].start = (supportInstance, self.master_window.system.beams[self.beamID - 1][0].start[1]) else: self.master_window.system.beams[self.beamID - 1][0].end = (supportInstance, self.master_window.system.beams[self.beamID - 1][0].end[1]) self.master_window.drawing_area.delete(self.master_window.forcePreview) support = self.master_window.drawing_area.create_image(tipX, tipY, image = supportAsset) self.master_window.actions.append(Action(related = (support, supportAsset, self.beamID, position), type = ActionType.ADD_SUPPORT)) self.master_window.inserting = False self.master.destroy()
def replyMessageAuth(): id = request.form['id'] reply = request.form['reply'] Support.replySupport(conn, id, reply) return redirect(url_for('admin'))
def support_check(self): if self.mid < self.dfD.iloc[-1]['Daily Pivot Point']: # print '**** Checking Support Pivots ****' support = Support(self.instrument, self.dfD, self.mid, self.units, self.pivot, self.rl1, self.rl2, self.rl3, self.sl1, self.sl2, self.sl3, self.rate1, self.rate2) units, stop_loss, profit = support.support() return units, stop_loss, profit
def sendMessageAuth(): email = request.form['email'] title = request.form['title'] message = request.form['message'] Support.addSupport(conn, email, title, message) return redirect(url_for('support'))
def sup_check(self): if self.mid < self.dfD.iloc[-1]['D Pivot Point']: print '**** Checking Support Pivots ****' try: sup = Support(self.instrument, self.mid, self.dfD, self.units, self.pivot, self.sl1, self.sl2, self.sl3, self.rate1, self.rate2) # print sup.support() supLoss = sup.support() loss = float(round(supLoss + .025, 3)) return loss except: pass
def sup_check(self): if self.mid < self.dfD.iloc[-1]['Daily Pivot Point']: print '**** Checking Support Pivots ****' sup = Support(self.instrument, self.mid, self.dfD, self.units, self.pivot, self.sl1, self.sl2, self.sl3, self.rate1, self.rate2) print sup.support() try: supUnits, supProfit, supLoss = sup.support() supex = Execute(self.api, self._id, self.instrument, supUnits, supProfit, supLoss) supex.trade() except Exception as e: print(e)
def createRandomForest(self, dataset: Dataset): support = Support(dataset) attributes = dataset.attributes classification = dataset.classification possibleAttributeValues = dataset.unique_values for i in range(self.bootstraps): bootstrap = support.bootstrap() data = Dataset(attributes, classification, bootstrap[:, :-1], bootstrap[:, -1], possibleAttributeValues, dataset.quantitative) self.randomForest.append(DecisionTree(dataset.unique_values, dataset.quantitative, None, True).createDecisionTree(dataset))
def random_employee(employee_type): if employee_type == 'developer': return Developer(**Developer.random_attrs()) if employee_type == 'sales': return Sales(**Sales.random_attrs()) if employee_type == 'project_manager': return ProjectManager(**ProjectManager.random_attrs()) if employee_type == 'support': return Support(**Support.random_attrs()) err_msg = ( '{} employee type is not supported.\n'.format(type), 'Allowed values are: \'developer\', \'project_manager\', \'sales\' or \'support\'', ) raise ValueError(err_msg)
def mail_or_calendar(self): mail.check_if_authenticated() self.choice = input('进入邮箱还是日历?(E/C) 您也可以向我们反馈。(S)或进入设置(O)') if self.choice == 'E': self.choice = input('读邮件(R)还是写邮件(W)?') if self.choice == 'R': mail.read_email() self.choice = input('要读正文吗?(Y/N)') if self.choice == 'Y': print('\n') mail.get_body() os.system('pause') else: os.system('pause') elif self.choice == 'W': mail.get_full_mail_info() mail.send_email() else: Start().mail_or_calendar() elif self.choice == 'C': calendar.load_events() calendar.clear_event() os.system("pause") elif self.choice == 'S': Support().support() elif self.choice == 'O': sets.choose_set() else: Start().mail_or_calendar() os.system("pause")
def start(self): self.state['m'] = Support() self.state['created'] = False self.state['invalid_model_id'] = False self.state['invalid_target_id'] = False self.state['receptacle_full'] = False self.state['have_splitter'] = False self.state['splitter_receptacle_ids'] = [] self.state['examine_count'] = 0
def start(self): self.delay(50) self.state['model'] = Support(self.magic_page) output = self.state['model'].board_string() self.read(length=len(output), expect=output) prompt = self.state['model'].prompt_string() self.read(length=len(prompt), expect=prompt)
def get_supports(self, data): # создаём список с объектами опор temp_span = None for cur_support in data.supports_for_calc: for cur_span in self.spans: if end_flag(cur_support, data.end_supports_list): if int(cur_span.span_support1_number ) == cur_support or int( cur_span.span_support2_number) == cur_support: support = Support(cur_support, cur_span) self.supports.append(support) break else: if int(cur_span.span_support2_number) == cur_support: temp_span = cur_span continue elif int(cur_span.span_support1_number) == cur_support: support = Support(cur_support, temp_span, cur_span) self.supports.append(support) break
def __init__(self, name, tstr_min=0.1, tstr_max=2, buff_len=70, k=10, dt=0.001, g=1, Nt=2000): self.name = name self.support = Support(tstr_min, tstr_max, buff_len, k, dt, g, Nt) self.value = np.zeros(Nt)
def __init__(self, Name, Parent=None, Description=""): daeModel.__init__(self, Name, Parent, Description) self.F = Compartment("Feed", self) self.M = Membrane("Membrane", self) self.S = Support("Support", self) self.P = Compartment("Permeate", self) self.Nc = daeDomain("Nc", self, unit(), "Number of components") self.z = daeDomain("z", self, unit(), "Axial domain") self.Tref = daeParameter("T_ref", K, self, "") self.Pref = daeParameter("P_ref", Pa, self, "") self.Tfeed = daeParameter("T_feed", K, self, "Feed temperature") self.Purity_feed = daeVariable("Purity_feed", fraction_t, self, "", [self.Nc]) self.Purity_permeate = daeVariable("Purity_permeate", fraction_t, self, "", [self.Nc]) self.Recovery_feed = daeVariable("Recovery_feed", recovery_t, self, "", [self.Nc]) self.Selectivity = daeVariable("Selectivity", selectivity_t, self, "", [self.Nc, self.Nc, self.z]) self.Phigh = daeVariable("P_high", pressure_t, self, "", []) self.Plow = daeVariable("P_low", pressure_t, self, "", []) self.MembraneArea = daeVariable("MembraneArea", area_t, self, "", []) self.MembraneThickness = daeVariable("MembraneThickness", length_t, self, "", []) self.SupportThickness = daeVariable("SupportThickness", length_t, self, "", []) self.Qfeed_stp = daeVariable("Qfeed_stp", volume_flowrate_t, self, "", []) self.Qsweep_stp = daeVariable("Qsweep_stp", volume_flowrate_t, self, "", [])
def on_created(self, event): regex = r"(.tif)|(.jp2)" # TODO parametrizar matches = re.finditer(regex, event.src_path) images_path = '' inotify = INotify() print("listening to " + event.src_path) for match in matches: print("match found") images_path = os.path.dirname(event.src_path) + '/' img = os.path.basename(event.src_path) watch_flags = flags.CLOSE_WRITE wd = inotify.add_watch(images_path, watch_flags) # noqa inotify.read( ) # bloquea el resto de los procesos hasta que se cierre la escritura del archivo que se está copiando print('copied: ' + img) red_exists = os.path.isfile(images_path + 'red_665_10.jp2') nir_exists = os.path.isfile(images_path + 'nir4_832_10.jp2') if red_exists and nir_exists: ni = NormalizedDifferenceIndex(images_path, 'sentinel') print("starting ndvi calculation process...") ni.write_ndvi_image() support = Support() src_name = 'ndvi.tif' original_image = images_path + src_name reprojected_image = images_path + 'reprojected-' + src_name print("starting reprojection process...") support.reprojection('EPSG:4326', original_image, reprojected_image) print("starting cropping process...") support.crop_process(images_path, 'reprojected-' + src_name, images_path, '/graticules', "ISO8859-1") print("returning to detection process")
def start(self): self.state['m'] = Support() self.state['created'] = False self.state['invalid'] = False
def start(self): self.state['model'] = Support() self.state['uaf'] = False
def start(self): #self.delay(100) self.state['model'] = Support(self.magic_page)
def support(): email = session['account']['email'] oldMessages = Support.getMyMessages(conn, email) return render_template('support.html', oldMessages=oldMessages)
class MembraneUnit(daeModel): def __init__(self, Name, Parent=None, Description=""): daeModel.__init__(self, Name, Parent, Description) self.F = Compartment("Feed", self) self.M = Membrane("Membrane", self) self.S = Support("Support", self) self.P = Compartment("Permeate", self) self.Nc = daeDomain("Nc", self, unit(), "Number of components") self.z = daeDomain("z", self, unit(), "Axial domain") self.Tref = daeParameter("T_ref", K, self, "") self.Pref = daeParameter("P_ref", Pa, self, "") self.Tfeed = daeParameter("T_feed", K, self, "Feed temperature") self.Purity_feed = daeVariable("Purity_feed", fraction_t, self, "", [self.Nc]) self.Purity_permeate = daeVariable("Purity_permeate", fraction_t, self, "", [self.Nc]) self.Recovery_feed = daeVariable("Recovery_feed", recovery_t, self, "", [self.Nc]) self.Selectivity = daeVariable("Selectivity", selectivity_t, self, "", [self.Nc, self.Nc, self.z]) self.Phigh = daeVariable("P_high", pressure_t, self, "", []) self.Plow = daeVariable("P_low", pressure_t, self, "", []) self.MembraneArea = daeVariable("MembraneArea", area_t, self, "", []) self.MembraneThickness = daeVariable("MembraneThickness", length_t, self, "", []) self.SupportThickness = daeVariable("SupportThickness", length_t, self, "", []) self.Qfeed_stp = daeVariable("Qfeed_stp", volume_flowrate_t, self, "", []) self.Qsweep_stp = daeVariable("Qsweep_stp", volume_flowrate_t, self, "", []) def DeclareEquations(self): daeModel.DeclareEquations(self) eq = self.CreateEquation("Recovery_feed") i = eq.DistributeOnDomain(self.Nc, eClosedClosed, 'i') eq.Residual = self.Recovery_feed(i) * ( self.F.Cin(i) * self.F.Qin()) - self.F.Qout() * self.F.Cout(i) eq = self.CreateEquation("Purity_feed") i = eq.DistributeOnDomain(self.Nc, eClosedClosed, 'i') eq.Residual = self.Purity_feed(i) - self.F.Xout(i) eq = self.CreateEquation("Purity_permeate") i = eq.DistributeOnDomain(self.Nc, eClosedClosed, 'i') eq.Residual = self.Purity_permeate(i) - self.P.Xout(i) eq = self.CreateEquation("Selectivity") i = eq.DistributeOnDomain(self.Nc, eClosedClosed, 'i') j = eq.DistributeOnDomain(self.Nc, eClosedClosed, 'j') z = eq.DistributeOnDomain(self.z, eClosedClosed) eq.Residual = self.Selectivity(i, j, z) * (self.F.X(i, z) * self.P.X( j, z)) - (self.P.X(i, z) * self.F.X(j, z)) # Fluxes at the Feed-Membrane, Membrane-Support, # Support-Retentate compartments are equal eq = self.CreateEquation("Feed_Flux") i = eq.DistributeOnDomain(self.F.Nc, eClosedClosed, 'i') z = eq.DistributeOnDomain(self.F.z, eClosedClosed) eq.Residual = self.F.Flux(i, z) - self.M.Flux(i, z) eq = self.CreateEquation("Support_Flux") i = eq.DistributeOnDomain(self.F.Nc, eClosedClosed, 'i') z = eq.DistributeOnDomain(self.F.z, eClosedClosed) eq.Residual = self.S.Flux(i, z) - self.M.Flux(i, z) eq = self.CreateEquation("Permeate_Flux") i = eq.DistributeOnDomain(self.F.Nc, eClosedClosed, 'i') z = eq.DistributeOnDomain(self.F.z, eClosedClosed) eq.Residual = self.P.Flux(i, z) + self.S.Flux(i, z) # Gas mole fraction at the Feed-Membrane, and Membrane-Support, # Support-Retentate compartments eq = self.CreateEquation("Membrane_Xinlet") i = eq.DistributeOnDomain(self.F.Nc, eClosedClosed, 'i') z = eq.DistributeOnDomain(self.F.z, eClosedClosed) eq.Residual = self.F.X(i, z) - self.M.Xinlet(i, z) eq = self.CreateEquation("Support_Xinlet") i = eq.DistributeOnDomain(self.F.Nc, eClosedClosed, 'i') z = eq.DistributeOnDomain(self.F.z, eClosedClosed) eq.Residual = self.S.Xinlet(i, z) - self.M.Xoutlet(i, z) eq = self.CreateEquation("Permeate_X") i = eq.DistributeOnDomain(self.F.Nc, eClosedClosed, 'i') z = eq.DistributeOnDomain(self.F.z, eClosedClosed) eq.Residual = self.P.X(i, z) - self.S.Xoutlet(i, z) # Pressures at the Feed-Membrane, and Membrane-Support, # Support-Retentate compartments are equal eq = self.CreateEquation("Membrane_Pinlet") z = eq.DistributeOnDomain(self.F.z, eClosedClosed) eq.Residual = self.F.P(z) - self.M.Pinlet(z) eq = self.CreateEquation("Support_Pinlet") z = eq.DistributeOnDomain(self.S.z, eClosedClosed) eq.Residual = self.S.Pinlet(z) - self.M.Poutlet(z) eq = self.CreateEquation("Support_Poutlet") z = eq.DistributeOnDomain(self.P.z, eClosedClosed) eq.Residual = self.P.P(z) - self.S.Poutlet(z) # Temperatures at the Feed-Membrane, and Membrane-Support, # Support-Retentate compartments are equal eq = self.CreateEquation("Feed_T") eq.Residual = self.F.T() - self.Tfeed() eq = self.CreateEquation("Membrane_T") eq.Residual = self.M.T() - self.Tfeed() eq = self.CreateEquation("Support_S") eq.Residual = self.S.T() - self.Tfeed() eq = self.CreateEquation("Permeate_T") eq.Residual = self.P.T() - self.Tfeed()
def callSup(self, mainForm): suppForm = Support().showHelp(mainForm) suppForm.grab_set()
class Commander(object): Logger.log.debug("Instantiating {} class...".format(__qualname__)) set_level = 0 def __init__(self, logger): Logger.log.debug('{} initializing....'.format(__name__)) self.logger = logger self.config = Config(logger=self.logger) self.support = Support(config=self.config, logger=self.logger) self.gpio = Gpio(config=self.config, logger=self.logger) self.pollperm = Pollperm(logger=self.logger) self.decoder = Decoder(config=self.config, logger=self.logger, gpio=self.gpio) self.spi = SPI(config=self.config, logger=self.logger, decoder=self.decoder, pollperm=self.pollperm) self.codegen = Codegen(config=self.config, logger=self.logger, gpio=self.gpio, spi=self.spi) self.securitylevel = SecurityLevel(logger=self.logger) self.gui = Mainwindow(self, codegen=self.codegen, config=self.config, logger=self.logger, support=self.support, securitylevel=self.securitylevel) self.switches = Switches(config=self.config, logger=self.logger, spi=self.spi, gui=self.gui) self.currentsense = CurrentSense(logger=self.logger, spi=self.spi, decoder=self.decoder, gui=self.gui, config=self.config) self.pollvalues = Pollvalues(pollperm=self.pollperm, logger=logger, config=self.config, currentsense=self.currentsense, switches=self.switches, sense_callback=self.poll_sense_callback, switch_callback=self.poll_switch_callback) self.securitywindow = SecurityWindow(logger=self.logger, securitylevel=self.securitylevel) self.window = self.gui.window self.log = self.logger.log self.knob_values = 0 self.rotary_0_pins = None self.rotary_1_pins = None self.rotary_2_pins = None self.rotary_3_pins = None self.rotary_0_pin_0_debounce = None self.rotary_0_pin_1_debounce = None self.rotary_1_pin_0_debounce = None self.rotary_1_pin_1_debounce = None self.rotary_2_pin_0_debounce = None self.rotary_2_pin_1_debounce = None self.rotary_3_pin_0_debounce = None self.rotary_3_pin_1_debounce = None self.gain0_val = 0 self.gain1_val = 0 self.gain_0_name = None self.gain_1_name = None self.gain_0_spi_channel = None self.gain_1_spi_channel = None self.gain_0_thresholds = None self.gain_1_thresholds = None self.GAIN_0_CS = None self.GAIN_1_CS = None self.speed0_val = 0 self.speed1_val = 0 self.speed_0_name = None self.speed_1_name = None self.speed_0_shape = None self.speed_1_shape = None self.speed_0_spi_channel = None self.speed_1_spi_channel = None self.speed_0_thresholds = None self.speed_1_thresholds = None self.screen_brightness_max = None self.screen_brightness_min = None self.display_brightness = None self.spi_log_pause = False self.SPEED_0_CS = None # 6 # SPEED SIMULATION TACH 1 self.SPEED_1_CS = None # 7 # SPEED SIMULATION TACH 2 self.load_from_config() self.adc_scale = None self.sense_amp_max_amps = None self.sense_ad_vin = None # LM4128CQ1MF3.3/NOPB voltage reference self.sense_ad_max_bits = 0 # AD7940 ADC self.sense_scaling_factor_mv_amp = None # 110 milivolts per amp self.sense_ad_max_scaled_value = None self.speed0 = Speedgen( pollperm=self.pollperm, logger=self.logger, config=self.config, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.speed_0_name, shape=self.speed_0_shape, spi_channel=self.speed_0_spi_channel, chip_select=self.SPEED_0_CS, pin_0=self.rotary_0_pins[0], pin_1=self.rotary_0_pins[1], pin_0_debounce=self.rotary_0_pin_0_debounce, pin_1_debounce=self.rotary_0_pin_1_debounce, thresholds=self.speed_0_thresholds, callback=self.speed_callback, commander_speed_move_callback=self.speed_move_callback) self.speed1 = Speedgen( pollperm=self.pollperm, logger=self.logger, config=self.config, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.speed_1_name, shape=self.speed_1_shape, spi_channel=self.speed_1_spi_channel, chip_select=self.SPEED_1_CS, pin_0=self.rotary_1_pins[0], pin_1=self.rotary_1_pins[1], pin_0_debounce=self.rotary_1_pin_0_debounce, pin_1_debounce=self.rotary_1_pin_1_debounce, thresholds=self.speed_1_thresholds, callback=self.speed_callback, commander_speed_move_callback=self.speed_move_callback) self.gain0 = Gains( pollperm=self.pollperm, config=self.config, logger=self.logger, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.gain_0_name, spi_channel=self.gain_0_spi_channel, chip_select=self.GAIN_0_CS, pin_0=self.rotary_2_pins[0], pin_1=self.rotary_2_pins[1], pin_0_debounce=self.rotary_2_pin_0_debounce, pin_1_debounce=self.rotary_2_pin_1_debounce, thresholds=self.gain_0_thresholds, callback=self.gains_callback, commander_gain_move_callback=self.gain_move_callback) self.gain1 = Gains( pollperm=self.pollperm, config=self.config, logger=self.logger, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.gain_1_name, spi_channel=self.gain_1_spi_channel, chip_select=self.GAIN_1_CS, pin_0=self.rotary_3_pins[0], pin_1=self.rotary_3_pins[1], pin_0_debounce=self.rotary_3_pin_0_debounce, pin_1_debounce=self.rotary_3_pin_1_debounce, thresholds=self.gain_1_thresholds, callback=self.gains_callback, commander_gain_move_callback=self.gain_move_callback) self.startup_processes() # **************************************************************************************************************** def startup_processes(self): self.load_from_config() self.exit_signalling() self.log_level_first_start() self.speed_get_values() self.gains_get_values() self.shape_get_values() self.poll_timer_setup() self.display_timer_setup() self.brightness_check() # QApplication.restoreOverrideCursor() # **************************************************************************************************************** def gains_lock(self, value): self.log.info("Gains Locked button received {}".format(value)) if value: Gains.gains_locked = True else: Gains.gains_locked = False # **************************************************************************************************************** def logging_callback(self, level): self.log.info("Logging callback") # **************************************************************************************************************** def parse_args(self, arguments): """ parses arguments sent from running the command line :param arguments: """ for currentArgument, currentValue in arguments: if currentArgument in ("-v", "--verbose"): print("enabling verbose mode") elif currentArgument in ("-h", "--help"): print("displaying help") elif currentArgument in ("-o", "--output"): print(("enabling special output mode (%s)") % (currentValue)) # ******************************************************************************* def gpio_manual_read_pin(self): pinstate = 0 gpio_pin = self.window.SPIN_gpio_manual_read_select.value() if gpio_pin <= 40: pinstate = self.gpio.gpio.read(gpio_pin) elif gpio_pin > 40: gpio_pin = gpio_pin - 41 pinstate = self.switch_values & gpio_pin if pinstate == 0: self.window.LBL_gpio_manual_read_value.setText("LOW") elif pinstate == 1: self.window.LBL_gpio_manual_read_value.setText("HIGH") # **************************************************************************************************************** def PB_spi_log_pause(self, value): self.spi_log_pause = value # ******************************************************************************* def gpio_manual_toggled(self, value): """grabs the gpio from the spin box control and sets it high or low based on button press. if pin is > 40 then these are the auxillary gpio located on the spi expander. currently the firs 4 pins are set as inputs and the last 4 are set as outputs. :param value: """ gpio_pin = self.window.SPIN_gpio_manual_select.value() if gpio_pin <= 40: try: if value: self.gpio.gpio.write(gpio_pin, True) self.log.info("Setting GPIO {} to ON ".format(gpio_pin)) self.window.PB_gpio_manual_toggle.setText("ON") elif not value: self.gpio.gpio.write(gpio_pin, False) self.log.info("Setting GPIO {} to OFF".format(gpio_pin)) self.window.PB_gpio_manual_toggle.setText("OFF") except Exception: self.log.info("GPIO ERROR") self.window.PB_gpio_manual_toggle.setText("ERR") elif gpio_pin >= 41: try: gpio_pin = gpio_pin - 41 if value: self.switches.spi_write_values(pinvalue=1**gpio_pin) self.log.info( "Setting EXTENDED GPIO {} to ON".format(gpio_pin)) ret = self.window.PB_gpio_manual_toggle.setText("ON") elif not value: self.switches.spi_write_values(pinvalue=0**gpio_pin) self.log.info( "Setting EXTENDED GPIO {} to OFF".format(gpio_pin)) ret = self.window.PB_gpio_manual_toggle.setText("OFF") except Exception: self.log.info("GPIO ERROR") self.window.PB_gpio_manual_toggle.setText("ERR") # *************************************************************************************** def manual_chip_select_toggled(self, value): cs = self.window.SPIN_chip_select.value() self.decoder.chip_select(cs) self.log.info("Setting manual CS PIN:{} to {}".format( cs, ("ON", "OFF")[value])) self.window.PB_chip_select_manual_toggle.setText(("ON", "OFF")[value]) if cs > 7: self.gpio.gpio.write(18, value) else: self.gpio.gpio.write(16, value) # ****************************************************************************** def exit_signalling(self): signal.signal(signal.SIGINT, self.exit_application) signal.signal(signal.SIGTERM, self.exit_application) self.log.debug("Setting up exit signaling...") # **************************************************************************************************************** def poll_timer_setup(self): self.poll_timer = QTimer() self.poll_timer.setObjectName("POLL_TIMER") self.poll_timer.timeout.connect(self.pollvalues.poll_read_values) self.poll_timer.start(self.config.poll_timer_interval) # **************************************************************************************************************** def display_timer_setup(self): self.display = QTimer() self.display.setObjectName("DISPLAY_TIMER") self.display.timeout.connect(self.display_timer_run) self.display.start(self.config.display_timer_interval) # **************************************************************************************************************** def poll_sense_callback( self, raw_analog_digital_value): # adc_average, display_amps, counts): analog_digital_volts, scaled_value = self.adc_process_values( raw_analog_digital_value) display_amps = (scaled_value * analog_digital_volts) display_amps = display_amps / 1000 adc_millivolts = analog_digital_volts * 1000 self.window.LBL_display_adc.setText("{:4.1f}".format(adc_millivolts)) self.window.LBL_display_amps.setText("{:2.3f}".format(display_amps)) self.window.LBL_loop_current.setText("{:2.3f}".format(display_amps)) self.window.LBL_display_adc_counts.setText( "{:5.0f}".format(raw_analog_digital_value)) self.log.debug('GUI received sense values...') self.log.debug("RAW A/D:{} Volts:{} Scaled:{} AMPS:{}".format( raw_analog_digital_value, analog_digital_volts, scaled_value, display_amps)) # ********************************************************************************************** def adc_process_values(self, raw_analog_digital_value): analog_digital_volts = self.sense_ad_vin * ( raw_analog_digital_value / self.sense_ad_max_scaled_value) scaled_value = (analog_digital_volts / self.sense_scaling_factor_mv_amp) self.log.debug( "Analog_Digital converter switches_value: {} Scaled Value({})". format(analog_digital_volts, scaled_value)) return analog_digital_volts, scaled_value # **************************************************************************************************************** def display_timer_run(self): self.display_update() self.gpio_manual_read_pin() # ************************************************************************************ # call back from switch_polling def poll_switch_callback(self, switches_value): self.log.debug( "onSwitchChangeValues :{:08b}".format(switches_value)) self.log.debug("knob values :{:08b}".format( self.knob_values)) self.switch_values = switches_value switches_value = (switches_value | self.knob_values) self.log.debug( "onSwitchChangeValues ORED:{:08b}".format(switches_value)) if switches_value & 0b00000001: self.window.switch3_green.setVisible(True) self.window.switch3_red.setVisible(False) self.window.QDIAL_primary_gain.setStyleSheet( 'background-color: rgb(255, 0, 0)') else: self.window.switch3_green.setVisible(False) self.window.switch3_red.setVisible(True) self.window.QDIAL_primary_gain.setStyleSheet( 'background-color: rgb(191, 191, 191)') if switches_value & 0b00000010: self.window.switch4_green.setVisible(True) self.window.switch4_red.setVisible(False) self.window.QDIAL_secondary_gain.setStyleSheet( 'background-color: rgb(255, 0, 0)') else: self.window.switch4_green.setVisible(False) self.window.switch4_red.setVisible(True) self.window.QDIAL_secondary_gain.setStyleSheet( 'background-color: rgb(191, 191, 191)') if switches_value & 0b00000100: self.window.switch5_green.setVisible(True) self.window.switch5_red.setVisible(False) self.window.QDIAL_speed_0.setStyleSheet( 'background-color: rgb(255, 0, 0)') else: self.window.switch5_green.setVisible(False) self.window.switch5_red.setVisible(True) self.window.QDIAL_speed_0.setStyleSheet( 'background-color: rgb(191, 191, 191)') if switches_value & 0b00001000: self.window.switch6_green.setVisible(True) self.window.switch6_red.setVisible(False) self.window.QDIAL_speed_1.setStyleSheet( 'background-color: rgb(255, 0, 0)') else: self.window.switch6_green.setVisible(False) self.window.switch6_red.setVisible(True) self.window.QDIAL_speed_1.setStyleSheet( 'background-color: rgb(191, 191, 191)') # if self.switches.primary_gain_pb_status == "ON": # self.window.LBL_primary_gain_pb_status.setText("ON") # self.digital_pots.gains_locked = False # self.window.LBL_frequency_selected.setText("SEC") # if self.switches.primary_gain_pb_status == "OFF": # self.window.LBL_primary_gain_pb_status.setText("OFF") # self.digital_pots.gains_locked = False # if self.switches.primary_gain_pb_status == "CODERATE": # self.window.LBL_primary_gain_pb_status.setText("CODERATE") # self.digital_pots.gains_locked = False # if self.switches.primary_gain_pb_status == "LOCKED": # self.window.LBL_primary_gain_pb_status.setText("LOCKED") # self.digital_pots.gains_locked = True # self.primary_gain_pb_status = "NONE" # # if self.switches.secondary_gain_pb_status == "ON": # self.window.LBL_secondary_gain_pb_status.setText("ON") # if self.switches.secondary_gain_pb_status == "OFF": # self.window.LBL_secondary_gain_pb_status.setText("OFF") # if self.switches.secondary_gain_pb_status == "CODERATE": # self.window.LBL_secondary_gain_pb_status.setText("CODERATE") # if self.switches.secondary_gain_pb_status == "LOCKED": # self.window.LBL_secondary_gain_pb_status.setText("LOCKED") # self.secondary_gain_pb_status = "NONE" # # # self.lcd_switches.display(switch_value) # self.thread_info() # **************************************************************************************************************** def speed_buttonstate_change(self, name, value): if name == "SPEED0": self.speed0.update_shape(shape=value) elif name == "SPEED1": self.speed1.update_shape(shape=value) # **************************************************************************************************************** def speed_callback(self, name, frequency): """ receives callback from the speed class to update screen :rtype: object """ self.log.debug( "Callback received from {} with switches_value of {}".format( name, frequency)) if name == "SPEED0": self.window.LBL_pri_tach_freq.setText("{:5.0f}".format(frequency)) if name == "SPEED1": self.window.LBL_sec_tach_freq.setText("{:5.0f}".format(frequency)) self.log.debug("updated GUI ") self.change_tab("SPEED") # **************************************************************************************************************** def change_tab(self, tab): tabvalue = self.securitylevel.get_index_from_name(tab) self.window.tabWidget.setCurrentIndex(tabvalue) # **************************************************************************************************************** def shape_get_values(self): shape0 = self.speed0.shape shape1 = self.speed1.shape self.shape_update_gui("SPEED0", shape0) self.shape_update_gui("SPEED1", shape1) # **************************************************************************************************************** def shape_update_gui(self, name, value): if name == "SPEED0": if value == self.config.FREQ_SHAPE_SINE: self.window.BUTTON_speed0_sine.setChecked(True) if value == self.config.FREQ_SHAPE_SQUARE: self.window.BUTTON_speed0_square.setChecked(True) if value == self.config.FREQ_SHAPE_TRIANGLE: self.window.BUTTON_speed0_triangle.setChecked(True) if name == "SPEED1": if value == self.config.FREQ_SHAPE_SINE: self.window.BUTTON_speed1_sine.setChecked(True) if value == self.config.FREQ_SHAPE_SQUARE: self.window.BUTTON_speed1_square.setChecked(True) if value == self.config.FREQ_SHAPE_TRIANGLE: self.window.BUTTON_speed1_triangle.setChecked(True) # **************************************************************************************************************** def gains_get_values(self): gain0 = self.gain0.wiper_total_percentage gain1 = self.gain1.wiper_total_percentage self.gains_gui_update("GAIN0", gain0) self.gains_gui_update("GAIN1", gain1) # **************************************************************************************************************** def speed_get_values(self): speed0 = self.speed0.speed_frequency speed1 = self.speed1.speed_frequency self.speed_gui_update("SPEED0", speed0) self.speed_gui_update("SPEED1", speed1) # **************************************************************************************************************** def gains_callback(self, name, gain): """ receives callback from the speed class to update screen :rtype: object """ self.log.debug( "Callback received from {} with switches_value of {}".format( name, gain)) self.gains_gui_update(name, gain) self.change_tab("CODERATE") # **************************************************************************************************************** def security_pressed(self): self.log.debug("Security presssed") self.securitywindow.window.show() # **************************************************************************************************************** def msgbtn(self, value): self.log.debug("In MSG Button:{}".format(value)) # **************************************************************************************************************** def SLIDER_duty_cycle_changed(self, value): self.codegen.coded_carrier_generate(duty_cycle=value) self.gui.window.LBL_duty_cycle.setText(str(value)) # **************************************************************************************************************** def gains_gui_update(self, name, gain): if name == "GAIN0": if Gains.gains_locked == True: self.gain1.set_value(self.gain0.value) self.window.LBL_primary_gain_percent.setText( "{0:.3%}".format(gain)) if name == "GAIN1": # if Gains.gains_locked == True: self.window.LBL_secondary_gain_percent.setText( "{0:.3%}".format(gain)) # **************************************************************************************************************** def speed_gui_update(self, name, frequency): if name == "SPEED0": self.window.LBL_pri_tach_freq.setText("{:5.0f}".format(frequency)) if name == "SPEED1": self.window.LBL_sec_tach_freq.setText("{:5.0f}".format(frequency)) self.log.debug("updated GUI ") # **************************************************************************************************************** def speed_move_callback(self, name, direction, speed_increment): """ when the physical speed dial is moved this callback is activated. it causes the screen simulated dial to move :param name: :param direction: :param speed_increment: """ self.log.debug("Callback from:{} Direction:{} Speed:{}".format( name, direction, speed_increment)) if name == "SPEED0": if direction == 1: self.speed0_val = self.speed0_val + 1 if direction == -1: self.speed0_val = self.speed0_val - 1 self.window.QDIAL_speed_0.setValue(self.speed0_val) if name == "SPEED1": if direction == 1: self.speed1_val = self.speed1_val + 1 if direction == -1: self.speed1_val = self.speed1_val - 1 self.window.QDIAL_speed_1.setValue(self.speed1_val) # **************************************************************************************************************** def gain_move_callback(self, name, direction, speed_increment): """ when the physical speed dial is moved this callback is activated. it causes the screen simulated dial to move :param name: :param direction: :param speed_increment: """ self.log.debug("Callback from:{} Direction:{} Speed:{}".format( name, direction, speed_increment)) if name == "GAIN0": if direction == 1: self.gain0_val = self.gain0_val + 1 if direction == -1: self.gain0_val = self.gain0_val - 1 self.window.QDIAL_primary_gain.setValue(self.gain0_val) if name == "GAIN1": if direction == 1: self.gain1_val = self.gain1_val + 1 if direction == -1: self.gain1_val = self.gain1_val - 1 self.window.QDIAL_secondary_gain.setValue(self.gain1_val) # **************************************************************************************************************** def speed_simulate(self, name, sim_pins): """ when the on screen dial is rotated, this routine is called to simulate the physical pot turning :param name: :param sim_pins: """ self.log.debug("Simulating:{} PINS:{}".format(name, sim_pins)) if name == "SPEED0": self.speed0.simulate(sim_pins) if name == "SPEED1": self.speed1.simulate(sim_pins) # **************************************************************************************************************** def gain_simulate(self, name, sim_pins): """ when the on screen dial is rotated, this routine is called to simulate the physical pot turning :param name: :param sim_pins: """ self.log.debug("Simulating:{} PINS:{}".format(name, sim_pins)) if name == "GAIN0": self.gain0.simulate(sim_pins) if name == "GAIN1": self.gain1.simulate(sim_pins) # **************************************************************************************************************** def log_level_PB_changed(self, value): self.log.debug("Log level PB pushed") Commander.set_level = Commander.set_level + 10 self.log_level_set(Commander.set_level) txt_level = self.log_level_to_text(Commander.set_level) self.log_level_update_gui(txt_level) if Commander.set_level == 50: Commander.set_level = 0 # **************************************************************************************************************** def log_level_set(self, setLevel): self.log.debug("Set log level:{}".format(setLevel)) txt_level = self.log_level_to_text(setLevel) self.log.setLevel(txt_level) self.log.debug("Setting LOG LEVEL:{}".format(txt_level)) # **************************************************************************************************************** def log_level_update_gui(self, value): self.log.debug("SLog level update gui:{}".format(value)) self.window.PB_log_level.setText(value) # **************************************************************************************************************** def log_level_get(self): level = self.log.getEffectiveLevel() Commander.set_level = level self.log.debug("Get log level:{}".format(level)) return level # **************************************************************************************************************** def log_level_first_start(self): self.log.debug("Log level first start:{}") level = self.log_level_get() txt_level = self.log_level_to_text(level) self.log_level_update_gui(txt_level) # **************************************************************************************************************** def log_level_to_text(self, value): txtlevel = None if value == 0: txtlevel = "NOTSET" elif value == 10: txtlevel = "DEBUG" elif value == 20: txtlevel = "INFO" elif value == 30: txtlevel = "WARNING" elif value == 40: txtlevel = "ERROR" elif value == 50: value = -10 txtlevel = "CRITICAL" self.log.debug("Convert Log level:{} to text:{}".format( value, txtlevel)) return txtlevel # ******************************************************************************************* def brightness_check(self): # check and set brightness of LCD brightness_value = self.support.brightness_query() if brightness_value is not None: self.support.brightness_set(brightness_value) self.window.SPIN_brightness.setValue(int(brightness_value)) # ******************************************************************************************* # CATCH BRIGHTNESS BUTTON CHANGE def brightness_changed(self, value): if value >= self.screen_brightness_max: value = self.screen_brightness_max if value <= self.screen_brightness_min: value = self.screen_brightness_min self.log.debug('GUI brightness changed to ' + str(value)) self.support.brightness_set(value) # ******************************************************************************************* def display_update(self): cpu_percentage_numeric = psutil.cpu_percent() cpu_percentage_string = 'CPU:{}'.format(psutil.getloadavg()) cpu_temperature_numeric = psutil.sensors_temperatures(fahrenheit=True) cpu_temperature_degree = cpu_temperature_numeric.get( "cpu-thermal")[0][1] boot_time = datetime.datetime.fromtimestamp( psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S") memory = psutil.virtual_memory() log = False if log: self.log.debug('LOCAL TIMER RUNNING...') self.log.debug("CPU %: {}".format(cpu_percentage_numeric)) self.log.debug("CPU LOAD AVG : {}".format(cpu_percentage_string)) self.log.debug( "CPU Temperature : {} def F".format(cpu_temperature_numeric)) self.log.debug("BootTime : {}".format(boot_time)) self.log.debug("Memory : {}".format(memory)) self.log.debug("THREADS RUNNING {0:d}".format( threading.active_count())) self.window.LBL_threads_value.setText(str(threading.active_count())) str1 = "" t_list = threading.enumerate() for ele in t_list: str1 += str(ele) + "\r\n" self.window.LBL_t_list.setText(str(str1)) self.window.LBL_cpu_percent_value.setText( "{:3.2f}".format(cpu_percentage_numeric)) self.window.LBL_cpu_temperature_value.setText( "{:3.2f}".format(cpu_temperature_degree)) self.window.LBL_boot_time_value.setText(boot_time) if not self.spi_log_pause: self.window.TE_spi_log.insertPlainText(str(self.spi.data)) # ******************************************************************************************* def load_from_config(self): self.rotary_0_pins = self.config.rotary_0_pins self.rotary_1_pins = self.config.rotary_1_pins self.rotary_2_pins = self.config.rotary_2_pins self.rotary_3_pins = self.config.rotary_3_pins self.rotary_0_pin_0_debounce = self.config.rotary_0_pin_0_debounce self.rotary_0_pin_1_debounce = self.config.rotary_0_pin_1_debounce self.rotary_1_pin_0_debounce = self.config.rotary_1_pin_0_debounce self.rotary_1_pin_1_debounce = self.config.rotary_1_pin_1_debounce self.rotary_2_pin_0_debounce = self.config.rotary_2_pin_0_debounce self.rotary_2_pin_1_debounce = self.config.rotary_2_pin_1_debounce self.rotary_3_pin_0_debounce = self.config.rotary_3_pin_0_debounce self.rotary_3_pin_1_debounce = self.config.rotary_3_pin_1_debounce self.gain_0_name = self.config.gain_0_name self.gain_1_name = self.config.gain_1_name self.gain_0_spi_channel = self.config.gain_0_spi_channel self.gain_1_spi_channel = self.config.gain_0_spi_channel self.gain_0_thresholds = self.config.gain_0_thresholds self.gain_1_thresholds = self.config.gain_1_thresholds self.GAIN_0_CS = self.config.GAIN_0_CS self.GAIN_1_CS = self.config.GAIN_1_CS self.speed_0_name = self.config.speed_0_name self.speed_1_name = self.config.speed_1_name self.speed_0_shape = self.config.speed_0_shape self.speed_1_shape = self.config.speed_1_shape self.speed_0_spi_channel = self.config.speed_0_spi_channel self.speed_1_spi_channel = self.config.speed_0_spi_channel self.SPEED_0_CS = self.config.SPEED_0_CS # 6 # SPEED SIMULATION TACH 1 self.SPEED_1_CS = self.config.SPEED_1_CS # 7 # SPEED SIMULATION TACH 2 self.speed_0_thresholds = self.config.SPEED_0_thresholds self.speed_1_thresholds = self.config.SPEED_1_thresholds self.display_timer_interval = self.config.display_timer_interval self.poll_timer_interval = self.config.poll_timer_interval self.screen_brightness_max = self.config.screen_brightness_max self.screen_brightness_min = self.config.screen_brightness_min self.display_brightness = self.config.display_brightness self.display_amps_template = self.config.display_amps_template self.loop_current_template = self.config.loop_current_template self.adc_counts_template = self.config.adc_counts_template self.adc_template = self.config.adc_template self.adc_scale = self.config.adc_scale self.sense_amp_max_amps = self.config.sense_amp_max_amps self.sense_ad_vin = self.config.sense_ad_vin self.sense_ad_max_bits = self.config.sense_ad_max_bits self.sense_scaling_factor_mv_amp = self.config.sense_scaling_factor_mv_amp self.sense_ad_max_scaled_value = 2**self.sense_ad_max_bits # ******************************************************************************************* def exit_application(self, signum, frame): self.log.debug("Received signal from signum: {} with frame:{}".format( signum, frame)) self.shutdown() # ******************************************************************************************* def shutdown(self): self.log.info( "***********************************************************************************************************" ) self.log.info( "***********************************************************************************************************" ) self.log.info( "***********************************************************************************************************" ) self.log.info( "***********************************************************************************************************" ) self.log.info( "***********************************************************************************************************" ) self.log.info("Starting shutdown") # self.gains.setval_and_store(0) try: self.poll_timer.stop() self.gain0.set_value(0) self.gain1.set_value(0) self.speed0.set_value(0) self.speed1.set_value(0) self.codegen.off() time.sleep(1) self.log.critical("Goodbye...") except Exception: self.log.critical("Error shutting down TCP server") try: self.server.server_close() except Exception: self.log.critical("Error shutting down TCP server") # self.log.info('Turning off screen saver forced on') # subprocess.call('xset dpms force off', shell=True) # self.log.shutdown() sys.exit(0)
def __init__(self, logger): Logger.log.debug('{} initializing....'.format(__name__)) self.logger = logger self.config = Config(logger=self.logger) self.support = Support(config=self.config, logger=self.logger) self.gpio = Gpio(config=self.config, logger=self.logger) self.pollperm = Pollperm(logger=self.logger) self.decoder = Decoder(config=self.config, logger=self.logger, gpio=self.gpio) self.spi = SPI(config=self.config, logger=self.logger, decoder=self.decoder, pollperm=self.pollperm) self.codegen = Codegen(config=self.config, logger=self.logger, gpio=self.gpio, spi=self.spi) self.securitylevel = SecurityLevel(logger=self.logger) self.gui = Mainwindow(self, codegen=self.codegen, config=self.config, logger=self.logger, support=self.support, securitylevel=self.securitylevel) self.switches = Switches(config=self.config, logger=self.logger, spi=self.spi, gui=self.gui) self.currentsense = CurrentSense(logger=self.logger, spi=self.spi, decoder=self.decoder, gui=self.gui, config=self.config) self.pollvalues = Pollvalues(pollperm=self.pollperm, logger=logger, config=self.config, currentsense=self.currentsense, switches=self.switches, sense_callback=self.poll_sense_callback, switch_callback=self.poll_switch_callback) self.securitywindow = SecurityWindow(logger=self.logger, securitylevel=self.securitylevel) self.window = self.gui.window self.log = self.logger.log self.knob_values = 0 self.rotary_0_pins = None self.rotary_1_pins = None self.rotary_2_pins = None self.rotary_3_pins = None self.rotary_0_pin_0_debounce = None self.rotary_0_pin_1_debounce = None self.rotary_1_pin_0_debounce = None self.rotary_1_pin_1_debounce = None self.rotary_2_pin_0_debounce = None self.rotary_2_pin_1_debounce = None self.rotary_3_pin_0_debounce = None self.rotary_3_pin_1_debounce = None self.gain0_val = 0 self.gain1_val = 0 self.gain_0_name = None self.gain_1_name = None self.gain_0_spi_channel = None self.gain_1_spi_channel = None self.gain_0_thresholds = None self.gain_1_thresholds = None self.GAIN_0_CS = None self.GAIN_1_CS = None self.speed0_val = 0 self.speed1_val = 0 self.speed_0_name = None self.speed_1_name = None self.speed_0_shape = None self.speed_1_shape = None self.speed_0_spi_channel = None self.speed_1_spi_channel = None self.speed_0_thresholds = None self.speed_1_thresholds = None self.screen_brightness_max = None self.screen_brightness_min = None self.display_brightness = None self.spi_log_pause = False self.SPEED_0_CS = None # 6 # SPEED SIMULATION TACH 1 self.SPEED_1_CS = None # 7 # SPEED SIMULATION TACH 2 self.load_from_config() self.adc_scale = None self.sense_amp_max_amps = None self.sense_ad_vin = None # LM4128CQ1MF3.3/NOPB voltage reference self.sense_ad_max_bits = 0 # AD7940 ADC self.sense_scaling_factor_mv_amp = None # 110 milivolts per amp self.sense_ad_max_scaled_value = None self.speed0 = Speedgen( pollperm=self.pollperm, logger=self.logger, config=self.config, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.speed_0_name, shape=self.speed_0_shape, spi_channel=self.speed_0_spi_channel, chip_select=self.SPEED_0_CS, pin_0=self.rotary_0_pins[0], pin_1=self.rotary_0_pins[1], pin_0_debounce=self.rotary_0_pin_0_debounce, pin_1_debounce=self.rotary_0_pin_1_debounce, thresholds=self.speed_0_thresholds, callback=self.speed_callback, commander_speed_move_callback=self.speed_move_callback) self.speed1 = Speedgen( pollperm=self.pollperm, logger=self.logger, config=self.config, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.speed_1_name, shape=self.speed_1_shape, spi_channel=self.speed_1_spi_channel, chip_select=self.SPEED_1_CS, pin_0=self.rotary_1_pins[0], pin_1=self.rotary_1_pins[1], pin_0_debounce=self.rotary_1_pin_0_debounce, pin_1_debounce=self.rotary_1_pin_1_debounce, thresholds=self.speed_1_thresholds, callback=self.speed_callback, commander_speed_move_callback=self.speed_move_callback) self.gain0 = Gains( pollperm=self.pollperm, config=self.config, logger=self.logger, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.gain_0_name, spi_channel=self.gain_0_spi_channel, chip_select=self.GAIN_0_CS, pin_0=self.rotary_2_pins[0], pin_1=self.rotary_2_pins[1], pin_0_debounce=self.rotary_2_pin_0_debounce, pin_1_debounce=self.rotary_2_pin_1_debounce, thresholds=self.gain_0_thresholds, callback=self.gains_callback, commander_gain_move_callback=self.gain_move_callback) self.gain1 = Gains( pollperm=self.pollperm, config=self.config, logger=self.logger, decoder=self.decoder, spi=self.spi, gpio=self.gpio, name=self.gain_1_name, spi_channel=self.gain_1_spi_channel, chip_select=self.GAIN_1_CS, pin_0=self.rotary_3_pins[0], pin_1=self.rotary_3_pins[1], pin_0_debounce=self.rotary_3_pin_0_debounce, pin_1_debounce=self.rotary_3_pin_1_debounce, thresholds=self.gain_1_thresholds, callback=self.gains_callback, commander_gain_move_callback=self.gain_move_callback) self.startup_processes()
from beam import Beam from load import Load from support import Support import matplotlib.pyplot as plt #Init array of supports and loads supports = [] loads = [] #This is where you add supports For supports, there are two #parameters. The first is type. It can be either "fixed" or "roller" #Note: that the only possible configurations are one fixed support, or two roller supports. #Other configurations are not solvable. supports.append(Support("fixed", 5)) #This is where you add loads. For loads there are 3 parameters. The first is type. #it can be either "point", "distributed", or "triangle". The next is the location along the beam. #For distributed loads, you enter in a length 2 array where the first value is the start location #and the second value is the end locaiton. The third parameter is the load. The load does need to be #signed. For unevenly distributed loads, you have to enter in a length 2 array where the first value #is the starting force and the second value is the ending force. loads.append(Load("point", 3, -5)) #loads.append(Load("distributed", [0,2],-1)) loads.append(Load("triangle", [0, 3], [-2, -6])) #Checks to see if there are any uneven loads that need to be split for load in loads: if (load.need_to_split()): loads.append(load.split()) #Initialize the beam #Parameters are length, support array, loads array beam = Beam(5, supports, loads)
def start(self): self.state['model'] = Support()
def admin(): applications = Skill.getPendingApplications(conn) messages = Support.getNewSupport(conn) return render_template('admin.html', applications=applications, messages=messages)
def run_game(): #初始化 pygame.init() #设置类的对象 my_settings = Setting() screen = pygame.display.set_mode( (my_settings.screen_width, my_settings.screen_height)) pygame.display.set_caption("the first of my game") #对象的创建 play_button = Button('play', screen) #按钮 pause_btn = PauseBtn(screen) ship = Ship(my_settings, screen) aliens = Group() bullets = Group() stats = GameStats(my_settings) sb = ScoreBoard(screen, my_settings, stats) bg = pygame.image.load("./image/back4.png") sp = StartPage(screen) start_bg = pygame.image.load("./image/back4.png") title = Title("Maybe Our Game", screen) end_title = Title("HAAAAAAA YOU LOSE", screen) score_display = Title("YOUR SCORE:", screen) support = Support(screen, my_settings) # bgm 的创建 pygame.mixer.init() bg_sound = pygame.mixer.Sound('./music/开头.mp3') bg_sound.play() gf.create_fleet(screen, my_settings, aliens, ship) SUPPLY_TIME = pygame.USEREVENT pygame.time.set_timer(SUPPLY_TIME, 30 * 1000) while True: if stats.game_first_page: gf.check_events(ship, my_settings, screen, bullets, stats, play_button, aliens, sb, bg_sound, pause_btn, sp, SUPPLY_TIME, support) gf.first_page_show(screen, sp, start_bg, title) else: gf.check_events(ship, my_settings, screen, bullets, stats, play_button, aliens, sb, bg_sound, pause_btn, sp, SUPPLY_TIME, support) if stats.game_active and not stats.game_paused: ship.update() gf.update_aliens( aliens, my_settings, ship, stats, bullets, screen, sb, ) gf.bullet_update(bullets, aliens, screen, my_settings, ship, stats, sb) gf.support_upate(support, my_settings, ship, stats) gf.screen_update(screen, my_settings, ship, bullets, aliens, stats, play_button, sb, bg, pause_btn, end_title, support, score_display)
def start(self): self.state['m'] = Support() self.state['invalid'] = False self.state['no_sol'] = False
from encoding import WsiEncoding from utils import write_xml from argconfigparser import ArgumentConfigParser from utils import is_valid_file # parse arguments parser = ArgumentConfigParser('./fsorparameters.yml', description='FSOR') parser.add_argument("-i", '--query_encoding_path', dest="query_encoding_path", required=True, help="query_encoding_path", metavar="FILE_PATH", type=lambda x: is_valid_file(parser, x)) config = parser.parse_args() pprint(f'CONFIG: \n{config}') # create support support = Support(datasource=config['datasource'], model_path=config['model_path'], labels=config['labels']) # get prototype, threshold and anchors prototype, threshold, anchors = support.prototype() # load wsi encoding wsienc = WsiEncoding(None) wsienc.load(config['query_encoding_path']) # get encoding coordinates enckeys = wsienc._encoding['vectors'].keys() encvectorkeys = [e for e in wsienc._encoding['vectors'].keys()] # get valid anchors valid_anchor_indexes = [] for idx, enckey in enumerate(wsienc._encoding['vectors'].keys()):