OpenASIP 2.2
Loading...
Searching...
No Matches
OperationImplementationResourceDialog.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2017 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24 /**
25 * @file FUGENResourceDialog.cc
26 *
27 * Implementation of FUGENResourceDialog.
28 *
29 * @author Lasse Lehtonen 2017 (lasse.lehtonen-no.spam-tut.fi)
30 */
31
33#include "HDBEditor.hh"
34#include "HDBManager.hh"
36#include "HDBBrowserWindow.hh"
38
39
40wxDEFINE_EVENT(BUTTON_SYN_VHDL, wxFileDirPickerEvent);
41wxDEFINE_EVENT(BUTTON_SIM_VHDL, wxFileDirPickerEvent);
42wxDEFINE_EVENT(BUTTON_SYN_VERILOG, wxFileDirPickerEvent);
43wxDEFINE_EVENT(BUTTON_SIM_VERILOG, wxFileDirPickerEvent);
44wxDEFINE_EVENT(BUTTON_IPXACT, wxFileDirPickerEvent);
45wxDEFINE_EVENT(BUTTON_DEL, wxCommandEvent);
46
47BEGIN_EVENT_TABLE(OperationImplementationResourceDialog, wxDialog)
49 EVT_FILEPICKER_CHANGED(BUTTON_SYN_VHDL,
51 EVT_FILEPICKER_CHANGED(BUTTON_SIM_VHDL,
53 EVT_FILEPICKER_CHANGED(BUTTON_SYN_VERILOG,
54 OperationImplementationResourceDialog::onAddVerilogSynFile)
55 EVT_FILEPICKER_CHANGED(BUTTON_SIM_VERILOG,
56 OperationImplementationResourceDialog::onAddVerilogSimFile)
57 EVT_BUTTON(wxID_DELETE,
60
61/// Constructor
64 : wxDialog(NULL, -1, "Add Operation Implementation Resource",
65 wxDefaultPosition, wxSize(600, 480))
66{
67 wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
68 wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
69
70 wxButton *okButton = new wxButton(this, wxID_OK, wxT("Ok"),
71 wxDefaultPosition, wxSize(70, 30));
72 wxButton *closeButton = new wxButton(this, wxID_CANCEL, wxT("Cancel"),
73 wxDefaultPosition, wxSize(70, 30));
74
75 wxButton *delButton = new wxButton(this , wxID_DELETE, wxT(""));
76
77 hbox1->Add(okButton, 1);
78 hbox1->Add(closeButton, 1, wxLEFT, 5);
79
80 wxFlexGridSizer *flex1 = new wxFlexGridSizer(7, 2, 9, 25);
81
82 wxStaticText *title1 = new wxStaticText(
83 this, -1, wxT("Name"));
84 wxStaticText *title2 = new wxStaticText(
85 this, -1, wxT("VHDL Synthesis file"));
86 wxStaticText *title3 = new wxStaticText(
87 this, -1, wxT("VHDL Simulation file"));
88 wxStaticText *title4 = new wxStaticText(
89 this, -1, wxT("Verilog Synthesis file"));
90 wxStaticText *title5 = new wxStaticText(
91 this, -1, wxT("Verilog Simulation file"));
92 wxStaticText *title7 = new wxStaticText(
93 this, -1, wxT("IP-XACT component file"));
94 wxStaticText *title6 = new wxStaticText(
95 this, -1, wxT("Selected files"));
96
97 nameCtrl_ = new wxTextCtrl(this, -1);
98
99 wxFilePickerCtrl *pick1 = new wxFilePickerCtrl(this, BUTTON_SYN_VHDL,
100 "", "Select VHDL Synthesis File", "*.vhd;*.vhdl",
101 wxDefaultPosition, wxDefaultSize,
102 wxFLP_OPEN | wxFLP_FILE_MUST_EXIST | wxFLP_SMALL);
103 wxFilePickerCtrl *pick2 = new wxFilePickerCtrl(this, BUTTON_SIM_VHDL,
104 "", "Select VHDL Simulation File", "*.vhd;*.vhdl",
105 wxDefaultPosition, wxDefaultSize,
106 wxFLP_OPEN | wxFLP_FILE_MUST_EXIST | wxFLP_SMALL);
107 wxFilePickerCtrl *pick3 = new wxFilePickerCtrl(this, BUTTON_SYN_VERILOG,
108 "", "Select Verilog Synthesis File", "*.vh;*.v",
109 wxDefaultPosition, wxDefaultSize,
110 wxFLP_OPEN | wxFLP_FILE_MUST_EXIST | wxFLP_SMALL);
111 wxFilePickerCtrl *pick4 = new wxFilePickerCtrl(this, BUTTON_SIM_VERILOG,
112 "", "Select Verilog Simulation File", "*.vh;*.v",
113 wxDefaultPosition, wxDefaultSize,
114 wxFLP_OPEN | wxFLP_FILE_MUST_EXIST | wxFLP_SMALL);
115 ipxactPick_ = new wxFilePickerCtrl(this, BUTTON_IPXACT,
116 "", "Select IP-XACT component File", "*.xml",
117 wxDefaultPosition, wxDefaultSize,
118 wxFLP_OPEN | wxFLP_FILE_MUST_EXIST | wxFLP_SMALL);
119
120 flex1->Add(title1);
121 flex1->Add(nameCtrl_, 1, wxEXPAND);
122 flex1->Add(title2);
123 flex1->Add(pick1, 1, wxEXPAND);
124 flex1->Add(title3);
125 flex1->Add(pick2, 1, wxEXPAND);
126 flex1->Add(title4);
127 flex1->Add(pick3, 1, wxEXPAND);
128 flex1->Add(title5);
129 flex1->Add(pick4, 1, wxEXPAND);
130 flex1->Add(title7);
131 flex1->Add(ipxactPick_, 1, wxEXPAND);
132 flex1->Add(title6);
133 flex1->Add(delButton, 1, wxEXPAND);
134
135
136 fileList1_ = new wxListCtrl(this, -1,
137 wxDefaultPosition, wxDefaultSize, wxLC_REPORT);
138 fileList1_->AppendColumn("File", wxLIST_FORMAT_LEFT, 400);
139 fileList1_->AppendColumn("Type", wxLIST_FORMAT_LEFT, 150);
140
141 vbox->Add(flex1, 1, wxALL | wxEXPAND, 15);
142 vbox->Add(fileList1_, 1, wxALL | wxEXPAND, 15);
143 vbox->Add(hbox1, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);
144
145 SetSizer(vbox);
146 Centre();
147 ShowModal();
148 Destroy();
149}
150
151void
154 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
155
156 resource.name = nameCtrl_->GetLineText(0);
157 if (resource.name.length() < 1) {
158 wxMessageBox( wxT("Give the resource a name."),
159 wxT("Error"), wxICON_ERROR);
160 return;
161 }
162
163 long items = fileList1_->GetItemCount();
164 for (int i = 0; i < items; ++i) {
165 std::string file = fileList1_->GetItemText(i, 0).ToStdString();
166 std::string type = fileList1_->GetItemText(i, 1).ToStdString();
167 if (type == manager->formatString(
169 resource.synFiles.emplace_back(file);
170 resource.synFormats.emplace_back(type);
171 } else if (type == manager->formatString(
173 resource.simFiles.emplace_back(file);
174 resource.simFormats.emplace_back(type);
175 }
176 else if (type == manager->formatString(
178 resource.synFiles.emplace_back(file);
179 resource.synFormats.emplace_back(type);
180 }
181 else if (type == manager->formatString(
183 resource.simFiles.emplace_back(file);
184 resource.simFormats.emplace_back(type);
185 } else {
186 wxMessageBox( wxT("Unknown file type."),
187 wxT("Error"), wxICON_ERROR);
188 return;
189 }
190 }
191
192 resource.ipxact = sanitize(ipxactPick_->GetPath());
193 if (resource.ipxact.length() < 1) {
194 wxMessageBox(wxT("Give the IP-XACT component file."),
195 wxT("Error"), wxICON_ERROR);
196 return;
197 }
198
199 manager->addOperationImplementationResource(resource);
200 wxGetApp().mainFrame().browser()->update();
201 EndModal(wxID_OK);
202}
203
204std::string
206 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
207 std::string es(path);
208 std::string s(manager->fileName());
209 size_t i = s.rfind('/', s.length());
210 if (i != std::string::npos) {
211 s = s.substr(0, i+1);
212 if (es.find(s) == 0) {
213 return es.substr(s.length());
214 }
215 }
216 return es;
217}
218
219
220void
222 wxFileDirPickerEvent& e) {
223 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
224 int idx = fileList1_->GetItemCount();
225 fileList1_->InsertItem(idx, sanitize(e.GetPath()));
226 fileList1_->SetItem(idx, 1, manager->formatString(
228}
229
230void
232 wxFileDirPickerEvent& e) {
233 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
234 int idx = fileList1_->GetItemCount();
235 fileList1_->InsertItem(idx, sanitize(e.GetPath()));
236 fileList1_->SetItem(idx, 1, manager->formatString(
238}
239
240void
242 wxFileDirPickerEvent& e) {
243 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
244 int idx = fileList1_->GetItemCount();
245 fileList1_->InsertItem(idx, sanitize(e.GetPath()));
246 fileList1_->SetItem(idx, 1, manager->formatString(
248}
249
250void
252 wxFileDirPickerEvent& e) {
253 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
254 int idx = fileList1_->GetItemCount();
255 fileList1_->InsertItem(idx, sanitize(e.GetPath()));
256 fileList1_->SetItem(idx, 1, manager->formatString(
258}
259
260void
262 long item = -1;
263
264 for (;;)
265 {
266 item = fileList1_->GetNextItem(
267 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
268 if (item == -1)
269 break;
270 fileList1_->DeleteItem(item);
271 if (fileList1_->GetItemCount() == 0 ||
272 item == fileList1_->GetItemCount())
273 break;
274 }
275}
END_EVENT_TABLE() using namespace IDF
OperationImplementationResourceDialog::onAddVhdlSimFile OperationImplementationResourceDialog::onAddVerilogSimFile EVT_BUTTON(wxID_DELETE, OperationImplementationResourceDialog::onDeleteListItem) OperationImplementationResourceDialog
Constructor.
wxDEFINE_EVENT(BUTTON_SYN_VHDL, wxFileDirPickerEvent)
EVT_FILEPICKER_CHANGED(BUTTON_SYN_VHDL, OperationImplementationResourceDialog::onAddVhdlSynFile) EVT_FILEPICKER_CHANGED(BUTTON_SIM_VHDL
@ Verilogsim
Verilog simulation file.
static std::string formatString(BlockImplementationFile::Format format)
void addOperationImplementationResource(const OperationImplementationResource &resource)
std::string fileName() const