Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ReadHandler] Report Scheduler class #27553

Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7328172
Added a new class that will handle the scheduling of reports.
lpbeliveau-silabs Jun 27, 2023
c1930a3
Restyled by clang-format
restyled-commits Jun 29, 2023
ed7bfac
Removed un-necessary define in TestReportScheduler and applied refact…
lpbeliveau-silabs Jun 29, 2023
e9812ae
Added TimerDelegate and wrapper functions around calls to Timer. Remo…
lpbeliveau-silabs Jun 29, 2023
498716e
Added VerifyOrReturn after NL_TEST_ASSERTS for nullptr
lpbeliveau-silabs Jun 30, 2023
9a16c68
Completed TimerDelegate class and modified ReadHandlerNodes so they c…
lpbeliveau-silabs Jun 30, 2023
48454fb
Modified TimerDelegate to allow to pass different objects as context
lpbeliveau-silabs Jul 4, 2023
02bf98a
ifdefing out ScheduleRun() to debug failing CI
lpbeliveau-silabs Jul 5, 2023
5e38e01
Added issue # to TODOs, refactored Min/Max Intervals to Min/Max Times…
lpbeliveau-silabs Jul 6, 2023
7c2cf2f
Clarified some comments regarding timing
lpbeliveau-silabs Jul 6, 2023
58df486
Restyled by whitespace
restyled-commits Jul 6, 2023
bfb69d9
Restyled by clang-format
restyled-commits Jul 6, 2023
6d92863
Added interface to GetMonotonicTimestamp in the timer delegate
lpbeliveau-silabs Jul 11, 2023
86aec76
Apply suggestions from code review
lpbeliveau-silabs Jul 11, 2023
64f5041
Completed renaming to eliminate compiling error, moved TestReporScehd…
lpbeliveau-silabs Jul 11, 2023
f015837
Removed useless objects from tests as well as useless typecasting, an…
lpbeliveau-silabs Jul 12, 2023
97683ad
Fixed comment about private methods used in ReportScheduler as a frie…
lpbeliveau-silabs Jul 12, 2023
e81641d
Changed to SetMinReportInterval to SetMinReportingIntervalForTests, r…
lpbeliveau-silabs Jul 13, 2023
2a55ac5
Apply suggestions from code review
lpbeliveau-silabs Jul 13, 2023
a0b9d6e
Restyled by clang-format
restyled-commits Jul 13, 2023
4df646c
Removed all calls to ReadHandler States to prevent Engine calls from …
lpbeliveau-silabs Jul 13, 2023
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
Prev Previous commit
Next Next commit
Restyled by clang-format
  • Loading branch information
restyled-commits authored and lpbeliveau-silabs committed Jun 29, 2023
commit c1930a30531cef4f06c6bee12222c01eb0864b9a
125 changes: 25 additions & 100 deletions src/app/ReadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,9 @@ class ReadHandler : public Messaging::ExchangeDelegate
ReadHandler(ManagementCallback & apCallback, Observer * observer = nullptr);
#endif

const ObjectList<AttributePathParams> * GetAttributePathList() const
{
return mpAttributePathList;
}
const ObjectList<EventPathParams> * GetEventPathList() const
{
return mpEventPathList;
}
const ObjectList<DataVersionFilter> * GetDataVersionFilterList() const
{
return mpDataVersionFilterList;
}
const ObjectList<AttributePathParams> * GetAttributePathList() const { return mpAttributePathList; }
const ObjectList<EventPathParams> * GetEventPathList() const { return mpEventPathList; }
const ObjectList<DataVersionFilter> * GetDataVersionFilterList() const { return mpDataVersionFilterList; }

void GetReportingIntervals(uint16_t & aMinInterval, uint16_t & aMaxInterval) const
{
Expand Down Expand Up @@ -269,14 +260,8 @@ class ReadHandler : public Messaging::ExchangeDelegate
}

private:
PriorityLevel GetCurrentPriority() const
{
return mCurrentPriority;
}
EventNumber & GetEventMin()
{
return mEventMin;
}
PriorityLevel GetCurrentPriority() const { return mCurrentPriority; }
EventNumber & GetEventMin() { return mEventMin; }

enum class ReadHandlerFlags : uint8_t
{
Expand Down Expand Up @@ -357,10 +342,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
*/
bool IsFromSubscriber(Messaging::ExchangeContext & apExchangeContext) const;

bool IsIdle() const
{
return mState == HandlerState::Idle;
}
bool IsIdle() const { return mState == HandlerState::Idle; }

// TODO: Change back to IsReportable once ReportScheduler is implemented so this can assess reportability without considering
// timing. The ReporScheduler will handle timing.
Expand All @@ -374,14 +356,8 @@ class ReadHandler : public Messaging::ExchangeDelegate
return mState == HandlerState::GeneratingReports && !mFlags.Has(ReadHandlerFlags::WaitingUntilMinInterval) &&
(IsDirty() || !mFlags.Has(ReadHandlerFlags::WaitingUntilMaxInterval));
}
bool IsGeneratingReports() const
{
return mState == HandlerState::GeneratingReports;
}
bool IsAwaitingReportResponse() const
{
return mState == HandlerState::AwaitingReportResponse;
}
bool IsGeneratingReports() const { return mState == HandlerState::GeneratingReports; }
bool IsAwaitingReportResponse() const { return mState == HandlerState::AwaitingReportResponse; }

// Resets the path iterator to the beginning of the whole report for generating a series of new reports.
void ResetPathIterator();
Expand All @@ -393,41 +369,17 @@ class ReadHandler : public Messaging::ExchangeDelegate
// sanpshotted last event, check with latest last event number, re-setup snapshoted checkpoint, and compare again.
bool CheckEventClean(EventManagement & aEventManager);

bool IsType(InteractionType type) const
{
return (mInteractionType == type);
}
bool IsChunkedReport() const
{
return mFlags.Has(ReadHandlerFlags::ChunkedReport);
}
bool IsType(InteractionType type) const { return (mInteractionType == type); }
bool IsChunkedReport() const { return mFlags.Has(ReadHandlerFlags::ChunkedReport); }
// Is reporting indicates whether we are in the middle of a series chunks. As we will set mIsChunkedReport on the first chunk
// and clear that flag on the last chunk, we can use mIsChunkedReport to indicate this state.
bool IsReporting() const
{
return mFlags.Has(ReadHandlerFlags::ChunkedReport);
}
bool IsPriming() const
{
return mFlags.Has(ReadHandlerFlags::PrimingReports);
}
bool IsActiveSubscription() const
{
return mFlags.Has(ReadHandlerFlags::ActiveSubscription);
}
bool IsFabricFiltered() const
{
return mFlags.Has(ReadHandlerFlags::FabricFiltered);
}
bool IsReporting() const { return mFlags.Has(ReadHandlerFlags::ChunkedReport); }
bool IsPriming() const { return mFlags.Has(ReadHandlerFlags::PrimingReports); }
bool IsActiveSubscription() const { return mFlags.Has(ReadHandlerFlags::ActiveSubscription); }
bool IsFabricFiltered() const { return mFlags.Has(ReadHandlerFlags::FabricFiltered); }
CHIP_ERROR OnSubscribeRequest(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload);
void GetSubscriptionId(SubscriptionId & aSubscriptionId) const
{
aSubscriptionId = mSubscriptionId;
}
AttributePathExpandIterator * GetAttributePathExpandIterator()
{
return &mAttributePathExpandIterator;
}
void GetSubscriptionId(SubscriptionId & aSubscriptionId) const { aSubscriptionId = mSubscriptionId; }
AttributePathExpandIterator * GetAttributePathExpandIterator() { return &mAttributePathExpandIterator; }

/// @brief Notifies the read handler that a set of attribute paths has been marked dirty. This will schedule a reporting engine
/// run if the change to the attribute path makes the ReadHandler reportable.
Expand All @@ -437,10 +389,7 @@ class ReadHandler : public Messaging::ExchangeDelegate
{
return (mDirtyGeneration > mPreviousReportsBeginGeneration) || mFlags.Has(ReadHandlerFlags::ForceDirty);
}
void ClearForceDirtyFlag()
{
ClearStateFlag(ReadHandlerFlags::ForceDirty);
}
void ClearForceDirtyFlag() { ClearStateFlag(ReadHandlerFlags::ForceDirty); }
NodeId GetInitiatorNodeId() const
{
auto session = GetSession();
Expand All @@ -454,47 +403,23 @@ class ReadHandler : public Messaging::ExchangeDelegate
}

Transport::SecureSession * GetSession() const;
SubjectDescriptor GetSubjectDescriptor() const
{
return GetSession()->GetSubjectDescriptor();
}
SubjectDescriptor GetSubjectDescriptor() const { return GetSession()->GetSubjectDescriptor(); }

auto GetTransactionStartGeneration() const
{
return mTransactionStartGeneration;
}
auto GetTransactionStartGeneration() const { return mTransactionStartGeneration; }

/// @brief Forces the read handler into a dirty state, regardless of what's going on with attributes.
/// This can lead to scheduling of a reporting run immediately, if the min interval has been reached,
/// or after the min interval is reached if it has not yet been reached.
void ForceDirtyState();

const AttributeValueEncoder::AttributeEncodeState & GetAttributeEncodeState() const
{
return mAttributeEncoderState;
}
void SetAttributeEncodeState(const AttributeValueEncoder::AttributeEncodeState & aState)
{
mAttributeEncoderState = aState;
}
uint32_t GetLastWrittenEventsBytes() const
{
return mLastWrittenEventsBytes;
}
const AttributeValueEncoder::AttributeEncodeState & GetAttributeEncodeState() const { return mAttributeEncoderState; }
void SetAttributeEncodeState(const AttributeValueEncoder::AttributeEncodeState & aState) { mAttributeEncoderState = aState; }
uint32_t GetLastWrittenEventsBytes() const { return mLastWrittenEventsBytes; }

// Returns the number of interested paths, including wildcard and concrete paths.
size_t GetAttributePathCount() const
{
return mpAttributePathList == nullptr ? 0 : mpAttributePathList->Count();
};
size_t GetEventPathCount() const
{
return mpEventPathList == nullptr ? 0 : mpEventPathList->Count();
};
size_t GetDataVersionFilterCount() const
{
return mpDataVersionFilterList == nullptr ? 0 : mpDataVersionFilterList->Count();
};
size_t GetAttributePathCount() const { return mpAttributePathList == nullptr ? 0 : mpAttributePathList->Count(); };
size_t GetEventPathCount() const { return mpEventPathList == nullptr ? 0 : mpEventPathList->Count(); };
size_t GetDataVersionFilterCount() const { return mpDataVersionFilterList == nullptr ? 0 : mpDataVersionFilterList->Count(); };

CHIP_ERROR SendStatusReport(Protocols::InteractionModel::Status aStatus);

Expand Down