You are not logged in. Click here to log in.

Application Lifecycle Management

Search In Project

Search inClear

Tags:  not added yet

Bulk Connect

Three alternatives are demonstrated for connecting components in an OMS model simulation file.

Concept

For complex models involving many components, there are less verbose ways than the standard OMS convention to connect components in the simulation file.

Implementation

The three component collection alternatives are provided in the simulation file. 'Comp1' produces output consumed by both 'Comp2' and 'Comp3' at the same time. Hence execution order of 'Comp2' and 'Comp3' is random and parallel. Running this simulation multiple times demonstrates the varying order of execution.

'Comp1' consumes the 'initial' parameter, multiplies it by 3.4, and outputs the result as 'var'.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
package ex10;

import oms3.annotations.*;

public class Comp1 {

    @In public double initial;

    @Out public double var;

    @Execute
    public void execute() {
        var = initial * 3.4;
    }
}

'Comp2' consumes 'var' from 'Comp1' and prints a preceding string and the value of 'var'.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
package ex10;

import oms3.annotations.*;

public class Comp2 {

    @In public double var;

    @Execute
    public void execute() {
        System.out.println("var in Comp2: " + var);
    }
}

'Comp3' also consumes 'var' from 'Comp1' and prints its preceding string and the value of 'var'.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
package ex10;

import oms3.annotations.*;

public class Comp3 {

    @In public double var;

    @Execute
    public void execute() {
        System.out.println("var in Comp3: " + var);
    }
}

The simulation file provides three ways to connect the three components, with the two most verbose ways commented out. The order in which 'Comp2' and 'Comp3' execute varies with each simulation run.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import static oms3.SimBuilder.instance as OMS3

OMS3.sim {
  model {
    parameter {
          // pass in the coordinated as native integer to the 
          // first component. 
          'c1.initial'  20
       }

       components {
          'c1' 'ex10.Comp1'
          'c2' 'ex10.Comp2'
          'c3' 'ex10.Comp3'
       }

       // connect variants 1), 2), and 3) are equivalent, just more 
       // and less verbose for expressing the same.
       connect {
            // 1) simplified connect, 'var' is implicit
            'c1.var' 'c2 c3'

            // 2) more verbose, c2 and c3 are @In
            // 'c1.var' 'c2.var c3.var'

            // 3) most verbose connect
            // 'c1.var' 'c2.var'
            // 'c1.var' 'c3.var'
       }
   }
}