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

com.neuronrobotics.sdk.addons.kinematics.AnalogRotoryLink Maven / Gradle / Ivy

There is a newer version: 3.28.0
Show newest version
package com.neuronrobotics.sdk.addons.kinematics;

import com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel;
import com.neuronrobotics.sdk.dyio.peripherals.IAnalogInputListener;


// TODO: Auto-generated Javadoc
/**
 * The Class AnalogRotoryLink.
 */
public class AnalogRotoryLink  extends AbstractRotoryLink implements IAnalogInputListener{
	
	/** The channel. */
	private AnalogInputChannel channel;
	
	/**
	 * Instantiates a new analog rotory link.
	 *
	 * @param c the c
	 * @param conf the conf
	 */
	public AnalogRotoryLink(AnalogInputChannel c,LinkConfiguration conf) {
		super(conf);
		setAnalogChannel(c);
	}

	/* (non-Javadoc)
	 * @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#cacheTargetValueDevice()
	 */
	@Override
	public void cacheTargetValueDevice() {
		//ignore, input only
	}

	/* (non-Javadoc)
	 * @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#flush(double)
	 */
	@Override
	public void flushDevice(double time) {
		//ignore, input only
	}
	
	/* (non-Javadoc)
	 * @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#flushAll(double)
	 */
	@Override
	public void flushAllDevice(double time) {
		//ignore, input only
	}

	/* (non-Javadoc)
	 * @see com.neuronrobotics.sdk.addons.kinematics.AbstractLink#getCurrentPosition()
	 */
	@Override
	public double getCurrentPosition() {
		int val=getChannel().getValue();
		fireLinkListener(val);
		return val;
	}

	/**
	 * Sets the analog channel.
	 *
	 * @param channel the new analog channel
	 */
	public void setAnalogChannel(AnalogInputChannel channel) {
		channel.addAnalogInputListener(this);
		channel.configAdvancedAsyncNotEqual(10);
		//new RuntimeException().printStackTrace();
		this.channel = channel;
	}

	/**
	 * Gets the channel.
	 *
	 * @return the channel
	 */
	public AnalogInputChannel getChannel() {
		return channel;
	}

	/* (non-Javadoc)
	 * @see com.neuronrobotics.sdk.dyio.peripherals.IAnalogInputListener#onAnalogValueChange(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel, double)
	 */
	@Override
	public void onAnalogValueChange(AnalogInputChannel chan, double value) {
		if(chan == getChannel() ) {
			fireLinkListener((int) value);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy