OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SimulateDialog Class Reference

#include <SimulateDialog.hh>

Inheritance diagram for SimulateDialog:
Inheritance graph
Collaboration diagram for SimulateDialog:
Collaboration graph

Public Member Functions

 SimulateDialog (wxWindow *parent, Operation *operation, const std::string &pathName, const std::string &modName)
 
virtual ~SimulateDialog ()
 
std::string formattedValue (SimValue *value)
 

Static Public Attributes

static const wxString DIALOG_NAME = _T("SimulateDialog")
 Name of the dialog so it can be found with wxWindow::FindWindowByName.
 

Private Types

enum  {
  ID_INPUT_LIST = 12000 , ID_VALUE , ID_BUTTON_UPDATE , ID_OUTPUT_LIST ,
  ID_TEXT_READY , ID_BITMAP_READY , ID_TEXT_UPDATE , ID_BITMAP_UPDATE ,
  ID_TEXT_CLOCK , ID_TEXT_CLOCK_VALUE , ID_BUTTON_RESET , ID_BUTTON_TRIGGER ,
  ID_BUTTON_LATE_RESULT , ID_BUTTON_ADVANCE_LOCK , ID_BUTTON_SHOW_HIDE_REGISTERS , ID_FORMAT_TEXT ,
  ID_FORMAT
}
 

Private Member Functions

 SimulateDialog (const SimulateDialog &)
 Copying not allowed.
 
SimulateDialogoperator= (const SimulateDialog &)
 Assignment not allowed.
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
wxBitmap createBitmap (unsigned int index)
 
virtual bool TransferDataToWindow ()
 
void updateLists ()
 
void setTexts ()
 
void onSelection (wxListEvent &event)
 
void onUpdateValue (wxCommandEvent &event)
 
void onReset (wxCommandEvent &event)
 
void onTrigger (wxCommandEvent &event)
 
void onLateResult (wxCommandEvent &event)
 
void onAdvanceClock (wxCommandEvent &event)
 
void onFormatChanged (wxCommandEvent &event)
 
void showOrHideRegisters (wxCommandEvent &event)
 
void onOK (wxCommandEvent &event)
 
void onClose (wxCloseEvent &)
 
void setInputValues (std::vector< SimValue * > inputs)
 
void setOutputValues (std::vector< SimValue * > outputs)
 
void createState ()
 

Private Attributes

wxStaticBoxSizer * inputSizer_
 Input operand sizer.
 
wxStaticBoxSizer * outputSizer_
 Output operand sizer.
 
wxListCtrl * inputList_
 Input list.
 
wxListCtrl * outputList_
 Output list.
 
NumberControlupdateValue_
 Text control for updating input values.
 
wxChoice * format_
 Choice list of possible output formats.
 
Operationoperation_
 Bitmap for Trigger result.
 
std::string pathName_
 Path in which operation module belongs to.
 
std::string modName_
 Module in which operation belongs to.
 
std::vector< DataObject * > inputs_
 List of input values.
 
std::vector< DataObject * > outputs_
 List of output values.
 
unsigned int clock_
 Variable where the value of clock is kept.
 
SimulationInfoDialoginfoDialog_
 Dialog for showing additional information.
 
OperationBehaviorProxybehaviorProxy_
 The behavior proxy that loads the behavior. Used to "freeze" the behavior loading for the duration of the simulation.
 

Static Private Attributes

static const std::string FORMAT_SIGNED_INT = "signed int"
 Signed int format.
 
static const std::string FORMAT_UNSIGNED_INT = "unsigned int"
 Unsigned int format.
 
static const std::string FORMAT_DOUBLE = "double"
 Double format.
 
static const std::string FORMAT_FLOAT = "float"
 Float format.
 
static const std::string FORMAT_BINARY = "binary"
 Binary format.
 
static const std::string FORMAT_HEXA_DECIMAL = "hexadecimal"
 Hexadecimal format.
 

Detailed Description

Class for simulating operation behavior.

Definition at line 53 of file SimulateDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Component ids.

Enumerator
ID_INPUT_LIST 
ID_VALUE 
ID_BUTTON_UPDATE 
ID_OUTPUT_LIST 
ID_TEXT_READY 
ID_BITMAP_READY 
ID_TEXT_UPDATE 
ID_BITMAP_UPDATE 
ID_TEXT_CLOCK 
ID_TEXT_CLOCK_VALUE 
ID_BUTTON_RESET 
ID_BUTTON_TRIGGER 
ID_BUTTON_LATE_RESULT 
ID_BUTTON_ADVANCE_LOCK 
ID_BUTTON_SHOW_HIDE_REGISTERS 
ID_FORMAT_TEXT 
ID_FORMAT 

Definition at line 109 of file SimulateDialog.hh.

109 {
110 ID_INPUT_LIST = 12000,
111 ID_VALUE,
127 };

Constructor & Destructor Documentation

◆ SimulateDialog() [1/2]

SimulateDialog::SimulateDialog ( wxWindow *  parent,
Operation operation,
const std::string &  pathName,
const std::string &  modName 
)

Constructor.

Parameters
parentParent window.
operationOperation to be simulated.

Definition at line 98 of file SimulateDialog.cc.

102 :
103 wxDialog(parent, -1, _T(""),
105 wxDefaultSize, wxRESIZE_BORDER, DIALOG_NAME),
106 operation_(operation), pathName_(pathName), modName_(modName), clock_(0) {
107
108 createContents(this, true, true);
109
110 for (int i = 0; i < operation_->numberOfInputs(); i++) {
111 inputs_.push_back(new DataObject());
112 inputs_[i]->setString("0");
113 }
114
115 for (int i = 0; i < operation_->numberOfOutputs(); i++) {
116 outputs_.push_back(new DataObject());
117 outputs_[i]->setString("0");
118 }
119
120 inputList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_INPUT_LIST));
121 outputList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_OUTPUT_LIST));
123 format_ = dynamic_cast<wxChoice*>(FindWindow(ID_FORMAT));
124 //triggerBM_ = dynamic_cast<wxStaticBitmap*>(FindWindow(ID_BITMAP_READY));
125
126 //lateResultBM_ =
127 // dynamic_cast<wxStaticBitmap*>(FindWindow(ID_BITMAP_UPDATE));
128
129 FindWindow(wxID_OK)->SetFocus();
130
137
138 format_->SetSelection(0);
139
140 setTexts();
141
144 OSEdInformer* informer = wxGetApp().mainFrame()->informer();
147
148 /* Ensure we won't refresh the behavior from the plugin file again
149 during the simulation. This leads to crashes due to using a state
150 instance created by a behavior definition created by a previously
151 loaded behavior instance. This effectively "freezes" the behavior
152 to the one loaded in the next behavior function call. */
154 dynamic_cast<OperationBehaviorProxy*>(&operation->behavior());
155 assert(behaviorProxy_ != NULL);
157}
#define assert(condition)
static wxPoint getPosition(Dialogs dialog)
@ DIALOG_SIMULATE
Simulation dialog.
@ EVENT_REGISTER
Event when register value might change.
@ EVENT_RESET
Event when operation is reseted.
void registerListener(EventId event, OSEdListener *listener)
virtual void setAlwaysReloadBehavior(bool f)
static OperationContext & operationContext()
virtual OperationBehavior & behavior() const
Definition Operation.cc:388
virtual int numberOfInputs() const
Definition Operation.cc:192
virtual int numberOfOutputs() const
Definition Operation.cc:202
static const std::string FORMAT_SIGNED_INT
Signed int format.
std::string pathName_
Path in which operation module belongs to.
wxChoice * format_
Choice list of possible output formats.
static const std::string FORMAT_BINARY
Binary format.
static const std::string FORMAT_UNSIGNED_INT
Unsigned int format.
wxListCtrl * inputList_
Input list.
SimulationInfoDialog * infoDialog_
Dialog for showing additional information.
std::vector< DataObject * > outputs_
List of output values.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
static const std::string FORMAT_HEXA_DECIMAL
Hexadecimal format.
unsigned int clock_
Variable where the value of clock is kept.
std::string modName_
Module in which operation belongs to.
OperationBehaviorProxy * behaviorProxy_
The behavior proxy that loads the behavior. Used to "freeze" the behavior loading for the duration of...
Operation * operation_
Bitmap for Trigger result.
static const std::string FORMAT_DOUBLE
Double format.
std::vector< DataObject * > inputs_
List of input values.
NumberControl * updateValue_
Text control for updating input values.
static const wxString DIALOG_NAME
Name of the dialog so it can be found with wxWindow::FindWindowByName.
wxListCtrl * outputList_
Output list.
static const std::string FORMAT_FLOAT
Float format.
static wxString toWxString(const std::string &source)

References assert, OSEdInformer::EVENT_REGISTER, OSEdInformer::EVENT_RESET, OperationContainer::operationContext(), OSEdInformer::registerListener(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ ~SimulateDialog()

SimulateDialog::~SimulateDialog ( )
virtual

Destructor.

Definition at line 162 of file SimulateDialog.cc.

162 {
163
166
167 int x, y;
168 GetPosition(&x, &y);
169 wxPoint point(x, y);
171
172 /* Ensure we won't use the old state object the next time because
173 the behavior will be reloaded from the dynlib. It would crash. */
176
177 /* "Unfreeze" the OperationBehavior. Now it will be reloaded always
178 when accessing the methods to enable the dynamic menu items in
179 the operation list. */
182
183}
static void setPosition(Dialogs dialog, wxPoint point)
virtual void deleteState(OperationContext &context) const
static void deleteAllItems(SequenceType &aSequence)

References Operation::behavior(), behaviorProxy_, SequenceTools::deleteAllItems(), OperationBehavior::deleteState(), DialogPosition::DIALOG_SIMULATE, inputs_, operation_, OperationContainer::operationContext(), outputs_, OperationBehaviorProxy::setAlwaysReloadBehavior(), DialogPosition::setPosition(), and OperationBehaviorProxy::uninitializeBehavior().

Here is the call graph for this function:

◆ SimulateDialog() [2/2]

SimulateDialog::SimulateDialog ( const SimulateDialog )
private

Copying not allowed.

Member Function Documentation

◆ createBitmap()

wxBitmap SimulateDialog::createBitmap ( unsigned int  index)
private

Definition at line 693 of file SimulateDialog.cc.

693 {
694
695 if (index == 0)
696 {
697 /* XPM */
698 static const char *xpm_data[] = {
699 /* columns rows colors chars-per-pixel */
700 "16 15 2 1",
701 " c None",
702 "a c #FF0000",
703 /* pixels */
704 " ",
705 " aaaaaaaaaaaaaa ",
706 " aaaaaaaaaaaaaa ",
707 " aaaaaaaaaaaaaa ",
708 " aaaaaaaaaaaaaa ",
709 " aaaaaaaaaaaaaa ",
710 " aaaaaaaaaaaaaa ",
711 " aaaaaaaaaaaaaa ",
712 " aaaaaaaaaaaaaa ",
713 " aaaaaaaaaaaaaa ",
714 " aaaaaaaaaaaaaa ",
715 " aaaaaaaaaaaaaa ",
716 " aaaaaaaaaaaaaa ",
717 " aaaaaaaaaaaaaa ",
718 " "
719 };
720 wxBitmap bitmap( xpm_data );
721 return bitmap;
722 }
723 if (index == 1)
724 {
725 /* XPM */
726 static const char *xpm_data[] = {
727 /* columns rows colors chars-per-pixel */
728 "16 15 2 1",
729 " c None",
730 "b c #00FF00",
731 /* pixels */
732 " ",
733 " bbbbbbbbbbbbbb ",
734 " bbbbbbbbbbbbbb ",
735 " bbbbbbbbbbbbbb ",
736 " bbbbbbbbbbbbbb ",
737 " bbbbbbbbbbbbbb ",
738 " bbbbbbbbbbbbbb ",
739 " bbbbbbbbbbbbbb ",
740 " bbbbbbbbbbbbbb ",
741 " bbbbbbbbbbbbbb ",
742 " bbbbbbbbbbbbbb ",
743 " bbbbbbbbbbbbbb ",
744 " bbbbbbbbbbbbbb ",
745 " bbbbbbbbbbbbbb ",
746 " "
747 };
748 wxBitmap bitmap( xpm_data );
749 return bitmap;
750 }
751 if (index == 2)
752 {
753 /* XPM */
754 static const char *xpm_data[] = {
755 /* columns rows colors chars-per-pixel */
756 "16 15 2 1",
757 " c None",
758 "a c Black",
759 /* pixels */
760 " ",
761 " aaaaaaaaaaaaaa ",
762 " aaaaaaaaaaaaaa ",
763 " aaaaaaaaaaaaaa ",
764 " aaaaaaaaaaaaaa ",
765 " aaaaaaaaaaaaaa ",
766 " aaaaaaaaaaaaaa ",
767 " aaaaaaaaaaaaaa ",
768 " aaaaaaaaaaaaaa ",
769 " aaaaaaaaaaaaaa ",
770 " aaaaaaaaaaaaaa ",
771 " aaaaaaaaaaaaaa ",
772 " aaaaaaaaaaaaaa ",
773 " aaaaaaaaaaaaaa ",
774 " "
775 };
776 wxBitmap bitmap( xpm_data );
777 return bitmap;
778 }
779 return wxNullBitmap;
780}

◆ createContents()

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

Creates the contents of the dialog.

NOTE! This function was generated by wxDesigner.

Parameters
parentParent window.
call_fitIf true fits the contenst inside the dialog.
set_sizerIf true sets the main sizer as dialog contents.
Returns
The created sizer.

Definition at line 582 of file SimulateDialog.cc.

585 {
586
587 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
588
589 wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
590
591 wxStaticBox *item3 = new wxStaticBox( parent, -1, wxT("Input values") );
592 wxStaticBoxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
593 inputSizer_ = item2;
594
595 wxListCtrl *item4 = new wxListCtrl( parent, ID_INPUT_LIST, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER );
596 item2->Add( item4, 1, wxGROW|wxALL, 5 );
597
598 wxBoxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
599
600 NumberControl *item6 = new NumberControl(
601 parent, ID_VALUE, wxDefaultPosition, wxSize(200, -1),
605
606 item5->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
607
608 wxButton *item7 = new wxButton( parent, ID_BUTTON_UPDATE, wxT("Update"), wxDefaultPosition, wxDefaultSize, 0 );
609 item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
610
611 item2->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
612
613 item1->Add( item2, 1, wxGROW|wxALL, 5 );
614
615 wxStaticBox *item9 = new wxStaticBox( parent, -1, wxT("Output values") );
616 wxStaticBoxSizer *item8 = new wxStaticBoxSizer( item9, wxVERTICAL );
617 outputSizer_ = item8;
618
619 wxListCtrl *item10 = new wxListCtrl( parent, ID_OUTPUT_LIST, wxDefaultPosition, wxSize(200,120), wxLC_REPORT|wxSUNKEN_BORDER );
620 item8->Add( item10, 1, wxGROW|wxALL, 5 );
621
622 item1->Add( item8, 1, wxGROW|wxALL, 5 );
623
624 wxGridSizer *item11 = new wxGridSizer( 2, 0, 0 );
625
626 //wxStaticText *item12 = new wxStaticText( parent, ID_TEXT_READY, wxT("Ready"), wxDefaultPosition, wxDefaultSize, 0 );
627 //item11->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
628
629 //wxStaticBitmap *item13 = new wxStaticBitmap( parent, ID_BITMAP_READY, createBitmap( 2 ), wxDefaultPosition, wxDefaultSize );
630 //item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
631
632 //wxStaticText *item14 = new wxStaticText( parent, ID_TEXT_UPDATE, wxT("Update"), wxDefaultPosition, wxDefaultSize, 0 );
633 //item11->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
634
635 //wxStaticBitmap *item15 = new wxStaticBitmap( parent, ID_BITMAP_UPDATE, createBitmap( 2 ), wxDefaultPosition, wxDefaultSize );
636 //item11->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
637
638 wxStaticText *item16 = new wxStaticText( parent, ID_TEXT_CLOCK, wxT("Clock count:"), wxDefaultPosition, wxDefaultSize, 0 );
639 item11->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
640
641 wxStaticText *item17 = new wxStaticText( parent, ID_TEXT_CLOCK_VALUE, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 );
642 item11->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
643
644 item1->Add( item11, 0, wxGROW|wxALL, 5 );
645
646 item0->Add( item1, 1, wxGROW|wxALL, 5 );
647
648 wxBoxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );
649
650 wxStaticText *item19 = new wxStaticText( parent, ID_FORMAT_TEXT, wxT("Format:"), wxDefaultPosition, wxDefaultSize, 0 );
651 item18->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
652
653 wxString *strs20 = (wxString*) NULL;
654 wxChoice *item20 = new wxChoice( parent, ID_FORMAT, wxDefaultPosition, wxSize(130,-1), 0, strs20, 0 );
655 item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
656
657 item0->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
658
659 wxBoxSizer *item21 = new wxBoxSizer( wxHORIZONTAL );
660
661 wxButton *item22 = new wxButton( parent, ID_BUTTON_RESET, wxT("Reset"), wxDefaultPosition, wxDefaultSize, 0 );
662 item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
663
664 wxButton *item23 = new wxButton( parent, ID_BUTTON_TRIGGER, wxT("Trigger"), wxDefaultPosition, wxDefaultSize, 0 );
665 item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
666
667 wxButton *item25 = new wxButton( parent, ID_BUTTON_ADVANCE_LOCK, wxT("Advance Clock"), wxDefaultPosition, wxDefaultSize, 0 );
668 item21->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
669
670 wxButton *item26 = new wxButton( parent, ID_BUTTON_SHOW_HIDE_REGISTERS, wxT("Show registers"), wxDefaultPosition, wxDefaultSize, 0 );
671 item21->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
672
673 wxButton *item27 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
674 item21->Add( item27, 0, wxALIGN_CENTER|wxALL, 5 );
675
676 item0->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
677
678 if (set_sizer)
679 {
680 parent->SetSizer( item0 );
681 if (call_fit)
682 item0->SetSizeHints( parent );
683 }
684
685 return item0;
686
687}
static const long MODE_INT
Style flag for signed integer mode availablity.
static const long MODE_UNSIGNED
Style flag for unsigned integer mode availability.
static const long MODE_DOUBLE
Style flag for double mode availability.
static const long MODE_FLOAT
Style flag for float mode availability.
static const long MODE_BINARY
Style flag for binary mode availability.
static const long MODE_HEXADECIMAL
Style flag for hexadecimal mode availability.
wxStaticBoxSizer * inputSizer_
Input operand sizer.
wxStaticBoxSizer * outputSizer_
Output operand sizer.

References ID_BUTTON_ADVANCE_LOCK, ID_BUTTON_RESET, ID_BUTTON_SHOW_HIDE_REGISTERS, ID_BUTTON_TRIGGER, ID_BUTTON_UPDATE, ID_FORMAT, ID_FORMAT_TEXT, ID_INPUT_LIST, ID_OUTPUT_LIST, ID_TEXT_CLOCK, ID_TEXT_CLOCK_VALUE, ID_VALUE, inputSizer_, NumberControl::MODE_BINARY, NumberControl::MODE_DOUBLE, NumberControl::MODE_FLOAT, NumberControl::MODE_HEXADECIMAL, NumberControl::MODE_INT, NumberControl::MODE_UNSIGNED, and outputSizer_.

◆ createState()

void SimulateDialog::createState ( )
private

Creates the state for the operation.

Definition at line 566 of file SimulateDialog.cc.

566 {
569}
virtual void createState(OperationContext &context) const

References Operation::behavior(), OperationBehavior::createState(), operation_, and OperationContainer::operationContext().

Referenced by onAdvanceClock(), and onTrigger().

Here is the call graph for this function:

◆ formattedValue()

string SimulateDialog::formattedValue ( SimValue value)

Formats the value of the SimValue.

Parameters
valueValue to be formatted.

Definition at line 532 of file SimulateDialog.cc.

532 {
533
534 string format = WxConversion::toString(format_->GetStringSelection());
535 if (format == FORMAT_SIGNED_INT) {
536 SIntWord intSigned = value->sIntWordValue();
537 return Conversion::toString(static_cast<int>(intSigned));
538 } else if (format == FORMAT_UNSIGNED_INT) {
539 UIntWord intUnsigned = value->uIntWordValue();
540 return Conversion::toString(intUnsigned);
541 } else if (format == FORMAT_DOUBLE) {
542 DoubleWord doubleWord = value->doubleWordValue();
543 return Conversion::toString(doubleWord);
544 } else if (format == FORMAT_FLOAT) {
545 FloatWord floatWord = value->floatWordValue();
546 string floatString = Conversion::toString(floatWord);
547 if (floatString.find(".") == string::npos) {
548 floatString += ".0";
549 }
550 floatString += "f";
551 return floatString;
552 } else if (format == FORMAT_BINARY) {
553 UIntWord binary = value->uIntWordValue();
554 return Conversion::toBinString(static_cast<int>(binary));
555 } else if (format == FORMAT_HEXA_DECIMAL) {
556 UIntWord hex = value->uIntWordValue();
557 return Conversion::toHexString(hex);
558 }
559 return "";
560}
Word UIntWord
Definition BaseType.hh:144
float FloatWord
Definition BaseType.hh:160
double DoubleWord
Definition BaseType.hh:166
SignedWord SIntWord
Definition BaseType.hh:149
static std::string toBinString(int source)
Definition Conversion.cc:81
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
static std::string toString(const T &source)
SIntWord sIntWordValue() const
Definition SimValue.cc:944
UIntWord uIntWordValue() const
Definition SimValue.cc:972
DoubleWord doubleWordValue() const
Definition SimValue.cc:1052
FloatWord floatWordValue() const
Definition SimValue.cc:1075
static std::string toString(const wxString &source)

References SimValue::doubleWordValue(), SimValue::floatWordValue(), format_, FORMAT_BINARY, FORMAT_DOUBLE, FORMAT_FLOAT, FORMAT_HEXA_DECIMAL, FORMAT_SIGNED_INT, FORMAT_UNSIGNED_INT, SimValue::sIntWordValue(), Conversion::toBinString(), Conversion::toHexString(), Conversion::toString(), WxConversion::toString(), and SimValue::uIntWordValue().

Referenced by onUpdateValue(), setInputValues(), setOutputValues(), and SimulationInfoDialog::updateList().

Here is the call graph for this function:

◆ onAdvanceClock()

void SimulateDialog::onAdvanceClock ( wxCommandEvent &  event)
private

Handles the event when advance clock button is pushed.

Definition at line 399 of file SimulateDialog.cc.

399 {
400 createState();
403 clock_++;
405 OSEdInformer* informer = wxGetApp().mainFrame()->informer();
407}
virtual void advanceClock()
Definition Memory.cc:819
void handleEvent(EventId event)
@ EVENT_MEMORY
Event when memory may be changed.
static Memory & memory()

References Memory::advanceClock(), OperationContext::advanceClock(), clock_, createState(), OSEdInformer::EVENT_MEMORY, OSEdInformer::handleEvent(), ID_TEXT_CLOCK_VALUE, OperationContainer::memory(), OperationContainer::operationContext(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onClose()

void SimulateDialog::onClose ( wxCloseEvent &  event)
private

Handles the event when window is closed.

Parameters
eventEvent to be handled.

Definition at line 485 of file SimulateDialog.cc.

485 {
486 OSEdInformer* informer = wxGetApp().mainFrame()->informer();
489 infoDialog_->Destroy();
490 event.Skip();
491}
void unregisterListener(EventId event, OSEdListener *listener)

References OSEdInformer::EVENT_REGISTER, OSEdInformer::EVENT_RESET, infoDialog_, and OSEdInformer::unregisterListener().

Here is the call graph for this function:

◆ onFormatChanged()

void SimulateDialog::onFormatChanged ( wxCommandEvent &  event)
private

Handles the event when intput and output format is changed.

Definition at line 413 of file SimulateDialog.cc.

413 {
414
415 vector<SimValue*> outputs;
416
418 string result = "";
419
420 for (size_t i = 0; i < inputs_.size(); i++) {
421 SimValue* sim = new SimValue(32);
422 string value = inputs_[i]->stringValue();
423 simulator.initializeSimValue(value, sim, result);
424 outputs.push_back(sim);
425 }
426
427 for (size_t i = 0; i < outputs_.size(); i++) {
428 SimValue* sim = new SimValue(32);
429 string value = outputs_[i]->stringValue();
430 simulator.initializeSimValue(value, sim, result);
431 outputs.push_back(sim);
432 }
433
434 setInputValues(outputs);
435 setOutputValues(outputs);
436 updateLists();
438 OSEdInformer* informer = wxGetApp().mainFrame()->informer();
440}
static OperationSimulator & instance()
bool initializeSimValue(std::string value, SimValue *sim, std::string &result)
void setOutputValues(std::vector< SimValue * > outputs)
void setInputValues(std::vector< SimValue * > inputs)

References SequenceTools::deleteAllItems(), OSEdInformer::EVENT_REGISTER, OSEdInformer::handleEvent(), OperationSimulator::initializeSimValue(), inputs_, OperationSimulator::instance(), outputs_, setInputValues(), setOutputValues(), and updateLists().

Here is the call graph for this function:

◆ onLateResult()

void SimulateDialog::onLateResult ( wxCommandEvent &  event)
private

◆ onOK()

void SimulateDialog::onOK ( wxCommandEvent &  event)
private

Handles the event when OK button is pushed.

Definition at line 471 of file SimulateDialog.cc.

471 {
472 OSEdInformer* informer = wxGetApp().mainFrame()->informer();
475 infoDialog_->Destroy();
476 Destroy();
477}

References OSEdInformer::EVENT_REGISTER, OSEdInformer::EVENT_RESET, infoDialog_, and OSEdInformer::unregisterListener().

Here is the call graph for this function:

◆ onReset()

void SimulateDialog::onReset ( wxCommandEvent &  event)
private

Handles the event when Reset button is pushed.

Reset sets all values to their defaults.

Definition at line 336 of file SimulateDialog.cc.

336 {
337
340
341 for (size_t i = 0; i < inputs_.size(); i++) {
342 inputs_[i]->setString("0");
343 }
344
345 for (size_t i = 0; i < outputs_.size(); i++) {
346 outputs_[i]->setString("0");
347 }
348
349 //triggerBM_->SetBitmap(createBitmap(2));
350 //lateResultBM_->SetBitmap(createBitmap(2));
351 clock_ = 0;
354 updateLists();
355 OSEdInformer* informer = wxGetApp().mainFrame()->informer();
357}

References Operation::behavior(), clock_, OperationBehavior::deleteState(), OSEdInformer::EVENT_RESET, OSEdInformer::handleEvent(), ID_TEXT_CLOCK_VALUE, inputs_, operation_, OperationContainer::operationContext(), outputs_, WxConversion::toWxString(), and updateLists().

Here is the call graph for this function:

◆ onSelection()

void SimulateDialog::onSelection ( wxListEvent &  event)
private

Handles the event when a value is selected or deselected on input list.

Definition at line 299 of file SimulateDialog.cc.

299 {
300 if (inputList_->GetSelectedItemCount() != 1) {
301 FindWindow(ID_BUTTON_UPDATE)->Disable();
302 } else {
303 FindWindow(ID_BUTTON_UPDATE)->Enable();
304 }
305}

References ID_BUTTON_UPDATE, and inputList_.

Referenced by updateLists().

◆ onTrigger()

void SimulateDialog::onTrigger ( wxCommandEvent &  event)
private

Handles the event when Trigger button is pushed.

Definition at line 363 of file SimulateDialog.cc.

363 {
364
366 vector<SimValue*> outputs;
367 vector<DataObject> inputs;
368 for (size_t i = 0; i < inputs_.size(); i++) {
369 inputs.push_back(*inputs_[i]);
370 }
371
372 string result = "";
373
374 createState();
376 if (simulator.simulateTrigger(
377 *operation_, inputs, outputs, context, result)) {
378
379 //triggerBM_->SetBitmap(createBitmap(1));
380 setOutputValues(outputs);
381 updateLists();
382 } else {
383 //triggerBM_->SetBitmap(createBitmap(0));
384 if (result != "") {
385 ErrorDialog dialog(this, WxConversion::toWxString(result));
386 dialog.ShowModal();
387 }
388 }
390 OSEdInformer* informer = wxGetApp().mainFrame()->informer();
393}
bool simulateTrigger(Operation &op, std::vector< DataObject > inputs, std::vector< SimValue * > &outputs, OperationContext &context, std::string &result)

References createState(), SequenceTools::deleteAllItems(), OSEdInformer::EVENT_MEMORY, OSEdInformer::EVENT_REGISTER, OSEdInformer::handleEvent(), inputs_, OperationSimulator::instance(), operation_, OperationContainer::operationContext(), setOutputValues(), OperationSimulator::simulateTrigger(), WxConversion::toWxString(), and updateLists().

Here is the call graph for this function:

◆ onUpdateValue()

void SimulateDialog::onUpdateValue ( wxCommandEvent &  event)
private

Handles the event when input value is updated.

Definition at line 311 of file SimulateDialog.cc.

311 {
312 TransferDataFromWindow();
313 string inputString = WidgetTools::lcStringSelection(inputList_, 0);
314 if (inputString != "") {
315 int input = Conversion::toInt(inputString);
316 SimValue* temp = new SimValue(32);
318 double value = updateValue_->doubleValue();
319 *temp = value;
320 } else {
321 int value = updateValue_->intValue();
322 *temp = value;
323 }
324 inputs_[input - 1]->setString(formattedValue(temp));
325 delete temp;
326 updateLists();
327 }
328}
static int toInt(const T &source)
int intValue() const
double doubleValue() const
long mode() const
std::string formattedValue(SimValue *value)
static std::string lcStringSelection(wxListCtrl *list, int column)

References NumberControl::doubleValue(), formattedValue(), inputList_, inputs_, NumberControl::intValue(), WidgetTools::lcStringSelection(), NumberControl::mode(), NumberControl::MODE_DOUBLE, Conversion::toInt(), updateLists(), and updateValue_.

Here is the call graph for this function:

◆ operator=()

SimulateDialog & SimulateDialog::operator= ( const SimulateDialog )
private

Assignment not allowed.

◆ setInputValues()

void SimulateDialog::setInputValues ( std::vector< SimValue * >  inputs)
private

Sets the input values after the format has changed.

Parameters
inputsInput values of operation.

Definition at line 499 of file SimulateDialog.cc.

499 {
500
501 string inputFormat = WxConversion::toString(format_->GetStringSelection());
502
503 for (size_t i = 0; i < inputs_.size(); i++) {
504 SimValue* current = inputs[i];
505 inputs_[i]->setString(formattedValue(current));
506 }
507}

References format_, formattedValue(), inputs_, and WxConversion::toString().

Referenced by onFormatChanged().

Here is the call graph for this function:

◆ setOutputValues()

void SimulateDialog::setOutputValues ( std::vector< SimValue * >  outputs)
private

Sets the output values of the operation after executing a command.

Parameters
outputsOutput values of operation.

Definition at line 515 of file SimulateDialog.cc.

515 {
516
517 int k = 0;
518 size_t upperBound = inputs_.size() + outputs_.size();
519 for (size_t i = inputs_.size(); i < upperBound; i++) {
520 SimValue* current = outputs[i];
521 outputs_[k]->setString(formattedValue(current));
522 k++;
523 }
524}

References formattedValue(), inputs_, and outputs_.

Referenced by onFormatChanged(), and onTrigger().

Here is the call graph for this function:

◆ setTexts()

void SimulateDialog::setTexts ( )
private

Set texts to widgets.

Definition at line 198 of file SimulateDialog.cc.

198 {
199
202
203 // title
205 fmt % operation_->name();
206 SetTitle(WxConversion::toWxString(fmt.str()));
207
208 // static texts
209 //WidgetTools::setLabel(&osedText, FindWindow(ID_TEXT_READY),
210 // OSEdTextGenerator::TXT_LABEL_READY);
211
212 //WidgetTools::setLabel(&osedText, FindWindow(ID_TEXT_UPDATE),
213 // OSEdTextGenerator::TXT_LABEL_UPDATE);
214
217
220
221 // buttons
222 WidgetTools::setLabel(&guiText, FindWindow(wxID_OK),
224
227
230
233
236
239
240 // column titles
242 inputList_->InsertColumn(
243 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
245
246 outputList_->InsertColumn(
247 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
249
251 inputList_->InsertColumn(
252 1, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
254
255 outputList_->InsertColumn(
256 1, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
258
259 // box sizers
262
265}
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
static const int DEFAULT_COLUMN_WIDTH
Default column width.
static OSEdTextGenerator & instance()
@ TXT_BOX_INPUT_VALUES
Input values sizer label.
@ TXT_BUTTON_ADVANCE_LOCK
Advance Lock button label.
@ TXT_BUTTON_RESET
Reset button label.
@ TXT_COLUMN_OPERAND
Operand column header.
@ TXT_SIMULATE_DIALOG_TITLE
Simulate dialog title.
@ TXT_COLUMN_VALUE
Value column header.
@ TXT_LABEL_CLOCK
Clock label.
@ TXT_BOX_OUTPUT_VALUES
Output values sizer label.
@ TXT_BUTTON_TRIGGER
Trigger button label.
@ TXT_LABEL_FORMAT
Format label.
@ TXT_BUTTON_UPDATE
Update button label.
@ TXT_BUTTON_SHOW_REGISTERS
Show registers button label.
virtual TCEString name() const
Definition Operation.cc:93
virtual boost::format text(int textId)
static void setWidgetLabel(wxWindow *widget, std::string text)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References OSEdConstants::DEFAULT_COLUMN_WIDTH, ID_BUTTON_ADVANCE_LOCK, ID_BUTTON_RESET, ID_BUTTON_SHOW_HIDE_REGISTERS, ID_BUTTON_TRIGGER, ID_BUTTON_UPDATE, ID_FORMAT_TEXT, ID_TEXT_CLOCK, inputList_, inputSizer_, GUITextGenerator::instance(), OSEdTextGenerator::instance(), Operation::name(), operation_, outputList_, outputSizer_, WidgetTools::setLabel(), WidgetTools::setWidgetLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_BOX_INPUT_VALUES, OSEdTextGenerator::TXT_BOX_OUTPUT_VALUES, OSEdTextGenerator::TXT_BUTTON_ADVANCE_LOCK, GUITextGenerator::TXT_BUTTON_OK, OSEdTextGenerator::TXT_BUTTON_RESET, OSEdTextGenerator::TXT_BUTTON_SHOW_REGISTERS, OSEdTextGenerator::TXT_BUTTON_TRIGGER, OSEdTextGenerator::TXT_BUTTON_UPDATE, OSEdTextGenerator::TXT_COLUMN_OPERAND, OSEdTextGenerator::TXT_COLUMN_VALUE, OSEdTextGenerator::TXT_LABEL_CLOCK, OSEdTextGenerator::TXT_LABEL_FORMAT, and OSEdTextGenerator::TXT_SIMULATE_DIALOG_TITLE.

Here is the call graph for this function:

◆ showOrHideRegisters()

void SimulateDialog::showOrHideRegisters ( wxCommandEvent &  event)
private

Handles the event when registers are shown or hidden.

Definition at line 446 of file SimulateDialog.cc.

446 {
447 wxButton* button =
448 dynamic_cast<wxButton*>(FindWindow(ID_BUTTON_SHOW_HIDE_REGISTERS));
451 if (button->GetLabel() == WxConversion::toWxString(fmt.str())) {
452 int x, y;
453 GetPosition(&x, &y);
454 int width, height;
455 GetSize(&width, &height);
456 y += height + 25;
457 infoDialog_->Move(x, y);
458 infoDialog_->Show(true);
460 button->SetLabel(WxConversion::toWxString(fmt.str()));
461 } else {
462 infoDialog_->Show(false);
463 button->SetLabel(WxConversion::toWxString(fmt.str()));
464 }
465}
@ TXT_BUTTON_HIDE_REGISTERS
Hide registers button label.

References ID_BUTTON_SHOW_HIDE_REGISTERS, infoDialog_, OSEdTextGenerator::instance(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_BUTTON_HIDE_REGISTERS, and OSEdTextGenerator::TXT_BUTTON_SHOW_REGISTERS.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool SimulateDialog::TransferDataToWindow ( )
privatevirtual

Transfers data to window.

Definition at line 189 of file SimulateDialog.cc.

189 {
190 updateLists();
191 return wxWindow::TransferDataToWindow();
192}

References updateLists().

Here is the call graph for this function:

◆ updateLists()

void SimulateDialog::updateLists ( )
private

Updates input and output value lists.

Definition at line 271 of file SimulateDialog.cc.

271 {
272
273 inputList_->DeleteAllItems();
274 outputList_->DeleteAllItems();
275 for (unsigned int i = 0; i < inputs_.size(); i++) {
276 wxString id = WxConversion::toWxString(i + 1);
277 inputList_->InsertItem(i, id);
278 inputList_->SetItem(
279 i, 1, WxConversion::toWxString(inputs_[i]->stringValue()));
280 }
281
282 int k = inputs_.size() + 1;
283 for (unsigned int i = 0; i < outputs_.size(); i++) {
284 wxString id = WxConversion::toWxString(k);
285 outputList_->InsertItem(i, id);
286 outputList_->SetItem(
287 i, 1, WxConversion::toWxString(outputs_[i]->stringValue()));
288 k++;
289 }
290
291 wxListEvent dummy;
293}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onSelection(wxListEvent &event)

References dummy, inputList_, inputs_, onSelection(), outputList_, outputs_, and WxConversion::toWxString().

Referenced by onFormatChanged(), onReset(), onTrigger(), onUpdateValue(), and TransferDataToWindow().

Here is the call graph for this function:

Member Data Documentation

◆ behaviorProxy_

OperationBehaviorProxy* SimulateDialog::behaviorProxy_
private

The behavior proxy that loads the behavior. Used to "freeze" the behavior loading for the duration of the simulation.

Definition at line 161 of file SimulateDialog.hh.

Referenced by ~SimulateDialog().

◆ clock_

unsigned int SimulateDialog::clock_
private

Variable where the value of clock is kept.

Definition at line 156 of file SimulateDialog.hh.

Referenced by onAdvanceClock(), and onReset().

◆ DIALOG_NAME

const wxString SimulateDialog::DIALOG_NAME = _T("SimulateDialog")
static

Name of the dialog so it can be found with wxWindow::FindWindowByName.

Definition at line 66 of file SimulateDialog.hh.

Referenced by OSEdBuildAllCmd::Do(), and OSEdBuildCmd::Do().

◆ format_

wxChoice* SimulateDialog::format_
private

Choice list of possible output formats.

Definition at line 140 of file SimulateDialog.hh.

Referenced by formattedValue(), and setInputValues().

◆ FORMAT_BINARY

const string SimulateDialog::FORMAT_BINARY = "binary"
staticprivate

Binary format.

Definition at line 102 of file SimulateDialog.hh.

Referenced by formattedValue().

◆ FORMAT_DOUBLE

const string SimulateDialog::FORMAT_DOUBLE = "double"
staticprivate

Double format.

Definition at line 98 of file SimulateDialog.hh.

Referenced by formattedValue().

◆ FORMAT_FLOAT

const string SimulateDialog::FORMAT_FLOAT = "float"
staticprivate

Float format.

Definition at line 100 of file SimulateDialog.hh.

Referenced by formattedValue().

◆ FORMAT_HEXA_DECIMAL

const string SimulateDialog::FORMAT_HEXA_DECIMAL = "hexadecimal"
staticprivate

Hexadecimal format.

Definition at line 104 of file SimulateDialog.hh.

Referenced by formattedValue().

◆ FORMAT_SIGNED_INT

const string SimulateDialog::FORMAT_SIGNED_INT = "signed int"
staticprivate

Signed int format.

Definition at line 94 of file SimulateDialog.hh.

Referenced by formattedValue().

◆ FORMAT_UNSIGNED_INT

const string SimulateDialog::FORMAT_UNSIGNED_INT = "unsigned int"
staticprivate

Unsigned int format.

Definition at line 96 of file SimulateDialog.hh.

Referenced by formattedValue().

◆ infoDialog_

SimulationInfoDialog* SimulateDialog::infoDialog_
private

Dialog for showing additional information.

Definition at line 158 of file SimulateDialog.hh.

Referenced by onClose(), onOK(), and showOrHideRegisters().

◆ inputList_

wxListCtrl* SimulateDialog::inputList_
private

Input list.

Definition at line 134 of file SimulateDialog.hh.

Referenced by onSelection(), onUpdateValue(), setTexts(), and updateLists().

◆ inputs_

std::vector<DataObject*> SimulateDialog::inputs_
private

◆ inputSizer_

wxStaticBoxSizer* SimulateDialog::inputSizer_
private

Input operand sizer.

Definition at line 130 of file SimulateDialog.hh.

Referenced by createContents(), and setTexts().

◆ modName_

std::string SimulateDialog::modName_
private

Module in which operation belongs to.

Definition at line 150 of file SimulateDialog.hh.

◆ operation_

Operation* SimulateDialog::operation_
private

Bitmap for Trigger result.

Bitmap for Late Result result. Operation to be simulated.

Definition at line 146 of file SimulateDialog.hh.

Referenced by createState(), onReset(), onTrigger(), setTexts(), and ~SimulateDialog().

◆ outputList_

wxListCtrl* SimulateDialog::outputList_
private

Output list.

Definition at line 136 of file SimulateDialog.hh.

Referenced by setTexts(), and updateLists().

◆ outputs_

std::vector<DataObject*> SimulateDialog::outputs_
private

List of output values.

Definition at line 154 of file SimulateDialog.hh.

Referenced by onFormatChanged(), onReset(), setOutputValues(), updateLists(), and ~SimulateDialog().

◆ outputSizer_

wxStaticBoxSizer* SimulateDialog::outputSizer_
private

Output operand sizer.

Definition at line 132 of file SimulateDialog.hh.

Referenced by createContents(), and setTexts().

◆ pathName_

std::string SimulateDialog::pathName_
private

Path in which operation module belongs to.

Definition at line 148 of file SimulateDialog.hh.

◆ updateValue_

NumberControl* SimulateDialog::updateValue_
private

Text control for updating input values.

Definition at line 138 of file SimulateDialog.hh.

Referenced by onUpdateValue().


The documentation for this class was generated from the following files: