def run_Radar(): print "Spots version {}".format(basic.ADSB.VERSION) sys.stderr = open("spots.err", 'w') logger = logging.getLogger('spots') logger.setLevel(logging.DEBUG) fh = logging.handlers.RotatingFileHandler( filename=basic.ADSB.cfg_log_file, mode='w', maxBytes=basic.ADSB.cfg_log_max_bytes, backupCount=basic.ADSB.cfg_log_backup_count) formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - (%(threadName)-10s) - %(message)s' ) fh.setFormatter(formatter) logger.addHandler(fh) fh.setLevel(logging.DEBUG) logger.info("Spots version: {}".format(basic.ADSB.VERSION)) if basic.ADSB.cfg_read_from_file: tuner1090 = tuner.Tuner(filename=basic.ADSB.cfg_file_name) else: tuner1090 = tuner.Tuner() tuner1090.start() radar = Radar() radar.start() host = basic.ADSB.cfg_server_address port = basic.ADSB.cfg_server_port spots_server = server.SpotsServer((host, port), radar) spots_server.start() logger.info("Spots message server running, listening on {}:{}".format( host, port)) tuner1090.read(radar.tuner_read) # This is the main loop and main thread spots_server.die()
def __init__(self, width, height, A4=432, tolerance=0.1, accuracy=5): self.__tuner = tuner.Tuner(A4, tolerance, accuracy) self.__master = Tk() screen_w = self.__master.winfo_screenwidth() screen_h = self.__master.winfo_screenheight() self.__width = width self.__height = height pos = "+{}+{}".format(screen_w / 2 - self.__width / 2, screen_h / 2 - self.__height / 2) self.__master.title("Chromatic tuner") self.__master.geometry(pos) self.__master.resizable(False, False) self.__accuracy = accuracy self.__info_content = StringVar() self.__text_info = Label(self.__master, textvariable=self.__info_content) self.__canvas = Canvas(self.__master, width=self.__width, height=self.__height) image = Image.open("../assets/gears.png") image = image.resize((35, 35), Image.ANTIALIAS) self.image = ImageTk.PhotoImage(image) self.button = Button(self.__master, command=self.settings) self.button.config(image=self.image) self.button.grid(row=0, column=0, sticky=W) self.__c_freq = StringVar() self.updateCfreq() Label(self.__master, textvariable=self.__c_freq, font="Helvetica 16 bold").grid(row=0, column=0) self.__canvas.grid(row=1, column=0) self.__text_info.grid(row=2, column=0) self.__needle = needle.Needle(self.__master, self.__canvas, width, height) self.drawBar() self.listen_t = threading.Thread(target=self.read, args=()) self.listen_t.daemon = True self.listen_t.start()
def __init__(self, training_labels, training, validation_labels, validation, clabel): ''' Initialization of the problem through training data. labels is a list of 0,1 that recognize each sample in the training, where 1 is a positive example for the class training is a dictionary clabel name of classifier ''' # Added a label field, contains the name of the dataset self.clabel = clabel self.t_labels = training_labels self.training = training self.v_labels = validation_labels self.validation = validation # self.tuning_log = None # Ranges for parameter C and gamma self.n_iterations = 1 self.C_range = [pow(2, -5), pow(2, 15)] #max pow(2,15) self.C_step = float(self.C_range[1] - self.C_range[0]) / self.n_iterations self.gamma_range = [pow(2, -15), pow(2, 3)] #max pow(2,3) self.gamma_step = float(self.gamma_range[1] - self.gamma_range[0]) / self.n_iterations self.finer_range = {'C': 100, 'gamma': 1} ## SVM initialization # To disable output messages from the library svmc.svm_set_quiet() # Definition of standard parameters for SVM self.parameters = svm_parameter(svm_type = C_SVC, kernel_type = RBF, \ C = 1, gamma = 0, probability = 1) # Definition of the problem wrt training examples self.problem = svm_problem(self.t_labels, self.training) # Initializing the external tuner self.tune = tuner.Tuner(self)
'reqCurrentStation' : 9, 'reqChangeBand' : 10, 'reqSetHomeAddress' : 11, 'reqSetBrightness' : 12, 'reqSetColor' : 13, 'reqSetContrast' : 14, 'reqSetAddress' : 15, 'reqGetRecentDestinations': 16 } messages = [] messages.append(json.dumps({'time': datetime.datetime.utcnow().isoformat() + 'Z'})) Media = media.Media('media') Tuner = tuner.Tuner('tuner') Navi = navigation.Navigation('navi') Settings = settings.Settings('Settings') def parseMsg(msg): try: messageObj = json.loads(msg) except ValueError: LOG.error('Cannot parse message to JSON! ') return False except: LOG.error('Unexpected error: ' + sys.exc_info()[0]); return False return messageObj async def consumer (message):