]> git.basschouten.com Git - openhab-addons.git/blob
67ba37f206efac8b117a2aa6abc1813c0a48baed
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.digitalstrom.internal.lib.manager;
14
15 import java.util.List;
16 import java.util.Map;
17 import java.util.Set;
18
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;
23
24 /**
25  * The {@link StructureManager} builds the internal model of the digitalSTROM-System.
26  *
27  * @author Michael Ochel - Initial contribution
28  * @author Matthias Siegele - Initial contribution
29  */
30 public interface StructureManager {
31
32     /**
33      * Generates the zone- and group-names.
34      *
35      * @param connectionManager must not be null
36      * @return true, if it's generated, otherwise false
37      */
38     boolean generateZoneGroupNames(ConnectionManager connectionManager);
39
40     /**
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)}.
43      *
44      * @param zoneID of the zone
45      * @return zone-name
46      */
47     String getZoneName(int zoneID);
48
49     /**
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)}.
52      *
53      * @param zoneName of the zone
54      * @return zoneID
55      */
56     int getZoneId(String zoneName);
57
58     /**
59      * Returns the name of the given groupID from the given zoneID or null, if the zoneID or groupID dose not exists.
60      * <br>
61      * Note: Zone-group-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
62      *
63      * @param zoneID of the group
64      * @param groupID of the group
65      * @return group-name
66      */
67     String getZoneGroupName(int zoneID, short groupID);
68
69     /**
70      * Returns the groupID of the given group-name from the given zone name or -1, if the zone-name or group name dose
71      * not exists.<br>
72      * Note: Zone-group-names have to be generated over {@link #generateZoneGroupNames(ConnectionManager)}.
73      *
74      * @param zoneName of the group
75      * @param groupName of the group
76      * @return group-id
77      */
78     short getZoneGroupId(String zoneName, String groupName);
79
80     /**
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.
83      *
84      * @return device-map (cannot be null)
85      */
86     Map<DSID, Device> getDeviceMap();
87
88     /**
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.
91      *
92      * @return reference device-map
93      */
94     Map<DSID, Device> getDeviceHashMapReference();
95
96     /**
97      * Returns the reference of the structure as {@link Map}[zoneID, {@link Map}[groupID,
98      * {@link List}[{@link Device}]]].
99      *
100      * @return structure reference
101      */
102     Map<Integer, Map<Short, List<Device>>> getStructureReference();
103
104     /**
105      * Returns the Map of all groups as format HashMap[Short, List[Device]].
106      *
107      * @param zoneID of the zone
108      * @return groups
109      */
110     Map<Short, List<Device>> getGroupsFromZoneX(int zoneID);
111
112     /**
113      * Returns the reference {@link List} of the {@link Device}'s of a zone-group.
114      *
115      * @param zoneID of the zone
116      * @param groupID of the group
117      * @return reference device-list
118      */
119     List<Device> getReferenceDeviceListFromZoneXGroupX(int zoneID, short groupID);
120
121     /**
122      * Returns the {@link Device} of the given dSID as {@link String} or null if no {@link Device} exists.
123      *
124      * @param dSID of the device
125      * @return device
126      */
127     Device getDeviceByDSID(String dSID);
128
129     /**
130      * Returns the {@link Device} of the given dSID as {@link DSID} or null if no {@link Device} exists.
131      *
132      * @param dSID of the device
133      * @return device
134      */
135     Device getDeviceByDSID(DSID dSID);
136
137     /**
138      * Returns the {@link Device} of the given dSUID or null if no {@link Device} exists.
139      *
140      * @param dSUID of the device
141      * @return the {@link Device} with the given dSUID
142      */
143     Device getDeviceByDSUID(String dSUID);
144
145     /**
146      * Updates a {@link Device} of the structure.
147      *
148      * @param oldZone ID
149      * @param oldGroups ID's
150      * @param device new {@link Device}
151      */
152     void updateDevice(int oldZone, List<Short> oldGroups, Device device);
153
154     /**
155      * Updates a {@link Device} of the structure.
156      *
157      * @param device to update
158      */
159     void updateDevice(Device device);
160
161     /**
162      * Deletes a {@link Device} from the structure.
163      *
164      * @param device to delete
165      */
166     void deleteDevice(Device device);
167
168     /**
169      * Adds a {@link Device} to the structure.
170      *
171      * @param device to add
172      */
173     void addDeviceToStructure(Device device);
174
175     /**
176      * Returns a {@link Set} of all zoneID's
177      *
178      * @return zoneID's
179      */
180     Set<Integer> getZoneIDs();
181
182     /**
183      * Returns true, if a zone with the given zoneID exists, otherwise false.
184      *
185      * @param zoneID to check
186      * @return true = zoneID exists | false = zoneID not exists
187      */
188     boolean checkZoneID(int zoneID);
189
190     /**
191      * Returns true, if a zone-group with the given zoneID and groupID exists, otherwise false.
192      *
193      * @param zoneID to check
194      * @param groupID to check
195      * @return true = zoneID or groupID exists | false = zoneID or groupID not exists
196      */
197     boolean checkZoneGroupID(int zoneID, short groupID);
198
199     /**
200      * Adds the given {@link List} of {@link Circuit}'s to this {@link StructureManager}.
201      *
202      * @param referenceCircuitList to add
203      */
204     void addCircuitList(List<Circuit> referenceCircuitList);
205
206     /**
207      * Adds the given {@link Circuit} to this {@link StructureManager}.
208      *
209      * @param circuit to add
210      * @return the old {@link Circuit}, if the given {@link Circuit} was already added.
211      */
212     Circuit addCircuit(Circuit circuit);
213
214     /**
215      * Returns the {@link Circuit} with the given {@link DSID}.
216      *
217      * @param dSID of the {@link Circuit} to get
218      * @return the {@link Circuit} with the given {@link DSID}
219      */
220     Circuit getCircuitByDSID(DSID dSID);
221
222     /**
223      * Returns the {@link Circuit} with the given dSID as {@link String}.
224      *
225      * @param dSID of the {@link Circuit} to get
226      * @return the {@link Circuit} with the given dSID
227      */
228     Circuit getCircuitByDSID(String dSID);
229
230     /**
231      * Returns the {@link Circuit} with the given dSUID as {@link DSUID}.
232      *
233      * @param dSUID of the {@link Circuit} to get
234      * @return the {@link Circuit} with the given {@link DSUID}
235      */
236     Circuit getCircuitByDSUID(DSUID dSUID);
237
238     /**
239      * Returns the {@link Circuit} with the given dSUID as {@link String}.
240      *
241      * @param dSUID of the {@link Circuit} to get
242      * @return the {@link Circuit} with the given dSUID
243      */
244     Circuit getCircuitByDSUID(String dSUID);
245
246     /**
247      * Updates the configuration of an added {@link Circuit} through a new {@link Circuit} object.
248      *
249      * @param newCircuit to update
250      * @return {@link Circuit} with the old configuration
251      */
252     Circuit updateCircuitConfig(Circuit newCircuit);
253
254     /**
255      * Deletes the {@link Circuit} with the given {@link DSID}.
256      *
257      * @param dSID of the {@link Circuit} to remove
258      * @return the removed {@link Circuit}
259      */
260     Circuit deleteCircuit(DSID dSID);
261
262     /**
263      * Deletes the {@link Circuit} with the given dSUID.
264      *
265      * @param dSUID of the {@link Circuit} to remove
266      * @return the removed {@link Circuit}
267      */
268     Circuit deleteCircuit(String dSUID);
269
270     /**
271      * Returns a {@link Map} of all {@link Circuit}'s which are added to this {@link StructureManager}.
272      *
273      * @return {@link Map} of all added {@link Circuit}'s
274      */
275     Map<DSID, Circuit> getCircuitMap();
276 }