Hello Marcus, i work for Bretain university in france and i like your Dataflow Frameworks.
We want to test your frameworks and why not using it for research on Noc.
i have follow your tutorial and i have create a small circuit code to the end of post :
i have compile it and it return an undefined reference, i dont really know why because all dspatch header has been put inside usr/include directory in my linux18.04 OS.
Have you some idies? i am autodidact
Thanks
chapoul@lo-lester-007:~/Téléchargements/dspatch-master$ gcc hello.cpp -o f
/tmp/ccWZiQ8F.o : Dans la fonction « main » :
hello.cpp:(.text+0x1db) : référence indéfinie vers « DSPatch::Circuit::AddComponent(std::shared_ptrDSPatch::Component const&) »
hello.cpp:(.text+0x21e) : référence indéfinie vers « DSPatch::Circuit::AddComponent(std::shared_ptrDSPatch::Component const&) »
hello.cpp:(.text+0x261) : référence indéfinie vers « DSPatch::Circuit::AddComponent(std::shared_ptrDSPatch::Component const&) »
hello.cpp:(.text+0x2a1) : référence indéfinie vers « DSPatch::Circuit::AddComponent(std::shared_ptrDSPatch::Component const&) »
hello.cpp:(.text+0x2e1) : référence indéfinie vers « DSPatch::Circuit::AddComponent(std::shared_ptrDSPatch::Component const&) »
/tmp/ccWZiQ8F.o:hello.cpp:(.text+0x321) : encore plus de références indéfinies suivent vers « DSPatch::Circuit::AddComponent(std::shared_ptrDSPatch::Component const&) »
CODE:
#include <DSPatch.h>
#include <components.h>
#include <stdio.h>
#include <stdlib.h>
using namespace DSPatch;
class Multiplexeur: public Component{
public:
Multiplexeur(){
//input/output block
SetInputCount_( 3 );
SetOutputCount_( 1 );
}
protected:
virtual void Process_( SignalBus const& inputs, SignalBus& outputs ) override{
// create some local pointers to hold our input values
auto int1 = inputs.GetValue<int>( 0 );
auto int2 = inputs.GetValue<int>( 1 );
auto int3 = inputs.GetValue<int>( 2 );
// check first that our component has received valid inputs
if ( int1 && int2 && int3 )
{
// set the output as the result of bool1 AND bool2
outputs.SetValue( 0, *int1 && *int2 && *int3 );
}
}
};
class Sub: public Component{
public:
Sub(){
//input/output block
SetInputCount_( 2 );
SetOutputCount_( 1 );
}
protected:
virtual void Process_( SignalBus const& inputs, SignalBus& outputs ) override{
// create some local pointers to hold our input values
auto int1 = inputs.GetValue<int>( 0 );
auto int2 = inputs.GetValue<int>( 1 );
// check first that our component has received valid inputs
if ( int1 && int2)
{
// set the output as the result of bool1 AND bool2
outputs.SetValue( 0, *int1 - *int2);
}
}
};
class Add: public Component{
public:
Add(){
//input/output block
SetInputCount_( 1 );
SetOutputCount_( 1 );
}
protected:
virtual void Process_( SignalBus const& inputs, SignalBus& outputs ) override{
// create some local pointers to hold our input values
auto int1 = inputs.GetValue<int>( 0 );
// check first that our component has received valid inputs
if ( int1 )
{
// set the output as the result of bool1 AND bool2
outputs.SetValue( 0, *int1 +10);
}
}
};
class RandInt final : public Component
{
public:
RandInt()
{
// add 1 output
SetOutputCount_( 1 );
// seed randomizer
srand( static_cast<unsigned int>( time( nullptr ) ) );
}
protected:
virtual void Process_( SignalBus const&, SignalBus& outputs ) override
{
// set output as randomized true / false
outputs.SetValue( 0, rand() );
}
};
class PrintValue final : public Component
{
public:
PrintValue()
{
// add 1 input
SetInputCount_( 1 );
}
protected:
virtual void Process_( SignalBus const& inputs, SignalBus& ) override
{
// create a local stack variable to hold input value
auto inputVal = inputs.GetValue( 0 );
// get boolean value from inputs bus
if ( inputVal )
{
// print "true" / "false" depending on boolean value received
if ( *inputVal )
{
std::cout << "PrintValue:" <<inputVal <<std::endl;
}
else
{
std::cout << "error" << '\n';
}
}
}
};
int main(){
//component declaration
auto circuit = std::make_shared();
auto randIntGen1 = std::make_shared();
auto randIntGen2 = std::make_shared();
auto randIntGen3 = std::make_shared();
auto Sub1 = std::make_shared();
auto Mult1 = std::make_shared();
auto Add1 = std::make_shared();
auto Print1 = std::make_shared();
//circuit component declaration
circuit->AddComponent( randIntGen1 );
circuit->AddComponent( randIntGen2 );
circuit->AddComponent( randIntGen3 );
circuit->AddComponent( Sub1 );
circuit->AddComponent( Mult1 );
circuit->AddComponent( Add1 );
circuit->AddComponent( Print1 );
//Graphe node configuration of the circuit
circuit->ConnectOutToIn( randIntGen1, 0, Mult1, 0 );
circuit->ConnectOutToIn( randIntGen2, 0, Mult1, 1 );
circuit->ConnectOutToIn( randIntGen2, 0, Sub1, 0 );
circuit->ConnectOutToIn( randIntGen3, 0, Sub1, 1 );
circuit->ConnectOutToIn( Sub1, 0, Mult1, 2 );
circuit->ConnectOutToIn( Mult1, 0, Print1, 0 );
for( int i = 0; i < 10; ++i )
{
circuit->Tick();
}
std::cout << "Press any key to begin circuit auto-tick.";
getchar();
circuit->StartAutoTick();
circuit->SetBufferCount( 4 );
return 0;
}