コード例 #1
0
    def __init__(self, queue, t, n):
        """
            Constructs a server which will continually accept connections.
            When a connection is received the RFID receiver will be initially
            configured to query at a rate of 't' seconds and take 'n' samples
            per gain level.  See ReceiverConnection class for details.
            
            For each observation made the observation will be offered to the
            queue 'queue'. 
        """
        self.server = Server()
        self.server.connect()

        self.queue = queue
        self.rate = t
        self.count = n

        threading.Thread.__init__(self)
コード例 #2
0
    rate = float(optlist.get("--receiver-rate", 1))
    count = int(optlist.get("--receiver-samples", 100))

    if not id:
        usage("No tag specified.")
    if pos < 0:
        usage("Position not specified or is invalid")

    ## Open a writer object for this tag, retrieve the actual id for the alias
    ##-------------------------------------------------------------------------
    writer = CalibrationFileWriter("Tag%s.cali" % id)

    if id in known_tags.keys():
        id = known_tags.get(id)

    print "INFO: Starting Server"
    serv = Server()
    serv.connect()

    ## Wait until the maximum number of connections has been reached
    for i in range(len(known_hosts.keys())):
        con = serv.getNextConnection()
        print "INFO: Connected by receiver %s on port %d" % (con.addr,
                                                             con.port)

        thread = CalibrationThread(id, pos, writer, con, rate, count)
        thread.start()

    print "INFO: Maximum connections reached."