rt mode v1
This commit is contained in:
34
.gitignore
vendored
Normal file
34
.gitignore
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
*.a
|
||||||
|
*.o
|
||||||
|
*.md
|
||||||
|
*.exe
|
||||||
|
*.user
|
||||||
|
*.Debug
|
||||||
|
*.Release
|
||||||
|
*.stash
|
||||||
|
MakeFile
|
||||||
|
*.bin
|
||||||
|
*.m
|
||||||
|
*.txt
|
||||||
|
*.mpd
|
||||||
|
*.sens
|
||||||
|
*.kna
|
||||||
|
*.djvu
|
||||||
|
resource/
|
||||||
|
*.qrc
|
||||||
|
resource.h
|
||||||
|
*.png
|
||||||
|
*.jpeg
|
||||||
|
*.mp3
|
||||||
|
*.wav
|
||||||
|
*.db
|
||||||
|
data/
|
||||||
|
debug/
|
||||||
|
platforms/
|
||||||
|
release/
|
||||||
|
compiler/
|
||||||
|
src_build/
|
||||||
|
html/
|
||||||
|
log/
|
||||||
|
doc/
|
||||||
|
QtXml/
|
20
TestTa1.pro
Normal file
20
TestTa1.pro
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
QT += testlib
|
||||||
|
QT += core gui
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
WDMTMKv2.cpp \
|
||||||
|
bcmil.cpp \
|
||||||
|
cmdwrd.cpp \
|
||||||
|
main.cpp \
|
||||||
|
mainwindow.cpp \
|
||||||
|
testinfo.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
WDMTMKv2.h \
|
||||||
|
bcmil.h \
|
||||||
|
cmdwrd.h \
|
||||||
|
declarations.h \
|
||||||
|
mainwindow.h \
|
||||||
|
testinfo.h
|
BIN
USB_TA_DRV.dll
Normal file
BIN
USB_TA_DRV.dll
Normal file
Binary file not shown.
BIN
USB_TA_VC2.dll
Normal file
BIN
USB_TA_VC2.dll
Normal file
Binary file not shown.
2105
WDMTMKv2.cpp
Normal file
2105
WDMTMKv2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1020
WDMTMKv2.h
Normal file
1020
WDMTMKv2.h
Normal file
File diff suppressed because it is too large
Load Diff
195
bcmil.cpp
Normal file
195
bcmil.cpp
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
#include <QDebug>
|
||||||
|
#include "bcmil.h"
|
||||||
|
#include "WDMTMKv2.cpp"
|
||||||
|
//#include <windows.h>
|
||||||
|
|
||||||
|
//TTmkEventData tmkEvD;
|
||||||
|
HANDLE hBcEvent;
|
||||||
|
//HANDLE hRtEvent;
|
||||||
|
|
||||||
|
int nTmk;
|
||||||
|
unsigned long dwGoodStarts = 0, dwBusyStarts = 0, dwErrStarts = 0, dwStatStarts = 0;
|
||||||
|
unsigned long dwStarts = 0L;
|
||||||
|
TMK_DATA wSubAddr, wState, wStatus;
|
||||||
|
|
||||||
|
MIL::MIL(int dev_index) //open the driver, configuration, create event
|
||||||
|
{
|
||||||
|
qDebug() << "MIL constructor";
|
||||||
|
if (TmkOpen())
|
||||||
|
{
|
||||||
|
qDebug() << "TmkOpen() error";
|
||||||
|
closeAllrt();
|
||||||
|
//closeAll();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((dev_index > tmkgetmaxn()) || (dev_index < 0))
|
||||||
|
{
|
||||||
|
closeAllrt();
|
||||||
|
//closeAll();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->m_TmkIndex = dev_index;
|
||||||
|
|
||||||
|
if (tmkconfig(this->m_TmkIndex))
|
||||||
|
{
|
||||||
|
closeAllrt();
|
||||||
|
//closeAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int MIL::WaitInt(TMK_DATA wCtrlCode)
|
||||||
|
{
|
||||||
|
//Wait for an interrupt
|
||||||
|
DWORD k;
|
||||||
|
k = WaitForSingleObject(hBcEvent, 1000);
|
||||||
|
switch (k)
|
||||||
|
{
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
ResetEvent(hBcEvent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT_TIMEOUT:
|
||||||
|
qDebug() << "Interrupt timeout error\n";
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
qDebug() << "k = " << k;
|
||||||
|
qDebug() << "Interrupt wait error\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get interrupt data
|
||||||
|
// We do not need to check tmkEvD.nInt because bcstartx with CX_NOSIG
|
||||||
|
// guarantees us only single interrupt of single type nInt == 3
|
||||||
|
tmkgetevd(&tmkEvD);
|
||||||
|
|
||||||
|
if (tmkEvD.bcx.wResultX & SX_IB_MASK)
|
||||||
|
{
|
||||||
|
// We have set bit(s) in Status Word
|
||||||
|
if (((tmkEvD.bcx.wResultX & SX_ERR_MASK) == SX_NOERR) || ((tmkEvD.bcx.wResultX & SX_ERR_MASK) == SX_TOD))
|
||||||
|
{
|
||||||
|
wStatus = bcgetansw(wCtrlCode); // We have either no errors or Data Time Out (No Data) error
|
||||||
|
if (wStatus & BUSY_MASK) // We have BUSY bit set
|
||||||
|
++dwBusyStarts;
|
||||||
|
else // We have unknown bit(s) set
|
||||||
|
++dwStatStarts;
|
||||||
|
}
|
||||||
|
else // We have an error
|
||||||
|
++dwErrStarts;
|
||||||
|
}
|
||||||
|
else if (tmkEvD.bcx.wResultX & SX_ERR_MASK) // We have an error
|
||||||
|
++dwErrStarts;
|
||||||
|
else // We have a completed message
|
||||||
|
++dwGoodStarts;
|
||||||
|
|
||||||
|
++dwStarts;
|
||||||
|
return 0;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*void MIL::closeAll()
|
||||||
|
{
|
||||||
|
qDebug() << "Close All";
|
||||||
|
//printf("\nGood: %ld, Busy: %ld, Error: %ld, Status: %ld\n", dwGoodStarts, dwBusyStarts, dwErrStarts, dwStatStarts);
|
||||||
|
bcreset();
|
||||||
|
//Close all opened things
|
||||||
|
CloseHandle(hBcEvent);
|
||||||
|
tmkdone(ALL_TMKS);
|
||||||
|
TmkClose();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void MIL::closeAllrt()
|
||||||
|
{
|
||||||
|
qDebug() << "Close All";
|
||||||
|
//printf("\nGood: %ld, Busy: %ld, Error: %ld, Status: %ld\n", dwGoodStarts, dwBusyStarts, dwErrStarts, dwStatStarts);
|
||||||
|
rtreset();
|
||||||
|
//Close all opened things
|
||||||
|
CloseHandle(hBcEvent);
|
||||||
|
tmkdone(ALL_TMKS);
|
||||||
|
TmkClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
MIL::~MIL()
|
||||||
|
{
|
||||||
|
qDebug() << "MIL destructor";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*BC_MIL::BC_MIL(int dev_index): MIL(dev_index)
|
||||||
|
{
|
||||||
|
qDebug() << "BC_MIL constructor";
|
||||||
|
//Find first configured device
|
||||||
|
for (nTmk = 0; nTmk <= MAX_TMK_NUMBER; ++nTmk)
|
||||||
|
if (!tmkselect(nTmk))
|
||||||
|
break;
|
||||||
|
if (nTmk > MAX_TMK_NUMBER)
|
||||||
|
{
|
||||||
|
qDebug() << "tmkselect error";
|
||||||
|
closeAll();
|
||||||
|
}
|
||||||
|
//Try to reset in BC mode
|
||||||
|
if (bcreset())
|
||||||
|
{
|
||||||
|
qDebug() << "bcreset error";
|
||||||
|
closeAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BC_MIL::~BC_MIL()
|
||||||
|
{
|
||||||
|
qDebug() << "BC_MIL destructor";
|
||||||
|
}*/
|
||||||
|
|
||||||
|
RT_MIL::RT_MIL(int dev_index, unsigned short Addr): MIL(dev_index)
|
||||||
|
{
|
||||||
|
qDebug() << "RT_MIL constructor";
|
||||||
|
this->m_Addr = Addr;
|
||||||
|
|
||||||
|
//Find first configured device
|
||||||
|
for (nTmk = 0; nTmk <= MAX_TMK_NUMBER; ++nTmk)
|
||||||
|
if (!tmkselect(nTmk))
|
||||||
|
break;
|
||||||
|
if (nTmk > MAX_TMK_NUMBER)
|
||||||
|
{
|
||||||
|
qDebug() << "tmkselect error";
|
||||||
|
closeAllrt();
|
||||||
|
}
|
||||||
|
//Try to reset in RT mode
|
||||||
|
if (rtreset())
|
||||||
|
{
|
||||||
|
qDebug() << "rtreset error";
|
||||||
|
closeAllrt();
|
||||||
|
}
|
||||||
|
//Set RT address, set flag mode, enable data irqs
|
||||||
|
rtdefaddress(Addr);
|
||||||
|
rtdefmode(rtgetmode()|RT_FLAG_MODE);
|
||||||
|
//rtdefmode(rtgetmode()&~RT_FLAG_MODE);
|
||||||
|
rtdefirqmode(rtgetirqmode()&~RT_DATA_BL);
|
||||||
|
|
||||||
|
for (wSubAddr = 1; wSubAddr <= 30; ++wSubAddr)
|
||||||
|
{
|
||||||
|
//Ready to receive, not ready to transmit
|
||||||
|
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||||
|
rtclrflag();
|
||||||
|
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||||
|
rtclrflag();
|
||||||
|
}
|
||||||
|
|
||||||
|
hBcEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (!hBcEvent)
|
||||||
|
{
|
||||||
|
qDebug() << "create event error";
|
||||||
|
closeAllrt();
|
||||||
|
}
|
||||||
|
ResetEvent(hBcEvent);
|
||||||
|
tmkdefevent(hBcEvent, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
RT_MIL::~RT_MIL()
|
||||||
|
{
|
||||||
|
qDebug() << "RT_MIL destructor";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
98
bcmil.h
Normal file
98
bcmil.h
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
#ifndef BCMIL_H
|
||||||
|
#define BCMIL_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
//*******************
|
||||||
|
//#include "WDMTMKv2.h"
|
||||||
|
//#include "windows.h"
|
||||||
|
//*******************
|
||||||
|
/*typedef struct
|
||||||
|
{
|
||||||
|
int nInt;
|
||||||
|
unsigned short wMode;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned short wResult;
|
||||||
|
unsigned short wAW1;
|
||||||
|
unsigned short wAW2;
|
||||||
|
} bc;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned short wBase;
|
||||||
|
unsigned short wResultX;
|
||||||
|
} bcx;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned short wStatus;
|
||||||
|
unsigned short wCmd;
|
||||||
|
} rt;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned short wBase;
|
||||||
|
unsigned short wResultX;
|
||||||
|
} mt;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned short wStatus;
|
||||||
|
} mrt;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned short wRequest;
|
||||||
|
// DWORD dwTimer;
|
||||||
|
} tmk;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned short wData1;
|
||||||
|
unsigned short wData2;
|
||||||
|
} raw;
|
||||||
|
};
|
||||||
|
} TTmkEventData1;*/
|
||||||
|
|
||||||
|
#define TMK_DATA unsigned short
|
||||||
|
typedef void *HANDLE;
|
||||||
|
|
||||||
|
//class BC_MIL;
|
||||||
|
//class RT_MIL;
|
||||||
|
class MIL:public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
MIL(int dev_index);
|
||||||
|
~MIL();
|
||||||
|
|
||||||
|
//int WaitInt(TMK_DATA wCtrlCode);
|
||||||
|
//void closeAll();
|
||||||
|
void closeAllrt();
|
||||||
|
//bool GetEvent(TTmkEventData1 *pEv, unsigned short Timeout);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
int m_TmkIndex;
|
||||||
|
//HANDLE m_hEvent;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*class BC_MIL:public MIL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
BC_MIL(int dev_index);
|
||||||
|
~BC_MIL(void);
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
class RT_MIL:public MIL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
RT_MIL(int dev_indexi, unsigned short Addr);
|
||||||
|
~RT_MIL();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
unsigned short m_Addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BCMIL_H
|
87
cmdwrd.cpp
Normal file
87
cmdwrd.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
#include "cmdwrd.h"
|
||||||
|
|
||||||
|
extern unsigned char HexBinFlag;
|
||||||
|
|
||||||
|
CommandWord::CommandWord()
|
||||||
|
{
|
||||||
|
addrRTf = 0;
|
||||||
|
Kf = 0;
|
||||||
|
subAddrf = 0;
|
||||||
|
numDWf = 0;
|
||||||
|
|
||||||
|
cmdCode.insert(dynBC, "Принять упр-е интерфейсом");
|
||||||
|
cmdCode.insert(sync1, "Синхронизация");
|
||||||
|
cmdCode.insert(transSW, "Передать ОС");
|
||||||
|
cmdCode.insert(initST, "Начать самоконтроль ОУ");
|
||||||
|
cmdCode.insert(transS, "Блокировать передатчик");
|
||||||
|
cmdCode.insert(overrTS, "Разблокировать передатчик");
|
||||||
|
cmdCode.insert(inhTFB, "Блок-ть признак неиспр-ти ОУ");
|
||||||
|
cmdCode.insert(overrITF, "Разблок-ть признак неиспр-ти ОУ");
|
||||||
|
cmdCode.insert(resetRT, "Уст-ть ОУ в исх-е состояние");
|
||||||
|
cmdCode.insert(transVW, "Передать вект-ое слово");
|
||||||
|
cmdCode.insert(sync2, "Синхронизация (с СД)");
|
||||||
|
cmdCode.insert(transLC, "Передать послед-ю команду");
|
||||||
|
cmdCode.insert(transBW, "Передать слово ВСК ОУ");
|
||||||
|
cmdCode.insert(selectedSW, "Блок-ть i-й передатчик");
|
||||||
|
cmdCode.insert(overrSTS, "Разблок-ть i-й передатчик");
|
||||||
|
|
||||||
|
for(uint8_t i = 0b01001; i < 0b10000; i++)
|
||||||
|
cmdCode.insert(i, "Резерв");
|
||||||
|
|
||||||
|
for(uint8_t i = 0b10110; i < 0b11111; i++)
|
||||||
|
cmdCode.insert(i, "Резерв");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CommandWord::addrRTFind(uint16_t cmdw)
|
||||||
|
{
|
||||||
|
CW.all = cmdw;
|
||||||
|
return CW.addrRT;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CommandWord::KFind(uint16_t cmdw)
|
||||||
|
{
|
||||||
|
CW.all = cmdw;
|
||||||
|
return CW.K;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CommandWord::subAddrFind(uint16_t cmdw)
|
||||||
|
{
|
||||||
|
CW.all = cmdw;
|
||||||
|
return CW.subAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CommandWord::numDWFind(uint16_t cmdw)
|
||||||
|
{
|
||||||
|
CW.all = cmdw;
|
||||||
|
return CW.numDW;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandWord::description(QString CmdW)
|
||||||
|
{
|
||||||
|
uint16_t cmdw;
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
if(HexBinFlag)
|
||||||
|
cmdw = CmdW.toInt(&result, 16);
|
||||||
|
else
|
||||||
|
cmdw = CmdW.toInt(&result, 2);
|
||||||
|
|
||||||
|
if(result == false)
|
||||||
|
QMessageBox::warning(0, "Ошибка", "Недопустимое значение КС");
|
||||||
|
else if((HexBinFlag == 0) && (CmdW.length() != 16))
|
||||||
|
QMessageBox::warning(0, "Ошибка", "Недопустимое значение КС");
|
||||||
|
else if((HexBinFlag == 1) && (CmdW.length() != 4))
|
||||||
|
QMessageBox::warning(0, "Ошибка", "Недопустимое значение КС");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addrRTf = addrRTFind(cmdw);
|
||||||
|
Kf = KFind(cmdw);
|
||||||
|
subAddrf = subAddrFind(cmdw);
|
||||||
|
numDWf = numDWFind(cmdw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandWord::~CommandWord()
|
||||||
|
{
|
||||||
|
}
|
45
cmdwrd.h
Normal file
45
cmdwrd.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef CMDWRD_H
|
||||||
|
#define CMDWRD_H
|
||||||
|
|
||||||
|
#include "declarations.h"
|
||||||
|
|
||||||
|
class CommandWord:public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
uint16_t all;
|
||||||
|
struct {
|
||||||
|
unsigned numDW: 5; // DW - data word
|
||||||
|
unsigned subAddr: 5;
|
||||||
|
unsigned K: 1; // translate/receive flag
|
||||||
|
unsigned addrRT: 5; // RT - remote terminal
|
||||||
|
};
|
||||||
|
} CW_t;
|
||||||
|
|
||||||
|
CW_t CW;
|
||||||
|
|
||||||
|
uint8_t addrRTf;
|
||||||
|
uint8_t Kf;
|
||||||
|
uint8_t subAddrf;
|
||||||
|
uint8_t numDWf;
|
||||||
|
|
||||||
|
QHash<uint8_t, QString> cmdCode;
|
||||||
|
|
||||||
|
//01001 - 01111 reserved, 10110 - 11111 reserved
|
||||||
|
enum codeName {dynBC, sync1, transSW, initST, transS,
|
||||||
|
overrTS, inhTFB, overrITF, resetRT, transVW = 0b10000,
|
||||||
|
sync2, transLC, transBW, selectedSW, overrSTS};
|
||||||
|
|
||||||
|
void description(QString CmdW);
|
||||||
|
uint8_t addrRTFind(uint16_t cmdw);
|
||||||
|
uint8_t KFind(uint16_t cmdw);
|
||||||
|
uint8_t subAddrFind(uint16_t cmdw);
|
||||||
|
uint8_t numDWFind(uint16_t cmdw);
|
||||||
|
|
||||||
|
CommandWord();
|
||||||
|
~CommandWord();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CMDWRD_H
|
22
declarations.h
Normal file
22
declarations.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef DECLARATIONS_H
|
||||||
|
#define DECLARATIONS_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QTableWidgetItem>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QString>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include <QTest>
|
||||||
|
|
||||||
|
#endif // DECLARATIONS_H
|
14
main.cpp
Normal file
14
main.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
//#include "testinfo.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
MainWindow w;
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
//QTest::qExec(new testInfo, argc, argv);
|
||||||
|
return a.exec();
|
||||||
|
}
|
325
mainwindow.cpp
Normal file
325
mainwindow.cpp
Normal file
@@ -0,0 +1,325 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
//#include "windows.h"
|
||||||
|
//#include "WDMTMKv2.cpp"
|
||||||
|
#include "bcmil.cpp"
|
||||||
|
|
||||||
|
TTmkEventData tmkEvD;
|
||||||
|
extern HANDLE hBcEvent;
|
||||||
|
|
||||||
|
//#define RT_ADDR 10
|
||||||
|
|
||||||
|
//const int fInstMode = 1;
|
||||||
|
|
||||||
|
unsigned short awBuf[32];
|
||||||
|
|
||||||
|
TMK_DATA wBase, wMaxBase, wLen;
|
||||||
|
extern TMK_DATA wSubAddr, wState;
|
||||||
|
|
||||||
|
unsigned char HexBinFlag = 1; //1 - hex, 0 - bin
|
||||||
|
|
||||||
|
MainWindow::MainWindow()
|
||||||
|
{
|
||||||
|
init_mainwindowobj();
|
||||||
|
init_table();
|
||||||
|
init_connections();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::init_mainwindowobj()
|
||||||
|
{
|
||||||
|
qDebug() << "Startyem";
|
||||||
|
|
||||||
|
Window_1 = new QWidget;
|
||||||
|
Window_2 = new QWidget;
|
||||||
|
|
||||||
|
HexBinButton = new QPushButton("Hex/Bin");
|
||||||
|
HexBinLabel = new QLabel("Hex");
|
||||||
|
|
||||||
|
CmdWordLabel = new QLabel("Enter the command word:");
|
||||||
|
CmdWordLineEdit = new QLineEdit;
|
||||||
|
EnterCmdWordButton = new QPushButton("Start");
|
||||||
|
DataTable = new QTableWidget;
|
||||||
|
|
||||||
|
QGridLayout *layout_g = new QGridLayout(Window_2);
|
||||||
|
layout_g->addWidget(HexBinButton, 0, 1);
|
||||||
|
layout_g->addWidget(HexBinLabel, 0, 0);
|
||||||
|
layout_g->addWidget(CmdWordLabel, 1, 0); // Row 0, Column 0
|
||||||
|
layout_g->addWidget(CmdWordLineEdit, 2, 0);
|
||||||
|
layout_g->addWidget(EnterCmdWordButton, 3, 0);
|
||||||
|
|
||||||
|
Window_2->setLayout(layout_g);
|
||||||
|
setCentralWidget(Window_2);
|
||||||
|
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(Window_1);
|
||||||
|
layout->addWidget(Window_2);
|
||||||
|
layout->addWidget(DataTable);
|
||||||
|
|
||||||
|
Window_1->setLayout(layout);
|
||||||
|
setCentralWidget(Window_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::init_connections()
|
||||||
|
{
|
||||||
|
/*connect(EnterCmdWordButton,
|
||||||
|
SIGNAL(clicked()),
|
||||||
|
this,
|
||||||
|
SLOT(getlineedit()));*/
|
||||||
|
/*connect(EnterCmdWordButton,
|
||||||
|
SIGNAL(clicked()),
|
||||||
|
this,
|
||||||
|
SLOT(sendcmdwrd()));*/
|
||||||
|
connect(EnterCmdWordButton,
|
||||||
|
SIGNAL(clicked()),
|
||||||
|
this,
|
||||||
|
SLOT(rthandler()));
|
||||||
|
connect(HexBinButton,
|
||||||
|
SIGNAL(clicked()),
|
||||||
|
this,
|
||||||
|
SLOT(HexBinChange()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString intToBinaryString(int number)
|
||||||
|
{
|
||||||
|
return QString::number(number,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString intToDecString(int number)
|
||||||
|
{
|
||||||
|
return QString::number(number,10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void MainWindow::getlineedit()
|
||||||
|
{
|
||||||
|
qDebug() << "Entered the button command word";
|
||||||
|
QString CmdW = CmdWordLineEdit->text();
|
||||||
|
qDebug() << CmdW;
|
||||||
|
|
||||||
|
QScopedPointer<CommandWord> NewCmdWord(new CommandWord());
|
||||||
|
NewCmdWord->description(CmdW);
|
||||||
|
|
||||||
|
set_item(DataTable, 0, 0, "Адрес устройства", false);
|
||||||
|
set_item(DataTable, 0, 1, intToBinaryString(NewCmdWord->addrRTf), false);
|
||||||
|
set_item(DataTable, 0, 2, intToDecString(NewCmdWord->addrRTf), false);
|
||||||
|
|
||||||
|
if(NewCmdWord->Kf)
|
||||||
|
{
|
||||||
|
set_item(DataTable, 1, 0, "Передача", false);
|
||||||
|
set_item(DataTable, 1, 1, intToBinaryString(NewCmdWord->Kf), false);
|
||||||
|
set_item(DataTable, 1, 2, intToDecString(NewCmdWord->Kf), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_item(DataTable, 1, 0, "Прием", false);
|
||||||
|
set_item(DataTable, 1, 1, intToBinaryString(NewCmdWord->Kf), false);
|
||||||
|
set_item(DataTable, 1, 2, intToDecString(NewCmdWord->Kf), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((NewCmdWord->subAddrf == 0) || (NewCmdWord->subAddrf == 31))
|
||||||
|
{
|
||||||
|
set_item(DataTable, 2, 0, "Режим управления", false);
|
||||||
|
set_item(DataTable, 2, 1, intToBinaryString(NewCmdWord->subAddrf), false);
|
||||||
|
set_item(DataTable, 2, 2, intToDecString(NewCmdWord->subAddrf), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_item(DataTable, 2, 0, "Подадрес", false);
|
||||||
|
set_item(DataTable, 2, 1, intToBinaryString(NewCmdWord->subAddrf), false);
|
||||||
|
set_item(DataTable, 2, 2, intToDecString(NewCmdWord->subAddrf), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((NewCmdWord->subAddrf == 0) || (NewCmdWord->subAddrf == 31))
|
||||||
|
{
|
||||||
|
set_item(DataTable, 3, 0, NewCmdWord->cmdCode.value(NewCmdWord->numDWf), false);
|
||||||
|
set_item(DataTable, 3, 1, intToBinaryString(NewCmdWord->numDWf), false);
|
||||||
|
set_item(DataTable, 3, 2, intToDecString(NewCmdWord->numDWf), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(NewCmdWord->numDWf == 0)
|
||||||
|
{
|
||||||
|
set_item(DataTable, 3, 0, "Число СД", false);
|
||||||
|
set_item(DataTable, 3, 1, intToBinaryString(32), false);
|
||||||
|
set_item(DataTable, 3, 2, intToDecString(32), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_item(DataTable, 3, 0, "Число СД", false);
|
||||||
|
set_item(DataTable, 3, 1, intToBinaryString(NewCmdWord->numDWf), false);
|
||||||
|
set_item(DataTable, 3, 2, intToDecString(NewCmdWord->numDWf), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void MainWindow::HexBinChange()
|
||||||
|
{
|
||||||
|
switch(HexBinFlag)
|
||||||
|
{
|
||||||
|
case 0: //было bin
|
||||||
|
HexBinLabel->setText("Hex");
|
||||||
|
HexBinFlag = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: //было hex
|
||||||
|
HexBinLabel->setText("Bin");
|
||||||
|
HexBinFlag = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::init_table()
|
||||||
|
{
|
||||||
|
int ColCount = 3;
|
||||||
|
int RowCount = 4;
|
||||||
|
QStringList header;
|
||||||
|
header << "Биты КС" << "Бинарное представление" << "Десятичное представление";
|
||||||
|
|
||||||
|
DataTable->setColumnCount(ColCount);
|
||||||
|
DataTable->setRowCount(RowCount);
|
||||||
|
DataTable->setHorizontalHeaderLabels(header);
|
||||||
|
DataTable->verticalHeader()->setVisible(true);
|
||||||
|
|
||||||
|
DataTable->setColumnWidth(0,200);
|
||||||
|
DataTable->setColumnWidth(1,160);
|
||||||
|
DataTable->setColumnWidth(2,160);
|
||||||
|
|
||||||
|
for(int i = 0; i < RowCount; i++)
|
||||||
|
{
|
||||||
|
DataTable->setRowHeight(i,20);
|
||||||
|
for(int j = 0; j < ColCount; j++)
|
||||||
|
set_item(DataTable, i, j, "%", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::set_item(QTableWidget *pTable, int indRow,
|
||||||
|
int indCol, QString data, bool editFlag)
|
||||||
|
{
|
||||||
|
QColor color;
|
||||||
|
color.black();
|
||||||
|
QTableWidgetItem *itm =
|
||||||
|
new QTableWidgetItem(data);
|
||||||
|
pTable->setItem(indRow,indCol,itm);
|
||||||
|
|
||||||
|
if (editFlag) {}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pTable->item(indRow, indCol)->setFlags(Qt::ItemIsSelectable|
|
||||||
|
Qt::ItemIsDragEnabled|
|
||||||
|
Qt::ItemIsUserCheckable);
|
||||||
|
}
|
||||||
|
pTable->item(indRow, indCol)->setTextColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void MainWindow::sendcmdwrd()
|
||||||
|
{
|
||||||
|
qDebug() << "send1";
|
||||||
|
QScopedPointer<BC_MIL> NewBC(new BC_MIL(0));
|
||||||
|
qDebug() << "send2";
|
||||||
|
wBase = 0;
|
||||||
|
wMaxBase = bcgetmaxbase();
|
||||||
|
srand(1);
|
||||||
|
|
||||||
|
//Select base
|
||||||
|
if (wBase > wMaxBase)
|
||||||
|
wBase = 0;
|
||||||
|
bcdefbase(wBase);
|
||||||
|
qDebug() << "send3";
|
||||||
|
|
||||||
|
//Prepare data to RT
|
||||||
|
//wSubAddr = rand() & 0x1F;
|
||||||
|
wSubAddr = 0x1F;;
|
||||||
|
//if (fInstMode)
|
||||||
|
// wSubAddr |= 0x10;
|
||||||
|
//wLen = rand() & 0x1F;
|
||||||
|
wLen = 0x1;
|
||||||
|
if (wLen == 0)
|
||||||
|
wLen = 32;
|
||||||
|
for (int i = 0; i < wLen; ++i)
|
||||||
|
awBuf[i] = (wSubAddr<<8) | i;
|
||||||
|
qDebug() << "send4";
|
||||||
|
|
||||||
|
//Try to send data to RT until it answers with Clear Status
|
||||||
|
bcputw(0, CW(RT_ADDR, RT_RECEIVE, wSubAddr, wLen));
|
||||||
|
bcputblk(1, awBuf, wLen);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
//bcstartx(wBase, DATA_BC_RT | CX_STOP | CX_BUS_A | CX_NOSIG);
|
||||||
|
bcstartx(wBase, DATA_BC_RT | CX_STOP | CX_BUS_B | CX_NOSIG);
|
||||||
|
if (NewBC->WaitInt(DATA_BC_RT))
|
||||||
|
NewBC->closeAll();
|
||||||
|
} while ((tmkEvD.bcx.wResultX & (SX_ERR_MASK | SX_IB_MASK)) != 0);
|
||||||
|
qDebug() << "send5";
|
||||||
|
NewBC->closeAll();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void MainWindow::rthandler()
|
||||||
|
{
|
||||||
|
qDebug() << "rt1";
|
||||||
|
QScopedPointer<RT_MIL> NewRT(new RT_MIL(0, 1));
|
||||||
|
qDebug() << "rt2";
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (i != 1000)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
if (tmkselect(0))
|
||||||
|
{
|
||||||
|
qDebug() << "tmk select error";
|
||||||
|
NewRT->closeAllrt();
|
||||||
|
}
|
||||||
|
//Wait for an interrupt
|
||||||
|
switch (WaitForSingleObject(hBcEvent, 1000))
|
||||||
|
{
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
qDebug() << "Interrupt";
|
||||||
|
//New message has arrived
|
||||||
|
ResetEvent(hBcEvent);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
//Get interrupt data
|
||||||
|
tmkgetevd(&tmkEvD);
|
||||||
|
//Check interrupt type
|
||||||
|
if (tmkEvD.nInt == 3)
|
||||||
|
{
|
||||||
|
wSubAddr = (tmkEvD.rt.wStatus >> 5) &0x1F;
|
||||||
|
wLen = tmkEvD.rt.wStatus & 0x1F;
|
||||||
|
if (wLen == 0)
|
||||||
|
wLen = 32;
|
||||||
|
if ((tmkEvD.rt.wStatus & RT_DIR_MASK) == RT_RECEIVE)
|
||||||
|
{
|
||||||
|
//If we received some data then copy the data from Rx subaddres to
|
||||||
|
//Tx subaddress and process flags
|
||||||
|
if ((rtgetflag(RT_RECEIVE, wSubAddr) & RT_FLAG_MASK) == 0)
|
||||||
|
{
|
||||||
|
//qDebug() << "Flag read error";
|
||||||
|
NewRT->closeAllrt();
|
||||||
|
}
|
||||||
|
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||||
|
rtgetblk(0, awBuf, wLen);
|
||||||
|
rtclrflag();
|
||||||
|
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||||
|
rtputblk(0, awBuf, wLen);
|
||||||
|
rtsetflag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (tmkEvD.nInt != 0); //Loop while we have not processed all interrupts
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT_TIMEOUT:
|
||||||
|
// No new messages
|
||||||
|
qDebug() << "No new messages";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
qDebug() << "Interrupt wait error";
|
||||||
|
NewRT->closeAllrt();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NewRT->closeAllrt();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
}
|
55
mainwindow.h
Normal file
55
mainwindow.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include "declarations.h"
|
||||||
|
|
||||||
|
class MainWindow:public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
void init_mainwindowobj(); //the function of this class
|
||||||
|
void init_connections();
|
||||||
|
explicit MainWindow(); //constructor
|
||||||
|
~MainWindow(); //destructor
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init_table();
|
||||||
|
void set_item(QTableWidget *pTable, int indRow,
|
||||||
|
int indCol, QString data, bool editFlag);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//void getlineedit();
|
||||||
|
//void sendcmdwrd();
|
||||||
|
void rthandler();
|
||||||
|
void HexBinChange();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget *Window_1 = new QWidget;
|
||||||
|
QWidget *Window_2 = new QWidget;
|
||||||
|
|
||||||
|
QLabel *HexBinLabel;
|
||||||
|
QPushButton *HexBinButton;
|
||||||
|
|
||||||
|
QLabel *CmdWordLabel;
|
||||||
|
QLineEdit *CmdWordLineEdit;
|
||||||
|
QPushButton *EnterCmdWordButton;
|
||||||
|
QTableWidget *DataTable;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void keyPressEvent(QKeyEvent *event) override
|
||||||
|
{
|
||||||
|
if (loopActive)
|
||||||
|
{
|
||||||
|
loopActive = false;
|
||||||
|
qDebug() << "Key pressed! Stopping loop.";
|
||||||
|
}
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool loopActive = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
310
testinfo.cpp
Normal file
310
testinfo.cpp
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
/*#include <QTest>
|
||||||
|
#include "testinfo.h"
|
||||||
|
#include <windows.h>
|
||||||
|
#include "declarations.h"
|
||||||
|
#include <WDMTMKv2.cpp>
|
||||||
|
|
||||||
|
HANDLE hEvent;
|
||||||
|
TTmkEventData tmkEvD;
|
||||||
|
|
||||||
|
void testInfo::init()
|
||||||
|
{
|
||||||
|
if (isFailed)
|
||||||
|
{
|
||||||
|
qDebug() << "Skip";
|
||||||
|
QSKIP("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::cleanup()
|
||||||
|
{
|
||||||
|
bool a = QTest::currentTestFailed();
|
||||||
|
if (a)
|
||||||
|
isFailed = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::cleanupTestCase()
|
||||||
|
{
|
||||||
|
qDebug() << "TmkClose()";
|
||||||
|
TmkClose();
|
||||||
|
if (hEvent)
|
||||||
|
CloseHandle(hEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testcreateevent()
|
||||||
|
{
|
||||||
|
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
QVERIFY(hEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testTmkOpen()
|
||||||
|
{
|
||||||
|
DWORD a;
|
||||||
|
|
||||||
|
a = TmkOpen();
|
||||||
|
QCOMPARE(a, DWORD(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testtmkgetmaxn()
|
||||||
|
{
|
||||||
|
QCOMPARE(tmkgetmaxn(), (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testmrtgetmaxn()
|
||||||
|
{
|
||||||
|
QCOMPARE(mrtgetmaxn(), (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testtmkconfig()
|
||||||
|
{
|
||||||
|
int hTmk = 0;
|
||||||
|
|
||||||
|
QCOMPARE(tmkconfig(hTmk), (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testtmkselect()
|
||||||
|
{
|
||||||
|
int hTmk = 0;
|
||||||
|
|
||||||
|
QCOMPARE(tmkselect(hTmk), (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testtmkgetinfo()
|
||||||
|
{
|
||||||
|
TTmkConfigData tmkCfg;
|
||||||
|
int hTmk = 0;
|
||||||
|
|
||||||
|
tmkgetinfo(&tmkCfg);
|
||||||
|
QCOMPARE(hTmk, (int)(0)); //Device Number
|
||||||
|
QCOMPARE(tmkCfg.nType, (short)(9)); //Device Type
|
||||||
|
QCOMPARE(tmkCfg.szName, "TA1USB"); //Device Name
|
||||||
|
QCOMPARE(tmkCfg.wPorts1, (unsigned short)(0)); //Device I/O Ports
|
||||||
|
|
||||||
|
if (tmkCfg.wPorts2 == (unsigned short)(0xFFFF)) //Device I/O Ports
|
||||||
|
;
|
||||||
|
else
|
||||||
|
QCOMPARE(tmkCfg.wPorts2, (unsigned short)(0));
|
||||||
|
|
||||||
|
if (tmkCfg.wIrq2 == (unsigned short)(0xFF))
|
||||||
|
QCOMPARE(tmkCfg.wIrq1, (unsigned short)(0)); //Device Interrupt
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QCOMPARE(tmkCfg.wIrq1, (unsigned short)(0)); //Device Interrupts
|
||||||
|
QCOMPARE(tmkCfg.wIrq2, (unsigned short)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
QCOMPARE(tmkCfg.wIODelay, (unsigned short)(0)); //Device I/O Delay
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testtmkgethwver()
|
||||||
|
{
|
||||||
|
QCOMPARE(tmkgethwver(), (unsigned short)(11));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testbcreset()
|
||||||
|
{
|
||||||
|
QCOMPARE(bcreset(), (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testbcgetmaxbase()
|
||||||
|
{
|
||||||
|
QCOMPARE(bcgetmaxbase(), (unsigned short)(1023));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testbcputgetw()
|
||||||
|
{
|
||||||
|
int fError;
|
||||||
|
unsigned short wBase, wAddr;
|
||||||
|
unsigned short wMaxBase = bcgetmaxbase();
|
||||||
|
|
||||||
|
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||||
|
{
|
||||||
|
bcdefbase(wBase);
|
||||||
|
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||||
|
{
|
||||||
|
bcputw(wAddr, wAddr|(wBase<<6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fError = 0;
|
||||||
|
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||||
|
{
|
||||||
|
bcdefbase(wBase);
|
||||||
|
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||||
|
{
|
||||||
|
if (bcgetw(wAddr) != (unsigned short)(wAddr|(wBase<<6)))
|
||||||
|
fError = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QCOMPARE(fError, (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testbcputgetblk()
|
||||||
|
{
|
||||||
|
int fError;
|
||||||
|
unsigned short awBuf[64];
|
||||||
|
unsigned short wBase, wAddr;
|
||||||
|
unsigned short wMaxBase = bcgetmaxbase();
|
||||||
|
|
||||||
|
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||||
|
{
|
||||||
|
bcdefbase(wBase);
|
||||||
|
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||||
|
{
|
||||||
|
awBuf[63-wAddr] = wBase+(wAddr<<8);
|
||||||
|
}
|
||||||
|
bcputblk(0, awBuf, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
fError = 0;
|
||||||
|
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||||
|
{
|
||||||
|
bcdefbase(wBase);
|
||||||
|
bcgetblk(0, awBuf, 64);
|
||||||
|
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||||
|
{
|
||||||
|
if (awBuf[63-wAddr] != (wBase+(wAddr<<8)))
|
||||||
|
fError = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QCOMPARE(fError, (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testrtreset()
|
||||||
|
{
|
||||||
|
QCOMPARE(rtreset(), (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testrtgetmaxpage()
|
||||||
|
{
|
||||||
|
QCOMPARE(rtgetmaxpage(), (unsigned short)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testrtputgetw()
|
||||||
|
{
|
||||||
|
int fError;
|
||||||
|
unsigned short wPage, wAddr, wSubAddr;
|
||||||
|
unsigned short wMaxPage = rtgetmaxpage();
|
||||||
|
|
||||||
|
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||||
|
{
|
||||||
|
rtdefpage(wPage);
|
||||||
|
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||||
|
{
|
||||||
|
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
rtputw(wAddr, wAddr|(wSubAddr<<8)|(wPage<<13));
|
||||||
|
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
rtputw(wAddr, (wAddr+32)|(wSubAddr<<8)|(wPage<<13));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fError = 0;
|
||||||
|
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||||
|
{
|
||||||
|
rtdefpage(wPage);
|
||||||
|
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||||
|
{
|
||||||
|
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
{
|
||||||
|
if (rtgetw(wAddr) != (wAddr|(wSubAddr<<8)|(wPage<<13)))
|
||||||
|
fError = 1;
|
||||||
|
}
|
||||||
|
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
{
|
||||||
|
if (rtgetw(wAddr) != ((wAddr+32)|(wSubAddr<<8)|(wPage<<13)))
|
||||||
|
fError = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QCOMPARE(fError, (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testrtputgetblk()
|
||||||
|
{
|
||||||
|
int fError;
|
||||||
|
unsigned short awBuf[64];
|
||||||
|
unsigned short wPage, wAddr, wSubAddr;
|
||||||
|
unsigned short wMaxPage = rtgetmaxpage();
|
||||||
|
|
||||||
|
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||||
|
{
|
||||||
|
rtdefpage(wPage);
|
||||||
|
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||||
|
{
|
||||||
|
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
awBuf[31-wAddr] = wSubAddr|(wAddr<<8)|(wPage<<13);
|
||||||
|
rtputblk(0, awBuf, 32);
|
||||||
|
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
awBuf[31-wAddr] = (wSubAddr+32)|(wAddr<<8)|(wPage<<13);
|
||||||
|
rtputblk(0, awBuf, 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fError = 0;
|
||||||
|
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||||
|
{
|
||||||
|
rtdefpage(wPage);
|
||||||
|
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||||
|
{
|
||||||
|
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||||
|
rtgetblk(0, awBuf, 32);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
{
|
||||||
|
if (awBuf[31-wAddr] != (wSubAddr|(wAddr<<8)|(wPage<<13)))
|
||||||
|
fError = 1;
|
||||||
|
}
|
||||||
|
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||||
|
rtgetblk(0, awBuf, 32);
|
||||||
|
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||||
|
{
|
||||||
|
if (awBuf[31-wAddr] != ((wSubAddr+32)|(wAddr<<8)|(wPage<<13)))
|
||||||
|
fError = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QCOMPARE(fError, (int)(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testInfo::testgetInt()
|
||||||
|
{
|
||||||
|
bcreset();
|
||||||
|
tmkdefevent(hEvent, TRUE);
|
||||||
|
tmkgetevd(&tmkEvD);
|
||||||
|
QCOMPARE(tmkEvD.nInt, (int)(0));
|
||||||
|
bcdefbase(0);
|
||||||
|
bcputw(0, 0xFFE1);
|
||||||
|
bcstart(0, CTRL_C_BRCST);
|
||||||
|
|
||||||
|
switch (WaitForSingleObject(hEvent, 1000))
|
||||||
|
{
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
ResetEvent(hEvent);
|
||||||
|
qDebug() << "We got interrupt!";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT_TIMEOUT:
|
||||||
|
qDebug() << "We didn't get interrupt!";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
qDebug() << "Somebody abandon our interrupt waiting!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmkgetevd(&tmkEvD);
|
||||||
|
QCOMPARE(tmkEvD.nInt, (int)(1));
|
||||||
|
|
||||||
|
tmkdefevent(0,TRUE);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
49
testinfo.h
Normal file
49
testinfo.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*#ifndef TESTINFO_H
|
||||||
|
#define TESTINFO_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTest>
|
||||||
|
|
||||||
|
class testInfo:public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void testcreateevent();
|
||||||
|
|
||||||
|
void testTmkOpen();
|
||||||
|
void testtmkgetmaxn();
|
||||||
|
void testmrtgetmaxn();
|
||||||
|
void testtmkconfig();
|
||||||
|
void testtmkselect();
|
||||||
|
void testtmkgetinfo();
|
||||||
|
void testtmkgethwver();
|
||||||
|
|
||||||
|
//Now we'll test onboard RAM in Bus Controller mode
|
||||||
|
void testbcreset();
|
||||||
|
void testbcgetmaxbase();
|
||||||
|
void testbcputgetw();
|
||||||
|
void testbcputgetblk();
|
||||||
|
|
||||||
|
//Now we'll test onboard RAM in Remote Terminal mode
|
||||||
|
void testrtreset();
|
||||||
|
void testrtgetmaxpage();
|
||||||
|
void testrtputgetw();
|
||||||
|
void testrtputgetblk();
|
||||||
|
|
||||||
|
|
||||||
|
//Now we'll test interrupt in Bus Controller mode
|
||||||
|
void testgetInt();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void cleanup();
|
||||||
|
void cleanupTestCase();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool isFailed = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TESTINFO_H
|
||||||
|
*/
|
Reference in New Issue
Block a user