示例#1
0
def main():
   capValues = extractValues.capacitorValues()
   newCapValues = extractValues.getComponentCombinations(capValues, 2, extractValues.cSeries, 'C Series')
   
   rValues = extractValues.resistorValues()
   newRValues = extractValues.getComponentCombinations(rValues, 2, extractValues.rSeries, 'R Series')
   
   TOLERANCE = 0.00000000001
   
   target = 1020
   
   print('*** findBestPairs TEST ***')
   
   bestPairs = findBestPairs(capValues, rValues, multiply, TOLERANCE, target)
   for bestPair in bestPairs:
      res = bestPair
      capValue = res[0]
      rValue = res[1]
      result = res[2]
      tolerance = res[3]
      print('C: ', capValue, ' R: ', rValue, ' res: ', result, ' target: ', target, ' tolerance: ', tolerance)  

   print('*** USING PERMUTATIONS ***')
   
   bestPairs = findBestPairs(newCapValues, newRValues, multiply, TOLERANCE, target)
   for bestPair in bestPairs:
      res = bestPair
      capValue = res[0]
      rValue = res[1]
      result = res[2]
      tolerance = res[3]
      print('C: ', capValue, ' R: ', rValue, ' res: ', result, ' target: ', target, ' tolerance: ', tolerance)  
示例#2
0
def main():
    capValues = extractValues.capacitorValues()
    newCapValues = extractValues.getComponentCombinations(capValues, 2, extractValues.cSeries, "C Series")

    rValues = extractValues.resistorValues()
    newRValues = extractValues.getComponentCombinations(rValues, 2, extractValues.rSeries, "R Series")

    TOLERANCE = 0.00000000001

    target = 1020

    print("*** findBestPairs TEST ***")

    bestPairs = findBestPairs(capValues, rValues, multiply, TOLERANCE, target)
    for bestPair in bestPairs:
        res = bestPair
        capValue = res[0]
        rValue = res[1]
        result = res[2]
        tolerance = res[3]
        print("C: ", capValue, " R: ", rValue, " res: ", result, " target: ", target, " tolerance: ", tolerance)

    print("*** USING PERMUTATIONS ***")

    bestPairs = findBestPairs(newCapValues, newRValues, multiply, TOLERANCE, target)
    for bestPair in bestPairs:
        res = bestPair
        capValue = res[0]
        rValue = res[1]
        result = res[2]
        tolerance = res[3]
        print("C: ", capValue, " R: ", rValue, " res: ", result, " target: ", target, " tolerance: ", tolerance)
示例#3
0
def main():

    rValues = extractValues.resistorValues()
    seriesR = extractValues.getComponentCombinations(rValues, 1, extractValues.rSeries, "R Series")
    for r in seriesR:
        print(r)

    print(binarySearch(list(range(0, 19)), 10))

    print(binarySearch(seriesR, 68001.0))
    return
def setup_routine():
   test_file = 'EE347_parts.txt'
   rValues   = extractValues.resistorValues(test_file)
   
   configuration = 'parallel'
   length = 2
   operation = extractValues.rParallel
   key = 'resistor' + '-' + configuration + '-' + str(length) + '[' + test_file + ']'

   permuted_components[key] = \
   extractValues.getComponentCombinations(rValues, length, operation, '||', componentType = 'resistor')
      
   update_component_list_box()
   return  
    def permute(*args):
        component_choice = component_choice_var.get()
        configuration = configuration_choice_var.get()
        length = permutation_length_var.get()
        key = component_choice + "-" + configuration + "-" + length

        length = int(length)

        print(key)

        file_name = get_file_name_from_file_frame()
        operation = None

        # seriesCaps = extractValues.getComponentCombinations(capValues, 2, extractValues.cSeries, 'C Series')
        # parallelCaps =  extractValues.getComponentCombinations(capValues, 2, extractValues.cParallel, 'C Parallel')

        if component_choice == "capacitor":
            # load all the single capValues and resValues from file
            capValues = extractValues.capacitorValues(file_name)

            if configuration == "series":
                operation = extractValues.cSeries

            elif configuration == "parallel":
                operation = extractValues.cParallel

            permuted_components[key] = extractValues.getComponentCombinations(
                capValues, length, operation, "capacitor " + configuration
            )

        elif component_choice == "resistor":
            # load all the single capValues and resValues from file
            rValues = extractValues.resistorValues(file_name)

            if configuration == "series":
                operation = extractValues.rSeries

            elif configuration == "parallel":
                operation = extractValues.rParallel

            permuted_components[key] = extractValues.getComponentCombinations(
                rValues, length, operation, "resistor " + configuration
            )

        # refresh the component_search list_box
        text = get_list_of_keys_from_dict(permuted_components)
        text = tuple(text)
        component_list_box_var.set(text)
        return
   def permute():
   
      component_choice = component_choice_var.get()
      
      configuration = configuration_choice_var.get()
      
      length    = int(permutation_length_var.get())
       
      error_msg = ''
      
      read_source_success = False 
      
      source = ''
      
      source_components = []
      
      operation = None
       
      try:       
         #try getting source components from the file list box
         file_name = get_file_name_from_file_frame()
          
         source = file_name
                           
         if component_choice == 'capacitor':
            #load all the single capValues and resValues from file
            source_components = extractValues.capacitorValues(source)   
         
         elif component_choice == 'resistor':
         
            source_components = extractValues.resistorValues(source)
                 
         read_source_success = True
       
      except Exception as e:     
        
         #Couldn't retrieve a file from the list box   
         print(e)    
         
         error_msg += str(e)
         
         #no success so try to read source components from the 
         #component list box
         read_source_success = False
       
      if not read_source_success:
         try:
            #try sourcing the components from the component list box
            #instead of the file list box
            
            key = get_key_from_component_list_box()   
               
            source = key
            
            source_components = permuted_components[key]
            
            read_source_success = True
            
         except Exception as e: 
         
            error_msg += '\n' + str(e)
            
            read_source_success = False
      
      if not read_source_success:
      
         status_label_var.set(error_msg)
         return 
      
      if component_choice == 'capacitor':
      
         if configuration == 'series':
         
            operation = component.cSeries
             
         elif configuration == 'parallel':
         
            operation = component.cParallel
                       
      elif component_choice == 'resistor':
      
         if configuration == 'series':
         
            operation = component.rSeries
             
         elif configuration == 'parallel':
         
            operation = component.rParallel
      
      label = ''
      
      if configuration == 'series':
         
         label = ' + '
      
      elif configuration == 'parallel':
      
         label = ' || '
         
      key = component_choice + '-' + configuration + '-' + str(length) + '[' + source + ']'
 
      if length == 1:
      
         key = component_choice + '-single-'  + '[' + source + ']'
     
      progress_frame.show()
      
      progress_frame.setText('Permuting... with ' + str(key))
      
      pb = progress_frame.getProgressBar()
      
      pb.start()
      
      #run this in background:
      #permuted_components[key] = \
      #extractValues.getComponentCombinations(source_components, length, operation, label)
      #print_permuted_components_with_key(permuted_components, key)
      
      out_queue = mp.Queue()    

      func = extractValues.getComponentCombinations
      
      start_background(root, out_queue, func, componentList = source_components, \
      numComponentsInGroup = length, op = operation, operationName = label,\
      componentType = component_choice)
         
      # Start a function to check a queue for GUI-related updates
      # When the background process is done, it will call permute_finisher
      finsher_func = permute_finisher
      
      #snag the old key
      old_key = source
      
      #call updater which will use root.after
      updater(root, out_queue, finsher_func, key, old_key)
      return