私はJavaが初めてなので、マルチスレッドの概念をまだ完全には理解していません.これを可能にするPIDControllerクラスを作成したいと思います:
ControllerMethods methods = new ControllerMethods()
{
public long getError(long setpoint)
{
//get an input
}
public void setOutput(long value)
{
//do something
}
public void isComplete(long setpoint)
{
return getError() == 0;
}
};
PIDController motorPID = new PIDController(setpoint, kp, ki, kd, methods);
motorPID.run();
//runs the PID controller to completion (methods.isComplete() == true)
motorPID.run(false);
//starts the PID controller in a separate thread, allowing
//continual monitoring in the current thread
while(motorPID.isRunning())
{
//do something else
if(condition1)
motorPID.pause();
//pause the PID controller, preventing the integral from increasing
else if(condition2)
motorPID.stop();
}
標準の PID アルゴリズムを計算する方法はわかりましたが、非同期機能を提供する方法はわかりません。
同様の API を実現する方法を誰か教えてもらえますか?