Skip to content

Commit

Permalink
Removal optional conformance fro DayOfWeekForSequence/ChargingTargets…
Browse files Browse the repository at this point in the history
… fields in ChargingTargetScheduleStruct + regen zap files
  • Loading branch information
PeterC1965 committed Jun 27, 2024
1 parent 3fbdfec commit e43ff1e
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4363,8 +4363,8 @@ cluster EnergyEvse = 153 {
}

struct ChargingTargetScheduleStruct {
optional TargetDayOfWeekBitmap dayOfWeekForSequence = 0;
optional ChargingTargetStruct chargingTargets[] = 1;
TargetDayOfWeekBitmap dayOfWeekForSequence = 0;
ChargingTargetStruct chargingTargets[] = 1;
}

info event EVConnected = 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1723,8 +1723,8 @@ cluster EnergyEvse = 153 {
}

struct ChargingTargetScheduleStruct {
optional TargetDayOfWeekBitmap dayOfWeekForSequence = 0;
optional ChargingTargetStruct chargingTargets[] = 1;
TargetDayOfWeekBitmap dayOfWeekForSequence = 0;
ChargingTargetStruct chargingTargets[] = 1;
}

info event EVConnected = 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ limitations under the License.

<struct name="ChargingTargetScheduleStruct" apiMaturity="provisional">
<cluster code="0x0099"/>
<item fieldId="0" name="DayOfWeekForSequence" type="TargetDayOfWeekBitmap" min="0x00" max="0x7F" optional="true"/>
<item fieldId="1" name="ChargingTargets" array="true" type="ChargingTargetStruct" length="10" optional="true"/>
<item fieldId="0" name="DayOfWeekForSequence" type="TargetDayOfWeekBitmap" min="0x00" max="0x7F"/>
<item fieldId="1" name="ChargingTargets" array="true" type="ChargingTargetStruct" length="10"/>
</struct>

<cluster>
Expand Down
4 changes: 2 additions & 2 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4946,8 +4946,8 @@ cluster EnergyEvse = 153 {
}

struct ChargingTargetScheduleStruct {
optional TargetDayOfWeekBitmap dayOfWeekForSequence = 0;
optional ChargingTargetStruct chargingTargets[] = 1;
TargetDayOfWeekBitmap dayOfWeekForSequence = 0;
ChargingTargetStruct chargingTargets[] = 1;
}

info event EVConnected = 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8230,23 +8230,23 @@ public String toString() {
}
}
public static class EnergyEvseClusterChargingTargetScheduleStruct {
public Optional<Integer> dayOfWeekForSequence;
public Optional<ArrayList<ChipStructs.EnergyEvseClusterChargingTargetStruct>> chargingTargets;
public Integer dayOfWeekForSequence;
public ArrayList<ChipStructs.EnergyEvseClusterChargingTargetStruct> chargingTargets;
private static final long DAY_OF_WEEK_FOR_SEQUENCE_ID = 0L;
private static final long CHARGING_TARGETS_ID = 1L;

public EnergyEvseClusterChargingTargetScheduleStruct(
Optional<Integer> dayOfWeekForSequence,
Optional<ArrayList<ChipStructs.EnergyEvseClusterChargingTargetStruct>> chargingTargets
Integer dayOfWeekForSequence,
ArrayList<ChipStructs.EnergyEvseClusterChargingTargetStruct> chargingTargets
) {
this.dayOfWeekForSequence = dayOfWeekForSequence;
this.chargingTargets = chargingTargets;
}

public StructType encodeTlv() {
ArrayList<StructElement> values = new ArrayList<>();
values.add(new StructElement(DAY_OF_WEEK_FOR_SEQUENCE_ID, dayOfWeekForSequence.<BaseTLVType>map((nonOptionaldayOfWeekForSequence) -> new UIntType(nonOptionaldayOfWeekForSequence)).orElse(new EmptyType())));
values.add(new StructElement(CHARGING_TARGETS_ID, chargingTargets.<BaseTLVType>map((nonOptionalchargingTargets) -> ArrayType.generateArrayType(nonOptionalchargingTargets, (elementnonOptionalchargingTargets) -> elementnonOptionalchargingTargets.encodeTlv())).orElse(new EmptyType())));
values.add(new StructElement(DAY_OF_WEEK_FOR_SEQUENCE_ID, new UIntType(dayOfWeekForSequence)));
values.add(new StructElement(CHARGING_TARGETS_ID, ArrayType.generateArrayType(chargingTargets, (elementchargingTargets) -> elementchargingTargets.encodeTlv())));

return new StructType(values);
}
Expand All @@ -8255,18 +8255,18 @@ public static EnergyEvseClusterChargingTargetScheduleStruct decodeTlv(BaseTLVTyp
if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
return null;
}
Optional<Integer> dayOfWeekForSequence = Optional.empty();
Optional<ArrayList<ChipStructs.EnergyEvseClusterChargingTargetStruct>> chargingTargets = Optional.empty();
Integer dayOfWeekForSequence = null;
ArrayList<ChipStructs.EnergyEvseClusterChargingTargetStruct> chargingTargets = null;
for (StructElement element: ((StructType)tlvValue).value()) {
if (element.contextTagNum() == DAY_OF_WEEK_FOR_SEQUENCE_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
UIntType castingValue = element.value(UIntType.class);
dayOfWeekForSequence = Optional.of(castingValue.value(Integer.class));
dayOfWeekForSequence = castingValue.value(Integer.class);
}
} else if (element.contextTagNum() == CHARGING_TARGETS_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.Array) {
ArrayType castingValue = element.value(ArrayType.class);
chargingTargets = Optional.of(castingValue.map((elementcastingValue) -> ChipStructs.EnergyEvseClusterChargingTargetStruct.decodeTlv(elementcastingValue)));
chargingTargets = castingValue.map((elementcastingValue) -> ChipStructs.EnergyEvseClusterChargingTargetStruct.decodeTlv(elementcastingValue));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import java.util.Optional
import matter.tlv.AnonymousTag
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class EnergyEvseClusterChargingTargetScheduleStruct(
val dayOfWeekForSequence: Optional<UInt>,
val chargingTargets: Optional<List<EnergyEvseClusterChargingTargetStruct>>,
val dayOfWeekForSequence: UInt,
val chargingTargets: List<EnergyEvseClusterChargingTargetStruct>,
) {
override fun toString(): String = buildString {
append("EnergyEvseClusterChargingTargetScheduleStruct {\n")
Expand All @@ -38,18 +37,12 @@ class EnergyEvseClusterChargingTargetScheduleStruct(
fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
if (dayOfWeekForSequence.isPresent) {
val optdayOfWeekForSequence = dayOfWeekForSequence.get()
put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE), optdayOfWeekForSequence)
}
if (chargingTargets.isPresent) {
val optchargingTargets = chargingTargets.get()
startArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
for (item in optchargingTargets.iterator()) {
item.toTlv(AnonymousTag, this)
}
endArray()
put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE), dayOfWeekForSequence)
startArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
for (item in chargingTargets.iterator()) {
item.toTlv(AnonymousTag, this)
}
endArray()
endStructure()
}
}
Expand All @@ -60,25 +53,14 @@ class EnergyEvseClusterChargingTargetScheduleStruct(

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct {
tlvReader.enterStructure(tlvTag)
val dayOfWeekForSequence =
if (tlvReader.isNextTag(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE))) {
Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)))
} else {
Optional.empty()
}
val dayOfWeekForSequence = tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE))
val chargingTargets =
if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARGING_TARGETS))) {
Optional.of(
buildList<EnergyEvseClusterChargingTargetStruct> {
tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
while (!tlvReader.isEndOfContainer()) {
add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader))
}
tlvReader.exitContainer()
}
)
} else {
Optional.empty()
buildList<EnergyEvseClusterChargingTargetStruct> {
tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
while (!tlvReader.isEndOfContainer()) {
add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader))
}
tlvReader.exitContainer()
}

tlvReader.exitContainer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package matter.controller.cluster.structs

import java.util.Optional
import matter.controller.cluster.*
import matter.tlv.AnonymousTag
import matter.tlv.ContextSpecificTag
Expand All @@ -25,8 +24,8 @@ import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class EnergyEvseClusterChargingTargetScheduleStruct(
val dayOfWeekForSequence: Optional<UByte>,
val chargingTargets: Optional<List<EnergyEvseClusterChargingTargetStruct>>,
val dayOfWeekForSequence: UByte,
val chargingTargets: List<EnergyEvseClusterChargingTargetStruct>,
) {
override fun toString(): String = buildString {
append("EnergyEvseClusterChargingTargetScheduleStruct {\n")
Expand All @@ -38,18 +37,12 @@ class EnergyEvseClusterChargingTargetScheduleStruct(
fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
if (dayOfWeekForSequence.isPresent) {
val optdayOfWeekForSequence = dayOfWeekForSequence.get()
put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE), optdayOfWeekForSequence)
}
if (chargingTargets.isPresent) {
val optchargingTargets = chargingTargets.get()
startArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
for (item in optchargingTargets.iterator()) {
item.toTlv(AnonymousTag, this)
}
endArray()
put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE), dayOfWeekForSequence)
startArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
for (item in chargingTargets.iterator()) {
item.toTlv(AnonymousTag, this)
}
endArray()
endStructure()
}
}
Expand All @@ -61,24 +54,14 @@ class EnergyEvseClusterChargingTargetScheduleStruct(
fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct {
tlvReader.enterStructure(tlvTag)
val dayOfWeekForSequence =
if (tlvReader.isNextTag(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE))) {
Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)))
} else {
Optional.empty()
}
tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE))
val chargingTargets =
if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARGING_TARGETS))) {
Optional.of(
buildList<EnergyEvseClusterChargingTargetStruct> {
tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
while (!tlvReader.isEndOfContainer()) {
add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader))
}
tlvReader.exitContainer()
}
)
} else {
Optional.empty()
buildList<EnergyEvseClusterChargingTargetStruct> {
tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS))
while (!tlvReader.isEndOfContainer()) {
add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader))
}
tlvReader.exitContainer()
}

tlvReader.exitContainer()
Expand Down
8 changes: 4 additions & 4 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e43ff1e

Please sign in to comment.