Version 3 (modified by jorisborgdorff, 12 years ago) (diff) |
---|
The MUSCLE configuration file, or, historically, the Complex Automata (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.
To use it, make a file and get the cxa object
cxa = Cxa.LAST
and then add kernels to it by giving a name and a Java class that has the submodel implementation
cxa.add_kernel('w', 'examples.simplejava.Sender') cxa.add_kernel('r', 'examples.simplejava.ConsoleWriter')
To add properties, add them to the env hash of cxa:
cxa.env["max_timesteps"] = 4 cxa.env["w:dt"] = 1; cxa.env["w:someDoubleProperty"] = 6.1; cxa.env["w:someOtherProperty"] = "this is w text"; cxa.env["r:someOtherProperty"] = "this is r text"; cxa.env["cxa_path"] = File.dirname(__FILE__)
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.
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.
cs = cxa.cs cs.attach('w' => 'r') { tie('dataOut', 'dataIn') tie('otherOut', 'other') }