def update_cal(instrument): # Display an instruction message to the user... print( "Place the factory calibration file (e.g. 12345.cal) in the import folder." ) input("Press the ENTER key when ready to begin the procedure...") # Specify a capture file... instrument.capfile = "save/update_cal.log.txt" # Open a serial (RS232) connection... instrument.set_timeout(2) instrument.init_connection() # Enable printing to user screen... print("Instrument will now print to your screen...") instrument.echo = True # Display current cal coefficients from instrument... instrument.imm_cmd('#%sdc' % instrument.remote_id) # Set the source file for the new coefficients... instrument.cal_source_file = "%s.cal" % instrument.serialnumber[3:] # Get coefficients from cal file... coefs = get_cal_from_file(instrument) coefs.pop('INSTRUMENT_TYPE') coefs.pop('SERIALNO') # Update the instrument... for coef in coefs.keys(): instrument.imm_cmd('#%s%s=%s' % (instrument.remote_id, coef, coefs[coef])) # Display updated cal coefficients from instrument... instrument.imm_cmd('#%sdc' % instrument.remote_id) # Wrap up... instrument.echo = False # Prompt to generate a new cal csv... again = input("Would you like to create a new calibration csv? [y]/n ") if again.lower() != "n": instrument.generate_cal_csv() print("\nUpdate complete.\n") filedate = common.current_utc().strftime('%Y%m%d') instrument.rename_capfile("save/CTDMO_%s_update_coefficients_%s.txt" % (instrument.serialnumber, filedate)) if not instrument.disconnect(): print("Error closing serial port!") return True
def clock_set_test(self, margin, conditions=['utc']): for condition in conditions: while True: if condition == 'noon': print("Setting clock to noon yesterday...") t1 = common.noon_yesterday() elif condition == 'utc': print("Setting clock to current time UTC...") t1 = common.current_utc() self.imm_set_datetime(common.formatdate(t1, 'sbe')) t2 = self.get_time() if common.compare_times_ordered(t1, t2, margin): break else: if common.usertryagain("There was a problem setting the clock. The reported time is %s. The expected time is %s" % (common.formatdate(t2, 'us'), common.formatdate(t1, 'us'))): continue else: return False return True
def proc_deploy(instrument): # Specify a capture file... instrument.capfile = "save/NUTNR_SN_config_%s.txt" % common.formatdate( common.current_utc(), 'filename') # Open a serial (RS232) connection... instrument.init_connection() # List current configuration details... print(instrument.get_cfg()) # Set the instrument clock to current time... print(instrument.set_clock()) print(instrument.get_cmd('get clock')) # Send deployment configurations to instrument... print(instrument.get_cmd('set msglevel info')) print(instrument.get_cmd('set outfrtyp full_ascii')) print(instrument.get_cmd('set logfrtyp full_ascii')) print(instrument.get_cmd('set outdrkfr output')) print(instrument.get_cmd('set logdrkfr output')) print(instrument.get_cmd('set logftype daily')) print(instrument.get_cmd('set opermode continuous')) print(instrument.get_cmd('set operctrl samples')) print(instrument.get_cmd('set exdevtyp wiper')) print(instrument.get_cmd('set exdevrun on')) print(instrument.get_cmd('set countdwn 3')) print(instrument.get_cmd('set drkavers 100')) print(instrument.get_cmd('set lgtavers 3')) print(instrument.get_cmd('set drksmpls 1')) print(instrument.get_cmd('set lgtsmpls 1')) print(instrument.get_cmd('set intpradj off')) print(instrument.get_cmd('set intprfac 1')) # List updated configuration details... print(instrument.get_cfg()) # End procedure... if not instrument.disconnect(): print("Error closing serial port!") return True
def export_cal(instrument): # Display an instruction message to the user... print( "This procedure will connect to an instrument and generate a calibration csv" ) print("from the coefficients stored on the instrument.") input("Press the ENTER key when ready to begin...") # Open a serial (RS232) connection... instrument.set_timeout(2) instrument.init_connection() instrument.cal_source_file = "retreived from instrument on %s" % common.current_utc( ).strftime("%Y-%m-%d") instrument.generate_cal_csv() print("Procedure complete.") if not instrument.disconnect(): print("Error closing serial port!") return True
def set_clock(self): return self.get_cmd('set clock %s' % common.formatdate(common.current_utc(), 'suna'))