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.automation.pidcontroller.internal.type;
15 import static org.openhab.automation.pidcontroller.internal.PIDControllerConstants.*;
17 import java.math.BigDecimal;
18 import java.util.List;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.automation.pidcontroller.internal.handler.PIDControllerActionHandler;
22 import org.openhab.core.automation.Visibility;
23 import org.openhab.core.automation.type.ActionType;
24 import org.openhab.core.automation.type.Input;
25 import org.openhab.core.config.core.ConfigDescriptionParameter;
26 import org.openhab.core.config.core.ConfigDescriptionParameter.Type;
27 import org.openhab.core.config.core.ConfigDescriptionParameterBuilder;
31 * @author Hilbrand Bouwkamp - Initial Contribution
34 public class PIDControllerActionType extends ActionType {
35 public static final String INPUT = "input";
37 public static PIDControllerActionType initialize() {
38 final ConfigDescriptionParameter outputItem = ConfigDescriptionParameterBuilder.create(OUTPUT, Type.TEXT)
39 .withRequired(true).withMultiple(false).withContext("item").withLabel("Output Item")
40 .withDescription("Item to send output").build();
41 final ConfigDescriptionParameter pInspectorItem = ConfigDescriptionParameterBuilder
42 .create(P_INSPECTOR, Type.TEXT).withRequired(false).withMultiple(false).withContext("item")
43 .withLabel("P Inspector Item").withDescription("Item for debugging the P part").build();
44 final ConfigDescriptionParameter iInspectorItem = ConfigDescriptionParameterBuilder
45 .create(I_INSPECTOR, Type.TEXT).withRequired(false).withMultiple(false).withContext("item")
46 .withLabel("I Inspector Item").withDescription("Item for debugging the I part").build();
47 final ConfigDescriptionParameter dInspectorItem = ConfigDescriptionParameterBuilder
48 .create(D_INSPECTOR, Type.TEXT).withRequired(false).withMultiple(false).withContext("item")
49 .withLabel("D Inspector Item").withDescription("Item for debugging the D part").build();
50 final ConfigDescriptionParameter eInspectorItem = ConfigDescriptionParameterBuilder
51 .create(E_INSPECTOR, Type.TEXT).withRequired(false).withMultiple(false).withContext("item")
52 .withLabel("Error Inspector Item").withDescription("Item for debugging the error value").build();
54 List<ConfigDescriptionParameter> config = List.of(outputItem, pInspectorItem, iInspectorItem, dInspectorItem,
57 List<Input> inputs = List.of(createInput(INPUT), createInput(P_INSPECTOR), createInput(I_INSPECTOR),
58 createInput(D_INSPECTOR), createInput(E_INSPECTOR));
60 return new PIDControllerActionType(config, inputs);
63 private static Input createInput(String name) {
64 return new Input(name, BigDecimal.class.getName());
67 public PIDControllerActionType(List<ConfigDescriptionParameter> configDescriptions, List<Input> inputs) {
68 super(PIDControllerActionHandler.MODULE_TYPE_ID, configDescriptions, "calculate PID output", null, null,
69 Visibility.VISIBLE, inputs, null);