def __init__(self):
        self.ttimer = 100

        self.conf = Conf()
        self.home = self.conf.home
        self.currentpath = self.home + self.conf.get(
            'GENERAL', 'op_folder') + '/openplotter'

        Language(self.conf)

        self.list_iter = []

        titleadd = ''
        if len(sys.argv) > 2:
            titleadd = sys.argv[2]

        wx.Frame.__init__(self, None, title=titleadd, size=(650, 435))
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        panel = wx.Panel(self, wx.ID_ANY)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.timer_act, self.timer)

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.currentpath + '/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.logger = wx.TextCtrl(panel,
                                  style=wx.TE_MULTILINE | wx.TE_READONLY
                                  | wx.TE_DONTWRAP | wx.LC_SORT_ASCENDING)

        self.list = wx.ListCtrl(panel,
                                -1,
                                style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.list.InsertColumn(0, _('Device'), width=50)
        self.list.InsertColumn(1, _('Type'), width=50)
        self.list.InsertColumn(2,
                               _('Interval'),
                               wx.LIST_FORMAT_RIGHT,
                               width=50)
        self.list.InsertColumn(3, _('Data'), width=500)

        self.button_pause = wx.Button(panel, label=_('Pause'), pos=(555, 160))
        self.button_pause.Bind(wx.EVT_BUTTON, self.pause)

        sort = wx.Button(panel, label=_('Sort'), pos=(555, 200))
        sort.Bind(wx.EVT_BUTTON, self.sort)

        nmea = wx.Button(panel, label=_('NMEA info'), pos=(555, 240))
        nmea.Bind(wx.EVT_BUTTON, self.nmea_info)

        self.pause_all = 0

        htextbox = wx.BoxSizer(wx.HORIZONTAL)
        htextbox.Add(self.logger, 1, wx.ALL | wx.EXPAND, 5)

        hlistbox = wx.BoxSizer(wx.HORIZONTAL)
        hlistbox.Add(self.list, 1, wx.ALL | wx.EXPAND, 5)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self.button_pause, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(sort, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(nmea, 0, wx.RIGHT | wx.LEFT, 5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(htextbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hlistbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 0)
        panel.SetSizer(vbox)

        self.CreateStatusBar()

        self.Show(True)

        self.s2 = ''
        self.status = ''
        self.data = []
        self.baudc = 0
        self.baud = 0

        self.timer.Start(self.ttimer)
Beispiel #2
0
# Openplotter is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Openplotter. If not, see <http://www.gnu.org/licenses/>.

import socket, time, pynmea2, RTIMU, math, csv
from classes.paths import Paths
from classes.conf import Conf

paths=Paths()
currentpath=paths.currentpath

conf=Conf()

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

nmea_hdg_b = conf.get('STARTUP', 'nmea_hdg')=='1'
nmea_heel_b = conf.get('STARTUP', 'nmea_heel')=='1'
nmea_pitch_b = conf.get('STARTUP', 'nmea_pitch')=='1'
poll_interval = 1

imu_b = False
pressure_val_b = False
humidity_val_b = False
log_list_b = False

nmea_press_b = conf.get('STARTUP', 'nmea_press')=='1'
nmea_temp_p_b = conf.get('STARTUP', 'nmea_temp_p')=='1'
Beispiel #3
0
    def __init__(self):
        # This creates a UDP socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

        # This opens the OpenPlotter configuration file in ~/.openplotter/openplotter.conf
        self.conf = Conf()

        Language(self.conf)

        title = _('Demo tool')

        wx.Frame.__init__(self, None, title=title, size=(600, 360))

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(op_folder + '/static/icons/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        panel = wx.Panel(self)

        info = wx.StaticText(
            panel,
            label=_('To create tools see ~/.openplotter/tools/README.md.'))

        # Getting info from OpenPlotter configuration file. When reading from demo tool conf file or OpenPlotter conf file, if section or option do not exist, they will be created with no value.
        op_data_box = wx.StaticBox(panel, -1, _(' OpenPlotter config data '))
        version = _('OpenPlotter version: ').decode('utf8') + self.conf.get(
            'GENERAL', 'version') + ' ' + self.conf.get('GENERAL', 'state')
        text1 = wx.StaticText(panel, label=version)

        sk_key_box = wx.StaticBox(panel, -1, _(' Working with Signal K '))
        text2 = wx.StaticText(panel, label=_('Select a Signal K key'))
        self.SKkey = wx.TextCtrl(panel, style=wx.CB_READONLY)
        self.SKkey.SetValue(conf2.get('SIGNALK', 'key'))
        self.edit_skkey = wx.Button(panel, label=_('Edit'))
        # This uses the OpenPlotter class to select a signal k key
        self.edit_skkey.Bind(wx.EVT_BUTTON, self.onEditSkkey)
        text3 = wx.StaticText(panel, label=_('Write some text to publish'))
        self.data = wx.TextCtrl(panel)
        self.data.SetValue(conf2.get('SIGNALK', 'data'))
        self.button_publish = wx.Button(panel, label=_('Publish'))
        self.button_publish.Bind(wx.EVT_BUTTON, self.onPublish)

        button_cancel = wx.Button(panel, label=_('Cancel'))
        self.Bind(wx.EVT_BUTTON, self.on_cancel, button_cancel)

        button_ok = wx.Button(panel, label=_('OK'))
        self.Bind(wx.EVT_BUTTON, self.on_ok, button_ok)

        v_boxSizer1 = wx.StaticBoxSizer(op_data_box, wx.VERTICAL)
        v_boxSizer1.AddSpacer(5)
        v_boxSizer1.Add(text1, 0, wx.ALL | wx.EXPAND, 5)

        h_boxSizer1 = wx.BoxSizer(wx.HORIZONTAL)
        h_boxSizer1.Add(self.SKkey, 1, wx.ALL | wx.EXPAND, 5)
        h_boxSizer1.Add(self.edit_skkey, 0, wx.ALL | wx.EXPAND, 5)

        h_boxSizer2 = wx.BoxSizer(wx.HORIZONTAL)
        h_boxSizer2.Add(self.data, 1, wx.ALL | wx.EXPAND, 5)
        h_boxSizer2.Add(self.button_publish, 0, wx.ALL | wx.EXPAND, 5)

        v_boxSizer2 = wx.StaticBoxSizer(sk_key_box, wx.VERTICAL)
        v_boxSizer2.AddSpacer(5)
        v_boxSizer2.Add(text2, 0, wx.ALL | wx.EXPAND, 5)
        v_boxSizer2.Add(h_boxSizer1, 0, wx.ALL | wx.EXPAND, 5)
        v_boxSizer2.Add(text3, 0, wx.ALL | wx.EXPAND, 5)
        v_boxSizer2.Add(h_boxSizer2, 0, wx.ALL | wx.EXPAND, 5)

        buttons = wx.BoxSizer(wx.HORIZONTAL)
        buttons.Add((0, 0), 1, wx.ALL | wx.EXPAND, 0)
        buttons.Add(button_cancel, 0, wx.ALL | wx.EXPAND, 10)
        buttons.Add(button_ok, 0, wx.ALL | wx.EXPAND, 10)

        vbox3 = wx.BoxSizer(wx.VERTICAL)
        vbox3.Add(info, 0, wx.ALL | wx.EXPAND, 10)
        vbox3.Add(v_boxSizer1, 0, wx.ALL | wx.EXPAND, 5)
        vbox3.Add(v_boxSizer2, 0, wx.ALL | wx.EXPAND, 5)
        vbox3.Add(buttons, 0, wx.ALL | wx.EXPAND, 0)

        panel.SetSizer(vbox3)

        self.Centre()
    def __init__(self):
        self.ttimer = 40

        self.conf = Conf()
        self.home = self.conf.home
        self.currentpath = self.home + self.conf.get(
            'GENERAL', 'op_folder') + '/openplotter'

        try:
            self.ser = serial.Serial(self.conf.get('N2K', 'can_usb'),
                                     115200,
                                     timeout=0.5)
        except:
            print 'failed to start N2K input diagnostic on ' + self.conf.get(
                'N2K', 'can_usb')
            sys.exit(0)

        Language(self.conf)

        list_N2K_txt = []
        self.list_N2K = []
        with open(self.currentpath + '/classes/N2K_PGN.csv') as f:
            list_N2K_txt = [x.strip('\n\r').split(',') for x in f.readlines()]

        for ii in list_N2K_txt:
            pgn = int(ii[0])
            self.list_N2K.append([pgn, ii[1]])

        self.Buffer = [0] * 500
        self.Zustand = 6
        self.list_iter = []

        wx.Frame.__init__(self,
                          None,
                          title='diagnostic N2K input',
                          size=(650, 435))
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        panel = wx.Panel(self, wx.ID_ANY)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.timer_act, self.timer)

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.currentpath + '/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.list = wx.ListCtrl(panel,
                                -1,
                                style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.list.InsertColumn(0, _('PGN'), wx.LIST_FORMAT_RIGHT, width=62)
        self.list.InsertColumn(1, _('SRC'), wx.LIST_FORMAT_RIGHT, width=38)
        self.list.InsertColumn(2, _('DST'), wx.LIST_FORMAT_RIGHT, width=38)
        self.list.InsertColumn(3, _('Name'), width=180)
        self.list.InsertColumn(4,
                               _('Interval'),
                               wx.LIST_FORMAT_RIGHT,
                               width=45)
        self.list.InsertColumn(5, _('Data'), width=350)

        sort_SRC = wx.Button(panel, label=_('Sort SRC'))
        sort_SRC.Bind(wx.EVT_BUTTON, self.on_sort_SRC)

        sort_PGN = wx.Button(panel, label=_('Sort PGN'))
        sort_PGN.Bind(wx.EVT_BUTTON, self.on_sort_PGN)

        hlistbox = wx.BoxSizer(wx.HORIZONTAL)
        hlistbox.Add(self.list, 1, wx.ALL | wx.EXPAND, 5)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(sort_SRC, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(sort_PGN, 0, wx.RIGHT | wx.LEFT, 5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(hlistbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 0)
        panel.SetSizer(vbox)

        self.CreateStatusBar()

        self.Show(True)

        self.status = ''
        self.data = []
        self.baudc = 0
        self.baud = 0

        self.timer.Start(self.ttimer)
Beispiel #5
0
    def __init__(self):

        self.conf = Conf()
        Language(self.conf.get('GENERAL', 'lang'))

        wx.Frame.__init__(self, None, title=_('Connection'), size=(550, 385))

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(currentpath + '/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.in_out = sys.argv[1]
        self.con_type = sys.argv[2]

        wx.StaticText(self, label=_('Name'), pos=(25, 35))
        self.name = wx.TextCtrl(self, -1, size=(120, 32), pos=(20, 55))

        if self.con_type == 'serial':
            if self.in_out == 'in':
                wx.StaticBox(self,
                             label=_(' Serial input '),
                             size=(530, 90),
                             pos=(10, 10))
            if self.in_out == 'out':
                wx.StaticBox(self,
                             label=_(' Serial output '),
                             size=(530, 90),
                             pos=(10, 10))
            self.SerDevLs = []
            self.SerialCheck('/dev/rfcomm')
            self.SerialCheck('/dev/ttyUSB')
            self.SerialCheck('/dev/ttyS')
            self.SerialCheck('/dev/ttyACM')
            self.SerialCheck('/dev/ttyAMA')
            wx.StaticText(self, label=_('Port'), pos=(155, 35))
            self.deviceComboBox = wx.ComboBox(self,
                                              choices=self.SerDevLs,
                                              style=wx.CB_DROPDOWN,
                                              size=(155, 32),
                                              pos=(150, 55))
            if self.SerDevLs: self.deviceComboBox.SetValue(self.SerDevLs[0])
            self.bauds = ['4800', '9600', '19200', '38400', '57600', '115200']
            wx.StaticText(self, label=_('Bauds'), pos=(320, 35))
            self.baudComboBox = wx.ComboBox(self,
                                            choices=self.bauds,
                                            style=wx.CB_READONLY,
                                            size=(90, 32),
                                            pos=(315, 55))
            self.baudComboBox.SetValue('4800')

        if self.con_type == 'network':
            if self.in_out == 'in':
                wx.StaticBox(self,
                             label=_(' Network input '),
                             size=(530, 90),
                             pos=(10, 10))
                self.gpsd = wx.Button(self, label=_('GPSD'), pos=(440, 55))
                self.Bind(wx.EVT_BUTTON, self.create_gpsd, self.gpsd)
            if self.in_out == 'out':
                wx.StaticBox(self,
                             label=_(' Network output '),
                             size=(530, 90),
                             pos=(10, 10))
            self.type = ['TCP', 'UDP']
            wx.StaticText(self, label=_('Type'), pos=(155, 35))
            self.typeComboBox = wx.ComboBox(self,
                                            choices=self.type,
                                            style=wx.CB_READONLY,
                                            size=(70, 32),
                                            pos=(150, 55))
            self.typeComboBox.SetValue('TCP')
            wx.StaticText(self, label=_('Address'), pos=(235, 35))
            self.address = wx.TextCtrl(self, -1, size=(120, 32), pos=(230, 55))
            wx.StaticText(self, label=_('Port'), pos=(365, 35))
            self.port = wx.TextCtrl(self, -1, size=(55, 32), pos=(360, 55))

        wx.StaticBox(self, label=_(' Filter '), size=(530, 195), pos=(10, 105))
        self.mode_filter = [
            _('none'),
            _('Accept only sentences:'),
            _('Ignore sentences:')
        ]
        self.filter = wx.ComboBox(self,
                                  choices=self.mode_filter,
                                  style=wx.CB_READONLY,
                                  size=(220, 32),
                                  pos=(20, 130))
        self.filter.SetValue(self.mode_filter[0])
        wx.StaticText(self, label=_('Filtering'), pos=(25, 175))
        self.sentences = wx.TextCtrl(self,
                                     -1,
                                     style=wx.CB_READONLY,
                                     size=(400, 32),
                                     pos=(20, 195))
        self.sentences.SetBackgroundColour(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_INACTIVECAPTION))
        self.delete = wx.Button(self, label=_('Delete'), pos=(440, 195))
        self.Bind(wx.EVT_BUTTON, self.delete_sentences, self.delete)
        wx.StaticText(self, label=_('Talker - Sentence'), pos=(25, 240))
        self.talker = wx.TextCtrl(self, -1, size=(35, 32), pos=(20, 260))
        wx.StaticText(self, label=_('-'), pos=(60, 265))
        self.sent = wx.TextCtrl(self, -1, size=(45, 32), pos=(70, 260))
        self.add_sent = wx.Button(self,
                                  label=_('Add sentence'),
                                  pos=(160, 260))
        self.Bind(wx.EVT_BUTTON, self.add_sentence, self.add_sent)

        self.sentences.SetValue(_('nothing'))
        self.talker.SetValue('**')
        self.sent.SetValue('***')

        self.ok = wx.Button(self, label=_('OK'), pos=(440, 310))
        self.Bind(wx.EVT_BUTTON, self.ok_conn, self.ok)
        self.cancel = wx.Button(self, label=_('Cancel'), pos=(330, 310))
        self.Bind(wx.EVT_BUTTON, self.cancel_conn, self.cancel)

        self.Centre()
    def __init__(self):
        Quelle = '127.0.0.1'  # Adresse des eigenen Rechners
        Port = 55560

        self.e_udp_sock = socket.socket(socket.AF_INET,
                                        socket.SOCK_DGRAM)  #s.o.
        self.e_udp_sock.bind((Quelle, Port))
        self.e_udp_sock.settimeout(1)

        self.ttimer = 20
        self.conf = Conf()
        self.home = self.conf.home
        self.currentpath = self.conf.get('GENERAL', 'op_folder')

        Language(self.conf)
        print self.conf.get('GENERAL', 'lang')

        list_N2K_txt = []
        self.list_N2K = []
        with open(self.currentpath + '/classes/N2K_PGN.csv') as f:
            list_N2K_txt = [x.strip('\n\r').split(',') for x in f.readlines()]

        for ii in list_N2K_txt:
            pgn = int(ii[0])
            self.list_N2K.append([pgn, ii[1]])

        self.Buffer = [0] * 500
        self.Zustand = 6
        self.list_iter = []

        wx.Frame.__init__(self,
                          None,
                          title='diagnostic N2K output',
                          size=(650, 435))
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        panel = wx.Panel(self, wx.ID_ANY)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.timer_act, self.timer)

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.currentpath + '/static/icons/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.list = wx.ListCtrl(panel,
                                -1,
                                style=wx.LC_REPORT | wx.SUNKEN_BORDER,
                                size=(540, 370),
                                pos=(5, 5))
        self.list.InsertColumn(0, _('PGN'), wx.LIST_FORMAT_RIGHT, width=62)
        self.list.InsertColumn(1, _('SRC'), wx.LIST_FORMAT_RIGHT, width=38)
        self.list.InsertColumn(2, _('DST'), wx.LIST_FORMAT_RIGHT, width=38)
        self.list.InsertColumn(3, _('Name'), width=180)
        self.list.InsertColumn(4,
                               _('Interval'),
                               wx.LIST_FORMAT_RIGHT,
                               width=45)
        self.list.InsertColumn(5, _('Data'), width=350)

        sort_SRC = wx.Button(panel, label=_('Sort SRC'))
        sort_SRC.Bind(wx.EVT_BUTTON, self.on_sort_SRC)

        sort_PGN = wx.Button(panel, label=_('Sort PGN'))
        sort_PGN.Bind(wx.EVT_BUTTON, self.on_sort_PGN)

        hlistbox = wx.BoxSizer(wx.HORIZONTAL)
        hlistbox.Add(self.list, 1, wx.ALL | wx.EXPAND, 5)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(sort_SRC, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(sort_PGN, 0, wx.RIGHT | wx.LEFT, 5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(hlistbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 0)
        panel.SetSizer(vbox)

        self.CreateStatusBar()

        self.Show(True)

        self.status = ''
        self.data = []

        self.timer.Start(self.ttimer)