Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CaptureFb final : public daq::asam_cmp_common_lib::CaptureCommonFb
std::shared_ptr<asam_cmp_common_lib::EthernetPcppItf> ethernetWrapper;
const StringPtr& selectedEthernetDeviceName;
DevicePtr parentDevice;
bool useParentDomain;
};

END_NAMESPACE_ASAM_CMP_CAPTURE_MODULE
16 changes: 12 additions & 4 deletions modules/asam_cmp_capture_module/src/capture_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CaptureFb::CaptureFb(const ModuleInfoPtr& moduleInfo,
, ethernetWrapper(init.ethernetWrapper)
, selectedEthernetDeviceName(init.selectedDeviceName)
, parentDevice(FindParentDevice(parent))
, useParentDomain(parentDevice.assigned() && parentDevice.getDomain().assigned())
{
initStatusPacket();
initProperties();
Expand Down Expand Up @@ -110,20 +111,27 @@ ASAM::CMP::DataContext CaptureFb::createEncoderDataContext() const

uint64_t CaptureFb::getCurrentSystemTime()
{
if (!parentDevice.assigned())
if (!useParentDomain)
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count();

DeviceDomainPtr domain = parentDevice.getDomain();

const auto domainResolution = domain.getTickResolution();
return static_cast<Int>(parentDevice.getTicksSinceOrigin()) * (SimplifiedRatioPtr(domainResolution) * NanoTicksPerSec);
}

DevicePtr CaptureFb::FindParentDevice(const ComponentPtr& parent)
{
auto parentDevice = parent;
while (parentDevice.assigned() && !parentDevice.asPtrOrNull<IDevice>().assigned())
parentDevice = parentDevice.getParent();
DevicePtr parentDevice = nullptr;
auto parentComponent = parent.asPtrOrNull<IComponent>();
while (parentComponent.assigned())
{
auto tempDevice = parentComponent.asPtrOrNull<IDevice>();
if (tempDevice.assigned())
parentDevice = std::move(tempDevice);

parentComponent = parentComponent.getParent();
}
return parentDevice;
}

Expand Down
Loading