OpenASIP  2.0
SimulationInfoDialog.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 SimulationInfoDialog.cc
26  *
27  * Definition of SimulationInfoDialog class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <boost/format.hpp>
34 #include <string>
35 
36 #include "SimulationInfoDialog.hh"
37 #include "WidgetTools.hh"
38 #include "GUITextGenerator.hh"
39 #include "OSEdTextGenerator.hh"
40 #include "SimulationInfoDialog.hh"
41 #include "OperationContext.hh"
42 #include "WxConversion.hh"
43 #include "DialogPosition.hh"
44 #include "OSEdConstants.hh"
45 
46 using boost::format;
47 using std::string;
48 
49 /**
50  * Constructor.
51  *
52  * @param parent Parent window.
53  * @param context Operation context.
54  */
56  wxWindow* parent,
57  OperationContext* context) :
58  wxDialog(parent, -1, _T(""),
59  DialogPosition::getPosition(DialogPosition::DIALOG_SIMULATION_INFO),
60  wxSize(400, 150), wxRESIZE_BORDER), context_(context) {
61 
62  createContents(this, false, true);
63 
64  parent_ = dynamic_cast<SimulateDialog*>(parent);
65 
66  infoList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_LISTCTRL));
67  infoList_->InsertColumn(0, _T(""), wxLIST_FORMAT_LEFT,
69  infoList_->InsertColumn(1, _T(""), wxLIST_FORMAT_LEFT,
71 
73 
74  format fmt = texts.text(OSEdTextGenerator::TXT_LABEL_PC);
75  infoList_->InsertItem(0, WxConversion::toWxString(fmt.str()));
76 
78  infoList_->InsertItem(1, WxConversion::toWxString(fmt.str()));
79 
81  infoList_->InsertItem(2, WxConversion::toWxString(fmt.str()));
82 
84  infoList_->InsertItem(3, WxConversion::toWxString(fmt.str()));
85 
86  setTexts();
87 }
88 
89 /**
90  * Sets the texts for the widgets.
91  */
92 void
94 
96 
97  // title
98  format fmt =
100  SetTitle(WxConversion::toWxString(fmt.str()));
101 
102 }
103 
104 
105 /**
106  * Destructor.
107  */
109  int x, y;
110  GetPosition(&x, &y);
111  wxPoint point(x, y);
113 }
114 
115 /**
116  * Transfer data to dialog.
117  *
118  * @return True if transfer is successful.
119  */
120 bool
122  updateList();
123  return wxWindow::TransferDataToWindow();
124 }
125 
126 /**
127  * Updates the list of information.
128  */
129 void
131 #if 0
133  infoList_->SetItem(0, 1, WxConversion::toWxString(0));
134  } else {
135  SimValue& value = context_->programCounter();
136  string valueString = parent_->formattedValue(&value);
137  infoList_->SetItem(0, 1, WxConversion::toWxString(valueString));
138  }
139 #endif
140  infoList_->SetItem(
142 
143 #if 0
145  infoList_->SetItem(1, 1, WxConversion::toWxString(0));
146  } else {
147  SimValue& value = context_->returnAddress();
148  string valueString = parent_->formattedValue(&value);
149  infoList_->SetItem(1, 1, WxConversion::toWxString(valueString));
150  }
151 #endif
152  infoList_->SetItem(
153  1, 1,
155 }
156 
157 /**
158  * Updates the list which contains information about simulation.
159  *
160  * This method is called when trigger button is pushed in parent dialog
161  * (SimulateDialog).
162  *
163  * @param id The id of the event.
164  */
165 void
167  switch (id) {
169  updateList();
170  break;
172  context_->programCounter() = 0;
173  context_->returnAddress() = 0;
174  updateList();
175  break;
176  default:
177  break;
178  }
179 }
180 
181 /**
182  * Creates the contents of the dialog.
183  *
184  * NOTE! This function was generated by wxDesigner.
185  *
186  * @param parent Parent window.
187  * @param call_fit If true fits the contenst inside the dialog.
188  * @param set_sizer If true sets the main sizer as dialog contents.
189  * @return The created sizer.
190  */
191 wxSizer*
193  wxWindow* parent,
194  bool call_fit,
195  bool set_sizer ) {
196 
197  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
198 
199  wxListCtrl *item1 = new wxListCtrl( parent, ID_LISTCTRL, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER );
200  item0->Add( item1, 1, wxGROW|wxALL, 5 );
201 
202  if (set_sizer)
203  {
204  parent->SetSizer( item0 );
205  if (call_fit)
206  item0->SetSizeHints( parent );
207  }
208 
209  return item0;
210 }
OSEdTextGenerator::TXT_LABEL_RA
@ TXT_LABEL_RA
Return address label.
Definition: OSEdTextGenerator.hh:62
SimulationInfoDialog::setTexts
void setTexts()
Definition: SimulationInfoDialog.cc:93
OSEdInformer::EventId
EventId
Definition: OSEdInformer.hh:52
OSEdConstants::DEFAULT_COLUMN_WIDTH
static const int DEFAULT_COLUMN_WIDTH
Default column width.
Definition: OSEdConstants.hh:113
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OSEdTextGenerator::TXT_LABEL_SYS_CALL_NUMBER
@ TXT_LABEL_SYS_CALL_NUMBER
Sys call number label.
Definition: OSEdTextGenerator.hh:64
SimulationInfoDialog.hh
SimulateDialog
Definition: SimulateDialog.hh:53
OperationContext
Definition: OperationContext.hh:56
SimulationInfoDialog::infoList_
wxListCtrl * infoList_
List for showing simulation statistics.
Definition: SimulationInfoDialog.hh:74
NullSimValue::instance
static SimValue & instance()
Definition: SimValue.cc:1642
OSEdInformer::EVENT_REGISTER
@ EVENT_REGISTER
Event when register value might change.
Definition: OSEdInformer.hh:53
WidgetTools.hh
OSEdTextGenerator::TXT_SIMULATION_INFO_DIALOG_TITLE
@ TXT_SIMULATION_INFO_DIALOG_TITLE
Simulation info dialog title.
Definition: OSEdTextGenerator.hh:119
FindWindow
Definition: FindWindow.hh:49
SimulationInfoDialog::updateList
void updateList()
Definition: SimulationInfoDialog.cc:130
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
SimValue::uIntWordValue
UIntWord uIntWordValue() const
Definition: SimValue.cc:972
DialogPosition::setPosition
static void setPosition(Dialogs dialog, wxPoint point)
Definition: DialogPosition.cc:63
SimulationInfoDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: SimulationInfoDialog.cc:192
SimulationInfoDialog::context_
OperationContext * context_
Operation context for retrieving simulation data.
Definition: SimulationInfoDialog.hh:78
OSEdConstants.hh
SimValue
Definition: SimValue.hh:96
SimulationInfoDialog::ID_LISTCTRL
@ ID_LISTCTRL
Definition: SimulationInfoDialog.hh:70
SimulationInfoDialog::parent_
SimulateDialog * parent_
Parent window.
Definition: SimulationInfoDialog.hh:76
DialogPosition
Definition: DialogPosition.hh:42
OSEdTextGenerator::TXT_LABEL_SYS_CALL_HANDLER
@ TXT_LABEL_SYS_CALL_HANDLER
Sys call handler label.
Definition: OSEdTextGenerator.hh:63
SimulationInfoDialog::SimulationInfoDialog
SimulationInfoDialog(wxWindow *parent, OperationContext *context)
Definition: SimulationInfoDialog.cc:55
GUITextGenerator.hh
DialogPosition::DIALOG_SIMULATION_INFO
@ DIALOG_SIMULATION_INFO
Simulation info dialog.
Definition: DialogPosition.hh:55
OSEdInformer::EVENT_RESET
@ EVENT_RESET
Event when operation is reseted.
Definition: OSEdInformer.hh:54
SimulationInfoDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: SimulationInfoDialog.cc:121
OperationContext::programCounter
InstructionAddress & programCounter()
Definition: OperationContext.cc:152
SimulationInfoDialog::handleEvent
virtual void handleEvent(OSEdInformer::EventId id)
Definition: SimulationInfoDialog.cc:166
OSEdTextGenerator::TXT_LABEL_PC
@ TXT_LABEL_PC
Program counter label.
Definition: OSEdTextGenerator.hh:61
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
SimulationInfoDialog::~SimulationInfoDialog
virtual ~SimulationInfoDialog()
Definition: SimulationInfoDialog.cc:108
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
WxConversion.hh
OSEdTextGenerator.hh
SimulateDialog::formattedValue
std::string formattedValue(SimValue *value)
Definition: SimulateDialog.cc:532
OperationContext::returnAddress
SimValue & returnAddress()
Definition: OperationContext.cc:207
OperationContext.hh
DialogPosition.hh