File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/.DS_Store
2+ /build
Original file line number Diff line number Diff line change 1+ import pymoos
2+ import time
3+
4+ #another simple example - here we install a callback which
5+ #fires every time mail arrives. We need to call fetch to
6+ #retrieve it though. We send mail in simple forever loop
7+ #We also subscribe to the same message..
8+
9+ #This version demonstrates setting and using a timewarp that allows speeding up
10+ #simulations with MOOS
11+
12+ comms = pymoos .comms ()
13+
14+ def c ():
15+ print ("\t |-Time Warp @ {0:.1f} \n " .format (pymoos .get_moos_timewarp ()))
16+ print ("\t |-Time Warp delay @ {0:.1f} ms \n " .format ( \
17+ comms .get_comms_control_timewarp_scale_factor ()* pymoos .get_moos_timewarp ()))
18+ return comms .register ('simple_var' ,0 )
19+
20+ def m ():
21+ map (lambda msg : msg .trace (), comms .fetch () )
22+ return True
23+
24+ def main ():
25+
26+ comms .set_on_connect_callback (c )
27+ comms .set_on_mail_callback (m )
28+ pymoos .set_moos_timewarp (10 )
29+ comms .set_comms_control_timewarp_scale_factor (0.4 )
30+ comms .run ('localhost' ,9000 ,'pymoos' )
31+
32+ while True :
33+ time .sleep (1.0 )
34+ comms .notify ('simple_var' ,'a string' ,pymoos .time ())
35+
36+ if __name__ == "__main__" :
37+ main ()
Original file line number Diff line number Diff line change @@ -398,6 +398,8 @@ BOOST_PYTHON_MODULE(pymoos)
398398 bp::def (" time" , &MOOSTime, time_overloads ());
399399 bp::def (" local_time" , &MOOSLocalTime, time_overloads ());
400400 bp::def (" is_little_end_in" , &IsLittleEndian);
401+ bp::def (" set_moos_timewarp" , &SetMOOSTimeWarp);
402+ bp::def (" get_moos_timewarp" , &GetMOOSTimeWarp);
401403
402404 bp::register_exception_translator<pyMOOSException>(&MOOSExceptionTranslator);
403405
You can’t perform that action at this time.
0 commit comments