Skip to content

Commit

Permalink
WindowCovering: Add operational-status + YAML tests (#14606)
Browse files Browse the repository at this point in the history
* YAML: Update WindowCovering tests 3.1 3.2 to latest test plan

* DEV: Expose and Use HasFeaturePas

* DEV: Add mOperationalStatus var to class WindowApp

* DEV: Add fake motion simulator for CI

* DEV: add to All-cluster-app the missing callback

* ZAP: Add missing diff from regen

* YAML: Tests - Add Feature conditional PICS to WNCV 3.1 3.2

* CFG: ZAP all-cluster-app allows LF + PA_LF and  TL + PA_TL by default

* TEST: YAML update value and report

* DEV: Add PostEvent for Attributes Changes

* DEV: WindowAppImpl Add DispatchEventAttributeChange function

* DEV: Remove StopMotion

- prefer single method of goto current position

* DEV: Rewrite position movement using attributes

* DEV: Window-covering-server cleanup

* DEV: Remove Todos we use PICS to enable/disable tests

* TEST: YAML update WNCV 3.3 StopMotion

* Test: YAML WNCV 3.3 disable steps relying on saveAS

- add a todo on issue #14502

* TEST: Declare YAML test accordingly w/ Test Plan

* TEST: YAML WNCV 3.2 fix target

* TEST: YAML adjust timing

* DEV: remove unused option from ConvertValue

* DEV: Up or Down are inverted compare to the spec

* CFG: Zap Window-app update feature-map

* Restyled by whitespace

* Restyled by clang-format

* Restyled by prettier-yaml

* DEV: Use generated callback rather than declaring one

* DEV: Remove Post attribute declaration

* Restyled by whitespace

* Restyled by clang-format

* YAML: Update attributes check

* Rebase/Regen

* Restyled by whitespace

* TEST: YAML enable test on WNCV 3.3

- issue #14502 fixes by PR# 14602

* DEV: REbase / regen

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 21, 2023
1 parent 8455043 commit 1197960
Show file tree
Hide file tree
Showing 20 changed files with 4,506 additions and 609 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11921,7 +11921,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"defaultValue": "0x17",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down
50 changes: 33 additions & 17 deletions examples/window-app/common/include/WindowApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

#pragma once

#include <app-common/zap-generated/enums.h>
#include <app/util/af-types.h>
#include <app/clusters/window-covering-server/window-covering-server.h>
#include <lib/core/CHIPError.h>

using namespace chip::app::Clusters::WindowCovering;

class WindowApp
{
public:
Expand Down Expand Up @@ -76,13 +77,10 @@ class WindowApp
CoverChange,
CoverTypeChange,
TiltModeChange,
LiftUp,
LiftDown,
LiftChanged,
TiltUp,
TiltDown,
TiltChanged,
StopMotion,

// Cover Attribute update events
AttributeChange,

// Provisioning events
ProvisionedStateChanged,
ConnectivityStateChanged,
Expand All @@ -95,32 +93,48 @@ class WindowApp
{
Event(EventId id) : mId(id), mEndpoint(0) {}
Event(EventId id, chip::EndpointId endpoint) : mId(id), mEndpoint(endpoint) {}
Event(EventId id, chip::EndpointId endpoint, chip::AttributeId attributeId) :
mId(id), mEndpoint(endpoint), mAttributeId(attributeId)
{}

EventId mId;
chip::EndpointId mEndpoint;
chip::AttributeId mAttributeId;
};

struct Cover
{
void Init(chip::EndpointId endpoint);
void Finish();

void LiftUpdate(bool newTarget);
void LiftGoToTarget() { LiftUpdate(true); }
void LiftContinueToTarget() { LiftUpdate(false); }
void LiftUp();
void LiftDown();
void GotoLift(EventId action = EventId::None);

void TiltUpdate(bool newTarget);
void TiltGoToTarget() { TiltUpdate(true); }
void TiltContinueToTarget() { TiltUpdate(false); }
void TiltUp();
void TiltDown();
void GotoTilt(EventId action = EventId::None);
void StopMotion();

EmberAfWcType CycleType();

static void OnLiftTimeout(Timer & timer);
static void OnTiltTimeout(Timer & timer);

chip::EndpointId mEndpoint = 0;
Timer * mLiftTimer = nullptr;
Timer * mTiltTimer = nullptr;
EventId mLiftAction = EventId::None;
EventId mTiltAction = EventId::None;

// Attribute: Id 10 OperationalStatus
OperationalStatus mOperationalStatus = { .global = OperationalState::Stall,
.lift = OperationalState::Stall,
.tilt = OperationalState::Stall };

Timer * mLiftTimer = nullptr;
Timer * mTiltTimer = nullptr;
OperationalState mLiftOpState = OperationalState::Stall;
OperationalState mTiltOpState = OperationalState::Stall;
};

static WindowApp & Instance();
Expand All @@ -130,7 +144,8 @@ class WindowApp
virtual CHIP_ERROR Start() = 0;
virtual CHIP_ERROR Run();
virtual void Finish();
virtual void PostEvent(const Event & event) = 0;
virtual void PostEvent(const Event & event) = 0;
virtual void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) = 0;

protected:
struct StateFlags
Expand Down Expand Up @@ -172,6 +187,7 @@ class WindowApp

private:
void HandleLongPress();
void DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute);

Cover mCoverList[WINDOW_COVER_COUNT];
uint8_t mCurrentCover = 0;
Expand Down
Loading

0 comments on commit 1197960

Please sign in to comment.