]> git.basschouten.com Git - openhab-addons.git/blob
de086e06a402ff8106d263c856e9535962c6965e
[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.paradoxalarm.internal.communication;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 /**
19  * The {@link MemoryMap} this keeps Paradox RAM map as cached object inside the communicator.
20  * Every record in the list is byte array which contains 64 byte RAM page.
21  *
22  * @author Konstantin Polihronov - Initial contribution
23  */
24 public class MemoryMap {
25     private List<byte[]> ramCache = new ArrayList<>();
26
27     public MemoryMap(List<byte[]> ramCache) {
28         this.ramCache = ramCache;
29     }
30
31     public List<byte[]> getRamCache() {
32         return ramCache;
33     }
34
35     public void setRamCache(List<byte[]> ramCache) {
36         this.ramCache = ramCache;
37     }
38
39     public synchronized byte[] getElement(int index) {
40         return ramCache.get(index);
41     }
42
43     public synchronized void updateElement(int index, byte[] elementValue) {
44         ramCache.set(index - 1, elementValue);
45     }
46 }