Apollo 11.0
自动驾驶开放平台
py_time.cc 文件参考
#include "cyber/python/internal/py_time.h"
#include <set>
#include <string>
#include <Python.h>
py_time.cc 的引用(Include)关系图:

浏览源代码.

宏定义

#define PYOBJECT_NULL_STRING   PyString_FromStringAndSize("", 0)
 

函数

template<typename T >
T PyObjectToPtr (PyObject *pyobj, const std::string &type_ptr)
 
PyObject * cyber_new_PyTime (PyObject *self, PyObject *args)
 
PyObject * cyber_delete_PyTime (PyObject *self, PyObject *args)
 
PyObject * cyber_PyTime_to_sec (PyObject *self, PyObject *args)
 
PyObject * cyber_PyTime_to_nsec (PyObject *self, PyObject *args)
 
PyObject * cyber_PyTime_sleep_until (PyObject *self, PyObject *args)
 
PyObject * cyber_PyTime_now (PyObject *self, PyObject *args)
 
PyObject * cyber_PyTime_mono_time (PyObject *self, PyObject *args)
 
PyObject * cyber_new_PyDuration (PyObject *self, PyObject *args)
 
PyObject * cyber_delete_PyDuration (PyObject *self, PyObject *args)
 
PyObject * cyber_PyDuration_sleep (PyObject *self, PyObject *args)
 
PyObject * cyber_new_PyRate (PyObject *self, PyObject *args)
 
PyObject * cyber_delete_PyRate (PyObject *self, PyObject *args)
 
PyObject * cyber_PyRate_sleep (PyObject *self, PyObject *args)
 
PyObject * cyber_PyRate_reset (PyObject *self, PyObject *args)
 
PyObject * cyber_PyRate_get_cycle_time (PyObject *self, PyObject *args)
 
PyObject * cyber_PyRate_get_expected_cycle_time (PyObject *self, PyObject *args)
 
PyMODINIT_FUNC PyInit__cyber_time_wrapper (void)
 Init function of this module
 

宏定义说明

◆ PYOBJECT_NULL_STRING

#define PYOBJECT_NULL_STRING   PyString_FromStringAndSize("", 0)

在文件 py_time.cc 第 28 行定义.

函数说明

◆ cyber_delete_PyDuration()

PyObject * cyber_delete_PyDuration ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 157 行定义.

157 {
158 PyObject* pyobj_duration = nullptr;
159 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_delete_PyDuration"),
160 &pyobj_duration)) {
161 Py_INCREF(Py_None);
162 return Py_None;
163 }
164
165 auto* pyduration = reinterpret_cast<PyDuration*>(
166 PyCapsule_GetPointer(pyobj_duration, "apollo_cybertron_pyduration"));
167 if (nullptr == pyduration) {
168 AERROR << "cyber_delete_PyDuration:pyduration ptr is null!";
169 Py_INCREF(Py_None);
170 return Py_None;
171 }
172 delete pyduration;
173 Py_INCREF(Py_None);
174 return Py_None;
175}
#define AERROR
Definition log.h:44

◆ cyber_delete_PyRate()

PyObject * cyber_delete_PyRate ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 211 行定义.

211 {
212 PyObject* pyobj_rate = nullptr;
213 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_delete_PyRate"),
214 &pyobj_rate)) {
215 Py_INCREF(Py_None);
216 return Py_None;
217 }
218
219 auto* pyrate = reinterpret_cast<PyRate*>(
220 PyCapsule_GetPointer(pyobj_rate, "apollo_cybertron_pyrate"));
221 if (nullptr == pyrate) {
222 AERROR << "cyber_delete_PyRate:rate ptr is null!";
223 Py_INCREF(Py_None);
224 return Py_None;
225 }
226 delete pyrate;
227 Py_INCREF(Py_None);
228 return Py_None;
229}

◆ cyber_delete_PyTime()

PyObject * cyber_delete_PyTime ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 52 行定义.

52 {
53 PyObject* pyobj_time = nullptr;
54 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_delete_PyTime"),
55 &pyobj_time)) {
56 Py_INCREF(Py_None);
57 return Py_None;
58 }
59
60 auto* pytime = reinterpret_cast<PyTime*>(
61 PyCapsule_GetPointer(pyobj_time, "apollo_cybertron_pytime"));
62 if (nullptr == pytime) {
63 AERROR << "cyber_delete_PyTime:time ptr is null!";
64 Py_INCREF(Py_None);
65 return Py_None;
66 }
67 delete pytime;
68 Py_INCREF(Py_None);
69 return Py_None;
70}

◆ cyber_new_PyDuration()

PyObject * cyber_new_PyDuration ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 144 行定义.

144 {
145 uint64_t nanoseconds = 0;
146 if (!PyArg_ParseTuple(args, const_cast<char*>("L:cyber_new_PyDuration"),
147 &nanoseconds)) {
148 AERROR << "cyber_new_PyDuration parsetuple failed!";
149 Py_INCREF(Py_None);
150 return Py_None;
151 }
152
153 PyDuration* pyduration = new PyDuration(nanoseconds);
154 return PyCapsule_New(pyduration, "apollo_cybertron_pyduration", nullptr);
155}

◆ cyber_new_PyRate()

PyObject * cyber_new_PyRate ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 198 行定义.

198 {
199 uint64_t nanoseconds = 0;
200 if (!PyArg_ParseTuple(args, const_cast<char*>("L:cyber_new_PyRate"),
201 &nanoseconds)) {
202 AERROR << "cyber_new_PyRate parsetuple failed!";
203 Py_INCREF(Py_None);
204 return Py_None;
205 }
206
207 PyRate* pyrate = new PyRate(nanoseconds);
208 return PyCapsule_New(pyrate, "apollo_cybertron_pyrate", nullptr);
209}

◆ cyber_new_PyTime()

PyObject * cyber_new_PyTime ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 39 行定义.

39 {
40 uint64_t nanoseconds = 0;
41 if (!PyArg_ParseTuple(args, const_cast<char*>("K:cyber_new_PyTime"),
42 &nanoseconds)) {
43 AERROR << "cyber_new_PyTime parsetuple failed!";
44 Py_INCREF(Py_None);
45 return Py_None;
46 }
47
48 PyTime* pytime = new PyTime(nanoseconds);
49 return PyCapsule_New(pytime, "apollo_cybertron_pytime", nullptr);
50}

◆ cyber_PyDuration_sleep()

PyObject * cyber_PyDuration_sleep ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 177 行定义.

177 {
178 PyObject* pyobj_duration = nullptr;
179 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_PyDuration_sleep"),
180 &pyobj_duration)) {
181 Py_INCREF(Py_None);
182 return Py_None;
183 }
184
185 auto* pyduration = reinterpret_cast<PyDuration*>(
186 PyCapsule_GetPointer(pyobj_duration, "apollo_cybertron_pyduration"));
187 if (nullptr == pyduration) {
188 AERROR << "cyber_PyDuration_sleep:pyduration ptr is null!";
189 Py_INCREF(Py_None);
190 return Py_None;
191 }
192 pyduration->sleep();
193 Py_INCREF(Py_None);
194 return Py_None;
195}

◆ cyber_PyRate_get_cycle_time()

PyObject * cyber_PyRate_get_cycle_time ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 271 行定义.

271 {
272 PyObject* pyobj_rate = nullptr;
273 if (!PyArg_ParseTuple(args,
274 const_cast<char*>("O:cyber_PyRate_get_cycle_time"),
275 &pyobj_rate)) {
276 return PyLong_FromUnsignedLongLong(0);
277 }
278
279 auto* pyrate = reinterpret_cast<PyRate*>(
280 PyCapsule_GetPointer(pyobj_rate, "apollo_cybertron_pyrate"));
281 if (nullptr == pyrate) {
282 AERROR << "cyber_PyRate_get_cycle_time:rate ptr is null!";
283 return PyLong_FromUnsignedLongLong(0);
284 }
285 uint64_t ctime = pyrate->get_cycle_time();
286 return PyLong_FromUnsignedLongLong(ctime);
287}

◆ cyber_PyRate_get_expected_cycle_time()

PyObject * cyber_PyRate_get_expected_cycle_time ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 289 行定义.

289 {
290 PyObject* pyobj_rate = nullptr;
291 if (!PyArg_ParseTuple(
292 args, const_cast<char*>("O:cyber_PyRate_get_expected_cycle_time"),
293 &pyobj_rate)) {
294 return PyLong_FromUnsignedLongLong(0);
295 }
296
297 auto* pyrate = reinterpret_cast<PyRate*>(
298 PyCapsule_GetPointer(pyobj_rate, "apollo_cybertron_pyrate"));
299 if (nullptr == pyrate) {
300 AERROR << "cyber_PyRate_get_expected_cycle_time:rate ptr is null!";
301 return PyLong_FromUnsignedLongLong(0);
302 }
303 uint64_t exp_cycle_time = pyrate->get_expected_cycle_time();
304 return PyLong_FromUnsignedLongLong(exp_cycle_time);
305}

◆ cyber_PyRate_reset()

PyObject * cyber_PyRate_reset ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 251 行定义.

251 {
252 PyObject* pyobj_rate = nullptr;
253 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_PyRate_reset"),
254 &pyobj_rate)) {
255 Py_INCREF(Py_None);
256 return Py_None;
257 }
258
259 auto* pyrate = reinterpret_cast<PyRate*>(
260 PyCapsule_GetPointer(pyobj_rate, "apollo_cybertron_pyrate"));
261 if (nullptr == pyrate) {
262 AERROR << "cyber_PyRate_reset:rate ptr is null!";
263 Py_INCREF(Py_None);
264 return Py_None;
265 }
266 pyrate->reset();
267 Py_INCREF(Py_None);
268 return Py_None;
269}

◆ cyber_PyRate_sleep()

PyObject * cyber_PyRate_sleep ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 231 行定义.

231 {
232 PyObject* pyobj_rate = nullptr;
233 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_PyRate_sleep"),
234 &pyobj_rate)) {
235 Py_INCREF(Py_None);
236 return Py_None;
237 }
238
239 auto* pyrate = reinterpret_cast<PyRate*>(
240 PyCapsule_GetPointer(pyobj_rate, "apollo_cybertron_pyrate"));
241 if (nullptr == pyrate) {
242 AERROR << "cyber_PyRate_sleep:rate ptr is null!";
243 Py_INCREF(Py_None);
244 return Py_None;
245 }
246 pyrate->sleep();
247 Py_INCREF(Py_None);
248 return Py_None;
249}

◆ cyber_PyTime_mono_time()

PyObject * cyber_PyTime_mono_time ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 138 行定义.

138 {
139 PyTime mono_time = PyTime::mono_time();
140 return PyLong_FromUnsignedLongLong(mono_time.to_nsec());
141}
uint64_t to_nsec() const
Definition py_time.h:54
static PyTime mono_time()
Definition py_time.h:42

◆ cyber_PyTime_now()

PyObject * cyber_PyTime_now ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 133 行定义.

133 {
134 PyTime now = PyTime::now();
135 return PyLong_FromUnsignedLongLong(now.to_nsec());
136}
static PyTime now()
Definition py_time.h:36

◆ cyber_PyTime_sleep_until()

PyObject * cyber_PyTime_sleep_until ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 110 行定义.

110 {
111 PyObject* pyobj_time = nullptr;
112 uint64_t nanoseconds = 0;
113 if (!PyArg_ParseTuple(args, const_cast<char*>("OK:cyber_PyTime_sleep_until"),
114 &pyobj_time, &nanoseconds)) {
115 AERROR << "cyber_PyTime_sleep_until:PyArg_ParseTuple failed!";
116 Py_INCREF(Py_None);
117 return Py_None;
118 }
119
120 auto* pytime = reinterpret_cast<PyTime*>(
121 PyCapsule_GetPointer(pyobj_time, "apollo_cybertron_pytime"));
122 if (nullptr == pytime) {
123 AERROR << "cyber_PyTime_sleep_until ptr is null!";
124 Py_INCREF(Py_None);
125 return Py_None;
126 }
127
128 pytime->sleep_until(nanoseconds);
129 Py_INCREF(Py_None);
130 return Py_None;
131}

◆ cyber_PyTime_to_nsec()

PyObject * cyber_PyTime_to_nsec ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 91 行定义.

91 {
92 PyObject* pyobj_time = nullptr;
93 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_PyTime_to_nsec"),
94 &pyobj_time)) {
95 AERROR << "cyber_PyTime_to_nsec:PyArg_ParseTuple failed!";
96 return PyLong_FromUnsignedLongLong(0);
97 }
98
99 auto* pytime = reinterpret_cast<PyTime*>(
100 PyCapsule_GetPointer(pyobj_time, "apollo_cybertron_pytime"));
101 if (nullptr == pytime) {
102 AERROR << "cyber_PyTime_to_nsec ptr is null!";
103 return PyLong_FromUnsignedLongLong(0);
104 }
105
106 uint64_t num = pytime->to_nsec();
107 return PyLong_FromUnsignedLongLong(num);
108}

◆ cyber_PyTime_to_sec()

PyObject * cyber_PyTime_to_sec ( PyObject *  self,
PyObject *  args 
)

在文件 py_time.cc 第 72 行定义.

72 {
73 PyObject* pyobj_time = nullptr;
74 if (!PyArg_ParseTuple(args, const_cast<char*>("O:cyber_PyTime_to_sec"),
75 &pyobj_time)) {
76 AERROR << "cyber_PyTime_to_sec:PyArg_ParseTuple failed!";
77 return PyFloat_FromDouble(0);
78 }
79
80 auto* pytime = reinterpret_cast<PyTime*>(
81 PyCapsule_GetPointer(pyobj_time, "apollo_cybertron_pytime"));
82 if (nullptr == pytime) {
83 AERROR << "cyber_PyTime_to_sec ptr is null!";
84 return PyFloat_FromDouble(0);
85 }
86
87 double num = pytime->to_sec();
88 return PyFloat_FromDouble(num);
89}

◆ PyInit__cyber_time_wrapper()

PyMODINIT_FUNC PyInit__cyber_time_wrapper ( void  )

Init function of this module

在文件 py_time.cc 第 335 行定义.

335 {
336 static struct PyModuleDef module_def = {
337 PyModuleDef_HEAD_INIT,
338 "_cyber_time_wrapper", // Module name.
339 "CyberTime module", // Module doc.
340 -1, // Module size.
341 _cyber_time_methods, // Module methods.
342 nullptr,
343 nullptr,
344 nullptr,
345 nullptr,
346 };
347
348 return PyModule_Create(&module_def);
349}

◆ PyObjectToPtr()

template<typename T >
T PyObjectToPtr ( PyObject *  pyobj,
const std::string &  type_ptr 
)

在文件 py_time.cc 第 31 行定义.

31 {
32 T obj_ptr = (T)PyCapsule_GetPointer(pyobj, type_ptr.c_str());
33 if (obj_ptr == nullptr) {
34 AERROR << "PyObjectToPtr failed,type->" << type_ptr << "pyobj: " << pyobj;
35 }
36 return obj_ptr;
37}