]> git.basschouten.com Git - openhab-addons.git/blob
fe124366d5b8eede4a282b2d28140c5ec57e0608
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.plclogo.internal;
14
15 import java.util.Collections;
16 import java.util.HashMap;
17 import java.util.Map;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.thing.ThingTypeUID;
22
23 /**
24  * The {@link PLCLogoBindingConstants} class defines common constants, which are
25  * used across the whole binding.
26  *
27  * @author Alexander Falkenstern - Initial contribution
28  */
29 @NonNullByDefault
30 public class PLCLogoBindingConstants {
31
32     public static final String BINDING_ID = "plclogo";
33
34     // List of all thing type UIDs
35     public static final ThingTypeUID THING_TYPE_DEVICE = new ThingTypeUID(BINDING_ID, "device");
36     public static final ThingTypeUID THING_TYPE_ANALOG = new ThingTypeUID(BINDING_ID, "analog");
37     public static final ThingTypeUID THING_TYPE_MEMORY = new ThingTypeUID(BINDING_ID, "memory");
38     public static final ThingTypeUID THING_TYPE_DIGITAL = new ThingTypeUID(BINDING_ID, "digital");
39     public static final ThingTypeUID THING_TYPE_DATETIME = new ThingTypeUID(BINDING_ID, "datetime");
40     public static final ThingTypeUID THING_TYPE_PULSE = new ThingTypeUID(BINDING_ID, "pulse");
41
42     // Something goes wrong...
43     public static final String NOT_SUPPORTED = "NOT SUPPORTED";
44
45     // List of all channels
46     public static final String STATE_CHANNEL = "state";
47     public static final String OBSERVE_CHANNEL = "observed";
48     public static final String VALUE_CHANNEL = "value";
49     public static final String RTC_CHANNEL = "rtc";
50     public static final String DAIGNOSTICS_CHANNEL = "diagnostic";
51     public static final String DAY_OF_WEEK_CHANNEL = "weekday";
52
53     // List of all channel properties
54     public static final String BLOCK_PROPERTY = "block";
55
56     // List of all item types
57     public static final String ANALOG_ITEM = "Number";
58     public static final String DATE_TIME_ITEM = "DateTime";
59     public static final String DIGITAL_INPUT_ITEM = "Contact";
60     public static final String DIGITAL_OUTPUT_ITEM = "Switch";
61     public static final String INFORMATION_ITEM = "String";
62
63     // LOGO! family definitions
64     public static final String LOGO_0BA7 = "0BA7";
65     public static final String LOGO_0BA8 = "0BA8";
66
67     // LOGO! block definitions
68     public static final String MEMORY_BYTE = "VB"; // Bit or Byte memory
69     public static final String MEMORY_WORD = "VW"; // Word memory
70     public static final String MEMORY_DWORD = "VD"; // DWord memory
71     public static final String MEMORY_SIZE = "SIZE"; // Size of memory
72
73     public static final String I_DIGITAL = "I"; // Physical digital input
74     public static final String Q_DIGITAL = "Q"; // Physical digital output
75     public static final String M_DIGITAL = "M"; // Program digital marker
76     public static final String NI_DIGITAL = "NI"; // Network digital input
77     public static final String NQ_DIGITAL = "NQ"; // Network digital output
78
79     public static final String I_ANALOG = "AI"; // Physical analog input
80     public static final String Q_ANALOG = "AQ"; // Physical analog output
81     public static final String M_ANALOG = "AM"; // Program analog marker
82     public static final String NI_ANALOG = "NAI"; // Network analog input
83     public static final String NQ_ANALOG = "NAQ"; // Network analog output
84
85     private static final Map<Integer, @Nullable String> LOGO_STATES_0BA7;
86     static {
87         Map<Integer, String> buffer = new HashMap<>();
88         // buffer.put(???, "Network access error"); // Netzwerkzugriffsfehler
89         // buffer.put(???, "Expansion module bus error"); // Erweiterungsmodul-Busfehler
90         // buffer.put(???, "SD card read/write error"); // Fehler beim Lesen oder Schreiben der SD-Karte
91         // buffer.put(???, "SD card write protection"); // Schreibschutz der SD-Karte
92         LOGO_STATES_0BA7 = Collections.unmodifiableMap(buffer);
93     }
94
95     private static final Map<Integer, @Nullable String> LOGO_STATES_0BA8;
96     static {
97         Map<Integer, String> buffer = new HashMap<>();
98         buffer.put(1, "Ethernet link error"); // Netzwerk Verbindungsfehler
99         buffer.put(2, "Expansion module changed"); // Ausgetauschtes Erweiterungsmodul
100         buffer.put(4, "SD card read/write error"); // Fehler beim Lesen oder Schreiben der SD-Karte
101         buffer.put(8, "SD Card does not exist"); // "SD-Karte nicht vorhanden"
102         buffer.put(16, "SD Card is full"); // SD-Karte voll
103         // buffer.put(???, "Network S7 Tcp Error"); //
104         LOGO_STATES_0BA8 = Collections.unmodifiableMap(buffer);
105     }
106
107     public static final Map<String, @Nullable Map<Integer, @Nullable String>> LOGO_STATES;
108     static {
109         Map<String, @Nullable Map<Integer, @Nullable String>> buffer = new HashMap<>();
110         buffer.put(LOGO_0BA7, LOGO_STATES_0BA7);
111         buffer.put(LOGO_0BA8, LOGO_STATES_0BA8);
112         LOGO_STATES = Collections.unmodifiableMap(buffer);
113     }
114
115     public static final class Layout {
116         public final int address;
117         public final int length;
118
119         public Layout(int address, int length) {
120             this.address = address;
121             this.length = length;
122         }
123     }
124
125     public static final Map<String, @Nullable Layout> LOGO_CHANNELS;
126     static {
127         Map<String, @Nullable Layout> buffer = new HashMap<>();
128         buffer.put(DAIGNOSTICS_CHANNEL, new Layout(984, 1)); // Diagnostics starts at 984 for 1 byte
129         buffer.put(RTC_CHANNEL, new Layout(985, 6)); // RTC starts at 985 for 6 bytes: year month day hour minute second
130         buffer.put(DAY_OF_WEEK_CHANNEL, new Layout(998, 1)); // Diagnostics starts at 998 for 1 byte
131         LOGO_CHANNELS = Collections.unmodifiableMap(buffer);
132     }
133
134     public static final Map<Integer, @Nullable String> DAY_OF_WEEK;
135     static {
136         Map<Integer, @Nullable String> buffer = new HashMap<>();
137         buffer.put(1, "SUNDAY");
138         buffer.put(2, "MONDAY");
139         buffer.put(3, "TUEsDAY");
140         buffer.put(4, "WEDNESDAY");
141         buffer.put(5, "THURSDAY");
142         buffer.put(6, "FRIDAY");
143         buffer.put(7, "SATURDAY");
144         DAY_OF_WEEK = Collections.unmodifiableMap(buffer);
145     }
146
147     private static final Map<String, @Nullable Layout> LOGO_MEMORY_0BA7;
148     static {
149         Map<String, @Nullable Layout> buffer = new HashMap<>();
150         buffer.put(MEMORY_BYTE, new Layout(0, 850));
151         buffer.put(MEMORY_DWORD, new Layout(0, 850));
152         buffer.put(MEMORY_WORD, new Layout(0, 850));
153         buffer.put(I_DIGITAL, new Layout(923, 3)); // Digital inputs starts at 923 for 3 bytes
154         buffer.put(Q_DIGITAL, new Layout(942, 2)); // Digital outputs starts at 942 for 2 bytes
155         buffer.put(M_DIGITAL, new Layout(948, 4)); // Digital markers starts at 948 for 4 bytes
156         buffer.put(I_ANALOG, new Layout(926, 16)); // Analog inputs starts at 926 for 16 bytes -> 8 words
157         buffer.put(Q_ANALOG, new Layout(944, 4)); // Analog outputs starts at 944 for 4 bytes -> 2 words
158         buffer.put(M_ANALOG, new Layout(952, 32)); // Analog markers starts at 952 for 32 bytes -> 16 words
159         buffer.put(MEMORY_SIZE, new Layout(0, 984)); // Size of memory block for LOGO! 7
160         LOGO_MEMORY_0BA7 = Collections.unmodifiableMap(buffer);
161     }
162
163     private static final Map<String, @Nullable Layout> LOGO_MEMORY_0BA8;
164     static {
165         Map<String, @Nullable Layout> buffer = new HashMap<>();
166         buffer.put(MEMORY_BYTE, new Layout(0, 850));
167         buffer.put(MEMORY_DWORD, new Layout(0, 850));
168         buffer.put(MEMORY_WORD, new Layout(0, 850));
169         buffer.put(I_DIGITAL, new Layout(1024, 8)); // Digital inputs starts at 1024 for 8 bytes
170         buffer.put(Q_DIGITAL, new Layout(1064, 8)); // Digital outputs starts at 1064 for 8 bytes
171         buffer.put(M_DIGITAL, new Layout(1104, 14)); // Digital markers starts at 1104 for 14 bytes
172         buffer.put(I_ANALOG, new Layout(1032, 32)); // Analog inputs starts at 1032 for 32 bytes -> 16 words
173         buffer.put(Q_ANALOG, new Layout(1072, 32)); // Analog outputs starts at 1072 for 32 bytes -> 16 words
174         buffer.put(M_ANALOG, new Layout(1118, 128)); // Analog markers starts at 1118 for 128 bytes -> 64 words
175         buffer.put(NI_DIGITAL, new Layout(1246, 16)); // Network inputs starts at 1246 for 16 bytes
176         buffer.put(NI_ANALOG, new Layout(1262, 128)); // Network analog inputs starts at 1262 for 128 bytes -> 64 words
177         buffer.put(NQ_DIGITAL, new Layout(1390, 16)); // Network outputs starts at 1390 for 16 bytes
178         buffer.put(NQ_ANALOG, new Layout(1406, 64)); // Network analog inputs starts at 1406 for 64 bytes -> 32 words
179         buffer.put(MEMORY_SIZE, new Layout(0, 1470)); // Size of memory block for LOGO! 8
180         LOGO_MEMORY_0BA8 = Collections.unmodifiableMap(buffer);
181     }
182
183     public static final Map<String, @Nullable Map<String, @Nullable Layout>> LOGO_MEMORY_BLOCK;
184     static {
185         Map<String, @Nullable Map<String, @Nullable Layout>> buffer = new HashMap<>();
186         buffer.put(LOGO_0BA7, LOGO_MEMORY_0BA7);
187         buffer.put(LOGO_0BA8, LOGO_MEMORY_0BA8);
188         LOGO_MEMORY_BLOCK = Collections.unmodifiableMap(buffer);
189     }
190 }