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

Application Lifecycle Management

Search In Project

Search inClear

Tags:  not added yet

Default Parameter

Default values for @In annotated fields

Concept

An '@In' field can be left unconnected and take its default value specified within the component.

Implementation

OMS component 'Compute' has 'param1' and 'param2' with default values of 12 and 13, respectively. The component prints the values of both parameters.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
package ex13;

import oms3.annotations.Execute;
import oms3.annotations.In;

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

    @In public double param1 = 12;
    @In public double param2 = 13;

    @Execute
    public void run1() {
        System.out.println(param1);
        System.out.println(param2);
    }
}

The simulation file initializes 'param1' as 4.6, but does not initialize 'param2'. Running the simulation executes 'Compute' to print the initialized value of 'param1' and default value of 'param2'.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import static oms3.SimBuilder.instance as OMS3

OMS3.sim {
   model {
       parameter {
            // c.param2 is not initialized from here, 
            // Its default value is being used in this case.
            'c.param1' 4.6
       }

       components {
           'c' 'ex13.Compute'
       }
    }
}