2 * Copyright (c) 2010-2021 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;
24 * The {@link StructureManager} builds the internal model of the digitalSTROM-System.
26 * @author Michael Ochel - Initial contribution
27 * @author Matthias Siegele - Initial contribution
29 public interface StructureManager {
32 * Generates the zone- and group-names.
34 * @param connectionManager must not be null
35 * @return true, if it's generated, otherwise false
37 boolean generateZoneGroupNames(ConnectionManager connectionManager);
40 * Returns the name of a zone or null, if the given zoneID dose not exists.<br>
41 * Note: Zone-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
43 * @param zoneID of the zone
46 String getZoneName(int zoneID);
49 * Returns the id of a given zone-name or -1, if the given zone-name dose not exists.<br>
50 * Note: Zone-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
52 * @param zoneName of the zone
55 int getZoneId(String zoneName);
58 * Returns the name of the given groupID from the given zoneID or null, if the zoneID or groupID dose not exists.
60 * Note: Zone-group-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
62 * @param zoneID of the group
63 * @param groupID of the group
66 String getZoneGroupName(int zoneID, short groupID);
69 * Returns the groupID of the given group-name from the given zone name or -1, if the zone-name or group name dose
71 * Note: Zone-group-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
73 * @param zoneName of the group
74 * @param groupName of the group
77 short getZoneGroupId(String zoneName, String groupName);
80 * Returns a new {@link Map} of all {@link Device}'s with the {@link DSID} as key and the {@link Device} as value.
81 * If no devices are found, an empty {@link Map} will be returned.
83 * @return device-map (cannot be null)
85 Map<DSID, Device> getDeviceMap();
88 * Returns a reference to the {@link Map} of all {@link Device}'s with the {@link DSID} as key and the
89 * {@link Device} as value. If no devices are found, an empty {@link Map} will be returned.
91 * @return reference device-map
93 Map<DSID, Device> getDeviceHashMapReference();
96 * Returns the reference of the structure as {@link Map}[zoneID, {@link Map}[groupID,
97 * {@link List}[{@link Device}]]].
99 * @return structure reference
101 Map<Integer, Map<Short, List<Device>>> getStructureReference();
104 * Returns the Map of all groups as format HashMap[Short, List[Device]].
106 * @param zoneID of the zone
109 Map<Short, List<Device>> getGroupsFromZoneX(int zoneID);
112 * Returns the reference {@link List} of the {@link Device}'s of an zone-group.
114 * @param zoneID of the zone
115 * @param groupID of the group
116 * @return reference device-list
118 List<Device> getReferenceDeviceListFromZoneXGroupX(int zoneID, short groupID);
121 * Returns the {@link Device} of the given dSID as {@link String} or null if no {@link Device} exists.
123 * @param dSID of the device
126 Device getDeviceByDSID(String dSID);
129 * Returns the {@link Device} of the given dSID as {@link DSID} or null if no {@link Device} exists.
131 * @param dSID of the device
134 Device getDeviceByDSID(DSID dSID);
137 * Returns the {@link Device} of the given dSUID or null if no {@link Device} exists.
139 * @param dSUID of the device
140 * @return the {@link Device} with the given dSUID
142 Device getDeviceByDSUID(String dSUID);
145 * Updates a {@link Device} of the structure.
148 * @param oldGroups ID's
149 * @param device new {@link Device}
151 void updateDevice(int oldZone, List<Short> oldGroups, Device device);
154 * Updates a {@link Device} of the structure.
156 * @param device to update
158 void updateDevice(Device device);
161 * Deletes a {@link Device} from the structure.
163 * @param device to delete
165 void deleteDevice(Device device);
168 * Adds a {@link Device} to the structure.
170 * @param device to add
172 void addDeviceToStructure(Device device);
175 * Returns a {@link Set} of all zoneID's
179 Set<Integer> getZoneIDs();
182 * Returns true, if a zone with the given zoneID exists, otherwise false.
184 * @param zoneID to check
185 * @return true = zoneID exists | false = zoneID not exists
187 boolean checkZoneID(int zoneID);
190 * Returns true, if a zone-group with the given zoneID and groupID exists, otherwise false.
192 * @param zoneID to check
193 * @param groupID to check
194 * @return true = zoneID or groupID exists | false = zoneID or groupID not exists
196 boolean checkZoneGroupID(int zoneID, short groupID);
199 * Adds the given {@link List} of {@link Circuit}'s to this {@link StructureManager}.
201 * @param referenceCircuitList to add
203 void addCircuitList(List<Circuit> referenceCircuitList);
206 * Adds the given {@link Circuit} to this {@link StructureManager}.
208 * @param circuit to add
209 * @return the old {@link Circuit}, if the given {@link Circuit} was already added.
211 Circuit addCircuit(Circuit circuit);
214 * Returns the {@link Circuit} with the given {@link DSID}.
216 * @param dSID of the {@link Circuit} to get
217 * @return the {@link Circuit} with the given {@link DSID}
219 Circuit getCircuitByDSID(DSID dSID);
222 * Returns the {@link Circuit} with the given dSID as {@link String}.
224 * @param dSID of the {@link Circuit} to get
225 * @return the {@link Circuit} with the given dSID
227 Circuit getCircuitByDSID(String dSID);
230 * Returns the {@link Circuit} with the given dSUID as {@link String}.
232 * @param dSUID of the {@link Circuit} to get
233 * @return the {@link Circuit} with the given dSUID
235 Circuit getCircuitByDSUID(String dSUID);
238 * Updates the configuration of an added {@link Circuit} through a new {@link Circuit} object.
240 * @param newCircuit to update
241 * @return {@link Circuit} with the old configuration
243 Circuit updateCircuitConfig(Circuit newCircuit);
246 * Deletes the {@link Circuit} with the given {@link DSID}.
248 * @param dSID of the {@link Circuit} to remove
249 * @return the removed {@link Circuit}
251 Circuit deleteCircuit(DSID dSID);
254 * Deletes the {@link Circuit} with the given dSUID.
256 * @param dSUID of the {@link Circuit} to remove
257 * @return the removed {@link Circuit}
259 Circuit deleteCircuit(String dSUID);
262 * Returns a {@link Map} of all {@link Circuit}'s which are added to this {@link StructureManager}.
264 * @return {@link Map} of all added {@link Circuit}'s
266 Map<DSID, Circuit> getCircuitMap();