コード例 #1
0
    def __init__(self, activity=None):
        #Carrega a interface a partir do arquivo glade

        self.activity = activity

        #        if gtk.gtk_version >= (2, 6, 0):
        #            self.gui = gtk.glade.XML('gui/monitor.glade')
        #        else:
        #            self.gui = gtk.glade.XML('gui/monitor-alt.glade')
        self.gui = gtk.glade.XML('gui/monitor.glade')

        self.window = self.gui.get_widget('mainWindow')
        self.statusbar = self.gui.get_widget('statusbar')

        self.GoGo = GoGoComms()

        #self.gui.get_widget('statusbarVersion').push(0,'Versão '+VERSION)
        self.gui.get_widget('statusbarVersion').push(0,
                                                     _('Version ') + VERSION)
        #self.statusbar.set_has_resize_grip(True)

        self.notebookMain = self.gui.get_widget('notebookMain')
        self.liststore = gtk.ListStore(str, str,
                                       str)  # Name, Unit, #Description

        self.sensorsTab = SensorsTab(self.gui, self.liststore)
        self.sensorTypes = self.sensorsTab.sensorTypes
        self.proceduresTab = ProceduresTab(self.gui, self.GoGo, self.statusbar,
                                           self.activity)
        self.uploadTab = UploadTab(self.gui, self.GoGo, self.liststore,
                                   self.sensorTypes, self.activity)
        self.configTab = ConfigTab(self.gui, self.GoGo, self.notebookMain,
                                   self.statusbar, self.activity)
        self.consoleTab = ConsoleTab(self.gui, self.GoGo, self.statusbar,
                                     self.liststore, self.sensorTypes)

        self.notebookMain.reorder_child(
            self.gui.get_widget('vboxConfigurationTab'), -1)
        self.notebookMain.set_current_page(-1)
        self.notebookMain.set_show_tabs(True)

        #Conecta Sinais aos Callbacks:
        dic = {"gtk_main_quit": gtk.main_quit}
        self.gui.signal_autoconnect(dic)
        self.gui.signal_autoconnect(self)
コード例 #2
0
ファイル: monitor.py プロジェクト: yantrabuddhi/blocos
    def __init__(self):
        #Carrega a interface a partir do arquivo glade
        
        self.gui = gtk.glade.XML('gui/monitor.glade')
        self.window = self.gui.get_widget('mainWindow')  
        
        self.GoGo = GoGoComms()

        self.statusbar=self.gui.get_widget('statusbar')
        self.gui.get_widget('statusbarVersion').push(0,'Versão '+VERSION)
        self.notebookMain = self.gui.get_widget('notebookMain')    
        self.liststore=gtk.ListStore(str,str,str) # Name, Unit, #Description
        
        self.sensorsTab     = SensorsTab(self.gui, self.statusbar, self.liststore)
        self.sensorTypes    = self.sensorsTab.sensorTypes        
        self.consoleTab     = ConsoleTab(self.gui, self.GoGo, self.statusbar, self.liststore, self.sensorTypes)
        self.uploadTab      = UploadTab(self.gui, self.GoGo, self.liststore, self.sensorTypes)     
        
        self.notebookMain.set_current_page(0)    
        self.notebookMain.set_show_tabs(True)    
        
        #Conecta Sinais aos Callbacks:        
        dic = {"gtk_main_quit" : gtk.main_quit}
        self.gui.signal_autoconnect(dic)    
        self.gui.signal_autoconnect(self)
        
        self.window.connect("destroy", self.quit)
        
        #Exibe toda interface:
        self.window.show_all() 
        
        # Tenta conectar-se à GogoBoard
        if self.GoGo.autoConnect():
            i = self.GoGo.getPort()
            if os.name == 'nt':
                self.statusbar.push(0,_("GoGo connected on:")+" COM "+str(i+1)+" "+"port")
            else:
                self.statusbar.push(0,_("GoGo connected on:")+" /dev/ttyS"+str(i)+" "+"port")
            
        else:
            print "Gogo not found"
            self.showWarning(_("There was a problem with the connection\nVerify that the board is properly connected with your computer"))
            self.window.destroy()
            return
コード例 #3
0
class BoardMonitor(object):
    def __init__(self, activity=None):
        #Carrega a interface a partir do arquivo glade

        self.activity = activity

        #        if gtk.gtk_version >= (2, 6, 0):
        #            self.gui = gtk.glade.XML('gui/monitor.glade')
        #        else:
        #            self.gui = gtk.glade.XML('gui/monitor-alt.glade')
        self.gui = gtk.glade.XML('gui/monitor.glade')

        self.window = self.gui.get_widget('mainWindow')
        self.statusbar = self.gui.get_widget('statusbar')

        self.GoGo = GoGoComms()

        #self.gui.get_widget('statusbarVersion').push(0,'Versão '+VERSION)
        self.gui.get_widget('statusbarVersion').push(0,
                                                     _('Version ') + VERSION)
        #self.statusbar.set_has_resize_grip(True)

        self.notebookMain = self.gui.get_widget('notebookMain')
        self.liststore = gtk.ListStore(str, str,
                                       str)  # Name, Unit, #Description

        self.sensorsTab = SensorsTab(self.gui, self.liststore)
        self.sensorTypes = self.sensorsTab.sensorTypes
        self.proceduresTab = ProceduresTab(self.gui, self.GoGo, self.statusbar,
                                           self.activity)
        self.uploadTab = UploadTab(self.gui, self.GoGo, self.liststore,
                                   self.sensorTypes, self.activity)
        self.configTab = ConfigTab(self.gui, self.GoGo, self.notebookMain,
                                   self.statusbar, self.activity)
        self.consoleTab = ConsoleTab(self.gui, self.GoGo, self.statusbar,
                                     self.liststore, self.sensorTypes)

        self.notebookMain.reorder_child(
            self.gui.get_widget('vboxConfigurationTab'), -1)
        self.notebookMain.set_current_page(-1)
        self.notebookMain.set_show_tabs(True)

        #Conecta Sinais aos Callbacks:
        dic = {"gtk_main_quit": gtk.main_quit}
        self.gui.signal_autoconnect(dic)
        self.gui.signal_autoconnect(self)

### Main Window Callbacks:

    def imagemenuitemAbout_activate_cb(self, widget):
        about = gtk.AboutDialog()
        about.set_name(NAME)
        about.set_version(VERSION)
        #about.set_copyright(copyright)
        #about.set_comments(comments)
        #about.set_license(license)
        #about.set_wrap_license(license)
        #about.set_website(website)
        #about.set_website_label(website_label)
        about.set_authors(AUTHORS)
        #about.set_documenters(documenters)
        #about.set_artists(artists)
        #about.set_translator_credits(translator_credits)
        #about.set_logo(gtk.gdk.pixbuf_new_from_file("gui/gogo.png"))
        about.set_logo(self.gui.get_widget('imageMonitor').get_pixbuf())
        #about.set_logo_icon_name(icon_name)

        about.run()
        about.destroy()

    def imagemenuitemHelp_activate_cb(self, widget):
        pass
### Board Console Callbacks:

    def buttonBeep_clicked_cb(self, widget):
        self.consoleTab.buttonBeep_clicked_cb(widget)

    def buttonLedOn_clicked_cb(self, widget):
        self.consoleTab.buttonLedOn_clicked_cb(widget)

    def buttonLedOff_clicked_cb(self, widget):
        self.consoleTab.buttonLedOff_clicked_cb(widget)

    def checkbuttonMotor_toggled_cb(self, widget):
        self.consoleTab.checkbuttonMotor_toggled_cb(widget)

    def buttonMotorControlOn_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlOn_clicked_cb(widget)

    def buttonMotorControlOff_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlOff_clicked_cb(widget)

    def buttonMotorControlBreak_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlBreak_clicked_cb(widget)

    def buttonMotorControlCoast_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlCoast_clicked_cb(widget)

    def buttonPowerSet_clicked_cb(self, widget):
        self.consoleTab.buttonPowerSet_clicked_cb(widget)

    def buttonMotorControlThisway_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlThisway_clicked_cb(widget)

    def buttonMotorControlThatway_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlThatway_clicked_cb(widget)

    def buttonMotorControlReverse_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlReverse_clicked_cb(widget)

    # def entryMinPwmDuty_changed_cb(self,widget):
    # print "entryMinPwmDuty_changed_cb"
    # #self.consoleTab.entryMaxPwmDuty_changed_cb(widget)

    # def entryMaxPwmDuty_changed_cb(self,widget):
    # print "entryMaxPwmDuty_changed_cb"
    # #self.consoleTab.entryMaxPwmDuty_changed_cb(widget)

    def entryMinPwmDuty_changed_cb(self, widget):
        self.consoleTab.entryMinPwmDuty_changed_cb(widget)

    def entryMaxPwmDuty_changed_cb(self, widget):
        self.consoleTab.entryMaxPwmDuty_changed_cb(widget)

    def buttonSetPwmDuty_clicked_cb(self, widget):
        print "buttonSetPwmDuty_clicked_cb"
        self.consoleTab.buttonSetPwmDuty_clicked_cb(widget)

    def buttonRefreshAll_clicked_cb(self, widget):
        self.consoleTab.buttonRefreshAll_clicked_cb(widget)

    def buttonSensorBurstOn_clicked_cb(self, widget):
        self.consoleTab.buttonSensorBurstOn_clicked_cb(widget)

    def radiobuttonBurstFast_toggled_cb(self, widget):
        self.consoleTab.radiobuttonBurstFast_toggled_cb(widget)

    def radiobuttonBurstSlow_toggled_cb(self, widget):
        self.consoleTab.radiobuttonBurstSlow_toggled_cb(widget)

    def buttonSensorBurstOff_clicked_cb(self, widget):
        self.consoleTab.buttonSensorBurstOff_clicked_cb(widget)

### /Board Console

### Logo Procedures Callbacks:

    def buttonNew_clicked_cb(self, widget):
        self.proceduresTab.buttonNew_clicked_cb(widget)

    def buttonOpen_clicked_cb(self, widget):
        self.proceduresTab.buttonOpen_clicked_cb(widget)

    def buttonSave_clicked_cb(self, widget):
        self.proceduresTab.buttonSave_clicked_cb(widget)

    def buttonSaveAs_clicked_cb(self, widget):
        self.proceduresTab.buttonSaveAs_clicked_cb(widget)

    def buttonDownload_clicked_cb(self, widget):
        self.proceduresTab.buttonDownload_clicked_cb(widget)
### /Logo Procedures

### Recorded Data Callbacks:

    def buttonStartUpload_clicked_cb(self, widget):
        self.uploadTab.buttonStartUpload_clicked_cb(widget)

    def buttonSaveData_clicked_cb(self, widget):
        self.uploadTab.buttonSaveData_clicked_cb(widget)

    def buttonClearData_clicked_cb(self, widget):
        self.uploadTab.buttonClearData_clicked_cb(widget)

    def spinbuttonColumns_changed_cb(self, widget):
        self.uploadTab.spinbuttonColumns_changed_cb(widget)

    def colSpec_changed_cb(self, widget):
        self.uploadTab.colSpec_changed_cb(widget)

    def checkbuttonShowHeaders_toggled_cb(self, widget):
        self.uploadTab.checkbuttonShowHeaders_toggled_cb(widget)

    def checkbuttonTwoLineHeader_toggled_cb(self, widget):
        self.uploadTab.checkbuttonTwoLineHeader_toggled_cb(widget)

    def notebookDataView_switch_page_cb(self, widget, page, page_num):
        self.uploadTab.notebookDataView_switch_page_cb(widget, page, page_num)

### /Recorded Data

### SensorLab Callbacks:

    def sensorPoint_edited_cb(self, cell, path, new_text, column):
        self.sensorsTab.sensorPoint_edited_cb(cell, path, new_text, column)

    def edited_cb(self, cell, path, new_text, column):
        self.sensorsTab.edited_cb(cell, path, new_text, column)

    def treeviewSensors_cursor_changed_cb(self, treeviewSensors):
        self.sensorsTab.treeviewSensors_cursor_changed_cb(treeviewSensors)

    def buttonAddSensor_clicked_cb(self, widget):
        self.sensorsTab.buttonAddSensor_clicked_cb(widget)

    def buttonRemoveSensor_clicked_cb(self, widget):
        self.sensorsTab.buttonRemoveSensor_clicked_cb(widget)

    def buttonImportSensors_clicked_cb(self, widget):
        self.sensorsTab.buttonImportSensors_clicked_cb(widget)

    def buttonExportSensors_clicked_cb(self, widget):
        self.sensorsTab.buttonExportSensors_clicked_cb(widget)

    def buttonExportSensorsCSV_clicked_cb(self, widget):
        self.sensorsTab.buttonExportSensorsCSV_clicked_cb(widget)

    def buttonInsertPoint_clicked_cb(self, widget):
        self.sensorsTab.buttonInsertPoint_clicked_cb(widget)

    def buttonRemovePoint_clicked_cb(self, widget):
        self.sensorsTab.buttonRemovePoint_clicked_cb(widget)
###/Sensors

### Configuration Callbacks:

    def buttonConnect_clicked_cb(self, widget):
        self.configTab.buttonConnect_clicked_cb(widget)

    def buttonDisconnect_clicked_cb(self, widget):
        self.configTab.buttonDisconnect_clicked_cb(widget)

    def buttonSetLanguage_clicked_cb(self, widget):
        self.configTab.buttonSetLanguage_clicked_cb(widget)
コード例 #4
0
ファイル: monitor.py プロジェクト: yantrabuddhi/blocos
class BoardMonitor(object):
    def showDialog(self,text,dialog_type,parent):
        dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, dialog_type, gtk.BUTTONS_OK, text)
        dialog.run()
        dialog.destroy()
    def showInfo(self,text,parent=None):
        self.showDialog(text,gtk.MESSAGE_INFO,parent)
    def showWarning(self,text,parent=None):
        self.showDialog(text,gtk.MESSAGE_WARNING,parent)
    def showError(self,text,parent=None):
        self.showDialog(text,gtk.MESSAGE_ERROR,parent)
        
    def quit(self, widget):
        self.window = None
        self.GoGo.closePort()
        del self
        
    def __init__(self):
        #Carrega a interface a partir do arquivo glade
        
        self.gui = gtk.glade.XML('gui/monitor.glade')
        self.window = self.gui.get_widget('mainWindow')  
        
        self.GoGo = GoGoComms()

        self.statusbar=self.gui.get_widget('statusbar')
        self.gui.get_widget('statusbarVersion').push(0,'Versão '+VERSION)
        self.notebookMain = self.gui.get_widget('notebookMain')    
        self.liststore=gtk.ListStore(str,str,str) # Name, Unit, #Description
        
        self.sensorsTab     = SensorsTab(self.gui, self.statusbar, self.liststore)
        self.sensorTypes    = self.sensorsTab.sensorTypes        
        self.consoleTab     = ConsoleTab(self.gui, self.GoGo, self.statusbar, self.liststore, self.sensorTypes)
        self.uploadTab      = UploadTab(self.gui, self.GoGo, self.liststore, self.sensorTypes)     
        
        self.notebookMain.set_current_page(0)    
        self.notebookMain.set_show_tabs(True)    
        
        #Conecta Sinais aos Callbacks:        
        dic = {"gtk_main_quit" : gtk.main_quit}
        self.gui.signal_autoconnect(dic)    
        self.gui.signal_autoconnect(self)
        
        self.window.connect("destroy", self.quit)
        
        #Exibe toda interface:
        self.window.show_all() 
        
        # Tenta conectar-se à GogoBoard
        if self.GoGo.autoConnect():
            i = self.GoGo.getPort()
            if os.name == 'nt':
                self.statusbar.push(0,_("GoGo connected on:")+" COM "+str(i+1)+" "+"port")
            else:
                self.statusbar.push(0,_("GoGo connected on:")+" /dev/ttyS"+str(i)+" "+"port")
            
        else:
            print "Gogo not found"
            self.showWarning(_("There was a problem with the connection\nVerify that the board is properly connected with your computer"))
            self.window.destroy()
            return
        
### Main Window Callbacks:
    def imagemenuitemAbout_activate_cb(self,widget):    
        about = gtk.AboutDialog()        
        about.set_name(NAME)
        about.set_version(VERSION)
        #about.set_copyright(copyright)
        #about.set_comments(comments)
        #about.set_license(license)
        #about.set_wrap_license(license)
        #about.set_website(website)
        #about.set_website_label(website_label)
        about.set_authors(AUTHORS)
        #about.set_documenters(documenters)
        #about.set_artists(artists)
        #about.set_translator_credits(translator_credits)    
        #about.set_logo(gtk.gdk.pixbuf_new_from_file("gui/gogo.png"))
        about.set_logo(self.gui.get_widget('imageMonitor').get_pixbuf())
        #about.set_logo_icon_name(icon_name)
        
        about.run()
        about.destroy()
    def imagemenuitemHelp_activate_cb(self,widget):
        pass
### Board Console Callbacks:    
    def buttonBeep_clicked_cb(self, widget):
        self.consoleTab.buttonBeep_clicked_cb(widget)        
        
    def buttonLedOn_clicked_cb(self, widget):
        self.consoleTab.buttonLedOn_clicked_cb(widget)        
        
    def buttonLedOff_clicked_cb(self, widget):
        self.consoleTab.buttonLedOff_clicked_cb(widget)        
       
#    def buttonRun_clicked_cb(self, widget):
#        self.consoleTab.buttonRun_clicked_cb(widget)
        
    def checkbuttonMotor_toggled_cb(self,widget):
        self.consoleTab.checkbuttonMotor_toggled_cb(widget)        
        
    def buttonMotorControlOn_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlOn_clicked_cb(widget)        
    
    def buttonMotorControlOff_clicked_cb(self, widget):        
        self.consoleTab.buttonMotorControlOff_clicked_cb(widget)
    
    def buttonMotorControlBreak_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlBreak_clicked_cb(widget)
        
    def buttonMotorControlCoast_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlCoast_clicked_cb(widget)
    
    def buttonPowerSet_clicked_cb(self, widget):
        self.consoleTab.buttonPowerSet_clicked_cb(widget)
    
    def buttonMotorControlThisway_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlThisway_clicked_cb(widget)
        
    def buttonMotorControlThatway_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlThatway_clicked_cb(widget)
        
    def buttonMotorControlReverse_clicked_cb(self, widget):
        self.consoleTab.buttonMotorControlReverse_clicked_cb(widget)
        
    
    # def entryMinPwmDuty_changed_cb(self,widget):
        # print "entryMinPwmDuty_changed_cb"
        # #self.consoleTab.entryMaxPwmDuty_changed_cb(widget)
            
    # def entryMaxPwmDuty_changed_cb(self,widget):
        # print "entryMaxPwmDuty_changed_cb"
        # #self.consoleTab.entryMaxPwmDuty_changed_cb(widget)
    
    def entryMinPwmDuty_changed_cb(self,widget):
        self.consoleTab.entryMinPwmDuty_changed_cb(widget)
        
    def entryMaxPwmDuty_changed_cb(self,widget):
        self.consoleTab.entryMaxPwmDuty_changed_cb(widget)
        
    def buttonSetPwmDuty_clicked_cb(self,widget):
        print "buttonSetPwmDuty_clicked_cb"
        self.consoleTab.buttonSetPwmDuty_clicked_cb(widget)
    
    def buttonRefreshAll_clicked_cb(self,widget):
        self.consoleTab.buttonRefreshAll_clicked_cb(widget)
    
    def buttonSensorBurstOn_clicked_cb(self,widget):
        self.consoleTab.buttonSensorBurstOn_clicked_cb(widget)
        
    def radiobuttonBurstFast_toggled_cb(self,widget):
        self.consoleTab.radiobuttonBurstFast_toggled_cb(widget)
            
    def radiobuttonBurstSlow_toggled_cb(self,widget):
        self.consoleTab.radiobuttonBurstSlow_toggled_cb(widget)
    
    def buttonSensorBurstOff_clicked_cb(self,widget):
        self.consoleTab.buttonSensorBurstOff_clicked_cb(widget)    
    
        
### /Board Console    
    
### Upload Data Callbacks:    
    def buttonStartUpload_clicked_cb(self,widget):
        self.uploadTab.buttonStartUpload_clicked_cb(widget)
        
    def buttonSaveData_clicked_cb(self,widget):
        self.uploadTab.buttonSaveData_clicked_cb(widget)
        
    def buttonClearData_clicked_cb(self,widget):
        self.uploadTab.buttonClearData_clicked_cb(widget)
        
    def spinbuttonColumns_changed_cb(self,widget):
        self.uploadTab.spinbuttonColumns_changed_cb(widget)
        
    def colSpec_changed_cb(self,widget):
        self.uploadTab.colSpec_changed_cb(widget)
        
    def checkbuttonShowHeaders_toggled_cb(self,widget):
        self.uploadTab.checkbuttonShowHeaders_toggled_cb(widget)
        
    def checkbuttonTwoLineHeader_toggled_cb(self,widget):
        self.uploadTab.checkbuttonTwoLineHeader_toggled_cb(widget)
            
    def notebookDataView_switch_page_cb(self,widget,page,page_num):
        self.uploadTab.notebookDataView_switch_page_cb(widget,page,page_num)
        
### /Recorded Data

    
### SensorLab Callbacks:
    def sensorPoint_edited_cb(self,cell, path, new_text, column):
        self.sensorsTab.sensorPoint_edited_cb(cell, path, new_text, column)    
        
    def treeviewSensors_edited_cb(self,cell, path, new_text, column):        
        self.sensorsTab.edited_cb(cell, path, new_text, column)        
            
    def treeviewSensors_cursor_changed_cb(self,treeviewSensors):
        self.sensorsTab.treeviewSensors_cursor_changed_cb(treeviewSensors)    
    
    def buttonAddSensor_clicked_cb(self,widget):
        self.sensorsTab.buttonAddSensor_clicked_cb(widget)        
        
    def buttonRemoveSensor_clicked_cb(self,widget):
        self.sensorsTab.buttonRemoveSensor_clicked_cb(widget)
    
    def buttonImportSensors_clicked_cb(self,widget):
        self.sensorsTab.buttonImportSensors_clicked_cb(widget)
        
    def buttonExportSensors_clicked_cb(self,widget):
        self.sensorsTab.buttonExportSensors_clicked_cb(widget)
        
    def buttonExportSensorsCSV_clicked_cb(self,widget):
        self.sensorsTab.buttonExportSensorsCSV_clicked_cb(widget)
    
    def buttonInsertPoint_clicked_cb(self,widget):
        self.sensorsTab.buttonInsertPoint_clicked_cb(widget)
            
    def buttonRemovePoint_clicked_cb(self,widget):
        self.sensorsTab.buttonRemovePoint_clicked_cb(widget)