ACQ2XX_API
AcqDataModel.h
Go to the documentation of this file.
00001 /* ------------------------------------------------------------------------- */
00002 /* file AcqDataModel.h                                                       */
00003 /* ------------------------------------------------------------------------- */
00004 /*   Copyright (C) 2010 Peter Milne, D-TACQ Solutions Ltd
00005  *                      <Peter dot Milne at D hyphen TACQ dot com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of Version 2 of the GNU General Public License
00009     as published by the Free Software Foundation;
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
00019 /* ------------------------------------------------------------------------- */
00020 
00021 /** @file AcqDataModel.h generic Data Model for all ACQxxx raw data
00022  * Refs: 
00023 */
00024 
00025 #ifndef __ACQDATAMODEL_H__
00026 #define __ACQDATAMODEL_H__
00027 
00028 using namespace std;
00029 #include <string>
00030 #include <vector>
00031 
00032 #define DEFSCAN "DEFSCAN"       /* operate in normal sequence */
00033 #define DEFMASK "DEFMASK"       /* operate in normal sequence */
00034 
00035 
00036 class AcqType;
00037 class AcqCal;
00038 class DumpDef;
00039 class NewEventSignature;
00040 
00041 class ChannelVisitor {
00042 public:
00043         virtual ~ChannelVisitor() {}
00044         virtual void onSample(int ichan, int sample) = 0;
00045 };
00046 
00047 enum WCP {
00048         WCP_COUNT_FROM_TBLOCK_START,
00049         WCP_TIMED_AT_EVENT
00050 };
00051 
00052 class AcqDataModel {
00053         int maxsamples;
00054         int actual_samples;
00055 
00056 protected:
00057         const AcqType& acq_type;
00058         string scanlist;
00059         string channelMask;
00060         AcqCal* acq_cal;
00061         string ident;
00062         string dataSourceName;
00063 
00064         unsigned msecs_start;
00065 
00066         AcqDataModel(
00067                 const AcqType& _acq_type, 
00068                 string _scanlist, string _channelMask);
00069 
00070 public:
00071         static bool processNoStashES(int& len) {
00072                 if (len < 0){
00073                         len = -len;
00074                         return true;
00075                 }else{
00076                         return false;
00077                 }
00078         }
00079         static void setProcessNoStashES(int &len){
00080                 len = -len;
00081         }
00082         bool has_timebase;
00083         const char* ch_name_core;
00084 
00085         static string pfx;
00086 
00087         virtual ~AcqDataModel() {}
00088 
00089         void setAcqCal(AcqCal* _acq_cal);
00090         void setIdent(string& _ident) {
00091                 ident = _ident;
00092         }
00093         void setDataSourceName(string _dataSourceName){
00094                 dataSourceName = _dataSourceName;
00095         }
00096         void setPrefix(string& _pfx){
00097                 pfx = _pfx;
00098         }
00099         virtual void addEventSignature(NewEventSignature* _es) {
00100                 ;
00101         }
00102 
00103         const AcqType& getAcqType() { return acq_type; }
00104         const AcqCal* getAcqCal() { return acq_cal; }
00105 
00106         virtual void dumpFormat(const string& dirFile, unsigned long start_sample = 0);
00107         virtual void print();
00108         virtual void processRaw(void *data, int ndata_bytes);
00109         virtual void processCooked(const void *cdata, int ch, int ndata_bytes);
00110 
00111         void dump(string root);
00112         virtual void dump(DumpDef& dd) = 0;
00113         virtual void clear(int expected_samples);
00114 
00115         virtual void setMaxsamples(int _maxsamples) {
00116                 maxsamples = _maxsamples;
00117         }
00118 
00119         virtual void visitChannels(ChannelVisitor& visitor) {}
00120 
00121         virtual vector<int>& getEvents() {
00122                 static vector<int> empty;
00123                 return empty;
00124         }
00125 
00126         virtual void clear() {};
00127 
00128         static AcqDataModel* create(
00129                 const AcqType& acq_type,
00130                 string _scanlist  = DEFSCAN, 
00131                 string _channel_mask = DEFMASK);
00132 
00133         virtual vector<short>& getChannelData(int ch) {
00134                 static vector<short> empty;
00135                 return empty;
00136         }
00137         virtual vector<NewEventSignature*>& getEventSignatures() {
00138                 static vector<NewEventSignature*> empty;
00139                 return empty;
00140         }
00141 
00142 
00143 
00144         static enum WCP wallclock_policy;
00145 
00146         virtual void setWallClockPolicy(
00147                         unsigned _msecs_start){
00148                 msecs_start = _msecs_start;
00149         }
00150 };
00151 
00152 
00153 
00154 #endif  // __ACQDATAMODEL_H__