📄 abstractmodule.java
字号:
package name.lxm.robot.arch;
public abstract class AbstractModule implements Runnable, Module, ValueUpdateListener
{
protected String module_name;
protected ModuleDoc doc;
protected Thread t_this;
protected boolean bRun = false;
public String getName()
{
return module_name;
}
public abstract Port getPort(String name);
public ModuleDoc getModuleDoc()
{
return doc;
}
public void init(ModuleDoc cfg) throws Exception
{
doc = cfg;
module_name = doc.getName();
}
public void start() throws Exception
{
t_this = new Thread(this);
bRun = true;
t_this.start();
}
public void stop() throws Exception
{
bRun = false;
int i = 0;
while(t_this.isAlive() && i < 5)
{
t_this.interrupt();
sleep(50);
i++;
}
if(t_this.isAlive())
throw new Exception("Cannot stop the module: " + module_name);
}
protected void sleep(long milli)
{
try{
Thread.sleep(milli);
}catch(InterruptedException e){}
}
public void destroy() throws Exception
{
}
public int getLayer()
{
return doc.getLayer();
}
public abstract void run();
public abstract void valueUpdated();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -