Menu

Multiple outputs from an atomic

nanael
2014-08-11
2014-08-11
  • nanael

    nanael - 2014-08-11

    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

     
  • Federico Bergero

    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

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.