本文整理汇总了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()
示例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)
示例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)
示例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()
示例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 ""
示例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)
示例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)
示例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))
示例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()
示例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)
示例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)
示例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()
示例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)
示例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")
示例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)