@@ -10,8 +10,7 @@ are mostly boilerplate that you write once and rarely touch.
1010pub mod tasks ;
1111
1212use cu29 :: prelude :: * ;
13- use cu29_helpers :: basic_copper_setup;
14- use std :: path :: {Path , PathBuf };
13+ use std :: path :: Path ;
1514use std :: thread :: sleep;
1615use std :: time :: Duration ;
1716
@@ -27,24 +26,17 @@ fn main() {
2726 std :: fs :: create_dir_all (parent ). expect (" Failed to create logs directory" );
2827 }
2928 }
30- let copper_ctx = basic_copper_setup (
31- & PathBuf :: from (& logger_path ),
32- PREALLOCATED_STORAGE_SIZE ,
33- true ,
34- None ,
35- )
36- . expect (" Failed to setup logger." );
3729 debug! (" Logger created at {}." , logger_path );
3830 debug! (" Creating application... " );
39- let mut application = MyProjectApplicationBuilder :: new ()
40- . with_context (& copper_ctx )
31+ let mut application = MyProjectApplication :: builder ()
32+ . with_log_path (logger_path , PREALLOCATED_STORAGE_SIZE )
33+ . expect (" Failed to setup logger." )
4134 . build ()
4235 . expect (" Failed to create application." );
43- let clock = copper_ctx . clock. clone ();
44- debug! (" Running... starting clock: {}." , clock . now ());
36+ debug! (" Running... starting clock: {}." , application . clock (). now ());
4537
4638 application . run (). expect (" Failed to run application." );
47- debug! (" End of program: {}." , clock . now ());
39+ debug! (" End of program: {}." , application . clock () . now ());
4840 sleep (Duration :: from_secs (1 ));
4941}
5042```
@@ -63,20 +55,21 @@ generated code is injected by the macro.
6355** ` PREALLOCATED_STORAGE_SIZE ` ** -- How much memory (in bytes) to pre-allocate for the
6456structured log. 100 MB is a reasonable default.
6557
66- ** ` basic_copper_setup ()` ** -- Initializes the unified logger, the robot clock, and returns
67- a ` copper_ctx ` that holds references to both. The parameters are: log file path,
68- pre-allocated size, whether to also print to console, and an optional custom monitor .
58+ ** ` MyProjectApplication::builder ()` ** -- Creates the generated application builder.
59+ You provide the pieces you want to override, such as the clock, config override, or
60+ resource factory .
6961
70- ** ` MyProjectApplicationBuilder::new().with_context(&copper_ctx ).build()` ** -- Wires
62+ ** ` .with_log_path(... ).build()` ** -- Wires
7163everything together: creates each task by calling their ` new() ` constructors,
7264pre-allocates all message buffers, and sets up the scheduler.
7365
7466** ` application.run() ` ** -- Starts the deterministic execution loop. Calls ` start() ` on
7567all tasks, then enters the cycle loop (` preprocess ` -> ` process ` -> ` postprocess ` for
7668each task, in topological order), and continues until you stop the application (Ctrl+C).
7769
78- ** ` copper_ctx.clock.clone() ` ** -- Note that we clone the clock ** after** passing
79- ` copper_ctx ` to the builder, to avoid a partial-move error.
70+ ** ` application.clock() ` ** -- Returns the runtime clock handle. The builder creates a
71+ default clock unless you override it with ` .with_clock(...) ` , which is mainly useful in
72+ tests or simulation.
8073
8174## build.rs -- log index setup
8275
0 commit comments