2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.digitalstrom.internal.lib.manager;
15 import java.util.List;
19 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit;
20 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.Device;
21 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DSID;
22 import org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DSUID;
25 * The {@link StructureManager} builds the internal model of the digitalSTROM-System.
27 * @author Michael Ochel - Initial contribution
28 * @author Matthias Siegele - Initial contribution
30 public interface StructureManager {
33 * Generates the zone- and group-names.
35 * @param connectionManager must not be null
36 * @return true, if it's generated, otherwise false
38 boolean generateZoneGroupNames(ConnectionManager connectionManager);
41 * Returns the name of a zone or null, if the given zoneID dose not exists.<br>
42 * Note: Zone-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
44 * @param zoneID of the zone
47 String getZoneName(int zoneID);
50 * Returns the id of a given zone-name or -1, if the given zone-name dose not exists.<br>
51 * Note: Zone-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
53 * @param zoneName of the zone
56 int getZoneId(String zoneName);
59 * Returns the name of the given groupID from the given zoneID or null, if the zoneID or groupID dose not exists.
61 * Note: Zone-group-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
63 * @param zoneID of the group
64 * @param groupID of the group
67 String getZoneGroupName(int zoneID, short groupID);
70 * Returns the groupID of the given group-name from the given zone name or -1, if the zone-name or group name dose
72 * Note: Zone-group-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
74 * @param zoneName of the group
75 * @param groupName of the group
78 short getZoneGroupId(String zoneName, String groupName);
81 * Returns a new {@link Map} of all {@link Device}'s with the {@link DSID} as key and the {@link Device} as value.
82 * If no devices are found, an empty {@link Map} will be returned.
84 * @return device-map (cannot be null)
86 Map<DSID, Device> getDeviceMap();
89 * Returns a reference to the {@link Map} of all {@link Device}'s with the {@link DSID} as key and the
90 * {@link Device} as value. If no devices are found, an empty {@link Map} will be returned.
92 * @return reference device-map
94 Map<DSID, Device> getDeviceHashMapReference();
97 * Returns the reference of the structure as {@link Map}[zoneID, {@link Map}[groupID,
98 * {@link List}[{@link Device}]]].
100 * @return structure reference
102 Map<Integer, Map<Short, List<Device>>> getStructureReference();
105 * Returns the Map of all groups as format HashMap[Short, List[Device]].
107 * @param zoneID of the zone
110 Map<Short, List<Device>> getGroupsFromZoneX(int zoneID);
113 * Returns the reference {@link List} of the {@link Device}'s of a zone-group.
115 * @param zoneID of the zone
116 * @param groupID of the group
117 * @return reference device-list
119 List<Device> getReferenceDeviceListFromZoneXGroupX(int zoneID, short groupID);
122 * Returns the {@link Device} of the given dSID as {@link String} or null if no {@link Device} exists.
124 * @param dSID of the device
127 Device getDeviceByDSID(String dSID);
130 * Returns the {@link Device} of the given dSID as {@link DSID} or null if no {@link Device} exists.
132 * @param dSID of the device
135 Device getDeviceByDSID(DSID dSID);
138 * Returns the {@link Device} of the given dSUID or null if no {@link Device} exists.
140 * @param dSUID of the device
141 * @return the {@link Device} with the given dSUID
143 Device getDeviceByDSUID(String dSUID);
146 * Updates a {@link Device} of the structure.
149 * @param oldGroups ID's
150 * @param device new {@link Device}
152 void updateDevice(int oldZone, List<Short> oldGroups, Device device);
155 * Updates a {@link Device} of the structure.
157 * @param device to update
159 void updateDevice(Device device);
162 * Deletes a {@link Device} from the structure.
164 * @param device to delete
166 void deleteDevice(Device device);
169 * Adds a {@link Device} to the structure.
171 * @param device to add
173 void addDeviceToStructure(Device device);
176 * Returns a {@link Set} of all zoneID's
180 Set<Integer> getZoneIDs();
183 * Returns true, if a zone with the given zoneID exists, otherwise false.
185 * @param zoneID to check
186 * @return true = zoneID exists | false = zoneID not exists
188 boolean checkZoneID(int zoneID);
191 * Returns true, if a zone-group with the given zoneID and groupID exists, otherwise false.
193 * @param zoneID to check
194 * @param groupID to check
195 * @return true = zoneID or groupID exists | false = zoneID or groupID not exists
197 boolean checkZoneGroupID(int zoneID, short groupID);
200 * Adds the given {@link List} of {@link Circuit}'s to this {@link StructureManager}.
202 * @param referenceCircuitList to add
204 void addCircuitList(List<Circuit> referenceCircuitList);
207 * Adds the given {@link Circuit} to this {@link StructureManager}.
209 * @param circuit to add
210 * @return the old {@link Circuit}, if the given {@link Circuit} was already added.
212 Circuit addCircuit(Circuit circuit);
215 * Returns the {@link Circuit} with the given {@link DSID}.
217 * @param dSID of the {@link Circuit} to get
218 * @return the {@link Circuit} with the given {@link DSID}
220 Circuit getCircuitByDSID(DSID dSID);
223 * Returns the {@link Circuit} with the given dSID as {@link String}.
225 * @param dSID of the {@link Circuit} to get
226 * @return the {@link Circuit} with the given dSID
228 Circuit getCircuitByDSID(String dSID);
231 * Returns the {@link Circuit} with the given dSUID as {@link DSUID}.
233 * @param dSUID of the {@link Circuit} to get
234 * @return the {@link Circuit} with the given {@link DSUID}
236 Circuit getCircuitByDSUID(DSUID dSUID);
239 * Returns the {@link Circuit} with the given dSUID as {@link String}.
241 * @param dSUID of the {@link Circuit} to get
242 * @return the {@link Circuit} with the given dSUID
244 Circuit getCircuitByDSUID(String dSUID);
247 * Updates the configuration of an added {@link Circuit} through a new {@link Circuit} object.
249 * @param newCircuit to update
250 * @return {@link Circuit} with the old configuration
252 Circuit updateCircuitConfig(Circuit newCircuit);
255 * Deletes the {@link Circuit} with the given {@link DSID}.
257 * @param dSID of the {@link Circuit} to remove
258 * @return the removed {@link Circuit}
260 Circuit deleteCircuit(DSID dSID);
263 * Deletes the {@link Circuit} with the given dSUID.
265 * @param dSUID of the {@link Circuit} to remove
266 * @return the removed {@link Circuit}
268 Circuit deleteCircuit(String dSUID);
271 * Returns a {@link Map} of all {@link Circuit}'s which are added to this {@link StructureManager}.
273 * @return {@link Map} of all added {@link Circuit}'s
275 Map<DSID, Circuit> getCircuitMap();