qavrg 0.0.28
|
00001 #include "qavrgacquisitionparms.h" 00002 00003 #include "qavrgfitter.h" 00004 #include <QMetaProperty> 00005 #include <stdio.h> 00006 00007 QavrgAcquisitionParms::QavrgAcquisitionParms(QObject *parent) 00008 : QObject(parent), 00009 m_SettingsSaver(new QcepSettingsSaver(this)), 00010 m_NChannels(m_SettingsSaver, this, "channels", 4, "Number of Channels"), 00011 m_NSamples(m_SettingsSaver, this, "samples", 900000, "Number of Samples per Channel"), 00012 m_IntegrationTime(m_SettingsSaver, this, "integrationTime", 4, "Integration Time"), 00013 m_ScopeIntegrationTime(m_SettingsSaver, this, "scopeIntegrationTime", 1, "Integration Time in Scope Mode"), 00014 m_AcquireIntegrationTime(m_SettingsSaver, this, "acquireIntegrationTime", 1, "Acquisition Integration Time"), 00015 m_NRepeats(m_SettingsSaver, this, "repeats", 1, "Number of Repeats"), 00016 m_DarkNRepeats(m_SettingsSaver, this, "darkRepeats", 1, "Number of Dark Repeats"), 00017 m_ReferenceNRepeats(m_SettingsSaver, this, "referenceRepeats", 1, "Number of Reference Repeats"), 00018 m_BucketsPerOrbit(m_SettingsSaver, this,"bucketsPerOrbit",1296, "Buckets per Orbit"), 00019 m_SamplesPerOrbit(m_SettingsSaver, this,"samplesPerOrbit",3683.5, "Samples per Orbit"), 00020 m_FillPatternMode(m_SettingsSaver, this,"fillPatternMode",0, "Fill Pattern Mode"), 00021 m_CustomFilledBucketsPerOrbit(m_SettingsSaver, this, "customFilledBucketsPerOrbit", 24, "Filled Buckets per Orbit (custom)"), 00022 m_TriggerLevel(m_SettingsSaver, this,"triggerLevel",1.0, "Trigger Level"), 00023 m_TriggerSlope(m_SettingsSaver, this,"triggerSlope",0, "Trigger Slope"), 00024 m_TriggerSource(m_SettingsSaver, this,"triggerSource",0, "Trigger Source"), 00025 m_OutputDirectory(m_SettingsSaver, this,"outputDirectory",".","Output Directory"), 00026 m_FileName(m_SettingsSaver, this,"fileName","saveddata", "File Name"), 00027 m_FilePath(m_SettingsSaver, this,"filePath","saveddata", "File Path"), 00028 m_ScanNumber(m_SettingsSaver, this,"scanNumber",1, "Scan Number"), 00029 m_SimulationMode(m_SettingsSaver, this,"simulationMode",0, "Simulation Mode"), 00030 // m_Instrument(m_SettingsSaver, this, "instrument", 0), 00031 // m_Concurrent(m_SettingsSaver, this,"concurrent",3), 00032 m_Status(QcepSettingsSaverWPtr(), this,"status",AcquireDone, "Acquisition Status"), 00033 m_LaserRepRate(m_SettingsSaver, this,"laserRepRate",1000, "Laser Rep Rate") 00034 // m_Mutex(QMutex::Recursive), 00035 { 00036 } 00037 00038 QavrgFitter *QavrgAcquisitionParms::fitter(int chan) 00039 { 00040 QMutexLocker lock(&m_FittersMutex); 00041 00042 return m_Fitters.value(chan); 00043 } 00044 00045 double QavrgAcquisitionParms::get_BucketSeparation() const 00046 { 00047 return get_SamplesPerOrbit()/get_BucketsPerOrbit(); 00048 } 00049 00050 void QavrgAcquisitionParms::set_BucketSeparation(const double sep) 00051 { 00052 set_SamplesPerOrbit(sep*get_BucketsPerOrbit()); 00053 } 00054 00055 QcepBoolVector QavrgAcquisitionParms::get_FillPattern() const 00056 { 00057 QMutexLocker lock(&m_FillPatternMutex); 00058 00059 return m_FillPattern; 00060 } 00061 00062 QVector<int> QavrgAcquisitionParms::get_FilledBuckets() const 00063 { 00064 QMutexLocker lock(&m_FillPatternMutex); 00065 00066 QVector<int> res; 00067 int sz = m_FillPattern.size(); 00068 00069 for (int i=0; i<sz; i++) { 00070 if (m_FillPattern.value(i)) { 00071 res.append(i); 00072 } 00073 } 00074 00075 return res; 00076 } 00077 00078 int QavrgAcquisitionParms::get_FilledBucketsPerOrbit() const 00079 { 00080 QMutexLocker lock(&m_FillPatternMutex); 00081 00082 int res=0; 00083 int sz = m_FillPattern.size(); 00084 00085 for (int i=0; i<sz; i++) { 00086 if (m_FillPattern.value(i)) { 00087 res++; 00088 } 00089 } 00090 00091 return res; 00092 } 00093 00094 void QavrgAcquisitionParms::set_FillPattern(const QcepBoolVector patt) 00095 { 00096 QMutexLocker lock(&m_FillPatternMutex); 00097 00098 // printf("set fill pattern = "); 00099 // int sz = patt.size(); 00100 // 00101 // for(int i=0; i<sz; i++) { 00102 // if (patt.value(i)) { 00103 // printf("%d ", i); 00104 // } 00105 // } 00106 // 00107 // printf(";\n"); 00108 00109 m_FillPattern = patt; 00110 } 00111 00112 QcepBoolVector QavrgAcquisitionParms::get_CustomFillPattern() const 00113 { 00114 QMutexLocker lock(&m_FillPatternMutex); 00115 00116 return m_CustomFillPattern; 00117 } 00118 00119 bool QavrgAcquisitionParms::get_CustomFillPattern(int bin) const 00120 { 00121 QMutexLocker lock(&m_FillPatternMutex); 00122 00123 return m_CustomFillPattern.value(bin); 00124 } 00125 00126 void QavrgAcquisitionParms::set_CustomFillPattern(const QcepBoolVector patt) 00127 { 00128 QMutexLocker lock(&m_FillPatternMutex); 00129 00130 m_CustomFillPattern = patt; 00131 } 00132 00133 void QavrgAcquisitionParms::set_CustomFillPattern(int bin, bool val) 00134 { 00135 QMutexLocker lock(&m_FillPatternMutex); 00136 00137 if (bin >= m_CustomFillPattern.size()) { 00138 m_CustomFillPattern.resize(bin+1); 00139 } 00140 00141 m_CustomFillPattern[bin] = val; 00142 } 00143 00144 QavrgAcquisitionParms::AcquisitionMode QavrgAcquisitionParms::get_AcquisitionMode() const 00145 { 00146 QMutexLocker lock(&m_AcqModeMutex); 00147 00148 return m_AcquisitionMode; 00149 } 00150 00151 void QavrgAcquisitionParms::set_AcquisitionMode(QavrgAcquisitionParms::AcquisitionMode mode) 00152 { 00153 QMutexLocker lock(&m_AcqModeMutex); 00154 00155 m_AcquisitionMode = mode; 00156 } 00157 00158 int QavrgAcquisitionParms::incr_NQueuedResults() 00159 { 00160 int res = m_NQueuedResults.fetchAndAddOrdered(1); 00161 00162 // printf("QavrgAcquisitionParms::incr_NQueuedResults = %d\n", res); 00163 00164 return res; 00165 } 00166 00167 int QavrgAcquisitionParms::decr_NQueuedResults() 00168 { 00169 int res = m_NQueuedResults.fetchAndAddOrdered(-1); 00170 00171 // printf("QavrgAcquisitionParms::decr_NQueuedResults = %d\n", res); 00172 00173 return res; 00174 } 00175 00176 void QavrgAcquisitionParms::properties() const 00177 { 00178 printf("Static Properties:\n"); 00179 00180 const QMetaObject *meta = &staticMetaObject; 00181 00182 int count = meta->propertyCount(); 00183 int offset= meta->propertyOffset(); 00184 00185 for (int i=offset; i<count; i++) { 00186 QMetaProperty metaprop = meta->property(i); 00187 00188 printf("%d : %s = %s\n", i, metaprop.name(), qPrintable(metaprop.read(this).toString())); 00189 } 00190 00191 printf("Dynamic Properties:\n"); 00192 00193 int i=0; 00194 foreach(QByteArray nm, dynamicPropertyNames()) { 00195 printf("%d : %s = %s\n", i, nm.data(), qPrintable(property(nm.data()).toString())); 00196 } 00197 } 00198 00199 void QavrgAcquisitionParms::readSettings(QSettings *settings) 00200 { 00201 // QMutexLocker lock(&m_Mutex); 00202 00203 QcepProperty::readSettings(this, &staticMetaObject, "acquisition", settings); 00204 00205 foreach (QavrgFitter* f, m_Fitters) { 00206 f -> readSettings(settings); 00207 } 00208 } 00209 00210 void QavrgAcquisitionParms::writeSettings(QSettings *settings) 00211 { 00212 // QMutexLocker lock(&m_Mutex); 00213 00214 QcepProperty::writeSettings(this, &staticMetaObject, "acquisition", settings); 00215 00216 foreach (QavrgFitter* f, m_Fitters) { 00217 f -> writeSettings(settings); 00218 } 00219 }