Line 2... |
Line 2... |
|
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <fcntl.h>
|
#include <fcntl.h>
|
#include <pthread.h>
|
#include <pthread.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
|
#include <math.h>
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#include <sys/stat.h>
|
#include <sys/stat.h>
|
#include <pthread.h>
|
#include <pthread.h>
|
#include "utypes.h"
|
#include "utypes.h"
|
#include "tf_teststrm.h"
|
#include "tf_teststrm.h"
|
#include "cl_ambpex.h"
|
#include "cl_ambpex.h"
|
//#include "useful.h"
|
|
|
|
#define BUFSIZEPKG 62
|
#define BUFSIZEPKG 62
|
|
|
#define TRDIND_MODE0 0x0
|
#define TRDIND_MODE0 0x0
|
#define TRDIND_MODE1 0x9
|
#define TRDIND_MODE1 0x9
|
Line 26... |
Line 26... |
#define TRDIND_FSRC 0x13
|
#define TRDIND_FSRC 0x13
|
#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
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
int GetTickCount(void)
|
int GetTickCount(void)
|
{
|
{
|
return time( NULL);
|
return time( NULL);
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
TF_TestStrm::TF_TestStrm( char* fname, CL_AMBPEX *pex )
|
TF_TestStrm::TF_TestStrm( char* fname, CL_AMBPEX *pex )
|
{
|
{
|
lc_status=0;
|
lc_status=0;
|
|
|
Terminate=0;
|
Terminate=0;
|
Line 51... |
Line 55... |
CalculateParams();
|
CalculateParams();
|
|
|
isFirstCallStep=true;
|
isFirstCallStep=true;
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
TF_TestStrm::~TF_TestStrm()
|
TF_TestStrm::~TF_TestStrm()
|
{
|
{
|
pBrd->StreamDestroy( rd0.Strm );
|
pBrd->StreamDestroy( rd0.Strm );
|
//delete bufIsvi; bufIsvi=NULL;
|
delete bufIsvi;
|
|
bufIsvi=NULL;
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::Prepare( void )
|
void TF_TestStrm::Prepare( void )
|
{
|
{
|
PrepareAdm();
|
PrepareAdm();
|
|
|
rd0.trd=trdNo;
|
rd0.trd=trdNo;
|
rd0.Strm=strmNo;
|
rd0.Strm=strmNo;
|
pBrd->StreamInit( rd0.Strm, CntBuffer, SizeBuferOfBytes, rd0.trd, 1, isCycle, isSystem, isAgreeMode );
|
pBrd->StreamInit( rd0.Strm, CntBuffer, SizeBuferOfBytes, rd0.trd, 1, isCycle, isSystem, isAgreeMode );
|
//pBrd->StreamInit( rd0.Strm, CntBuffer, SizeBuferOfBytes, rd0.trd, 2, isCycle, isSystem, isAgreeMode );
|
|
|
|
bufIsvi = new U32[SizeBlockOfWords*2];
|
bufIsvi = new U32[SizeBlockOfWords*2];
|
//pBrd->StreamInit( strm, CntBuffer, SizeBuferOfBytes, rd0.trd, 1, 0, 0 );
|
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::Start( void )
|
void TF_TestStrm::Start( void )
|
{
|
{
|
int res = pthread_attr_init(&attrThread_);
|
int res = pthread_attr_init(&attrThread_);
|
if(res != 0) {
|
if(res != 0) {
|
fprintf(stderr, "%s\n", "Stream not started");
|
fprintf(stderr, "%s\n", "Stream not started");
|
Line 109... |
Line 118... |
fprintf(stderr, "%s\n", "Stream not started");
|
fprintf(stderr, "%s\n", "Stream not started");
|
return;
|
return;
|
}
|
}
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::Stop( void )
|
void TF_TestStrm::Stop( void )
|
{
|
{
|
Terminate=1;
|
Terminate=1;
|
lc_status=3;
|
lc_status=3;
|
|
//BRDC_fprintf( stderr, "TF_TestStrm::Stop(): lc_status = %d\n", lc_status );
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::Step( void )
|
void TF_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 );
|
|
//BRDC_fprintf( stderr, "%10s %10d %10d %10d %10d\n", "FIFO_0 :", tr0.BlockWr, rd0.BlockRd, rd0.BlockOk, rd0.BlockError );
|
|
//BRDC_fprintf( stderr, "%10s %10d %10d %10d %10d\n", "FIFO_1 :", tr1.BlockWr, rd1.BlockRd, rd1.BlockOk, rd1.BlockError );
|
|
|
|
U32 status = pBrd->RegPeekDir( rd0.trd, 0 ) & 0xFFFF;
|
U32 status = pBrd->RegPeekDir( rd0.trd, 0 ) & 0xFFFF;
|
BRDC_fprintf( stderr, "%6s %3d %10d %10d %10d %10d %9.1f %10.1f 0x%.4X %d %4d\r", "TRD :", rd0.trd, rd0.BlockWr, rd0.BlockRd, rd0.BlockOk, rd0.BlockError, rd0.VelocityCurrent, rd0.VelocityAvarage, status, IsviStatus, IsviCnt );
|
|
|
|
|
U32 cnt_rd=rd0.BlockRd;
|
|
if( isRestart )
|
|
cnt_rd = cntRestart;
|
|
|
|
BRDC_fprintf( stderr, "%6s %3d %10d %10d %10d %10d %9.1f %10.1f 0x%.4X %d %4d\r", "TRD :", rd0.trd, rd0.BlockWr, cnt_rd, rd0.BlockOk, rd0.BlockError, rd0.VelocityCurrent, rd0.VelocityAvarage, status, IsviStatus, IsviCnt );
|
|
|
|
if( isSystemMonitor )
|
|
{
|
|
unsigned temp;
|
|
float ty;
|
|
pBrd->RegPokeInd( 0, 0x210, 0 );
|
|
temp = pBrd->RegPeekInd( 0, 0x211 );
|
|
|
|
temp >>=6;
|
|
temp &= 0x3FF;
|
|
ty = (temp*503.975)/1024-273.15;
|
|
|
|
BRDC_fprintf( stderr, "%6s %3d %10.1f\n", "SYSMON", 0, ty );
|
|
|
}
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
int TF_TestStrm::isComplete( void )
|
int TF_TestStrm::isComplete( void )
|
{
|
{
|
if( (lc_status==4) && (IsviStatus==100) )
|
if( (lc_status==4) && (IsviStatus==100) )
|
return 1;
|
return 1;
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::GetResult( void )
|
void TF_TestStrm::GetResult( void )
|
{
|
{
|
//if(pkg_in.BlockRd!=0 && pkg_in.BlockError!=0)
|
BRDC_fprintf( stderr, "\n\nResult of receiving data from trd %d \n", trdNo );
|
// printf("%s\n", pkg_in.testBuf.report_word_error());
|
|
|
|
BRDC_fprintf( stderr, "\n\nResult of receiving data from tetrade %d \n", trdNo );
|
|
if(rd0.BlockRd!=0 && rd0.BlockError!=0)
|
if(rd0.BlockRd!=0 && rd0.BlockError!=0)
|
printf("%s\n", rd0.testBuf.report_word_error());
|
printf("%s\n", rd0.testBuf.report_word_error());
|
|
|
BRDC_fprintf( stderr, "\n\n" );
|
BRDC_fprintf( stderr, "\n\n" );
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void* TF_TestStrm::ThreadFunc( void* lpvThreadParm )
|
void* TF_TestStrm::ThreadFunc( void* lpvThreadParm )
|
{
|
{
|
TF_TestStrm *test=(TF_TestStrm*)lpvThreadParm;
|
TF_TestStrm *test=(TF_TestStrm*)lpvThreadParm;
|
UINT ret;
|
UINT ret;
|
if( !test )
|
if( !test )
|
return 0;
|
return 0;
|
ret=test->Execute();
|
ret=test->Execute();
|
return (void*)ret;
|
return (void*)ret;
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void* TF_TestStrm::ThreadFuncIsvi( void* lpvThreadParm )
|
void* TF_TestStrm::ThreadFuncIsvi( void* lpvThreadParm )
|
{
|
{
|
TF_TestStrm *test=(TF_TestStrm*)lpvThreadParm;
|
TF_TestStrm *test=(TF_TestStrm*)lpvThreadParm;
|
UINT ret;
|
UINT ret;
|
if( !test )
|
if( !test )
|
Line 179... |
Line 203... |
Sleep( 200 );
|
Sleep( 200 );
|
ret=test->ExecuteIsvi();
|
ret=test->ExecuteIsvi();
|
return (void*)ret;
|
return (void*)ret;
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
//! Установка параметров по умолчанию
|
//! Установка параметров по умолчанию
|
void TF_TestStrm::SetDefault( void )
|
void TF_TestStrm::SetDefault( void )
|
{
|
{
|
int ii=0;
|
int ii=0;
|
|
|
Line 190... |
Line 216... |
array_cfg[ii++]=STR_CFG( 0, "CntBlockInBuffer", "512", (U32*)&CntBlockInBuffer, "Blocks in buffer" );
|
array_cfg[ii++]=STR_CFG( 0, "CntBlockInBuffer", "512", (U32*)&CntBlockInBuffer, "Blocks in buffer" );
|
array_cfg[ii++]=STR_CFG( 0, "SizeBlockOfWords", "2048", (U32*)&SizeBlockOfWords, "Block size (in words)" );
|
array_cfg[ii++]=STR_CFG( 0, "SizeBlockOfWords", "2048", (U32*)&SizeBlockOfWords, "Block size (in words)" );
|
array_cfg[ii++]=STR_CFG( 0, "isCycle", "1", (U32*)&isCycle, "1 - Stream working in cycle mode" );
|
array_cfg[ii++]=STR_CFG( 0, "isCycle", "1", (U32*)&isCycle, "1 - Stream working in cycle mode" );
|
array_cfg[ii++]=STR_CFG( 0, "isSystem", "1", (U32*)&isSystem, "1 - system memory allocation" );
|
array_cfg[ii++]=STR_CFG( 0, "isSystem", "1", (U32*)&isSystem, "1 - system memory allocation" );
|
array_cfg[ii++]=STR_CFG( 0, "isAgreeMode", "0", (U32*)&isAgreeMode, "1 - adjust mode" );
|
array_cfg[ii++]=STR_CFG( 0, "isAgreeMode", "0", (U32*)&isAgreeMode, "1 - adjust mode" );
|
|
array_cfg[ii++]=STR_CFG( 0, "isRestart", "0", (U32*)&isRestart, "1 - Перезапуск АЦП" );
|
|
|
array_cfg[ii++]=STR_CFG( 0, "trdNo", "4", (U32*)&trdNo, "Номер тетрады" );
|
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, "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;
|
fnameAdmReg=NULL;
|
array_cfg[ii++]=STR_CFG( 2, "AdmReg", "adcreg.ini", (U32*)&fnameAdmReg, "имя файла регистров" );
|
array_cfg[ii++]=STR_CFG( 2, "AdmReg", "adcreg.ini", (U32*)&fnameAdmReg, "имя файла регистров" );
|
|
|
array_cfg[ii++]=STR_CFG( 0, "isAdmReg", "0", (U32*)&isAdmReg, "1 - разрешение записи регистров из файла AdmReg" );
|
array_cfg[ii++]=STR_CFG( 0, "isAdmReg", "0", (U32*)&isAdmReg, "1 - разрешение записи регистров из файла AdmReg" );
|
|
|
Line 216... |
Line 238... |
fnameIsvi=NULL;
|
fnameIsvi=NULL;
|
array_cfg[ii++]=STR_CFG( 2, "ISVI_FILE", "", (U32*)&fnameIsvi, "имя файла данных ISVI" );
|
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, "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" );
|
|
|
array_cfg[ii++]=STR_CFG( 0, "Cnt2", "0", (U32*)&Cnt2, "Число тактов паузы при записи в FIFO" );
|
array_cfg[ii++]=STR_CFG( 0, "Cnt2", "0", (U32*)&Cnt2, "Число тактов паузы при записи в FIFO" );
|
Line 229... |
Line 250... |
|
|
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, "isTestCtrl", "0", (U32*)&isTestCtrl, "1 - подготовка тетрады TEST_CTRL" );
|
|
|
|
|
array_cfg[ii++]=STR_CFG( 0, "TestSeq", "0", (U32*)&TestSeq, "Значение регистра TEST_SEQ" );
|
array_cfg[ii++]=STR_CFG( 0, "TestSeq", "0", (U32*)&TestSeq, "Значение регистра TEST_SEQ" );
|
|
|
max_item=ii;
|
max_item=ii;
|
|
|
{
|
{
|
Line 241... |
Line 261... |
for( unsigned ii=0; ii<max_item; ii++ )
|
for( unsigned ii=0; ii<max_item; ii++ )
|
{
|
{
|
sprintf( str, "%s %s", array_cfg[ii].name, array_cfg[ii].def );
|
sprintf( str, "%s %s", array_cfg[ii].name, array_cfg[ii].def );
|
GetParamFromStr( str );
|
GetParamFromStr( str );
|
}
|
}
|
|
|
|
|
}
|
}
|
|
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
//! Расчёт параметров
|
//! Расчёт параметров
|
void TF_TestStrm::CalculateParams( void )
|
void TF_TestStrm::CalculateParams( void )
|
{
|
{
|
SizeBlockOfBytes = SizeBlockOfWords * 4; // Размер блока в байтах
|
SizeBlockOfBytes = SizeBlockOfWords * 4; // Размер блока в байтах
|
SizeBuferOfBytes = CntBlockInBuffer * SizeBlockOfBytes ; // Размер буфера в байтах
|
SizeBuferOfBytes = CntBlockInBuffer * SizeBlockOfBytes ; // Размер буфера в байтах
|
SizeStreamOfBytes = CntBuffer * SizeBuferOfBytes; // Общий размер буфера стрима
|
SizeStreamOfBytes = CntBuffer * SizeBuferOfBytes; // Общий размер буфера стрима
|
|
|
ShowParam();
|
ShowParam();
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
//! Отображение параметров
|
//! Отображение параметров
|
void TF_TestStrm::ShowParam( void )
|
void TF_TestStrm::ShowParam( void )
|
{
|
{
|
TF_WorkParam::ShowParam();
|
TF_WorkParam::ShowParam();
|
|
|
BRDC_fprintf( stderr, "Total stream buffer size: %d MB\n\n", SizeStreamOfBytes/(1024*1024) );
|
BRDC_fprintf( stderr, "Total stream buffer size: %d MB\n\n", SizeStreamOfBytes/(1024*1024) );
|
|
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
U32 TF_TestStrm::Execute( void )
|
U32 TF_TestStrm::Execute( void )
|
{
|
{
|
rd0.testBuf.buf_check_start( 32, 64 );
|
rd0.testBuf.buf_check_start( 32, 64 );
|
|
|
//U32 *buffer = pBrd->StreamGetBufByNum(rd0.Strm,0);
|
|
|
|
//fprintf(stderr, "%s(): buffer = %p\n", __FUNCTION__, buffer);
|
|
//getchar();
|
|
/*
|
|
for(u32 i=0; i<SizeBlockOfWords; i++) {
|
|
buffer[i] = 0x1;
|
|
}
|
|
*/
|
|
//Sleep( 100 );
|
|
//pBrd->RegPokeInd( 4, 0, 0x2038 );
|
|
|
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2010 );
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2010 );
|
pBrd->StreamStart( rd0.Strm );
|
pBrd->StreamStart( rd0.Strm );
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2038 );
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2038 );
|
if( isTestCtrl )
|
if( isTestCtrl )
|
{
|
{
|
StartTestCtrl();
|
StartTestCtrl();
|
}
|
}
|
|
|
if( isAdmReg2 )
|
if( isAdmReg2 ) {
|
PrepareAdmReg( fnameAdmReg2 );
|
PrepareAdmReg( fnameAdmReg2 );
|
|
}
|
|
|
pBrd->RegPokeInd( 4, 0, 0x2038 );
|
pBrd->RegPokeInd( 4, 0, 0x2038 );
|
|
|
rd0.time_last=rd0.time_start=GetTickCount();
|
rd0.time_last=rd0.time_start=GetTickCount();
|
|
|
Line 307... |
Line 317... |
{
|
{
|
break;
|
break;
|
}
|
}
|
|
|
ReceiveData( &rd0 );
|
ReceiveData( &rd0 );
|
//Sleep( 100 );
|
|
}
|
}
|
|
|
pBrd->RegPokeInd( rd0.trd, 0, 2 );
|
pBrd->RegPokeInd( rd0.trd, 0, 2 );
|
Sleep( 200 );
|
Sleep( 200 );
|
|
|
pBrd->StreamStop( rd0.Strm );
|
pBrd->StreamStop( rd0.Strm );
|
Sleep( 10 );
|
Sleep( 10 );
|
|
|
lc_status=4;
|
lc_status=4;
|
return 1;
|
|
}
|
|
|
|
|
//BRDC_fprintf( stderr, "TF_TestStrm::Execute(): lc_status = %d\n", lc_status );
|
|
|
|
return 1;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::ReceiveData( ParamExchange *pr )
|
void TF_TestStrm::ReceiveData( ParamExchange *pr )
|
{
|
{
|
U32 *ptr;
|
U32 *ptr;
|
U32 *ptrBlock;
|
U32 *ptrBlock;
|
Line 333... |
Line 345... |
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 );
|
if( ret )
|
if( ret )
|
{ // Проверка буфера стрима
|
{ // Проверка буфера стрима
|
Line 359... |
Line 367... |
else if( 4==isTest )
|
else if( 4==isTest )
|
pr->testBuf.buf_check_inv( ptrBlock, SizeBlockOfWords );
|
pr->testBuf.buf_check_inv( ptrBlock, SizeBlockOfWords );
|
|
|
pr->BlockRd++;
|
pr->BlockRd++;
|
}
|
}
|
//if( isAgreeMode )
|
if( isAgreeMode )
|
//{
|
{
|
// pBrd->StreamGetBufDone( pr->Strm );
|
pBrd->StreamGetBufDone( pr->Strm );
|
//}
|
}
|
|
if( (1==isRestart) && (pr->BlockRd==(CntBuffer*CntBlockInBuffer) ) )
|
} else
|
|
{
|
{
|
//Sleep( 0 );
|
RestartAdc();
|
|
}
|
|
|
|
} else {
|
|
|
pr->freeCycle++;
|
pr->freeCycle++;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
//Sleep( 0 );
|
|
|
|
U32 currentTime = GetTickCount();
|
U32 currentTime = GetTickCount();
|
if( (currentTime - pr->time_last)>10 )
|
if( (currentTime - pr->time_last)>10 )
|
{
|
{
|
float t1 = currentTime - pr->time_last;
|
float t1 = currentTime - pr->time_last;
|
Line 389... |
Line 399... |
pr->VelocityAvarage=v;
|
pr->VelocityAvarage=v;
|
pr->time_last = currentTime;
|
pr->time_last = currentTime;
|
pr->BlockLast = pr->BlockRd;
|
pr->BlockLast = pr->BlockRd;
|
pr->freeCycleZ=pr->freeCycle;
|
pr->freeCycleZ=pr->freeCycle;
|
pr->freeCycle=0;
|
pr->freeCycle=0;
|
|
|
// if(lowRange == 0)
|
|
// pr->testBuf.buf_check_sine_show();
|
|
//pr->testBuf.buf_check_sine_calc_delta();
|
|
}
|
}
|
//Sleep(1);
|
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::PrepareAdm( void )
|
void TF_TestStrm::PrepareAdm( void )
|
{
|
{
|
U32 trd=trdNo;
|
U32 trd=trdNo;
|
U32 id, id_mod, ver;
|
U32 id, id_mod, ver;
|
Line 409... |
Line 415... |
|
|
id = pBrd->RegPeekInd( trd, 0x100 );
|
id = pBrd->RegPeekInd( trd, 0x100 );
|
id_mod = pBrd->RegPeekInd( trd, 0x101 );
|
id_mod = pBrd->RegPeekInd( trd, 0x101 );
|
ver = pBrd->RegPeekInd( trd, 0x102 );
|
ver = pBrd->RegPeekInd( trd, 0x102 );
|
|
|
//pBrd->RegPokeInd( trd, 0, 0x2038 );
|
|
|
|
BRDC_fprintf( stderr, "\nTetrade %d ID: 0x%.2X MOD: %d VER: %d.%d \n\n",
|
BRDC_fprintf( stderr, "\nTetrade %d ID: 0x%.2X MOD: %d VER: %d.%d \n\n",
|
trd, id, id_mod, (ver>>8) & 0xFF, ver&0xFF );
|
trd, id, id_mod, (ver>>8) & 0xFF, ver&0xFF );
|
|
|
|
|
//if( fnameDDS )
|
|
// PrepareDDS();
|
|
|
|
|
|
if( isMainTest )
|
if( isMainTest )
|
PrepareMain();
|
PrepareMain();
|
|
|
|
|
BlockMode = DataType <<8;
|
BlockMode = DataType <<8;
|
BlockMode |= DataFix <<7;
|
BlockMode |= DataFix <<7;
|
|
|
if( isTestCtrl )
|
if( isTestCtrl )
|
PrepareTestCtrl();
|
PrepareTestCtrl();
|
|
|
if( isAdmReg )
|
if( isAdmReg )
|
PrepareAdmReg( fnameAdmReg );
|
PrepareAdmReg( fnameAdmReg );
|
|
|
|
|
IsviStatus=0;
|
IsviStatus=0;
|
IsviCnt=0;
|
IsviCnt=0;
|
isIsvi=0;
|
isIsvi=0;
|
if( fnameIsvi )
|
if( fnameIsvi )
|
{
|
{
|
IsviStatus=1;
|
IsviStatus=1;
|
isIsvi=1;
|
isIsvi=1;
|
}
|
}
|
/*
|
|
pBrd->RegPokeInd( trd, 25, 3 );
|
|
pBrd->RegPokeInd( trd, 16, 3 );
|
|
pBrd->RegPokeInd( trd, 0x13, 0);
|
|
pBrd->RegPokeInd( trd, 28, 0 );
|
|
*/
|
|
//pBrd->RegPokeInd( trd, 0x1B, 0x100 );
|
|
|
|
// pBrd->RegPokeInd( trdSdram, 0, 1 );
|
|
|
|
|
|
|
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
//! Подготовка MAIN
|
//! Подготовка MAIN
|
void TF_TestStrm::PrepareMain( void )
|
void TF_TestStrm::PrepareMain( void )
|
{
|
{
|
|
|
if( 4==isTest )
|
if( 4==isTest )
|
{
|
{
|
BRDC_fprintf( stderr, "В тетраде MAIN установлен режим формирования двоично-инверсной последовательности\n" );
|
BRDC_fprintf( stderr, "In tetrade MAIN set mode of binary-inversion sequence\n" );
|
} else
|
} else
|
{
|
{
|
BRDC_fprintf( stderr, "В тетраде MAIN установлен режим формирования псевдослучайной последовательности\n" );
|
BRDC_fprintf( stderr, "In tetrade MAIN set of pseudo-random mode sequence\n" );
|
pBrd->RegPokeInd( 0, 12, 1 ); // Регистр TEST_MODE[0]=1 - режим формирования псевдослучайной последовательности
|
pBrd->RegPokeInd( 0, 12, 1 ); // Регистр TEST_MODE[0]=1 - режим формирования псевдослучайной последовательности
|
}
|
}
|
pBrd->RegPokeInd( 0, 0, 2 ); // Сброс FIFO - перевод в начальное состояние
|
pBrd->RegPokeInd( 0, 0, 2 ); // Сброс FIFO - перевод в начальное состояние
|
Sleep( 1 );
|
Sleep( 1 );
|
pBrd->RegPokeInd( 0, 0, 0 );
|
pBrd->RegPokeInd( 0, 0, 0 );
|
Sleep( 1 );
|
Sleep( 1 );
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::IsviStep( U32* ptr )
|
void TF_TestStrm::IsviStep( U32* ptr )
|
{
|
{
|
unsigned ii;
|
unsigned ii;
|
if( (1==IsviStatus) || (4==IsviStatus ) )
|
if( (1==IsviStatus) || (4==IsviStatus ) )
|
{
|
{
|
for( ii=0; ii<SizeBlockOfWords; ii++ ) bufIsvi[ii]=ptr[ii];
|
for( ii=0; ii<SizeBlockOfWords; ii++ ) bufIsvi[ii]=ptr[ii];
|
IsviStatus++;
|
IsviStatus++;
|
}
|
}
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::WriteFlagSinc(int flg, int isNewParam)
|
void TF_TestStrm::WriteFlagSinc(int flg, int isNewParam)
|
{
|
{
|
int fs = -1;
|
int fs = -1;
|
int val[2];
|
int val[2];
|
|
|
Line 501... |
Line 489... |
fs = open( fname, O_RDWR|O_CREAT, 0666 );
|
fs = open( fname, O_RDWR|O_CREAT, 0666 );
|
Sleep( 10 );
|
Sleep( 10 );
|
}
|
}
|
val[0] = flg;
|
val[0] = flg;
|
val[1] = isNewParam;
|
val[1] = isNewParam;
|
write( fs, val, 8 );
|
int res = write( fs, val, 8 );
|
|
if(res < 0) {
|
|
BRDC_fprintf( stderr, "Error write flag sync\r\n" );
|
|
}
|
close( fs );
|
close( fs );
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
int TF_TestStrm::ReadFlagSinc(void)
|
int TF_TestStrm::ReadFlagSinc(void)
|
{
|
{
|
int fs = -1;
|
int fs = -1;
|
int flg;
|
int flg;
|
|
|
Line 518... |
Line 511... |
while( fs==-1 )
|
while( fs==-1 )
|
{
|
{
|
fs = open( fname, O_RDWR|O_CREAT, 0666 );
|
fs = open( fname, O_RDWR|O_CREAT, 0666 );
|
Sleep( 10 );
|
Sleep( 10 );
|
}
|
}
|
read( fs, &flg, 4 );
|
int res = read( fs, &flg, 4 );
|
|
if(res < 0) {
|
|
BRDC_fprintf( stderr, "Error read flag sync\r\n" );
|
|
}
|
close( fs );
|
close( fs );
|
|
|
return flg;
|
return flg;
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TF_TestStrm::WriteDataFile( U32 *pBuf, U32 sizew )
|
void TF_TestStrm::WriteDataFile( U32 *pBuf, U32 sizew )
|
{
|
{
|
char fname[256];
|
char fname[256];
|
sprintf( fname, "%s.bin", fnameIsvi );
|
sprintf( fname, "%s.bin", fnameIsvi );
|
int fl = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
int fl = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
Line 536... |
Line 534... |
{
|
{
|
return;
|
return;
|
}
|
}
|
|
|
|
|
write( fl, pBuf, sizew*4 );
|
int res = write( fl, pBuf, sizew*4 );
|
|
if(res < 0) {
|
|
BRDC_fprintf( stderr, "Error write ISVI data\r\n" );
|
|
}
|
|
|
write( fl, IsviHeaderStr, IsviHeaderLen );
|
res = write( fl, IsviHeaderStr, IsviHeaderLen );
|
|
if(res < 0) {
|
|
BRDC_fprintf( stderr, "Error write ISVI header\r\n" );
|
|
}
|
|
|
close( fl );
|
close( fl );
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
U32 TF_TestStrm::ExecuteIsvi( void )
|
U32 TF_TestStrm::ExecuteIsvi( void )
|
{
|
{
|
for( ; ; )
|
for( ; ; )
|
{
|
{
|
Line 607... |
Line 612... |
}
|
}
|
IsviStatus=100;
|
IsviStatus=100;
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
#define TRD_CTRL 1
|
#define TRD_CTRL 1
|
|
|
#define REG_MUX_CTRL 0x0F
|
#define REG_MUX_CTRL 0x0F
|
#define REG_GEN_CNT1 0x1A
|
#define REG_GEN_CNT1 0x1A
|
#define REG_GEN_CNT2 0x1B
|
#define REG_GEN_CNT2 0x1B
|
#define REG_GEN_CTRL 0x1E
|
#define REG_GEN_CTRL 0x1E
|
#define REG_GEN_SIZE 0x1F
|
#define REG_GEN_SIZE 0x1F
|
#define TRD_DIO_IN 6
|
#define TRD_DIO_IN 6
|
#define TRD_CTRL 1
|
#define TRD_CTRL 1
|
//#define TRD_DIO_IN
|
|
//! Подготовка TEST_CTRL
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//! Подготовка TEST_CTRL
|
void TF_TestStrm::PrepareTestCtrl( void )
|
void TF_TestStrm::PrepareTestCtrl( void )
|
{
|
{
|
BRDC_fprintf( stderr, "\nПодготовка тетрады TEST_CTRL\n" );
|
BRDC_fprintf( stderr, "\nПодготовка тетрады TEST_CTRL\n" );
|
|
|
BlockMode = DataType <<8;
|
BlockMode = DataType <<8;
|
Line 679... |
Line 684... |
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT1, 0 );
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT1, 0 );
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT2, 0 );
|
pBrd->RegPokeInd( TRD_CTRL, REG_GEN_CNT2, 0 );
|
BRDC_fprintf( stderr, "Установлено формирование потока на максимальной скорости: 1907 МБайт/с \r\n"
|
BRDC_fprintf( stderr, "Установлено формирование потока на максимальной скорости: 1907 МБайт/с \r\n"
|
"Установлено ожидание готовности FIFO \r\n\r\n" );
|
"Установлено ожидание готовности FIFO \r\n\r\n" );
|
}
|
}
|
|
|
|
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
//! Запуск TestCtrl
|
//! Запуск TestCtrl
|
void TF_TestStrm::StartTestCtrl( void )
|
void TF_TestStrm::StartTestCtrl( void )
|
{
|
{
|
|
|
U32 ctrl=0x20;
|
U32 ctrl=0x20;
|
Line 706... |
Line 710... |
//pBrd->RegPokeInd( 6, 0, mode0 ); // Запуск DIO_IN
|
//pBrd->RegPokeInd( 6, 0, mode0 ); // Запуск DIO_IN
|
|
|
|
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
//! Запись регистров из файла
|
//! Запись регистров из файла
|
void TF_TestStrm::PrepareAdmReg( char* fname )
|
void TF_TestStrm::PrepareAdmReg( char* fname )
|
{
|
{
|
BRDC_fprintf( stderr, "\nУстановка регистров из файла %s\r\n\n", fname );
|
BRDC_fprintf( stderr, "\nSetting up ADM registers from file: %s\r\n\n", fname );
|
|
|
FILE *in = fopen( fname, "rt" );
|
FILE *in = fopen( fname, "rt" );
|
if( in==NULL )
|
if( in==NULL )
|
{
|
{
|
throw( "Ошибка доступа к файлу " );
|
throw( "Error file access" );
|
}
|
}
|
|
|
char str[256];
|
char str[256];
|
U32 trd, reg, val;
|
U32 trd, reg, val;
|
int ret;
|
int ret;
|
Line 740... |
Line 744... |
|
|
}
|
}
|
BRDC_fprintf( stderr, "\n\n" );
|
BRDC_fprintf( stderr, "\n\n" );
|
}
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void TF_TestStrm::RestartAdc( void )
|
|
{
|
|
pBrd->RegPokeInd( rd0.trd, 0, 2 );
|
|
Sleep( 100 );
|
|
|
|
pBrd->StreamStop( rd0.Strm );
|
|
Sleep( 100 );
|
|
|
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2000 );
|
|
|
|
pBrd->StreamStart( rd0.Strm );
|
|
Sleep( 100 );
|
|
|
|
rd0.BlockRd=0;
|
|
cntRestart++;
|
|
|
|
pBrd->RegPokeInd( rd0.trd, 0, 0x2038 );
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void TF_TestStrm::RestartDac( void )
|
|
{
|
|
U32 trdDac = 5;
|
|
|
|
pBrd->RegPokeInd( trdDac, 0, 2 );
|
|
Sleep( 100 );
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void TF_TestStrm::PrepareDac( void )
|
|
{
|
|
U32 trdDac = 5;
|
|
|
|
fprintf(stderr,"%s(): Start DAC\n", __FUNCTION__);
|
|
pBrd->RegPokeInd( trdDac, 0x0, 0x0010 );
|
|
Sleep( 1 );
|
|
pBrd->RegPokeInd( trdDac, 0x0, 0x0030 );
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
No newline at end of file
|
No newline at end of file
|