OpenASIP  2.0
SimulatorSettingsDialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 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 SimulatorSettingsDialog.cc
26  *
27  * Implementation of SimulatorSettingsDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/spinctrl.h>
34 #include <wx/statline.h>
35 #include <wx/valgen.h>
37 #include "ProximLineReader.hh"
38 #include "WxConversion.hh"
39 #include "SimulatorFrontend.hh"
40 #include "ProximConstants.hh"
41 #include "Conversion.hh"
42 
43 BEGIN_EVENT_TABLE(SimulatorSettingsDialog, wxDialog)
46 
47 /**
48  * The Constructor.
49  *
50  * @param parent Parent window of the dialog.
51  * @param id Dialog window identifier.
52  * @param simulator Simulator frontend to configure.
53  */
55  wxWindow* parent, wxWindowID id, SimulatorFrontend& simulator,
56  ProximLineReader& lineReader) :
57  wxDialog(parent, id, _T("Simulator Settings"), wxDefaultPosition),
58  simulator_(simulator), lineReader_(lineReader) {
59 
60  createContents(this, true, true);
61 
62  FindWindow(ID_EXEC_TRACE)->SetValidator(wxGenericValidator(&execTrace_));
63  FindWindow(ID_BUS_TRACE)->SetValidator(wxGenericValidator(&busTrace_));
64  FindWindow(ID_PT_TRACKING)->SetValidator(wxGenericValidator(&ptTrace_));
65  FindWindow(ID_RF_TRACKING)->SetValidator(wxGenericValidator(&rfTrace_));
66  FindWindow(ID_FU_CONFLICT_DETECTION)->SetValidator(
67  wxGenericValidator(&fuConflictDetection_));
68 
69  FindWindow(ID_PROFILE_DATA_SAVING)->SetValidator(
70  wxGenericValidator(&profileDataSaving_));
71  FindWindow(ID_UTILIZATION_DATA_SAVING)->SetValidator(
72  wxGenericValidator(&utilizationDataSaving_));
73  FindWindow(ID_NEXT_INSTRUCTION_PRINTING)->SetValidator(
74  wxGenericValidator(&nextInstructionPrinting_));
75  FindWindow(ID_SIMULATION_TIME_STATISTICS)->SetValidator(
76  wxGenericValidator(&simulationTimeStatistics_));
77 
78  FindWindow(ID_SAVE_HISTORY)->SetValidator(
79  wxGenericValidator(&historySave_));
80 
81  FindWindow(ID_HISTORY_FILE)->SetValidator(
82  wxGenericValidator(&historyFile_));
83 
84  FindWindow(ID_HISTORY_SIZE)->SetValidator(
85  wxGenericValidator(&historySize_));
86 }
87 
88 /**
89  * The Destructor.
90  */
92 }
93 
94 
95 /**
96  * Transfers settings data from the simulator frontend to the dialog widgets.
97  */
98 bool
100 
105 
110 
112 
117 
118  return wxDialog::TransferDataToWindow();
119 }
120 
121 
122 /**
123  * Updates the simulator settings and closes the dialog when the OK-button
124  * is pressed.
125  */
126 void
128 
129  TransferDataFromWindow();
130 
131  std::string command;
132  std::string historyFile =
133  WxConversion::toString(historyFile_.Trim(false).Trim(true));
134 
136  command += ProximConstants::SCL_SET + " ";
138  command += Conversion::toString(execTrace_);
139  command += ProximConstants::SCL_DELIM;
140  }
141 
142  if (simulator_.busTracing() != busTrace_) {
143  command += ProximConstants::SCL_SET + " ";
145  command += Conversion::toString(busTrace_);
146  command += ProximConstants::SCL_DELIM;
147  }
148 
150  command += ProximConstants::SCL_SET + " ";
152  command += Conversion::toString(ptTrace_);
153  command += ProximConstants::SCL_DELIM;
154  }
155 
157  command += ProximConstants::SCL_SET + " ";
158  command += ProximConstants::SCL_SETTING_RF_TRACE + " ";
159  command += Conversion::toString(rfTrace_);
160  command += ProximConstants::SCL_DELIM;
161  }
162 
164  command += ProximConstants::SCL_SET + " ";
167  command += ProximConstants::SCL_DELIM;
168  }
169 
171  command += ProximConstants::SCL_SET + " ";
174  command += ProximConstants::SCL_DELIM;
175  }
176 
178  command += ProximConstants::SCL_SET + " ";
181  command += ProximConstants::SCL_DELIM;
182 
183  }
184 
185  if (lineReader_.inputHistoryFilename() != historyFile) {
186  command += ProximConstants::SCL_SET + " ";
188  command += historyFile;
189  command += ProximConstants::SCL_DELIM;
190  }
191 
193  command += ProximConstants::SCL_SET + " ";
196  command += ProximConstants::SCL_DELIM;
197  }
198 
200  command += ProximConstants::SCL_SET + " ";
203  command += ProximConstants::SCL_DELIM;
204  }
205 
207  command += ProximConstants::SCL_SET + " ";
210  command += ProximConstants::SCL_DELIM;
211  }
212 
214  command += ProximConstants::SCL_SET + " ";
217  command += ProximConstants::SCL_DELIM;
218  }
219 
220  lineReader_.input(command);
221 
222  EndModal(wxID_OK);
223 }
224 
225 
226 /**
227  * Creates the dialog widgets.
228  *
229  * Source code generated by wxDesigner. Do not modify by hand!
230  *
231  * @param parent Parent dialog of the widgets.
232  * @param call_fit If true, resize the dialog to fit the widgets.
233  * @param set_sizer If true, set the created widgets as the dialog contents.
234  * @return Top level sizer of the dialog contents.
235  */
236 wxSizer*
238  wxWindow *parent, bool call_fit, bool set_sizer) {
239 
240  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
241 
242  wxStaticBox *item2 = new wxStaticBox( parent, -1, wxT("Tracing:") );
243  wxStaticBoxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
244 
245  wxCheckBox *item3 = new wxCheckBox( parent, ID_EXEC_TRACE, wxT("Write basic execution trace."), wxDefaultPosition, wxDefaultSize, 0 );
246  item1->Add( item3, 0, wxALL, 5 );
247 
248  wxCheckBox *item4 = new wxCheckBox( parent, ID_BUS_TRACE, wxT("Write bus trace."), wxDefaultPosition, wxDefaultSize, 0 );
249  item1->Add( item4, 0, wxALL, 5 );
250 
251  wxCheckBox *item19 = new wxCheckBox( parent, ID_PT_TRACKING, wxT("Procedure transfer tracking."), wxDefaultPosition, wxDefaultSize, 0 );
252  item1->Add( item19, 0, wxALL, 5 );
253 
254  wxCheckBox *item5 = new wxCheckBox( parent, ID_RF_TRACKING, wxT("Concurrent register file access tracking."), wxDefaultPosition, wxDefaultSize, 0 );
255  item1->Add( item5, 0, wxALL, 5 );
256 
257  wxCheckBox *item6 = new wxCheckBox( parent, ID_FU_CONFLICT_DETECTION, wxT("Function unit resouce conflict detection."), wxDefaultPosition, wxDefaultSize, 0 );
258  item1->Add( item6, 0, wxALL, 5 );
259 
260  wxCheckBox *profiledata = new wxCheckBox( parent, ID_PROFILE_DATA_SAVING, wxT("Profile data saving."), wxDefaultPosition, wxDefaultSize, 0 );
261  item1->Add( profiledata, 0, wxALL, 5 );
262 
263  wxCheckBox *utildata = new wxCheckBox( parent, ID_UTILIZATION_DATA_SAVING, wxT("Utilization data saving."), wxDefaultPosition, wxDefaultSize, 0 );
264  item1->Add( utildata, 0, wxALL, 5 );
265 
266  wxCheckBox *nextinstr = new wxCheckBox( parent, ID_NEXT_INSTRUCTION_PRINTING, wxT("Next instruction printing."), wxDefaultPosition, wxDefaultSize, 0 );
267  item1->Add( nextinstr, 0, wxALL, 5 );
268 
269  wxCheckBox *timestat = new wxCheckBox( parent, ID_SIMULATION_TIME_STATISTICS, wxT("Simulation time statistics."), wxDefaultPosition, wxDefaultSize, 0 );
270  item1->Add( timestat, 0, wxALL, 5 );
271 
272  item0->Add( item1, 0, wxGROW|wxALL, 5 );
273 
274  wxStaticBox *item8 = new wxStaticBox( parent, -1, wxT("Command history:") );
275  wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
276 
277  wxBoxSizer *item9 = new wxBoxSizer( wxHORIZONTAL );
278 
279  wxStaticText *item10 = new wxStaticText( parent, ID_LABEL_HISTORY_SIZE, wxT("Maximum size of command history:"), wxDefaultPosition, wxDefaultSize, 0 );
280  item9->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
281 
282  wxSpinCtrl *item11 = new wxSpinCtrl( parent, ID_HISTORY_SIZE, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 10000, 0 );
283  item9->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
284 
285  item7->Add( item9, 0, wxGROW|wxALL, 5 );
286 
287  wxBoxSizer *item12 = new wxBoxSizer( wxVERTICAL );
288 
289  wxCheckBox *item13 = new wxCheckBox( parent, ID_SAVE_HISTORY, wxT("Save command history to file:"), wxDefaultPosition, wxDefaultSize, 0 );
290  item12->Add( item13, 0, wxALL, 5 );
291 
292  wxTextCtrl *item14 = new wxTextCtrl( parent, ID_HISTORY_FILE, wxT(""), wxDefaultPosition, wxSize(300,-1), 0 );
293  item12->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
294 
295  item7->Add( item12, 0, wxGROW|wxALL, 5 );
296 
297  item0->Add( item7, 0, wxGROW|wxALL, 5 );
298 
299  wxStaticLine *item15 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
300  item0->Add( item15, 0, wxGROW|wxALL, 5 );
301 
302  wxBoxSizer *item16 = new wxBoxSizer( wxHORIZONTAL );
303 
304  wxButton *item17 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
305  item16->Add( item17, 0, wxALL, 5 );
306 
307  wxButton *item18 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
308  item16->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
309 
310  item0->Add( item16, 0, 0, 5 );
311 
312  if (set_sizer)
313  {
314  parent->SetSizer( item0 );
315  if (call_fit)
316  item0->SetSizeHints( parent );
317  }
318 
319  return item0;
320 }
ProximConstants::SCL_DELIM
static const std::string SCL_DELIM
Command delimeter for the simulator commands.
Definition: ProximConstants.hh:202
SimulatorSettingsDialog::busTrace_
bool busTrace_
Bus trace enabled/disabled.
Definition: SimulatorSettingsDialog.hh:84
SimulatorFrontend::simulationTimeStatistics
bool simulationTimeStatistics() const
Definition: SimulatorFrontend.cc:2097
SimulatorSettingsDialog::ID_FU_CONFLICT_DETECTION
@ ID_FU_CONFLICT_DETECTION
Definition: SimulatorSettingsDialog.hh:64
SimulatorSettingsDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: SimulatorSettingsDialog.cc:99
WxConversion::toWxString
static wxString toWxString(const std::string &source)
SimulatorSettingsDialog::~SimulatorSettingsDialog
virtual ~SimulatorSettingsDialog()
Definition: SimulatorSettingsDialog.cc:91
SimulatorFrontend::rfAccessTracing
bool rfAccessTracing() const
Definition: SimulatorFrontend.cc:1818
SimulatorSettingsDialog::historySize_
int historySize_
History log max size.
Definition: SimulatorSettingsDialog.hh:104
SimulatorFrontend::procedureTransferTracing
bool procedureTransferTracing() const
Definition: SimulatorFrontend.cc:1827
SimulatorFrontend::profileDataSaving
bool profileDataSaving() const
Definition: SimulatorFrontend.cc:1837
ProximConstants::SCL_SETTING_RF_TRACE
static const std::string SCL_SETTING_RF_TRACE
Name of the rf access trace setting.
Definition: ProximConstants.hh:183
SimulatorSettingsDialog.hh
SimulatorSettingsDialog::ID_BUS_TRACE
@ ID_BUS_TRACE
Definition: SimulatorSettingsDialog.hh:61
SimulatorFrontend::fuResourceConflictDetection
bool fuResourceConflictDetection() const
Definition: SimulatorFrontend.cc:2032
ProximLineReader.hh
ProximConstants::SCL_SET
static const std::string SCL_SET
Command for configuring simulator settings.
Definition: ProximConstants.hh:174
SimulatorSettingsDialog::ID_SAVE_HISTORY
@ ID_SAVE_HISTORY
Definition: SimulatorSettingsDialog.hh:71
SimulatorSettingsDialog::historySave_
bool historySave_
Input history log file enabled/disabled.
Definition: SimulatorSettingsDialog.hh:102
FindWindow
Definition: FindWindow.hh:49
SimulatorSettingsDialog::nextInstructionPrinting_
bool nextInstructionPrinting_
Next instruction printing enabled/disabled.
Definition: SimulatorSettingsDialog.hh:97
ProximLineReader::input
void input(std::string command)
Definition: ProximLineReader.cc:131
SimulatorSettingsDialog::historyFile_
wxString historyFile_
History log file name.
Definition: SimulatorSettingsDialog.hh:106
SimulatorSettingsDialog::ID_SIMULATION_TIME_STATISTICS
@ ID_SIMULATION_TIME_STATISTICS
Definition: SimulatorSettingsDialog.hh:69
SimulatorSettingsDialog::execTrace_
bool execTrace_
Execution trace enabled/disabled.
Definition: SimulatorSettingsDialog.hh:82
SimulatorFrontend::busTracing
bool busTracing() const
Definition: SimulatorFrontend.cc:1808
LineReader::inputHistoryMaxLength
virtual size_t inputHistoryMaxLength() const
Conversion::toString
static std::string toString(const T &source)
ProximConstants::SCL_SETTING_FU_CONFLICT_DETECTION
static const std::string SCL_SETTING_FU_CONFLICT_DETECTION
Name of the fu conflict detection setting.
Definition: ProximConstants.hh:185
SimulatorSettingsDialog::simulator_
SimulatorFrontend & simulator_
Frontend of the simulator to configure.
Definition: SimulatorSettingsDialog.hh:77
SimulatorSettingsDialog::ID_LINE
@ ID_LINE
Definition: SimulatorSettingsDialog.hh:73
SimulatorSettingsDialog::ID_UTILIZATION_DATA_SAVING
@ ID_UTILIZATION_DATA_SAVING
Definition: SimulatorSettingsDialog.hh:67
SimulatorSettingsDialog::ID_NEXT_INSTRUCTION_PRINTING
@ ID_NEXT_INSTRUCTION_PRINTING
Definition: SimulatorSettingsDialog.hh:68
SimulatorSettingsDialog::ID_EXEC_TRACE
@ ID_EXEC_TRACE
Definition: SimulatorSettingsDialog.hh:60
SimulatorSettingsDialog::rfTrace_
bool rfTrace_
Register file access tracing enabled/disabled.
Definition: SimulatorSettingsDialog.hh:88
Conversion.hh
SimulatorSettingsDialog::ID_PROFILE_DATA_SAVING
@ ID_PROFILE_DATA_SAVING
Definition: SimulatorSettingsDialog.hh:66
ProximLineReader::inputHistoryFilename
std::string inputHistoryFilename() const
Definition: ProximLineReader.cc:310
SimulatorSettingsDialog
Definition: SimulatorSettingsDialog.hh:44
SimulatorSettingsDialog::profileDataSaving_
bool profileDataSaving_
Profile data saving enabled/disabled.
Definition: SimulatorSettingsDialog.hh:93
SimulatorSettingsDialog::ID_HISTORY_FILE
@ ID_HISTORY_FILE
Definition: SimulatorSettingsDialog.hh:72
ProximConstants::SCL_SETTING_NEXT_INSTRUCTION_PRINTING
static const std::string SCL_SETTING_NEXT_INSTRUCTION_PRINTING
Name of the fu next insturction printing setting.
Definition: ProximConstants.hh:191
ProximLineReader
Definition: ProximLineReader.hh:60
SimulatorSettingsDialog::ID_LABEL_HISTORY_SIZE
@ ID_LABEL_HISTORY_SIZE
Definition: SimulatorSettingsDialog.hh:65
SimulatorSettingsDialog::fuConflictDetection_
bool fuConflictDetection_
FU conflict detection enabled/disabled.
Definition: SimulatorSettingsDialog.hh:90
ProximConstants::SCL_SETTING_EXEC_TRACE
static const std::string SCL_SETTING_EXEC_TRACE
Name of the execution trace setting.
Definition: ProximConstants.hh:177
SimulatorFrontend.hh
SimulatorSettingsDialog::simulationTimeStatistics_
bool simulationTimeStatistics_
Profile data saving enabled/disabled.
Definition: SimulatorSettingsDialog.hh:99
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
ProximConstants::SCL_SETTING_HISTORY_FILE
static const std::string SCL_SETTING_HISTORY_FILE
Name of the input history file name setting.
Definition: ProximConstants.hh:199
ProximConstants.hh
ProximConstants::SCL_SETTING_HISTORY_SIZE
static const std::string SCL_SETTING_HISTORY_SIZE
Name of the input history size setting.
Definition: ProximConstants.hh:197
SimulatorFrontend::utilizationDataSaving
bool utilizationDataSaving() const
Definition: SimulatorFrontend.cc:1847
SimulatorSettingsDialog::createContents
wxSizer * createContents(wxWindow *parent, bool set_sizer, bool call_fit)
Definition: SimulatorSettingsDialog.cc:237
LineReader::saveInputHistoryToFile
virtual bool saveInputHistoryToFile() const
ProximConstants::SCL_SETTING_HISTORY_SAVE
static const std::string SCL_SETTING_HISTORY_SAVE
Name of the input history saving setting,.
Definition: ProximConstants.hh:195
SimulatorSettingsDialog::utilizationDataSaving_
bool utilizationDataSaving_
Utilization data saving enabled/disabled.
Definition: SimulatorSettingsDialog.hh:95
ProximConstants::SCL_SETTING_PROFILE_DATA_SAVING
static const std::string SCL_SETTING_PROFILE_DATA_SAVING
Name of the profile data saving setting.
Definition: ProximConstants.hh:187
SimulatorSettingsDialog::onOK
void onOK(wxCommandEvent &event)
Definition: SimulatorSettingsDialog.cc:127
SimulatorFrontend::executionTracing
bool executionTracing() const
Definition: SimulatorFrontend.cc:1798
WxConversion.hh
ProximConstants::SCL_SETTING_UTILIZATION_DATA_SAVING
static const std::string SCL_SETTING_UTILIZATION_DATA_SAVING
Name of the utilization data saving setting.
Definition: ProximConstants.hh:189
SimulatorFrontend::nextInstructionPrinting
bool nextInstructionPrinting() const
Definition: SimulatorFrontend.cc:2080
SimulatorSettingsDialog::lineReader_
ProximLineReader & lineReader_
Line reader to configure.
Definition: SimulatorSettingsDialog.hh:79
WxConversion::toString
static std::string toString(const wxString &source)
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
SimulatorSettingsDialog::ID_PT_TRACKING
@ ID_PT_TRACKING
Definition: SimulatorSettingsDialog.hh:62
ProximConstants::SCL_SETTING_BUS_TRACE
static const std::string SCL_SETTING_BUS_TRACE
Name of the bus trace setting.
Definition: ProximConstants.hh:179
SimulatorSettingsDialog::ptTrace_
bool ptTrace_
Procedure transfer tracing enabled/disabled.
Definition: SimulatorSettingsDialog.hh:86
ProximConstants::SCL_SETTING_SIMULATION_TIME_STATISTICS
static const std::string SCL_SETTING_SIMULATION_TIME_STATISTICS
Name of the simulation time statistics setting.
Definition: ProximConstants.hh:193
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
ProximConstants::SCL_SETTING_PROCEDURE_TRANSFER_TRACE
static const std::string SCL_SETTING_PROCEDURE_TRANSFER_TRACE
Name of the procedure transfer trace setting.
Definition: ProximConstants.hh:181
SimulatorSettingsDialog::ID_RF_TRACKING
@ ID_RF_TRACKING
Definition: SimulatorSettingsDialog.hh:63
SimulatorSettingsDialog::ID_HISTORY_SIZE
@ ID_HISTORY_SIZE
Definition: SimulatorSettingsDialog.hh:70