/**
 * 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.BrickServo;

/**
 * Passes through actions of the Servo Brick.
 * @author Erik Fleckstein - Initial contribution
 */
@ThingActionsScope(name = "tinkerforge")
@NonNullByDefault
public class BrickServoActions implements ThingActions, IBrickServoActions {

    private @Nullable DeviceHandler handler;

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

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

    private static IBrickServoActions invokeMethodOf(@Nullable ThingActions actions) {
        if (actions == null) {
            throw new IllegalArgumentException("actions cannot be null");
        }
        if (actions.getClass().getName().equals(BrickServoActions.class.getName())) {
            if (actions instanceof IBrickServoActions) {
                return (IBrickServoActions) actions;
            } else {
                return (IBrickServoActions) Proxy.newProxyInstance(IBrickServoActions.class.getClassLoader(),
                        new Class[] { IBrickServoActions.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 BrickServoActions");
    }

        @Override
    @RuleAction(label = "Enable")
    public void brickServoEnable(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.enable(servoNum);
        
    }

    public static void brickServoEnable(@Nullable ThingActions actions, short servoNum) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoEnable(servoNum);
    }

    @Override
    @RuleAction(label = "Disable")
    public void brickServoDisable(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.disable(servoNum);
        
    }

    public static void brickServoDisable(@Nullable ThingActions actions, short servoNum) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoDisable(servoNum);
    }


    @Override
    @RuleAction(label = "Is Enabled")
    public @ActionOutput(name = "enabled", type="boolean")
           Map<String, Object> brickServoIsEnabled(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        boolean value = dev.isEnabled(servoNum);
        
        result.put("enabled", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Position")
    public void brickServoSetPosition(
            @ActionInput(name = "servoNum") short servoNum,
            @ActionInput(name = "position") short position) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setPosition(servoNum, position);
        
    }

    public static void brickServoSetPosition(@Nullable ThingActions actions, short servoNum, short position) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoSetPosition(servoNum, position);
    }


    @Override
    @RuleAction(label = "Get Position")
    public @ActionOutput(name = "position", type="short")
           Map<String, Object> brickServoGetPosition(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        short value = dev.getPosition(servoNum);
        
        result.put("position", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Current Position")
    public @ActionOutput(name = "position", type="short")
           Map<String, Object> brickServoGetCurrentPosition(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        short value = dev.getCurrentPosition(servoNum);
        
        result.put("position", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Velocity")
    public void brickServoSetVelocity(
            @ActionInput(name = "servoNum") short servoNum,
            @ActionInput(name = "velocity") int velocity) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setVelocity(servoNum, velocity);
        
    }

    public static void brickServoSetVelocity(@Nullable ThingActions actions, short servoNum, int velocity) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoSetVelocity(servoNum, velocity);
    }


    @Override
    @RuleAction(label = "Get Velocity")
    public @ActionOutput(name = "velocity", type="int")
           Map<String, Object> brickServoGetVelocity(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getVelocity(servoNum);
        
        result.put("velocity", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Current Velocity")
    public @ActionOutput(name = "velocity", type="int")
           Map<String, Object> brickServoGetCurrentVelocity(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getCurrentVelocity(servoNum);
        
        result.put("velocity", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Acceleration")
    public void brickServoSetAcceleration(
            @ActionInput(name = "servoNum") short servoNum,
            @ActionInput(name = "acceleration") int acceleration) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setAcceleration(servoNum, acceleration);
        
    }

    public static void brickServoSetAcceleration(@Nullable ThingActions actions, short servoNum, int acceleration) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoSetAcceleration(servoNum, acceleration);
    }


    @Override
    @RuleAction(label = "Get Acceleration")
    public @ActionOutput(name = "acceleration", type="int")
           Map<String, Object> brickServoGetAcceleration(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getAcceleration(servoNum);
        
        result.put("acceleration", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Output Voltage")
    public void brickServoSetOutputVoltage(
            @ActionInput(name = "voltage") int voltage) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setOutputVoltage(voltage);
        
    }

    public static void brickServoSetOutputVoltage(@Nullable ThingActions actions, int voltage) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoSetOutputVoltage(voltage);
    }


    @Override
    @RuleAction(label = "Get Output Voltage")
    public @ActionOutput(name = "voltage", type="int")
           Map<String, Object> brickServoGetOutputVoltage(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getOutputVoltage();
        
        result.put("voltage", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Pulse Width")
    public void brickServoSetPulseWidth(
            @ActionInput(name = "servoNum") short servoNum,
            @ActionInput(name = "min") int min,
            @ActionInput(name = "max") int max) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setPulseWidth(servoNum, min, max);
        
    }

    public static void brickServoSetPulseWidth(@Nullable ThingActions actions, short servoNum, int min, int max) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoSetPulseWidth(servoNum, min, max);
    }


    @Override
    @RuleAction(label = "Get Pulse Width")
    public @ActionOutput(name = "min", type="int")
           @ActionOutput(name = "max", type="int")
           Map<String, Object> brickServoGetPulseWidth(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickServo.PulseWidth value = dev.getPulseWidth(servoNum);
        
        result.put("min", value.min);
        result.put("max", value.max);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Degree")
    public void brickServoSetDegree(
            @ActionInput(name = "servoNum") short servoNum,
            @ActionInput(name = "min") short min,
            @ActionInput(name = "max") short max) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setDegree(servoNum, min, max);
        
    }

    public static void brickServoSetDegree(@Nullable ThingActions actions, short servoNum, short min, short max) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoSetDegree(servoNum, min, max);
    }


    @Override
    @RuleAction(label = "Get Degree")
    public @ActionOutput(name = "min", type="short")
           @ActionOutput(name = "max", type="short")
           Map<String, Object> brickServoGetDegree(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickServo.Degree value = dev.getDegree(servoNum);
        
        result.put("min", value.min);
        result.put("max", value.max);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Period")
    public void brickServoSetPeriod(
            @ActionInput(name = "servoNum") short servoNum,
            @ActionInput(name = "period") int period) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setPeriod(servoNum, period);
        
    }

    public static void brickServoSetPeriod(@Nullable ThingActions actions, short servoNum, int period) throws TinkerforgeException {
        invokeMethodOf(actions).brickServoSetPeriod(servoNum, period);
    }


    @Override
    @RuleAction(label = "Get Period")
    public @ActionOutput(name = "period", type="int")
           Map<String, Object> brickServoGetPeriod(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getPeriod(servoNum);
        
        result.put("period", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Servo Current")
    public @ActionOutput(name = "current", type="int")
           Map<String, Object> brickServoGetServoCurrent(
            @ActionInput(name = "servoNum") short servoNum) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getServoCurrent(servoNum);
        
        result.put("current", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Overall Current")
    public @ActionOutput(name = "current", type="int")
           Map<String, Object> brickServoGetOverallCurrent(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getOverallCurrent();
        
        result.put("current", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Stack Input Voltage")
    public @ActionOutput(name = "voltage", type="int")
           Map<String, Object> brickServoGetStackInputVoltage(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getStackInputVoltage();
        
        result.put("voltage", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get External Input Voltage")
    public @ActionOutput(name = "voltage", type="int")
           Map<String, Object> brickServoGetExternalInputVoltage(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getExternalInputVoltage();
        
        result.put("voltage", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Minimum Voltage")
    public @ActionOutput(name = "voltage", type="int")
           Map<String, Object> brickServoGetMinimumVoltage(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getMinimumVoltage();
        
        result.put("voltage", value);
        return result;
    }

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


    @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> brickServoGetIdentity(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickServo.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> brickServoGetIdentity(@Nullable ThingActions actions) throws TinkerforgeException {
        return invokeMethodOf(actions).brickServoGetIdentity();
    }


    @Override
    @RuleAction(label = "Is Status LED Enabled")
    public @ActionOutput(name = "enabled", type="boolean")
           Map<String, Object> brickServoIsStatusLEDEnabled(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        boolean value = dev.isStatusLEDEnabled();
        
        result.put("enabled", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Chip Temperature")
    public @ActionOutput(name = "temperature", type="short")
           Map<String, Object> brickServoGetChipTemperature(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        short value = dev.getChipTemperature();
        
        result.put("temperature", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Send Timeout Count")
    public @ActionOutput(name = "timeoutCount", type="long")
           Map<String, Object> brickServoGetSendTimeoutCount(
            @ActionInput(name = "communicationMethod") short communicationMethod) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        long value = dev.getSendTimeoutCount(communicationMethod);
        
        result.put("timeoutCount", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get SPITFP Baudrate Config")
    public @ActionOutput(name = "enableDynamicBaudrate", type="boolean")
           @ActionOutput(name = "minimumDynamicBaudrate", type="long")
           Map<String, Object> brickServoGetSPITFPBaudrateConfig(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickServo.SPITFPBaudrateConfig value = dev.getSPITFPBaudrateConfig();
        
        result.put("enableDynamicBaudrate", value.enableDynamicBaudrate);
        result.put("minimumDynamicBaudrate", value.minimumDynamicBaudrate);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get SPITFP Error Count")
    public @ActionOutput(name = "errorCountACKChecksum", type="long")
           @ActionOutput(name = "errorCountMessageChecksum", type="long")
           @ActionOutput(name = "errorCountFrame", type="long")
           @ActionOutput(name = "errorCountOverflow", type="long")
           Map<String, Object> brickServoGetSPITFPErrorCount(
            @ActionInput(name = "brickletPort") char brickletPort) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickServo.SPITFPErrorCount value = dev.getSPITFPErrorCount(brickletPort);
        
        result.put("errorCountACKChecksum", value.errorCountACKChecksum);
        result.put("errorCountMessageChecksum", value.errorCountMessageChecksum);
        result.put("errorCountFrame", value.errorCountFrame);
        result.put("errorCountOverflow", value.errorCountOverflow);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get SPITFP Baudrate")
    public @ActionOutput(name = "baudrate", type="long")
           Map<String, Object> brickServoGetSPITFPBaudrate(
            @ActionInput(name = "brickletPort") char brickletPort) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickServoWrapper dev = ((@Nullable BrickServoWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        long value = dev.getSPITFPBaudrate(brickletPort);
        
        result.put("baudrate", value);
        return result;
    }

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