OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ProximStopDialog Class Reference

#include <ProximStopDialog.hh>

Inheritance diagram for ProximStopDialog:
Inheritance graph
Collaboration diagram for ProximStopDialog:
Collaboration graph

Public Member Functions

 ProximStopDialog (wxWindow *parent, wxWindowID id, SimulatorFrontend &frontend)
 
virtual ~ProximStopDialog ()
 

Private Types

enum  {
  ID_STOP = 10000, ID_LABEL_CYCLES, ID_CYCLES, ID_LABEL_TIME,
  ID_TIME, ID_LABEL_CPS, ID_CPS, ID_TEXT,
  ID_LINE
}
 Widget IDs. More...
 

Private Member Functions

void onStop (wxCommandEvent &event)
 
void onClose (wxCloseEvent &event)
 
void onUpdate (wxTimerEvent &event)
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 

Private Attributes

SimulatorFrontendfrontend_
 Simulator frontend to stop and track. More...
 
wxTimer * timer_
 Timer which updates the dialog periodically. More...
 
wxStopWatch * watch_
 Stop watch measuring the simulation runtime. More...
 
wxStaticText * timeCtrl_
 Text displaying the elapsed simulation time. More...
 
wxStaticText * cyclesCtrl_
 Text displaying the simulated cycle count. More...
 
wxStaticText * cpsCtrl_
 Text displaying the average cps value. More...
 
long time_
 Time elapsed on the cps update. More...
 
ClockCycleCount cycles_
 Cycles simulated on the last cps update. More...
 

Static Private Attributes

static const int UPDATE_INTERVAL = 100
 Dialog update itnerval in milliseconds. More...
 

Detailed Description

Dialog which is diaplayed when the simulation is running.

The dialog contains Stop-button for stopping the simulation, and some information of the simulation progress.

Definition at line 47 of file ProximStopDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Widget IDs.

Enumerator
ID_STOP 
ID_LABEL_CYCLES 
ID_CYCLES 
ID_LABEL_TIME 
ID_TIME 
ID_LABEL_CPS 
ID_CPS 
ID_TEXT 
ID_LINE 

Definition at line 64 of file ProximStopDialog.hh.

64  {
65  ID_STOP = 10000,
67  ID_CYCLES,
69  ID_TIME,
71  ID_CPS,
72  ID_TEXT,
73  ID_LINE
74  };

Constructor & Destructor Documentation

◆ ProximStopDialog()

ProximStopDialog::ProximStopDialog ( wxWindow *  parent,
wxWindowID  id,
SimulatorFrontend frontend 
)

The Constructor.

Parameters
parentParent window of the dialog.
idWindow identifier.
frontendSimulator frontend to stop.

Definition at line 54 of file ProximStopDialog.cc.

55  :
56  wxDialog(parent, id, _T("Simulation running..."), wxDefaultPosition),
57  frontend_(frontend), time_(0) {
58 
59  createContents(this, true, true);
60 
61  cyclesCtrl_ = dynamic_cast<wxStaticText*>(FindWindow(ID_CYCLES));
62  timeCtrl_ = dynamic_cast<wxStaticText*>(FindWindow(ID_TIME));
63  cpsCtrl_ = dynamic_cast<wxStaticText*>(FindWindow(ID_CPS));
64  cpsCtrl_->SetLabel(_T(""));
65 
66  timer_ = new wxTimer(this, 0);
67  watch_ = new wxStopWatch();
68 
70  timer_->Start(UPDATE_INTERVAL);
71 }

◆ ~ProximStopDialog()

ProximStopDialog::~ProximStopDialog ( )
virtual

The Destructor.

Definition at line 77 of file ProximStopDialog.cc.

77  {
78  delete timer_;
79  delete watch_;
80 }

References timer_, and watch_.

Member Function Documentation

◆ createContents()

wxSizer * ProximStopDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the dialog widgets.

Code generated by wxDesigner. Do not modify manually.

Parameters
parentParent window of the dialog.
call_fitIf true, the parent window is resized to fit the widgets.
set_sizerIf true, Sets the created widgets as parent window contents.

Definition at line 155 of file ProximStopDialog.cc.

156  {
157  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
158 
159  item0->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
160 
161  wxStaticText *item1 = new wxStaticText( parent, ID_TEXT, wxT("Simulation running..."), wxDefaultPosition, wxDefaultSize, 0 );
162  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
163 
164  item0->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
165 
166  wxFlexGridSizer *item2 = new wxFlexGridSizer( 2, 0, 0 );
167 
168  wxStaticText *item3 = new wxStaticText( parent, ID_LABEL_CYCLES, wxT("Cycles:"), wxDefaultPosition, wxDefaultSize, 0 );
169  item2->Add( item3, 0, wxALIGN_RIGHT|wxALL, 5 );
170 
171  wxStaticText *item4 = new wxStaticText( parent, ID_CYCLES, wxT("???????????????????"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
172  item2->Add( item4, 0, wxALL, 5 );
173 
174  wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_TIME, wxT("Time:"), wxDefaultPosition, wxDefaultSize, 0 );
175  item2->Add( item5, 0, wxALIGN_RIGHT|wxALL, 5 );
176 
177  wxStaticText *item6 = new wxStaticText( parent, ID_TIME, wxT("???????????????????"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
178  item2->Add( item6, 0, wxALL, 5 );
179 
180  wxStaticText *item7 = new wxStaticText( parent, ID_LABEL_CPS, wxT("Avg. cycles/sec:"), wxDefaultPosition, wxDefaultSize, 0 );
181  item2->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
182 
183  wxStaticText *item8 = new wxStaticText( parent, ID_CPS, wxT("???????????????????"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
184  item2->Add( item8, 0, wxALL, 5 );
185 
186  item0->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
187 
188  wxStaticLine *item9 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(300,-1), wxLI_HORIZONTAL );
189  item0->Add( item9, 0, wxGROW|wxALL, 5 );
190 
191  wxButton *item10 = new wxButton( parent, ID_STOP, wxT("&Stop"), wxDefaultPosition, wxDefaultSize, 0 );
192  item0->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
193 
194  if (set_sizer)
195  {
196  parent->SetSizer( item0 );
197  if (call_fit)
198  item0->SetSizeHints( parent );
199  }
200 
201  return item0;
202 }

References ID_CPS, ID_CYCLES, ID_LABEL_CPS, ID_LABEL_CYCLES, ID_LABEL_TIME, ID_LINE, ID_STOP, ID_TEXT, and ID_TIME.

◆ onClose()

void ProximStopDialog::onClose ( wxCloseEvent &  event)
private

Event handler for the windowmanager dialog close button.

Requests simulator stop and closes the dialog.

Definition at line 138 of file ProximStopDialog.cc.

138  {
140  EndModal(wxID_OK);
141 }

References frontend_, SimulatorFrontend::prepareToStop(), and SRE_USER_REQUESTED.

Here is the call graph for this function:

◆ onStop()

void ProximStopDialog::onStop ( wxCommandEvent &  event)
private

Event handler for the Stop button.

Request simulator stop and closes the dialog.

Definition at line 127 of file ProximStopDialog.cc.

127  {
129  EndModal(wxID_OK);
130 }

References frontend_, SimulatorFrontend::prepareToStop(), and SRE_USER_REQUESTED.

Here is the call graph for this function:

◆ onUpdate()

void ProximStopDialog::onUpdate ( wxTimerEvent &  event)
private

Event handler for the dialog update timer.

Updates the cycle count and simulation time. Also checks if the simulation is still running. If the simulation is no longer running, the dialog is closed automatically.

Definition at line 90 of file ProximStopDialog.cc.

90  {
91 
93  // simualtion not running anymore
94  EndModal(wxID_OK);
95  }
96 
98  cyclesCtrl_->SetLabel(WxConversion::toWxString((boost::format("%.0f") %
99  cycles).str()));
100  long time = watch_->Time();
101  unsigned seconds = (time / 1000) % 60;
102  unsigned minutes = (time / 1000) / 60;
103  wxString timeStr = WxConversion::toWxString(seconds);
104  if (seconds < 10) {
105  timeStr.Prepend(_T(":0"));
106  } else {
107  timeStr.Prepend(_T(":"));
108  }
109  timeStr.Prepend(WxConversion::toWxString(minutes));
110  timeCtrl_->SetLabel(timeStr);
111 
112  if (time - time_ > 1000) {
113  int cps = (1000 * (cycles - cycles_)) / (time - time_);
114  wxString cpsStr = WxConversion::toWxString(cps);
115  cpsCtrl_->SetLabel(cpsStr);
116  time_ = time;
117  cycles_ = cycles;
118  }
119 }

References cpsCtrl_, SimulatorFrontend::cycleCount(), cycles_, cyclesCtrl_, frontend_, SimulatorFrontend::isSimulationRunning(), time_, timeCtrl_, WxConversion::toWxString(), and watch_.

Here is the call graph for this function:

Member Data Documentation

◆ cpsCtrl_

wxStaticText* ProximStopDialog::cpsCtrl_
private

Text displaying the average cps value.

Definition at line 89 of file ProximStopDialog.hh.

Referenced by onUpdate().

◆ cycles_

ClockCycleCount ProximStopDialog::cycles_
private

Cycles simulated on the last cps update.

Definition at line 94 of file ProximStopDialog.hh.

Referenced by onUpdate().

◆ cyclesCtrl_

wxStaticText* ProximStopDialog::cyclesCtrl_
private

Text displaying the simulated cycle count.

Definition at line 87 of file ProximStopDialog.hh.

Referenced by onUpdate().

◆ frontend_

SimulatorFrontend& ProximStopDialog::frontend_
private

Simulator frontend to stop and track.

Definition at line 77 of file ProximStopDialog.hh.

Referenced by onClose(), onStop(), and onUpdate().

◆ time_

long ProximStopDialog::time_
private

Time elapsed on the cps update.

Definition at line 92 of file ProximStopDialog.hh.

Referenced by onUpdate().

◆ timeCtrl_

wxStaticText* ProximStopDialog::timeCtrl_
private

Text displaying the elapsed simulation time.

Definition at line 85 of file ProximStopDialog.hh.

Referenced by onUpdate().

◆ timer_

wxTimer* ProximStopDialog::timer_
private

Timer which updates the dialog periodically.

Definition at line 80 of file ProximStopDialog.hh.

Referenced by ~ProximStopDialog().

◆ UPDATE_INTERVAL

const int ProximStopDialog::UPDATE_INTERVAL = 100
staticprivate

Dialog update itnerval in milliseconds.

Definition at line 97 of file ProximStopDialog.hh.

◆ watch_

wxStopWatch* ProximStopDialog::watch_
private

Stop watch measuring the simulation runtime.

Definition at line 82 of file ProximStopDialog.hh.

Referenced by onUpdate(), and ~ProximStopDialog().


The documentation for this class was generated from the following files:
WxConversion::toWxString
static wxString toWxString(const std::string &source)
ProximStopDialog::cycles_
ClockCycleCount cycles_
Cycles simulated on the last cps update.
Definition: ProximStopDialog.hh:94
ProximStopDialog::time_
long time_
Time elapsed on the cps update.
Definition: ProximStopDialog.hh:92
SRE_USER_REQUESTED
@ SRE_USER_REQUESTED
User requested the simulation to stop explicitly, e.g., by pressing ctrl-c in the CLI.
Definition: SimulatorConstants.hh:66
ProximStopDialog::ID_LABEL_TIME
@ ID_LABEL_TIME
Definition: ProximStopDialog.hh:68
ProximStopDialog::ID_TIME
@ ID_TIME
Definition: ProximStopDialog.hh:69
FindWindow
Definition: FindWindow.hh:49
ProximStopDialog::ID_STOP
@ ID_STOP
Definition: ProximStopDialog.hh:65
ProximStopDialog::ID_LABEL_CPS
@ ID_LABEL_CPS
Definition: ProximStopDialog.hh:70
ProximStopDialog::frontend_
SimulatorFrontend & frontend_
Simulator frontend to stop and track.
Definition: ProximStopDialog.hh:77
ProximStopDialog::ID_CPS
@ ID_CPS
Definition: ProximStopDialog.hh:71
ProximStopDialog::cyclesCtrl_
wxStaticText * cyclesCtrl_
Text displaying the simulated cycle count.
Definition: ProximStopDialog.hh:87
ProximStopDialog::ID_CYCLES
@ ID_CYCLES
Definition: ProximStopDialog.hh:67
ProximStopDialog::timeCtrl_
wxStaticText * timeCtrl_
Text displaying the elapsed simulation time.
Definition: ProximStopDialog.hh:85
ProximStopDialog::watch_
wxStopWatch * watch_
Stop watch measuring the simulation runtime.
Definition: ProximStopDialog.hh:82
SimulatorFrontend::isSimulationRunning
bool isSimulationRunning() const
Definition: SimulatorFrontend.cc:1260
SimulatorFrontend::cycleCount
ClockCycleCount cycleCount() const
Definition: SimulatorFrontend.cc:1194
ProximStopDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: ProximStopDialog.cc:155
ProximStopDialog::ID_TEXT
@ ID_TEXT
Definition: ProximStopDialog.hh:72
ProximStopDialog::cpsCtrl_
wxStaticText * cpsCtrl_
Text displaying the average cps value.
Definition: ProximStopDialog.hh:89
ProximStopDialog::ID_LINE
@ ID_LINE
Definition: ProximStopDialog.hh:73
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
ProximStopDialog::timer_
wxTimer * timer_
Timer which updates the dialog periodically.
Definition: ProximStopDialog.hh:80
ProximStopDialog::ID_LABEL_CYCLES
@ ID_LABEL_CYCLES
Definition: ProximStopDialog.hh:66
ProximStopDialog::UPDATE_INTERVAL
static const int UPDATE_INTERVAL
Dialog update itnerval in milliseconds.
Definition: ProximStopDialog.hh:97
SimulatorFrontend::prepareToStop
void prepareToStop(StopReason reason)
Definition: SimulatorFrontend.cc:1331