boardworkerthread.cpp

Go to the documentation of this file.
00001 
00002 // Name:        BoardWorkerThread.cpp
00003 // Purpose:     
00004 // Author:      NDA
00005 // Modified by: 
00006 // Created:     11/24/05 15:04:29
00007 // RCS-ID:      
00008 // Copyright:   CAEN S.p.A. All rights reserved
00009 // Licence:     
00011 
00012 // Generated by DialogBlocks (unregistered), 11/24/05 15:04:29
00013 
00014 #if defined(__GNUG__) && !defined(__APPLE__)
00015 #pragma implementation "boardworkerthread.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 #include <wx/datetime.h>
00029 
00030 #include "generic_board.h"
00031 #include "physical_board_channel.h"
00032 #include "boardworkerthread.h"
00033 #include "appsettings.h"
00034 extern "C" 
00035 {
00036         #include "../include/CAENVMETool/cvt_v1724.h"
00037 }
00038 
00039 BoardWorkerThread::BoardWorkerThread(GenericBoard* parent)
00040 {
00041         this->m_parent= parent;
00042 }
00043 
00044 BoardWorkerThread::~BoardWorkerThread(void)
00045 {
00046 }
00047 
00048 wxThread::ExitCode BoardWorkerThread::Entry( void)
00049 {
00050         const int SW_TRIGGER_INTERVAL_MSEC= 1;
00051         this->m_next_sw_trigger= wxDateTime::UNow();
00052         while( !this->TestDestroy())
00053         {
00054                 UINT32 num_samples_read;
00055                 UINT32 num_events;
00056                 //
00057                 // Get channels' samples
00058 
00059                 // Refresh channels' data cache
00060                 
00061                 num_samples_read= num_events= 0;
00062                 if( this->m_parent->ReadBoardData( &num_samples_read, &num_events))
00063                 {
00064                         if( num_samples_read)
00065                         {
00066                                 if( num_samples_read> (UINT32)this->m_parent->m_p_app_settings->m_max_log_X)
00067                                         num_samples_read= (UINT32)this->m_parent->m_p_app_settings->m_max_log_X;
00068 
00069                                 for( size_t i= 0; ( i< this->m_parent->m_channel_array.GetCount())&& !this->TestDestroy(); i++)
00070                                 {
00071                                         PhysicalBoardChannel *board_channel= ( PhysicalBoardChannel *)this->m_parent->m_channel_array[i];
00072                                         if( board_channel->ReadSamplesCache( num_samples_read))
00073                                         {
00074                                                 if( this->m_parent->m_is_recording)
00075                                                         board_channel->RecordSamples( );
00076                                         }
00077                                         this->Sleep( 1);
00078                                 }
00079                                 if( num_samples_read&& this->m_parent->m_is_recording)
00080                                 {
00081                                         for( size_t i= 0; ( i< this->m_parent->m_virtual_channel_array.GetCount())&& !this->TestDestroy(); i++)
00082                                         {
00083                                                 VirtualBoardChannel *board_channel= ( VirtualBoardChannel *)this->m_parent->m_virtual_channel_array[i];
00084                                                 board_channel->RecordSamples( );
00085                                                 this->Sleep( 1);
00086                                         }
00087                                 }
00088                         }
00089                 }
00090                 else
00091                 {
00092                         num_samples_read= 0;
00093                 }
00094                 //
00095                 // Software autoretrig.
00096                 if( this->TestDestroy())
00097                         goto exit_point;
00098                 if(( this->m_parent->m_p_app_settings->m_trigger_msk& (int)AppSettings::SW_AUTO_TRIGGER_MSK)&& !this->TestDestroy())
00099                 {
00100                         if( wxDateTime::UNow()>= this->m_next_sw_trigger)
00101                         {
00102                                 // Update next trigger timer
00103                                 this->m_next_sw_trigger= wxDateTime::UNow().Add( wxTimeSpan( 0, 0, 0, SW_TRIGGER_INTERVAL_MSEC));
00104 
00105                                 // Send SW retrigger
00106                                 this->m_parent->WriteSoftwareTrigger( );
00107                         }
00108                 }
00109                 if( num_samples_read&& this->m_parent->ScopeRefresh)
00110                 {
00111                         for( int i= 0; i< SCOPE_NUM_PANELS; i++)
00112                         {
00113                                 ( this->m_parent->ScopeRefresh)( i, false);
00114                         }
00115                 }
00116 
00117         }
00118 exit_point:
00119     this->m_parent->m_thread_exited= true;
00120         return (wxThread::ExitCode)0;
00121 }
00122 

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