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