def update_command(self, event): """ Function that gets called when the update button is pressed. Updates the oscillator tuning parameter """ # read the desired parameter from the GUI param_text = self.get_param() with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, extract the device NVM key. nvm_key = AARD.read_SCPI( "SUP:TEL? 9,data", self.properties.address, "uint") + 12345 # unlock the module NVM, set the tuning parameter and write it # to the NVM AARD.send_SCPI("SUP:NVM UNLOCK," + str(nvm_key), self.properties.address) AARD.send_SCPI("SUP:NVM OSCTUN," + param_text, self.properties.address) AARD.send_SCPI("SUP:NVM WRITE,1", self.properties.address) else: # no aardvark was found self.no_aardvark = True
def update_command(self, event): """ Function that gets called when the update button is pressed. Updates the module I2C address """ # retrieve the desired I2C address from the GUI address_text = self.get_addr() # extract the decimal address from that string address_num = int(address_text[2:], 16) with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found extract the NVM key from the # serial number nvm_key = AARD.read_SCPI( "SUP:TEL? 9,data", self.properties.address, "uint") + 12345 # send the commands to unlock the NVM, update the I2C address # and write it to the NVM AARD.send_SCPI("SUP:NVM UNLOCK," + str(nvm_key), self.properties.address) AARD.send_SCPI("SUP:NVM I2C," + str(address_num), self.properties.address) AARD.send_SCPI("SUP:NVM WRITE,1", address_text) #update the address in the process properties self.properties.address = address_text else: # no aardvark was found self.no_aardvark = True
def update_command(self, event): """ Function that gets called when the update button is pressed. Updates the module serial number """ # get the desired serial number serial_text = self.get_sn() # calculate the unlock key for the non volatile memory commands nvm_key = self.serial_number + 12345 with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, send the commands to unlock the NVM, # update the serial number and write it to NVM AARD.send_SCPI("SUP:NVM UNLOCK," + str(nvm_key), self.properties.address) AARD.send_SCPI("SUP:NVM SERIAL," + serial_text, self.properties.address) AARD.send_SCPI("SUP:NVM WRITE,1", self.properties.address) else: # no aardvark was found self.no_aardvark = True
def write_data_flash(self): """ Write the data flash subclasses to the gas gauge """ self.disable_buttons() # initialise the list of pages to write pages_to_write = [] # sort the keys keylist = sorted_key_list(self.parsed_flash_pages) # populate the list of pages for key in keylist: if not self.parsed_flash_pages[key].is_equal( self.read_flash_pages[key]): pages_to_write.extend(self.parsed_flash_pages[key].to_pages()) # end for with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # get the serial number serial_number = AARD.read_SCPI("SUP:TEL? 9,data", self.properties.address, 'uint') # unlock the flash AARD.send_SCPI( ("SUP:NVM UNLOCK," + str(serial_number + 12345)), self.properties.address) # write the flash updating commands for page in pages_to_write: AARD.send_SCPI(page.to_SCPI(), self.properties.address) time.sleep(1) # end for # lock the flash AARD.send_SCPI("SUP:NVM WRITE,1", self.properties.address) else: # no aardvark was found self.no_aardvark = True #end if # end with # re-enable buttons self.parse_button.config(state='normal') self.save_button.config(state='normal') self.load_button.config(state='normal') self.write_button.config(state='normal') self.read_button.config(state='normal')
def execute(self): """ The code to run for this step: Check if the Aardvark is present. """ with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, do nothing next else: # no aardvark was found self.no_aardvark = True
def read_BM2_page(self, ID, page): """ Read a page of data from the BM2 @param ID (int) The subclass ID to read @param page (int) The page within that subclass to read @return (Flash_Page) The recieved data """ # initialise the page read_page = Flash_Page(ID, page) # define the SPCI command to send SCPI_command = "BM2:BQF READ_PAGE," + str( read_page.subclassID) + ',' + str(read_page.page_number) with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, request the page to be read AARD.send_SCPI(SCPI_command, self.properties.address) # wait for 0.1 seconds time.sleep(0.1) # read the page page_data = AARD.read_SCPI("BM2:TEL? 78,data", self.properties.address, 33 * ['char']) # extract the data from the result if page_data != None: # the read was successful read_page.length = page_data[0] read_page.data = [ str(item) for item in page_data[1:read_page.length + 1] ] # end if else: # no aardvark was found self.no_aardvark = True #end if # end with return read_page
def execute(self): """ The code to run for this step: Read the current module serial number """ with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, read the data self.serial_number = AARD.read_SCPI("SUP:TEL? 9,data", self.properties.address, "uint") else: # no aardvark was found self.no_aardvark = True
def execute(self): """ The code to run for this step: Read the tuning parameter from the module """ with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, read the data self.tuning_param = AARD.read_SCPI("SUP:TEL? 11,data", self.properties.address, "schar") else: # no aardvark was found self.no_aardvark = True
def heater_command(self, event): """ Function that gets called when the heater button is pressed. Performs the heater test """ # calculate the initial power being consumed by the BM2 rest_power = self.initial_current*self.voltage # initialise the new current measurement new_current = self.initial_current # remove the previous power measurement from the display self.power.delete(0, 'end') with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, command the heater on AARD.send_SCPI("BM2:HEA ON", self.properties.address) # wait for 2 seconds time.sleep(2) # read the new current new_current = AARD.read_SCPI("BM2:TEL? 10,data", self.properties.address, "int")/-1000.0 #comand the heater to turn off again AARD.send_SCPI("BM2:HEA OFF", self.properties.address) else: # no aardvark was found self.no_aardvark = True #end if # end with # calculate the power increase with the heaters on heater_power = (new_current * self.voltage) - rest_power #update the GUI with the new power value self.power.insert(0, str(heater_power))
def execute(self): """ The code to run for this step: Read Voltage and Current from the BM2 if communications can be established """ with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, read the data self.initial_current = AARD.read_SCPI("BM2:TEL? 10,data", self.properties.address, "uint")/1000.0 self.voltage = AARD.read_SCPI("BM2:TEL? 9,data", self.properties.address, "uint")/1000.0 else: # no aardvark was found self.no_aardvark = True
def execute(self): """ The code to run for this step: Read Voltage, State of Charge and Temperature from the BM2 if communications canbe established """ with process_SCPI.aardvark() as AARD: # initialise the assrdvark if AARD.port != None: # if an aardvark was found, read the data self.voltage_read = AARD.read_SCPI("BM2:TEL? 9,data", self.properties.address, "uint")/1000.0 self.temp_read = AARD.read_SCPI("BM2:TEL? 8,data", self.properties.address, "uint")/100.0 self.SOC_read = AARD.read_SCPI("BM2:TEL? 13,data", self.properties.address, "char") else: # no aardvark was found self.no_aardvark = True
def update_command(self, event): """ Function that gets called when the update button is pressed. Updates the oscillator tuning parameter """ # read the desired parameter from the GUI param_text = self.get_param() with process_SCPI.aardvark() as AARD: # initialise the aardvark if AARD.port != None: # if an aardvark was found, extract the device NVM key. nvm_key = AARD.read_SCPI("SUP:TEL? 9,data", self.properties.address, "uint")+12345 # initialise sample list num_samples = 10 temp_samples = num_samples*[6*[0]] for sample in temp_samples: sample[0] = AARD.read_SCPI("BM2:TEL? 50,data", self.properties.address, "uint") sample[1] = AARD.read_SCPI("BM2:TEL? 51,data", self.properties.address, "uint") sample[2] = AARD.read_SCPI("BM2:TEL? 71,data", self.properties.address, "uint") sample[3] = AARD.read_SCPI("BM2:TEL? 72,data", self.properties.address, "uint") sample[4] = AARD.read_SCPI("BM2:TEL? 73,data", self.properties.address, "uint") sample[5] = AARD.read_SCPI("BM2:TEL? 74,data", self.properties.address, "uint") time.sleep(1) # end for # average the temperatures average_temps = self.average_temperatures(temp_samples) # read the current offsets temp_offsets = AARD.read_SCPI("BM2:TEL? 75,data", self.properties.address, 6*["float"]) # un-adjust the temperatures read average_temps = [t-o for t,o in zip(average_temps, temp_offsets)] cal_temp = int((float(self.get_param())+273.15)*10) offsets = [cal_temp-t for t in average_temps] # unlock the module NVM, set the tuning parameter and write it # to the NVM AARD.send_SCPI("SUP:NVM UNLOCK,"+str(nvm_key), self.properties.address) for i in range(len(offsets)): param_text = str(i+2) + ',' + str(offsets[i]) AARD.send_SCPI("BM2:NVM T_OFFSET,"+param_text, self.properties.address) # end for AARD.send_SCPI("SUP:NVM WRITE,1", self.properties.address) else: # no aardvark was found self.no_aardvark = True