def generate_sim_records(records, sim_record_name, dis_record_name):      
    sim_prefix = sim_record_name + ':'
    
    grouper = Grouper()
    groups = grouper.group_records(records)
    
    output = ""

    for g in groups.keys():
        sim_record_name = get_sim_name(groups[g].main)
        
        #Check sim record does not already exist - maybe someone started writing the records but got bored!
        if sim_record_name in records:
            continue
            
        #Skip record if it is a simulation record 
        if groups[g].main.startswith(sim_prefix):
            continue
            
        #Skip adding sim record if the original is a soft record
        if records[groups[g].main].dtyp is None or records[groups[g].main].dtyp.lower() == "soft channel":
            continue

        #No point simulating SIM or DISABLE
        if groups[g].RB != sim_record_name and groups[g].RB != dis_record_name:
            typ = records[groups[g].main].type
            #Don't add simulation record unless the type is suitable
            if typ in ALLOWED_SIM_TYPES:            
                print "ADDED SIM RECORD =", sim_record_name
                output += generate_record_text(records[groups[g].main], groups[g].RB, groups[g].SP, groups[g].SP_RBV)
                
    return output
 def check(self):
     print "\n** CHECKING", self.file, "**"
     records = parse_db(self.file)
     grouper = Grouper()
     
     #Check for consistancy in whether PV macros are followed by colons
     colon = None
     for r in records.keys():
         if colon is None:
             n = self.remove_macro(r, False)
             colon = n.startswith(':')
         else:
             n = self.remove_macro(r, False)
             if n.startswith(':') != colon:
                 if colon:
                     self.errors.append("FORMAT ERROR: " + r + " should have a colon after the macro")
                 else:
                     self.errors.append("FORMAT ERROR: " + r + " should not have a colon after the macro")
     
     groups = grouper.group_records(records)
     
     if self.debug:
         for s in groups.keys():
             print s, groups[s].RB, groups[s].SP, groups[s].SP_RBV
     
     for s in groups.keys():
         self.check_case(groups[s])
         self.check_chars(groups[s])
         self.check_candidates(groups[s], records)
             
     for w in self.warnings:
         print w
                 
     for e in self.errors:
         print e
                             
     print "** WARNING COUNT =", len(self.warnings), "**"
     print "** ERROR COUNT =", len(self.errors), "**"