OpenCores
URL https://opencores.org/ocsvn/modular_oscilloscope/modular_oscilloscope/trunk

Subversion Repositories modular_oscilloscope

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /modular_oscilloscope/trunk
    from Rev 59 to Rev 60
    Reverse comparison

Rev 59 → Rev 60

/sw/src/rviboardtools.h
0,0 → 1,155
#ifndef RVIBOARDTOOLS_H
#define RVIBOARDTOOLS_H
 
 
#include <QtGui/QWidget>
#include <QString>
#include <QTimer>
#include <QVector>
#include <QString>
//#include <qwt_array.h> // ??
#include "rvicommthread.h"
 
 
 
namespace Ui
{
class RVIBoardTools;
}
 
class RVIBoardTools : public QWidget
{
Q_OBJECT
 
public:
 
enum VariableType
{
Time = 0,
ChannelA = 1,
ChannelB = 2
};
 
RVIBoardTools(QWidget *parent = 0);
~RVIBoardTools();
void setDefaultValues();
 
QVector<double> getData(VariableType var = Time);
 
 
signals:
// ch A
void channelAEnabled(bool set);
void channelAData(QVector<double> time, QVector<double> chA);
void channelAColorChanged(QColor );
void channelAChangeDiv(int value);
void channelAMove(int value);
void channelAResetPos();
// ch B
void channelBEnabled(bool set);
void channelBData(QVector<double> time, QVector<double> chB);
void channelBColorChanged(QColor );
void channelBChangeDiv(int value);
void channelBMove(int value);
void channelBResetPos();
// time
void timeChangeDiv(int value);
void timeMove(int value);
void timeChangeLimits(double, double);
// trigger
void showTriggerLine(bool, int);
void changeTriggerValue(double);
// adq
void statusChanged(QString);
void stopAcquistion();
 
 
private:
Ui::RVIBoardTools *ui;
 
 
RVICommThread *board;
QTimer *slidersTimer;
QTimer *dataTimer;
 
QVector<double> *dataAVec;
QVector<double> *dataBVec;
QVector<double> *timeVec;
QList<int> data;
 
short int confTScal;
bool confTScalEn;
 
bool paused;
 
double chAVoltMultiplier;
double chBVoltMultiplier;
double chAOffset;
double chBOffset;
 
 
public slots:
void setChannelADiv(double div);
void setChannelBDiv(double div);
void setTimeDiv(double div);
void setPaused(const bool &on);
 
private slots:
// Actions from UI
// chA
void on_trigBox_toggled(bool );
void on_sampleTimeCombo_currentIndexChanged(int index);
void on_trigLevelSpinBox_valueChanged(int );
void on_trigOffsetSpinBox_valueChanged(int );
void on_trigSlopeCombo_currentIndexChanged(int index);
void on_channelAColorButton_clicked();
void on_channelABox_toggled(bool set);
void on_channelAZoomSlider_valueChanged(int value);
void on_channelAZoomSlider_sliderReleased();
void on_channelAResetButton_pressed();
void on_channelAPosSlider_sliderReleased();
void on_channelAPosSlider_valueChanged(int value);
void on_channelAAutoButton_toggled(bool checked);
// chB
void on_channelBColorButton_clicked();
void on_channelBBox_toggled(bool set);
void on_channelBPosSlider_sliderReleased();
void on_channelBResetButton_pressed();
void on_channelBAutoButton_toggled(bool checked);
void on_channelBZoomSlider_sliderReleased();
void on_channelBZoomSlider_valueChanged(int value);
void on_channelBPosSlider_valueChanged(int value);
// Trigg
void on_trigSouceCombo_currentIndexChanged(int index);
void on_trigLineCheck_toggled(bool checked);
void on_timeAutoButton_toggled(bool checked);
void on_trigLevelSlider_valueChanged(int value);
// Time
void on_timePosSlider_valueChanged(int value);
void on_timePosSlider_sliderReleased();
void on_timeZoomSlider_sliderReleased();
void on_adcSampleButton_clicked();
void on_timeZoomSlider_valueChanged(int value);
void on_bufferSpinBox_valueChanged(int value);
// aqc
void on_singleButton_toggled(bool checked);
void on_runButton_toggled(bool checked);
 
 
 
void setVoltMultipliers();
void updateSlidersValues();
void uncheckRunButtons();
 
void startAcquisition(const bool &continuous = true);
void stop();
void showResults();
void sendStatusMessage(const QString &status);
void updateTimeVec();
void fillTriggerCombo();
void fillSampleTimeCombo();
 
 
};
 
#endif // RVIBOARDTOOLS_H
sw/src/rviboardtools.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/include/epp_parallel_access_win.cpp =================================================================== --- sw/src/include/epp_parallel_access_win.cpp (nonexistent) +++ sw/src/include/epp_parallel_access_win.cpp (revision 60) @@ -0,0 +1,45 @@ +#include "epp_parallel_access_win.h" + +PORTOUT PortOut; +PORTWORDOUT PortWordOut; +PORTDWORDOUT PortDWordOut; +PORTIN PortIn; +PORTWORDIN PortWordIn; +PORTDWORDIN PortDWordIn; +SETPORTBIT SetPortBit; +CLRPORTBIT ClrPortBit; +NOTPORTBIT NotPortBit; +GETPORTBIT GetPortBit; +RIGHTPORTSHIFT RightPortShift; +LEFTPORTSHIFT LeftPortShift; +ISDRIVERINSTALLED IsDriverInstalled; + +HMODULE hio; + +void UnloadIODLL() { + FreeLibrary(hio); +} + +int LoadIODLL() { + hio = LoadLibraryA("io"); + if (hio == NULL) return 1; + PortOut = (PORTOUT)GetProcAddress(hio, "PortOut"); + PortWordOut = (PORTWORDOUT)GetProcAddress(hio, "PortWordOut"); + PortDWordOut = (PORTDWORDOUT)GetProcAddress(hio, "PortDWordOut"); + PortIn = (PORTIN)GetProcAddress(hio, "PortIn"); + PortWordIn = (PORTWORDIN)GetProcAddress(hio, "PortWordIn"); + PortDWordIn = (PORTDWORDIN)GetProcAddress(hio, "PortDWordIn"); + SetPortBit = (SETPORTBIT)GetProcAddress(hio, "SetPortBit"); + ClrPortBit = (CLRPORTBIT)GetProcAddress(hio, "ClrPortBit"); + NotPortBit = (NOTPORTBIT)GetProcAddress(hio, "NotPortBit"); + GetPortBit = (GETPORTBIT)GetProcAddress(hio, "GetPortBit"); + RightPortShift = (RIGHTPORTSHIFT)GetProcAddress(hio, "RightPortShift"); + LeftPortShift = (LEFTPORTSHIFT)GetProcAddress(hio, "LeftPortShift"); + IsDriverInstalled = (ISDRIVERINSTALLED)GetProcAddress(hio, "IsDriverInstalled"); + + atexit(UnloadIODLL); + + return 0; +} + +
sw/src/include/epp_parallel_access_win.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/include/delay.c =================================================================== --- sw/src/include/delay.c (nonexistent) +++ sw/src/include/delay.c (revision 60) @@ -0,0 +1,63 @@ +/* + * libieee1284 - IEEE 1284 library + * Copyright (C) 2001 Tim Waugh + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MSC_VER +#include +#endif +#ifdef __unix__ +#include +#endif +#if defined __MINGW32__ || defined _MSC_VER +#include +#endif + +#include "delay.h" + +void udelay(unsigned long usec) +{ +#if !(defined __MINGW32__ || defined _MSC_VER) + struct timeval now, deadline; + + gettimeofday(&deadline, NULL); + deadline.tv_usec += usec; + deadline.tv_sec += deadline.tv_usec / 1000000; + deadline.tv_usec %= 1000000; + + do { + gettimeofday(&now, NULL); + } while ((now.tv_sec < deadline.tv_sec) || + (now.tv_sec == deadline.tv_sec && + now.tv_usec < deadline.tv_usec)); +#else + /* MinGW has no gettimeofday(). ftime() seems to be the best alternative as I + * don't know of any standard Windows function with microsecond accuracy. I + * should have a look at the Cygwin source code... - dbjh */ + struct timeb tb; + long int now, deadline; + + ftime(&tb); + deadline = tb.time * 1000 + tb.millitm + usec / 1000; + + do { + ftime(&tb); + now = tb.time * 1000 + tb.millitm; + } while (now < deadline); +#endif +} +
sw/src/include/delay.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/include/epp_parallel_use_win.h =================================================================== --- sw/src/include/epp_parallel_use_win.h (nonexistent) +++ sw/src/include/epp_parallel_use_win.h (revision 60) @@ -0,0 +1,106 @@ +/* +* + + +* Check action status is forced when return value is used. +* When reading the port, data is obtaiend by reference (for consistency) + +*/ + + + +#ifndef EPP_PARALLEL_USE_WIN_H +#define EPP_PARALLEL_USE_WIN_H + +#include "epp_parallel_access_win.h" + + +class EppParallelUseWin { + public: + enum PPStatusType + { + PP_STATE_IDLE = 0, // Estado inicial, sin negociación previa + PP_CONECTED = 1, // Luego de la negociación + PP_COMUNICATION_FAIL = 2, // Fallo en la comunicación (dispositivo no accesible o + // desconectado) + PP_NEGOTIATION_FAIL = 3, // Dispositivo accesible, pero fallo en la negociación (existe + // dispositivo pero no soporta modo EPP) + PP_TIME_OUT = 4, // Time out + /* PP_RA_TIME_OUT = 4, // Read address fails + PP_WA_TIME_OUT = 5, // Write address fails + PP_RB_TIME_OUT = 6, // Read byte fails + PP_WB_TIME_OUT = 7, // Write byte fails + PP_RW_TIME_OUT = 8, // Read word fails + PP_WW_TIME_OUT = 9, // Write word fails*/ + PP_LOAD_LIBRARY_FAIL = 5, // Falla al cargar la librería + PP_WRONG_BASE_ADDRESS = 6 // Dirección base incorrecta + }; + + // Inicializacón + EppParallelUseWin(); + // Inicialización con negociación + EppParallelUseWin(const short int &base_address); + ~EppParallelUseWin(); + + // Negociación con devolución de estado + PPStatusType negotiateEPP(); + // Negociación con devolución de estado y seteo de dirección del puerto + PPStatusType negotiateEPP(const unsigned short int &base_address); + + // Reinicia el estado del puerto + void closeEPP(); + + // Dirección base del puerto (solo soporta 0x3BC, 0x378 y 0x278) + PPStatusType setBaseAddress(const short int &address); + short int getBaseAddress(); + + // Escribe/lee dirección sin/con retorno de estado + void writeAddress(const char &address); + //PPStatusType writeAddress(const char &address); + + void readAddress(char &return_address); + //PPStatusType readAddress(char &return_address) const; + + + // Escribe/lee un byte sin/con retorno de estado y selección de direccón destino + void writeByte(const char &byte); + void writeByte(const char &byte, const char &address); +// PPStatusType writeByte(const char &byte) const; +// PPStatusType writeByte(const char &byte, const char &address) const; + void readByte(char &return_byte); + void readByte(char &return_byte, const char &addresss); +// PPStatusType readByte(char &return_byte) const; +// PPStatusType readByte(char &return_byte, const char &addresss) const; + + // Escribe/lee dos bytes sin/con retorno de estado y selección de direccón destino + void writeWord(const unsigned short int &word); + void writeWord(const unsigned short int &word, const char &address); +// PPStatusType writeWord(const short int &word) const; +// PPStatusType writeWord(const short int &word, const char &address) const; + void readWord(unsigned int &return_word); + void readWord(unsigned int &return_word, const char &address); +// PPStatusType readWord(short int &return_word) const; +// PPStatusType readWord(short int &return_word, const char &address) const; + + // Devolución de estado del puerto + PPStatusType getStatus(); + + // make private + PPStatusType testDataTransfer() ; + + private: + short int baseAddress; + //int errorsCount; + PPStatusType status; + + PPStatusType loadDLL(); + // Verifica si es un estado compatible con transferencia de datos (1 = posible, 0 = no permitir) + bool testStatusForDataTransfer(); + // Resetea estado de time out + void prepareTestDataTransfer(); + // Verifica estado de time out + //PPStatusType testDataTransfer() ; + +}; + +#endif //EPP_PARALLEL_USE_WIN_H
sw/src/include/epp_parallel_use_win.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/include/delay.h =================================================================== --- sw/src/include/delay.h (nonexistent) +++ sw/src/include/delay.h (revision 60) @@ -0,0 +1,45 @@ +/* + * libieee1284 - IEEE 1284 library + * Copyright (C) 2001 Tim Waugh + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _DELAY_H_ +#define _DELAY_H_ + +enum Delays { + IO_POLL_DELAY = 0, + TIMEVAL_SIGNAL_TIMEOUT = 1, + TIMEVAL_STROBE_DELAY = 2, +}; + +static const long delay_table[] = { + 1, /* IO_POLL_DELAY */ + 100000, /* TIMEVAL_SIGNAL_TIMEOUT */ + 1 /* TIMEVAL_STROBE_DELAY */ }; + +#define lookup_delay(which, tv) ((tv)->tv_sec = 0, \ + (tv)->tv_usec = delay_table[which]) + +void udelay(unsigned long usec); + +#endif /* _DELAY_H_ */ + +/* + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */
sw/src/include/delay.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/include/epp_parallel_access_win.h =================================================================== --- sw/src/include/epp_parallel_access_win.h (nonexistent) +++ sw/src/include/epp_parallel_access_win.h (revision 60) @@ -0,0 +1,37 @@ +#ifndef EPP_PARALLEL_ACCESS_WIN_H +#define EPP_PARALLEL_ACCESS_WIN_H + +#include + +typedef void (WINAPI *PORTOUT) (short int Port, char Data); +typedef void (WINAPI *PORTWORDOUT)(short int Port, short int Data); +typedef void (WINAPI *PORTDWORDOUT)(short int Port, int Data); +typedef char (WINAPI *PORTIN) (short int Port); +typedef short int (WINAPI *PORTWORDIN)(short int Port); +typedef int (WINAPI *PORTDWORDIN)(short int Port); +typedef void (WINAPI *SETPORTBIT)(short int Port, char Bit); +typedef void (WINAPI *CLRPORTBIT)(short int Port, char Bit); +typedef void (WINAPI *NOTPORTBIT)(short int Port, char Bit); +typedef short int (WINAPI *GETPORTBIT)(short int Port, char Bit); +typedef short int (WINAPI *RIGHTPORTSHIFT)(short int Port, short int Val); +typedef short int (WINAPI *LEFTPORTSHIFT)(short int Port, short int Val); +typedef short int (WINAPI *ISDRIVERINSTALLED)(); + +extern PORTOUT PortOut; +extern PORTWORDOUT PortWordOut; +extern PORTDWORDOUT PortDWordOut; +extern PORTIN PortIn; +extern PORTWORDIN PortWordIn; +extern PORTDWORDIN PortDWordIn; +extern SETPORTBIT SetPortBit; +extern CLRPORTBIT ClrPortBit; +extern NOTPORTBIT NotPortBit; +extern GETPORTBIT GetPortBit; +extern RIGHTPORTSHIFT RightPortShift; +extern LEFTPORTSHIFT LeftPortShift; +extern ISDRIVERINSTALLED IsDriverInstalled; + +extern int LoadIODLL(); +extern void UnloadIODLL(); + +#endif //EPP_PARALLEL_ACCESS_WIN_H
sw/src/include/epp_parallel_access_win.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/include/epp_parallel_use_win.cpp =================================================================== --- sw/src/include/epp_parallel_use_win.cpp (nonexistent) +++ sw/src/include/epp_parallel_use_win.cpp (revision 60) @@ -0,0 +1,450 @@ +#include "delay.h" +#include "delay.c" +#include "epp_parallel_access_win.h" +#include "epp_parallel_use_win.h" + + +//// CONEXIÓN ////////////////////////////////////////////////////////////////////////////////////// +EppParallelUseWin::EppParallelUseWin() +{ + baseAddress = 0; + status = loadDLL(); +} + + +EppParallelUseWin::EppParallelUseWin(const short int &base_address) +{ + status = loadDLL(); + if (status == PP_STATE_IDLE) + { + status = negotiateEPP(base_address); + } +} + +EppParallelUseWin::~EppParallelUseWin() +{ + closeEPP(); +} + + + EppParallelUseWin::PPStatusType EppParallelUseWin::negotiateEPP() +{ + + switch(status) + { +/* case PP_RA_TIME_OUT: + case PP_WA_TIME_OUT: + case PP_RB_TIME_OUT: + case PP_WB_TIME_OUT: + case PP_RW_TIME_OUT: + case PP_WW_TIME_OUT:*/ + case PP_TIME_OUT: + case PP_CONECTED: + closeEPP(); + case PP_STATE_IDLE: + case PP_COMUNICATION_FAIL: + case PP_NEGOTIATION_FAIL: + char data; // temporales + int i; + // Resumen de señales de los regisros + //+1(/Busy, Ackm, Paper end, Select, Error, nc, nc, EPPtimeout?) + //+1(/Busy, Ackm, PError, Select, nFault, nc, nc, nc) + //+2(nc, nc, PCD, IRQE, /SelectIn, init, /autofeed, /strobe) + + // Se indican los números de eventos y los nombres de los tiempos de espera según estándar + + // evento -1 + data = PortIn(baseAddress+2) & 0xDE ; + PortOut(baseAddress+2, data); + udelay(1); // Tp + + // evento 0 + PortOut(baseAddress, 0x40); + udelay(1); // Tp + + // evento 1 + data = PortIn(baseAddress+2) & 0xF7 | 0x02; + PortOut(baseAddress+2, data); + + // evento 2 + for (i=0; i<35; i++) + { + udelay(1000); + data = PortIn(baseAddress+1); + if ( (data & 0x78) == 0x38) break; + //select =1 nFault = 1 nack = 0 perror = 1 + } + if (i >= 35) status = PP_COMUNICATION_FAIL; + else + { + + // evento 3 + data = PortIn(baseAddress+2) | 0x01; // nstrobe = 1 + PortOut(baseAddress+2, data); + udelay(1); // Tp + //+2(nc, nc, PCD, IRQE, /SelectIn, init, /autofeed, /strobe) + + // evento 4 + data = PortIn(baseAddress+2) & 0xfc; // nstrobe = 0 nautofeed = 0 + PortOut(baseAddress+2, data); + udelay(1); // Tp + //+2(nc, nc, PCD, IRQE, /SelectIn, init, /autofeed, /strobe) + + // evento 6 + for (i=0; i<35; i++) + { + udelay(1000); + data = PortIn(baseAddress+1); + if ( (data & 0x50) == 0x50) break; + //nack = 1 select = 1 + //+1(/Busy, Ackm, PError, Select, nFault, nc, nc, nc) + + } + + if (i >= 35) status = PP_NEGOTIATION_FAIL; + else status = PP_CONECTED; + + } + break; + + default: + break; + } + return(status); +} + + +EppParallelUseWin::PPStatusType EppParallelUseWin::negotiateEPP(const unsigned short int &address) +{ + status = setBaseAddress(address); + if (status == PP_STATE_IDLE) status = negotiateEPP(); + return(status); + +} + + +void EppParallelUseWin::closeEPP() +{ + char data; + //+2(nc, nc, PCD, IRQE, /SelectIn, init, /autofeed, /strobe) + + + // evento initialization + data = PortIn(baseAddress+2) & 0xFB | 0x08; //ninit=0 nselectin=1 + PortOut(baseAddress+2, data); + udelay(500); // T_ER + + // se realiza dos veces por las dudas + data = PortIn(baseAddress+2) | 0x04; //ninit=1 + PortOut(baseAddress+2, data); + udelay(500); // T_ER + + status = PP_STATE_IDLE; +} + + + +EppParallelUseWin::PPStatusType EppParallelUseWin::setBaseAddress(const short int &address) +{ + + if (address == 0x3BC || address == 0x378 || address == 0x278) + { + baseAddress = address; + closeEPP(); // Reinicia interfaz y setea status a PP_STATE_IDLE + } + else + { + baseAddress = 0; + status = PP_WRONG_BASE_ADDRESS; + } + return(status); +} + +short int EppParallelUseWin::getBaseAddress() {return(baseAddress);} + + +// LECTURA/ESCRITURA DIRECCIÓN ///////////////////////////////////////////////////////////////////// + +void EppParallelUseWin::writeAddress(const char &address) +{ + if (testStatusForDataTransfer()) PortOut(baseAddress + 3, address); + +} + + +//EppParallelUseWin::PPStatusType EppParallelUseWin::writeAddress(const char &address) +//{ +// if (testStatusForDataTransfer()) +// { +// prepareTestDataTransfer(); +// PortOut(baseAddress + 3, address); +// status = testDataTransfer(); +// } +// return(status); +//} + +void EppParallelUseWin::readAddress(char &return_address) +{ + if (testStatusForDataTransfer()) return_address = PortIn(baseAddress + 3); +} + +//EppParallelUseWin::PPStatusType EppParallelUseWin::readAddress(char &return_address) const +//{ +// if (testStatusForDataTransfer()) +// { +// prepareTestDataTransfer(); +// return_address = PortIn(baseAddress + 3); +// status = testDataTransfer(); +// } +// return(status); +//} + +// LECTURA/ESCRITURA BYTE ////////////////////////////////////////////////////////////////////////// +void EppParallelUseWin::writeByte(const char &byte) +{ + if (testStatusForDataTransfer()) PortOut(baseAddress + 4, byte); +} + + +void EppParallelUseWin::writeByte(const char &byte, const char &address) +{ + writeAddress(address); + if (testStatusForDataTransfer()) PortOut(baseAddress + 4, byte); +} + + +//EppParallelUseWin::PPStatusType EppParallelUseWin::writeByte(const char &byte) const +//{ +// if (testStatusForDataTransfer()) +// { +// prepareTestDataTransfer(); +// PortOut(baseAddress + 4, byte); +// status = testDataTransfer(); +// } +// return(status); +//} +// +// +//EppParallelUseWin::PPStatusType EppParallelUseWin::writeByte(const char &byte, const char &address) const +//{ +// status = writeAddress(address); +// if (status == PP_CONECTED) +// { +// prepareTestDataTransfer(); +// PortOut(baseAddress + 4, byte); +// status = testDataTransfer(); +// } +// return(status); +//} + + +void EppParallelUseWin::readByte(char &return_byte) +{ + if (testStatusForDataTransfer()) return_byte = PortIn(baseAddress+4); +} + + +void EppParallelUseWin::readByte(char &return_byte, const char &address) +{ + writeAddress(address); + if (testStatusForDataTransfer()) return_byte = PortIn(baseAddress + 4); +} + + +//EppParallelUseWin::PPStatusType EppParallelUseWin::readByte(char &return_byte) const +//{ +// if (testStatusForDataTransfer()) +// { +// prepareTestDataTransfer(); +// return_byte = PortIn(baseAddress + 4); +// status = testDataTransfer(); +// } +// return(status); +//} +// +// +//EppParallelUseWin::PPStatusType EppParallelUseWin::readByte(char &return_byte, const char &addresss) const +//{ +// status = writeAddress(address); +// if (status == PP_CONECTED) +// { +// prepareTestDataTransfer(); +// return_byte = PortIn(baseAddress + 4); +// status = testDataTransfer(); +// } +// return(status); +//} + + +// LECTURA/ESCRITURA WORD ////////////////////////////////////////////////////////////////////////// +void EppParallelUseWin::writeWord(const unsigned short int &word) +{ + if (testStatusForDataTransfer()) + { + char data; + data = word & 0x00FF; + PortOut(baseAddress + 4, data); + data = (word & 0xFF00) >> 8; + PortOut(baseAddress + 4, data); + } +} + + +void EppParallelUseWin::writeWord(const unsigned short int &word, const char &address) +{ + writeAddress(address); + writeWord(word); +} + + +//EppParallelUseWin::PPStatusType EppParallelUseWin::writeWord(const short int &word) const +//{ +// if (testStatusForDataTransfer()) +// { +// prepareTestDataTransfer(); +// char data; +// data = word & 0xFF; +// PortOut(baseAddress + 4, data); +// data = (word & 0xFF00) >> 8; +// PortOut(baseAddress + 4, data); +// status = testDataTransfer(); +// } +// return(status); +//} +// +// +//EppParallelUseWin::PPStatusType EppParallelUseWin::writeWord(const short int &word, const char &address) const +//{ +// status = writeAddress(address); +// if (status == PP_CONECTED) +// { +// prepareTestDataTransfer(); +// char data; +// data = word & 0xFF; +// PortOut(baseAddress + 4, data); +// data = (word & 0xFF00) >> 8; +// PortOut(baseAddress + 4, data); +// status = testDataTransfer(); +// } +// return(status); +//} + + +void EppParallelUseWin::readWord(unsigned int &return_word) +{ + if (testStatusForDataTransfer()) + { + unsigned int data; + + data = PortIn(baseAddress + 4) & 0x00FF; + data = (PortIn(baseAddress + 4) << 8) | data; + // udelay(600); + return_word = data & 0xFFFF; + } +} + + +void EppParallelUseWin::readWord(unsigned int &return_word, const char &address) +{ + writeAddress(address); + readWord(return_word); +} + + +//EppParallelUseWin::PPStatusType EppParallelUseWin::readWord(short int &return_word) const +//{ +// if (testStatusForDataTransfer()) +// { +// prepareTestDataTransfer(); +// short int data; +// data = PortIn(baseAddress + 4); +// data = PortIn(baseAddress + 4) << 8 | data; +// return_word = data; +// status = testDataTransfer(); +// } +// return(status); +//} +// +// +//EppParallelUseWin::PPStatusType EppParallelUseWin::readWord(short int &return_word, const char &address) const +//{ +// status = writeAddress(address); +// if (status == PP_CONECTED) +// { +// prepareTestDataTransfer(); +// short int data; +// data = PortIn(baseAddress + 4); +// data = PortIn(baseAddress + 4) << 8 | data; +// return_word = data; +// status = testDataTransfer(); +// } +// return(status); +//} + + +// LECTURA DE ESTADO DE CONEXIÓN /////////////////////////////////////////////////////////////////// +EppParallelUseWin::PPStatusType EppParallelUseWin::getStatus() {return(status);} + + +// FUNCIONES PRIVADAS ////////////////////////////////////////////////////////////////////////////// +EppParallelUseWin::PPStatusType EppParallelUseWin::loadDLL() +{ + int result; + + LoadIODLL(); + result = IsDriverInstalled(); // Funcion de testeo + if (result == 0) { + LoadIODLL(); // Segundo intento, corrige errores en Windows Vista + result = IsDriverInstalled(); + if (result == 0) return(PP_LOAD_LIBRARY_FAIL); + else return(PP_STATE_IDLE); + } + else return(PP_STATE_IDLE); +} + + +bool EppParallelUseWin::testStatusForDataTransfer() +{ + switch(status) + { + case PP_CONECTED: + /* case PP_RA_TIME_OUT: + case PP_WA_TIME_OUT: + case PP_RB_TIME_OUT: + case PP_WB_TIME_OUT: + case PP_RW_TIME_OUT: + case PP_WW_TIME_OUT:*/ + case PP_TIME_OUT: + return(1); + break; + default: + return(0); + break; + } +} + + +void EppParallelUseWin::prepareTestDataTransfer() +{ + char data; // temporal + data = PortIn(baseAddress + 1) & 0xFE ; //EPP timeout = 0 + PortOut(baseAddress + 1, data); +} + + +EppParallelUseWin::PPStatusType EppParallelUseWin::testDataTransfer() +{ + char data; + //udelay(50); + data = PortIn(baseAddress + 1) & 0x01 ; // leer EPP timeout + prepareTestDataTransfer(); + switch (data) + { + case 0: + return(PP_CONECTED); + break; + default: + return(PP_TIME_OUT); + break; + } +}
sw/src/include/epp_parallel_use_win.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rvicommthread.cpp =================================================================== --- sw/src/rvicommthread.cpp (nonexistent) +++ sw/src/rvicommthread.cpp (revision 60) @@ -0,0 +1,441 @@ +#include +#include +#include +#include +#include +//#include +#include "rvicommthread.h" + +RVICommThread::RVICommThread(QObject *parent): QThread(parent = 0) +{ + portAddress = 0; + continuous = 0; + triggerOn = 0; + triggerSlope = 0; + triggerChannel = 0; + timeScaleEnabled = 0; + timeScaleValue = 0; + channelAEnabled = 0; + channelBEnabled = 0; + bufferSize = 0; + triggerLevel = 0; + triggerOffset = 0; + + aDCSampleRate = BASE_SAMPLE_RATE; + +} + + +RVICommThread::~RVICommThread() +{ + port.closeEPP(); +} + + +void RVICommThread::run() +{ + //////////////////////////////////////////////////////////////////////////////////////////////// + // Init + acqStopped = false; + bufferFull = false; + + unsigned short int confArray[5]; + + if (bufferSize < triggerOffset || -bufferSize > triggerOffset ) + { + if (triggerOffset < 0) + triggerOffset = -bufferSize; + else + triggerOffset = bufferSize; + + emit statusMessage(tr("Too big trigger offset, truncating to: %1").arg(triggerOffset)); + } + if ( (channelAEnabled == false) && (channelBEnabled == false) ) + { + emit statusMessage(tr("All channels disabled.")); + return; + } + timer = new QTimer; + timer->setSingleShot(true); + connect(timer, SIGNAL(timeout()), SLOT(endWaiting())); + //////////////////////////////////////////////////////////////////////////////////////////////// + // Writing config + confArray[0] = 1; // Run + confArray[0] = continuous << 1 | confArray[0]; // Cont + confArray[0] = triggerOn << 2 | confArray[0]; // TrOn + confArray[0] = triggerSlope << 3 | confArray[0]; // TrEdg + confArray[0] = triggerChannel << 4 | confArray[0]; // TrCh + confArray[0] = timeScaleEnabled << 5 | confArray[0]; // TScalEn + confArray[0] = timeScaleValue << 6 | confArray[0]; // TScal00..04 + + confArray[1] = channelAEnabled; // RCh00 + confArray[1] = channelBEnabled << 1 | confArray[1]; // RCh01 + + confArray[2] = bufferSize; // BuffS00..13 + + confArray[3] = triggerLevel; // TrLvl00..09 + + confArray[4] = triggerOffset; // TrOff00..14 + + /* + ADR NAME MODE [ 15| 14| 13| 12| 11| 10| 9| 8| + 7| 6| 5| 4| 3| 2| 1| 0] bits + + 00 RunConf_R RW [ | | | | |TScal04|TScal03|TScal02| + -- TScal01|TScal00|TScalEn| TrCh| TrEdg| TrOn| Cont| Start] + -- + -- 01 Channels_R RW [ | | | | | | | | + -- | | | | | | RCh01| RCh00] + -- + -- 02 BuffSize_R RW [ | |BuffS13|BuffS12|BuffS11|BuffS10|BuffS09|BuffS08| + -- BuffS07|BuffS06|BuffS05|BuffS04|BuffS03|BuffS02|BuffS01|BuffS00] + -- + -- 03 TrigLvl_R RW [ | | | | | |TrLvl09|TrLvl08| + -- TrLvl07|TrLvl06|TrLvl05|TrLvl04|TrLvl03|TrLvl02|TrLvl01|TrLvl00] + -- + -- 04 TrigOff_R RW [ |TrOff14|TrOff13|TrOff12|TrOff11|TrOff10|TrOff09|TrOff08| + -- TrOff07|TrOff06|TrOff00|TrOff00|TrOff00|TrOff00|TrOff00|TrOff00] + -- + -- 05 ADCConf RW [ | | | | ADCS|ADSleep| ADPSEn| ADPS08| + -- ADPS07| ADPS06| ADPS05| ADPS04| ADPS03| ADPS02| ADPS01| ADPS00] + -- + -- 08 Data_O R [ErrFlag|RunFlag| | | | DCh00| Dat09| Dat08| + -- Dat07| Dat06| Dat05| Dat04| Dat03| Dat02| Dat01| Dat00] + -- + -- 09 Error_O R [ | | | | | | | | + -- | | | | | ErrN02| ErrN01| ErrN00] + */ + + + EppParallelUseWin::PPStatusType status; + + status = port.negotiateEPP(portAddress); + emit statusMessage(translateStatus(status)); + + if (status != EppParallelUseWin::PP_CONECTED) + return; + + status = port.testDataTransfer(); + for (int i = 4; i >= 0; i--) + { + port.writeWord(confArray[i], i); + status = port.testDataTransfer(); + + if (status != EppParallelUseWin::PP_CONECTED) + { + for (int j = 0; (j <= 5) && (status != EppParallelUseWin::PP_CONECTED); j++) + { + port.writeWord(confArray[i], i); + status = port.testDataTransfer(); + } + if (status != EppParallelUseWin::PP_CONECTED) + { + emit statusMessage(translateStatus(status)); + return; + } + } + + } + + //////////////////////////////////////////////////////////////////////////////////////////////// + // Write and check stream address + char address = 8; // input data address + port.testDataTransfer(); + port.writeAddress(address); + port.readAddress(address); + if (address != 8) + { + emit statusMessage(tr("Can't write an address")); + return; + } + + //////////////////////////////////////////////////////////////////////////////////////////////// + // Getting data + int count = 0; + bool oddBuffer = false; + unsigned int data = 0x80; // stopped with errors + + + dataUsed = false; + port.testDataTransfer(); // clear time out flags + channelData[0].clear(); + channelData[1].clear(); + + + if (triggerOn) + emit statusMessage(tr("Waiting for trigger...")); + else + emit statusMessage(tr("Running")); + + do { + port.readWord(data); + status = port.testDataTransfer(); + + if ((status == EppParallelUseWin::PP_CONECTED) && (data != 0xFFFF)) + { + // check running flag + if ((data & 0x4000) == 0x0000 ) + { + port.readWord(data ,0); + port.readWord(data,8); + if ((data & 0x4000) == 0x0000 ) + { + if (continuous) + { + emit statusMessage(tr("Error in data")); + } + else + { + checkDataSize(); + } + bufferFull = true; + while (dataUsed == false && acqStopped == false) ; + // emit endOfBuffer(); + return; + } + } + // if buffer is full + + else if ( ((data & 0x8000) == 0x0000) != oddBuffer) + { + // emit endOfBuffer(); + dataUsed = false; + bufferFull = true; + checkDataSize(); + while (dataUsed == false && acqStopped == false) ; + channelData[0].clear(); + channelData[1].clear(); + } + + // channel A + else if ( (data & 0x0400) == 0x0400 ) + { + // emit chBNewData(0x3FF & data); + channelData[0] << (0x3FF & data); + // oddBuffer = (data & 0x8000) == 0x0000 ; + } + // channel B + else + { + // emit chANewData(0x3FF & data); + channelData[1] << (0x3FF & data); + + } + oddBuffer = (data & 0x8000) == 0x0000 ; + count = 0; + } + else + { + count++; + if (count >= 500000) + { + if (triggerOn) + { + statusMessage(tr("Still waiting for trigger...")); + count = 0; + } + else + { + // emit endOfBuffer(); + emit statusMessage(tr("Too much time out. Check the cable.")); + return; + } + } + } + } while (acqStopped == false); + +} + + +QList RVICommThread::getChannelData(int channel) +{ + if (channel > 1 || channel < 0) + channel = 0; + dataUsed = true; + bufferFull = false; + return channelData[channel]; +} + +bool RVICommThread::isBufferFull() +{ + return bufferFull; +} + + + +void RVICommThread::checkDataSize() +{ + if (channelAEnabled && channelBEnabled) + { + if ( (bufferSize != (channelData[0].size()-1)*2) && \ + (bufferSize != (channelData[1].size()-1)*2) ) + emit statusMessage(tr("Data size and buffer size not match")); + else + emit statusMessage(tr("")); + } + else if (channelAEnabled) + { + if (bufferSize != channelData[0].size()) + emit statusMessage(tr("Data size and buffer size not match")); + else + emit statusMessage(tr("")); + } + else + { + if (bufferSize != channelData[1].size()) + emit statusMessage(tr("Data size and buffer size not match")); + else + emit statusMessage(tr("")); + } +} + + +QString RVICommThread::translateStatus(const EppParallelUseWin::PPStatusType &port_status) +{ + switch(port_status) + { + case EppParallelUseWin::PP_CONECTED: + return QString( tr("Conected")); + break; + case EppParallelUseWin::PP_TIME_OUT: + return QString( tr("Time Out")); + break; + case EppParallelUseWin::PP_COMUNICATION_FAIL: + return QString( tr("Comunication fail at 0x%1").arg(portAddress, 0, 16)); + break; + case EppParallelUseWin::PP_NEGOTIATION_FAIL: + return QString( tr("Negotiation fail at 0x%1").arg(portAddress, 0, 16)); + break; + case EppParallelUseWin::PP_LOAD_LIBRARY_FAIL: + return QString( tr("Can´t load the library")); + break; + case EppParallelUseWin::PP_WRONG_BASE_ADDRESS: + return QString( tr("Wrong port base address: 0x%1").arg(portAddress, 0, 16)); + break; + default: + return QString( tr("OK")); + break; + } +} + +void RVICommThread::endWaiting() +{ + waiting = false; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Parameters +void RVICommThread::setAddress(const short int &address) +{ + portAddress = address; +} + + +void RVICommThread::setContinuous(const bool &on) +{ + continuous = on; +} + + +void RVICommThread::setTrigger(const bool &on, const bool &slope, const bool &channel, const int &level, const int &offset) +{ + triggerOn = on; + triggerSlope = slope; + triggerChannel = channel; + triggerLevel = level; + triggerOffset = offset; +} + + +void RVICommThread::setChannels(const bool &chAOn, const bool &chBOn) +{ + channelAEnabled = chAOn; + channelBEnabled = chBOn; +} + + +void RVICommThread::setBuffer(const int &size) +{ + bufferSize = size; +} + + +void RVICommThread::setTimeScaler(const bool &on, const int &value) +{ + timeScaleEnabled = on; + timeScaleValue = value; +} + + +void RVICommThread::setADCPreScale(const int &preScale) +{ + adcPreScaler = preScale; +} + + +void RVICommThread::stopAcquistion() +{ + acqStopped = true; +} + + +void RVICommThread::configADC() +{ + if (adcPreScaler > pow(2.0, 8) ) + { + emit statusMessage("Too big pre scaler, setting to default value (1)."); + adcPreScaler = 1; + } + else + { + emit statusMessage(tr("ADC Config Writed.")); + } + + unsigned short int config; + config = adcPreScaler; // clk_pre_scaler + config = 1 << 9 | config; // clk_pre_scaler_ena + config = 0 << 10 | config; // adc sleep + config = 0 << 11 | config; // adc_chip_sel + + // if clk_pre_scaler_ena = 1, + // freq_adc = freq_wbn / ((clk_pre_scaler+1)*2) + + EppParallelUseWin::PPStatusType status; + + status = port.negotiateEPP(portAddress); + + + if (status != EppParallelUseWin::PP_CONECTED) + { + emit statusMessage(translateStatus(status)); + return; + } + + status = port.testDataTransfer(); + + port.writeWord(config, 5); + status = port.testDataTransfer(); + + if (status != EppParallelUseWin::PP_CONECTED) + { + for (int j = 0; (j <= 5) && (status != EppParallelUseWin::PP_CONECTED); j++) + { + port.writeWord(config, 5); + status = port.testDataTransfer(); + } + if (status != EppParallelUseWin::PP_CONECTED) + { + emit statusMessage(translateStatus(status)); + return; + } + } + + aDCSampleRate = BASE_SAMPLE_RATE/adcPreScaler; + +} + +double RVICommThread::getADCSampleRate() +{ + return aDCSampleRate; +}
sw/src/rvicommthread.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/data_plot.cpp =================================================================== --- sw/src/data_plot.cpp (nonexistent) +++ sw/src/data_plot.cpp (revision 60) @@ -0,0 +1,430 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "data_plot.h" + +// +// Initialize main window +// +DataPlot::DataPlot(QWidget *parent): + QwtPlot(parent) +{ + // Disable polygon clipping + QwtPainter::setDeviceClipping(false); + + // We don't need the cache here + canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); + canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); + + canvas()->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator); + + //canvas()->setPaintAttribute(QwtPlotCanvas::FocusIndicator, true); +#if QT_VERSION >= 0x040000 +//#ifdef 1 + /* + Qt::WA_PaintOnScreen is only supported for X11, but leads + to substantial bugs with Qt 4.2.x/Windows + */ + //canvas()->setAttribute(Qt::WA_PaintOnScreen, true); +//#endif +#endif + + alignScales(); + + + + // Insert new curves + curveA = new QwtPlotCurve("Channel A"); + curveA->attach(this); + curveA->setData(0,0,0); + curveA->setAxis(QwtPlot::xBottom, QwtPlot::yLeft); + + curveB = new QwtPlotCurve("Channel B"); + curveB->attach(this); + curveB->setData(0,0,0); + curveB->setAxis(QwtPlot::xBottom, QwtPlot::yRight); + + triggerLine = new QwtPlotMarker; + triggerLine->attach(this); + triggerLine->setYAxis(QwtPlot::yLeft); + triggerLine->setYValue(0); + triggerLine->setLineStyle(QwtPlotMarker::HLine); + triggerLine->setLinePen(QPen(Qt::white, 0, Qt::SolidLine)); + enableTriggerLine(false, 0); + + // Axis + // setAxisTitle(QwtPlot::xBottom, "Time/seconds"); + setAxisScale(QwtPlot::xBottom, 0, 10); + enableAxis(QwtPlot::xBottom, true); + //setAxisTitle(QwtPlot::xBottom, "Time [s]"); + //setAxisMaxMinor(QwtPlot::yLeft, 20); + //setAxisMaxMajor(QwtPlot::yLeft, 10); + enableAxis(QwtPlot::yLeft, true); + setAxisScale(QwtPlot::yLeft, -2, 2); + setAxisTitle(QwtPlot::yLeft, tr("A")); + axisTitle(QwtPlot::yLeft).setFont(QFont("Serif", 8)); + + setAxisMaxMajor(QwtPlot::xBottom, 13); + setAxisMaxMinor(QwtPlot::xBottom, 10); + + enableAxis(QwtPlot::yRight, true); + setAxisScale(QwtPlot::yRight, -2, 2); + setAxisTitle(QwtPlot::yRight, "B"); + + + setAxisFont(QwtPlot::xBottom, QFont("Serif", 8)); + setAxisFont(QwtPlot::yRight, QFont("Serif", 8)); + setAxisFont(QwtPlot::yLeft, QFont("Serif", 8)); + + // grid + gridA = new QwtPlotGrid(); + gridA->setAxis(QwtPlot::xBottom, QwtPlot::yLeft); + + gridA->setMajPen(QPen(Qt::white, 0, Qt::DotLine)); + gridA->setMinPen(QPen(Qt::white, 0 , Qt::DotLine)); + gridA->attach(this); + + + gridB = new QwtPlotGrid(); + gridB->setAxis(QwtPlot::xBottom, QwtPlot::yRight); + //gridA->enableXMin(true); + gridB->enableX(false); + gridB->setMajPen(QPen(Qt::gray, 0, Qt::DotLine)); + gridB->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); + gridB->attach(this); + + alignScales(); + + setPaused(false); + +} + +// +// Set a plain canvas frame and align the scales to it +// +void DataPlot::alignScales() +{ + // The code below shows how to align the scales to + // the canvas frame, but is also a good example demonstrating + // why the spreaded API needs polishing. + + canvas()->setFrameStyle(QFrame::Box | QFrame::Plain ); + canvas()->setLineWidth(1); + + for ( int i = 0; i < QwtPlot::axisCnt; i++ ) + { + QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); + if ( scaleWidget ) + scaleWidget->setMargin(0); + + QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); + if ( scaleDraw ) + scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); + } +} + + + +void DataPlot::setCurveAColor(const QColor &color) +{ + curveA->setPen(QPen(color)); + replot(); +} + + +void DataPlot::setCurveBColor(const QColor &color) +{ + curveB->setPen(QPen(color)); + replot(); +} + +void DataPlot::setPaused(const bool &pause) +{ + paused = pause; +} + +void DataPlot::curveAShow(const bool &show) +{ + if (show) + curveA->attach(this); + else + curveA->detach(); +} + +void DataPlot::curveBShow(const bool &show) +{ + if (show) + curveB->attach(this); + else + curveB->detach(); +} + + +void DataPlot::curveAUpdate(QVector time, QVector chA) +{ + if (paused == false) + { + curveA->setData(time, chA); + replot(); + } + + updateDivs(); +} + +void DataPlot::curveBUpdate(QVector time, QVector chB) +{ + + if (paused == false) + { + curveB->setData(time, chB); + replot(); + } + + updateDivs(); +} + +void DataPlot::updateDivs() +{ + QwtValueList tiks; + // Get aDiv values + tiks = gridA->yScaleDiv().ticks(QwtScaleDiv::MajorTick); + aDiv = tiks.value(1, 0.0) - tiks.value(0, 0.0); + aDiv = qAbs(aDiv); + + // Get bDiv values + tiks = gridB->yScaleDiv().ticks(QwtScaleDiv::MajorTick); + bDiv = tiks.value(1, 0.0) - tiks.value(0, 0.0); + bDiv = qAbs(bDiv); + + // Get tDiv values + tiks = gridA->xScaleDiv().ticks(QwtScaleDiv::MajorTick); + tDiv = tiks.value(1, 0.0) - tiks.value(0, 0.0); + tDiv = qAbs(tDiv); + + if (aDiv != 0.0) + emit aScaleDivChanged(aDiv); + else + aDiv = 1e-5; + + if (bDiv != 0.0) + emit aScaleDivChanged(bDiv); + else + bDiv = 1e-5; + + if (tDiv != 0.0) + emit tScaleDivChanged(tDiv); + else + tDiv = 1/(20e6); + +} + +void DataPlot::curveASetLimits(const double &down, const double &up) +{ + elementSetLimits(QwtPlot::yLeft, down, up); +} + + +void DataPlot::curveAZoom(const int &value) +{ + elementZoom(QwtPlot::yLeft, value); +} + +void DataPlot::curveAMove(const int &value) +{ + elementZoom(QwtPlot::yLeft, value, true); +} + +void DataPlot::curveAResetPos() +{ + double yUp, yDown; + yUp = qAbs(axisScaleDiv(QwtPlot::yLeft)->upperBound()); + yDown = qAbs(axisScaleDiv(QwtPlot::yLeft)->lowerBound()); + if (yUp >= yDown) + curveASetLimits(-yUp, yUp); + else + curveASetLimits(-yDown, yDown); +} + + +void DataPlot::curveBSetLimits(const double &down, const double &up) +{ + elementSetLimits(QwtPlot::yRight, down, up); +} + + +void DataPlot::curveBZoom(const int &value) +{ + elementZoom(QwtPlot::yRight, value); +} + + +void DataPlot::curveBMove(const int &value) +{ + elementZoom(QwtPlot::yRight, value, true); +} + + +void DataPlot::curveBResetPos() +{ + double yUp, yDown; + yUp = qAbs(axisScaleDiv(QwtPlot::yRight)->upperBound()); + yDown = qAbs(axisScaleDiv(QwtPlot::yRight)->lowerBound()); + if (yUp >= yDown) + curveBSetLimits(-yUp, yUp); + else + curveBSetLimits(-yDown, yDown); +} + + +void DataPlot::timeSetLimits(const double &min, const double &max) +{ + elementSetLimits(QwtPlot::xBottom, min, max); +} + +void DataPlot::timeZoom(const int &value) +{ + elementZoom(QwtPlot::xBottom, value); +} + +void DataPlot::timeMove(const int &value) +{ + elementZoom(QwtPlot::xBottom, value, true); +} + +void DataPlot::elementZoom(const int &axisId, const int &value, const bool &move) +{ + double up, down, div; + + switch(axisId) + { + case QwtPlot::yLeft: + div = aDiv; + break; + + case QwtPlot::yRight: + div = bDiv; + break; + + default: + div = tDiv; + break; + } + + if (value == 0) //auto scale + { + setAxisAutoScale(axisId); + } + else + { + up = axisScaleDiv(axisId)->upperBound() - div * value/10.0 ; + if (up >= 10.0) + up = axisScaleDiv(axisId)->upperBound(); + + + down = move ? axisScaleDiv(axisId)->lowerBound() - div * value/10.0 : + axisScaleDiv(axisId)->lowerBound() + div * value/10.0; + + if (down <= -10.0) + down = axisScaleDiv(axisId)->lowerBound(); + + setAxisScale(axisId, down, up); + } + + updateDivs(); + replot(); +} + + +void DataPlot::elementSetLimits(const int &axisId, const double &min, const double &max) +{ + if (min == 0 && max == 0) + setAxisAutoScale(axisId); + else + setAxisScale(axisId, \ + min, \ + max); + replot(); + updateDivs(); +} + + + +void DataPlot::curveAShowGrid(const bool &on) +{ + elementShowGrid(QwtPlot::yLeft, on); +} + + +void DataPlot::curveBShowGrid(const bool &on) +{ + elementShowGrid(QwtPlot::yRight, on); +} + + +void DataPlot::timeShowGrid(const bool &on) +{ + elementShowGrid(QwtPlot::xBottom, on); +} + +void DataPlot::elementShowGrid(const int &axisId, const bool &on) +{ + switch(axisId) + { + case QwtPlot::yLeft: + gridA->enableY(on); + break; + + case QwtPlot::yRight: + gridB->enableY(on); + break; + + default: + gridA->enableX(on); + break; + } + replot(); +} + + + +void DataPlot::enableTriggerLine(const bool &on, const int &channel) +{ + int axisId; + switch(channel) + { + case 1: + axisId = QwtPlot::yRight; + break; + + default: + axisId = QwtPlot::yLeft; + break; + } + + triggerLine->setVisible(on); + if(on) + { + triggerLine->show(); + triggerLine->setAxis(QwtPlot::xBottom, axisId); + replot(); + } + else + { + triggerLine->hide(); + replot(); + } +} + +void DataPlot::setTriggerLineValue(double val) +{ + triggerLine->setYValue(val); + replot(); +}
sw/src/data_plot.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rvicommthread.h =================================================================== --- sw/src/rvicommthread.h (nonexistent) +++ sw/src/rvicommthread.h (revision 60) @@ -0,0 +1,94 @@ +#ifndef RVICOMMTHREAD_H +#define RVICOMMTHREAD_H + +#include +#include +#include "include/epp_parallel_use_win.h" + + +const int MAX_BUFF_SIZE= 15359;// = 15359; size of memory address bus +const int MIN_BUFF_SIZE = 20; +const int SCALE_BITS = 5; // bits for data skipper +const double BASE_SAMPLE_RATE = 20e6; +const int PLOT_SIZE = 15359; +const int ADC_PS_BITS = 5; + + +class RVICommThread : public QThread +{ + Q_OBJECT + + public: + RVICommThread(QObject *parent); + ~RVICommThread(); + // Reimplementation + void run(); + + // Control + void setAddress(const short int &address); + void setContinuous(const bool &on); + void setTrigger(const bool &on, const bool &slope, const bool &channel, const int &level, \ + const int &offset); + void setChannels(const bool &chAOn, const bool &chBOn); + void setBuffer(const int &size); + void setTimeScaler(const bool &on, const int &value); + + // ADC + void setADCPreScale(const int &preScale); + + // Data + QList getChannelData(int channel); + bool isBufferFull(); + double getADCSampleRate(); + + public slots: + void stopAcquistion(); + void configADC(); + + private slots: + void endWaiting(); + + signals: + void chANewData(int val); + void chBNewData(int val); + void statusMessage(QString message); + void endOfBuffer(); + + private: + QString translateStatus(const EppParallelUseWin::PPStatusType &port_status); + EppParallelUseWin port; + void checkDataSize(); + bool acqStopped; + bool dataUsed; + bool bufferFull; + + //Data + QList channelData[2]; // two channels + // Timer + QTimer *timer; + bool waiting; + // Config variables + short int portAddress; + bool continuous; + bool triggerOn; + bool triggerSlope; + bool triggerChannel; + bool timeScaleEnabled; + int timeScaleValue; + bool channelAEnabled; + bool channelBEnabled; + int bufferSize; + int triggerLevel; + int triggerOffset; + // ADC + int adcPreScaler; + + // Values + double aDCSampleRate; + +}; + +#endif // RVICOMMTHREAD_H + + +
sw/src/rvicommthread.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rvioscilloscope.ui =================================================================== --- sw/src/rvioscilloscope.ui (nonexistent) +++ sw/src/rvioscilloscope.ui (revision 60) @@ -0,0 +1,283 @@ + + + RVIOscilloscope + + + + 0 + 0 + 595 + 342 + + + + + 0 + 0 + + + + RVI Osciloscope + + + + + + + + 0 + 0 + 595 + 19 + + + + + &File + + + + + + + + + &View + + + + + + + + + &Help + + + + + + + + + + + + Main Toolbar + + + TopToolBarArea + + + false + + + + + + + + + + + QDockWidget::AllDockWidgetFeatures + + + Qt::AllDockWidgetAreas + + + Controls + + + 8 + + + + + 0 + + + + + + + File + + + + + &Exit + + + + + &Manual + + + + + true + + + + :/images/media-playback-pause.png:/images/media-playback-pause.png + + + Pause + + + Pause the plot + + + Ctrl+P + + + + + true + + + true + + + &Show controls + + + Show board contros + + + + + + :/images/fill-color.png:/images/fill-color.png + + + &Background color... + + + Set plot background color... + + + + + true + + + + :/images/zoom-in.png + + + + Zoom + + + Zoom area from plot + + + + + + :/images/document-save-image.PNG:/images/document-save-image.PNG + + + Save &image... + + + Save an image of the current plot... + + + + + true + + + true + + + &Dock controls + + + Dock controls in the main wondows + + + + + + :/images/document-save.png:/images/document-save.png + + + Save data... + + + Save the current plot data + + + + + &About + + + + + true + + + true + + + + :/images/grid_left.png + + + + Show channel A grid + + + Enable/disable channel A grid in plotter + + + + + true + + + true + + + + :/images/grid_right.png + :/images/grid_right.png:/images/grid_right.png + + + Show channel B grid + + + Enable/disable channel B grid in plotter + + + + + true + + + true + + + + :/images/grid_time.png + :/images/grid_time.png:/images/grid_time.png + + + Show time grid + + + Enable/disable channel A grid in plotter + + + + + + + + +
sw/src/rvioscilloscope.ui Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/data_plot.h =================================================================== --- sw/src/data_plot.h (nonexistent) +++ sw/src/data_plot.h (revision 60) @@ -0,0 +1,88 @@ +#ifndef _DATA_PLOT_H +#define _DATA_PLOT_H 1 + +#include +#include +#include +#include +//#include +#include +#include + +//const int PLOT_SIZE = 600; // 0 to 200 + +class DataPlot : public QwtPlot +{ + Q_OBJECT + + + public: + DataPlot(QWidget* = NULL); + void updateDivs(); + + + public slots: + // void setTimerInterval(double interval); + void enableTriggerLine(const bool &on, const int &channel); + void setTriggerLineValue(double val); + + void setCurveAColor(const QColor &color); + void setCurveBColor(const QColor &color); + void setPaused(const bool &pause); + void curveAShow(const bool &show); + void curveBShow(const bool &show); + void curveAUpdate(QVector time, QVector chA); + void curveBUpdate(QVector time, QVector chB); + + void curveASetLimits(const double &down, const double &up); + void curveAZoom(const int &value); + void curveAMove(const int &value); + void curveAResetPos(); + void curveBSetLimits(const double &down, const double &up); + void curveBZoom(const int &value); + void curveBMove(const int &value); + void curveBResetPos(); + void timeSetLimits(const double &min, const double &max); + void timeZoom(const int &value); + void timeMove(const int &value); + + void curveAShowGrid(const bool &on); + void curveBShowGrid(const bool &on); + void timeShowGrid(const bool &on); + + + + + private: + void alignScales(); + void elementZoom(const int &axisId, const int &value, const bool &move = 0); + void elementSetLimits(const int &axisId, const double &min, const double &max); + void elementShowGrid(const int &axisId, const bool &on); + + QwtPlotGrid *gridA; + QwtPlotGrid *gridB; + + // QwtPlotGrid *gridB; + bool paused; + double aDiv; + double bDiv; + double tDiv; + + QwtPlotCurve *curveA; + QwtPlotCurve *curveB; + QwtPlotMarker *triggerLine; + QwtPlotRescaler *aRescaler; + QwtPlotRescaler *bRescaler; + QwtPlotRescaler *tRescaler; + + + signals: + void tScaleDivChanged(double ); + void aScaleDivChanged(double ); + void bScaleDivChanged(double ); +}; + +#endif + + +
sw/src/data_plot.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/widgetboardtools.cpp =================================================================== --- sw/src/widgetboardtools.cpp (nonexistent) +++ sw/src/widgetboardtools.cpp (revision 60) @@ -0,0 +1,102 @@ +#include "widgetboardtools.h" +#include "ui_widgetboardtools.h" + +WidgetBoardTools::WidgetBoardTools(QWidget *parent) + : QWidget(parent), ui(new Ui::WidgetBoardTools) +{ + maxBufferSize = 1000; + minBufferSize = 20; + scaleBits = 5; + sampleRate = 20e6; + timeDivitions = 10; + hSamplesNumber = 200; + + ui->setupUi(this); + fillTriggerCombo(); + fillTriggerSlope(); + on_bufferSlider_valueChanged(1000); + setUpMaxValues(); + + + + +} + +WidgetBoardTools::~WidgetBoardTools() +{ + delete ui; +} + + + +void WidgetBoardTools::fillTriggerCombo() +{ + ui->trigSouceCombo->clear(); + if (ui->channelABox->isChecked() == true) + { + ui->trigSouceCombo->addItem("A"); + } + if (ui->channelBBox->isChecked() == true) + { + ui->trigSouceCombo->addItem("B"); + } +} + +void WidgetBoardTools::fillTriggerSlope() +{ + ui->trigSlopeCombo->addItem(QIcon(":/images/rising.png"),"Rising"); + ui->trigSlopeCombo->addItem(QIcon(":/images/falling.png"),"Falling"); +} + + +void WidgetBoardTools::setUpMaxValues() +{ + + ui->bufferSpinBox->setMaximum(maxBufferSize); +// ui->bufferSlider->setMaximum(maxBufferSize); + ui->bufferSpinBox->setMinimum(minBufferSize); +// ui->bufferSlider->setMinimum(minBufferSize); + + float timePositions = 2^scaleBits; + float period = 1/sampleRate; + float positionValue; + float maxPositionValue; + int samplesPerDiv = hSamplesNumber/timeDivitions; + positionValue = period*samplesPerDiv; + maxPositionValue = period*samplesPerDiv*timePositions; + ui->timeScaleSpinBox->setDecimals(9); + ui->timeScaleSpinBox->setMaximum(timeDivitions*positionValue*timePositions); + ui->timeScaleSpinBox->setMinimum(0); + ui->timeScaleSpinBox->setSingleStep(positionValue); + +// ui->timeScaleKnob->Qwt +// +// TickType { +// NoTick = -1, +// MinorTick, +// MediumTick, +// MajorTick, +// NTickTypes +// } + +} + +void WidgetBoardTools::on_bufferSlider_valueChanged(int value) +{ + ui->trigOffsetSlider->setMaximum(value - 1); + ui->triggerOffsetSpinBox->setMaximum(value - 1); + ui->trigOffsetSlider->setMinimum(-value); + ui->triggerOffsetSpinBox->setMinimum(-value); + ui->triggerOffsetSpinBox->setValue(0); +} + + + +void WidgetBoardTools::on_runButton_clicked(bool checked) +{ + if (checked == true) + ui->runButton->setText(tr("Stop")); + else + ui->runButton->setText(tr("Start")); + +}
sw/src/widgetboardtools.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rvioscilloscope.cpp =================================================================== --- sw/src/rvioscilloscope.cpp (nonexistent) +++ sw/src/rvioscilloscope.cpp (revision 60) @@ -0,0 +1,227 @@ +#include +#include +#include +#include "rvioscilloscope.h" +#include +#include +#include "data_plot.h" +#include "ui_rvioscilloscope.h" +#include +#include + + +class Zoomer: public QwtPlotZoomer +{ +public: + Zoomer(int xAxis, int yAxis, QwtPlotCanvas *canvas): + QwtPlotZoomer(xAxis, yAxis, canvas) + { + setTrackerMode(QwtPicker::AlwaysOff); + setRubberBand(QwtPicker::NoRubberBand); + + // RightButton: zoom out by 1 + // Ctrl+RightButton: zoom out to full size + + setMousePattern(QwtEventPattern::MouseSelect2, + Qt::RightButton, Qt::ControlModifier); + + setMousePattern(QwtEventPattern::MouseSelect3, + Qt::RightButton); + + } +}; + + +RVIOscilloscope::RVIOscilloscope(QWidget *parent) + : QMainWindow(parent), ui(new Ui::RVIOscilloscope) +{ + ui->setupUi(this); + + extraTools = new RVIBoardTools(this); + ui->toolsLayout->addWidget(extraTools); + + createPlot(); + + + + // zoom + d_zoomer[0] = new Zoomer( QwtPlot::xBottom, QwtPlot::yLeft, + plot->canvas()); + d_zoomer[0]->setRubberBand(QwtPicker::RectRubberBand); + d_zoomer[0]->setRubberBandPen(QColor(Qt::green)); + d_zoomer[0]->setTrackerMode(QwtPicker::ActiveOnly); + d_zoomer[0]->setTrackerPen(QColor(Qt::white)); + + d_zoomer[1] = new Zoomer(QwtPlot::xTop, QwtPlot::yRight, + plot->canvas()); + + d_panner = new QwtPlotPanner(plot->canvas()); + d_panner->setMouseButton(Qt::MidButton); + + + + enableZoomMode(false); + + + // picker + QwtPlotPicker *selectLine = new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft , + QwtPlotPicker::VLineRubberBand, + QwtPlotPicker::AlwaysOff, + plot->canvas()); + + //selectLine->setRubberBand(QwtPlotPicker::VLineRubberBand); + selectLine->setStateMachine(new QwtPickerClickPointMachine); + selectLine->setAxis(QwtPlot::xBottom, QwtPlot::yLeft); + selectLine->setRubberBandPen(QPen(Qt::yellow, 0, Qt::SolidLine)); + selectLine->setEnabled(true); + + //selectLine->begin(); + //selectLine->append(QPoint(0,0)); + selectLine->setTrackerPen(QColor(Qt::white)); + + + connect(ui->actionDockControls,SIGNAL(triggered(bool)), this, SLOT(setDockedControlsDock(bool))); + connect(ui->controlsDock,SIGNAL(topLevelChanged(bool)), ui->actionDockControls, SLOT(toggle())); + connect(ui->actionShowControls, SIGNAL(toggled(bool)), ui->controlsDock, SLOT(setVisible(bool))); + connect(ui->controlsDock, SIGNAL(visibilityChanged(bool)), ui->actionShowControls, SLOT(setChecked(bool))); + + connect(ui->actionZoom, SIGNAL(triggered(bool)), this, SLOT(enableZoomMode(bool))); + connect(ui->actionSaveImage, SIGNAL(triggered()), SLOT(exportSVG())); + connect(ui->actionPause, SIGNAL(toggled(bool)), plot, SLOT(setPaused(bool))); + connect(ui->actionPause, SIGNAL(toggled(bool)), extraTools, SLOT(setPaused(bool))); + + connect(ui->actionEnChAGrid, SIGNAL(triggered(bool)), plot, SLOT(curveAShowGrid(bool))); + connect(ui->actionEnChBGrid, SIGNAL(triggered(bool)), plot, SLOT(curveBShowGrid(bool))); + connect(ui->actionEnTimeGrid, SIGNAL(triggered(bool)), plot, SLOT(timeShowGrid(bool))); + + connect(extraTools, SIGNAL(statusChanged(QString)) ,ui->statusBar, SLOT(showMessage(QString))); + connect(extraTools, SIGNAL(channelAEnabled(bool)), plot, SLOT(curveAShow(bool))); + connect(extraTools, SIGNAL(channelBEnabled(bool)), plot, SLOT(curveBShow(bool))); + connect(extraTools, SIGNAL(channelAColorChanged(QColor)),plot,SLOT(setCurveAColor(QColor))); + connect(extraTools, SIGNAL(channelBColorChanged(QColor)),plot,SLOT(setCurveBColor(QColor))); + connect(extraTools, SIGNAL(channelAData(QVector , QVector )),plot,SLOT(curveAUpdate(QVector,QVector))); + connect(extraTools, SIGNAL(channelBData(QVector , QVector )),plot,SLOT(curveBUpdate(QVector , QVector ))); + connect(plot, SIGNAL(aScaleDivChanged(double)), extraTools, SLOT(setChannelADiv(double))); + connect(plot, SIGNAL(tScaleDivChanged(double)), extraTools, SLOT(setTimeDiv(double))); + //connect(extraTools, SIGNAL(channelAChangeDiv(double,double)),plot,SLOT(curveASetLimits(double,double))); + connect(extraTools, SIGNAL(channelAChangeDiv(int)), plot, SLOT(curveAZoom(int))); + connect(extraTools, SIGNAL(channelAMove(int)), plot, SLOT(curveAMove(int))); + connect(extraTools, SIGNAL(channelAResetPos()), plot, SLOT(curveAResetPos())); + connect(extraTools, SIGNAL(channelBChangeDiv(int)), plot, SLOT(curveBZoom(int))); + connect(extraTools, SIGNAL(channelBMove(int)), plot, SLOT(curveBMove(int))); + connect(extraTools, SIGNAL(channelBResetPos()), plot, SLOT(curveBResetPos())); + connect(extraTools, SIGNAL(timeChangeDiv(int)), plot, SLOT(timeZoom(int))); + connect(extraTools, SIGNAL(timeMove(int)), plot, SLOT(timeMove(int))); + connect(extraTools, SIGNAL(timeChangeLimits(double,double)), plot, SLOT(timeSetLimits(double,double))); + connect(extraTools, SIGNAL(timeChangeLimits(double,double)), this, SLOT(updateZoomLimits())); + + connect(extraTools, SIGNAL(showTriggerLine(bool, int)),plot,SLOT(enableTriggerLine(bool, int))); + connect(extraTools, SIGNAL(changeTriggerValue(double)),plot,SLOT(setTriggerLineValue(double))); + + extraTools->setDefaultValues(); + plot->updateDivs(); +} + +RVIOscilloscope::~RVIOscilloscope() +{ + delete ui; +} + + +void RVIOscilloscope::createPlot() +{ + + plot = new DataPlot(this); + //setCentralWidget(plot); + ui->mainLayout->addWidget(plot); + plot->setMinimumHeight(200); + plot->setMinimumWidth(200); + plot->setCanvasBackground(QColor(Qt::black)); + + plot->setCurveAColor(Qt::red); + plot->setCurveBColor(Qt::yellow); +// QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); +// sizePolicy.setVerticalStretch(30); +// plot->setSizePolicy(sizePolicy); + //plot->setMargin(12); + +} + + +void RVIOscilloscope::enableZoomMode(bool on) +{ + d_panner->setEnabled(on); + + d_zoomer[0]->setEnabled(on); + // d_zoomer[0]->zoom(0); + + d_zoomer[1]->setEnabled(on); + // d_zoomer[1]->zoom(0); +} + + +void RVIOscilloscope::updateZoomLimits() +{ + d_zoomer[0]->setZoomBase(); + d_zoomer[1]->setZoomBase(); +} + + +void RVIOscilloscope::on_actionBackgroundColor_triggered() +{ + QColorDialog *colorChooser = new QColorDialog(plot->canvasBackground()); + plot->setCanvasBackground(colorChooser->getColor()); + +} + +void RVIOscilloscope::setDockedControlsDock(bool set) +{ + ui->controlsDock->setFloating(!(set)); +} + +void RVIOscilloscope::exportSVG() +{ + QString fileName = "plot.svg"; + + fileName = QFileDialog::getSaveFileName( + this, "Export File Name", QString(), + "SVG Documents (*.svg)"); + + if ( !fileName.isEmpty() ) + { + QSvgGenerator generator; + generator.setFileName(fileName); + generator.setSize(QSize(800, 600)); + + plot->print(generator); + } + +} + +void RVIOscilloscope::on_actionSaveData_triggered() +{ + QString fileName = "data"; + + fileName = QFileDialog::getSaveFileName( + this, "File name:", fileName, + "Text file (*.txt);;All files (*.*)"); + + if ( !fileName.isEmpty() ) + { + QFile file(fileName); + + if (file.open(QFile::WriteOnly | QFile::Truncate)) + { + QTextStream out(&file); + out << qSetFieldWidth(15) << right << "Time" << "Channel A" << "Channel B" << endl; + for (int i = 0; i < extraTools->getData(RVIBoardTools::Time).size(); i++) + { + out << qSetFieldWidth(15) << right \ + << extraTools->getData(RVIBoardTools::Time).value(i, 0.0)\ + << extraTools->getData(RVIBoardTools::ChannelA).value(i, 0.0) \ + << extraTools->getData(RVIBoardTools::ChannelB).value(i, 0.0) << endl; + } + + } + } +}
sw/src/rvioscilloscope.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/images/falling.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/falling.png =================================================================== --- sw/src/images/falling.png (nonexistent) +++ sw/src/images/falling.png (revision 60)
sw/src/images/falling.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/media-playback-pause.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/media-playback-pause.png =================================================================== --- sw/src/images/media-playback-pause.png (nonexistent) +++ sw/src/images/media-playback-pause.png (revision 60)
sw/src/images/media-playback-pause.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/in_couplig_mode_jumpers =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/in_couplig_mode_jumpers =================================================================== --- sw/src/images/in_couplig_mode_jumpers (nonexistent) +++ sw/src/images/in_couplig_mode_jumpers (revision 60)
sw/src/images/in_couplig_mode_jumpers Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/grid_left.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/grid_left.png =================================================================== --- sw/src/images/grid_left.png (nonexistent) +++ sw/src/images/grid_left.png (revision 60)
sw/src/images/grid_left.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/fill-color.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/fill-color.png =================================================================== --- sw/src/images/fill-color.png (nonexistent) +++ sw/src/images/fill-color.png (revision 60)
sw/src/images/fill-color.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/grid_right.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/grid_right.png =================================================================== --- sw/src/images/grid_right.png (nonexistent) +++ sw/src/images/grid_right.png (revision 60)
sw/src/images/grid_right.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/grid_time.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/grid_time.png =================================================================== --- sw/src/images/grid_time.png (nonexistent) +++ sw/src/images/grid_time.png (revision 60)
sw/src/images/grid_time.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/zoom-in.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/zoom-in.png =================================================================== --- sw/src/images/zoom-in.png (nonexistent) +++ sw/src/images/zoom-in.png (revision 60)
sw/src/images/zoom-in.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/document-save.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/document-save.png =================================================================== --- sw/src/images/document-save.png (nonexistent) +++ sw/src/images/document-save.png (revision 60)
sw/src/images/document-save.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/document-save-image.PNG =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/document-save-image.PNG =================================================================== --- sw/src/images/document-save-image.PNG (nonexistent) +++ sw/src/images/document-save-image.PNG (revision 60)
sw/src/images/document-save-image.PNG Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/images/rising.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sw/src/images/rising.png =================================================================== --- sw/src/images/rising.png (nonexistent) +++ sw/src/images/rising.png (revision 60)
sw/src/images/rising.png Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: sw/src/main.cpp =================================================================== --- sw/src/main.cpp (nonexistent) +++ sw/src/main.cpp (revision 60) @@ -0,0 +1,10 @@ +#include +#include "rvioscilloscope.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + RVIOscilloscope w; + w.show(); + return a.exec(); +}
sw/src/main.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rviboardtools.ui =================================================================== --- sw/src/rviboardtools.ui (nonexistent) +++ sw/src/rviboardtools.ui (revision 60) @@ -0,0 +1,2501 @@ + + + RVIBoardTools + + + + 0 + 0 + 619 + 275 + + + + + 0 + 0 + + + + Qt::ActionsContextMenu + + + WidgetBoardTools + + + Qt::LeftToRight + + + + QLayout::SetDefaultConstraint + + + 6 + + + 6 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Channel A + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + 5 + + + 6 + + + + + 6 + + + + + -5 + + + 5 + + + 1 + + + 0 + + + true + + + Qt::Vertical + + + false + + + false + + + QSlider::TicksBelow + + + 1 + + + + + + + + 0 + 0 + + + + Zoom + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + false + + + true + + + true + + + QAbstractSpinBox::NoButtons + + + V/Div + + + 2 + + + 1000.000000000000000 + + + + + + + + 16777215 + 16777215 + + + + Auto + + + + 16 + 16 + + + + true + + + + + + + + + 6 + + + + + -5 + + + 5 + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + false + + + false + + + QSlider::TicksBelow + + + 1 + + + + + + + + 0 + 0 + + + + Position + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + true + + + QAbstractSpinBox::NoButtons + + + Div + + + 2 + + + + + + + + 16777215 + 16777215 + + + + Center + + + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 63 + + + + + + + 127 + 127 + 0 + + + + + + + 170 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 63 + + + + + + + 127 + 127 + 0 + + + + + + + 170 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 127 + 127 + 0 + + + + + + + 255 + 255 + 0 + + + + + + + 255 + 255 + 127 + + + + + + + 255 + 255 + 63 + + + + + + + 127 + 127 + 0 + + + + + + + 170 + 170 + 0 + + + + + + + 127 + 127 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 127 + 127 + 0 + + + + + + + 255 + 255 + 0 + + + + + + + 255 + 255 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + + + + :/images/fill-color.png + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/in_couplig_mode_jumpers" /></p></body></html> + + + QFrame::StyledPanel + + + QFrame::Raised + + + 1 + + + + 0 + + + QLayout::SetMinimumSize + + + 0 + + + + + + 0 + 0 + + + + DC + + + true + + + true + + + true + + + true + + + + + + + + 0 + 0 + + + + 0 + + + true + + + true + + + true + + + + + + + + 0 + 0 + + + + AC + + + true + + + true + + + true + + + + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + + + Span: + + + + + + + 2 V + + + true + + + + + + + 1 V + + + + + + + + + + + + + + 0 + 0 + + + + Channel B + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + 5 + + + 6 + + + + + 6 + + + + + -5 + + + 5 + + + 1 + + + 0 + + + Qt::Vertical + + + false + + + false + + + QSlider::TicksBelow + + + 1 + + + + + + + + 0 + 0 + + + + Zoom + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + true + + + QAbstractSpinBox::NoButtons + + + V/Div + + + 2 + + + 1000.000000000000000 + + + + + + + + 16777215 + 16777215 + + + + Auto + + + true + + + + + + + + + 6 + + + + + -5 + + + 5 + + + 10 + + + 1 + + + 0 + + + 0 + + + true + + + Qt::Vertical + + + false + + + false + + + QSlider::TicksBelow + + + 1 + + + + + + + + 0 + 0 + + + + Position + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + true + + + QAbstractSpinBox::NoButtons + + + + + + Div + + + 2 + + + 1000.000000000000000 + + + + + + + + 16777215 + 16777215 + + + + Center + + + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 216 + 198 + + + + + + + 69 + 255 + 240 + + + + + + + 34 + 235 + 219 + + + + + + + 0 + 108 + 99 + + + + + + + 0 + 144 + 132 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 216 + 198 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 235 + 226 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 216 + 198 + + + + + + + 69 + 255 + 240 + + + + + + + 34 + 235 + 219 + + + + + + + 0 + 108 + 99 + + + + + + + 0 + 144 + 132 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 216 + 198 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 235 + 226 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 108 + 99 + + + + + + + 0 + 216 + 198 + + + + + + + 69 + 255 + 240 + + + + + + + 34 + 235 + 219 + + + + + + + 0 + 108 + 99 + + + + + + + 0 + 144 + 132 + + + + + + + 0 + 108 + 99 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 108 + 99 + + + + + + + 0 + 216 + 198 + + + + + + + 0 + 216 + 198 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 216 + 198 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + + + + :/images/fill-color.png + + + + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/in_couplig_mode_jumpers" /></p></body></html> + + + QFrame::StyledPanel + + + QFrame::Raised + + + 1 + + + + 0 + + + QLayout::SetMinimumSize + + + 0 + + + + + + 0 + 0 + + + + DC + + + true + + + true + + + true + + + true + + + + + + + + 0 + 0 + + + + 0 + + + true + + + true + + + true + + + + + + + + 0 + 0 + + + + AC + + + true + + + true + + + true + + + + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + + + Span: + + + + + + + 2 V + + + true + + + + + + + 1 V + + + + + + + + + + + + + + 0 + 0 + + + + Run control + + + + 6 + + + 3 + + + 6 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 0 + 0 + + + + + 0 + 0 + + + + 1 + + + 3 + + + + 3BC + + + + + 378 + + + + + 278 + + + + + + + + true + + + + 0 + 0 + + + + Single + + + + 16 + 16 + + + + true + + + false + + + + + + + + 0 + 0 + + + + Start + + + + 16 + 16 + + + + true + + + true + + + true + + + + + + + + + + + 0 + 0 + + + + Trigger + + + true + + + + 4 + + + + + + 0 + 0 + + + + false + + + + + + + + 0 + 0 + + + + + + + + Source + + + + + + + Slope + + + + + + + 6 + + + + + 100 + + + 50 + + + 50 + + + true + + + Qt::Vertical + + + false + + + false + + + QSlider::TicksBelow + + + 0 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + % + + + 100 + + + 50 + + + + + + + Show line + + + + + + + + 0 + 0 + + + + Level + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + 0 + 0 + + + + + + + + Offset + + + + + + + + 0 + 0 + + + + 50 + + + Qt::Horizontal + + + + + + + + + + + 0 + 0 + + + + Time + + + + 6 + + + + + + + + 0 + 0 + + + + Zoom + + + + + + + + 0 + 0 + + + + -5 + + + 5 + + + 1 + + + 0 + + + true + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 1 + + + + + + + + 0 + 0 + + + + true + + + QAbstractSpinBox::NoButtons + + + s/Div. + + + 2 + + + 1000.000000000000000 + + + + + + + + 16777215 + 16777215 + + + + + 0 + 0 + + + + + 0 + 13 + + + + + 8 + + + + Auto + + + + 15 + 16 + + + + true + + + false + + + false + + + false + + + + + + + + 0 + 0 + + + + Position + + + + + + + + 0 + 0 + + + + -3 + + + 3 + + + 1 + + + 0 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 1 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Vertical + + + + + + + + + + 0 + 0 + + + + Buffer Size + + + + + + + + 0 + 0 + + + + 10 + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Sample time + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + ADC... + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Quick update + + + + + + + + + + + + + channelABox + channelAZoomSlider + channelAZoomSpinBox + channelAPosSlider + channelAPosSpinBox + channelBBox + channelBZoomSlider + channelBZoomSpinBox + channelBPosSlider + channelBPosSpinBox + trigBox + trigSouceCombo + trigSlopeCombo + trigOffsetSlider + trigOffsetSpinBox + trigLevelSlider + trigLevelSpinBox + trigLineCheck + sampleTimeCombo + + + + + channelABox + toggled(bool) + RVIBoardTools + fillTriggerCombo() + + + 70 + 15 + + + 125 + 34 + + + + + channelBBox + toggled(bool) + RVIBoardTools + fillTriggerCombo() + + + 266 + 33 + + + 194 + 1 + + + + + trigLevelSlider + valueChanged(int) + trigLevelSpinBox + setValue(int) + + + 305 + 200 + + + 395 + 169 + + + + + trigLevelSpinBox + valueChanged(int) + trigLevelSlider + setValue(int) + + + 395 + 169 + + + 305 + 200 + + + + + trigOffsetSlider + valueChanged(int) + trigOffsetSpinBox + setValue(int) + + + 390 + 94 + + + 390 + 118 + + + + + trigOffsetSpinBox + valueChanged(int) + trigOffsetSlider + setValue(int) + + + 390 + 118 + + + 390 + 94 + + + + + chASpan2VRadio + toggled(bool) + RVIBoardTools + setVoltMultipliers() + + + 80 + 72 + + + 162 + 102 + + + + + channelAZBtn + toggled(bool) + RVIBoardTools + setVoltMultipliers() + + + 64 + 47 + + + 159 + 73 + + + + + channelBZBtn + toggled(bool) + RVIBoardTools + setVoltMultipliers() + + + 200 + 53 + + + 321 + 103 + + + + + chBSpan2VRadio + toggled(bool) + RVIBoardTools + setVoltMultipliers() + + + 220 + 79 + + + 318 + 157 + + + + + trigOffsetSpinBox + valueChanged(int) + RVIBoardTools + updateTimeVec() + + + 367 + 113 + + + 411 + 130 + + + + + sampleTimeCombo + currentIndexChanged(int) + RVIBoardTools + updateTimeVec() + + + 626 + 123 + + + 565 + 3 + + + + + bufferSpinBox + valueChanged(int) + RVIBoardTools + updateTimeVec() + + + 626 + 68 + + + 595 + 182 + + + + + + fillTriggerCombo() + setVoltMultipliers() + updateTimeVec() + +
sw/src/rviboardtools.ui Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rvioscilloscope.h =================================================================== --- sw/src/rvioscilloscope.h (nonexistent) +++ sw/src/rvioscilloscope.h (revision 60) @@ -0,0 +1,44 @@ +#ifndef RVIOSCILLOSCOPE_H +#define RVIOSCILLOSCOPE_H + +#include +#include +#include +#include "data_plot.h" +#include "rviboardtools.h" + +namespace Ui +{ + class RVIOscilloscope; +} + +class RVIOscilloscope : public QMainWindow +{ + Q_OBJECT + +public: + RVIOscilloscope(QWidget *parent = 0); + ~RVIOscilloscope(); + +private: + Ui::RVIOscilloscope *ui; + + QwtPlotZoomer *d_zoomer[2]; + QwtPlotPanner *d_panner; + QAction *zoomAct; + + DataPlot *plot; + RVIBoardTools *extraTools; + + void createPlot(); + +private slots: + void on_actionSaveData_triggered(); + void on_actionBackgroundColor_triggered(); + void enableZoomMode(bool on); + void setDockedControlsDock(bool set); + void exportSVG(); + void updateZoomLimits(); +}; + +#endif // RVIOSCILLOSCOPE_H
sw/src/rvioscilloscope.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rviboardtools.cpp =================================================================== --- sw/src/rviboardtools.cpp (nonexistent) +++ sw/src/rviboardtools.cpp (revision 60) @@ -0,0 +1,754 @@ +#include +#include +#include +#include +#include +#include +#include "rviboardtools.h" +#include "ui_rviboardtools.h" + +// temp +#include + + +class Suffixer +{ +public: + Suffixer(double number = 0.0) + { + setNumber(number); + } + + void setNumber(double number) + { + number = qAbs(number); + if (number < 1e-9) + { + multiplier = 1e9; + suffix = QString("p"); + } + else if (number < 1e-6) + { + multiplier = 1e6; + suffix = QString("n"); + } + else if (number < 1e-3) + { + multiplier = 1e6; + suffix = QString("u"); + } + else if (number < 1.0) + { + multiplier = 1e3; + suffix = QString("m"); + } + else + { + multiplier = 1.0; + suffix = QString(""); + } + } + + double multiplier; + QString suffix; +}; + + +RVIBoardTools::RVIBoardTools(QWidget *parent) + : QWidget(parent), + ui(new Ui::RVIBoardTools) +{ + ui->setupUi(this); + + slidersTimer = new QTimer(this); + slidersTimer->setInterval(550); + + dataTimer = new QTimer(this); + dataTimer->setInterval(30); // plot update time + + dataAVec = new QVector; + dataBVec = new QVector; + timeVec = new QVector; + board = new RVICommThread(this); + + + // Timer for sliders + connect(slidersTimer, SIGNAL(timeout()),this, SLOT(updateSlidersValues())); + + connect(ui->timeZoomSlider , SIGNAL(sliderPressed()), slidersTimer , SLOT(start())); + connect(ui->timeZoomSlider, SIGNAL(sliderReleased()), slidersTimer, SLOT(stop())); + connect(ui->timePosSlider , SIGNAL(sliderPressed()), slidersTimer , SLOT(start())); + connect(ui->timePosSlider, SIGNAL(sliderReleased()), slidersTimer, SLOT(stop())); + + connect(ui->channelAZoomSlider , SIGNAL(sliderPressed()), slidersTimer , SLOT(start())); + connect(ui->channelAZoomSlider, SIGNAL(sliderReleased()), slidersTimer, SLOT(stop())); + connect(ui->channelAPosSlider, SIGNAL(sliderPressed()), slidersTimer , SLOT(start())); + connect(ui->channelAPosSlider, SIGNAL(sliderReleased()), slidersTimer, SLOT(stop())); + + connect(ui->channelBZoomSlider , SIGNAL(sliderPressed()), slidersTimer , SLOT(start())); + connect(ui->channelBZoomSlider, SIGNAL(sliderReleased()), slidersTimer, SLOT(stop())); + connect(ui->channelBPosSlider, SIGNAL(sliderPressed()), slidersTimer , SLOT(start())); + connect(ui->channelBPosSlider, SIGNAL(sliderReleased()), slidersTimer, SLOT(stop())); + + // Board connections + //connect(board, SIGNAL(chANewData(int )), this, SLOT(chAAppData(int)) ); + //connect(board, SIGNAL(chBNewData(int )), this, SLOT(chBAppData(int))); + //connect(board, SIGNAL(finished()),this,SLOT(uncheckRunButtons())); + //connect(board, SIGNAL(endOfBuffer()), this, SLOT(showResults()),Qt::DirectConnection); + connect(board, SIGNAL(statusMessage(QString)), this, SLOT(sendStatusMessage(QString))); + connect(this, SIGNAL(stopAcquistion()), board, SLOT(stopAcquistion()), Qt::DirectConnection); + // Timer for board + connect(dataTimer, SIGNAL(timeout()), this, SLOT(showResults()), Qt::DirectConnection); + + +} + +RVIBoardTools::~RVIBoardTools() +{ + delete ui; +} + + +void RVIBoardTools::setDefaultValues() +{ + // Fill trigger combo + fillTriggerCombo(); + + // Fill trigger Slope + ui->trigSlopeCombo->addItem(QIcon(":/images/rising.png"),"Rising"); + ui->trigSlopeCombo->addItem(QIcon(":/images/falling.png"),"Falling"); + + + // Set Max-Min values + ui->bufferSpinBox->setMaximum(MAX_BUFF_SIZE); + ui->bufferSpinBox->setMinimum(MIN_BUFF_SIZE); + + + + + fillSampleTimeCombo(); + + // Data + chAOffset = 0; + chBOffset = 0; + + confTScal = 1023; + confTScalEn = 1; + + paused = false; + + ui->bufferSpinBox->setValue(1000); + setVoltMultipliers(); + updateTimeVec(); + + + // Signals + emit timeChangeLimits(timeVec->first(), timeVec->last()); + emit channelAColorChanged( ui->channelAColorButton->palette().button().color()); + emit channelBColorChanged( ui->channelBColorButton->palette().button().color()); + +} + + +void RVIBoardTools::stop() +{ + if (!ui->runButton->isChecked()) + { + dataTimer->stop(); + statusChanged("stop timer"); + } + emit stopAcquistion(); + //board->terminate(); +} + +void RVIBoardTools::setPaused(const bool &on) +{ + paused = on; + setEnabled(!on); + if (on) + emit statusChanged(tr("Paused")); +} + +void RVIBoardTools::startAcquisition(const bool &continuous) +{ + bool ok; + +// if (board->isRunning()) +// { +// //while (!board->isFinished()) +// // { +// repaint(); +// stop(); +// board->quit(); +// //} +// } + + emit timeChangeLimits(timeVec->first(), timeVec->last()); + + board->setAddress(ui->addressBox->currentText().toShort(&ok, 16)); + board->setContinuous(continuous); + board->setTrigger(ui->trigBox->isChecked(), + ui->trigSlopeCombo->currentText() == "Falling", + ui->trigSouceCombo->currentText() == "A", + ui->trigLevelSpinBox->value()* 1023/100, + ui->trigOffsetSpinBox->value()); + board->setChannels(ui->channelABox->isChecked(), + ui->channelBBox->isChecked()); + board->setBuffer(ui->bufferSpinBox->value()); + board->setTimeScaler(ui->sampleTimeCombo->currentIndex() > 0, + ui->sampleTimeCombo->currentIndex() - 1); + + board->start(QThread::LowestPriority); + + if (!dataTimer->isActive()) + dataTimer->start(); + + disconnect(board, SIGNAL(finished()),this,SLOT(startAcquisition())); + +} + + +void RVIBoardTools::showResults() +{ + if (!paused) + { + if ( ui->quickUpdateCheck->isChecked() || board->isBufferFull() ) + { + if (ui->channelABox->isChecked()) + { + dataAVec->clear(); + data = board->getChannelData(0); + if (data.size() > 5) + { + for (int i = 0; i < data.size(); i++) + dataAVec->append((data.at(i) - 512)* chAVoltMultiplier + chAOffset); + emit channelAData(*timeVec, *dataAVec); + } + } + if (ui->channelBBox->isChecked()) + { + dataBVec->clear(); + data = board->getChannelData(1); + if (data.size() > 5) + { + for (int i = 0; i < data.size(); i++) + dataBVec->append((data.at(i) - 512) * chBVoltMultiplier + chBOffset); + emit channelBData(*timeVec, *dataBVec); + } + } + } + } +} + + +void RVIBoardTools::sendStatusMessage(const QString &status) +{ + emit statusChanged(status); +} + + + +void RVIBoardTools::updateTimeVec() +{ + double deltaTime; + deltaTime = pow(2.0,ui->sampleTimeCombo->currentIndex()) / board->getADCSampleRate(); + + int size; + size = ui->bufferSpinBox->value(); + if (ui->channelABox->isChecked() && ui->channelBBox->isChecked()) + size = size/2; + + timeVec->clear(); + timeVec->append(deltaTime * ui->trigOffsetSpinBox->value()); + for (int i = 1; i < size; i++) + timeVec->append(timeVec->at(i-1) + deltaTime); + //statusChanged(tr("Primero %1 y segundo %2").arg(timeVec->first()).arg(timeVec->last())); +} + +void RVIBoardTools::setVoltMultipliers() +{ + if (!(ui->channelAZBtn->isChecked())) + { + if (ui->chASpan2VRadio->isChecked()) + chAVoltMultiplier = 2.0/1024; + else + chAVoltMultiplier = 1.0/1024; + } + else + chAVoltMultiplier = 0.0; + + if (!(ui->channelBZBtn->isChecked())) + { + if (ui->chBSpan2VRadio->isChecked()) + chBVoltMultiplier = 2.0/1024; + else + chBVoltMultiplier = 1.0/1024; + } + else + chBVoltMultiplier = 0.0; +} + + +void RVIBoardTools::uncheckRunButtons() +{ + ui->runButton->setChecked(false); + ui->singleButton->setChecked(false); +} + + +QVector RVIBoardTools::getData(RVIBoardTools::VariableType var) +{ + switch(var) + { + case RVIBoardTools::ChannelA: + return *dataAVec; + break; + + case RVIBoardTools::ChannelB: + return *dataBVec; + break; + + default: + return *timeVec; + break; + } + +} + + +/////////////////////////////////////////////////////////////////////// +// Trigger + +void RVIBoardTools::on_trigLevelSlider_valueChanged(int value) +{ + double d_value; + if (ui->trigSouceCombo->currentText() == "B") + { + if (ui->chBSpan2VRadio->isChecked()) + d_value = (value - 50) * 2.0/50; + else + d_value = (value - 50) * 1.0/50; + } + else + { + if (ui->chASpan2VRadio->isChecked()) + d_value = (value - 50) * 2.0/50; + else + d_value = (value - 50) * 1.0/50; + } + emit changeTriggerValue(d_value); + +} + + +void RVIBoardTools::on_trigLineCheck_toggled(bool checked) +{ + emit showTriggerLine(checked, ui->trigSouceCombo->currentIndex()); +} + + +void RVIBoardTools::on_trigSouceCombo_currentIndexChanged(int index) +{ + emit showTriggerLine(ui->trigLineCheck->isChecked(), index); + if (board->isRunning()) + { + stop(); + connect(board, SIGNAL(finished()),this,SLOT(startAcquisition())); + } + +} + +void RVIBoardTools::fillTriggerCombo() +{ + ui->trigSouceCombo->clear(); + if (ui->channelABox->isChecked() == true) + { + ui->trigSouceCombo->addItem("A"); + } + if (ui->channelBBox->isChecked() == true) + { + ui->trigSouceCombo->addItem("B"); + } +} + + +//////////////////////////// +// Channel A +void RVIBoardTools::on_channelABox_toggled(bool set) +{ + emit channelAEnabled(set); +} + + +void RVIBoardTools::on_channelAColorButton_clicked() +{ + QColorDialog *colorChooser = new QColorDialog(); + QColor color = colorChooser->getColor(ui->channelAColorButton->palette().button().color()); + ui->channelAColorButton->setPalette(color); + emit channelAColorChanged( color); +} + + +void RVIBoardTools::setChannelADiv(double div) +{ + Suffixer mod(div); + ui->channelAZoomSpinBox->setValue(div * mod.multiplier); + ui->channelAZoomSpinBox->setSuffix(" " + mod.suffix + tr("V/Div")); +} + + +void RVIBoardTools::on_channelAZoomSlider_valueChanged(int value) +{ + if (value != 0 ) + { + ui->channelAAutoButton->setChecked(false); + emit channelAChangeDiv(value); + + if (!slidersTimer->isActive()) + { + ui->channelAZoomSlider->setValue(0); + } + } +} + + +void RVIBoardTools::on_channelAZoomSlider_sliderReleased() +{ + ui->channelAZoomSlider->setValue(0); +} + + +void RVIBoardTools::on_channelAAutoButton_toggled(bool checked) +{ + if (checked) + { + emit channelAChangeDiv(0); + } + else + { + emit channelAChangeDiv(-1); + } +} + + +void RVIBoardTools::on_channelAPosSlider_valueChanged(int value) +{ + if (value != 0 ) + { + emit channelAMove(value); + + if (!slidersTimer->isActive()) + { + ui->channelAPosSlider->setValue(0); + } + } +} + +void RVIBoardTools::on_channelAPosSlider_sliderReleased() +{ + ui->channelAPosSlider->setValue(0); +} + + +void RVIBoardTools::on_channelAResetButton_pressed() +{ + emit channelAResetPos(); +} + + +//////////////////////////// +// Channel B +void RVIBoardTools::on_channelBBox_toggled(bool set) +{ + emit channelBEnabled(set); +} + + +void RVIBoardTools::on_channelBColorButton_clicked() +{ + QColorDialog *colorChooser = new QColorDialog(); + QColor color = colorChooser->getColor(ui->channelBColorButton->palette().button().color()); + ui->channelBColorButton->setPalette(color); + emit channelBColorChanged( color); +} + + +void RVIBoardTools::setChannelBDiv(double div) +{ + Suffixer mod(div); + ui->channelBZoomSpinBox->setValue(div * mod.multiplier); + ui->channelBZoomSpinBox->setSuffix(" " + mod.suffix + tr("V/Div")); +} + + +void RVIBoardTools::on_channelBZoomSlider_valueChanged(int value) +{ + if (value != 0 ) + { + ui->channelBAutoButton->setChecked(false); + emit channelBChangeDiv(value); + + if (!slidersTimer->isActive()) + { + ui->channelBZoomSlider->setValue(0); + } + } +} + + +void RVIBoardTools::on_channelBZoomSlider_sliderReleased() +{ + ui->channelBPosSlider->setValue(0); +} + + +void RVIBoardTools::on_channelBAutoButton_toggled(bool checked) +{ + if (checked) + { + emit channelBChangeDiv(0); + } + else + { + emit channelBChangeDiv(-1); + } +} + + +void RVIBoardTools::on_channelBPosSlider_valueChanged(int value) +{ + if (value != 0 ) + { + emit channelBMove(value); + + if (!slidersTimer->isActive()) + { + ui->channelBPosSlider->setValue(0); + } + } +} + +void RVIBoardTools::on_channelBPosSlider_sliderReleased() +{ + ui->channelBPosSlider->setValue(0); +} + + +void RVIBoardTools::on_channelBResetButton_pressed() +{ + emit channelBResetPos(); +} + + + +//////////////////////////// +// Time + +void RVIBoardTools::on_timeZoomSlider_valueChanged(int value) +{ + if (value != 0 ) + { + ui->timeAutoButton->setChecked(false); + emit timeChangeDiv(value); + + if (!slidersTimer->isActive()) + { + ui->timeZoomSlider->setValue(0); + } + } +} + + +void RVIBoardTools::on_timeAutoButton_toggled(bool checked) +{ + if (checked) + { + emit channelAChangeDiv(0); + } + else + { + emit channelAChangeDiv(-1); + } +} + + +void RVIBoardTools::setTimeDiv(double div) +{ + Suffixer mod(div); + ui->timeZoomSpinBox->setValue(div * mod.multiplier); + ui->timeZoomSpinBox->setSuffix(" " + mod.suffix + tr("s/Div")); +} + + +void RVIBoardTools::on_bufferSpinBox_valueChanged(int value) +{ + ui->trigOffsetSlider->setMaximum(value - 1); + ui->trigOffsetSpinBox->setMaximum(value - 1); + ui->trigOffsetSlider->setMinimum(-value); + ui->trigOffsetSpinBox->setMinimum(-value); + ui->trigOffsetSpinBox->setValue(0); + + if (board->isRunning()) + { + stop(); + connect(board, SIGNAL(finished()),this,SLOT(startAcquisition())); + } + +} + + +void RVIBoardTools::on_timeZoomSlider_sliderReleased() +{ + ui->timeZoomSlider->setValue(0); +} + + +void RVIBoardTools::on_timePosSlider_sliderReleased() +{ + ui->timePosSlider->setValue(0); +} + + +void RVIBoardTools::on_timePosSlider_valueChanged(int value) +{ + if (value != 0 ) + { + emit timeMove(value); + + if (!slidersTimer->isActive()) + { + ui->timePosSlider->setValue(0); + } + } +} + +void RVIBoardTools::fillSampleTimeCombo() +{ + double value; + double freq = board->getADCSampleRate(); + for (int i = 0; i <= pow(2.0,SCALE_BITS); i++) + { + value = pow(2.0,i)/freq; + if( value < 1e-3 ) + ui->sampleTimeCombo->addItem(QString("%L1 ns").arg(value*1e6)); + else if(value < 1) + ui->sampleTimeCombo->addItem(QString("%L1 ms").arg(value*1e3)); + else + ui->sampleTimeCombo->addItem(QString("%L1 s").arg(value)); + } +} +//////////////////////////// +// Common + +void RVIBoardTools::updateSlidersValues() +{ + on_channelAZoomSlider_valueChanged(ui->channelAZoomSlider->value()); + on_channelAPosSlider_valueChanged(ui->channelAPosSlider->value()); + on_channelBZoomSlider_valueChanged(ui->channelAZoomSlider->value()); + on_channelBPosSlider_valueChanged(ui->channelAPosSlider->value()); + on_timeZoomSlider_valueChanged(ui->timeZoomSlider->value()); + on_timePosSlider_valueChanged(ui->timePosSlider->value()); +} + + + +void RVIBoardTools::on_runButton_toggled(bool checked) +{ + if (checked == true) + { + ui->runButton->setText(tr("Stop")); + ui->singleButton->setEnabled(false); + startAcquisition(true); // start continuous + } + else + { + ui->runButton->setText(tr("Start")); + ui->singleButton->setEnabled(true); + stop(); + } +} + + +void RVIBoardTools::on_singleButton_toggled(bool checked) +{ + if (checked == true) + { + ui->singleButton->setText(tr("Stop")); + ui->runButton->setEnabled(false); + startAcquisition(false); // start single + } + else + { + ui->singleButton->setText(tr("Single")); + ui->runButton->setEnabled(true); + stop(); + } +} + + + + +void RVIBoardTools::on_adcSampleButton_clicked() +{ + bool ok; + QStringList items; + int index; + + for (int i = 1; i <= pow(2.0, ADC_PS_BITS); i++) + { + items << tr("%1 Hz").arg(BASE_SAMPLE_RATE/i); + } + + QString text = QInputDialog::getItem(this, tr("Set ADC sample rate"), + tr("Sample rate:"), items, 0, false, &ok); + + index = items.indexOf(text); + board->setAddress(ui->addressBox->currentText().toShort(&ok, 16)); + board->setADCPreScale(index); + board->configADC(); + fillSampleTimeCombo(); + +} + + + +void RVIBoardTools::on_trigSlopeCombo_currentIndexChanged(int index) +{ + if (board->isRunning()) + { + stop(); + connect(board, SIGNAL(finished()),this,SLOT(startAcquisition())); + } +} + +void RVIBoardTools::on_trigOffsetSpinBox_valueChanged(int ) +{ + if (board->isRunning()) + { + stop(); + connect(board, SIGNAL(finished()),this,SLOT(startAcquisition())); + } +} + +void RVIBoardTools::on_trigLevelSpinBox_valueChanged(int ) +{ + if (board->isRunning()) + { + stop(); + connect(board, SIGNAL(finished()),this,SLOT(startAcquisition())); + } +} + +void RVIBoardTools::on_sampleTimeCombo_currentIndexChanged(int index) +{ + if (board->isRunning()) + { + stop(); + connect(board, SIGNAL(finished()),this,SLOT(startAcquisition())); + } +} + +void RVIBoardTools::on_trigBox_toggled(bool ) +{ + +}
sw/src/rviboardtools.cpp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rviboardtools.qrc =================================================================== --- sw/src/rviboardtools.qrc (nonexistent) +++ sw/src/rviboardtools.qrc (revision 60) @@ -0,0 +1,15 @@ + + + images/rising.png + images/falling.png + images/in_couplig_mode_jumpers + images/media-playback-pause.png + images/zoom-in.png + images/document-save.png + images/document-save-image.PNG + images/fill-color.png + images/grid_left.png + images/grid_right.png + images/grid_time.png + +
sw/src/rviboardtools.qrc Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: sw/src/rvioscilloscope.pro =================================================================== --- sw/src/rvioscilloscope.pro (nonexistent) +++ sw/src/rvioscilloscope.pro (revision 60) @@ -0,0 +1,54 @@ +# ------------------------------------------------- +# Project created by QtCreator 2009-06-09T13:45:02 +# ------------------------------------------------- +QT += svg +TARGET = rvioscilloscope +TEMPLATE = app +SOURCES += main.cpp \ + rvioscilloscope.cpp \ + data_plot.cpp \ + rviboardtools.cpp \ + rvicommthread.cpp +HEADERS += data_plot.h \ + rvioscilloscope.h \ + rviboardtools.h \ + rvicommthread.h +FORMS += rvioscilloscope.ui \ + rviboardtools.ui +TRANSLATIONS = superapp_es.ts +win32 { + SOURCES += include/epp_parallel_use_win.cpp \ + include/epp_parallel_access_win.cpp + HEADERS += include/epp_parallel_use_win.h \ + include/epp_parallel_access_win.h +} +RESOURCES += rviboardtools.qrc + +# ------------------------------------------------- +# definitions +VER_MAJ = 5 +win32:QWT_ROOT = "C:\Qwt-5.3.0-svn" +win32:DEBUG_SUFFIX = d +RELEASE_SUFFIX = +DEPENDPATH += C:\Qwt-5.3.0-svn\include +INCLUDEPATH += C:\Qwt-5.3.0-svn\include + +# VVERSION = $$[QT_VERSION] +CONFIG(debug, debug|release):SUFFIX_STR = $${DEBUG_SUFFIX} +else:SUFFIX_STR = $${RELEASE_SUFFIX} +QWTLIB = qwt$${SUFFIX_STR} +unix { + # Qt 4 + DEPENDPATH += /usr/include/qwt-qt4 + INCLUDEPATH += /usr/include/qwt-qt4 + LIBS += -L$${QWT_ROOT}/lib \ + -l$${QWTLIB}-qt4 +} +win32 { + DEFINES += QWT_DLL \ + QT_DLL + QWTLIB = $${QWTLIB}$${VER_MAJ} + LIBS += -L$${QWT_ROOT}/lib \ + -l$${QWTLIB} +} +OTHER_FILES +=
sw/src/rvioscilloscope.pro Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.