00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013 #if defined(__GNUG__) && !defined(__APPLE__)
00014 #pragma implementation "physical_board_channel.h"
00015 #endif
00016
00017
00018 #include "wx/wxprec.h"
00019
00020 #ifdef __BORLANDC__
00021 #pragma hdrstop
00022 #endif
00023
00024 #ifndef WX_PRECOMP
00025 #include "wx/wx.h"
00026 #endif
00027 #include <wx/filename.h>
00028
00029
00030 #include "physical_board_channel.h"
00031 #include "appsettings.h"
00032 #include "drawing_panel.h"
00033
00034 PhysicalBoardChannel::PhysicalBoardChannel( GenericBoard* parent, int ch_index, cvt_board_data* p_data, void ( *scope_refresh)( int, bool), wxMutex* p_data_mutex, AppSettings *p_app_settings):
00035 GenericBoardChannel( parent, ch_index, p_data, scope_refresh, p_data_mutex, p_app_settings)
00036 {
00037 this->m_sample_buffer_size= 1024;
00038 this->m_p_sample_buffer= new UINT16[ this->m_sample_buffer_size];
00039 this->m_sample_buffer_count= 0;
00040
00041 this->m_tmp_sample_buffer_size= 1024;
00042 this->m_p_tmp_sample_buffer= new UINT16[ this->m_tmp_sample_buffer_size];
00043 this->m_tmp_sample_buffer_count= 0;
00044
00045 }
00046
00047 PhysicalBoardChannel::~PhysicalBoardChannel(void)
00048 {
00049 if( this->m_p_sample_buffer)
00050 {
00051 delete this->m_p_sample_buffer;
00052 this->m_p_sample_buffer= NULL;
00053 this->m_sample_buffer_count= 0;
00054 }
00055 if( this->m_p_tmp_sample_buffer)
00056 {
00057 delete this->m_p_tmp_sample_buffer;
00058 this->m_p_tmp_sample_buffer= NULL;
00059 this->m_tmp_sample_buffer_count= 0;
00060 }
00061 }
00062
00063 bool PhysicalBoardChannel::LoadConfig( wxConfigBase* p_config, const wxString& base_section)
00064 {
00065 GenericBoardChannel::LoadConfig( p_config, base_section);
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 this->m_DAC_offset_bit= 0x8000;
00078 p_config->Read( base_section+ _("DAC_OFFSET_BIT"), &this->m_DAC_offset_bit, 0x8000);
00079
00080
00081
00082 this->m_DAC_volt_2_bit= 26214.4;
00083 p_config->Read( base_section+ _("DAC_VOLT_2_BIT"), &this->m_DAC_volt_2_bit, 26214.4);
00084
00085
00086
00087 this->m_trigger_threshold_volt= 0;
00088 p_config->Read( base_section+ _("TRIGGER_THRESHOLD_VOLT"), &this->m_trigger_threshold_volt, 0.0);
00089
00090
00091 this->m_trigger_thr_sample= 0;
00092 p_config->Read( base_section+ _("TRIGGER_THR_SAMPLE"), &this->m_trigger_thr_sample, 0);
00093
00094 return true;
00095
00096 }
00097 bool PhysicalBoardChannel::SaveConfig( wxConfigBase* p_config, const wxString& base_section)
00098 {
00099 if( !GenericBoardChannel::SaveConfig( p_config, base_section))
00100 return false;
00101
00102
00103
00104 if( !p_config->Write( base_section+ _("DAC_OFFSET_BIT"), this->m_DAC_offset_bit))
00105 return false;
00106
00107
00108
00109 if( !p_config->Write( base_section+ _("DAC_VOLT_2_BIT"), this->m_DAC_volt_2_bit))
00110 return false;
00111
00112
00113
00114 if( !p_config->Write( base_section+ _("TRIGGER_THRESHOLD_VOLT"), this->m_trigger_threshold_volt))
00115 return false;
00116
00117
00118 if( !p_config->Write( base_section+ _("TRIGGER_THR_SAMPLE"), this->m_trigger_thr_sample))
00119 return false;
00120
00121 return true;
00122 }
00123 void PhysicalBoardChannel::DrawTrigger( int scope_index, wxDC &dc)
00124 {
00125 wxMutexLocker lock( this->m_p_app_settings->m_mutex);
00126
00127 const int TRIGGER_SIZE_PIX_X= 5;
00128 const int TRIGGER_SIZE_PIX_Y= 3;
00129 static wxPoint raising_trigger[ ] =
00130 {
00131 wxPoint( -TRIGGER_SIZE_PIX_X, +TRIGGER_SIZE_PIX_Y),
00132 wxPoint( 0, +TRIGGER_SIZE_PIX_Y),
00133 wxPoint( 0, -TRIGGER_SIZE_PIX_Y),
00134 wxPoint( +TRIGGER_SIZE_PIX_X, -TRIGGER_SIZE_PIX_Y)
00135 };
00136 static wxPoint falling_trigger[ ] =
00137 {
00138 wxPoint( -TRIGGER_SIZE_PIX_X, -TRIGGER_SIZE_PIX_Y),
00139 wxPoint( 0, -TRIGGER_SIZE_PIX_Y),
00140 wxPoint( 0, +TRIGGER_SIZE_PIX_Y),
00141 wxPoint( +TRIGGER_SIZE_PIX_X, +TRIGGER_SIZE_PIX_Y)
00142 };
00143
00144 if( !( this->m_enabled&& this->m_scope_view_enabled[ scope_index])||
00145 ( this->m_trigger_pen[ scope_index]== NULL))
00146 return;
00147
00148 if( this->m_trigger_pen[ scope_index])
00149 dc.SetPen( *this->m_trigger_pen[ scope_index]);
00150
00151 double offset_x= this->Sample2Sec( this->m_p_app_settings->m_max_log_X- ( this->m_p_app_settings->m_post_trigger+ this->m_trigger_thr_sample))+ this->m_p_app_settings->m_offset_sec[ scope_index];
00152
00153 double offset_y= this->m_div_2_pix_Y[ scope_index]*( (double)( DrawingCanvas::NUM_DIV_PER_SCREEN>> 1)+ this->m_offset_y[ scope_index]);
00154 switch( this->m_p_app_settings->m_trigger_edge_type)
00155 {
00156 case AppSettings::FALLING_EDGE:
00157
00158 dc.DrawLines( 4, falling_trigger, this->Sec2Pix( scope_index, offset_x), this->PixY2Dc( scope_index, (int)offset_y));
00159 break;
00160 case AppSettings::RAISING_EDGE:
00161
00162 dc.DrawLines( 4, raising_trigger, this->Sec2Pix( scope_index, offset_x), this->PixY2Dc( scope_index, (int)offset_y));
00163 break;
00164 default:
00165 break;
00166 }
00167 dc.SetPen( wxNullPen);
00168 }