]> git.basschouten.com Git - openhab-addons.git/blob
839a4a160f32b81b231ba24ae4e78ea75bab4a1f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.pioneeravr.internal.protocol;
14
15 import org.openhab.binding.pioneeravr.internal.protocol.avr.AvrCommand;
16
17 /**
18  * A simple command without parameters.
19  *
20  * @author Antoine Besnard - Initial contribution
21  * @author Leroy Foerster - Listening Mode, Playing Listening Mode
22  */
23 public class SimpleCommand implements AvrCommand {
24
25     /**
26      * List of the simple command types.
27      */
28     public enum SimpleCommandType implements AvrCommand.CommandType {
29
30         POWER_ON("PO", "APO", "BPO", "ZEO"),
31         POWER_OFF("PF", "APF", "BPF", "ZEF"),
32         POWER_QUERY("?P", "?AP", "?BP", "?ZEP"),
33         VOLUME_UP("VU", "ZU", "YU", "HZU"),
34         VOLUME_DOWN("VD", "ZD", "YD", "HZD"),
35         VOLUME_QUERY("?V", "?ZV", "?YV", "?HZV"),
36         MUTE_ON("MO", "Z2MO", "Z3MO", "HZMO"),
37         MUTE_OFF("MF", "Z2MF", "Z3MF", "HZMF"),
38         MUTE_QUERY("?M", "?Z2M", "?Z3M", "?HZM"),
39         INPUT_CHANGE_CYCLIC("FU"),
40         INPUT_CHANGE_REVERSE("FD"),
41         LISTENING_MODE_CHANGE_CYCLIC("0010SR"),
42         LISTENING_MODE_QUERY("?S"),
43         INPUT_QUERY("?F", "?ZS", "?ZT", "?ZEA");
44
45         private String zoneCommands[];
46
47         private SimpleCommandType(String... command) {
48             this.zoneCommands = command;
49         }
50
51         @Override
52         public String getCommand(int zone) {
53             return zoneCommands[zone - 1];
54         }
55     }
56
57     private CommandType commandType;
58     private int zone;
59
60     public SimpleCommand(CommandType commandType, int zone) {
61         this.commandType = commandType;
62         this.zone = zone;
63     }
64
65     @Override
66     public String getCommand() {
67         return commandType.getCommand(zone) + "\r";
68     }
69
70     @Override
71     public CommandType getCommandType() {
72         return commandType;
73     }
74
75     @Override
76     public int getZone() {
77         return zone;
78     }
79 }