Line 9... |
Line 9... |
#include <sys/stat.h>
|
#include <sys/stat.h>
|
#include <pthread.h>
|
#include <pthread.h>
|
#include "utypes.h"
|
#include "utypes.h"
|
#include "wb_teststrm.h"
|
#include "wb_teststrm.h"
|
#include "cl_wbpex.h"
|
#include "cl_wbpex.h"
|
|
#include "sys/time.h"
|
//#include "useful.h"
|
//#include "useful.h"
|
|
|
#define BUFSIZEPKG 62
|
#define BUFSIZEPKG 62
|
|
|
#define TRDIND_MODE0 0x0
|
#define TRDIND_MODE0 0x0
|
Line 28... |
Line 29... |
#define TRDIND_GAIN 0x15
|
#define TRDIND_GAIN 0x15
|
#define TRDIND_CONTROL1 0x17
|
#define TRDIND_CONTROL1 0x17
|
#define TRDIND_DELAY_CTRL 0x1F
|
#define TRDIND_DELAY_CTRL 0x1F
|
|
|
|
|
|
long GetTickCount(void)
|
|
{
|
|
struct timeval tv;
|
|
struct timezone tz;
|
|
gettimeofday(&tv, &tz);
|
|
long ret=tv.tv_sec*1000 + tv.tv_usec/1000;
|
|
return ret;
|
|
}
|
|
|
WB_TestStrm::WB_TestStrm( char* fname, CL_WBPEX *pex )
|
WB_TestStrm::WB_TestStrm( char* fname, CL_WBPEX *pex )
|
{
|
{
|
lc_status=0;
|
lc_status=0;
|
|
|
Terminate=0;
|
Terminate=0;
|
BlockRd=0;
|
|
BlockOk=0;
|
|
BlockError=0;
|
|
TotalError=0;
|
|
|
|
pBrd=pex;
|
pBrd=pex;
|
bufIsvi=NULL;
|
|
|
|
SetDefault();
|
SetDefault();
|
GetParamFromFile( fname );
|
GetParamFromFile( fname );
|
CalculateParams();
|
CalculateParams();
|
|
|
// if(5==isTest) {
|
|
// rd0.testBuf.buf_check_sine_init( SizeBlockOfWords, fftSize, lowRange, topRange, 3 );
|
|
// }
|
|
// cpuFreq = tk_freq();
|
|
isFirstCallStep=true;
|
isFirstCallStep=true;
|
}
|
}
|
|
|
WB_TestStrm::~WB_TestStrm()
|
WB_TestStrm::~WB_TestStrm()
|
{
|
{
|
pBrd->StreamDestroy( rd0.Strm );
|
pBrd->StreamDestroy( rd0.Strm );
|
//delete bufIsvi; bufIsvi=NULL;
|
|
|
|
}
|
}
|
|
|
void WB_TestStrm::Prepare( void )
|
void WB_TestStrm::Prepare( void )
|
{
|
{
|
|
|
|
|
PrepareWb();
|
PrepareWb();
|
|
|
rd0.trd=trdNo;
|
rd0.trd=0;
|
rd0.Strm=strmNo;
|
rd0.Strm=strmNo;
|
pBrd->StreamInit( rd0.Strm, CntBuffer, SizeBuferOfBytes, rd0.trd, 1, isCycle, isSystem, isAgreeMode );
|
pBrd->StreamInit( rd0.Strm, CntBuffer, SizeBuferOfBytes, 0, 1, isCycle, isSystem, isAgreeMode );
|
|
|
bufIsvi = new U32[SizeBlockOfWords*2];
|
|
// pBrd->StreamInit( rd0.Strm, CntBuffer, SizeBuferOfBytes, U32(0x3000),U32(1), 0, 1, U32(0) );
|
|
}
|
}
|
|
|
void WB_TestStrm::Start( void )
|
void WB_TestStrm::Start( void )
|
{
|
{
|
int res = pthread_attr_init(&attrThread_);
|
int res = pthread_attr_init(&attrThread_);
|
Line 93... |
Line 91... |
if(res != 0) {
|
if(res != 0) {
|
fprintf(stderr, "%s\n", "Stream not started");
|
fprintf(stderr, "%s\n", "Stream not started");
|
return;
|
return;
|
}
|
}
|
|
|
res = pthread_attr_init(&attrThreadIsvi_);
|
|
if(res != 0) {
|
|
fprintf(stderr, "%s\n", "Stream not started");
|
|
return;
|
|
}
|
|
|
|
res = pthread_attr_setdetachstate(&attrThreadIsvi_, PTHREAD_CREATE_JOINABLE);
|
|
if(res != 0) {
|
|
fprintf(stderr, "%s\n", "Stream not started");
|
|
return;
|
|
}
|
|
|
|
res = pthread_create(&hThreadIsvi, &attrThreadIsvi_, ThreadFuncIsvi, this);
|
|
if(res != 0) {
|
|
fprintf(stderr, "%s\n", "Stream not started");
|
|
return;
|
|
}
|
|
}
|
}
|
|
|
void WB_TestStrm::Stop( void )
|
void WB_TestStrm::Stop( void )
|
{
|
{
|
Terminate=1;
|
Terminate=1;
|
Line 121... |
Line 102... |
}
|
}
|
|
|
void WB_TestStrm::Step( void )
|
void WB_TestStrm::Step( void )
|
{
|
{
|
|
|
/*
|
|
pkg_in.testBuf.check_result( &pkg_in.BlockOk , &pkg_in.BlockError, NULL, NULL, NULL );
|
|
rd0.testBuf.check_result( &rd0.BlockOk , &rd0.BlockError, NULL, NULL, NULL );
|
|
rd1.testBuf.check_result( &rd1.BlockOk , &rd1.BlockError, NULL, NULL, NULL );
|
|
*/
|
|
|
|
rd0.testBuf.check_result( &rd0.BlockOk , &rd0.BlockError, NULL, NULL, NULL );
|
rd0.testBuf.check_result( &rd0.BlockOk , &rd0.BlockError, NULL, NULL, NULL );
|
|
|
//BRDC_fprintf( stderr, "%10s %10d %10d %10d %10d\n", "PACKAGE :", pkg_out.BlockWr, pkg_in.BlockRd, pkg_in.BlockOk, pkg_in.BlockError );
|
long currentTime = GetTickCount();
|
//BRDC_fprintf( stderr, "%10s %10d %10d %10d %10d\n", "FIFO_0 :", tr0.BlockWr, rd0.BlockRd, rd0.BlockOk, rd0.BlockError );
|
int min, sec_all, sec;
|
//BRDC_fprintf( stderr, "%10s %10d %10d %10d %10d\n", "FIFO_1 :", tr1.BlockWr, rd1.BlockRd, rd1.BlockOk, rd1.BlockError );
|
sec_all= currentTime-rd0.time_start;
|
|
sec_all/=1000;
|
|
sec=sec_all%60;
|
|
min=sec_all/60;
|
|
|
|
|
U32 status = pBrd->wb_block_read( 1, 0x10 );
|
U32 status = pBrd->wb_block_read( 1, 0x10 );
|
rd0.BlockWr = pBrd->wb_block_read( 1, 0x11 );
|
rd0.BlockWr = pBrd->wb_block_read( 1, 0x11 );
|
U32 sig = pBrd->wb_block_read( 1, 0x12 );
|
U32 sig = pBrd->wb_block_read( 1, 0x12 );
|
//pBrd->RegPeekDir( rd0.trd, 0 ) & 0xFFFF;
|
|
//rd0.BlockWr=pBrd->wb_block_read( 1, 0x11 );
|
|
|
|
BRDC_fprintf( stdout, "%6s %3d %10d %10d %10d %10d %9.1f %10.1f 0x%.4X 0x%.8X %4d %4f\r", "TRD :", rd0.trd, rd0.BlockWr, rd0.BlockRd, rd0.BlockOk, rd0.BlockError, rd0.VelocityCurrent, rd0.VelocityAvarage, status, sig, IsviCnt, rd0.fftTime_us );
|
BRDC_fprintf( stdout, "%6s %3d %10d %10d %10d %10d %9.1f %10.1f 0x%.4X 0x%.8X %u:%.2u \r", "TRD :", rd0.trd, rd0.BlockWr, rd0.BlockRd, rd0.BlockOk, rd0.BlockError, rd0.VelocityCurrent, rd0.VelocityAvarage, status, sig, min, sec );
|
|
|
|
|
|
|
|
|
}
|
}
|
|
|
int WB_TestStrm::isComplete( void )
|
int WB_TestStrm::isComplete( void )
|
{
|
{
|
if( (lc_status==4) && (IsviStatus==100) )
|
if( lc_status==4 )
|
return 1;
|
return 1;
|
return 0;
|
return 0;
|
}
|
}
|
|
|
void WB_TestStrm::GetResult( void )
|
void WB_TestStrm::GetResult( void )
|
{
|
{
|
//if(pkg_in.BlockRd!=0 && pkg_in.BlockError!=0)
|
BRDC_fprintf( stderr, "\n\nResult of receiving data \n" );
|
// printf("%s\n", pkg_in.testBuf.report_word_error());
|
|
|
BRDC_fprintf( stderr, "\n Recieved blocks : %d \n", rd0.BlockRd );
|
|
BRDC_fprintf( stderr, " Correct blocks : %d \n", rd0.BlockOk );
|
|
BRDC_fprintf( stderr, " Incorrect blocks: %d \n", rd0.BlockError );
|
|
BRDC_fprintf( stderr, " Total errors : %d \n\n", rd0.TotalError );
|
|
BRDC_fprintf( stderr, " Speed : %.1f [Mbytes/s] \n", rd0.VelocityAvarage );
|
|
|
BRDC_fprintf( stderr, "\n\nРезультат приёма данных через тетраду %d \n", trdNo );
|
long currentTime = GetTickCount();
|
if(rd0.BlockRd!=0 && rd0.BlockError!=0)
|
int min, sec_all, sec;
|
printf("%s\n", rd0.testBuf.report_word_error());
|
sec_all= currentTime-rd0.time_start;
|
|
sec_all/=1000;
|
|
sec=sec_all%60;
|
|
min=sec_all/60;
|
|
|
|
BRDC_fprintf( stderr, " Time of test : %d min %.2d sec\n\n", min, sec );
|
|
|
|
|
|
if(rd0.BlockRd!=0 && rd0.BlockError==0)
|
|
{
|
|
BRDC_fprintf( stderr,"All data is correct. No error\n" );
|
|
} else if( rd0.BlockRd==0 )
|
|
{
|
|
BRDC_fprintf( stderr,"Error - data is not received \n" );
|
|
|
|
} else
|
|
{
|
|
BRDC_fprintf( stderr,"List of error:\n" );
|
|
BRDC_fprintf( stderr,"%s\n", rd0.testBuf.report_word_error());
|
|
}
|
|
|
BRDC_fprintf( stderr, "\n\n" );
|
BRDC_fprintf( stderr, "\n\n" );
|
}
|
}
|
|
|
void* WB_TestStrm::ThreadFunc( void* lpvThreadParm )
|
void* WB_TestStrm::ThreadFunc( void* lpvThreadParm )
|
Line 175... |
Line 177... |
return 0;
|
return 0;
|
ret=test->Execute();
|
ret=test->Execute();
|
return (void*)ret;
|
return (void*)ret;
|
}
|
}
|
|
|
void* WB_TestStrm::ThreadFuncIsvi( void* lpvThreadParm )
|
|
{
|
|
WB_TestStrm *test=(WB_TestStrm*)lpvThreadParm;
|
|
UINT ret;
|
|
if( !test )
|
|
return 0;
|
|
|
|
Sleep( 200 );
|
|
ret=test->ExecuteIsvi();
|
|
return (void*)ret;
|
|
}
|
|
|
|
//! Установка параметров по умолчанию
|
//! Установка параметров по умолчанию
|
void WB_TestStrm::SetDefault( void )
|
void WB_TestStrm::SetDefault( void )
|
{
|
{
|
int ii=0;
|
int ii=0;
|
|
|
Line 199... |
Line 189... |
array_cfg[ii++]=STR_CFG( 0, "SizeBlockOfWords", "2048", (U32*)&SizeBlockOfWords, "Размер блока в словах" );
|
array_cfg[ii++]=STR_CFG( 0, "SizeBlockOfWords", "2048", (U32*)&SizeBlockOfWords, "Размер блока в словах" );
|
array_cfg[ii++]=STR_CFG( 0, "isCycle", "1", (U32*)&isCycle, "1 - Циклический режим работы стрима" );
|
array_cfg[ii++]=STR_CFG( 0, "isCycle", "1", (U32*)&isCycle, "1 - Циклический режим работы стрима" );
|
array_cfg[ii++]=STR_CFG( 0, "isSystem", "1", (U32*)&isSystem, "1 - выделение системной памяти" );
|
array_cfg[ii++]=STR_CFG( 0, "isSystem", "1", (U32*)&isSystem, "1 - выделение системной памяти" );
|
array_cfg[ii++]=STR_CFG( 0, "isAgreeMode", "0", (U32*)&isAgreeMode, "1 - согласованный режим" );
|
array_cfg[ii++]=STR_CFG( 0, "isAgreeMode", "0", (U32*)&isAgreeMode, "1 - согласованный режим" );
|
|
|
array_cfg[ii++]=STR_CFG( 0, "trdNo", "4", (U32*)&trdNo, "Номер тетрады" );
|
|
array_cfg[ii++]=STR_CFG( 0, "strmNo", "0", (U32*)&strmNo, "Номер стрма" );
|
array_cfg[ii++]=STR_CFG( 0, "strmNo", "0", (U32*)&strmNo, "Номер стрма" );
|
array_cfg[ii++]=STR_CFG( 0, "isTest", "0", (U32*)&isTest, "0 - нет, 1 - проверка псевдослучайной последовательности, 2 - проверка тестовой последовательности" );
|
array_cfg[ii++]=STR_CFG( 0, "isTest", "0", (U32*)&isTest, "0 - нет, 1 - проверка псевдослучайной последовательности, 2 - проверка тестовой последовательности" );
|
array_cfg[ii++]=STR_CFG( 0, "isMainTest", "0", (U32*)&isMainTest, "1 - включение режима тестирования в тетраде MAIN" );
|
|
|
|
array_cfg[ii++]=STR_CFG( 0, "lowRange", "0", (U32*)&lowRange, "нижний уровень спектра" );
|
|
array_cfg[ii++]=STR_CFG( 0, "topRange", "0", (U32*)&topRange, "верхний уровень спектра" );
|
|
array_cfg[ii++]=STR_CFG( 0, "fftSize", "2048", (U32*)&fftSize, "размер БПФ" );
|
|
|
|
|
|
fnameAdmReg=NULL;
|
|
array_cfg[ii++]=STR_CFG( 2, "AdmReg", "adcreg.ini", (U32*)&fnameAdmReg, "имя файла регистров" );
|
|
|
|
array_cfg[ii++]=STR_CFG( 0, "isAdmReg", "0", (U32*)&isAdmReg, "1 - разрешение записи регистров из файла AdmReg" );
|
|
|
|
fnameAdmReg2=NULL;
|
|
array_cfg[ii++]=STR_CFG( 2, "AdmReg2", "adcreg2.ini", (U32*)&fnameAdmReg2, "имя файла регистров (выполняется после старта стрима)" );
|
|
|
|
array_cfg[ii++]=STR_CFG( 0, "isAdmReg2", "0", (U32*)&isAdmReg2, "1 - разрешение записи регистров из файла AdmReg2" );
|
|
|
|
fnameIsvi=NULL;
|
|
array_cfg[ii++]=STR_CFG( 2, "ISVI_FILE", "", (U32*)&fnameIsvi, "имя файла данных ISVI" );
|
|
|
|
array_cfg[ii++]=STR_CFG( 0, "ISVI_HEADER", "0", (U32*)&IsviHeaderMode, "режим формирования суффикса ISVI, 0 - нет, 1 - DDC, 2 - ADC" );
|
|
|
|
|
|
array_cfg[ii++]=STR_CFG( 0, "FifoRdy", "0", (U32*)&isFifoRdy, "1 - генератор тестовой последовательности анализирует флаг готовности FIFO" );
|
array_cfg[ii++]=STR_CFG( 0, "FifoRdy", "0", (U32*)&isFifoRdy, "1 - генератор тестовой последовательности анализирует флаг готовности FIFO" );
|
|
|
array_cfg[ii++]=STR_CFG( 0, "Cnt1", "0", (U32*)&Cnt1, "Число тактов записи в FIFO, 0 - постоянная запись в FIFO" );
|
array_cfg[ii++]=STR_CFG( 0, "Cnt1", "0", (U32*)&Cnt1, "Число тактов записи в FIFO, 0 - постоянная запись в FIFO" );
|
Line 235... |
Line 203... |
|
|
array_cfg[ii++]=STR_CFG( 0, "DataType", "0", (U32*)&DataType, "Тип данных при фиксированном типе блока, 6 - счётчик, 8 - псевдослучайная последовательность" );
|
array_cfg[ii++]=STR_CFG( 0, "DataType", "0", (U32*)&DataType, "Тип данных при фиксированном типе блока, 6 - счётчик, 8 - псевдослучайная последовательность" );
|
|
|
array_cfg[ii++]=STR_CFG( 0, "DataFix", "0", (U32*)&DataFix, "1 - фиксированный тип блока, 0 - данные в блоке записят от номера блока" );
|
array_cfg[ii++]=STR_CFG( 0, "DataFix", "0", (U32*)&DataFix, "1 - фиксированный тип блока, 0 - данные в блоке записят от номера блока" );
|
|
|
array_cfg[ii++]=STR_CFG( 0, "isTestCtrl", "0", (U32*)&isTestCtrl, "1 - подготовка тетрады TEST_CTRL" );
|
|
|
|
|
|
array_cfg[ii++]=STR_CFG( 0, "TestSeq", "0", (U32*)&TestSeq, "Значение регистра TEST_SEQ" );
|
|
|
|
max_item=ii;
|
max_item=ii;
|
|
|
{
|
{
|
char str[1024];
|
char str[1024];
|
Line 270... |
Line 234... |
//! Отображение параметров
|
//! Отображение параметров
|
void WB_TestStrm::ShowParam( void )
|
void WB_TestStrm::ShowParam( void )
|
{
|
{
|
TF_WorkParam::ShowParam();
|
TF_WorkParam::ShowParam();
|
|
|
BRDC_fprintf( stderr, "Общий размер буфера стрима: %d МБ\n\n", SizeStreamOfBytes/(1024*1024) );
|
//BRDC_fprintf( stderr, "Size buffer: %d MB\n\n", SizeStreamOfBytes/(1024*1024) );
|
|
|
}
|
}
|
|
|
|
|
U32 WB_TestStrm::Execute( void )
|
U32 WB_TestStrm::Execute( void )
|
{
|
{
|
rd0.testBuf.buf_check_start( 32, 64 );
|
rd0.testBuf.buf_check_start( 32, 64 );
|
|
|
/*
|
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2010 );
|
|
pBrd->StreamStart( rd0.Strm );
|
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2038 );
|
|
if( isTestCtrl )
|
|
{
|
|
StartTestCtrl();
|
|
}
|
|
|
|
if( isAdmReg2 )
|
|
PrepareAdmReg( fnameAdmReg2 );
|
|
|
|
pBrd->RegPokeInd( 4, 0, 0x2038 );
|
|
*/
|
|
pBrd->wb_block_write( 1, 8, 1 );
|
pBrd->wb_block_write( 1, 8, 1 );
|
|
|
pBrd->StreamStart( rd0.Strm );
|
pBrd->StreamStart( rd0.Strm );
|
|
|
U32 val;
|
U32 val;
|
Line 308... |
Line 258... |
|
|
val=pBrd->wb_block_read( 1, 8 );
|
val=pBrd->wb_block_read( 1, 8 );
|
BRDC_fprintf( stderr, "GEN_CTRL=0x%.4X \n", val );
|
BRDC_fprintf( stderr, "GEN_CTRL=0x%.4X \n", val );
|
|
|
pBrd->wb_block_write( 1, 8, 0 );
|
pBrd->wb_block_write( 1, 8, 0 );
|
pBrd->wb_block_write( 1, 9, 1 );
|
|
pBrd->wb_block_write( 1, 8, 0x6A0 );
|
BlockMode = DataType <<8;
|
|
BlockMode |= DataFix <<7;
|
|
|
|
|
|
U32 size = SizeBlockOfWords/1024;
|
|
//if( isTestCtrl )
|
|
{
|
|
pBrd->wb_block_write( 1, 9, size );
|
|
pBrd->wb_block_write( 1, 8, BlockMode | 0x20 );
|
|
}
|
|
|
|
|
val=pBrd->wb_block_read( 1, 8 );
|
val=pBrd->wb_block_read( 1, 8 );
|
BRDC_fprintf( stderr, "GEN_CTRL=0x%.4X \n", val );
|
BRDC_fprintf( stderr, "GEN_CTRL=0x%.4X \n", val );
|
|
|
rd0.time_last=rd0.time_start=0 ;//GetTickCount();
|
rd0.time_last=rd0.time_start=GetTickCount();
|
|
|
|
|
for( ; ; )
|
for( ; ; )
|
{
|
{
|
if( Terminate )
|
if( Terminate )
|
Line 327... |
Line 287... |
}
|
}
|
|
|
ReceiveData( &rd0 );
|
ReceiveData( &rd0 );
|
//Sleep( 100 );
|
//Sleep( 100 );
|
}
|
}
|
/*
|
|
pBrd->RegPokeInd( rd0.trd, 0, 2 );
|
|
Sleep( 200 );
|
|
*/
|
|
pBrd->StreamStop( rd0.Strm );
|
pBrd->StreamStop( rd0.Strm );
|
Sleep( 10 );
|
Sleep( 10 );
|
|
|
lc_status=4;
|
lc_status=4;
|
return 1;
|
return 1;
|
Line 352... |
Line 309... |
mode |= pr->DataFix<<7;
|
mode |= pr->DataFix<<7;
|
|
|
int ret;
|
int ret;
|
int kk;
|
int kk;
|
|
|
//pr->BlockRd++;
|
|
//Sleep( 10 );
|
|
//return;
|
|
|
|
for( kk=0; kk<16; kk++ )
|
for( kk=0; kk<16; kk++ )
|
{
|
{
|
ret=pBrd->StreamGetBuf( pr->Strm, &ptr );
|
ret=pBrd->StreamGetBuf( pr->Strm, &ptr );
|
//ret=0;
|
//ret=0;
|
if( ret )
|
if( ret )
|
{ // Проверка буфера стрима
|
{ // check buffer
|
|
|
for( unsigned ii=0; ii<CntBlockInBuffer; ii++ )
|
for( unsigned ii=0; ii<CntBlockInBuffer; ii++ )
|
{
|
{
|
ptrBlock=ptr+ii*SizeBlockOfWords;
|
ptrBlock=ptr+ii*SizeBlockOfWords;
|
if( isIsvi )
|
|
IsviStep( ptrBlock );
|
|
|
|
if( 1==isTest )
|
if( 1==isTest )
|
pr->testBuf.buf_check_psd( ptrBlock, SizeBlockOfWords );
|
pr->testBuf.buf_check_psd( ptrBlock, SizeBlockOfWords );
|
//int a=0;
|
//int a=0;
|
else if( 2==isTest )
|
else if( 2==isTest )
|
Line 393... |
Line 345... |
break;
|
break;
|
}
|
}
|
}
|
}
|
//Sleep( 0 );
|
//Sleep( 0 );
|
|
|
/*
|
long currentTime = GetTickCount();
|
U32 currentTime = GetTickCount();
|
if( (currentTime - pr->time_last)>4000 )
|
if( (currentTime - pr->time_last)>4000 )
|
|
{
|
|
float t1 = currentTime - pr->time_last;
|
|
float t2 = currentTime - pr->time_start;
|
|
float v = 1000.0*(pr->BlockRd-pr->BlockLast)*SizeBlockOfBytes/t1;
|
|
v/=1024*1024;
|
|
pr->VelocityCurrent=v;
|
|
|
|
v = 1000.0*(pr->BlockRd)*SizeBlockOfBytes/t2;
|
|
v/=1024*1024;
|
|
pr->VelocityAvarage=v;
|
|
pr->time_last = currentTime;
|
|
pr->BlockLast = pr->BlockRd;
|
|
pr->freeCycleZ=pr->freeCycle;
|
|
pr->freeCycle=0;
|
|
|
|
if(lowRange == 0)
|
|
pr->testBuf.buf_check_sine_show();
|
|
//pr->testBuf.buf_check_sine_calc_delta();
|
|
}
|
|
//Sleep(1);
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
void WB_TestStrm::PrepareWb( void )
|
|
{
|
|
|
|
BRDC_fprintf( stderr, "\nPrepare TEST_GENERATE\n" );
|
|
|
|
|
|
|
|
BlockMode = DataType <<8;
|
|
BlockMode |= DataFix <<7;
|
|
|
|
//if( isTestCtrl )
|
|
{
|
{
|
pBrd->wb_block_write( 1, 9, 1 );
|
float t1 = currentTime - pr->time_last;
|
pBrd->wb_block_write( 1, 9, BlockMode );
|
float t2 = currentTime - pr->time_start;
|
}
|
float v = 1000.0*(pr->BlockRd-pr->BlockLast)*SizeBlockOfBytes/t1;
|
|
v/=1024*1024;
|
|
pr->VelocityCurrent=v;
|
|
|
|
v = 1000.0*(pr->BlockRd)*SizeBlockOfBytes/t2;
|
|
v/=1024*1024;
|
|
pr->VelocityAvarage=v;
|
|
pr->time_last = currentTime;
|
|
pr->BlockLast = pr->BlockRd;
|
|
pr->freeCycleZ=pr->freeCycle;
|
|
pr->freeCycle=0;
|
|
|
|
|
|
|
IsviStatus=0;
|
|
IsviCnt=0;
|
|
isIsvi=0;
|
|
if( fnameIsvi )
|
|
{
|
|
IsviStatus=1;
|
|
isIsvi=1;
|
|
}
|
}
|
|
|
}
|
}
|
|
|
|
|
|
void WB_TestStrm::PrepareWb( void )
|
|
|
//! Подготовка MAIN
|
|
void WB_TestStrm::PrepareMain( void )
|
|
{
|
|
/*
|
|
if( 4==isTest )
|
|
{
|
|
BRDC_fprintf( stderr, "В тетраде MAIN установлен режим формирования двоично-инверсной последовательности\n" );
|
|
} else
|
|
{
|
|
BRDC_fprintf( stderr, "В тетраде MAIN установлен режим формирования псевдослучайной последовательности\n" );
|
|
pBrd->RegPokeInd( 0, 12, 1 ); // Регистр TEST_MODE[0]=1 - режим формирования псевдослучайной последовательности
|
|
}
|
|
pBrd->RegPokeInd( 0, 0, 2 ); // Сброс FIFO - перевод в начальное состояние
|
|
Sleep( 1 );
|
|
pBrd->RegPokeInd( 0, 0, 0 );
|
|
Sleep( 1 );
|
|
*/
|
|
}
|
|
|
|
void WB_TestStrm::IsviStep( U32* ptr )
|
|
{
|
|
unsigned ii;
|
|
if( (1==IsviStatus) || (4==IsviStatus ) )
|
|
{
|
|
for( ii=0; ii<SizeBlockOfWords; ii++ ) bufIsvi[ii]=ptr[ii];
|
|
IsviStatus++;
|
|
}
|
|
}
|
|
|
|
void WB_TestStrm::WriteFlagSinc(int flg, int isNewParam)
|
|
{
|
|
int fs = -1;
|
|
int val[2];
|
|
|
|
char fname[256];
|
|
sprintf( fname, "%s.flg", fnameIsvi );
|
|
|
|
while( fs==-1 )
|
|
{
|
|
fs = open( fname, O_RDWR|O_CREAT, 0666 );
|
|
Sleep( 10 );
|
|
}
|
|
val[0] = flg;
|
|
val[1] = isNewParam;
|
|
write( fs, val, 8 );
|
|
close( fs );
|
|
}
|
|
|
|
int WB_TestStrm::ReadFlagSinc(void)
|
|
{
|
|
int fs = -1;
|
|
int flg;
|
|
|
|
char fname[256];
|
|
sprintf( fname, "%s.flg", fnameIsvi );
|
|
|
|
while( fs==-1 )
|
|
{
|
|
fs = open( fname, O_RDWR|O_CREAT, 0666 );
|
|
Sleep( 10 );
|
|
}
|
|
read( fs, &flg, 4 );
|
|
close( fs );
|
|
|
|
return flg;
|
|
}
|
|
|
|
void WB_TestStrm::WriteDataFile( U32 *pBuf, U32 sizew )
|
|
{
|
|
char fname[256];
|
|
sprintf( fname, "%s.bin", fnameIsvi );
|
|
int fl = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
|
|
|
if( fl==-1 )
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
write( fl, pBuf, sizew*4 );
|
|
|
|
write( fl, IsviHeaderStr, IsviHeaderLen );
|
|
|
|
close( fl );
|
|
}
|
|
|
|
|
|
U32 WB_TestStrm::ExecuteIsvi( void )
|
|
{
|
|
for( ; ; )
|
|
{
|
|
if( Terminate )
|
|
{
|
|
break;
|
|
}
|
|
|
|
int rr;
|
|
switch( IsviStatus )
|
|
{
|
|
case 2: // Подготовка суффикса
|
|
{
|
{
|
IsviHeaderStr[0]=0;
|
|
/*
|
/*
|
switch( IsviHeaderMode )
|
BRDC_fprintf( stderr, "\nPrepare TEST_GENERATE\n" );
|
{
|
|
case 1: SetFileHeaderDdc( SizeBlockOfWords, IsviHeaderStr ); break;
|
|
case 2: SetFileHeaderAdc( SizeBlockOfWords, IsviHeaderStr ); break;
|
|
}
|
|
*/
|
|
IsviHeaderLen = 0; //strlen( IsviHeaderStr );
|
|
WriteFlagSinc(0,0);
|
|
WriteDataFile( bufIsvi, SizeBlockOfWords );
|
|
WriteFlagSinc(0xffffffff,0xffffffff);
|
|
|
|
IsviCnt++;
|
|
IsviStatus=3;
|
|
}
|
|
break;
|
|
|
|
case 3:
|
|
{
|
|
rr=ReadFlagSinc();
|
|
if( 0==rr )
|
|
IsviStatus=4;
|
|
|
|
}
|
|
break;
|
|
|
|
case 4:
|
|
// Ожидание получения данных
|
|
Sleep( 100 );
|
|
break;
|
|
|
|
case 5:
|
|
{
|
|
WriteDataFile( bufIsvi, SizeBlockOfWords );
|
|
WriteFlagSinc(0xffffffff,0 );
|
|
IsviStatus=3;
|
|
IsviCnt++;
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
Sleep( 100 );
|
|
}
|
|
IsviStatus=100;
|
|
return 0;
|
|
}
|
|
|
|
|
|
#define TRD_CTRL 1
|
|
|
|
#define REG_MUX_CTRL 0x0F
|
|
#define REG_GEN_CNT1 0x1A
|
|
#define REG_GEN_CNT2 0x1B
|
|
#define REG_GEN_CTRL 0x1E
|
|
#define REG_GEN_SIZE 0x1F
|
|
#define TRD_DIO_IN 6
|
|
#define TRD_CTRL 1
|
|
//#define TRD_DIO_IN
|
|
//! Подготовка TEST_CTRL
|
|
|
|
void WB_TestStrm::PrepareTestCtrl( void )
|
|
{
|
|
BRDC_fprintf( stderr, "\nПодготовка тетрады TEST_CTRL\n" );
|
|
/*
|
|
BlockMode = DataType <<8;
|
BlockMode = DataType <<8;
|
BlockMode |= DataFix <<7;
|
BlockMode |= DataFix <<7;
|
|
|
if( !isFifoRdy )
|
//if( isTestCtrl )
|
BlockMode |=0x1000;
|
|
|
|
U32 block_mode=BlockMode;
|
|
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CTRL, 1 );
|
|
|
|
//U32 mode0=pBrd->RegPeekInd( TRD_DIO_IN, 0 );
|
|
// pBrd->RegPokeInd( TRD_DIO_IN, 0, 2 );
|
|
|
|
Sleep( 1 );
|
|
|
|
//pBrd->RegPokeInd( TRD_DIO_IN, 0, 0 );
|
|
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CTRL, 0 );
|
|
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_MUX_CTRL, 1 );
|
|
|
|
U32 val=SizeBlockOfBytes/4096;
|
|
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_SIZE, val );
|
|
|
|
if( block_mode & 0x80 )
|
|
{
|
|
BRDC_fprintf( stderr, "Используется сокращённая тестовая последовательность\r\n" );
|
|
} else
|
|
{
|
|
BRDC_fprintf( stderr, "Используется полная тестовая последовательность\r\n" );
|
|
}
|
|
|
|
|
|
if( Cnt1 || Cnt2 )
|
|
{
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT1, Cnt1 );
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT2, Cnt2 );
|
|
float sp=1907.348632812 * (Cnt1-1)/(Cnt1+Cnt2-2);
|
|
BRDC_fprintf( stderr, "Установлено ограничение скорости формирования потока: %6.1f МБайт/с \r\n"
|
|
"REG_CNT1=%d REGH_CNT2=%d \r\n", sp, Cnt1, Cnt2 );
|
|
if( block_mode&0x1000 )
|
|
{
|
{
|
BRDC_fprintf( stderr, "Установлен режим без ожидания готовности FIFO\r\n\r\n" );
|
pBrd->wb_block_write( 1, 9, 1 );
|
} else
|
pBrd->wb_block_write( 1, 8, BlockMode );
|
{
|
|
BRDC_fprintf( stderr, "Установлено ожидание готовности FIFO \r\n\r\n" );
|
|
}
|
}
|
} else
|
|
{
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT1, 0 );
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT2, 0 );
|
|
BRDC_fprintf( stderr, "Установлено формирование потока на максимальной скорости: 1907 МБайт/с \r\n"
|
|
"Установлено ожидание готовности FIFO \r\n\r\n" );
|
|
}
|
|
|
|
*/
|
|
}
|
|
|
|
//! Запуск TestCtrl
|
|
void WB_TestStrm::StartTestCtrl( void )
|
|
{
|
|
/*
|
|
U32 ctrl=0x20;
|
|
ctrl|=BlockMode;
|
|
if( Cnt1 || Cnt2 )
|
|
ctrl|=0x40;
|
|
|
|
if( !isFifoRdy )
|
|
ctrl |=0x1000;
|
|
// ctrl&= ~0x1000;
|
|
//BRDC_fprintf( stderr, "TEST_CTRL: REG_GEN_CTRL = 0x%.4X \r\n", ctrl );
|
|
|
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CTRL, ctrl ); // Запуск DIO_IN
|
|
|
|
//U32 mode0=pBrd->RegPeekInd( 6, 0 );
|
|
//mode0 |=0x30;
|
|
//pBrd->RegPokeInd( 6, 0, mode0 ); // Запуск DIO_IN
|
|
*/
|
*/
|
|
|
}
|
}
|
|
|
|
|
//! Запись регистров из файла
|
|
void WB_TestStrm::PrepareAdmReg( char* fname )
|
|
{
|
|
BRDC_fprintf( stderr, "\nУстановка регистров из файла %s\r\n\n", fname );
|
|
/*
|
|
FILE *in = fopen( fname, "rt" );
|
|
if( in==NULL )
|
|
{
|
|
throw( "Ошибка доступа к файлу " );
|
|
}
|
|
|
|
char str[256];
|
|
U32 trd, reg, val;
|
|
int ret;
|
|
for( ; ; )
|
|
{
|
|
if( fgets( str, 200, in )==NULL )
|
|
break;
|
|
|
|
if( str[0]==';' )
|
|
continue;
|
|
|
|
ret=sscanf( str, "%i %i %i", &trd, ®, &val );
|
|
if( 3==ret )
|
|
{
|
|
BRDC_fprintf( stderr, " TRD: %d REG[0x%.2X]=0x%.4X \n", trd, reg, val );
|
|
pBrd->RegPokeInd( trd, reg, val );
|
|
}
|
|
|
|
}
|
|
*/
|
|
BRDC_fprintf( stderr, "\n\n" );
|
|
}
|
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|