qavrg 0.0.28
qavrgspecserver.cpp
Go to the documentation of this file.
00001 #include "qavrgspecserver.h"
00002 #include "qavrgscriptingengine.h"
00003 #include "qavrgacquisition.h"
00004 
00005 #include <QVariant>
00006 #include <stdio.h>
00007 
00008 QavrgSpecServer::QavrgSpecServer(QavrgAcquisition *acq, QObject *parent)
00009   : QSpecServer(QcepExperimentWPtr(), "qavrg"),
00010     m_Acquisition(acq)
00011 {
00012 }
00013 
00014 void QavrgSpecServer::debug_print(QString msg)
00015 {
00016   printf("QavrgSpecServer:: %s\n", qPrintable(msg));
00017 }
00018 
00019 QVariant QavrgSpecServer::readProperty(QString name)
00020 {
00021   QVariant res;
00022   int chan, bin, nbins;
00023 
00024   if (name=="var/channel(0)") {
00025     res.setValue< QVector<double> >(m_Acquisition -> readResult(0,2));
00026 
00027     return res;
00028   }
00029 
00030   if (name=="var/channel(1)") {
00031     res.setValue< QVector<double> >(m_Acquisition -> readResult(1,2));
00032 
00033     return res;
00034   }
00035 
00036   if (name=="var/channel(2)") {
00037     res.setValue< QVector<double> >(m_Acquisition -> readResult(2,2));
00038 
00039     return res;
00040   }
00041 
00042   if (name=="var/channel(3)") {
00043     res.setValue< QVector<double> >(m_Acquisition -> readResult(3,2));
00044 
00045     return res;
00046   }
00047 
00048   if (sscanf(qPrintable(name),"var/data(%d,%d,%d)", &chan, &bin, &nbins) == 3) {
00049     res.setValue< QVector<double> > (m_Acquisition -> get_RawData(chan,bin,nbins));
00050 
00051     return res;
00052   }
00053 
00054   if (sscanf(qPrintable(name),"var/dark(%d,%d,%d)", &chan, &bin, &nbins) == 3) {
00055     res.setValue< QVector<double> > (m_Acquisition -> get_DarkData(chan,bin,nbins));
00056 
00057     return res;
00058   }
00059 
00060   if (sscanf(qPrintable(name),"var/ref(%d,%d,%d)", &chan, &bin, &nbins) == 3) {
00061     res.setValue< QVector<double> > (m_Acquisition -> get_ReferenceData(chan,bin,nbins));
00062 
00063     return res;
00064   }
00065 
00066   if (sscanf(qPrintable(name),"var/data(%d,%d)", &chan, &bin) == 2) {
00067     res.setValue< double > (m_Acquisition -> get_RawData(chan,bin));
00068 
00069     return res;
00070   }
00071 
00072   if (sscanf(qPrintable(name),"var/dark(%d,%d)", &chan, &bin) == 2) {
00073     res.setValue< double > (m_Acquisition -> get_DarkData(chan,bin));
00074 
00075     return res;
00076   }
00077 
00078   if (sscanf(qPrintable(name),"var/ref(%d,%d)", &chan, &bin) == 2) {
00079     res.setValue< double > (m_Acquisition -> get_ReferenceData(chan,bin));
00080 
00081     return res;
00082   }
00083 
00084   if (sscanf(qPrintable(name),"var/data(%d)", &chan) == 1) {
00085     res.setValue< QVector<double> >(m_Acquisition -> get_RawData(chan));
00086 
00087     return res;
00088   }
00089 
00090   if (sscanf(qPrintable(name),"var/dark(%d)", &chan) == 1) {
00091     res.setValue< QVector<double> >(m_Acquisition -> get_DarkData(chan));
00092 
00093     return res;
00094   }
00095 
00096   if (sscanf(qPrintable(name),"var/ref(%d)", &chan) == 1) {
00097     res.setValue< QVector<double> >(m_Acquisition -> get_ReferenceData(chan));
00098 
00099     return res;
00100   }
00101 
00102   return QSpecServer::readProperty(name);
00103 }