Show
Ignore:
Timestamp:
06/18/07 15:41:49 (6 years ago)
Author:
DrewCormier
Message:

reformatted some stuff

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • experimental/AWG/trunk/AWG/sources.py

    r3592 r4193  
    66class sources: 
    77    def __init__(self): 
    8         pass 
     8        self.available_sources = ['file', 'sine', 'cosine', 'random', 'zeros'] 
     9        self.corresponding_methods = ['read_file','gen_sine', 'gen_cosine', 'gen_random_data', 'gen_zeros'] 
     10 
    911 
    1012    def get_sources_list(self): 
    11         #TODO: setupt __init__ in AWG Frame so that 'file' can be first 
    12         return ['file','sine', 'cosine', 'random', 'zeros'] 
     13        return self.available_sources 
     14 
     15 
     16    def read_file(self, file_name, delimiter): 
     17 
     18        try: 
     19            my_file = open(file_name, 'r') 
     20        except IOError: 
     21            print "no file named " + file_name 
     22            return []  #return an empty packet 
     23 
     24        data_from_file = my_file.read()   #read the file as a big string 
     25        my_file.close()   #done reading the file.  process the string from now on 
     26 
     27        data_from_file.strip('\n')  #\n's will not be tollerated 
     28        data_from_file.strip('[')   #['s will not be tollerated 
     29        data_from_file.strip(']')   #]'s will not be tollerated 
     30 
     31        data_from_file = data_from_file.split(delimiter)  #break string into a list 
     32 
     33        return data_from_file 
     34 
    1335 
    1436    def gen_sine(self, freq, len): 
     
    3557        return cosine 
    3658 
    37     def read_file(self, file_name, delimiter): 
    3859 
    39         try: 
    40             my_file = open(file_name, 'r') 
    41         except IOError: 
    42             print "no file named " + file_name 
    43             return []  #return an empty packet 
    44  
    45         data_from_file = my_file.read()   #read the file as a big string 
    46         my_file.close()   #done reading the file.  process the string from now on 
    47  
    48         data_from_file.strip('\n')  #\n's will not be tollerated 
    49         data_from_file.strip('[')   #['s will not be tollerated 
    50         data_from_file.strip(']')   #]'s will not be tollerated 
    51  
    52         data_from_file = data_from_file.split(delimiter)  #break string into a list 
    53  
    54         return data_from_file 
    5560 
    5661    def gen_random_data(self, len, rand_type):