• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.14
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    Node.hpp
    Go to the documentation of this file.
    1
    2//
    3// Notice
    4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
    5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
    7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
    8//
    9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
    10// information or for any infringement of patents or other rights of third parties that may
    11// result from its use. No license is granted by implication or otherwise under any patent
    12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
    13// expressly authorized by NVIDIA. Details are subject to change without notice.
    14// This code supersedes and replaces all information previously supplied.
    15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
    16// components in life support devices or systems without express written approval of
    17// NVIDIA CORPORATION & AFFILIATES.
    18//
    19// SPDX-FileCopyrightText: Copyright (c) 2017-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
    20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
    21//
    22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
    23// property and proprietary rights in and to this material, related
    24// documentation and any modifications thereto. Any use, reproduction,
    25// disclosure or distribution of this material and related documentation
    26// without an express license agreement from NVIDIA CORPORATION or
    27// its affiliates is strictly prohibited.
    28//
    30
    31#ifndef DW_FRAMEWORK_BASECLASS_NODE_HPP_
    32#define DW_FRAMEWORK_BASECLASS_NODE_HPP_
    33
    34#include <map>
    35
    36#include <dw/core/base/Types.h>
    37#include <dw/core/context/ObjectExtra.h>
    38
    39#include <dwcgf/Types.hpp>
    41#include <dwcgf/pass/Pass.hpp>
    42#include <dwshared/dwfoundation/dw/core/logger/Logger.hpp>
    44#include <dwshared/dwfoundation/dw/core/container/VectorFixed.hpp>
    45#include <dwshared/dwfoundation/dw/core/container/BaseString.hpp>
    46#include <dwcgf/port/Port.hpp>
    47
    48#include <string>
    49#include <memory>
    50#include <atomic>
    51
    52namespace dw
    53{
    54namespace framework
    55{
    56using dw::core::FixedString;
    57using dw::core::VectorFixed;
    58// coverity[autosar_cpp14_a0_1_6_violation]
    59class ParameterProvider;
    60
    61#define DW_CGF_STRINGIFY(x) #x
    62// std::char_traits<char8_t>::length() is not constexpr before C++17, use "sizeof() - 1" as WAR
    63#define STRING_VIEW_OF_FIXED_STRING_TEMPLATE_TYPE(x) dw::core::StringView("dw::core::FixedString<" DW_CGF_STRINGIFY(x) ">", sizeof("dw::core::FixedString<" DW_CGF_STRINGIFY(x) ">") - 1)
    64
    65class Node
    66{
    67public:
    68 // coverity[autosar_cpp14_a0_1_1_violation] FP: nvbugs/2813925
    69 // coverity[autosar_cpp14_a5_1_1_violation] FP: nvbugs/4020293
    70 // coverity[autosar_cpp14_m0_1_4_violation] FP: nvbugs/2813925
    71 static constexpr const size_t MAX_NAME_LEN{128U};
    72
    73 virtual ~Node() = default;
    74
    79 virtual dwStatus reset() = 0;
    80
    87 virtual dwStatus setInputChannel(ChannelObject* channel, uint8_t portID) = 0;
    88
    95 virtual dwStatus setOutputChannel(ChannelObject* channel, uint8_t portID) = 0;
    96
    106 virtual dwStatus validate() = 0;
    107
    112 virtual dwStatus run() = 0;
    113
    118 virtual size_t getPassCount() const noexcept = 0;
    119
    125 virtual dwStatus runPass(size_t passIndex) = 0;
    126
    135 virtual dwStatus getPass(Pass** pass, uint8_t index) = 0;
    136
    142 // coverity[autosar_cpp14_a2_10_5_violation] RFD Pending: TID-2053
    143 virtual dwStatus getPasses(VectorFixed<Pass*>& passList) = 0;
    144
    151 // coverity[autosar_cpp14_a2_10_5_violation] RFD Pending: TID-2053
    152 virtual dwStatus getPasses(VectorFixed<Pass*>& passList,
    153 dwProcessorType processorType) = 0;
    154
    160 virtual dwStatus setName(const char* name) = 0;
    161
    167 virtual dwStatus getName(const char** name) = 0;
    168
    176 virtual dwStatus collectErrorSignals(dwGraphErrorSignal*& errorSignal, bool updateFromModule = true) = 0;
    177
    183 virtual dwStatus getModuleErrorSignal(dwErrorSignal& errorSignal) = 0; // Will Be Deprecated upon completion of PRC2 refactor
    184
    190 virtual dwStatus getNodeErrorSignal(dwGraphErrorSignal& errorSignal) = 0; // Will Be Deprecated upon completion of PRC2 refactor
    191
    199 virtual dwStatus collectHealthSignals(dwGraphHealthSignal*& healthSignal, bool updateFromModule = false) = 0;
    200
    206 virtual dwStatus getModuleHealthSignal(dwHealthSignal& healthSignal) = 0; // Will Be Deprecated upon completion of PRC2 refactor
    207
    213 virtual dwStatus getNodeHealthSignal(dwGraphHealthSignal& healthSignal) = 0; // Will Be Deprecated upon completion of PRC2 refactor
    214
    219 virtual dwStatus clearErrorSignal() = 0;
    220
    225 virtual dwStatus clearHealthSignal() = 0;
    226
    235 virtual dwStatus updateCurrentErrorSignal(dwGraphErrorSignal& signal) = 0; // Will Be Deprecated upon completion of PRC2 refactor
    236
    245 virtual dwStatus updateCurrentHealthSignal(dwGraphHealthSignal& signal) = 0; // Will Be Deprecated upon completion of PRC2 refactor
    246
    253 virtual dwStatus addToErrorSignal(uint32_t error, dwTime_t timestamp = 0UL) = 0;
    254
    261 virtual dwStatus addToHealthSignal(uint32_t error, dwTime_t timestamp = 0UL) = 0;
    262
    268 virtual dwStatus setIterationCount(uint32_t iterationCount) = 0;
    269
    277 virtual dwStatus setState(const char* state) = 0;
    278
    284 virtual dwStatus setNodePeriod(uint32_t period) = 0;
    285
    289 virtual void resetPorts() = 0;
    290
    297 virtual dwStatus getInputChannel(const uint8_t portID, ChannelObject*& channel) const = 0;
    298
    305 virtual dwStatus getOutputChannel(const uint8_t portID, ChannelObject*& channel) const = 0;
    306
    314 virtual dwStatus getInputPort(const uint8_t portID, dw::framework::PortBase*& port) const = 0;
    315
    323 virtual dwStatus getOutputPort(const uint8_t portID, dw::framework::PortBase*& port) const = 0;
    324};
    325
    327{
    328public:
    333 virtual dwStatus start() = 0;
    334
    339 virtual dwStatus stop() = 0;
    340
    345 virtual dwStatus setAffinityMask(uint) = 0;
    346
    351 virtual dwStatus setThreadPriority(int) = 0;
    352
    357 virtual dwStatus setStartTime(dwTime_t) = 0;
    358
    363 virtual dwStatus setEndTime(dwTime_t) = 0;
    364
    369 virtual dwStatus isVirtual(bool* isVirtualBool) = 0;
    370
    371 enum class DataEventType
    372 {
    373 PRODUCE, // sensor node produces data for a node-run
    374 DROP, // sensor node drops data in the next node-run
    375 NONE, // sensor node does not produce data for a node-run
    376 };
    377
    382 {
    394 dwStatus status;
    399 dwTime_t timestamp;
    400 };
    401
    402 using DataEventReadCallback = dw::core::Function<bool(DataEvent&)>;
    410
    411 using DataEventWriteCallback = dw::core::Function<void(DataEvent)>;
    419
    427 virtual dwStatus setLockstepDeterministicMode(bool enable) = 0;
    428
    434 virtual dwStatus getNextTimestamp(dwTime_t& nextTimestamp) = 0;
    435
    441 virtual dwStatus isEnabled(bool& isEnabled) = 0;
    442};
    443
    445{
    446public:
    448 : m_node(node)
    449 , m_sensorNode(dynamic_cast<ISensorNode*>(node))
    450 {
    451 if (m_sensorNode != nullptr)
    452 {
    453 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Passed node pointer does not implement ISensorNode.");
    454 }
    455 }
    456
    458 {
    459 return m_node;
    460 }
    461
    462 Node const* getNode() const
    463 {
    464 return m_node;
    465 }
    466
    468 {
    469 return m_sensorNode;
    470 }
    471
    473 {
    474 return m_sensorNode;
    475 }
    476
    477private:
    478 Node* m_node{};
    479 ISensorNode* m_sensorNode{};
    480};
    481
    489// coverity[autosar_cpp14_a0_1_6_violation]
    491{
    492public:
    493 virtual ~IContainsPreShutdownAction() = default;
    494
    499 virtual dwStatus preShutdown() = 0;
    500};
    501
    502// TODO(ajayawardane) WAR: When there is a single SSM pass in the graph, reset could potentially
    503// be called while node passes are running. Until STM schedule re-entry is supported, we reset the
    504// supported nodes in the setup pass.
    505// deprecated and Replaced by IResetable, which has an improved reset interface
    506// coverity[autosar_cpp14_a0_1_6_violation]
    508{
    509public:
    510 virtual ~IAsyncResetable() = default;
    511
    516 virtual dwStatus setAsyncReset() = 0;
    521 virtual dwStatus executeAsyncReset() = 0;
    522};
    523
    528// coverity[autosar_cpp14_a0_1_6_violation]
    530{
    531public:
    532 virtual ~IChannelsConnectedListener() = default;
    533
    537 virtual void onChannelsConnected() = 0;
    538};
    539
    544// coverity[autosar_cpp14_a0_1_6_violation]
    546{
    547public:
    548 virtual ~IResetable() = default;
    549
    554 virtual dwStatus reset() = 0;
    555};
    556
    559
    560} // namespace framework
    561} // namespace dw
    562
    564
    565#endif // DW_FRAMEWORK_BASECLASS_NODE_HPP_
    Basic error signal that gets reported only when there is an error.
    Basic health signal that describes the health status of the graph.
    virtual dwStatus setAsyncReset()=0
    Set the async reset flag.
    virtual dwStatus executeAsyncReset()=0
    Executes a reset if the async reset flag is set.
    virtual ~IAsyncResetable()=default
    virtual void onChannelsConnected()=0
    Callback received after channels are connected.
    virtual dwStatus preShutdown()=0
    actions to be taken before node shutdown
    virtual dwStatus reset()=0
    Executes reset of the node.
    virtual ~IResetable()=default
    virtual dwStatus setAffinityMask(uint)=0
    Sets the affinity mask of the sensor.
    virtual dwStatus setLockstepDeterministicMode(bool enable)=0
    Set whether replay is running in lockstep deterministic mode.
    virtual dwStatus setDataEventReadCallback(DataEventReadCallback cb)=0
    Set read timestamp function for dataset replay. Timestamps not in the sequence returned by the callba...
    virtual dwStatus setDataEventWriteCallback(DataEventWriteCallback cb)=0
    Set write timestamp function for live case. Each timestamp of data output from the node will be passe...
    virtual dwStatus start()=0
    Start the sensor.
    virtual dwStatus setEndTime(dwTime_t)=0
    Set end timestamp for dataset replay.
    dw::core::Function< bool(DataEvent &)> DataEventReadCallback
    Definition: Node.hpp:402
    virtual dwStatus isEnabled(bool &isEnabled)=0
    Whether or not the node is enabled.
    virtual dwStatus stop()=0
    Stop the sensor.
    virtual dwStatus isVirtual(bool *isVirtualBool)=0
    distinguishes between a live and virtual sensor
    virtual dwStatus getNextTimestamp(dwTime_t &nextTimestamp)=0
    Get the next timestamp of the sensor.
    dw::core::Function< void(DataEvent)> DataEventWriteCallback
    Definition: Node.hpp:411
    virtual dwStatus setThreadPriority(int)=0
    Sets the thread priority of the sensor.
    virtual dwStatus setStartTime(dwTime_t)=0
    Set start timestamp for dataset replay.
    virtual dwStatus addToHealthSignal(uint32_t error, dwTime_t timestamp=0UL)=0
    A function the allows user to add an error to the health signal list.
    virtual dwStatus getModuleHealthSignal(dwHealthSignal &healthSignal)=0
    Return a copy of health signals from module that is a member of node.
    virtual dwStatus validate()=0
    Checks that all mandatory ports are bound. The implementation should validate that all the ports are ...
    virtual dwStatus setNodePeriod(uint32_t period)=0
    Set the node's period.
    virtual dwStatus collectErrorSignals(dwGraphErrorSignal *&errorSignal, bool updateFromModule=true)=0
    Collect error signals from node and module, combine and return the pointer to the error signal for th...
    virtual dwStatus setOutputChannel(ChannelObject *channel, uint8_t portID)=0
    Sets an output channel for this node with an accompanying port.
    virtual dwStatus collectHealthSignals(dwGraphHealthSignal *&healthSignal, bool updateFromModule=false)=0
    Collect health signals from node and module, combine and return the pointer to the health signal for ...
    virtual dwStatus getInputPort(const uint8_t portID, dw::framework::PortBase *&port) const =0
    Gets the input port associated with the port id.
    virtual dwStatus runPass(size_t passIndex)=0
    Run one pass by index as defined by the pass descriptors.
    virtual dwStatus setInputChannel(ChannelObject *channel, uint8_t portID)=0
    Sets an input channel for this node with an accompanying port.
    virtual dwStatus getInputChannel(const uint8_t portID, ChannelObject *&channel) const =0
    Gets the input channel associated with the input port.
    virtual dwStatus run()=0
    Runs all the passes in the node.
    virtual ~Node()=default
    virtual dwStatus getPass(Pass **pass, uint8_t index)=0
    Get a const pointer to the pass at a specific index.
    virtual size_t getPassCount() const noexcept=0
    Get number of passes in the node.
    virtual dwStatus setIterationCount(uint32_t iterationCount)=0
    Sets the node's iteration count.
    virtual dwStatus getNodeErrorSignal(dwGraphErrorSignal &errorSignal)=0
    Get a copy of the error signals for the node.
    virtual dwStatus addToErrorSignal(uint32_t error, dwTime_t timestamp=0UL)=0
    A function the allows user to add an error to the error signal list.
    virtual dwStatus getModuleErrorSignal(dwErrorSignal &errorSignal)=0
    Get a copy of the error signals from the module that is a member of this node.
    virtual dwStatus updateCurrentHealthSignal(dwGraphHealthSignal &signal)=0
    A function that allows user override to update health signal It is automatically called by dwFramewor...
    virtual void resetPorts()=0
    Resets all the ports in the node.
    virtual dwStatus getPasses(VectorFixed< Pass * > &passList)=0
    Get all the passes in the node.
    virtual dwStatus setName(const char *name)=0
    Set the name of the node.
    virtual dwStatus getOutputPort(const uint8_t portID, dw::framework::PortBase *&port) const =0
    Gets the output port associated with the port id.
    virtual dwStatus getNodeHealthSignal(dwGraphHealthSignal &healthSignal)=0
    Return a copy of graph health signals for the node.
    virtual dwStatus getName(const char **name)=0
    Get the name of the node.
    static constexpr const size_t MAX_NAME_LEN
    Definition: Node.hpp:71
    virtual dwStatus updateCurrentErrorSignal(dwGraphErrorSignal &signal)=0
    A function that allows user override to update error signal It is automatically called by dwFramework...
    virtual dwStatus clearHealthSignal()=0
    Clear the health signal for this node.
    virtual dwStatus clearErrorSignal()=0
    Clear the error signal for this node.
    virtual dwStatus reset()=0
    Resets the state of the node.
    virtual dwStatus getOutputChannel(const uint8_t portID, ChannelObject *&channel) const =0
    Gets the output channel associated with the output port.
    virtual dwStatus setState(const char *state)=0
    Set the current state in node. Node implementation of this API need to be thread-safe.
    Pass is a runnable describes the metadata of a pass.
    Definition: Pass.hpp:49
    SensorNode(Node *node)
    Definition: Node.hpp:447
    Node const * getNode() const
    Definition: Node.hpp:462
    ISensorNode * getSensorNode()
    Definition: Node.hpp:467
    ISensorNode const * getSensorNode() const
    Definition: Node.hpp:472
    constexpr size_t passIndex(dw::core::StringView identifier)
    Get the the pass index for a pass identified by name.
    Definition: Buffer.hpp:40
    人人超碰97caoporen国产