def restoreModulesFunctions(self): t = self.tossim while(1): iTemp = raw_input("Select a Sensor Node to restore modules functions: ") print "" try: i = int(iTemp) except ValueError: print "ERROR: Invalid input type." print "" continue if not(i in self.sensors): print "ERROR: Invalid sensor node selected" print "" continue break #inject packet to simulate fire msg = RadioMsg() msg.set_msg_type(10) pkt = t.newPacket() pkt.setData(msg.data) pkt.setType(msg.get_amType()) pkt.setDestination(i) pkt.setSource(0) pkt.deliverNow(i)
def simulateSensorNodeModuleMalfunction(self): print "Simulating malfuntion of module in Sensor Node" t = self.tossim while(1): iTemp = raw_input("Select a Sensor Nodeto simulate module malfunction [look at topo]: ") print "" try: i = int(iTemp) except ValueError: print "ERROR: Invalid input type." print "" continue if not(i in self.sensors): print "ERROR: Invalid sensor node selected" print "" continue while(1): print "[1] Temperature Sensor" print "[2] Humidity Sensor" print "[3] Smoke Detector" print "[4] GPS" print "" print "[0] Cancel" iiTemp = raw_input("Select an option [0-4]: ") print "" try: ii = int(iiTemp) except ValueError: print "ERROR: Invalid input type." print "" continue if(ii < 0 or ii > 4): print "ERROR: Invalid option selected" print "" continue break break if not (0 == ii): #inject packet to simulate fire msg = RadioMsg() if(1 == ii): msg.set_msg_type(9) elif(2 == ii): msg.set_msg_type(8) elif(3 == ii): msg.set_msg_type(6) elif(4 == ii): msg.set_msg_type(7) msg.set_dest(i) pkt = t.newPacket() pkt.setData(msg.data) pkt.setType(msg.get_amType()) pkt.setDestination(i) pkt.setSource(0) pkt.deliverNow(i)