test_custom_entity.py
Go to the documentation of this file.
1 # Olivier Stasse
2 # 2019 CNRS
3 #
4 import os
5 import time
6 
7 from custom_entity import CustomEntity
8 from dynamic_graph import (
9  addLoggerCoutOutputStream,
10  addLoggerFileOutputStream,
11  closeLoggerFileOutputStream,
12  real_time_logger_destroy,
13  real_time_logger_spin_once,
14 )
15 from dynamic_graph.entity import VerbosityLevel
16 
17 print(os.getcwd())
18 
19 # Starts the real time logger instance
20 
21 aCustomEntity = CustomEntity("a_custom_entity")
22 
23 addLoggerFileOutputStream("/tmp/output.dat")
24 aCustomEntity.signals()
25 
26 aCustomEntity.setTimeSample(0.001)
27 print(aCustomEntity.getTimeSample())
28 aCustomEntity.setStreamPrintPeriod(0.002)
29 print(aCustomEntity.getStreamPrintPeriod())
30 
31 aCustomEntity.setLoggerVerbosityLevel(VerbosityLevel.VERBOSITY_INFO_WARNING_ERROR)
32 print(aCustomEntity.getLoggerVerbosityLevel())
33 for i in range(0, 5):
34  aCustomEntity.in_double.value = i
35  aCustomEntity.out_double.recompute(i)
36  real_time_logger_spin_once()
37  print(i)
38 time.sleep(1)
39 
40 aCustomEntity.setLoggerVerbosityLevel(VerbosityLevel.VERBOSITY_WARNING_ERROR)
41 print(aCustomEntity.getLoggerVerbosityLevel())
42 for i in range(5, 10):
43  aCustomEntity.in_double.value = i
44  aCustomEntity.out_double.recompute(i)
45  real_time_logger_spin_once()
46 time.sleep(1)
47 
48 aCustomEntity.setLoggerVerbosityLevel(VerbosityLevel.VERBOSITY_ERROR)
49 print(aCustomEntity.getLoggerVerbosityLevel())
50 for i in range(10, 15):
51  aCustomEntity.in_double.value = i
52  aCustomEntity.out_double.recompute(i)
53  real_time_logger_spin_once()
54 time.sleep(1)
56 time.sleep(1)
57 aCustomEntity.setLoggerVerbosityLevel(VerbosityLevel.VERBOSITY_NONE)
58 print(aCustomEntity.getLoggerVerbosityLevel())
59 for i in range(15, 20):
60  aCustomEntity.in_double.value = i
61  aCustomEntity.out_double.recompute(i)
62  real_time_logger_spin_once()
63 time.sleep(1)
64 
65 aCustomEntity.setLoggerVerbosityLevel(VerbosityLevel.VERBOSITY_ALL)
66 print(aCustomEntity.getLoggerVerbosityLevel())
67 for i in range(20, 25):
68  aCustomEntity.in_double.value = i
69  aCustomEntity.out_double.recompute(i)
70  real_time_logger_spin_once()
71 
72 # End the real time logger
73 real_time_logger_destroy()
74 
75 # Close all the output stream
void addLoggerFileOutputStream(const char *filename)
Definition: debug-py.cc:27


dynamic-graph-python
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:55:50