PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::cyclic::CyclicStats Struct Reference

Statistics for cyclic communication. More...

#include <cyclic.h>

+ Collaboration diagram for profinet::cyclic::CyclicStats:

Public Member Functions

std::uint64_t AvgCycleTimeUs () const
 Compute the average TX cycle duration.
 
void Reset ()
 Reset all counters to their initial values.
 

Public Attributes

std::atomic< std::uint64_t > framesSent {0}
 Total number of output frames sent.
 
std::atomic< std::uint64_t > framesReceived {0}
 Total number of input frames received.
 
std::atomic< std::uint64_t > framesMissed {0}
 Total number of watchdog timeouts (missed input frames).
 
std::atomic< std::uint64_t > framesInvalid {0}
 Total number of frames rejected for having an invalid DataStatus.
 
std::atomic< std::uint64_t > framesDuplicate {0}
 Total number of duplicate (repeated cycle counter) frames received.
 
std::atomic< std::uint64_t > framesOutOfOrder {0}
 Total number of frames received out of cycle-counter order.
 
std::atomic< std::uint32_t > lastCycleTimeUs {0}
 Duration of the most recently completed TX cycle, in microseconds.
 
std::atomic< std::uint32_t > maxJitterUs {0}
 Largest observed deviation from the target cycle time, in microseconds.
 
std::atomic< std::uint32_t > minCycleTimeUs {0x7FFFFFFF}
 Smallest observed TX cycle duration, in microseconds.
 
std::atomic< std::uint32_t > maxCycleTimeUs {0}
 Largest observed TX cycle duration, in microseconds.
 
std::atomic< std::chrono::steady_clock::time_point > lastReceiveTime {std::chrono::steady_clock::now()}
 Timestamp of the last received input frame (or watchdog check).
 
std::atomic< int > consecutiveTimeouts {0}
 Current run of consecutive watchdog timeouts (resets on a good frame).
 
std::atomic< std::uint64_t > cycleTimeSumUs {0}
 Running sum of observed TX cycle durations, in microseconds.
 
std::atomic< std::uint64_t > cycleCount {0}
 Number of TX cycles included in CycleTimeSumUs.
 

Detailed Description

Statistics for cyclic communication.

Counters are updated from both the TX and RX threads without a lock – like the Python original, these are advisory statistics where occasional torn reads are acceptable; individual counter increments use relaxed atomics.

Definition at line 64 of file cyclic.h.

Member Function Documentation

◆ AvgCycleTimeUs()

std::uint64_t profinet::cyclic::CyclicStats::AvgCycleTimeUs ( ) const
inline

Compute the average TX cycle duration.

Returns
The average cycle duration in microseconds, or 0 if no cycles have completed.

Definition at line 110 of file cyclic.h.

References cycleCount, and cycleTimeSumUs.

◆ Reset()

void profinet::cyclic::CyclicStats::Reset ( )

Reset all counters to their initial values.

Definition at line 42 of file cyclic.cpp.

References consecutiveTimeouts, cycleCount, cycleTimeSumUs, framesDuplicate, framesInvalid, framesMissed, framesOutOfOrder, framesReceived, framesSent, lastCycleTimeUs, lastReceiveTime, maxCycleTimeUs, maxJitterUs, and minCycleTimeUs.

Referenced by profinet::cyclic::CyclicController::Start().

+ Here is the caller graph for this function:

Member Data Documentation

◆ consecutiveTimeouts

std::atomic<int> profinet::cyclic::CyclicStats::consecutiveTimeouts {0}

Current run of consecutive watchdog timeouts (resets on a good frame).

Definition at line 100 of file cyclic.h.

Referenced by profinet::cyclic::CyclicController::HandleWatchdogTimeout(), profinet::cyclic::CyclicController::ProcessInputFrame(), Reset(), and profinet::cyclic::CyclicController::StatsSnapshot().

◆ cycleCount

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::cycleCount {0}

Number of TX cycles included in CycleTimeSumUs.

Definition at line 106 of file cyclic.h.

Referenced by AvgCycleTimeUs(), Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TxLoop().

◆ cycleTimeSumUs

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::cycleTimeSumUs {0}

Running sum of observed TX cycle durations, in microseconds.

Definition at line 103 of file cyclic.h.

Referenced by AvgCycleTimeUs(), Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TxLoop().

◆ framesDuplicate

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::framesDuplicate {0}

Total number of duplicate (repeated cycle counter) frames received.

Definition at line 79 of file cyclic.h.

Referenced by Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TrackCycleCounter().

◆ framesInvalid

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::framesInvalid {0}

Total number of frames rejected for having an invalid DataStatus.

Definition at line 76 of file cyclic.h.

Referenced by profinet::cyclic::CyclicController::ProcessInputFrame(), Reset(), and profinet::cyclic::CyclicController::StatsSnapshot().

◆ framesMissed

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::framesMissed {0}

◆ framesOutOfOrder

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::framesOutOfOrder {0}

Total number of frames received out of cycle-counter order.

Definition at line 82 of file cyclic.h.

Referenced by Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TrackCycleCounter().

◆ framesReceived

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::framesReceived {0}

Total number of input frames received.

Definition at line 70 of file cyclic.h.

Referenced by profinet::cyclic::CyclicController::ProcessInputFrame(), Reset(), and profinet::cyclic::CyclicController::StatsSnapshot().

◆ framesSent

std::atomic<std::uint64_t> profinet::cyclic::CyclicStats::framesSent {0}

◆ lastCycleTimeUs

std::atomic<std::uint32_t> profinet::cyclic::CyclicStats::lastCycleTimeUs {0}

Duration of the most recently completed TX cycle, in microseconds.

Definition at line 85 of file cyclic.h.

Referenced by Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TxLoop().

◆ lastReceiveTime

std::atomic<std::chrono::steady_clock::time_point> profinet::cyclic::CyclicStats::lastReceiveTime {std::chrono::steady_clock::now()}

Timestamp of the last received input frame (or watchdog check).

Definition at line 97 of file cyclic.h.

Referenced by profinet::cyclic::CyclicController::ProcessInputFrame(), Reset(), profinet::cyclic::CyclicController::RxLoop(), and profinet::cyclic::CyclicController::StatsSnapshot().

◆ maxCycleTimeUs

std::atomic<std::uint32_t> profinet::cyclic::CyclicStats::maxCycleTimeUs {0}

Largest observed TX cycle duration, in microseconds.

Definition at line 94 of file cyclic.h.

Referenced by Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TxLoop().

◆ maxJitterUs

std::atomic<std::uint32_t> profinet::cyclic::CyclicStats::maxJitterUs {0}

Largest observed deviation from the target cycle time, in microseconds.

Definition at line 88 of file cyclic.h.

Referenced by Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TxLoop().

◆ minCycleTimeUs

std::atomic<std::uint32_t> profinet::cyclic::CyclicStats::minCycleTimeUs {0x7FFFFFFF}

Smallest observed TX cycle duration, in microseconds.

Definition at line 91 of file cyclic.h.

Referenced by Reset(), profinet::cyclic::CyclicController::StatsSnapshot(), and profinet::cyclic::CyclicController::TxLoop().


The documentation for this struct was generated from the following files: