Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.1 on 2022-01-26 at 16:00 UTC+1 (a few minutes of down time)

Commit 99c182dc authored by Aleksandr Bakhshiev's avatar Aleksandr Bakhshiev
Browse files

Applied Rdk update.

--HG--
branch : IoRefactoring
parent 648e5b56f5ca
......@@ -44,7 +44,7 @@ NConstGenerator::~NConstGenerator(void)
//
bool NConstGenerator::SetAmplitude(const double &value)
{
if(Amplitude.v != value)
if(Amplitude.v() != value)
UpdateOutputFlag=true;
return true;
}
......@@ -77,7 +77,7 @@ bool NConstGenerator::ADefault(void)
//
bool NConstGenerator::ABuild(void)
{
return true;
return NSource::ABuild();
}
// .
......@@ -92,7 +92,9 @@ bool NConstGenerator::ACalculate(void)
{
if(UpdateOutputFlag)
{
*Output=Amplitude.v;
MDMatrix<double> out(Output->GetMatrixSize());
out=Amplitude.v();
Output=out;
UpdateOutputFlag=false;
}
return true;//NSource::ACalculate();
......
......@@ -26,7 +26,7 @@ class RDK_LIB_TYPE NConstGenerator: public NSource
{
public: //
//
RDK::ULProperty<double,NConstGenerator> Amplitude;
RDK::UProperty<double,NConstGenerator, ptPubParameter> Amplitude;
protected: //
......
......@@ -83,10 +83,10 @@ bool NControlObjectSource::ADefault(void)
bool NControlObjectSource::AReset(void)
{
UpdateOutputFlag=true;
DataShift->Assign(Input->GetRows(),Input->GetCols(),0.0);
DataIndexes->Assign(Input->GetRows(),0.0);
DataMul->Assign(Input->GetRows(),Input->GetCols(),1.0);
Output->Assign(Input->GetRows(),Input->GetCols(),0.0);
DataShift.Assign(Input.GetMatrixSize(),0.0);
DataIndexes.Assign(Input.GetRows(),0.0);
DataMul.Assign(Input.GetMatrixSize(),1.0);
Output.Assign(Input.GetMatrixSize(),0.0);
return NSource::AReset();
}
......@@ -94,15 +94,15 @@ bool NControlObjectSource::AReset(void)
bool NControlObjectSource::ACalculate(void)
{
UpdateOutputFlag=true;
DataShift->Resize(Input->GetRows(),Input->GetCols());
DataIndexes->Resize(Input->GetRows());
DataMul->Resize(Input->GetRows(),Input->GetCols());
Output->Resize(Input->GetRows(),Input->GetCols());
DataShift.Resize(Input.GetMatrixSize());
DataIndexes.Resize(Input.GetRows());
DataMul.Resize(Input.GetMatrixSize());
Output.Resize(Input.GetMatrixSize());
for(int i=0;i<Input->GetRows();i++)
for(int i=0;i<Input.GetRows();i++)
{
for(int j=0;j<Input->GetCols();j++)
(*Output)(i,j)=(*DataMul)(i,j)*( (*Input)((*DataIndexes)(i),j)-(*DataShift)(i,j));
for(int j=0;j<Input.GetCols();j++)
Output(i,j)=DataMul(i,j)*(Input(DataIndexes(i),j)-DataShift(i,j));
}
return true;
}
......
......@@ -28,20 +28,20 @@ public: //
//
// - , -
//
RDK::ULProperty<MDVector<int>,NControlObjectSource> DataIndexes;
RDK::UProperty<MDVector<int>,NControlObjectSource, ptPubParameter> DataIndexes;
//
RDK::ULProperty<MDMatrix<double>,NControlObjectSource> DataShift;
RDK::UProperty<MDMatrix<double>,NControlObjectSource, ptPubParameter> DataShift;
//
RDK::ULProperty<MDMatrix<double>,NControlObjectSource> DataMul;
RDK::UProperty<MDMatrix<double>,NControlObjectSource, ptPubParameter> DataMul;
protected: //
//
RDK::UPropertyInputData<MDMatrix<double>,NControlObjectSource> Input;
RDK::UProperty<MDMatrix<double>,NControlObjectSource, ptPubInput> Input;
//
RDK::UPropertyOutputData<MDMatrix<double>,NControlObjectSource> Output;
RDK::UProperty<MDMatrix<double>,NControlObjectSource, ptPubOutput> Output;
public: //
......
......@@ -43,7 +43,7 @@ NFileGenerator::~NFileGenerator(void)
//
bool NFileGenerator::SetFileName(const string &value)
{
FileName.v=value;
FileName.v()=value;
return Reset();
}
// --------------------------
......@@ -94,7 +94,7 @@ bool NFileGenerator::ABuild(void)
bool NFileGenerator::AReset(void)
{
Ini.Delete();
Ini.LoadFromFile(FileName);
Ini.LoadFromFile(*FileName);
Data.clear();
//
......@@ -135,7 +135,7 @@ bool NFileGenerator::ACalculate(void)
{
if(CurrentIndex == Data.end())
{
Output->ToZero();
Output.ToZero();
return true;
}
......@@ -152,12 +152,12 @@ bool NFileGenerator::ACalculate(void)
size_cols=(size_cols>CurrentIndex->second[i].GetCols())?CurrentIndex->second[i].GetCols():size_cols;
}
// DataOutput0->Resize(size_rows,size_cols);
Output.Resize(size_rows,size_cols);
for(int i=0;i<size_rows;i++)
for(int j=0;j<size_cols;j++)
{
Output.Double[j]=CurrentIndex->second[i].Double[j];
Output(i,j)=CurrentIndex->second[i].Double[j];
}
++CurrentIndex;
......
......@@ -16,6 +16,8 @@ See file license.txt for more information
#ifndef NFILE_GENERATOR_H
#define NFILE_GENERATOR_H
#include <map>
#include <vector>
#include "../../Nmsdk-BasicLib/Core/NSource.h"
#include "../../../Rdk/Deploy/Include/rdk.h"
......@@ -25,15 +27,13 @@ class RDK_LIB_TYPE NFileGenerator: public NSource
{
public: //
//
RDK::ULProperty<string,NFileGenerator> FileName;
protected: //
UProperty<string,NFileGenerator, ptPubParameter> FileName;
protected: //
RDK::UIniFile<char> Ini;
// 2D
map<double,vector<RDK::MDMatrix<double> > Data;
map<double,vector<RDK::MDMatrix<double> > > Data;
public: //
// ,
......
......@@ -113,25 +113,25 @@ bool NManipulatorSource::ACalculate(void)
if(NumInputs >0 && GetInputDataSize(0)[1]>0)
{
if(NumInputs<=4)
POutputData[0].Double[0]=GetInputData(0)->Double[0]-Movement;
GetOutputData(0).Double[0]=GetInputData(0).Double[0]-Movement;
else
POutputData[0].Double[0]=GetInputData(0)->Double[0]-GetInputData(4)->Double[0];
GetOutputData(0).Double[0]=GetInputData(0).Double[0]-GetInputData(4).Double[0];
}
if(NumInputs >1 && GetInputDataSize(1)[1]>0)
{
if(NumInputs<=5)
POutputData[1].Double[0]=GetInputData(1)->Double[0]-Angle;
GetOutputData(1).Double[0]=GetInputData(1).Double[0]-Angle;
else
POutputData[1].Double[0]=GetInputData(1)->Double[0]-GetInputData(5)->Double[0];
GetOutputData(1).Double[0]=GetInputData(1).Double[0]-GetInputData(5).Double[0];
}
if(NumInputs >2 && GetInputDataSize(2)[1]>0)
POutputData[2].Double[0]=GetInputData(2)->Double[0];
GetOutputData(2).Double[0]=GetInputData(2).Double[0];
if(NumInputs >3 && GetInputDataSize(3)[1]>0)
POutputData[3].Double[0]=GetInputData(3)->Double[0];
return true;//NManipulatorSource::ACalculate();
GetOutputData(3).Double[0]=GetInputData(3).Double[0];
return true;
}
// --------------------------
}
......
......@@ -25,13 +25,13 @@ class RDK_LIB_TYPE NManipulatorSource: public NSource
{
public: //
//
RDK::ULProperty<double,NManipulatorSource> Angle;
UProperty<double,NManipulatorSource, ptPubParameter> Angle;
//
RDK::ULProperty<double,NManipulatorSource> Speed;
UProperty<double,NManipulatorSource, ptPubParameter> Speed;
//
RDK::ULProperty<double,NManipulatorSource> Force;
UProperty<double,NManipulatorSource, ptPubParameter> Force;
RDK::ULProperty<double,NManipulatorSource> Movement;
UProperty<double,NManipulatorSource, ptPubParameter> Movement;
protected: //
......
......@@ -76,13 +76,13 @@ bool NManipulatorSourceEmulator::AReset(void)
bool NManipulatorSourceEmulator::ACalculate(void)
{
if(NumInputs >0 && GetInputDataSize(0)[1]>0)
POutputData[0].Double[0]=GetInputData(0)->Double[0];
GetOutputData(0).Double[0]=GetInputData(0).Double[0];
if(NumInputs >1 && GetInputDataSize(1)[1]>0)
POutputData[1].Double[0]=GetInputData(1)->Double[0];
GetOutputData(1).Double[0]=GetInputData(1).Double[0];
if(NumInputs >2 && GetInputDataSize(2)[1]>0)
POutputData[2].Double[0]=GetInputData(2)->Double[0];
GetOutputData(2).Double[0]=GetInputData(2).Double[0];
return true;//NManipulatorSource::ACalculate();
}
// --------------------------
......
......@@ -144,7 +144,7 @@ bool NPulseGenerator::ADefault(void)
//
bool NPulseGenerator::ABuild(void)
{
AvgFrequencyCounter->clear();
AvgFrequencyCounter.clear();
return true;
}
......@@ -159,9 +159,9 @@ bool NPulseGenerator::AReset(void)
// if(Frequency.v > 0 && PulseCounter.v<-int(TimeStep/Frequency.v))
// PulseCounter.v=-int(TimeStep/Frequency.v);
// else
PulseCounter.v=0;
PulseCounter.v()=0;
RandomFrequency=Frequency;
AvgFrequencyCounter->clear();
AvgFrequencyCounter.clear();
OldFrequency=Frequency;
return NSource::AReset();
......@@ -170,59 +170,59 @@ bool NPulseGenerator::AReset(void)
//
bool NPulseGenerator::ACalculate(void)
{
if(Frequency.v<1e-8 || TimeStep/Frequency.v<1)
if(Frequency.v()<1e-8 || TimeStep/Frequency.v()<1)
{
FillOutputData();
AvgFrequencyCounter->clear();
OldFrequency=Frequency.v;
PulseCounter.v = 0;
AvgFrequencyCounter.clear();
OldFrequency=Frequency.v();
PulseCounter.v() = 0;
return true;
}
if(OldFrequency != Frequency.v)
if(OldFrequency != Frequency.v())
{
if(PulseCounter.v < 0 && PulseCounter.v < static_cast<int>(-int(TimeStep/Frequency.v)))
PulseCounter.v = static_cast<int>(-int(TimeStep/Frequency.v));
if(PulseCounter.v() < 0 && PulseCounter.v() < static_cast<int>(-int(TimeStep/Frequency.v())))
PulseCounter.v() = static_cast<int>(-int(TimeStep/Frequency.v()));
OldFrequency=Frequency.v;
OldFrequency=Frequency.v();
}
if(FrequencyDeviation.v == 0)
if(FrequencyDeviation.v() == 0)
{
if(PulseCounter>0) //
{
--PulseCounter.v;
--PulseCounter.v();
if(PulseCounter <= 0) //
{
PulseCounter=static_cast<int>(-int(TimeStep/Frequency.v));
PulseCounter=static_cast<int>(-int(TimeStep/Frequency.v()));
FillOutputData(0);
FillOutputData(1);
}
}
else
{
++PulseCounter.v;
++PulseCounter.v();
if(PulseCounter >= 0) //
{
PulseCounter=static_cast<RDK::UTime>(PulseLength.v*TimeStep);
FillOutputData(0,&Amplitude.v);
FillOutputData(1,&Amplitude.v);
AvgFrequencyCounter->push_back(Environment->GetTime().GetDoubleTime());
PulseCounter=static_cast<RDK::UTime>(PulseLength.v()*TimeStep);
FillOutputData(0,&Amplitude.v());
FillOutputData(1,&Amplitude.v());
AvgFrequencyCounter.push_back(Environment->GetTime().GetDoubleTime());
}
}
FillOutputData(2,&Frequency.v);
FillOutputData(2,&Frequency.v());
}
else
{
if(PulseCounter>0) //
{
--PulseCounter.v;
--PulseCounter.v();
if(PulseCounter <= 0) //
{
RandomFrequency=double(rand()*FrequencyDeviation*2.0)/double(RAND_MAX)+
Frequency.v-FrequencyDeviation.v;
if(RandomFrequency.v>0)
PulseCounter=static_cast<int>(-int(TimeStep/RandomFrequency.v));
Frequency.v()-FrequencyDeviation.v();
if(RandomFrequency.v()>0)
PulseCounter=static_cast<int>(-int(TimeStep/RandomFrequency.v()));
else
PulseCounter=0;
FillOutputData(0);
......@@ -231,23 +231,23 @@ bool NPulseGenerator::ACalculate(void)
}
else
{
++PulseCounter.v;
++PulseCounter.v();
if(PulseCounter >= 0) //
{
PulseCounter=static_cast<RDK::UTime>(PulseLength.v*TimeStep);
FillOutputData(0,&Amplitude.v);
FillOutputData(1,&Amplitude.v);
AvgFrequencyCounter->push_back(Environment->GetTime().GetDoubleTime());
PulseCounter=static_cast<RDK::UTime>(PulseLength.v()*TimeStep);
FillOutputData(0,&Amplitude.v());
FillOutputData(1,&Amplitude.v());
AvgFrequencyCounter.push_back(Environment->GetTime().GetDoubleTime());
}
}
FillOutputData(2,&RandomFrequency.v);
FillOutputData(2,&RandomFrequency.v());
}
list<double>::iterator I,J,K;
I=AvgFrequencyCounter->begin();
J=AvgFrequencyCounter->end();
I=AvgFrequencyCounter.begin();
J=AvgFrequencyCounter.end();
if(AvgFrequencyCounter->size()>1)
if(AvgFrequencyCounter.size()>1)
{
while(I != J)
{
......@@ -256,18 +256,18 @@ bool NPulseGenerator::ACalculate(void)
{
K=I;
++I;
AvgFrequencyCounter->erase(K);
AvgFrequencyCounter.erase(K);
}
else
++I;
}
}
I=AvgFrequencyCounter->begin();
J=AvgFrequencyCounter->end();
SetOutputDataSize(3,MMatrixSize(1,AvgFrequencyCounter->size()),true);
for(int i=0;i<POutputData[3].GetSize();i++,++I)
POutputData[3].Double[i]=*I;
I=AvgFrequencyCounter.begin();
J=AvgFrequencyCounter.end();
SetOutputDataSize(3,MMatrixSize(1,AvgFrequencyCounter.size()));
for(int i=0;i<GetOutputData(3).GetSize();i++,++I)
GetOutputData(3).Double[i]=*I;
return true;//NSource::ACalculate();
}
......
......@@ -102,10 +102,10 @@ bool NSinusGenerator::AReset(void)
//
bool NSinusGenerator::ACalculate(void)
{
TimeCounter.v+=1.0/TimeStep;
TimeCounter.v()+=1.0/TimeStep;
double tmp=Amplitude*sin(2.0*M_PI*TimeCounter*Frequency);
for(int i=0;i<GetOutputDataSize(0)[1];i++)
POutputData[0].Double[i]=tmp;
GetOutputData(0).Double[i]=tmp;
return true;//NSource::ACalculate();
}
// --------------------------
......
......@@ -25,16 +25,16 @@ class RDK_LIB_TYPE NSinusGenerator: public NSource
{
public: //
//
RDK::ULProperty<double,NSinusGenerator> Amplitude;
RDK::UProperty<double, NSinusGenerator, ptPubParameter> Amplitude;
// ()
RDK::ULProperty<double,NSinusGenerator> Frequency;
RDK::UProperty<double, NSinusGenerator, ptPubParameter> Frequency;
protected: //
public: //
//
RDK::ULProperty<double,NSinusGenerator> TimeCounter;
RDK::UProperty<double, NSinusGenerator, ptPubParameter> TimeCounter;
public: //
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment