CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderPlatformTime.cpp
浏览该文件的文档.
1
// Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#include "
CarlaRecorderPlatformTime.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
void
CarlaRecorderPlatformTime::SetStartTime
()
12
{
13
RecorderStartTime
= std::chrono::system_clock::now();
14
}
15
void
CarlaRecorderPlatformTime::UpdateTime
()
16
{
17
auto
CurrentTime = std::chrono::system_clock::now();
18
auto
diff = std::chrono::duration_cast<std::chrono::microseconds>
19
(CurrentTime-
RecorderStartTime
).count();
20
Time
= diff/1000000.0;
21
}
22
23
void
CarlaRecorderPlatformTime::Read
(std::istream &InFile)
24
{
25
ReadValue<double>(InFile, this->
Time
);
26
}
27
28
void
CarlaRecorderPlatformTime::Write
(std::ostream &OutFile)
29
{
30
// write the packet id
31
WriteValue<char>(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::PlatformTime
));
32
33
// write packet size
34
uint32_t Total =
sizeof
(double);
35
WriteValue<uint32_t>(OutFile, Total);
36
37
WriteValue<double>(OutFile, this->
Time
);
38
}
CarlaRecorderHelpers.h
CarlaRecorderPlatformTime.h
CarlaRecorder.h
CarlaRecorderPacketId::PlatformTime
@ PlatformTime
CarlaRecorderPlatformTime::Time
double Time
Definition
CarlaRecorderPlatformTime.h:19
CarlaRecorderPlatformTime::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderPlatformTime.cpp:28
CarlaRecorderPlatformTime::RecorderStartTime
std::chrono::time_point< std::chrono::system_clock > RecorderStartTime
Definition
CarlaRecorderPlatformTime.h:17
CarlaRecorderPlatformTime::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderPlatformTime.cpp:23
CarlaRecorderPlatformTime::SetStartTime
void SetStartTime()
Definition
CarlaRecorderPlatformTime.cpp:11
CarlaRecorderPlatformTime::UpdateTime
void UpdateTime()
Definition
CarlaRecorderPlatformTime.cpp:15
制作者
1.10.0