View Javadoc

1   /*
2    * @(#) Positioner.java Mar 3, 2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.tutorial.section44;
11  
12  import java.rmi.RemoteException;
13  
14  import nl.tudelft.simulation.dsol.formalisms.dess.DifferentialEquation;
15  import nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface;
16  import nl.tudelft.simulation.logger.Logger;
17  
18  /***
19   * A Positioner <br>
20   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
21   * University of Technology </a>, the Netherlands. <br>
22   * See for project information <a
23   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
24   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
25   * License (GPL) </a>, no warranty <br>
26   * 
27   * @version 1.0 Mar 3, 2004 <br>
28   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
29   *         Jacobs </a>
30   */
31  public class Positioner extends DifferentialEquation
32  {
33  	/***
34  	 * constructs a new Positioner
35  	 * 
36  	 * @param simulator the simulator
37  	 * @throws RemoteException Exception
38  	 */
39  	public Positioner(final DESSSimulatorInterface simulator)
40  			throws RemoteException
41  	{
42  		super(simulator);
43  		this.initialize(0.0, new double[]{0.0, 0.0});
44  	}
45  
46  	/***
47  	 * sets the value
48  	 * 
49  	 * @param value the new value
50  	 */
51  	public void setValue(final double value)
52  	{
53  		try
54  		{
55  			super.initialize(this.simulator.getSimulatorTime(), new double[]{
56  					value, 0.0});
57  		} catch (RemoteException exception)
58  		{
59  			Logger.warning(this, "setValue", exception);
60  		}
61  	}
62  
63  	/***
64  	 * @see nl.tudelft.simulation.jstats.ode.DifferentialEquationInterface#dy(double,
65  	 *      double[])
66  	 */
67  	public double[] dy(final double x, final double[] y)
68  	{
69  		double[] dy = new double[2];
70  		dy[0] = y[1]; // v(t) = a(t)
71  		dy[1] = 0.5; // a(t) = constant
72  		return dy;
73  	}
74  }