📄 simpleoutport.java
字号:
package name.lxm.robot.arch;
import java.util.*;
public class SimpleOutPort implements Port
{
private String name;
private boolean i_flag;
private long i_time;
private String module_name;
private Module module = null;
private long timestamp;
private WireConfig wc = null;
public SimpleOutPort(Module module, String port_name)
{
this.module = module;
this.name = port_name;
i_flag = false;
i_time = 0;
}
public String getPortName()
{
return name;
}
public int getPortType()
{
return Port.PT_O;
}
/*
public void setUpperValue(Object v, long t, int i_s)
{
if(i_s != Port.OP_INHIBIT) return;
i_flag = true;
i_time = t;
timestamp = System.currentTimeMillis();
}
*/
public void setValue(Module module, Object v, long duration)
{
//{{{1
/*judge if output is disabled*/
if(i_flag && ((System.currentTimeMillis() - timestamp)<i_time))
{
return; //output is disabled
}
/* Looking for the target module and port */
Platform platform = Platform.getPlatform();
if(wc == null)
{
wc = platform.getWireConfig(module.getName()+"."+name);
if(wc == null)
return;
}
List list = wc.getWireTargets();
for(int i=0; i<list.size(); i++)
{
WireConfig.WireTarget wt = (WireConfig.WireTarget) list.get(i);
Module m = platform.getModule(wt.getTModule());
if(WireConfig.WireTarget.WTT_DIRECT.equals(wt.getType()))
{
//direct connect
m.getPort(wt.getTPort()).setValue(module, v, 1000);
}
else if(WireConfig.WireTarget.WTT_SUPPRESS.equals(wt.getType()))
{
//to lower layer
m.getPort(wt.getTPort()).setValue(module, v, wt.getDuration());
}else
{
m.getPort(wt.getTPort()).setValue(module, v, wt.getDuration());
}
}
//}}}1
}
public Object getValue()
{
//not used in output port
return null;
}
public Object getValue2()
{
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -