All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tacitknowledge.slowlight.proxyserver.handler.behavior.SinusoidalBehavior Maven / Gradle / Ivy

The newest version!
package com.tacitknowledge.slowlight.proxyserver.handler.behavior;

import java.util.Map;

/**
 * Sinusoidal function implementation, values of this function could be controlled by passing amplitude and period parameters.
 *
 * @author Alexandr Donciu ([email protected])
 */
public class SinusoidalBehavior extends IntervalBehaviorFunction
{

    private static final String ARG_PERIOD = "period";
    private static final String ARG_AMPLITUDE = "amplitude";

    @Override
    public Object evaluate(final Map params)
    {
        long period = Long.parseLong((String) params.get(ARG_PERIOD));
        long amplitude = Long.parseLong((String) params.get(ARG_AMPLITUDE));

        long time = System.currentTimeMillis();

        return Long.toString((long) (amplitude * Math.sin(time / period) + amplitude));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy