I have been trying to develop an atomic model with several outputs. My
problem is I do not know how to set up the output function to sent data to
all the outputs simultaneously as in the example below
//==== Init section ====
double y[4];
for (int i=0;i<4;i++)
{
y[i]=0;
};
//======== Output section =====
//This function returns an Event:
// Event(%&Value%, %NroPort%)
//where:
// %&Value% points to the variable which contains the value.
// %NroPort% is the port number (from 0 to n-1)
y[0]=f0;
y[1]=f1;
y[2]=f2;
y[3]=f3;
return Event(&y,0);
where f0..f3 represent outcome from some functions.
So far I can only have one output active associated with the port number
included in the Event(&y,0).
I went trough the library of atomics in PD but I could not find any example
how to do it.
Regards,
Nanael
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The thing is that in DEVS you cannot do it simultaneously.
What you are doing with:
y[0]=f0;
y[1]=f1;
y[2]=f2;
y[3]=f3;
return Event(&y,0);
is emmiting ONE event with values {f0,f1,f2,f3} through port 0.
Dont know if you are familiar with the DEVS formalism (hope so), but each event is emmited previous to an internal transition. If you want to emmit 4 events one to each outport you have to schedule 4 instantaneous internal transition (setting the ta=0) and emmit "sequentially" one through the outport 0, another through 1 and so on.
On the other hand, if your block ALWAYS sends 4 events at the same time you could just do it as you wrote it (sending ONE event through ONE port with 4 values). If you want to connect that one outport with other blocks you could write a block that selects ONE of those 4 values.
Best
Fede
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there,
I have been trying to develop an atomic model with several outputs. My
problem is I do not know how to set up the output function to sent data to
all the outputs simultaneously as in the example below
//==== Init section ====
double y[4];
for (int i=0;i<4;i++)
{
y[i]=0;
};
//======== Output section =====
//This function returns an Event:
// Event(%&Value%, %NroPort%)
//where:
// %&Value% points to the variable which contains the value.
// %NroPort% is the port number (from 0 to n-1)
y[0]=f0;
y[1]=f1;
y[2]=f2;
y[3]=f3;
return Event(&y,0);
where f0..f3 represent outcome from some functions.
So far I can only have one output active associated with the port number
included in the Event(&y,0).
I went trough the library of atomics in PD but I could not find any example
how to do it.
Regards,
Nanael
The thing is that in DEVS you cannot do it simultaneously.
What you are doing with:
y[0]=f0;
y[1]=f1;
y[2]=f2;
y[3]=f3;
return Event(&y,0);
is emmiting ONE event with values {f0,f1,f2,f3} through port 0.
Dont know if you are familiar with the DEVS formalism (hope so), but each event is emmited previous to an internal transition. If you want to emmit 4 events one to each outport you have to schedule 4 instantaneous internal transition (setting the ta=0) and emmit "sequentially" one through the outport 0, another through 1 and so on.
On the other hand, if your block ALWAYS sends 4 events at the same time you could just do it as you wrote it (sending ONE event through ONE port with 4 values). If you want to connect that one outport with other blocks you could write a block that selects ONE of those 4 values.
Best
Fede