def on_config_req_msg(self, agent, *larg): dmw.publish("pprz", "opaque", "%s %s CONFIG_REQ %s" % (larg[0], larg[1], larg[2])) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) if len(sys.argv) < 2: print "Must supply one argument (ac_id)" sys.exit(-1) aircraft_id = int(sys.argv[1]) dmw.init() dmw.init_pub("ground%d" % (aircraft_id)) interface = IvyMessagesInterface(process_messages, bind_regex='(.*)', verbose=True) ivyId1 = IvyBindMsg(on_aircraft_req_msg, '((\\S*) (\\S*) AIRCRAFTS_REQ)') ivyId2 = IvyBindMsg(on_config_req_msg, '((\\S*) (\\S*) CONFIG_REQ (\\S*))') # Subscribe to messages from gcs. t = SubscriptionThread(interface, aircraft_id) t.setDaemon(True) t.start() while True: time.sleep(0.1)
def on_aircrafts_msg( self, agent, *larg ): dmw.publish( "pprz", "opaque", "%s %s AIRCRAFTS %s"%( larg[0], larg[1], larg[2] ) ) def on_config_msg( self, agent, *larg ): dmw.publish( "pprz", "opaque", "%s %s CONFIG %s"%( larg[0], larg[1], larg[2] ) ) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) if len(sys.argv) < 2: print "Must supply one argument (ac_id)" sys.exit(-1) vehicle = Vehicle( int( sys.argv[1] ) ) dmw.init() dmw.init_pub( str(vehicle.ac_id) ) interface = IvyMessagesInterface( process_messages, verbose=True ) ivyId1 = IvyBindMsg( on_aircrafts_msg, '((\\S*) (\\S*) AIRCRAFTS (\\S*))') ivyId1 = IvyBindMsg( on_config_msg, '((\\S*) (\\S*) CONFIG (.*))') # Subscribe to messages from gcs. t = SubscriptionThread( interface ) t.setDaemon( True ) t.start() while True: time.sleep(0.1)