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

Subversion Repositories phr

[/] [phr/] [trunk/] [codigo/] [gui/] [windows/] [gui/] [phr-gui.py] - Blame information for rev 182

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

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

powered by: WebSVN 2.1.0

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