virtual_board_channel.cpp

Go to the documentation of this file.
00001 
00002 // Name:        virtual_board_channel.cpp
00003 // Purpose:     
00004 // Author:      NDA
00005 // Modified by: 
00006 // Created:     10/01/07 14:18:40
00007 // RCS-ID:      
00008 // Copyright:   CAEN S.p.A. All rights reserved
00009 // Licence:     
00011 
00012 #define __TEST__
00013 
00014 #if defined(__GNUG__) && !defined(__APPLE__)
00015 #pragma implementation "virtual_board_channel.h"
00016 #endif
00017 
00018 // For compilers that support precompilation, includes "wx/wx.h".
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 
00029 #include "appsettings.h"
00030 #include "virtual_board_channel.h"
00031 #include "rpn_handler.h"
00032 
00033 
00034 extern "C" 
00035 {
00036         #include "../include/CAENVMETool/cvt_v1724.h"
00037 }
00038 
00039 
00040 VirtualBoardChannel::VirtualBoardChannel( GenericBoard* parent, int ch_index, cvt_board_data* p_data, void ( *scope_refresh)( int, bool), wxMutex* p_data_mutex, AppSettings *p_app_settings):
00041                                                                         GenericBoardChannel( parent, ch_index, p_data, scope_refresh, p_data_mutex, p_app_settings)
00042 {
00043         this->m_p_rpn_handler= NULL;
00044 }
00045 
00046 VirtualBoardChannel::~VirtualBoardChannel( void)
00047 {
00048         if( this->m_p_rpn_handler)
00049                 delete this->m_p_rpn_handler;
00050 }
00051 double VirtualBoardChannel::GetSampleVolt( int i)
00052 {
00053         // evaluate expression and return the value
00054         this->m_sample_index= i;
00055         double result= 0;
00056         if( !this->m_p_rpn_handler)
00057                 return 0;
00058         if( !this->m_p_rpn_handler->Eval( result))
00059                 return 0;
00060         return result;
00061 }
00062 int VirtualBoardChannel::GetSample( int i)
00063 {
00064         return (int)(double)( this->GetSampleVolt( i)* this->m_volt_2_bit);
00065 }
00066 wxString VirtualBoardChannel::GetRecordChannelNumber( void)
00067 {
00068         return wxString::Format( "V%02d", this->m_ch_index);
00069 }
00070 UINT32 VirtualBoardChannel::GetBufferCount( void)
00071 {
00072         if( !this->m_p_rpn_handler)
00073                 return 0;
00074         return this->m_p_rpn_handler->GetBufferCount();
00075 }
00076 void VirtualBoardChannel::DrawTrigger( int /*scope_index*/, wxDC &/*dc*/)
00077 {
00078         // Do nothing
00079 }
00080 
00081 bool VirtualBoardChannel::LoadConfig( wxConfigBase* p_config, const wxString& base_section)
00082 {
00083         GenericBoardChannel::LoadConfig( p_config, base_section);
00084         /*
00085                 Application setting physical channel parameters' file structure
00086 
00087           |- VIRTUAL_CHANNEL_DEF=CH1,CH2,ADD        // Virtual channel RPN definition
00088         */
00089 
00090         //
00091         // Get RPN definition
00092         wxString tmp_string= _("");
00093         p_config->Read( base_section+ _("VIRTUAL_CHANNEL_DEF"), &tmp_string, _(""));
00094         this->m_p_rpn_handler= new RpnHandler( this, tmp_string);
00095 
00096         return true;
00097 
00098 }
00099 bool VirtualBoardChannel::SaveConfig( wxConfigBase* p_config, const wxString& base_section)
00100 {
00101         if( !GenericBoardChannel::SaveConfig( p_config, base_section))
00102                 return false;
00103 
00104         //
00105         // Set RPN definition
00106         if( this->m_p_rpn_handler)
00107         {
00108                 wxString tmp_string( this->m_p_rpn_handler->Format());
00109                 if( !p_config->Write( base_section+ _("VIRTUAL_CHANNEL_DEF"), tmp_string))
00110                         return false;
00111         }
00112         else
00113         {
00114                 if( !p_config->Write( base_section+ _("VIRTUAL_CHANNEL_DEF"), ""))
00115                         return false;
00116         }
00117         return true;
00118 }
00119 bool VirtualBoardChannel::GetChannelValue( int channel_id, double& result)
00120 {
00121         return this->m_parent->GetPhysicalChannelValue( channel_id, this->m_sample_index, result);
00122 }
00123 bool VirtualBoardChannel::GetChannelValueVolt( int channel_id, double& result)
00124 {
00125         return this->m_parent->GetPhysicalChannelValueVolt( channel_id, this->m_sample_index, result);
00126 }
00127 bool VirtualBoardChannel::GetChannelBufferCount( int channel_id, UINT32& result)
00128 {
00129         return this->m_parent->GetPhysicalChannelBufferCount( channel_id, result);
00130 }
00131 const char* VirtualBoardChannel::GetExpressionDef( void)
00132 {
00133         if( !this->m_p_rpn_handler)
00134                 return "";
00135         return this->m_p_rpn_handler->Format();
00136 }
00137 void VirtualBoardChannel::SetExpressionDef( const char* expression_def)
00138 {
00139         if( !this->m_p_rpn_handler)
00140         {
00141                 this->m_p_rpn_handler= new RpnHandler( this, expression_def);
00142                 return;
00143         }
00144         this->m_p_rpn_handler->Parse( expression_def);
00145 }

Generated on Mon Mar 19 17:14:08 2007 for CAENScope by  doxygen 1.4.6-NO