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

Subversion Repositories phr

[/] [phr/] [trunk/] [codigo/] [gui/] [linux/] [phr-gui.py] - Blame information for rev 213

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 213 maximiq
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# generated by wxGlade 0.6.3 on Wed Mar 26 16:29:14 2014
4
 
5
import wx
6
# imports by maximiq
7
import os          # se usa para el dialogo de abrir fichero
8
import subprocess  # para interactuar con el shell
9
 
10
#####################################
11
# Para que funcione mejor en Linux
12
#import os
13
 
14
abspath = os.path.abspath(__file__)
15
dname = os.path.dirname(abspath)
16
os.chdir(dname)
17
#####################################
18
 
19
# begin wxGlade: extracode
20
# end wxGlade
21
 
22
 
23
 
24
class MyFrame(wx.Frame):
25
    def __init__(self, *args, **kwds):
26
        # begin wxGlade: MyFrame.__init__
27
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
28
        wx.Frame.__init__(self, *args, **kwds)
29
        self.frame_1_statusbar = self.CreateStatusBar(1, 0)
30
        self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("grafica/banner.jpg", wx.BITMAP_TYPE_ANY))
31
        self.button_help = wx.Button(self, -1, "  Ayuda  ")
32
        self.button_about = wx.Button(self, -1, "  Acerca de  ")
33
        self.text_ctrl_file = wx.TextCtrl(self, -1, "")
34
        self.button_choose_file = wx.Button(self, -1, "Elegir fichero")
35
        self.button_conf_fpga = wx.Button(self, -1, "Configurar FPGA")
36
        self.button_prog_prom = wx.Button(self, -1, "Programar PROM")
37
        self.text_ctrl_console = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
38
        self.button_conection = wx.Button(self, -1, u"  Comprobar conexión  ")
39
        self.button_empty = wx.Button(self, -1, "  Borrar salida  ")
40
 
41
        self.__set_properties()
42
        self.__do_layout()
43
 
44
        self.Bind(wx.EVT_BUTTON, self.boton_ayuda, self.button_help)
45
        self.Bind(wx.EVT_BUTTON, self.boton_acerca_de, self.button_about)
46
        self.Bind(wx.EVT_BUTTON, self.boton_elegir_fichero, self.button_choose_file)
47
        self.Bind(wx.EVT_BUTTON, self.boton_conf_fpga, self.button_conf_fpga)
48
        self.Bind(wx.EVT_BUTTON, self.boton_prog_prom, self.button_prog_prom)
49
        self.Bind(wx.EVT_BUTTON, self.boton_conexion, self.button_conection)
50
        self.Bind(wx.EVT_BUTTON, self.boton_borrar, self.button_empty)
51
        # end wxGlade
52
 
53
    def __set_properties(self):
54
        # begin wxGlade: MyFrame.__set_properties
55
        self.SetTitle("PHR GUI")
56
        _icon = wx.EmptyIcon()
57
        _icon.CopyFromBitmap(wx.Bitmap("grafica/phr-gui.ico", wx.BITMAP_TYPE_ANY))
58
        self.SetIcon(_icon)
59
        self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
60
        self.frame_1_statusbar.SetStatusWidths([-1])
61
        # statusbar fields
62
        frame_1_statusbar_fields = ["Listo"]
63
        for i in range(len(frame_1_statusbar_fields)):
64
            self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
65
        self.text_ctrl_console.SetMinSize((-1, 150))
66
        # end wxGlade
67
        # start maximiq
68
        font1 = self.text_ctrl_console.GetFont()
69
        font1 = wx.Font(font1.GetPointSize(), wx.TELETYPE,
70
                       font1.GetStyle(),
71
                       font1.GetWeight(), font1.GetUnderlined())
72
        self.text_ctrl_console.SetFont(font1)
73
        #font1 = wx.Font(9, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')
74
        #self.text_ctrl_console.SetFont(font1)
75
        self.text_ctrl_console.SetValue("PHR>>> ")
76
 
77
    def __do_layout(self):
78
        # begin wxGlade: MyFrame.__do_layout
79
        grid_sizer_1 = wx.FlexGridSizer(5, 1, 0, 0)
80
        grid_sizer_2 = wx.GridSizer(1, 2, 0, 0)
81
        grid_sizer_4 = wx.GridSizer(1, 2, 0, 0)
82
        grid_sizer_5 = wx.FlexGridSizer(1, 2, 0, 0)
83
        grid_sizer_6 = wx.FlexGridSizer(1, 2, 0, 0)
84
        grid_sizer_7 = wx.FlexGridSizer(2, 1, 0, 0)
85
        grid_sizer_6.Add(self.bitmap_1, 0, wx.ALL, 5)
86
        grid_sizer_7.Add(self.button_help, 0, wx.RIGHT|wx.TOP|wx.BOTTOM|wx.EXPAND, 5)
87
        grid_sizer_7.Add(self.button_about, 0, wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
88
        grid_sizer_6.Add(grid_sizer_7, 1, wx.EXPAND, 0)
89
        grid_sizer_6.AddGrowableCol(1)
90
        grid_sizer_1.Add(grid_sizer_6, 1, wx.EXPAND, 0)
91
        grid_sizer_5.Add(self.text_ctrl_file, 0, wx.ALL|wx.EXPAND, 5)
92
        grid_sizer_5.Add(self.button_choose_file, 0, wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
93
        grid_sizer_5.AddGrowableCol(0)
94
        grid_sizer_1.Add(grid_sizer_5, 1, wx.EXPAND, 0)
95
        grid_sizer_4.Add(self.button_conf_fpga, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
96
        grid_sizer_4.Add(self.button_prog_prom, 0, wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
97
        grid_sizer_1.Add(grid_sizer_4, 1, wx.EXPAND, 0)
98
        grid_sizer_1.Add(self.text_ctrl_console, 0, wx.ALL|wx.EXPAND, 5)
99
        grid_sizer_2.Add(self.button_conection, 0, wx.LEFT|wx.BOTTOM, 5)
100
        grid_sizer_2.Add(self.button_empty, 0, wx.RIGHT|wx.BOTTOM|wx.ALIGN_RIGHT, 5)
101
        grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
102
        self.SetSizer(grid_sizer_1)
103
        grid_sizer_1.Fit(self)
104
        grid_sizer_1.SetSizeHints(self)
105
        grid_sizer_1.AddGrowableRow(3)
106
        grid_sizer_1.AddGrowableCol(0)
107
        self.Layout()
108
        # end wxGlade
109
 
110
    def OnAboutBox(self):
111
 
112
        description = """
113
PHR GUI es una interfaz grafica que permite interactuar con
114
la Plataforma de Hardware Reconfigurable (desarrollada en el
115
CUDAR) a traves del software xc3sprog.
116
 
117
Revision (SVN) 209.
118
"""
119
 
120
        licence = """
121
PHR GUI is free software; you can redistribute it and/or modify
122
it under the terms of the GNU General Public License as
123
published by the Free Software Foundation; either version 2
124
of the License, or (at your option) any later version.
125
 
126
PHR GUI is distributed in the hope that it will be useful,
127
but WITHOUT ANY WARRANTY; without even the implied warranty of
128
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
129
See the GNU General Public License for more details. You should have
130
received a copy of the GNU General Public License along with
131
PHR GUI; if not, write to the Free Software Foundation, Inc.,
132
59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
133
"""
134
 
135
 
136
        info = wx.AboutDialogInfo()
137
 
138
        info.SetIcon(wx.Icon('grafica/phr-gui-96.png', wx.BITMAP_TYPE_PNG))
139
        info.SetName('PHR GUI')
140
        info.SetVersion('0.1')
141
        info.SetDescription(description)
142
        #info.SetCopyright('(C) 2014 CUDAR (UTN-FRC)')
143
        info.SetCopyright('Abril de 2014, CUDAR (UTN-FRC)')
144
        info.SetWebSite('http://opencores.org/project,phr')
145
        #info.SetLicence(licence)
146
        info.AddDeveloper('Luis Guanuco, Maximiliano Quinteros.')
147
 
148
 
149
        wx.AboutBox(info)
150
 
151
    def ShowHelpMessage(self):
152
        mensaje = """
153
Procedimiento para usar este programa:
154
 
155
Para configurar la FPGA:
156
1) Setear el jumper en la placa PHR en modo JTAG.
157
2) Elegir el archivo de configuracion (*.bit).
158
3) Presione el boton \"Configurar FPGA\".
159
4) Tras terminar el paso anterior la FPGA debe comenzar a funcionar.
160
 
161
Para programar la memoria PROM:
162
1) Setear el jumper en la placa PHR en modo \"Master Serial\".
163
2) Elegir el archivo de programacion (*.bit).
164
3) Presione el boton \"Programar PROM\".
165
4) Una vez terminado el paso anterior, presionar el boton de RESET.
166
 
167
Mas ayuda en los manuales que puede descargar desde el servidor de
168
OpenCores donde se aloja el proyecto: http://opencores.org/project,phr
169
"""
170
        wx.MessageBox(mensaje, 'Info',
171
            wx.OK | wx.ICON_INFORMATION)
172
 
173
    def boton_ayuda(self, event): # wxGlade: MyFrame.<event_handler>
174
        self.ShowHelpMessage()
175
        event.Skip()
176
 
177
    def boton_acerca_de(self, event): # wxGlade: MyFrame.<event_handler>
178
        self.OnAboutBox()
179
        event.Skip()
180
 
181
    def boton_elegir_fichero(self, event): # wxGlade: MyFrame.<event_handler>
182
        #funcion editada por maximiq
183
 
184
        wildcard = "Archivo BIT de Xilinx (*.bit)|*.bit|" \
185
                   "Todos los archivos (*.*)|*.*"
186
        dialog = wx.FileDialog(None, "Elija un archivo", os.getcwd(), "", wildcard, wx.OPEN)
187
        if dialog.ShowModal() == wx.ID_OK:
188
            self.text_ctrl_file.SetValue(dialog.GetPath())
189
 
190
        dialog.Destroy()
191
 
192
        event.Skip()
193
 
194
    def boton_conf_fpga(self, event): # wxGlade: MyFrame.<event_handler>
195
        #funcion editada por maximiq
196
 
197
        ## preparar entorno
198
        self.button_conf_fpga.Disable()
199
        self.button_prog_prom.Disable()
200
        self.button_conection.Disable()
201
        self.button_empty.Disable()
202
        self.frame_1_statusbar.SetFields(["Espere ..."])
203
 
204
        ## accion
205
        # se copia el fichero de programacion al directorio local
206
        #subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
207
 
208
        # se ejecuta el xc3sprog
209
        command = "./xc3sprog/xc3sprog -v -c ftdi -p 0 \""+ self.text_ctrl_file.GetValue() + "\":w:0:BIT"
210
 
211
        self.text_ctrl_console.AppendText(command + "\n")
212
 
213
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
214
 
215
        for line in iter(process.stdout.readline, ''):
216
            self.text_ctrl_console.AppendText(line)
217
        process.stdout.close()
218
 
219
        self.text_ctrl_console.AppendText("\nPHR>>> ")
220
 
221
        ## restaurar entorno 
222
        self.button_conf_fpga.Enable()
223
        self.button_prog_prom.Enable()
224
        self.button_conection.Enable()
225
        self.button_empty.Enable()
226
        self.frame_1_statusbar.SetFields(["Listo"])
227
 
228
        event.Skip()
229
 
230
    def boton_prog_prom(self, event): # wxGlade: MyFrame.<event_handler>
231
        #funcion editada por maximiq
232
 
233
        ## preparar entorno
234
        self.button_conf_fpga.Disable()
235
        self.button_prog_prom.Disable()
236
        self.button_conection.Disable()
237
        self.button_empty.Disable()
238
        self.frame_1_statusbar.SetFields(["Espere ..."])
239
 
240
        ## accion
241
 
242
        # se copia el fichero de programacion al directorio local
243
        #subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
244
 
245
        command = "./xc3sprog/xc3sprog -v -c ftdi -p 1 \"" + self.text_ctrl_file.GetValue() + "\":w:0:BIT"
246
 
247
        self.text_ctrl_console.AppendText(command + "\n")
248
 
249
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
250
 
251
        for line in iter(process.stdout.readline, ''):
252
            self.text_ctrl_console.AppendText(line)
253
        process.stdout.close()
254
#        line = ''
255
#        while True:
256
#            out = process.stdout.read(1)
257
#            if out == '' and process.poll() != None:
258
#                break
259
#            if out != '' and out != '\x0a':
260
#                line = line + out
261
#                if out == '\x0d':
262
#                    self.text_ctrl_console.AppendText(line)
263
#                    line = ''
264
 
265
        self.text_ctrl_console.AppendText("\nPHR>>> ")
266
 
267
        ## restaurar entorno 
268
        self.button_conf_fpga.Enable()
269
        self.button_prog_prom.Enable()
270
        self.button_conection.Enable()
271
        self.button_empty.Enable()
272
        self.frame_1_statusbar.SetFields(["Listo"])
273
 
274
        event.Skip()
275
 
276
    def boton_conexion(self, event): # wxGlade: MyFrame.<event_handler>
277
        #funcion editada por maximiq
278
 
279
        ## preparar entorno
280
        self.button_conf_fpga.Disable()
281
        self.button_prog_prom.Disable()
282
        self.button_conection.Disable()
283
        self.button_empty.Disable()
284
        self.frame_1_statusbar.SetFields(["Espere ..."])
285
 
286
        ## accion
287
        command = "./xc3sprog/xc3sprog -c ftdi"  # the shell command
288
 
289
        self.text_ctrl_console.AppendText(command + "\n")
290
 
291
        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
292
 
293
        for line in iter(process.stdout.readline, ''):
294
            self.text_ctrl_console.AppendText(line)
295
        process.stdout.close()
296
 
297
        self.text_ctrl_console.AppendText("\nPHR>>> ")
298
 
299
        ## restaurar entorno 
300
        self.button_conf_fpga.Enable()
301
        self.button_prog_prom.Enable()
302
        self.button_conection.Enable()
303
        self.button_empty.Enable()
304
        self.frame_1_statusbar.SetFields(["Listo"])
305
 
306
        event.Skip()
307
 
308
    def boton_borrar(self, event): # wxGlade: MyFrame.<event_handler>
309
        #funcion editada por maximiq
310
 
311
        ## accion
312
        self.text_ctrl_console.SetValue("PHR>>> ") # borra todo el contenido
313
 
314
        event.Skip()
315
 
316
# end of class MyFrame
317
 
318
 
319
if __name__ == "__main__":
320
    app = wx.App(False)
321
    frame_1 = MyFrame(None, -1, "")
322
    app.SetTopWindow(frame_1)
323
    frame_1.Show()
324
    app.MainLoop()

powered by: WebSVN 2.1.0

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