001package com.pi4j.io.gpio.event;
002
003/*
004 * #%L
005 * **********************************************************************
006 * ORGANIZATION  :  Pi4J
007 * PROJECT       :  Pi4J :: Java Library (Core)
008 * FILENAME      :  IFTTTMakerChannelTriggerEvent.java
009 *
010 * This file is part of the Pi4J project. More information about
011 * this project can be found here:  https://www.pi4j.com/
012 * **********************************************************************
013 * %%
014 * Copyright (C) 2012 - 2019 Pi4J
015 * %%
016 * This program is free software: you can redistribute it and/or modify
017 * it under the terms of the GNU Lesser General Public License as
018 * published by the Free Software Foundation, either version 3 of the
019 * License, or (at your option) any later version.
020 *
021 * This program is distributed in the hope that it will be useful,
022 * but WITHOUT ANY WARRANTY; without even the implied warranty of
023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
024 * GNU General Lesser Public License for more details.
025 *
026 * You should have received a copy of the GNU General Lesser Public
027 * License along with this program.  If not, see
028 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
029 * #L%
030 */
031
032
033import com.pi4j.io.gpio.GpioPin;
034import com.pi4j.io.gpio.PinState;
035import com.pi4j.util.StringUtil;
036
037import java.util.EventObject;
038
039
040public class IFTTTMakerChannelTriggerEvent extends EventObject {
041
042    private static final long serialVersionUID = 1L;
043
044    protected final GpioPin pin;
045    protected final PinState state;
046    private final String eventName;
047    private String value1 = StringUtil.EMPTY;
048    private String value2 = StringUtil.EMPTY;
049    private String value3 = StringUtil.EMPTY;
050
051    public IFTTTMakerChannelTriggerEvent(Object obj, GpioPin pin, PinState state, String eventName, String value1, String value2, String value3) {
052        super(obj);
053        this.pin = pin;
054        this.state = state;
055        this.eventName = eventName;
056        this.value1 = value1;
057        this.value2 = value2;
058        this.value3 = value3;
059    }
060
061    /**
062     * Get the pin number that changed and raised this event.
063     *
064     * @return GPIO pin number (not header pin number; not wiringPi pin number)
065     */
066    public GpioPin getPin() {
067        return this.pin;
068    }
069
070    /**
071     * Get the pin state that activated this trigger.
072     *
073     * @return GPIO pin state
074     */
075    public PinState getState() { return this.state; }
076
077    /**
078     * Get the IFTTT event name configured for this trigger.
079     *
080     * @return IFTTT event name
081     */
082    public String getEventName() { return this.eventName; }
083
084    /**
085     * Get the IFTTT value1 data for this triggered event.
086     * By default, this is the GPIO pin name.
087     * The consumer can optionally override this value using the 'setValue1()' method.
088     *
089     * @return IFTTT value1 data
090     */
091    public String getValue1() { return this.value1; }
092
093    /**
094     * Set (override) the value1 data that will be sent to the IFTTT trigger event.
095     *
096     * @param data new value data/string
097     */
098    public void setValue1(String data) { this.value1 = data; }
099
100    /**
101     * Get the IFTTT value2 data for this triggered event.
102     * By default, this is the GPIO state value (integer).
103     * The consumer can optionally override this value using the 'setValue2()' method.
104     *
105     * @return IFTTT value2 data
106     */
107    public String getValue2() { return this.value2; }
108
109    /**
110     * Set (override) the value2 data that will be sent to the IFTTT trigger event.
111     *
112     * @param data new value data/string
113     */
114    public void setValue2(String data) { this.value2 = data; }
115
116    /**
117     * Get the IFTTT value2 data for this triggered event.
118     * By default, this is a JSON string of data including all details about the GPIO pin and PinState.
119     * The consumer can optionally override this value using the 'setValue3()' method.
120     *
121     * @return IFTTT value2 data
122     */
123    public String getValue3() { return this.value3; }
124
125    /**
126     * Set (override) the value3 data that will be sent to the IFTTT trigger event.
127     *
128     * @param data new value data/string
129     */
130    public void setValue3(String data) { this.value3 = data; }
131}