-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'EVSE_Add_NewXML' into EVSE_Add_Get_Set_Clear_Targets_Su…
…pport
- Loading branch information
Showing
2 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
...va/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 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. | ||
*/ | ||
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>> | ||
) { | ||
override fun toString(): String = buildString { | ||
append("EnergyEvseClusterChargingTargetScheduleStruct {\n") | ||
append("\tdayOfWeekforSequence : $dayOfWeekforSequence\n") | ||
append("\tchargingTargets : $chargingTargets\n") | ||
append("}\n") | ||
} | ||
|
||
fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { | ||
tlvWriter.apply { | ||
startStructure(tlvTag) | ||
if (dayOfWeekforSequence.isPresent) { | ||
val optdayOfWeekforSequence = dayOfWeekforSequence.get() | ||
put(ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE), optdayOfWeekforSequence) | ||
} | ||
if (chargingTargets.isPresent) { | ||
val optchargingTargets = chargingTargets.get() | ||
startArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) | ||
for (item in optchargingTargets.iterator()) { | ||
item.toTlv(AnonymousTag, this) | ||
} | ||
endArray() | ||
} | ||
endStructure() | ||
} | ||
} | ||
|
||
companion object { | ||
private const val TAG_DAY_OF_WEEKFOR_SEQUENCE = 0 | ||
private const val TAG_CHARGING_TARGETS = 1 | ||
|
||
fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { | ||
tlvReader.enterStructure(tlvTag) | ||
val dayOfWeekforSequence = | ||
if (tlvReader.isNextTag(ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE))) { | ||
Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE))) | ||
} else { | ||
Optional.empty() | ||
} | ||
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() | ||
} | ||
|
||
tlvReader.exitContainer() | ||
|
||
return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekforSequence, chargingTargets) | ||
} | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...d/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 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. | ||
*/ | ||
package matter.controller.cluster.structs | ||
|
||
import java.util.Optional | ||
import matter.controller.cluster.* | ||
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<UByte>, | ||
val chargingTargets: Optional<List<EnergyEvseClusterChargingTargetStruct>> | ||
) { | ||
override fun toString(): String = buildString { | ||
append("EnergyEvseClusterChargingTargetScheduleStruct {\n") | ||
append("\tdayOfWeekforSequence : $dayOfWeekforSequence\n") | ||
append("\tchargingTargets : $chargingTargets\n") | ||
append("}\n") | ||
} | ||
|
||
fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { | ||
tlvWriter.apply { | ||
startStructure(tlvTag) | ||
if (dayOfWeekforSequence.isPresent) { | ||
val optdayOfWeekforSequence = dayOfWeekforSequence.get() | ||
put(ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE), optdayOfWeekforSequence) | ||
} | ||
if (chargingTargets.isPresent) { | ||
val optchargingTargets = chargingTargets.get() | ||
startArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) | ||
for (item in optchargingTargets.iterator()) { | ||
item.toTlv(AnonymousTag, this) | ||
} | ||
endArray() | ||
} | ||
endStructure() | ||
} | ||
} | ||
|
||
companion object { | ||
private const val TAG_DAY_OF_WEEKFOR_SEQUENCE = 0 | ||
private const val TAG_CHARGING_TARGETS = 1 | ||
|
||
fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { | ||
tlvReader.enterStructure(tlvTag) | ||
val dayOfWeekforSequence = | ||
if (tlvReader.isNextTag(ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE))) { | ||
Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEKFOR_SEQUENCE))) | ||
} else { | ||
Optional.empty() | ||
} | ||
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() | ||
} | ||
|
||
tlvReader.exitContainer() | ||
|
||
return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekforSequence, chargingTargets) | ||
} | ||
} | ||
} |