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

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

    private @Nullable DeviceHandler handler;

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

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

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

        @Override
    @RuleAction(label = "Set Max Velocity")
    public void brickStepperSetMaxVelocity(
            @ActionInput(name = "velocity") int velocity) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setMaxVelocity(velocity);
        
    }

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


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

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

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


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

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

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

    @Override
    @RuleAction(label = "Set Speed Ramping")
    public void brickStepperSetSpeedRamping(
            @ActionInput(name = "acceleration") int acceleration,
            @ActionInput(name = "deacceleration") int deacceleration) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setSpeedRamping(acceleration, deacceleration);
        
    }

    public static void brickStepperSetSpeedRamping(@Nullable ThingActions actions, int acceleration, int deacceleration) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperSetSpeedRamping(acceleration, deacceleration);
    }


    @Override
    @RuleAction(label = "Get Speed Ramping")
    public @ActionOutput(name = "acceleration", type="int")
           @ActionOutput(name = "deacceleration", type="int")
           Map<String, Object> brickStepperGetSpeedRamping(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickStepper.SpeedRamping value = dev.getSpeedRamping();
        
        result.put("acceleration", value.acceleration);
        result.put("deacceleration", value.deacceleration);
        return result;
    }

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

    @Override
    @RuleAction(label = "Full Brake")
    public void brickStepperFullBrake(
            ) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.fullBrake();
        
    }

    public static void brickStepperFullBrake(@Nullable ThingActions actions) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperFullBrake();
    }

    @Override
    @RuleAction(label = "Set Steps")
    public void brickStepperSetSteps(
            @ActionInput(name = "steps") int steps) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setSteps(steps);
        
    }

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


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

        int value = dev.getSteps();
        
        result.put("steps", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get Remaining Steps")
    public @ActionOutput(name = "steps", type="int")
           Map<String, Object> brickStepperGetRemainingSteps(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        int value = dev.getRemainingSteps();
        
        result.put("steps", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Drive Forward")
    public void brickStepperDriveForward(
            ) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.driveForward();
        
    }

    public static void brickStepperDriveForward(@Nullable ThingActions actions) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperDriveForward();
    }

    @Override
    @RuleAction(label = "Drive Backward")
    public void brickStepperDriveBackward(
            ) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.driveBackward();
        
    }

    public static void brickStepperDriveBackward(@Nullable ThingActions actions) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperDriveBackward();
    }

    @Override
    @RuleAction(label = "Stop")
    public void brickStepperStop(
            ) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.stop();
        
    }

    public static void brickStepperStop(@Nullable ThingActions actions) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperStop();
    }

    @Override
    @RuleAction(label = "Set Motor Current")
    public void brickStepperSetMotorCurrent(
            @ActionInput(name = "current") int current) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setMotorCurrent(current);
        
    }

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


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

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

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

    @Override
    @RuleAction(label = "Enable")
    public void brickStepperEnable(
            ) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.enable();
        
    }

    public static void brickStepperEnable(@Nullable ThingActions actions) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperEnable();
    }

    @Override
    @RuleAction(label = "Disable")
    public void brickStepperDisable(
            ) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.disable();
        
    }

    public static void brickStepperDisable(@Nullable ThingActions actions) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperDisable();
    }


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

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

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

    @Override
    @RuleAction(label = "Set Current Position")
    public void brickStepperSetCurrentPosition(
            @ActionInput(name = "position") int position) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setCurrentPosition(position);
        
    }

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


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

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

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

    @Override
    @RuleAction(label = "Set Target Position")
    public void brickStepperSetTargetPosition(
            @ActionInput(name = "position") int position) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setTargetPosition(position);
        
    }

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


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

        int value = dev.getTargetPosition();
        
        result.put("position", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Step Mode")
    public void brickStepperSetStepMode(
            @ActionInput(name = "mode") short mode) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setStepMode(mode);
        
    }

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


    @Override
    @RuleAction(label = "Get Step Mode")
    public @ActionOutput(name = "mode", type="short")
           Map<String, Object> brickStepperGetStepMode(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        short value = dev.getStepMode();
        
        result.put("mode", value);
        return result;
    }

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


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

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

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


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

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

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


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

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

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

    @Override
    @RuleAction(label = "Set Decay")
    public void brickStepperSetDecay(
            @ActionInput(name = "decay") int decay) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setDecay(decay);
        
    }

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


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

        int value = dev.getDecay();
        
        result.put("decay", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Sync Rect")
    public void brickStepperSetSyncRect(
            @ActionInput(name = "syncRect") boolean syncRect) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setSyncRect(syncRect);
        
    }

    public static void brickStepperSetSyncRect(@Nullable ThingActions actions, boolean syncRect) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperSetSyncRect(syncRect);
    }


    @Override
    @RuleAction(label = "Is Sync Rect")
    public @ActionOutput(name = "syncRect", type="boolean")
           Map<String, Object> brickStepperIsSyncRect(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        boolean value = dev.isSyncRect();
        
        result.put("syncRect", value);
        return result;
    }

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

    @Override
    @RuleAction(label = "Set Time Base")
    public void brickStepperSetTimeBase(
            @ActionInput(name = "timeBase") long timeBase) throws TinkerforgeException {
        DeviceHandler h = handler;
        if(h == null) {
            return;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return;
        }
        dev.setTimeBase(timeBase);
        
    }

    public static void brickStepperSetTimeBase(@Nullable ThingActions actions, long timeBase) throws TinkerforgeException {
        invokeMethodOf(actions).brickStepperSetTimeBase(timeBase);
    }


    @Override
    @RuleAction(label = "Get Time Base")
    public @ActionOutput(name = "timeBase", type="long")
           Map<String, Object> brickStepperGetTimeBase(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        long value = dev.getTimeBase();
        
        result.put("timeBase", value);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get All Data")
    public @ActionOutput(name = "currentVelocity", type="int")
           @ActionOutput(name = "currentPosition", type="int")
           @ActionOutput(name = "remainingSteps", type="int")
           @ActionOutput(name = "stackVoltage", type="int")
           @ActionOutput(name = "externalVoltage", type="int")
           @ActionOutput(name = "currentConsumption", type="int")
           Map<String, Object> brickStepperGetAllData(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickStepper.AllData value = dev.getAllData();
        
        result.put("currentVelocity", value.currentVelocity);
        result.put("currentPosition", value.currentPosition);
        result.put("remainingSteps", value.remainingSteps);
        result.put("stackVoltage", value.stackVoltage);
        result.put("externalVoltage", value.externalVoltage);
        result.put("currentConsumption", value.currentConsumption);
        return result;
    }

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


    @Override
    @RuleAction(label = "Get All Data Period")
    public @ActionOutput(name = "period", type="long")
           Map<String, Object> brickStepperGetAllDataPeriod(
            ) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        long value = dev.getAllDataPeriod();
        
        result.put("period", value);
        return result;
    }

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


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

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


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

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

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


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

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

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


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

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

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


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

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

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


    @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> brickStepperGetSPITFPErrorCount(
            @ActionInput(name = "brickletPort") char brickletPort) throws TinkerforgeException {
        Map<String, Object> result = new HashMap<>();
        DeviceHandler h = handler;
        if(h == null) {
            return result;
        }
        
        @Nullable BrickStepperWrapper dev = ((@Nullable BrickStepperWrapper)h.getDevice());
        if(dev == null) {
            return result;
        }

        BrickStepper.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> brickStepperGetSPITFPErrorCount(@Nullable ThingActions actions, char brickletPort) throws TinkerforgeException {
        return invokeMethodOf(actions).brickStepperGetSPITFPErrorCount(brickletPort);
    }


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

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

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