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

Application Lifecycle Management

Search In Project

Search inClear

Tags:  not added yet

Parameter Conversion

Parameter passing from OMS simulation file to a component with or without conversion.

Concept

OMS converts values for parameters as needed. Parameters can be provided as first class objects or string representations. Files, dates, time, and other parameters usually are more descriptive as strings than objects.

Implementation

'OMS component 'Component' imports Java array and calendar utilities as well as OMS annotations. The component specifies six input parameters of types shown: double array, integer, boolean, double, Double, and Calendar. The component prints the respective parameter values.

 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
package ex14;

import java.util.Arrays;
import java.util.Calendar;
import oms3.annotations.*;

/**
 *
 * @author od
 */
public class Component {

    @In public double[] param1;
    @In public int param2;
    @In public boolean param3;
    @In public double param4;
    @In public Double param5;
    @In public Calendar param6;

    @Execute
    public void run1() {
        System.out.println(Arrays.toString(param1));
        System.out.println(param2);
        System.out.println(param3);
        System.out.println(param4);
        System.out.println(param5);
        System.out.println(param6.getTime());
    }
}

In the OMS simulation file, the six parameters are initialized as shown. OMS does any necessary conversion required for 'Component' to execute. To reiterate the comment in the simulation file, the modeler usually will be safe specifying parameters as strings as string conversion is widely implemented.

 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
32
import static oms3.SimBuilder.instance as OMS3

OMS3.sim {
   model {
       parameter {


            // array as string
            'c.param1' "{1.2, 3.4, 5.5}"

            // value
            'c.param2' 4
            'c.param3' true
            'c.param4' 5.4
            'c.param5' 5.9

            // Calendar as ISO date, this is more readable
            'c.param6' "2001-3-3"

            // Note, that this is groovy, All numbers here are
            // BigDecimals anyway, OMS converts if neccessary any parameter
            // value as specified here into what the component really needs.
            // you should be safe, if you specify everything as a String,
            // conversions for Strings are widely implemented.

       }

       components {
           'c' 'ex14.Component'
       }
    }
}