Exemplo n.º 1
0
    def __init__(self, parent, index, color, channelsizer):
        self.parent = parent
        self.index = index
        self.color = color
        self.readCommand = None
        self.readCommandSuffix = ''

        self.enable = 1
        self.enableID = wx.NewId()
        self.enableTB = wx.ToggleButton(parent, self.enableID, _("Enabled"))
        EVT_TOGGLEBUTTON(parent, self.enableID, self.OnEnableToggle)

        self.sigID = wx.NewId()
        self.sigBut = wx.Button(parent, self.sigID, _("Signal"))
        EVT_BUTTON(parent, self.sigID, self.OnSignal)

        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.sigBut, 1, wx.EXPAND | wx.ALL, 2)
        self.sizer.Add(self.enableTB, 2, wx.EXPAND | wx.ALL, 2)

        self.gainLB = wx.StaticText(parent,
                                    wx.NewId(),
                                    _("Gain"),
                                    style=wx.ALIGN_RIGHT)

        self.gain = 1.0
        self.gainID = wx.NewId()
        self.gainSC = wxSpinSequence(parent, self.gainID, -1000.0, 1000.0,
                                     self.gain, [1, 2, 5])
        EVT_TEXT(parent, self.gainID, self.OnGain)

        self.gainbox = wx.BoxSizer(wx.HORIZONTAL)
        self.gainbox.Add(self.gainLB, 1, wx.EXPAND | wx.ALL, 2)
        self.gainbox.Add(self.gainSC, 2, wx.EXPAND | wx.ALL, 2)

        self.offsLB = wx.StaticText(parent,
                                    wx.NewId(),
                                    _("Offset"),
                                    style=wx.ALIGN_RIGHT)

        self.offs = index + 1.0
        self.offsID = wx.NewId()
        self.offsSC = wxSpinSequence(parent, self.offsID, -1000.0, 1000.0,
                                     self.offs, [1, 2, 5])
        EVT_TEXT(parent, self.offsID, self.OnOffs)

        self.offsbox = wx.BoxSizer(wx.HORIZONTAL)
        self.offsbox.Add(self.offsLB, 1, wx.EXPAND | wx.ALL, 2)
        self.offsbox.Add(self.offsSC, 2, wx.EXPAND | wx.ALL, 2)

        self.box = wx.StaticBoxSizer(
            wx.StaticBox(parent, -1,
                         _("Channel ") + str(index)), wx.VERTICAL)
        self.box.Add(self.sizer, 0, wx.EXPAND | wx.ALL, 2)
        self.box.Add(self.gainbox, 0, wx.EXPAND | wx.ALL, 2)
        self.box.Add(self.offsbox, 0, wx.EXPAND | wx.ALL, 2)
        channelsizer.Add(self.box, 1, wx.EXPAND | wx.ALL, 2)
Exemplo n.º 2
0
    def __init__(self,parent,index,color,channelsizer):
        self.parent = parent
        self.index  = index
        self.color  = color
        self.readCommand = None
        self.readCommandSuffix = ''

        self.enable   = 1
        self.enableID = wx.NewId()
        self.enableTB = wx.ToggleButton(parent, self.enableID, _("Enabled"))
        EVT_TOGGLEBUTTON(parent, self.enableID, self.OnEnableToggle)

        self.sigID = wx.NewId()
        self.sigBut = wx.Button(parent, self.sigID, _("Signal"))
        EVT_BUTTON(parent, self.sigID, self.OnSignal)

        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.sigBut,   1, wx.EXPAND|wx.ALL, 2)
        self.sizer.Add(self.enableTB, 2, wx.EXPAND|wx.ALL, 2)
                   
        self.gainLB = wx.StaticText(parent, wx.NewId(), _("Gain"),   style=wx.ALIGN_RIGHT)

        self.gain   = 1.0
        self.gainID = wx.NewId()
        self.gainSC = wxSpinSequence(parent,self.gainID,-1000.0,1000.0,self.gain,[1,2,5])
        EVT_TEXT(parent, self.gainID, self.OnGain)
        
        self.gainbox = wx.BoxSizer(wx.HORIZONTAL)
        self.gainbox.Add(self.gainLB, 1, wx.EXPAND|wx.ALL, 2)
        self.gainbox.Add(self.gainSC, 2, wx.EXPAND|wx.ALL, 2)
        
        self.offsLB = wx.StaticText(parent, wx.NewId(), _("Offset"), style=wx.ALIGN_RIGHT)

        self.offs   = index+1.0
        self.offsID = wx.NewId()
        self.offsSC = wxSpinSequence(parent,self.offsID,-1000.0,1000.0,self.offs,[1,2,5])
        EVT_TEXT(parent,self.offsID, self.OnOffs) 

        self.offsbox = wx.BoxSizer(wx.HORIZONTAL)
        self.offsbox.Add(self.offsLB, 1, wx.EXPAND|wx.ALL, 2)
        self.offsbox.Add(self.offsSC, 2, wx.EXPAND|wx.ALL, 2)            
        
        self.box = wx.StaticBoxSizer(wx.StaticBox(parent, -1, _("Channel ")+str(index)), wx.VERTICAL)
        self.box.Add(self.sizer,   0, wx.EXPAND|wx.ALL, 2)
        self.box.Add(self.gainbox, 0, wx.EXPAND|wx.ALL, 2)
        self.box.Add(self.offsbox, 0, wx.EXPAND|wx.ALL, 2)
        channelsizer.Add(self.box, 1, wx.EXPAND|wx.ALL, 2)
Exemplo n.º 3
0
    def __init__ (self,frame,taskManager,nchannels=4):
        wx.Frame.__init__ (self,frame,-1,_("Oscilloscope"))
        self.SetSize((800, 600))

        self.taskManager = taskManager
        self.nMax      = 1000 
        self.status    = "idle"    
        if nchannels > 4: nchannels = 4   
        self.nchannels = nchannels       
        
        self.timerID = wx.NewId()
        self.timer   = wx.Timer(self,self.timerID)
        EVT_TIMER(self,self.timerID,self.OnTestTimer)      
        self.timer.mutex = 0
        
        self.valuerangeLB = wx.StaticText(self, wx.NewId(), _("Value Range"), style = wx.ALIGN_CENTRE)

        self.valuerangeID = wx.NewId()
        self.valuerangeSC = wxSpinSequence(self, self.valuerangeID, 0.001, 1000.0, self.nchannels+1, [1,2,5])
        EVT_TEXT(self, self.valuerangeID, self.OnValueSpinCtrl) 

        self.timerangeLB = wx.StaticText(self, wx.NewId(), _("Time Range [s]"), style = wx.ALIGN_CENTRE)

        self.timerangeID = wx.NewId()
        self.timerangeSC = wxSpinSequence(self, self.timerangeID, 1.0, 1000000.0, 2.0, [1,2,5])
        EVT_TEXT(self, self.timerangeID, self.OnTimeSpinCtrl) 
                 
        timerangesizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Settings"), wx.VERTICAL)
        #PKAZ: following not valid
        #timerangesizer.Add(1, 1, 1, wx.EXPAND)
        timerangesizer.Add(self.valuerangeLB, 0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        timerangesizer.Add(self.valuerangeSC, 0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        timerangesizer.Add(self.timerangeLB,  0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        timerangesizer.Add(self.timerangeSC,  0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        
        channelsizer = wx.BoxSizer(wx.HORIZONTAL)
        channelsizer.Add(timerangesizer, 0, wx.EXPAND|wx.ALL, 2)

        self.colors   = ['red','blue','green','cyan']
        self.channels = []
        for index in range(0,self.nchannels):
            color   = self.colors[index]
            channel = Cchannel(self,index,color,channelsizer)
            self.channels.append(channel)

        self.plot = PlotCanvas(self)
        self.ResetTimeData()
        self.ResetChartData()
        self.ResetPlotData()
        self.CreatePlotGraphics()
        self.ResetPlotAxis()
       
        #Create mouse event for showing cursor coords in status bar
        #
        EVT_LEFT_DOWN(self.plot, self.OnMouseLeftDown)
        
        startbuttonID = wx.NewId()
        startbutton   = wx.Button(self, startbuttonID, _("Start"))
        EVT_BUTTON(self, startbuttonID, self.OnTestStart )        

        stopbuttonID  = wx.NewId()
        stopbutton    = wx.Button(self, stopbuttonID,  _("Stop"))
        EVT_BUTTON(self, stopbuttonID,  self.OnTestStop  )        

        closebuttonID = wx.NewId()
        closebutton   = wx.Button(self, closebuttonID, _("Close"))
        EVT_BUTTON(self, closebuttonID, self.OnClose )        

        leiste = wx.BoxSizer(wx.HORIZONTAL)
        leiste.Add(startbutton, 1, wx.EXPAND|wx.ALL, 10)
        leiste.Add(stopbutton,  1, wx.EXPAND|wx.ALL, 10)
        leiste.Add(closebutton, 1, wx.EXPAND|wx.ALL, 10)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(channelsizer, 0, wx.EXPAND|wx.ALL, 2)
        sizer.Add(self.plot,    1, wx.EXPAND|wx.ALL, 2)
        sizer.Add(leiste,       0, wx.EXPAND|wx.ALL, 2)

        self.SetSizer(sizer)

        # Now Create the menu bar and items
        #
        self.mainmenu = wx.MenuBar()

        menu = wx.Menu()
        menu.Append(200, 'Page Setup...', 'Setup the printer page')
        EVT_MENU(self, 200, self.OnFilePageSetup)
        
        menu.Append(201, 'Print Preview...', 'Show the current plot on page')
        EVT_MENU(self, 201, self.OnFilePrintPreview)
        
        menu.Append(202, 'Print...', 'Print the current plot')
        EVT_MENU(self, 202, self.OnFilePrint)
        
        menu.Append(203, 'Save Plot...', 'Save current plot')
        EVT_MENU(self, 203, self.OnSaveFile)
        
        menu.Append(205, 'E&xit', 'Enough of this already!')
        EVT_MENU(self, 205, self.OnFileExit)

        self.mainmenu.Append(menu, '&File')

        menu = wx.Menu()
        menu.Append(207, 'Start', 'Start moving plot')
        EVT_MENU(self,207,self.OnTestStart)

        menu.Append(209, 'Stop', 'Stop moving plot')
        EVT_MENU(self,209,self.OnTestStop)
         
        menu.Append(211, '&Redraw', 'Redraw plots')
        EVT_MENU(self,211,self.OnPlotRedraw)

        menu.Append(212, '&Clear', 'Clear canvas')
        EVT_MENU(self,212,self.OnPlotClear)

        menu.Append(213, '&Scale', 'Scale canvas')
        EVT_MENU(self,213,self.OnPlotScale) 

        menu.Append(214, 'Enable &Zoom', 'Enable Mouse Zoom', kind=wx.ITEM_CHECK)
        EVT_MENU(self,214,self.OnEnableZoom) 

        menu.Append(215, 'Enable &Grid', 'Turn on Grid', kind=wx.ITEM_CHECK)
        EVT_MENU(self,215,self.OnEnableGrid)

        menu.Append(220, 'Enable &Legend', 'Turn on Legend', kind=wx.ITEM_CHECK)
        EVT_MENU(self,220,self.OnEnableLegend) 

        menu.Append(225, 'Scroll Up 1', 'Move View Up 1 Unit')
        EVT_MENU(self,225,self.OnScrUp) 

        menu.Append(230, 'Scroll Rt 2', 'Move View Right 2 Units')
        EVT_MENU(self,230,self.OnScrRt)

        menu.Append(235, '&Plot Reset', 'Reset to original plot')
        EVT_MENU(self,235,self.OnReset)

        self.mainmenu.Append(menu, '&Plot')

        menu = wx.Menu()
        menu.Append(300, '&About', 'About this thing...')
        EVT_MENU(self, 300, self.OnHelpAbout)

        self.mainmenu.Append(menu, '&Help')

        self.SetMenuBar(self.mainmenu)

        # A status bar to tell people what's happening
        #
        self.CreateStatusBar(1)

        EVT_CLOSE(self, self.OnClose)

        self.Show(True)
Exemplo n.º 4
0
    def __init__ (self,frame,taskManager,nchannels=4):
        wx.Frame.__init__ (self,frame,-1,_("Oscilloscope"))
        self.SetSize((800, 600))

        self.taskManager = taskManager
        self.nMax      = 1000 
        self.status    = "idle"    
        if nchannels > 4: nchannels = 4   
        self.nchannels = nchannels       
        
        self.timerID = wx.NewId()
        self.timer   = wx.Timer(self,self.timerID)
        EVT_TIMER(self,self.timerID,self.OnTestTimer)      
        self.timer.mutex = 0
        
        self.valuerangeLB = wx.StaticText(self, wx.NewId(), _("Value Range"), style = wx.ALIGN_CENTRE)

        self.valuerangeID = wx.NewId()
        self.valuerangeSC = wxSpinSequence(self, self.valuerangeID, 0.001, 1000.0, self.nchannels+1, [1,2,5])
        EVT_TEXT(self, self.valuerangeID, self.OnValueSpinCtrl) 

        self.timerangeLB = wx.StaticText(self, wx.NewId(), _("Time Range [s]"), style = wx.ALIGN_CENTRE)

        self.timerangeID = wx.NewId()
        self.timerangeSC = wxSpinSequence(self, self.timerangeID, 1.0, 1000000.0, 2.0, [1,2,5])
        EVT_TEXT(self, self.timerangeID, self.OnTimeSpinCtrl) 
                 
        timerangesizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Settings"), wx.VERTICAL)
        #PKAZ: following not valid
        #timerangesizer.Add(1, 1, 1, wx.EXPAND)
        timerangesizer.Add(self.valuerangeLB, 0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        timerangesizer.Add(self.valuerangeSC, 0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        timerangesizer.Add(self.timerangeLB,  0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        timerangesizer.Add(self.timerangeSC,  0, wx.ALIGN_BOTTOM|wx.ALL, 2)
        
        channelsizer = wx.BoxSizer(wx.HORIZONTAL)
        channelsizer.Add(timerangesizer, 0, wx.EXPAND|wx.ALL, 2)

        self.colors   = ['red','blue','green','cyan']
        self.channels = []
        for index in range(0,self.nchannels):
            color   = self.colors[index]
            channel = Cchannel(self,index,color,channelsizer)
            self.channels.append(channel)

        self.plot = PlotCanvas(self)
        self.ResetTimeData()
        self.ResetChartData()
        self.ResetPlotData()
        self.CreatePlotGraphics()
        self.ResetPlotAxis()
       
        #Create mouse event for showing cursor coords in status bar
        #
        EVT_LEFT_DOWN(self.plot, self.OnMouseLeftDown)
        
        startbuttonID = wx.NewId()
        startbutton   = wx.Button(self, startbuttonID, _("Start"))
        EVT_BUTTON(self, startbuttonID, self.OnTestStart )        

        stopbuttonID  = wx.NewId()
        stopbutton    = wx.Button(self, stopbuttonID,  _("Stop"))
        EVT_BUTTON(self, stopbuttonID,  self.OnTestStop  )        

        closebuttonID = wx.NewId()
        closebutton   = wx.Button(self, closebuttonID, _("Close"))
        EVT_BUTTON(self, closebuttonID, self.OnClose )        

        leiste = wx.BoxSizer(wx.HORIZONTAL)
        leiste.Add(startbutton, 1, wx.EXPAND|wx.ALL, 10)
        leiste.Add(stopbutton,  1, wx.EXPAND|wx.ALL, 10)
        leiste.Add(closebutton, 1, wx.EXPAND|wx.ALL, 10)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(channelsizer, 0, wx.EXPAND|wx.ALL, 2)
        sizer.Add(self.plot,    1, wx.EXPAND|wx.ALL, 2)
        sizer.Add(leiste,       0, wx.EXPAND|wx.ALL, 2)

        self.SetSizer(sizer)

        # Now Create the menu bar and items
        #
        self.mainmenu = wx.MenuBar()

        menu = wx.Menu()
        menu.Append(200, 'Page Setup...', 'Setup the printer page')
        EVT_MENU(self, 200, self.OnFilePageSetup)
        
        menu.Append(201, 'Print Preview...', 'Show the current plot on page')
        EVT_MENU(self, 201, self.OnFilePrintPreview)
        
        menu.Append(202, 'Print...', 'Print the current plot')
        EVT_MENU(self, 202, self.OnFilePrint)
        
        menu.Append(203, 'Save Plot...', 'Save current plot')
        EVT_MENU(self, 203, self.OnSaveFile)
        
        menu.Append(205, 'E&xit', 'Enough of this already!')
        EVT_MENU(self, 205, self.OnFileExit)

        self.mainmenu.Append(menu, '&File')

        menu = wx.Menu()
        menu.Append(207, 'Start', 'Start moving plot')
        EVT_MENU(self,207,self.OnTestStart)

        menu.Append(209, 'Stop', 'Stop moving plot')
        EVT_MENU(self,209,self.OnTestStop)
         
        menu.Append(211, '&Redraw', 'Redraw plots')
        EVT_MENU(self,211,self.OnPlotRedraw)

        menu.Append(212, '&Clear', 'Clear canvas')
        EVT_MENU(self,212,self.OnPlotClear)

        menu.Append(213, '&Scale', 'Scale canvas')
        EVT_MENU(self,213,self.OnPlotScale) 

        menu.Append(214, 'Enable &Zoom', 'Enable Mouse Zoom', kind=wx.ITEM_CHECK)
        EVT_MENU(self,214,self.OnEnableZoom) 

        menu.Append(215, 'Enable &Grid', 'Turn on Grid', kind=wx.ITEM_CHECK)
        EVT_MENU(self,215,self.OnEnableGrid)

        menu.Append(220, 'Enable &Legend', 'Turn on Legend', kind=wx.ITEM_CHECK)
        EVT_MENU(self,220,self.OnEnableLegend) 

        menu.Append(225, 'Scroll Up 1', 'Move View Up 1 Unit')
        EVT_MENU(self,225,self.OnScrUp) 

        menu.Append(230, 'Scroll Rt 2', 'Move View Right 2 Units')
        EVT_MENU(self,230,self.OnScrRt)

        menu.Append(235, '&Plot Reset', 'Reset to original plot')
        EVT_MENU(self,235,self.OnReset)

        self.mainmenu.Append(menu, '&Plot')

        menu = wx.Menu()
        menu.Append(300, '&About', 'About this thing...')
        EVT_MENU(self, 300, self.OnHelpAbout)

        self.mainmenu.Append(menu, '&Help')

        self.SetMenuBar(self.mainmenu)

        # A status bar to tell people what's happening
        #
        self.CreateStatusBar(1)

        EVT_CLOSE(self, self.OnClose)

        self.Show(True)