| 1 | The MUSCLE configuration file, or, historically, [[Complex Automata|http://www.complex-automata.org/]] (CxA) file specifies what code will be used in a simulation, and how its coupled together. It is actually a Ruby file, so any Ruby syntax will work inside it. |
| 2 | |
| 3 | To use it, make a file and get the cxa object |
| 4 | {{{ |
| 5 | cxa = Cxa.LAST |
| 6 | }}} |
| 7 | and then add kernels to it by giving a name and a Java class that has the submodel implementation |
| 8 | {{{ |
| 9 | cxa.add_kernel('w', 'examples.simplejava.Sender') |
| 10 | cxa.add_kernel('r', 'examples.simplejava.ConsoleWriter') |
| 11 | }}} |
| 12 | To add properties, add them to the {{{env}}} hash of {{{cxa}}}: |
| 13 | {{{ |
| 14 | cxa.env["max_timesteps"] = 4 |
| 15 | cxa.env["w:dt"] = 1; |
| 16 | cxa.env["w:someDoubleProperty"] = 6.1; |
| 17 | cxa.env["w:someOtherProperty"] = "this is w text"; |
| 18 | cxa.env["r:someOtherProperty"] = "this is r text"; |
| 19 | cxa.env["cxa_path"] = File.dirname(__FILE__) |
| 20 | }}} |
| 21 | Properties that are only meant for a single submodel are prepended with the name and a colon (e.g., "submodelName:propertyName"). Other properties are global and will be used by all submodels. |
| 22 | |
| 23 | The {{{cs}}} property of {{{cxa}}} is the connection scheme; it defines how submodels are coupled. In the example, submodel w is attached to submodel r by tying the conduit entrance dataOut of w to the conduit exit dataIn of r. It also ties conduit entrance otherOut of w to other of r. |
| 24 | |
| 25 | {{{ |
| 26 | cs = cxa.cs |
| 27 | |
| 28 | cs.attach('w' => 'r') { |
| 29 | tie('dataOut', 'dataIn') |
| 30 | tie('otherOut', 'other') |
| 31 | } |
| 32 | }}} |