OpenASIP  2.0
Static Public Member Functions | Protected Member Functions | List of all members
ProximToolbox Class Reference

#include <ProximToolbox.hh>

Collaboration diagram for ProximToolbox:
Collaboration graph

Static Public Member Functions

static const TTAMachine::Machinemachine ()
 
static const TTAProgram::Programprogram ()
 
static ProximMainFramemainFrame ()
 
static ProximMachineStateWindowmachineStateWindow ()
 
static ProximDisassemblyWindowdisassemblyWindow ()
 
static void addFramedWindow (wxWindow *window, const wxString &title, bool stayOnTop=false, const wxSize &minSize=wxSize(100, 100))
 
static SimulatorInterpreterinterpreter ()
 
static TracedSimulatorFrontendfrontend ()
 
static ProximLineReaderlineReader ()
 
static bool testExpression (wxWindow *parent, const std::string &expression)
 
static bool testCondition (wxWindow *parent, const std::string &condition)
 

Protected Member Functions

 ProximToolbox ()
 Instantiation not allowed. More...
 

Detailed Description

Set of helper functions to access Proxim windows and simulation.

Definition at line 56 of file ProximToolbox.hh.

Constructor & Destructor Documentation

◆ ProximToolbox()

ProximToolbox::ProximToolbox ( )
protected

Instantiation not allowed.

The Constructor.

Definition at line 57 of file ProximToolbox.cc.

57  {
58 }

Member Function Documentation

◆ addFramedWindow()

void ProximToolbox::addFramedWindow ( wxWindow *  window,
const wxString &  title,
bool  stayOnTop = false,
const wxSize &  minSize = wxSize(100, 100) 
)
static

Adds a new simulator window in it's own floating frame.

Parameters
windowWindow to add.
titleTitle of the frame.

Definition at line 176 of file ProximToolbox.cc.

178  {
179 
180  // Create a new frame for the window.
181  long style = wxDEFAULT_FRAME_STYLE;
182  if (stayOnTop) {
183  style = (style | wxFRAME_FLOAT_ON_PARENT);
184  }
185 
186  wxFrame* frame = new wxFrame(
187  mainFrame(), -1, title, wxDefaultPosition, wxDefaultSize, style);
188 
189  window->Reparent(frame);
190  wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
191  sizer->Add(window, 1, wxGROW);
192  sizer->SetSizeHints(window);
193  frame->SetSizer(sizer);
194  frame->Fit();
195  frame->SetSizeHints(minSize.GetWidth(), minSize.GetHeight());
196  frame->Show();
197  return;
198 }

References mainFrame().

Referenced by ProximNewPortWindowCmd::Do(), ProximNewRegisterWindowCmd::Do(), ProximFindCmd::Do(), ProximShowRegistersCmd::Do(), ProximShowPortsCmd::Do(), and ProximMainFrame::onToggleWindow().

Here is the call graph for this function:

◆ disassemblyWindow()

ProximDisassemblyWindow * ProximToolbox::disassemblyWindow ( )
static

Returns pointer to the program disassembly window.

Returns NULL if the disassembly window does not exist.

Returns
Pointer to the disassembly window.

Definition at line 150 of file ProximToolbox.cc.

150  {
151 
152  wxWindow* topWindow = wxGetApp().GetTopWindow();
153 
154  if (topWindow == NULL) {
155  return NULL;
156  }
157 
158  wxWindow* disasmWin = topWindow->FindWindowById(
160 
161  if (disasmWin == NULL) {
162  return NULL;
163  }
164 
165  return dynamic_cast<ProximDisassemblyWindow*>(disasmWin);
166 }

References ProximConstants::ID_DISASSEMBLY_WINDOW.

Referenced by DisasmTopCountAttrProvider::DisasmTopCountAttrProvider(), ClearDisassemblyHighlightCmd::Do(), HighlightExecPercentageCmd::Do(), HighlightTopExecCountsCmd::Do(), ProximBreakpointWindow::onBreakpointLookup(), FindWindow::onFindNext(), FindWindow::onFindPrev(), FindWindow::onInputText(), and DisasmExecCountFrame::onSelection().

◆ frontend()

TracedSimulatorFrontend * ProximToolbox::frontend ( )
static

◆ interpreter()

SimulatorInterpreter * ProximToolbox::interpreter ( )
static

Returns pointer to the simulator control language interpreter used by the simulator backend.

Returns
Simulator control language interpreter of the simulator.

Definition at line 207 of file ProximToolbox.cc.

207  {
208 
209  ProximSimulationThread* simulation = wxGetApp().simulation();
210  if (simulation == NULL) {
211  return NULL;
212  }
213 
214  return simulation->interpreter();
215 }

References ProximSimulationThread::interpreter().

Referenced by testCondition(), and testExpression().

Here is the call graph for this function:

◆ lineReader()

ProximLineReader & ProximToolbox::lineReader ( )
static

Returns reference to the line reader used by the simulator engine.

Returns
Simulator linereader.

Definition at line 238 of file ProximToolbox.cc.

238  {
239  return wxGetApp().simulation()->lineReader();
240 }

Referenced by ProximSimulatorSettingsCmd::Do(), ProximExecuteFileCmd::Do(), ProximQuitCmd::Do(), AddBreakpointDialog::onOK(), WatchPropertiesDialog::onOK(), AddWatchDialog::onOK(), BreakpointPropertiesDialog::onOK(), and ProximMainFrame::onToggleWindow().

◆ machine()

const TTAMachine::Machine & ProximToolbox::machine ( )
static

Returns the simulated machine.

Returns NullMachine, if a machine is not loaded in the simulator.

Returns
Reference to the simulated machine.

Definition at line 69 of file ProximToolbox.cc.

69  {
70 
71  TracedSimulatorFrontend* frontend = wxGetApp().simulation()->frontend();
72  if (frontend == NULL) {
74  } else {
75  return frontend->machine();
76  }
77 }

References frontend(), TTAMachine::NullMachine::instance(), and SimulatorFrontend::machine().

Referenced by AddWatchDialog::initialize(), AddWatchDialog::onASChoice(), AddWatchDialog::onFUChoice(), AddWatchDialog::onRFChoice(), ProximMachineStateWindow::ProximMachineStateWindow(), and ProximMachineStateWindow::setUtilizationHighlights().

Here is the call graph for this function:

◆ machineStateWindow()

ProximMachineStateWindow * ProximToolbox::machineStateWindow ( )
static

Returns pointer to the machine state window.

Returns NULL if the machine state window does not exist.

Returns
Pointer to the machine state window.

Definition at line 123 of file ProximToolbox.cc.

123  {
124 
125  wxWindow* topWindow = wxGetApp().GetTopWindow();
126 
127  if (topWindow == NULL) {
128  return NULL;
129  }
130 
131  wxWindow* machineWin = topWindow->FindWindowById(
133 
134  if (machineWin == NULL) {
135  return NULL;
136  }
137 
138  return dynamic_cast<ProximMachineStateWindow*>(machineWin);
139 }

References ProximConstants::ID_MACHINE_STATE_WINDOW.

Referenced by ProximComponentStatusCmd::Do(), ProximSetMachineWinStatusCmd::Do(), ProximFUPortDetailsCmd::Do(), ProximRFDetailsCmd::Do(), ProximSocketDetailsCmd::Do(), ProximIUDetailsCmd::Do(), ProximBusDetailsCmd::Do(), ProximFUDetailsCmd::Do(), and ProximMachineCanvasTool::onMouseEvent().

◆ mainFrame()

ProximMainFrame * ProximToolbox::mainFrame ( )
static

Returns pointer to the application main frame.

Returns
Application main frame, or NULL if the main frame does not exist.

Definition at line 105 of file ProximToolbox.cc.

105  {
106  wxWindow* topWindow = wxGetApp().GetTopWindow();
107  if (topWindow != NULL) {
108  return dynamic_cast<ProximMainFrame*>(topWindow);
109  } else {
110  return NULL;
111  }
112 }

Referenced by addFramedWindow(), ProximNewPortWindowCmd::Do(), ProximNewRegisterWindowCmd::Do(), ProximFindCmd::Do(), ProximOptionsCmd::Do(), ProximShowPortsCmd::Do(), ProximShowRegistersCmd::Do(), and ProximSimulatorWindow::~ProximSimulatorWindow().

◆ program()

const TTAProgram::Program & ProximToolbox::program ( )
static

Returns the simulated program.

Returns NullProgram, if a program is not loaded in the simulator.

Returns
Reference to the simulated program.

Definition at line 88 of file ProximToolbox.cc.

88  {
89 
90  TracedSimulatorFrontend* frontend = wxGetApp().simulation()->frontend();
91  if (frontend == NULL) {
93  } else {
94  return frontend->program();
95  }
96 }

References frontend(), TTAProgram::NullProgram::instance(), and SimulatorFrontend::program().

Referenced by ProximSetMachineWinStatusCmd::Do(), FindWindow::find(), ProximDebuggerWindow::onProgramLoaded(), ProximDisassemblyWindow::onProgramLoaded(), ProximDebuggerWindow::ProximDebuggerWindow(), and ProximDebuggerWindow::updateAnnotations().

Here is the call graph for this function:

◆ testCondition()

bool ProximToolbox::testCondition ( wxWindow *  parent,
const std::string &  condition 
)
static

Tests condition script validity.

An error dialog is displayed if the script is not legal.

Parameters
parentParent window for the possible error dialog to display.
conditionCondition script to test.

Definition at line 280 of file ProximToolbox.cc.

281  {
282 
283  TclConditionScript conditionScript(interpreter(), condition);
284 
285  // Check condition script validity using script interpreter.
286  try {
287  conditionScript.execute();
288  } catch (const ScriptExecutionFailure& sef) {
289  // Condition erroneous. Display error dialog.
290  wxString message = _T("Error in condition:\n");
291  message.Append(WxConversion::toWxString(sef.errorMessage()));
292  ErrorDialog dialog(parent, message);
293  dialog.ShowModal();
294  return false;
295  }
296  return true;
297 }

References Exception::errorMessage(), Script::execute(), interpreter(), and WxConversion::toWxString().

Referenced by WatchPropertiesDialog::onOK(), and BreakpointPropertiesDialog::onOK().

Here is the call graph for this function:

◆ testExpression()

bool ProximToolbox::testExpression ( wxWindow *  parent,
const std::string &  expression 
)
static

Tests expression script validity.

An error dialog is displayed if the script is not legal.

Parameters
parentParent window for the possible error dialog to display.
expressionExpression script to test.

Definition at line 252 of file ProximToolbox.cc.

253  {
254 
255  ExpressionScript expressionScript(interpreter(), expression);
256 
257  // Check condition script validity using script interpreter.
258  try {
259  expressionScript.execute();
260  } catch (const ScriptExecutionFailure& sef) {
261  // Condition erroneous. Display error dialog.
262  wxString message = _T("Error in expression:\n");
263  message.Append(WxConversion::toWxString(sef.errorMessage()));
264  ErrorDialog dialog(parent, message);
265  dialog.ShowModal();
266  return false;
267  }
268  return true;
269 }

References Exception::errorMessage(), Script::execute(), interpreter(), and WxConversion::toWxString().

Referenced by AddWatchDialog::onOK().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
ProximMainFrame
Definition: ProximMainFrame.hh:58
TracedSimulatorFrontend
Definition: TracedSimulatorFrontend.hh:49
ProximConstants::ID_MACHINE_STATE_WINDOW
@ ID_MACHINE_STATE_WINDOW
Definition: ProximConstants.hh:92
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
WxConversion::toWxString
static wxString toWxString(const std::string &source)
ProximToolbox::mainFrame
static ProximMainFrame * mainFrame()
Definition: ProximToolbox.cc:105
SimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimulatorFrontend.cc:276
ProximConstants::ID_DISASSEMBLY_WINDOW
@ ID_DISASSEMBLY_WINDOW
Definition: ProximConstants.hh:91
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
ExpressionScript
Definition: ExpressionScript.hh:44
ProximSimulationThread
Definition: ProximSimulationThread.hh:55
ProximSimulationThread::interpreter
SimulatorInterpreter * interpreter()
Definition: ProximSimulationThread.cc:244
ProximMachineStateWindow
Definition: ProximMachineStateWindow.hh:56
TclConditionScript
Definition: TclConditionScript.hh:50
ProximToolbox::interpreter
static SimulatorInterpreter * interpreter()
Definition: ProximToolbox.cc:207
TTAProgram::NullProgram::instance
static NullProgram & instance()
Definition: NullProgram.cc:72
ErrorDialog
Definition: ErrorDialog.hh:42
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TTAMachine::NullMachine::instance
static NullMachine & instance()
Definition: NullMachine.cc:60
ScriptExecutionFailure
Definition: Exception.hh:657
ProximDisassemblyWindow
Definition: ProximDisassemblyWindow.hh:58