def __init__(self, N): self.prevtime = time.time() self.N = N self.A = make_A_matrix(self.N) self.current_row = 0 #self.sym = [3]; #works #self.sym = [3.5]; #so does this, changed header #self.sym = self.A*np.matrix(np.ones((N,1))) #self.data = np.mat('[10.7; 1; 0; 1; .1; 6; .2; 1]') #self.data = np.random.randint(255,size=(N,1)) #random integer, type ndarray rndseed = np.random.RandomState(2413) #self.data = np.mat(np.random.randint(255,size=(N,1))) #type core.defmatrix.matrix self.data = np.mat(rndseed.randint( 255, size=(N, 1))) #type core.defmatrix.matrix #self.data[2,:] = 0.; #self.data[4,:] = 1.; #self.data[6,:] = 2.; print 'data is' print self.data self.sym = self.A * self.data #self.rndV = np.mat([-40, -40, -40, -40, -40, -40, -40, -40]) # Create a MoteIF print 'symbols are' print self.sym self.mif = MoteIF.MoteIF() # Attach a source to it self.source = self.mif.addSource("sf@localhost:9002") # SomeMessageClass.py would be generated by MIG self.mif.addListener(self, DecodedMsg)
def __init__(self, sfsource): # Create a MoteIF self.mif = MoteIF.MoteIF() # Attach a source to it if ':' in sfsource: # self.log.debug("Assuming Serial Forwarder interface") self.source = self.mif.addSource("sf@" + sfsource) elif "dev" in sfsource: # self.log.debug("Assuming Serial interface") self.source = self.mif.addSource("serial@" + sfsource + ":115200") else: try: import twist from threading import Thread sfsource = int(sfsource) print "Provide ssh password: "******"sf@localhost:9{0:03d}".format(sfsource)) except Exception, e: raise
def __init__(self, motestring): # Create a MoteIF self.mif = MoteIF.MoteIF() # Attach a source to it self.tos_source = self.mif.addSource(motestring) # SomeMessageClass.py would be generated by MIG self.mif.addListener(self, ChatMsg.ChatMsg)
def __init__(self): # Create a MoteIF self.mif = MoteIF.MoteIF() # Attach a source to it self.source = self.mif.addSource("sf@localhost:9001") # SomeMessageClass.py would be generated by MIG self.mif.addListener(self, TestSerialMsg)
def __init__(self, N, logfile, itMax=1, B=1, verbose=True, dest=False): #CHANGE SO THAT ONLY THINGS THAT ARE CALLED ONCE!! self.verbose = verbose self.prevtime = time.time() self.N = N self.logfile = logfile self.B = B self.itMax = itMax self.timeformat = '%Y/%d/%m %H:%M:%S' #self.A = make_A_matrix(self.N) #self.counter = 0; #self.num_transmissions = 0; self.current_row = 0 #needed now?? Transmitter.setup_logfile(self) ## Set up link to tos mote self.mif = MoteIF.MoteIF() self.source = self.mif.addSource("sf@localhost:9002") #TxSerialMsg.py is be generated by MIG class self.mif.addListener(self, TxSerialMsg) # RESET THESE ## generate random messages #self.W = np.random.randint(0,2**16, (N,B)) # each message is an array of B uint16s ##print 'W is :' ##print self.W ## store final received messages. goal is to "de-NaN" by the end ##self.final_messages = np.nan*np.zeros((N, B)) ##not actually messages but indicator if all the pieces for the node have been received #self.final_messages = np.nan*np.zeros((N, 1)) ## keep track of all transmitted and received messages/symbols #self.tx_symbols = np.array([]) # [1 -by- # of transmissions] # ## keep track of number of transmissions #self.TOTAL_TRANSMISSIONS = 0 ## for TDMA round also? #self.TDMA_TRANSMISSIONS = 0 #antidote matrix A #self.A = np.diag(self.W.reshape(-1)) # receiver (row) i has access to the message it plans to send #rewrite so not dependent on W #self.A = np.eye(N) # Receiver i wants message dest[i] # e.g. dest = [1, 0] means R0 wants W[1] and R1 wants W[0] if dest == False: self.dest = pairingperm(N) if self.verbose: print 'Message destinations chosen by pairing' print 'dest:', self.dest else: self.dest = dest #rewrite A so not dependent on W self.it = 0 Transmitter.reset(self)
def __init__(self, N): self.prevtime = time.time() self.N = N self.A = make_A_matrix(self.N) self.current_row = 0 # Create a MoteIF self.mif = MoteIF.MoteIF() # Attach a source to it self.source = self.mif.addSource("sf@localhost:9002") # SomeMessageClass.py would be generated by MIG self.mif.addListener(self, DecodedMsg)
def __init__(self, source): self.mif = MoteIF.MoteIF() self.source = self.mif.addSource(source) self.mif.addListener(self, OscilloscopeMsg) self.data = data.data() self.version = 0 self.a1 = 0 self.bad1 = 0. self.sum1 = 1. self.a2 = 0 self.bad2 = 0. self.sum2 = 1.
def __init__(self, N): self.N = N self.A = make_A_matrix(self.N) self.counter = 0 self.perform_svd = 0 # Create a MoteIF self.mif = MoteIF.MoteIF() # Attach a source to it self.source = self.mif.addSource("sf@localhost:9002") # SomeMessageClass.py would be generated by MIG self.mif.addListener(self, DecodedMsg)
def __init__(self, N, B=1, verbose=True, dest=False): #is pieces 1 here? self.verbose = verbose self.prevtime = time.time() self.N = N #self.A = make_A_matrix(self.N) self.counter = 0 self.num_transmissions = 0 self.current_row = 0 ## Set up link to tos mote self.mif = MoteIF.MoteIF() self.source = self.mif.addSource("sf@localhost:9002") #TxSerialMsg.py is be generated by MIG class self.mif.addListener(self, TxSerialMsg) # generate random messages self.W = np.random.randint( 0, 2**16, (N, B)) # each message is an array of B uint16s # store final received messages. goal is to "de-NaN" by the end self.final_messages = np.nan * np.zeros((N, B)) # keep track of all transmitted and received messages/symbols self.tx_symbols = np.array([]) # [1 -by- # of transmissions] # keep track of number of transmissions self.TOTAL_TRANSMISSIONS = 0 # for TDMA round also? self.TDMA_TRANSMISSIONS = 0 # antidote matrix A self.A = np.diag(self.W.reshape( -1)) # receiver (row) i has access to the message it plans to send # Receiver i wants message dest[i] # e.g. dest = [1, 0] means R0 wants W[1] and R1 wants W[0] if dest == False: self.dest = pairingperm(N) if self.verbose: print 'Message destinations chosen by pairing' print 'dest:', self.dest else: self.dest = dest mat_dest = (np.arange(self.N), np.array(self.dest)) signal_space = np.zeros((self.N, self.N)) > 0 signal_space[mat_dest] = True self.I = compute_interferers(self.A, signal_space) self.J = self.I.astype(float) self.J[mat_dest] = -1 self.map = np.arange(self.N) if self.verbose: print 'Interferer matrix is:' print self.J
def __init__(self, logfile): self.logfile = logfile self.timeformat = '%Y/%d/%m %H:%M:%S' self.num_nodes = 0 self.num_rounds = 0 self.num_transmissions = 0 # Create a MoteIF self.mif = MoteIF.MoteIF() # Attach a source to it self.source = self.mif.addSource("sf@localhost:9002") self.setup_logfile() # SerialMsg.py autogenerated by MIG self.mif.addListener(self, SerialMsg)
def run(self): # Create a MoteIF self.mif = MoteIF.MoteIF() # Attach a source to it self.ssr = self.mif.addSource(self.sensor) self.stx = self.mif.addSource(self.tx) self.srx = self.mif.addSource(self.rx) self.mif.addListener(self, CBSweepDataMsg) self.mif.addListener(self, radio_conf_msg) self.mif.addListener(self, radio_msg) self.log.info("run") b_channel = 11 last_channel = 11 self.configure(self.stx, channel=b_channel, power=31) self.configure(self.srx, channel=b_channel, power=31) ########################################## ### Controller logic ### while True: if self.channel_utilization is None: continue else: print "" self.channel_info() b_rssi = min(self.channel_utilization) b_channel = self.channel_utilization.index(b_rssi) + 11 print "Best channel: {:2d} (RSSI: {:.3f})".format( b_channel, b_rssi) if last_channel != b_channel: print "Configuring TX for channel {}.".format(b_channel) self.configure(self.stx, channel=b_channel) else: print "Staying on previous channel. It is still the best" print "Sending message" self.send_messge() time.sleep(1) if last_channel != b_channel: print "Configuring RX for channel {}.".format(b_channel) self.configure(self.srx, channel=b_channel) else: print "Staying on previous channel. It is still the best" print "Sending message" self.send_messge() last_channel = b_channel time.sleep(5)
def __init__(self): super(SerialInterface, self).__init__() self.mif = MoteIF.MoteIF() self.source = self.mif.addSource("sf@localhost:9002") self.mif.addListener(self, DataMsg) self.handler = None
def __init__(self): self.mif = MoteIF.MoteIF() self.source = self.mif.addSource("sf@localhost:9002") self.mif.addListener(self, answerMsg)
def __init__(self, N, B=1, verbose=True, dest=False): #is pieces 1 here? self.verbose = verbose self.prevtime = time.time() self.N = N #self.A = make_A_matrix(self.N) self.counter = 0; self.num_transmissions = 0; self.current_row = 0; ## Set up link to tos mote self.mif = MoteIF.MoteIF() self.source = self.mif.addSource("sf@localhost:9002") #TxSerialMsg.py is be generated by MIG class self.mif.addListener(self, TxSerialMsg) # generate random messages self.W = np.random.randint(0,2**16, (N,B)) # each message is an array of B uint16s #print 'W is :' #print self.W # store final received messages. goal is to "de-NaN" by the end self.final_messages = np.nan*np.zeros((N, B)) #not actually messages but indicator if all the pieces for the node have been received self.final_messages = np.nan*np.zeros((N, 1)) # keep track of all transmitted and received messages/symbols self.tx_symbols = np.array([]) # [1 -by- # of transmissions] # keep track of number of transmissions self.TOTAL_TRANSMISSIONS = 0 # for TDMA round also? self.TDMA_TRANSMISSIONS = 0 # antidote matrix A #self.A = np.diag(self.W.reshape(-1)) # receiver (row) i has access to the message it plans to send #rewrite so not dependent on W self.A = np.eye(N) # Receiver i wants message dest[i] # e.g. dest = [1, 0] means R0 wants W[1] and R1 wants W[0] if dest == False: self.dest = pairingperm(N) if self.verbose: print 'Message destinations chosen by pairing' print 'dest:', self.dest else: self.dest = dest mat_dest = (np.arange(self.N), np.array(self.dest)) signal_space = np.zeros((self.N,self.N))>0 signal_space[mat_dest] = True; self.I = compute_interferers(self.A, signal_space) self.J = self.I.astype(float) self.J[mat_dest] = -1 self.map = np.arange(self.N) print 'size of I is ', np.size(self.I) if self.verbose: print 'Interferer matrix is:' print self.J #send the first tdma packet? self.TDMA_MODE = 1; #self.tm = 0; #needed? self.TDleft = np.arange(self.N, dtype=np.uint8) self.ackList = np.nan*self.TDleft #self.ileft = 0; #transmit the first message Transmitter.tdma_stage(self) self.ileft = 1
def __init__(self, source_str): self.mif = MoteIF.MoteIF() self.mif.addListener(self, printf) self.source = self.mif.addSource(source_str)
def __init__(self, source): self.mif = MoteIF.MoteIF() self.source = self.mif.addSource(source) self.mif.addListener(self, StateMsg) self.mif.addListener(self, BootMsg) self.queue = Queue()