def main(): host = "localhost" #port = 6499 #host = "192.168.1.64" port = 5050 app = QtGui.QApplication(sys.argv) filename = "" if len(sys.argv) > 2: usage() return elif len(sys.argv) == 2: filename = sys.argv[1] #df = DataFetcher(host=host, port=port) #df.update() root = getNode('/', create=True) props_xml.load(filename, root) ex = Tuner(host=host, port=port) sys.exit(app.exec_())
def load(self, cal_file): config = PropertyNode() try: name, ext = os.path.splitext(cal_file) if ext == '.json': props_json.load(cal_file, config) self.valid = True elif ext == '.xml': props_xml.load(cal_file, config) self.valid = True else: return False except: print(cal_file + ": load error:\n" + str(sys.exc_info()[1])) return False root.pretty_print() self.min_temp = config.getFloat('min_temp_C') self.max_temp = config.getFloat('max_temp_C') node = config.getChild('p') if node: p1, p2, p3 = node.getString('bias').split() self.p_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.p_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('q') if node: p1, p2, p3 = node.getString('bias').split() self.q_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.q_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('r') if node: p1, p2, p3 = node.getString('bias').split() self.r_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.r_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('ax') if node: p1, p2, p3 = node.getString('bias').split() self.ax_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.ax_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('ay') if node: p1, p2, p3 = node.getString('bias').split() self.ay_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.ay_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('az') if node: p1, p2, p3 = node.getString('bias').split() self.az_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.az_scale = np.array([p1, p2, p3], dtype=np.float64) tokens = config.getString('mag_affine').split() if len(tokens) == 16: r = 0 c = 0 for i, x in enumerate(tokens): self.mag_affine[r, c] = float(x) c += 1 if c > 3: c = 0 r += 1 self.mag_affine_inv = np.linalg.inv(self.mag_affine) else: print("mag_affine requires 16 values") #print 'mag_affine:\n', self.mag_affine #print 'mag_affine_inv:\n', self.mag_affine_inv return True
#!/usr/bin/python from props import PropertyNode, root, getNode import props_xml import props_json import sys # run the system through it's paces xmlfile = sys.argv[1] jsonfile = sys.argv[2] config = PropertyNode() props_xml.load(xmlfile, config) props_json.save(jsonfile, config)
def load(self, cal_file): config = PropertyNode() try: name, ext = os.path.splitext(cal_file) if ext == '.json': props_json.load(cal_file, config) self.valid = True elif ext == '.xml': props_xml.load(cal_file, config) self.valid = True else: return False except: print cal_file + ": load error:\n" + str(sys.exc_info()[1]) return False root.pretty_print() self.min_temp = config.getFloat('min_temp_C') self.max_temp = config.getFloat('max_temp_C') node = config.getChild('p') if node: p1, p2, p3 = node.getString('bias').split() self.p_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.p_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('q') if node: p1, p2, p3 = node.getString('bias').split() self.q_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.q_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('r') if node: p1, p2, p3 = node.getString('bias').split() self.r_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.r_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('ax') if node: p1, p2, p3 = node.getString('bias').split() self.ax_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.ax_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('ay') if node: p1, p2, p3 = node.getString('bias').split() self.ay_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.ay_scale = np.array([p1, p2, p3], dtype=np.float64) node = config.getChild('az') if node: p1, p2, p3 = node.getString('bias').split() self.az_bias = np.array([p1, p2, p3], dtype=np.float64) p1, p2, p3 = node.getString('scale').split() self.az_scale = np.array([p1, p2, p3], dtype=np.float64) tokens = config.getString('mag_affine').split() if len(tokens) == 16: r = 0 c = 0 for i, x in enumerate(tokens): self.mag_affine[r,c] = float(x) c += 1 if c > 3: c = 0 r += 1 self.mag_affine_inv = np.linalg.inv(self.mag_affine) else: print "mag_affine requires 16 values" #print 'mag_affine:\n', self.mag_affine #print 'mag_affine_inv:\n', self.mag_affine_inv return True