Skip to content

Commit

Permalink
[atc] aeronautical altitude information
Browse files Browse the repository at this point in the history
  • Loading branch information
dewagter committed Oct 6, 2016
1 parent 1aefb4f commit 96ab854
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions conf/control_panel_example.xml
Expand Up @@ -65,6 +65,7 @@
<arg flag="--ac" constant="@AC_ID"/>
</program>
<program name="SVInfo" command="sw/ground_segment/python/svinfo/svinfo.py"/>
<program name="AeronauticalInfo" command="sw/ground_segment/python/atc/atc.py"/>
</section>

<section name="sessions">
Expand Down
Binary file added sw/ground_segment/python/atc/atc.ico
Binary file not shown.
18 changes: 18 additions & 0 deletions sw/ground_segment/python/atc/atc.py
@@ -0,0 +1,18 @@
#!/usr/bin/env python

import wx
import atc_frame

class Atc(wx.App):
def OnInit(self):
self.main = atc_frame.AtcFrame()
self.main.Show()
self.SetTopWindow(self.main)
return True

def main():
application = Atc(0)
application.MainLoop()

if __name__ == '__main__':
main()
108 changes: 108 additions & 0 deletions sw/ground_segment/python/atc/atc_frame.py
@@ -0,0 +1,108 @@
import wx
import sys
import os
import time
import threading
import math
import pynotify
import array
from cStringIO import StringIO



sys.path.append(os.getenv("PAPARAZZI_HOME") + "/sw/ext/pprzlink/lib/v1.0/python")

from pprzlink.ivy import IvyMessagesInterface

WIDTH = 300


class AtcFrame(wx.Frame):

def message_recv(self, ac_id, msg):
if msg.name == "INS_REF":
self.qfe = round(float(msg['baro_qfe']) / 100.0,1)
wx.CallAfter(self.update)
elif msg.name =="ROTORCRAFT_FP_MIN":
self.gspeed = round(float(msg['gspeed']) / 100.0 * 3.6 / 1.852,1)
self.alt = round(float(msg['up']) * 0.0039063 * 3.28084 ,1)
wx.CallAfter(self.update)
elif msg.name =="ROTORCRAFT_FP":
self.alt = round(float(msg['up']) * 0.0039063 * 3.28084 ,1)
wx.CallAfter(self.update)
elif msg.name =="AIR_DATA":
self.airspeed = round(float(msg['airspeed']) * 3.6 / 1.852,1)
self.qnh = round(float(msg['qnh']),1)
self.amsl = round(float(msg['amsl_baro']) * 3.28084,1)
wx.CallAfter(self.update)

def update(self):
self.Refresh()

def OnPaint(self, e):
tdx = 10
tdy = 80

w = self.w
h = self.w


dc = wx.PaintDC(self)
#brush = wx.Brush("white")
#dc.SetBackground(brush)
#dc.Clear()

# Background
dc.SetBrush(wx.Brush(wx.Colour(0,0,0), wx.TRANSPARENT))
#dc.DrawCircle(w/2,w/2,w/2-1)
font = wx.Font(40, wx.ROMAN, wx.BOLD, wx.NORMAL)
dc.SetFont(font)
dc.DrawText("Airspeed: " + str(self.airspeed) + " kt",tdx,tdx)
dc.DrawText("Ground Speed: " + str(self.gspeed) + " kt",tdx,tdx+tdy*1)

dc.DrawText("AMSL: " + str(self.amsl) + " ft",tdx,tdx+tdy*2)
dc.DrawText("QNH: " + str(self.qnh) + " ",tdx,tdx+tdy*3)

dc.DrawText("ALT: " + str(self.alt) + " ",tdx,tdx+tdy*4)
dc.DrawText("QFE: " + str(self.qfe) + " ",tdx,tdx+tdy*5)

#dc.DrawText("HMSL: " + str(self.hmsl) + " ft",tdx,tdx+tdy*6)

#c = wx.Colour(0,0,0)
#dc.SetBrush(wx.Brush(c, wx.SOLID))
#dc.DrawCircle(int(w/2),int(w/2),10)



def __init__(self):

self.w = 900
self.h = 700

self.airspeed = 0;

self.amsl = 0;
self.qnh = 0;

self.qfe = 0;
self.alt = 0;

#self.hmsl = 0;
self.gspeed = 0;

wx.Frame.__init__(self, id=-1, parent=None, name=u'ATC Center',
size=wx.Size(self.w, self.h), title=u'ATC Center')


self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_CLOSE, self.OnClose)

ico = wx.Icon(os.getenv("PAPARAZZI_HOME") + "/sw/ground_segment/python/atc/atc.ico", wx.BITMAP_TYPE_ICO)
self.SetIcon(ico)

self.interface = IvyMessagesInterface("ATC-Center")
self.interface.subscribe(self.message_recv)

def OnClose(self, event):
self.interface.shutdown()
self.Destroy()

0 comments on commit 96ab854

Please sign in to comment.