forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrvc-service-area-delegate.h
198 lines (144 loc) · 7.45 KB
/
rvc-service-area-delegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <app/clusters/service-area-server/service-area-server.h>
#include <app/util/config.h>
#include <cstring>
#include <utility>
namespace chip {
namespace app {
namespace Clusters {
class RvcDevice;
typedef bool (RvcDevice::*IsSetSelectedAreasAllowedCallback)(MutableCharSpan & statusText);
typedef bool (RvcDevice::*HandleSkipCurrentAreaCallback)(uint32_t skippedArea, MutableCharSpan & skipStatusText);
typedef bool (RvcDevice::*IsChangeAllowedSimpleCallback)();
namespace ServiceArea {
class RvcServiceAreaDelegate : public Delegate
{
private:
// containers for array attributes.
std::vector<ServiceArea::AreaStructureWrapper> mSupportedAreas;
std::vector<ServiceArea::MapStructureWrapper> mSupportedMaps;
std::vector<uint32_t> mSelectedAreas;
std::vector<ServiceArea::Structs::ProgressStruct::Type> mProgressList;
RvcDevice * mIsSetSelectedAreasAllowedDeviceInstance;
IsSetSelectedAreasAllowedCallback mIsSetSelectedAreasAllowedCallback;
RvcDevice * mHandleSkipCurrentAreaDeviceInstance;
HandleSkipCurrentAreaCallback mHandleSkipCurrentAreaCallback;
RvcDevice * mIsSupportedAreasChangeAllowedDeviceInstance;
IsChangeAllowedSimpleCallback mIsSupportedAreasChangeAllowedCallback;
RvcDevice * mIsSupportedMapChangeAllowedDeviceInstance;
IsChangeAllowedSimpleCallback mIsSupportedMapChangeAllowedCallback;
// hardcoded values for SUPPORTED MAPS.
const uint32_t supportedMapId_XX = 3;
const uint32_t supportedMapId_YY = 245;
// hardcoded values for SUPPORTED AREAS.
const uint32_t supportedAreaID_A = 7;
const uint32_t supportedAreaID_B = 1234567;
const uint32_t supportedAreaID_C = 10050;
const uint32_t supportedAreaID_D = 0x88888888;
/**
* Set the SupportedMaps and SupportedAreas where the SupportedMaps is not null.
*/
void SetMapTopology();
/**
* Set the SupportedMaps and SupportedAreas where the SupportedMaps is null.
*/
void SetNoMapTopology();
public:
CHIP_ERROR Init() override;
// command support
bool IsSetSelectedAreasAllowed(MutableCharSpan & statusText) override;
bool IsValidSelectAreasSet(const ServiceArea::Commands::SelectAreas::DecodableType & req,
ServiceArea::SelectAreasStatus & areaStatus, MutableCharSpan & statusText) override;
bool HandleSkipCurrentArea(uint32_t skippedArea, MutableCharSpan & skipStatusText) override;
//*************************************************************************
// Supported Areas accessors
bool IsSupportedAreasChangeAllowed() override;
uint32_t GetNumberOfSupportedAreas() override;
bool GetSupportedAreaByIndex(uint32_t listIndex, AreaStructureWrapper & supportedArea) override;
bool GetSupportedAreaById(uint32_t aAreaId, uint32_t & listIndex, AreaStructureWrapper & supportedArea) override;
bool AddSupportedArea(const AreaStructureWrapper & newArea, uint32_t & listIndex) override;
bool ModifySupportedArea(uint32_t listIndex, const AreaStructureWrapper & modifiedArea) override;
bool ClearSupportedAreas() override;
//*************************************************************************
// Supported Maps accessors
bool IsSupportedMapChangeAllowed() override;
uint32_t GetNumberOfSupportedMaps() override;
bool GetSupportedMapByIndex(uint32_t listIndex, ServiceArea::MapStructureWrapper & supportedMap) override;
bool GetSupportedMapById(uint32_t aMapId, uint32_t & listIndex, ServiceArea::MapStructureWrapper & supportedMap) override;
bool AddSupportedMap(const ServiceArea::MapStructureWrapper & newMap, uint32_t & listIndex) override;
bool ModifySupportedMap(uint32_t listIndex, const ServiceArea::MapStructureWrapper & newMap) override;
bool ClearSupportedMaps() override;
//*************************************************************************
// Selected Areas accessors
uint32_t GetNumberOfSelectedAreas() override;
bool GetSelectedAreaByIndex(uint32_t listIndex, uint32_t & selectedArea) override;
bool AddSelectedArea(uint32_t aAreaId, uint32_t & listIndex) override;
bool ClearSelectedAreas() override;
//*************************************************************************
// Progress accessors
uint32_t GetNumberOfProgressElements() override;
bool GetProgressElementByIndex(uint32_t listIndex, ServiceArea::Structs::ProgressStruct::Type & aProgressElement) override;
bool GetProgressElementById(uint32_t aAreaId, uint32_t & listIndex,
ServiceArea::Structs::ProgressStruct::Type & aProgressElement) override;
bool AddProgressElement(const ServiceArea::Structs::ProgressStruct::Type & newProgressElement, uint32_t & listIndex) override;
bool ModifyProgressElement(uint32_t listIndex,
const ServiceArea::Structs::ProgressStruct::Type & modifiedProgressElement) override;
bool ClearProgress() override;
//*************************************************************************
// RVC device callback setters
void SetIsSetSelectedAreasAllowedCallback(IsSetSelectedAreasAllowedCallback callback, RvcDevice * instance)
{
mIsSetSelectedAreasAllowedCallback = callback;
mIsSetSelectedAreasAllowedDeviceInstance = instance;
}
void SetHandleSkipCurrentAreaCallback(HandleSkipCurrentAreaCallback callback, RvcDevice * instance)
{
mHandleSkipCurrentAreaCallback = callback;
mHandleSkipCurrentAreaDeviceInstance = instance;
}
void SetIsSupportedAreasChangeAllowedCallback(IsChangeAllowedSimpleCallback callback, RvcDevice * instance)
{
mIsSupportedAreasChangeAllowedCallback = callback;
mIsSupportedAreasChangeAllowedDeviceInstance = instance;
}
void SetIsSupportedMapChangeAllowedCallback(IsChangeAllowedSimpleCallback callback, RvcDevice * instance)
{
mIsSupportedMapChangeAllowedCallback = callback;
mIsSupportedMapChangeAllowedDeviceInstance = instance;
}
//*************************************************************************
// Helper methods for setting service area attributes.
/**
* Sets the service area attributes at the start of a clean.
* This includes the current area an progress attributes.
*/
void SetAttributesAtCleanStart();
/**
* Go to the next area in the list of selected areas.
* @param currentAreaOpState The operational state to be set in the Status field of the Progress attribute for the current area.
* This can only be Completed or Skipped.
* @param finished true if there are no more areas to clean an we should end the clean.
*/
void GoToNextArea(OperationalStatusEnum currentAreaOpState, bool & finished);
};
} // namespace ServiceArea
} // namespace Clusters
} // namespace app
} // namespace chip