00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013 #if defined(__GNUG__) && !defined(__APPLE__)
00014 #pragma implementation "V1724_board.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
00028 #include "v1724_board.h"
00029 #include "v1724_board_channel.h"
00030 #include "appsettings.h"
00031
00032 V1724Board::V1724Board( int board_index, void (*scope_refresh)( int, bool), wxMutex *p_data_mutex, AppSettings *p_app_settings):
00033 GenericBoard( board_index, scope_refresh, p_data_mutex, p_app_settings)
00034 {
00035 this->m_p_data= (cvt_board_data*)new cvt_V1724_data;
00036 }
00037
00038 V1724Board::~V1724Board(void)
00039 {
00040 if( this->m_p_data!= NULL)
00041 {
00042 cvt_V1724_close( (cvt_V1724_data* )this->m_p_data);
00043 delete (cvt_V1724_data* )this->m_p_data;
00044 this->m_p_data= NULL;
00045 }
00046 }
00047
00048 bool V1724Board::Open( long )
00049 {
00050 return true;
00051 }
00052
00053 bool V1724Board::Init( long vme_handle)
00054 {
00055
00056
00057 if( !cvt_V1724_open( (cvt_V1724_data* )this->m_p_data, this->m_p_data->m_base_address, vme_handle))
00058 return false;
00059
00060
00061
00062 if( !this->WriteTriggerMode( false))
00063 return false;
00064
00065
00066 if( !this->SetFrontPanelIO( this->m_p_app_settings->m_use_TTL))
00067 return false;
00068
00069 return true;
00070 }
00071
00072 GenericBoardChannel* V1724Board::CreateChannel( int ch_index, void (* scope_refresh)( int, bool), wxMutex *p_data_mutex)
00073 {
00074 return new V1724BoardChannel( this, ch_index, this->m_p_data, scope_refresh, p_data_mutex, this->m_p_app_settings);
00075 }
00076
00077 bool V1724Board::WriteSampleBufferSize( void)
00078 {
00079 if( !cvt_V1724_set_acquisition_mode( (cvt_V1724_data* )this->m_p_data, false, ( CVT_V1724_CH_BLKSIZE) ( CVT_V1724_CHBKSZ_512- this->m_p_app_settings->m_sample_block_size), CVT_V1724_ACQCTRL_ACQ_MODE_REGISTER_CTRL, FALSE, 0))
00080 return false;
00081 return cvt_V1724_data_clear( (cvt_V1724_data* )this->m_p_data)!= FALSE;
00082
00083 }
00084
00085 bool V1724Board::WriteTriggerMode( bool started)
00086 {
00087 bool falling_edge_enable= this->m_p_app_settings->m_trigger_edge_type== AppSettings::FALLING_EDGE;
00088 bool trigger_out_enable= this->m_p_app_settings->m_trigger_edge_type!= AppSettings::NO_TRIGGER;
00089 unsigned char ch_msk= 0;
00090 int i;
00091
00092
00093 if( this->m_p_app_settings->m_post_trigger< 5)
00094 this->m_p_app_settings->m_post_trigger= 5;
00095
00096 for( i= 0; i< (int)this->m_channel_array.GetCount(); i++)
00097 {
00098 ch_msk|= ( (GenericBoardChannel*)this->m_channel_array[i])->m_enabled? ( 1<< i): 0;
00099 ( (GenericBoardChannel*)this->m_channel_array[i])->SetEnable( !started);
00100 }
00101 if( !( started?
00102 cvt_V1724_set_trigger_mode( (cvt_V1724_data* )this->m_p_data, falling_edge_enable, true, trigger_out_enable, this->m_p_app_settings->m_trigger_msk& ( int)AppSettings::EXT_TRIGGER_MSK, true, ch_msk, false, this->m_p_app_settings->m_post_trigger):
00103 cvt_V1724_set_trigger_mode( (cvt_V1724_data* )this->m_p_data, false, false, false, false, false, 0x00, false, this->m_p_app_settings->m_post_trigger)))
00104 return false;
00105
00106 return cvt_V1724_data_clear( (cvt_V1724_data* )this->m_p_data)!= FALSE;
00107 }
00108
00109 bool V1724Board::WriteSoftwareTrigger( void)
00110 {
00111 wxMutexLocker lock( this->m_p_app_settings->m_mutex);
00112
00113 return cvt_V1724_software_trigger( (cvt_V1724_data* )this->m_p_data)!= FALSE;
00114 }
00115
00116 bool V1724Board::SetFrontPanelIO( bool use_TTL)
00117 {
00118 if( !cvt_V1724_set_front_panel_IO( (cvt_V1724_data* )this->m_p_data, use_TTL, TRUE, 0, CVT_V1724_FPIO_MODES_GPIO))
00119 return false;
00120 return cvt_V1724_data_clear( (cvt_V1724_data* )this->m_p_data)!= FALSE;
00121 }
00122 bool V1724Board::ReadBoardData( UINT32 *p_max_num_samples, UINT32* p_num_events)
00123 {
00124 return cvt_V1724_read_data( (cvt_V1724_data* )this->m_p_data, p_max_num_samples, p_num_events)!= FALSE;
00125 }
00126 bool V1724Board::DoStartAcquisition( void)
00127 {
00128 unsigned char ch_msk= 0;
00129 int i= 0;
00130 for( i= 0; i< (int)this->m_channel_array.GetCount(); i++)
00131 {
00132 ch_msk|= ( (GenericBoardChannel*)this->m_channel_array[i])->m_enabled? ( 1<< i): 0;
00133 }
00134 if( cvt_V1724_set_readout_mode( (cvt_V1724_data* )this->m_p_data, TRUE, 1)== FALSE)
00135 {
00136 return false;
00137 }
00138 return cvt_V1724_start_acquisition( (cvt_V1724_data* )this->m_p_data, ch_msk)!= FALSE;
00139 }
00140 bool V1724Board::DoStopAcquisition( void)
00141 {
00142 return cvt_V1724_stop_acquisition( (cvt_V1724_data* )this->m_p_data)!= FALSE;
00143 }