/**
 * Copyright (c) 2010-2020 Contributors to the openHAB project
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */

 /* ***********************************************************
 * This file was automatically generated on 2022-01-03.      *
 *                                                           *
 * openHAB Bindings Version 2.0.0                            *
 *                                                           *
 * If you have a bugfix for this file and want to commit it, *
 * please fix the bug in the generator. You can find a link  *
 * to the generators git repository on tinkerforge.com       *
 *************************************************************/

package org.openhab.binding.tinkerforge.internal.device;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.tinkerforge.internal.handler.DeviceHandler;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.binding.ThingActions;
import org.eclipse.smarthome.core.thing.binding.ThingActionsScope;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.types.RefreshType;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.openhab.core.automation.annotation.ActionInput;
import org.openhab.core.automation.annotation.ActionOutput;
import org.openhab.core.automation.annotation.RuleAction;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import java.util.Map;
import java.util.HashMap;

import com.tinkerforge.TinkerforgeException;
import com.tinkerforge.BrickletIO16;

/**
 * Passes through actions of the IO-16 Bricklet.
 * @author Erik Fleckstein - Initial contribution
 */
@ThingActionsScope(name = "tinkerforge")
@NonNullByDefault
public class BrickletIO16Actions implements ThingActions, IBrickletIO16Actions {

    private @Nullable DeviceHandler handler;

    @Override
    public void setThingHandler(@Nullable ThingHandler handler) { this.handler = (DeviceHandler) handler; }

    @Override
    public @Nullable ThingHandler getThingHandler() { return handler; }

    private static IBrickletIO16Actions invokeMethodOf(@Nullable ThingActions actions) {
        if (actions == null) {
            throw new IllegalArgumentException("actions cannot be null");
        }
        if (actions.getClass().getName().equals(BrickletIO16Actions.class.getName())) {
            if (actions instanceof IBrickletIO16Actions) {
                return (IBrickletIO16Actions) actions;
            } else {
                return (IBrickletIO16Actions) Proxy.newProxyInstance(IBrickletIO16Actions.class.getClassLoader(),
                        new Class[] { IBrickletIO16Actions.class }, (Object proxy, Method method, Object[] args) -> {
                            Method m = actions.getClass().getDeclaredMethod(method.getName(),
                                    method.getParameterTypes());
                            return m.invoke(actions, args);
                        });
            }
        }
        throw new IllegalArgumentException("Actions is not an instance of BrickletIO16Actions");
    }

        @Override
    @RuleAction(label = "Set Port")
    public void brickletIO16SetPort(
            @ActionInput(name = "port") char port,
            @ActionInput(name = "valueMask") short valueMask) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        Thing t = h.getThing();
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setPort(port, valueMask);
        if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output0")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output0"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output1")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output1"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output2")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output2"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output3")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output3"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output4")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output4"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output5")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output5"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output6")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output6"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output7")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output7"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output8")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output8"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output9")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output9"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output10")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output10"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output11")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output11"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output12")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output12"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output13")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output13"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output14")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output14"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output15")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output15"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop0")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop0"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop1")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop1"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop2")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop2"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop3")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop3"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop4")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop4"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop5")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop5"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop6")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop6"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop7")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop7"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop8")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop8"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop9")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop9"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop10")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop10"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop11")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop11"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop12")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop12"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop13")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop13"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop14")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop14"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop15")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop15"), RefreshType.REFRESH);
}
    }

    public static void brickletIO16SetPort(@Nullable ThingActions actions, char port, short valueMask) throws TinkerforgeException {
        invokeMethodOf(actions).brickletIO16SetPort(port, valueMask);
    }

    @Override
    @RuleAction(label = "Set Selected Values")
    public void brickletIO16SetSelectedValues(
            @ActionInput(name = "port") char port,
            @ActionInput(name = "selectionMask") short selectionMask,
            @ActionInput(name = "valueMask") short valueMask) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        Thing t = h.getThing();
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setSelectedValues(port, selectionMask, valueMask);
        if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output0")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output0"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output1")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output1"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output2")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output2"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output3")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output3"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output4")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output4"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output5")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output5"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output6")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output6"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output7")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output7"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output8")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output8"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output9")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output9"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output10")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output10"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output11")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output11"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output12")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output12"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output13")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output13"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output14")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output14"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output15")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output15"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop0")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop0"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop1")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop1"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop2")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop2"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop3")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop3"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop4")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop4"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop5")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop5"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop6")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop6"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop7")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop7"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop8")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop8"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop9")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop9"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop10")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop10"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop11")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop11"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop12")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop12"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop13")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop13"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop14")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop14"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop15")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop15"), RefreshType.REFRESH);
}
    }

    public static void brickletIO16SetSelectedValues(@Nullable ThingActions actions, char port, short selectionMask, short valueMask) throws TinkerforgeException {
        invokeMethodOf(actions).brickletIO16SetSelectedValues(port, selectionMask, valueMask);
    }

    @Override
    @RuleAction(label = "Set Port Monoflop")
    public void brickletIO16SetPortMonoflop(
            @ActionInput(name = "port") char port,
            @ActionInput(name = "selectionMask") short selectionMask,
            @ActionInput(name = "valueMask") short valueMask,
            @ActionInput(name = "time") long time) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        Thing t = h.getThing();
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setPortMonoflop(port, selectionMask, valueMask, time);
        if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output0")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output0"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output1")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output1"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output2")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output2"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output3")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output3"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output4")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output4"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output5")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output5"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output6")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output6"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output7")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output7"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output8")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output8"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output9")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output9"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output10")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output10"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output11")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output11"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output12")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output12"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output13")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output13"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output14")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output14"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Output15")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Output15"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop0")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop0"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop1")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop1"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop2")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop2"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop3")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop3"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop4")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop4"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop5")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop5"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop6")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop6"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop7")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop7"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop8")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop8"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop9")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop9"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop10")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop10"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop11")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop11"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop12")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop12"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop13")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop13"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop14")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop14"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16Monoflop15")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16Monoflop15"), RefreshType.REFRESH);
}
    }

    public static void brickletIO16SetPortMonoflop(@Nullable ThingActions actions, char port, short selectionMask, short valueMask, long time) throws TinkerforgeException {
        invokeMethodOf(actions).brickletIO16SetPortMonoflop(port, selectionMask, valueMask, time);
    }


    @Override
    @RuleAction(label = "Get Port")
    public @ActionOutput(name = "valueMask", type="short")
           Map<String, Object> brickletIO16GetPort(
            @ActionInput(name = "port") char port) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        short value = dev.getPort(port);
        
        result.put("valueMask", value);
        return result;
    }

    public static Map<String, Object> brickletIO16GetPort(@Nullable ThingActions actions, char port) throws TinkerforgeException {
        return invokeMethodOf(actions).brickletIO16GetPort(port);
    }


    @Override
    @RuleAction(label = "Get Port Configuration")
    public @ActionOutput(name = "directionMask", type="short")
           @ActionOutput(name = "valueMask", type="short")
           Map<String, Object> brickletIO16GetPortConfiguration(
            @ActionInput(name = "port") char port) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickletIO16.PortConfiguration value = dev.getPortConfiguration(port);
        
        result.put("directionMask", value.directionMask);
        result.put("valueMask", value.valueMask);
        return result;
    }

    public static Map<String, Object> brickletIO16GetPortConfiguration(@Nullable ThingActions actions, char port) throws TinkerforgeException {
        return invokeMethodOf(actions).brickletIO16GetPortConfiguration(port);
    }


    @Override
    @RuleAction(label = "Get Edge Count")
    public @ActionOutput(name = "count", type="long")
           Map<String, Object> brickletIO16GetEdgeCount(
            @ActionInput(name = "pin") short pin,
            @ActionInput(name = "resetCounter") boolean resetCounter) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        Thing t = h.getThing();
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        long value = dev.getEdgeCount(pin, resetCounter);
        if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16EdgeCount0")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16EdgeCount0"), RefreshType.REFRESH);
}
if(t.getChannel(new ChannelUID(t.getUID(), "BrickletIO16EdgeCount1")) != null){
	h.handleCommand(new ChannelUID(t.getUID(), "BrickletIO16EdgeCount1"), RefreshType.REFRESH);
}
        result.put("count", value);
        return result;
    }

    public static Map<String, Object> brickletIO16GetEdgeCount(@Nullable ThingActions actions, short pin, boolean resetCounter) throws TinkerforgeException {
        return invokeMethodOf(actions).brickletIO16GetEdgeCount(pin, resetCounter);
    }


    @Override
    @RuleAction(label = "Get Port Monoflop")
    public @ActionOutput(name = "value", type="short")
           @ActionOutput(name = "time", type="long")
           @ActionOutput(name = "timeRemaining", type="long")
           Map<String, Object> brickletIO16GetPortMonoflop(
            @ActionInput(name = "port") char port,
            @ActionInput(name = "pin") short pin) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickletIO16.PortMonoflop value = dev.getPortMonoflop(port, pin);
        
        result.put("value", value.value);
        result.put("time", value.time);
        result.put("timeRemaining", value.timeRemaining);
        return result;
    }

    public static Map<String, Object> brickletIO16GetPortMonoflop(@Nullable ThingActions actions, char port, short pin) throws TinkerforgeException {
        return invokeMethodOf(actions).brickletIO16GetPortMonoflop(port, pin);
    }


    @Override
    @RuleAction(label = "Get Edge Count Config")
    public @ActionOutput(name = "edgeType", type="short")
           @ActionOutput(name = "debounce", type="short")
           Map<String, Object> brickletIO16GetEdgeCountConfig(
            @ActionInput(name = "pin") short pin) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickletIO16.EdgeCountConfig value = dev.getEdgeCountConfig(pin);
        
        result.put("edgeType", value.edgeType);
        result.put("debounce", value.debounce);
        return result;
    }

    public static Map<String, Object> brickletIO16GetEdgeCountConfig(@Nullable ThingActions actions, short pin) throws TinkerforgeException {
        return invokeMethodOf(actions).brickletIO16GetEdgeCountConfig(pin);
    }


    @Override
    @RuleAction(label = "Get Identity")
    public @ActionOutput(name = "uid", type="String")
           @ActionOutput(name = "connectedUid", type="String")
           @ActionOutput(name = "position", type="char")
           @ActionOutput(name = "hardwareVersion", type="short[]")
           @ActionOutput(name = "firmwareVersion", type="short[]")
           @ActionOutput(name = "deviceIdentifier", type="int")
           Map<String, Object> brickletIO16GetIdentity(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickletIO16Wrapper dev = ((@Nullable BrickletIO16Wrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickletIO16.Identity value = dev.getIdentity();
        
        result.put("uid", value.uid);
        result.put("connectedUid", value.connectedUid);
        result.put("position", value.position);
        result.put("hardwareVersion", value.hardwareVersion);
        result.put("firmwareVersion", value.firmwareVersion);
        result.put("deviceIdentifier", value.deviceIdentifier);
        return result;
    }

    public static Map<String, Object> brickletIO16GetIdentity(@Nullable ThingActions actions) throws TinkerforgeException {
        return invokeMethodOf(actions).brickletIO16GetIdentity();
    }
}
