forked from ROMEO/nexosim
Finalize the Context and BuildContext API
The API style is now more uniform: both are passed by mutable ref, and only expose accessors. Additionally, the methods that were initially accessed through the scheduler field are now directly implemented on `Context`.
This commit is contained in:
@ -85,7 +85,7 @@ impl Model for MotorAssembly {}
|
||||
impl ProtoModel for ProtoMotorAssembly {
|
||||
type Model = MotorAssembly;
|
||||
|
||||
fn build(self, ctx: &mut BuildContext<Self>) -> MotorAssembly {
|
||||
fn build(self, cx: &mut BuildContext<Self>) -> MotorAssembly {
|
||||
let mut assembly = MotorAssembly::new();
|
||||
let mut motor = Motor::new(self.init_pos);
|
||||
let mut driver = Driver::new(1.0);
|
||||
@ -105,8 +105,8 @@ impl ProtoModel for ProtoMotorAssembly {
|
||||
motor.position = self.position;
|
||||
|
||||
// Add the submodels to the simulation.
|
||||
ctx.add_submodel(driver, driver_mbox, "driver");
|
||||
ctx.add_submodel(motor, motor_mbox, "motor");
|
||||
cx.add_submodel(driver, driver_mbox, "driver");
|
||||
cx.add_submodel(motor, motor_mbox, "motor");
|
||||
|
||||
assembly
|
||||
}
|
||||
|
Reference in New Issue
Block a user