OpenCores
URL https://opencores.org/ocsvn/phr/phr/trunk

Subversion Repositories phr

[/] [phr/] [trunk/] [codigo/] [gui/] [linux/] [phr-gui.py] - Diff between revs 213 and 217

Show entire file | Details | Blame | View Log

Rev 213 Rev 217
Line 4... Line 4...
 
 
import wx
import wx
# imports by maximiq
# imports by maximiq
import os          # se usa para el dialogo de abrir fichero
import os          # se usa para el dialogo de abrir fichero
import subprocess  # para interactuar con el shell
import subprocess  # para interactuar con el shell
 
import thread      # to prevent gui blocking
 
 
#####################################
#####################################
# Para que funcione mejor en Linux
# Para que funcione mejor en Linux
#import os
#import os
 
 
Line 189... Line 190...
 
 
        dialog.Destroy()
        dialog.Destroy()
 
 
        event.Skip()
        event.Skip()
 
 
    def boton_conf_fpga(self, event): # wxGlade: MyFrame.<event_handler>
    def before_run (self):
        #funcion editada por maximiq
        ## preparar entorno para los eventos conf_fpga prog_prom comprobar_conexion
 
 
        ## preparar entorno
 
        self.button_conf_fpga.Disable()
        self.button_conf_fpga.Disable()
        self.button_prog_prom.Disable()
        self.button_prog_prom.Disable()
        self.button_conection.Disable()
        self.button_conection.Disable()
        self.button_empty.Disable()
        self.button_empty.Disable()
        self.frame_1_statusbar.SetFields(["Espere ..."])
        self.frame_1_statusbar.SetFields(["Espere ..."])
 
 
 
    def after_run (self):
 
        ## restaurar entorno 
 
        self.button_conf_fpga.Enable()
 
        self.button_prog_prom.Enable()
 
        self.button_conection.Enable()
 
        self.button_empty.Enable()
 
        self.frame_1_statusbar.SetFields(["Listo"])
 
 
 
    def boton_conf_fpga_thread(self):
 
        ## preparar entorno
 
        wx.CallAfter(self.before_run)
 
 
        ## accion
        ## accion
        # se copia el fichero de programacion al directorio local
        # se copia el fichero de programacion al directorio local
        #subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
        #subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
 
 
        # se ejecuta el xc3sprog
        # se ejecuta el xc3sprog
        command = "./xc3sprog/xc3sprog -v -c ftdi -p 0 \""+ self.text_ctrl_file.GetValue() + "\":w:0:BIT"
        command = "./xc3sprog/xc3sprog -v -c ftdi -p 0 \""+ self.text_ctrl_file.GetValue() + "\":w:0:BIT"
 
 
        self.text_ctrl_console.AppendText(command + "\n")
        wx.CallAfter(self.text_ctrl_console.AppendText, command + "\n")
 
 
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
 
        for line in iter(process.stdout.readline, ''):
        for line in iter(process.stdout.readline, ''):
            self.text_ctrl_console.AppendText(line)
            wx.CallAfter(self.text_ctrl_console.AppendText, line)
        process.stdout.close()
        process.stdout.close()
 
 
        self.text_ctrl_console.AppendText("\nPHR>>> ")
        wx.CallAfter(self.text_ctrl_console.AppendText, "\nPHR>>> ")
 
 
        ## restaurar entorno 
        ## restaurar entorno 
        self.button_conf_fpga.Enable()
        wx.CallAfter(self.after_run)
        self.button_prog_prom.Enable()
 
        self.button_conection.Enable()
 
        self.button_empty.Enable()
 
        self.frame_1_statusbar.SetFields(["Listo"])
 
 
 
 
    def boton_conf_fpga(self, event): # wxGlade: MyFrame.<event_handler>
 
        #funcion editada por maximiq
 
        thread.start_new_thread(self.boton_conf_fpga_thread, ())
        event.Skip()
        event.Skip()
 
 
    def boton_prog_prom(self, event): # wxGlade: MyFrame.<event_handler>
    def boton_prog_prom_thread(self):
        #funcion editada por maximiq
        #funcion editada por maximiq
 
 
        ## preparar entorno
        ## preparar entorno
        self.button_conf_fpga.Disable()
        wx.CallAfter(self.before_run)
        self.button_prog_prom.Disable()
 
        self.button_conection.Disable()
 
        self.button_empty.Disable()
 
        self.frame_1_statusbar.SetFields(["Espere ..."])
 
 
 
        ## accion
        ## accion
 
 
        # se copia el fichero de programacion al directorio local
        # se copia el fichero de programacion al directorio local
        #subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
        #subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
 
 
        command = "./xc3sprog/xc3sprog -v -c ftdi -p 1 \"" + self.text_ctrl_file.GetValue() + "\":w:0:BIT"
        command = "./xc3sprog/xc3sprog -v -c ftdi -p 1 \"" + self.text_ctrl_file.GetValue() + "\":w:0:BIT"
 
 
        self.text_ctrl_console.AppendText(command + "\n")
        wx.CallAfter(self.text_ctrl_console.AppendText, command + "\n")
 
 
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
 
        for line in iter(process.stdout.readline, ''):
        for line in iter(process.stdout.readline, ''):
            self.text_ctrl_console.AppendText(line)
            wx.CallAfter(self.text_ctrl_console.AppendText, line)
        process.stdout.close()
        process.stdout.close()
#        line = ''
#        line = ''
#        while True:
#        while True:
#            out = process.stdout.read(1)
#            out = process.stdout.read(1)
#            if out == '' and process.poll() != None:
#            if out == '' and process.poll() != None:
Line 260... Line 266...
#                line = line + out
#                line = line + out
#                if out == '\x0d':
#                if out == '\x0d':
#                    self.text_ctrl_console.AppendText(line)
#                    self.text_ctrl_console.AppendText(line)
#                    line = ''
#                    line = ''
 
 
        self.text_ctrl_console.AppendText("\nPHR>>> ")
        wx.CallAfter(self.text_ctrl_console.AppendText, "\nPHR>>> ")
 
 
        ## restaurar entorno 
        ## restaurar entorno 
        self.button_conf_fpga.Enable()
        wx.CallAfter(self.after_run)
        self.button_prog_prom.Enable()
 
        self.button_conection.Enable()
 
        self.button_empty.Enable()
 
        self.frame_1_statusbar.SetFields(["Listo"])
 
 
 
        event.Skip()
 
 
 
    def boton_conexion(self, event): # wxGlade: MyFrame.<event_handler>
    def boton_prog_prom(self, event): # wxGlade: MyFrame.<event_handler>
        #funcion editada por maximiq
        #funcion editada por maximiq
 
        thread.start_new_thread(self.boton_prog_prom_thread, ())
 
        event.Skip()
 
 
 
    def boton_conexion_thread (self):
        ## preparar entorno
        ## preparar entorno
        self.button_conf_fpga.Disable()
        wx.CallAfter(self.before_run, )
        self.button_prog_prom.Disable()
 
        self.button_conection.Disable()
 
        self.button_empty.Disable()
 
        self.frame_1_statusbar.SetFields(["Espere ..."])
 
 
 
        ## accion
        ## accion
        command = "./xc3sprog/xc3sprog -c ftdi"  # the shell command
        command = "./xc3sprog/xc3sprog -c ftdi"  # the shell command
 
 
        self.text_ctrl_console.AppendText(command + "\n")
        wx.CallAfter(self.text_ctrl_console.AppendText, command + "\n")
 
 
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
 
 
        for line in iter(process.stdout.readline, ''):
        for line in iter(process.stdout.readline, ''):
            self.text_ctrl_console.AppendText(line)
            wx.CallAfter(self.text_ctrl_console.AppendText, line)
        process.stdout.close()
        process.stdout.close()
 
 
        self.text_ctrl_console.AppendText("\nPHR>>> ")
        wx.CallAfter(self.text_ctrl_console.AppendText, "\nPHR>>> ")
 
 
        ## restaurar entorno 
        ## restaurar entorno 
        self.button_conf_fpga.Enable()
        wx.CallAfter(self.after_run, )
        self.button_prog_prom.Enable()
 
        self.button_conection.Enable()
 
        self.button_empty.Enable()
 
        self.frame_1_statusbar.SetFields(["Listo"])
 
 
 
 
 
 
    def boton_conexion(self, event): # wxGlade: MyFrame.<event_handler>
 
        #funcion editada por maximiq
 
        thread.start_new_thread(self.boton_conexion_thread, ())
        event.Skip()
        event.Skip()
 
 
    def boton_borrar(self, event): # wxGlade: MyFrame.<event_handler>
    def boton_borrar(self, event): # wxGlade: MyFrame.<event_handler>
        #funcion editada por maximiq
        #funcion editada por maximiq
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.