当前位置: 首页>>代码示例>>Python>>正文


Python ivy_msg_interface.IvyMessagesInterface类代码示例

本文整理汇总了Python中ivy_msg_interface.IvyMessagesInterface的典型用法代码示例。如果您正苦于以下问题:Python IvyMessagesInterface类的具体用法?Python IvyMessagesInterface怎么用?Python IvyMessagesInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IvyMessagesInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Ivy2RedisServer

class Ivy2RedisServer():
    def __init__(self, redishost, redisport, verbose=False):
        self.verbose = verbose
        self.interface = IvyMessagesInterface("Ivy2Redis")
        self.interface.subscribe(self.message_recv)
        self.r = redis.StrictRedis(host=redishost, port=redisport, db=0)
        self.keep_running = True
        print("Connected to redis server %s on port %i" % (redishost, redisport))

    def message_recv(self, ac_id, msg):
        # if ac_id is not 0 (i.e. telemetry from an aircraft) include it in the key
        # don't add it to the key for ground messages
        if ac_id:
            key = "{0}.{1}.{2}".format(msg.msg_class, msg.name, ac_id)
        else:
            key = "{0}.{1}".format(msg.msg_class, msg.name)
        if self.verbose:
            print("received message, key=%s, msg=%s" % (key, msg.to_json(payload_only=True)))
            sys.stdout.flush()
        self.r.publish(key, msg.to_json(payload_only=True))
        self.r.set(key, msg.to_json(payload_only=True))

    def run(self):
        while self.keep_running:
            time.sleep(0.1)

    def stop(self):
        self.keep_running = False
        self.interface.shutdown()
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:29,代码来源:ivy_to_redis.py

示例2: WaypointMover

class WaypointMover(object):
    def __init__(self, verbose=False):
        self.verbose = verbose
        self._interface = IvyMessagesInterface(self.message_recv)

    def message_recv(self, ac_id, msg):
        if self.verbose:
            print("Got msg %s" % msg.name)

    def shutdown(self):
        print("Shutting down ivy interface...")
        self._interface.shutdown()

    def __del__(self):
        self.shutdown()

    def move_waypoint(self, ac_id, wp_id, lat, lon, alt):
        msg = PprzMessage("ground", "MOVE_WAYPOINT")
        msg["ac_id"] = ac_id
        msg["wp_id"] = wp_id
        msg["lat"] = lat
        msg["long"] = lon
        msg["alt"] = alt
        print("Sending message: %s" % msg)
        self._interface.send(msg)
开发者ID:robert-b,项目名称:paparazzi,代码行数:25,代码来源:move_waypoint_example.py

示例3: ObstacleAdder

class ObstacleAdder(object):
    def __init__(self, verbose=False):
        self.verbose = verbose
        self._interface = IvyMessagesInterface(self.message_recv)

    def message_recv(self, ac_id, msg):
        if self.verbose:
            print("Got msg %s" % msg.name)

    def shutdown(self):
        print("Shutting down ivy interface...")
        self._interface.shutdown()

    def __del__(self):
        self.shutdown()

    def add_obstacle(self, obstacle_id, color, status, lat, lon, radius, alt):
        msg = PprzMessage("ground", "OBSTACLE")
        msg['id'] = obstacle_id
        msg['color'] = color
        msg['status'] = status
        msg['lat'] = lat
        msg['lon'] = lon
        msg['radius'] = radius
        msg['alt'] = alt
        print("Sending message: %s" % msg)
        self._interface.send(msg)
开发者ID:rijesha,项目名称:radarlink,代码行数:27,代码来源:obstacles.py

示例4: RadioWatchFrame

class RadioWatchFrame(wx.Frame):
    def message_recv(self, ac_id, msg):
        if msg.name == "ROTORCRAFT_STATUS":
            self.rc_status = int(msg['rc_status'])
        if self.rc_status != 0 and not self.alertChannel.get_busy():
            self.warn_timer = wx.CallLater(5, self.rclink_alert)
            # else:
            # self.notification.close()

    def gui_update(self):
        self.rc_statusText.SetLabel(["OK", "LOST", "REALLY LOST"][self.rc_status])
        self.update_timer.Restart(UPDATE_INTERVAL)

    def rclink_alert(self):
        self.alertChannel.queue(self.alertSound)
        self.notification.show()
        time.sleep(5)

    def setFont(self, control):
        font = control.GetFont()
        size = font.GetPointSize()
        font.SetPointSize(size * 1.4)
        control.SetFont(font)

    def __init__(self):
        wx.Frame.__init__(self, id=-1, parent=None, name=u'RCWatchFrame',
                          size=wx.Size(WIDTH, HEIGHT), title=u'RC Status')
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.rc_statusText = wx.StaticText(self, -1, "UNKWN")

        pygame.mixer.init()
        self.alertSound = pygame.mixer.Sound("crossing.wav")
        self.alertChannel = pygame.mixer.Channel(False)

        self.setFont(self.rc_statusText)

        self.notification = pynotify.Notification("RC Link Warning!",
                                                  "RC Link status not OK!",
                                                  "dialog-warning")

        self.rc_status = -1

        pynotify.init("RC Status")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.rc_statusText, 1, wx.EXPAND)
        self.SetSizer(sizer)
        sizer.Layout()
        self.interface = IvyMessagesInterface("radiowatchframe")
        self.interface.subscribe(self.message_recv)
        self.update_timer = wx.CallLater(UPDATE_INTERVAL, self.gui_update)

    def OnClose(self, event):
        self.interface.shutdown()
        self.Destroy()
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:56,代码来源:radiowatchframe.py

示例5: myQRParser

class myQRParser():
	def signal_handler(self, signal, frame):
			print('You pressed Ctrl+C!')
			self.interface.shutdown()
			sys.exit(0)

	def myCrapThread(self):
		time.sleep(1)
		myCode.decode_webcam(callback=self.codeRecognized, device='/dev/video0')
		#print('Finished, please ctrl+c')
		self.interface.shutdown()
		sys.exit(0)

	def __init__(self, ac_id, waypoint_id):
		self.ac_id = ac_id[0]
		self.waypoint_id = waypoint_id[0]
		self.interface = IvyMessagesInterface(self, self.emptyFun)
				
		t = threading.Thread(target=self.myCrapThread)
		t.start()

		signal.signal(signal.SIGINT, self.signal_handler)
		print('Press Ctrl+C')
		signal.pause()
		
		self.interface.shutdown()

	def emptyFun(ac_id, msg):
		print "Never"

	def codeRecognized (self, data):
		print data
		if data == '1':
			coords = 1
			print "Dropzone 1"
		elif data == '2':
			coords = 2
			print "Dropzone 2"
		elif data == '3':
			coords = 3
			print "Dropzone 3"
		else:
			print data
			return
		print('Going to: ', coords)
		pprzmsg = PprzMessage("ground", "DL_SETTING")
		pprzmsg.set_values([self.ac_id, self.waypoint_id, coords])
		self.interface.send(pprzmsg)
		#pprzmsg.set_values([self.ac_id, (self.waypoint_id+1), coords[0], coords[1], 10])
		#self.interface.send(pprzmsg)

	def __call__(a, b, c):
		print ""
开发者ID:bartslinger,项目名称:PyQrPprz,代码行数:53,代码来源:myqrparser.py

示例6: __init__

    def __init__(self, parent, frame):
        self.parent = parent  # we are drawing on our parent, so dc comes from this
        self.frame = frame  # the frame owns any controls we might need to update

        parent.SetDropTarget(TextDropTarget(self))  # calls self.OnDropText when drag and drop complete

        self.width = 800
        self.height = 200
        self.margin = min(self.height / 10, 20)
        self.font = wx.Font(self.margin / 2, wx.DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.pixmap = wx.EmptyBitmap(self.width, self.height)
        self.plot_size = self.width
        self.max = -1e32
        self.min = 1e32
        self.plot_interval = 200
        self.plots = {}
        self.auto_scale = True
        self.offset = 0.0
        self.scale = 1.0
        self.x_axis = None

        messages_xml_map.parse_messages()

        self.ivy_interface = IvyMessagesInterface(_IVY_APPNAME)

        # start the timer
        self.timer = wx.FutureCall(self.plot_interval, self.OnTimer)
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:27,代码来源:plotpanel.py

示例7: __init__

    def __init__(self):
        wx.Frame.__init__(self, id=-1, parent=None, name=u'RCWatchFrame',
                          size=wx.Size(WIDTH, HEIGHT), title=u'RC Status')
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.rc_statusText = wx.StaticText(self, -1, "UNKWN")

        pygame.mixer.init()
        self.alertSound = pygame.mixer.Sound("crossing.wav")
        self.alertChannel = pygame.mixer.Channel(False)

        self.setFont(self.rc_statusText)

        self.notification = pynotify.Notification("RC Link Warning!",
                                                  "RC Link status not OK!",
                                                  "dialog-warning")

        self.rc_status = -1

        pynotify.init("RC Status")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.rc_statusText, 1, wx.EXPAND)
        self.SetSizer(sizer)
        sizer.Layout()
        self.interface = IvyMessagesInterface("radiowatchframe")
        self.interface.subscribe(self.message_recv)
        self.update_timer = wx.CallLater(UPDATE_INTERVAL, self.gui_update)
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:28,代码来源:radiowatchframe.py

示例8: __init__

 def __init__(self, redishost, redisport, verbose=False):
     self.verbose = verbose
     self.interface = IvyMessagesInterface("Ivy2Redis")
     self.interface.subscribe(self.message_recv)
     self.r = redis.StrictRedis(host=redishost, port=redisport, db=0)
     self.keep_running = True
     print("Connected to redis server %s on port %i" % (redishost, redisport))
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:7,代码来源:ivy_to_redis.py

示例9: CommandReader

class CommandReader(object):

    def __init__(self, verbose=False, callback=None):
        self.verbose = verbose
        self.callback = callback
        self._interface = IvyMessagesInterface(self.message_recv)

    def message_recv(self, ac_id, msg):
        if (self.verbose and self.callback != None):
            self.callback(ac_id, msg)

    def shutdown(self):
        print("Shutting down ivy interface...")
        self._interface.shutdown()

    def __del__(self):
        self.shutdown()
开发者ID:rijesha,项目名称:radarlink,代码行数:17,代码来源:ivylinker.py

示例10: __init__

    def __init__(self, parent, callback, initIvy=True):
        wx.Frame.__init__(self, parent, name="MessagePicker", title=u"Message Picker", size=wx.Size(320, 640))

        self.aircrafts = {}
        self.callback = callback

        self.tree = wx.TreeCtrl(self)
        self.root = self.tree.AddRoot("Telemetry")
        self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
        self.tree.Bind(wx.EVT_CHAR, self.OnKeyChar)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.message_interface = IvyMessagesInterface(self.msg_recv, initIvy)
开发者ID:robert-b,项目名称:paparazzi,代码行数:12,代码来源:messagepicker.py

示例11: WaypointMover

class WaypointMover(object):
    def __init__(self, verbose=False):
        self.verbose = verbose
        self._interface = IvyMessagesInterface("WaypointMover")

    def shutdown(self):
        print("Shutting down ivy interface...")
        self._interface.shutdown()

    def __del__(self):
        self.shutdown()

    def move_waypoint(self, ac_id, wp_id, lat, lon, alt):
        msg = PprzMessage("ground", "MOVE_WAYPOINT")
        msg['ac_id'] = ac_id
        msg['wp_id'] = wp_id
        msg['lat'] = lat
        msg['long'] = lon
        msg['alt'] = alt
        print("Sending message: %s" % msg)
        self._interface.send(msg)
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:21,代码来源:move_waypoint_example.py

示例12: __init__

	def __init__(self, ac_id, waypoint_id):
		self.ac_id = ac_id[0]
		self.waypoint_id = waypoint_id[0]
		self.interface = IvyMessagesInterface(self, self.emptyFun)
				
		t = threading.Thread(target=self.myCrapThread)
		t.start()

		signal.signal(signal.SIGINT, self.signal_handler)
		print('Press Ctrl+C')
		signal.pause()
		
		self.interface.shutdown()
开发者ID:bartslinger,项目名称:PyQrPprz,代码行数:13,代码来源:myqrparser.py

示例13: __init__

    def __init__(self, msg_class="telemetry"):
        wx.Frame.__init__(self, id=-1, parent=None, name=u'MessagesFrame', size=wx.Size(WIDTH, HEIGHT), style=wx.DEFAULT_FRAME_STYLE, title=u'Messages')
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.notebook = wx.Notebook(self)
        self.aircrafts = {}

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.notebook, 1, wx.EXPAND)
        self.SetSizer(sizer)
        sizer.Layout()
        self.timer = threading.Timer(0.1, self.update_leds)
        self.timer.start()
        self.msg_class = msg_class
        self.interface = IvyMessagesInterface(self.message_recv)
开发者ID:Petterhg,项目名称:paparazzi,代码行数:14,代码来源:messagesframe.py

示例14: __init__

 def __init__(self, ac_id, verbose=False):
     self.ac_id = ac_id
     self.verbose = verbose
     self._interface = None
     self.auto2_index = None
     try:
         settings = PaparazziACSettings(self.ac_id)
     except Exception as e:
         print(e)
         return
     try:
         self.auto2_index = settings.name_lookup['auto2'].index
     except Exception as e:
         print(e)
         print("auto2 setting not found, mode change not possible.")
     self._interface = IvyMessagesInterface("guided mode example")
开发者ID:2seasuav,项目名称:paparuzzi,代码行数:16,代码来源:guided_mode_example.py

示例15: IntruderAdder

class IntruderAdder(object):
    def __init__(self, verbose=False):
        self.verbose = verbose
        self._interface = IvyMessagesInterface(self.message_recv)

    def message_recv(self, ac_id, msg):
        if self.verbose:
            print("Got msg %s" % msg.name)

    def shutdown(self):
        print("Shutting down ivy interface...")
        self._interface.shutdown()

    def __del__(self):
        self.shutdown()

    def add_intruder(self, intruder_id, name, lat, lon, alt, course, speed, climb, itow):
        msg = PprzMessage("ground", "INTRUDER")
        msg['id'] = intruder_id
        msg['name'] = name
        msg['lat'] = lat
        msg['lon'] = lon
        msg['alt'] = alt
        msg['course'] = course
        msg['speed'] = speed
        msg['climb'] = climb
        msg['itow'] = 0
        print("Sending message: %s" % msg)
        self._interface.send(msg)

    def new_intruder(self, intruder_id, name):
        msg = PprzMessage("ground", "INTRUDER")
        msg['id'] = intruder_id
        msg['name'] = name
        msg['itow'] = 0
        print("Sending message: %s" % msg)
        self._interface.send(msg)
开发者ID:rijesha,项目名称:radarlink,代码行数:37,代码来源:intruder.py


注:本文中的ivy_msg_interface.IvyMessagesInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。