| /* |
| * |
| * Copyright (c) 2022 Project CHIP Authors |
| * |
| * 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. |
| */ |
| |
| // THIS FILE IS GENERATED BY ZAP |
| // This file is generated from clusters-Structs.ipp.zapt |
| |
| #include <clusters/CommodityTariff/Structs.h> |
| |
| #include <app/data-model/StructDecodeIterator.h> |
| #include <app/data-model/WrappedStructEncoder.h> |
| |
| namespace chip { |
| namespace app { |
| namespace Clusters { |
| namespace CommodityTariff { |
| namespace Structs { |
| |
| namespace PeakPeriodStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kSeverity), severity); |
| encoder.Encode(to_underlying(Fields::kPeakPeriod), peakPeriod); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kSeverity)) |
| { |
| err = DataModel::Decode(reader, severity); |
| } |
| else if (__context_tag == to_underlying(Fields::kPeakPeriod)) |
| { |
| err = DataModel::Decode(reader, peakPeriod); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace PeakPeriodStruct |
| |
| namespace AuxiliaryLoadSwitchSettingsStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kNumber), number); |
| encoder.Encode(to_underlying(Fields::kRequiredState), requiredState); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kNumber)) |
| { |
| err = DataModel::Decode(reader, number); |
| } |
| else if (__context_tag == to_underlying(Fields::kRequiredState)) |
| { |
| err = DataModel::Decode(reader, requiredState); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace AuxiliaryLoadSwitchSettingsStruct |
| |
| namespace TariffPriceStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kPriceType), priceType); |
| encoder.Encode(to_underlying(Fields::kPrice), price); |
| encoder.Encode(to_underlying(Fields::kPriceLevel), priceLevel); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kPriceType)) |
| { |
| err = DataModel::Decode(reader, priceType); |
| } |
| else if (__context_tag == to_underlying(Fields::kPrice)) |
| { |
| err = DataModel::Decode(reader, price); |
| } |
| else if (__context_tag == to_underlying(Fields::kPriceLevel)) |
| { |
| err = DataModel::Decode(reader, priceLevel); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace TariffPriceStruct |
| |
| namespace TariffComponentStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kTariffComponentID), tariffComponentID); |
| encoder.Encode(to_underlying(Fields::kPrice), price); |
| encoder.Encode(to_underlying(Fields::kFriendlyCredit), friendlyCredit); |
| encoder.Encode(to_underlying(Fields::kAuxiliaryLoad), auxiliaryLoad); |
| encoder.Encode(to_underlying(Fields::kPeakPeriod), peakPeriod); |
| encoder.Encode(to_underlying(Fields::kPowerThreshold), powerThreshold); |
| encoder.Encode(to_underlying(Fields::kThreshold), threshold); |
| encoder.Encode(to_underlying(Fields::kLabel), label); |
| encoder.Encode(to_underlying(Fields::kPredicted), predicted); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kTariffComponentID)) |
| { |
| err = DataModel::Decode(reader, tariffComponentID); |
| } |
| else if (__context_tag == to_underlying(Fields::kPrice)) |
| { |
| err = DataModel::Decode(reader, price); |
| } |
| else if (__context_tag == to_underlying(Fields::kFriendlyCredit)) |
| { |
| err = DataModel::Decode(reader, friendlyCredit); |
| } |
| else if (__context_tag == to_underlying(Fields::kAuxiliaryLoad)) |
| { |
| err = DataModel::Decode(reader, auxiliaryLoad); |
| } |
| else if (__context_tag == to_underlying(Fields::kPeakPeriod)) |
| { |
| err = DataModel::Decode(reader, peakPeriod); |
| } |
| else if (__context_tag == to_underlying(Fields::kPowerThreshold)) |
| { |
| err = DataModel::Decode(reader, powerThreshold); |
| } |
| else if (__context_tag == to_underlying(Fields::kThreshold)) |
| { |
| err = DataModel::Decode(reader, threshold); |
| } |
| else if (__context_tag == to_underlying(Fields::kLabel)) |
| { |
| err = DataModel::Decode(reader, label); |
| } |
| else if (__context_tag == to_underlying(Fields::kPredicted)) |
| { |
| err = DataModel::Decode(reader, predicted); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace TariffComponentStruct |
| |
| namespace CalendarPeriodStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kStartDate), startDate); |
| encoder.Encode(to_underlying(Fields::kDayPatternIDs), dayPatternIDs); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kStartDate)) |
| { |
| err = DataModel::Decode(reader, startDate); |
| } |
| else if (__context_tag == to_underlying(Fields::kDayPatternIDs)) |
| { |
| err = DataModel::Decode(reader, dayPatternIDs); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace CalendarPeriodStruct |
| |
| namespace DayEntryStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kDayEntryID), dayEntryID); |
| encoder.Encode(to_underlying(Fields::kStartTime), startTime); |
| encoder.Encode(to_underlying(Fields::kDuration), duration); |
| encoder.Encode(to_underlying(Fields::kRandomizationOffset), randomizationOffset); |
| encoder.Encode(to_underlying(Fields::kRandomizationType), randomizationType); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kDayEntryID)) |
| { |
| err = DataModel::Decode(reader, dayEntryID); |
| } |
| else if (__context_tag == to_underlying(Fields::kStartTime)) |
| { |
| err = DataModel::Decode(reader, startTime); |
| } |
| else if (__context_tag == to_underlying(Fields::kDuration)) |
| { |
| err = DataModel::Decode(reader, duration); |
| } |
| else if (__context_tag == to_underlying(Fields::kRandomizationOffset)) |
| { |
| err = DataModel::Decode(reader, randomizationOffset); |
| } |
| else if (__context_tag == to_underlying(Fields::kRandomizationType)) |
| { |
| err = DataModel::Decode(reader, randomizationType); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace DayEntryStruct |
| |
| namespace DayPatternStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kDayPatternID), dayPatternID); |
| encoder.Encode(to_underlying(Fields::kDaysOfWeek), daysOfWeek); |
| encoder.Encode(to_underlying(Fields::kDayEntryIDs), dayEntryIDs); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kDayPatternID)) |
| { |
| err = DataModel::Decode(reader, dayPatternID); |
| } |
| else if (__context_tag == to_underlying(Fields::kDaysOfWeek)) |
| { |
| err = DataModel::Decode(reader, daysOfWeek); |
| } |
| else if (__context_tag == to_underlying(Fields::kDayEntryIDs)) |
| { |
| err = DataModel::Decode(reader, dayEntryIDs); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace DayPatternStruct |
| |
| namespace DayStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kDate), date); |
| encoder.Encode(to_underlying(Fields::kDayType), dayType); |
| encoder.Encode(to_underlying(Fields::kDayEntryIDs), dayEntryIDs); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kDate)) |
| { |
| err = DataModel::Decode(reader, date); |
| } |
| else if (__context_tag == to_underlying(Fields::kDayType)) |
| { |
| err = DataModel::Decode(reader, dayType); |
| } |
| else if (__context_tag == to_underlying(Fields::kDayEntryIDs)) |
| { |
| err = DataModel::Decode(reader, dayEntryIDs); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace DayStruct |
| |
| namespace TariffInformationStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kTariffLabel), tariffLabel); |
| encoder.Encode(to_underlying(Fields::kProviderName), providerName); |
| encoder.Encode(to_underlying(Fields::kCurrency), currency); |
| encoder.Encode(to_underlying(Fields::kBlockMode), blockMode); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kTariffLabel)) |
| { |
| err = DataModel::Decode(reader, tariffLabel); |
| } |
| else if (__context_tag == to_underlying(Fields::kProviderName)) |
| { |
| err = DataModel::Decode(reader, providerName); |
| } |
| else if (__context_tag == to_underlying(Fields::kCurrency)) |
| { |
| err = DataModel::Decode(reader, currency); |
| } |
| else if (__context_tag == to_underlying(Fields::kBlockMode)) |
| { |
| err = DataModel::Decode(reader, blockMode); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace TariffInformationStruct |
| |
| namespace TariffPeriodStruct { |
| CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const |
| { |
| DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; |
| encoder.Encode(to_underlying(Fields::kLabel), label); |
| encoder.Encode(to_underlying(Fields::kDayEntryIDs), dayEntryIDs); |
| encoder.Encode(to_underlying(Fields::kTariffComponentIDs), tariffComponentIDs); |
| return encoder.Finalize(); |
| } |
| |
| CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) |
| { |
| detail::StructDecodeIterator __iterator(reader); |
| while (true) |
| { |
| uint8_t __context_tag = 0; |
| CHIP_ERROR err = __iterator.Next(__context_tag); |
| VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR); |
| ReturnErrorOnFailure(err); |
| |
| if (__context_tag == to_underlying(Fields::kLabel)) |
| { |
| err = DataModel::Decode(reader, label); |
| } |
| else if (__context_tag == to_underlying(Fields::kDayEntryIDs)) |
| { |
| err = DataModel::Decode(reader, dayEntryIDs); |
| } |
| else if (__context_tag == to_underlying(Fields::kTariffComponentIDs)) |
| { |
| err = DataModel::Decode(reader, tariffComponentIDs); |
| } |
| |
| ReturnErrorOnFailure(err); |
| } |
| } |
| |
| } // namespace TariffPeriodStruct |
| } // namespace Structs |
| } // namespace CommodityTariff |
| } // namespace Clusters |
| } // namespace app |
| } // namespace chip |