00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
00015 #pragma implementation "trigger_ch_control.h"
00016 #endif
00017
00018
00019 #include "wx/wxprec.h"
00020
00021 #ifdef __BORLANDC__
00022 #pragma hdrstop
00023 #endif
00024
00025 #ifndef WX_PRECOMP
00026 #include "wx/wx.h"
00027 #endif
00028
00031
00032 #include "trigger_ch_control.h"
00033
00036
00041 IMPLEMENT_DYNAMIC_CLASS( TriggerChControl, wxPanel )
00042
00043
00047 BEGIN_EVENT_TABLE( TriggerChControl, wxPanel )
00048
00050 EVT_SPINCTRL( ID_THRESHOLD_SPINCTRL, TriggerChControl::OnThresholdSpinctrlUpdated )
00051
00052 EVT_SPINCTRL( ID_THR_SAMPLES_SPINCTRL, TriggerChControl::OnThrSamplesSpinctrlUpdated )
00053
00055 EVT_TEXT_ENTER( ID_THRESHOLD_SPINCTRL, TriggerChControl::OnThresholdSpinctrlTextUpdated )
00056 EVT_TEXT_ENTER( ID_THR_SAMPLES_SPINCTRL, TriggerChControl::OnThrSamplesSpinctrlTextUpdated )
00057
00058 END_EVENT_TABLE()
00059
00064 TriggerChControl::TriggerChControl( )
00065 {
00066 }
00067
00068 TriggerChControl::TriggerChControl( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00069 {
00070 Create(parent, id, pos, size, style);
00071 }
00072
00077 bool TriggerChControl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00078 {
00080 m_main_sizer_text = NULL;
00081 m_ch_threshold_control = NULL;
00082 m_thr_sample_control = NULL;
00084
00086 wxPanel::Create( parent, id, pos, size, style );
00087
00088 CreateControls();
00089 if (GetSizer())
00090 {
00091 GetSizer()->SetSizeHints(this);
00092 }
00093 Centre();
00095 return true;
00096 }
00097
00102 void TriggerChControl::CreateControls()
00103 {
00105
00106
00107 TriggerChControl* itemPanel1 = this;
00108
00109 this->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, false, _T("Verdana")));
00110 m_main_sizer_text = new wxStaticBox(itemPanel1, wxID_ANY, _("???"));
00111 wxStaticBoxSizer* itemStaticBoxSizer2 = new wxStaticBoxSizer(m_main_sizer_text, wxVERTICAL);
00112 itemPanel1->SetSizer(itemStaticBoxSizer2);
00113
00114 m_ch_threshold_control = new wxSpinCtrl( itemPanel1, ID_THRESHOLD_SPINCTRL, _T("0"), wxDefaultPosition, wxSize(75, -1), wxSP_ARROW_KEYS, -1250, 1250, 0 );
00115 m_ch_threshold_control->SetHelpText(_("Set trigger threshold (mV)"));
00116 if (ShowToolTips())
00117 m_ch_threshold_control->SetToolTip(_("Set trigger threshold (mV)"));
00118 itemStaticBoxSizer2->Add(m_ch_threshold_control, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 3);
00119
00120 m_thr_sample_control = new wxSpinCtrl( itemPanel1, ID_THR_SAMPLES_SPINCTRL, _T("0"), wxDefaultPosition, wxSize(75, -1), wxSP_ARROW_KEYS, -99999, 99999, 0 );
00121 m_thr_sample_control->SetHelpText(_("Set threshold samples"));
00122 if (ShowToolTips())
00123 m_thr_sample_control->SetToolTip(_("Set threshold samples"));
00124 itemStaticBoxSizer2->Add(m_thr_sample_control, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 3);
00125
00127
00128 }
00129
00134 bool TriggerChControl::ShowToolTips()
00135 {
00136 return true;
00137 }
00138
00143 wxBitmap TriggerChControl::GetBitmapResource( const wxString& name )
00144 {
00145
00147 wxUnusedVar(name);
00148 return wxNullBitmap;
00150 }
00151
00156 wxIcon TriggerChControl::GetIconResource( const wxString& name )
00157 {
00158
00160 wxUnusedVar(name);
00161 return wxNullIcon;
00163 }
00164
00169 void TriggerChControl::OnThresholdSpinctrlUpdated( wxSpinEvent& event )
00170 {
00171 this->UpdateThreshold( event.GetPosition());
00172 }
00173
00174
00179 void TriggerChControl::OnThrSamplesSpinctrlUpdated( wxSpinEvent& event )
00180 {
00181 this->UpdateThrSamples( event.GetPosition());
00182 }
00183
00184 bool TriggerChControl::SetupBoard( GenericBoard* p_board, int ch_index, int ch_count)
00185 {
00186 this->m_p_board= p_board;
00187 this->m_ch_index= ch_index;
00188 this->m_ch_count= ch_count;
00189 if( ( size_t)this->m_ch_index>= this->m_p_board->m_channel_array.GetCount())
00190 return false;
00191 this->m_p_board_channel= (PhysicalBoardChannel*)this->m_p_board->m_channel_array[ this->m_ch_index];
00192
00193 if( !this->UpdateControls())
00194 return false;
00195 return true;
00196 }
00197 bool TriggerChControl::UpdateControls( )
00198 {
00199 this->m_main_sizer_text->SetLabel( wxString::Format( "%d", this->m_ch_count));
00200 this->m_ch_threshold_control->SetValue( (int)(double)(this->m_p_board_channel->m_trigger_threshold_volt* 1000.0));
00201 this->m_thr_sample_control->SetValue( this->m_p_board_channel->m_trigger_thr_sample);
00202
00203 this->m_p_board_channel->WriteChannelTrigger();
00204
00205 return true;
00206 }
00207
00212 void TriggerChControl::OnThresholdSpinctrlTextUpdated( wxCommandEvent& )
00213 {
00214 int value= atoi( this->m_ch_threshold_control->GetLabel( ));
00215 this->UpdateThreshold( value);
00216 }
00217
00222 void TriggerChControl::OnThrSamplesSpinctrlTextUpdated( wxCommandEvent& )
00223 {
00224 int value= atoi( this->m_thr_sample_control->GetLabel( ));
00225 this->UpdateThrSamples( value);
00226 }
00227
00228 void TriggerChControl::UpdateThreshold( int value)
00229 {
00230 this->m_p_board_channel->m_trigger_threshold_volt= (double)value/ 1000.0;
00231 this->m_p_board_channel->WriteChannelTrigger();
00232 for( int i= 0; i< SCOPE_NUM_PANELS; i++)
00233 {
00234 (this->m_p_board_channel->ScopeRefresh)( i, true);
00235 }
00236 }
00237
00238 void TriggerChControl::UpdateThrSamples( int value)
00239 {
00240 this->m_p_board_channel->m_trigger_thr_sample= value;
00241 this->m_p_board_channel->WriteChannelTrigger();
00242 for( int i= 0; i< SCOPE_NUM_PANELS; i++)
00243 {
00244 (this->m_p_board_channel->ScopeRefresh)( i, true);
00245 }
00246 }