qmaroc.h 7.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
#ifndef QMAROC_H
#define QMAROC_H

#include <QThread>
#include <QMutex>
#include <QVariant>
#include <QList>
#include <QTimer>
#include <QSettings>
#include <QVector>
#include "dlglog.h"
#include "dlglog_def.h"
#include "maroc.h"
#include "maroc_def.h"
#include "device.h"
#include "device_def.h"
#include "qmarocworker.h"
#include "qmarocupdater.h"
#include "qconcentrator.h"
#include "dlggrafik.h"

class Maroc;
class QMarocWorker;
class QMarocSaver;
class QMarocUpdater;
class DlgGrafik;
class QConcentrator;

class QMaroc : public QObject
{
    Q_OBJECT
public:
    explicit        QMaroc(QWidget *parent, QConcentrator *qconcentrator, quint32 devno, qint32 marocnr, DEVICE_DATA *devdata, quint32 Offset, QString ConfigP);
    virtual         ~QMaroc();
    DlgGrafik*      GetGrafikPtr();

    PromSettings    *GetPromSettings();
    Device          *GetDevicePtr();
    void            WriteConfigToFile(QString filename);
    void            ReadConfigFromFile(QString filename);

/*
    void            WriteUseDAQTriggerMask(bool all, quint32 val=0);
    void            BFS_Mask_EnableAll();
    void            BFS_Mask_DisableAll();
    void            UFS_Mask_EnableAll();
    void            UFS_Mask_DisableAll();
    void            WriteTriggerInput(quint32 ch);
    void            ChargeReset();
    bool            WriteSerialToChip(bool info, bool todisk);
*/
    void            SetDaqModeParam(bool updateGrafik = true);
    void            WriteControlDaq(bool ena);
    quint32         GetMarocNo();

    tMarocFlags     GetSettingsFlags();
    void            SetSettingsFlags(tMarocFlags flags);

    quint32         GetEEPromSerial();


signals:
    void            OTabChanged(int id);
    void            OSetValue(int id, int idx, QVariant val);
    void            OSubSetValue(int id, int idx, QVariant val);
    void            OGetValue(int id, int idx);
    void            OWorkerStop();
    void            OWorkerStart(int mode, bool savedata, QString);

    void            OUpdaterStart(int mode);
    void            OUpdaterStop();
    void            OUpdateDaqData(const QVector<double> &x, const QVector<double> &y);
    void            OUpdateADCData(const QVector<double> &x, const QVector<double> &y,const QVector<double> &,const QVector<double> &);
    void            OUpdateHistoData(int Channel, const QVector<double> &xh,const QVector<double> &yh, const QVector<double> &yh1);
    void            OUpdateConfigFile(QString);

    void            OResetYHistoMax();
    void            OResetDaqAxis();

public slots:
    void            ISetValue(int id, int idx, QVariant val);
    QVariant        IGetValue(int id, int idx);

    void            IWorkerStarted(int mode);
    void            IWorkerFinished(int mode);

    void            IUpdaterStarted(int mode);
    void            IUpdaterFinished(int mode);



private slots:
    void            UpdateGrafik(bool update = false);

protected:

private:
/*
    quint32         _FifoFulls;
    quint32         _InputOverflows;
    quint32         _Grobzeiten;
    quint32         _DatasetsRead;
*/
    QString         _ConfigPath;
    QString         _ConfigFile;
    QString         _DataFile;

    QMutex          _Mutex;
    Maroc           *_Maroc;

//    bool            _WorkerActive;
    int             _DeviceNo;
    qint32          _MarocNo;
    quint32         _Offset;
    quint32         _BoardID;

    quint32         _SerialNo;
    QString         _Serial;

    DlgGrafik       *_DlgGrafik;

    friend class QMarocWorker;
    friend class QMarocUpdater;
    QMarocWorker    *_Worker;
    QMarocUpdater   *_WorkerUpdater;

    tMarocSettings  _MarocSettings;

    QConcentrator   *_QConcentrator;
    quint32         OldControl;
    quint32         OldStatus;

    bool            _OnConcentrator;

    int             _WorkerMode;

    void            DropMsg(int typ, QString txt);

    void            SetDefaultValues();
    bool            LoadSettings(QString ModType, QString Filename, bool CheckSerial);
    void            SaveSettings(QString ModType, QString Filename);
    void            BuildConfigFile();

    void            MarocInit();

    void            SetTriggerMode(int mode);
    void            SetAutoTrigger();
    void            SetTriggerInactiv();
    bool            WriteEEProm(quint32 adr, quint32 dat);
    quint32         ReadEEProm(quint32 adr, bool *ok);

    void            StopThreads();


    void            ClearDaqData();
    void            ClearADCData();
    void            ClearHistoData(int channel);
    void            SelectDisplayChannel(int channel);
    void            ClearYHistoMax();
    void            SelectChargeOutput(int channel);


    void            ADCRead();
    int             ReadADCMem();
    void            ADCMemoryTest();
//    void            LEDSetState(int state);
//    int             LEDGetState();
    bool            WriteWRRegAryToLink(int MaxReg);
    void            ShowControlReg(bool debug = false);
    void            ShowStatusReg(bool debug = false);
    bool            CompareWRRegAryWithLink(bool info, int MaxReg, bool WRAry);
    bool            ReadWRRegAryFromLink(int MaxReg);
    bool            ReadRDRegAryFromLink(int MaxReg);
    void            ClearRegAry();
    void            WriteDataBit(int bitpos, bool b);
    void            WriteDataBits(int startbit, int anzbits, quint32 value);
    void            WriteRegAryToDisk(bool info, bool ReadData, quint32 MaxReg, QString fname);
    void            WriteSerRegToDisk(bool info, quint32 MaxReg, quint32 LastReg, quint32 LastBit);

    void            WriteHistoToDisk(bool info);
    void            WriteChargeToChip(bool info, bool write);
    void            SelectMask(int c);
    void            SetSelMasks();
    void            ShowTriggerInReg();


    void            WriteHoldSignals();
    void            WriteTriggerEnableRegs(bool all, quint32 val=0);
    void            WriteHoldDelay();

    void            SetTriggerChannel(int channel);
    void            SetEEPromWriteProtect(bool wp);

    void            SetMode();

    void            SetMarocSettingsValue(quint32 *data, QVariant val);

    void            ShowRegInCtrl();



    void            WriteUseDAQTriggerMask(bool all, quint32 val=0);
    void            BFS_Mask_EnableAll();
    void            BFS_Mask_DisableAll();
    void            UFS_Mask_EnableAll();
    void            UFS_Mask_DisableAll();
    void            WriteTriggerInput(quint32 ch);
    void            ChargeReset();
    bool            WriteSerialToChip(bool info = false, bool todisk = false);
    void            SaveDataToFile();
    void            CalcHisto(int channel);
    void            CalcMittelwert(int channel);
    void            CalcProzentualeAbweichung();
    void            CalcStandardAbweichung();
    void            ClearStatData();
    void            CalcDaqStandardAbweichung();
    void            CalcDaqProzentualeAbweichung();
    void            SaveDaqProzAbwToFile();
    void            AdjustGain();

    void            DoSyncReset();
    void            DoSyncStart();
    void            DoSyncStartReset();
    void            DoSyncStop();

};

#endif // QMAROC_H