• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.8
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    dwChannelDrainerTemplate.hpp
    Go to the documentation of this file.
    1
    2// This code contains NVIDIA Confidential Information and is disclosed
    3// under the Mutual Non-Disclosure Agreement.
    4//
    5// Notice
    6// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
    7// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    8// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
    9// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
    10//
    11// NVIDIA Corporation assumes no responsibility for the consequences of use of such
    12// information or for any infringement of patents or other rights of third parties that may
    13// result from its use. No license is granted by implication or otherwise under any patent
    14// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
    15// expressly authorized by NVIDIA. Details are subject to change without notice.
    16// This code supersedes and replaces all information previously supplied.
    17// NVIDIA Corporation products are not authorized for use as critical
    18// components in life support devices or systems without express written approval of
    19// NVIDIA Corporation.
    20//
    21// Copyright (c) 2020-2022 NVIDIA Corporation. All rights reserved.
    22//
    23// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
    24// rights in and to this software and related documentation and any modifications thereto.
    25// Any use, reproduction, disclosure or distribution of this software and related
    26// documentation without an express license agreement from NVIDIA Corporation is
    27// strictly prohibited.
    28//
    30#ifndef DW_FRAMEWORK_CHANNEL_DRAINER_TEMPLATE_HPP_
    31#define DW_FRAMEWORK_CHANNEL_DRAINER_TEMPLATE_HPP_
    32
    33#include <dw/sensors/Sensors.h>
    34#include <dw/sensors/radar/Radar.h>
    35#include <dw/sensors/canbus/CAN.h>
    36#include <dw/core/base/Types.h>
    37
    38#include <dwcgf/Exception.hpp>
    39#include <dwcgf/node/Node.hpp>
    41
    42#include <unistd.h>
    43#include <memory>
    44
    46#include <dwcgf/port/Port.hpp>
    47
    48namespace dw
    49{
    50namespace framework
    51{
    52
    53template <typename OutputProcessedDataType, typename InputProcessedDataType = OutputProcessedDataType>
    55{
    57 std::shared_ptr<InputProcessedDataType> m_nextDataEvent = nullptr;
    58
    59 virtual dwStatus readNextData(dwTime_t inTimeout_us, InputDataPort inputPort)
    60 {
    61
    62 if (!inputPort->isBound())
    63 {
    64 return DW_NOT_AVAILABLE;
    65 }
    66
    67 if (inputPort->wait(inTimeout_us) == DW_SUCCESS)
    68 {
    69 m_nextDataEvent = inputPort->recv();
    70 return DW_SUCCESS;
    71 }
    72
    73 return DW_TIME_OUT;
    74 }
    75
    76 virtual dwStatus getNextDataTimestamp(dwTime_t& outTimestamp) = 0;
    77
    78 virtual dwStatus getNextData(OutputProcessedDataType* outDataFrame, InputDataPort) = 0;
    79
    80 dwStatus reset()
    81 {
    82 m_nextDataEvent = nullptr;
    83 return DW_SUCCESS;
    84 }
    85};
    86
    87template <typename OutputProcessedDataType, typename ReadProcessedDataFunc, typename InputProcessedDataType = OutputProcessedDataType>
    88class dwChannelDrainerTemplate : public dwBaseDrainerTemplate<OutputProcessedDataType, ReadProcessedDataFunc, PortInput<InputProcessedDataType>*>
    89{
    91
    92public:
    93 static constexpr char LOG_TAG[] = "dwChannelDrainerTemplate";
    94
    95 explicit dwChannelDrainerTemplate(dwSensorDrainerParams params, std::unique_ptr<ReadProcessedDataFunc> readProcessedDataFunc, InputDataPort inputPort)
    96 : dwBaseDrainerTemplate<OutputProcessedDataType, ReadProcessedDataFunc, InputDataPort>(params, std::move(readProcessedDataFunc), inputPort)
    97 {
    98 }
    99
    100 virtual ~dwChannelDrainerTemplate() = default;
    101
    102 virtual dwStatus reset() override
    103 {
    104 this->m_virtualSyncTime = 0;
    105 this->m_nextDataReady = false;
    106 return DW_SUCCESS;
    107 }
    108
    109 // [out] outFrame output sensor frame
    110 // [in/out] latestTimestamp timestamp associated with the sensor frame
    111 // [in] timeout sensor reading timeout in microseconds
    112 // [in] isDroppingData indicates if data is being dropped
    113 dwStatus readProcessedData(OutputProcessedDataType* outFrame,
    114 dwTime_t& latestTimestamp,
    115 dwTime_t timeout,
    116 bool isDroppingData = false) override
    117 {
    118 return dwBaseDrainerTemplate<OutputProcessedDataType, ReadProcessedDataFunc, InputDataPort>::tryRead(outFrame, latestTimestamp, timeout, isDroppingData);
    119 }
    120};
    121
    122template <typename OutputProcessedDataType, typename ReadProcessedDataFunc, typename InputProcessedDataType>
    124} // namespace framework
    125} // namespace dw
    126
    127#endif // DW_FRAMEWORK_CHANNEL_DRAINER_TEMPLATE_HPP_
    virtual std::shared_ptr< T > recv()
    Definition: Port.hpp:407
    dwStatus wait(dwTime_t timeout)
    Definition: Port.hpp:373
    bool isBound() override
    Definition: Port.hpp:358
    virtual dwStatus tryRead(ProcessedDataType *outFrame, dwTime_t &latestTimestamp, dwTime_t timeout, bool isDroppingData=false)
    dwStatus readProcessedData(OutputProcessedDataType *outFrame, dwTime_t &latestTimestamp, dwTime_t timeout, bool isDroppingData=false) override
    dwChannelDrainerTemplate(dwSensorDrainerParams params, std::unique_ptr< ReadProcessedDataFunc > readProcessedDataFunc, InputDataPort inputPort)
    Definition: Exception.hpp:47
    virtual dwStatus getNextDataTimestamp(dwTime_t &outTimestamp)=0
    virtual dwStatus readNextData(dwTime_t inTimeout_us, InputDataPort inputPort)
    std::shared_ptr< InputProcessedDataType > m_nextDataEvent
    virtual dwStatus getNextData(OutputProcessedDataType *outDataFrame, InputDataPort)=0
    人人超碰97caoporen国产