62,614
社区成员
发帖
与我相关
我的任务
分享
public class simpleLogicalProcess<LP,S extends AbstractState> extends
LogicalProcess<LP,S>{
//WB do i really need the flexibility?
private S innerstate;
public simpleLogicalProcess() {
super();
// TODO Auto-generated constructor stub
}
public simpleLogicalProcess(String name) {
super(name);
// TODO Auto-generated constructor stub
}
@Override
public ArrayList<LP> influenced() {
// TODO Auto-generated method stub
return super.influenced();
}
@Override
public ArrayList<IEvent<LP, ?, ?>> out() {
// TODO Auto-generated method stub
return super.out();
}
@Override
protected void sendEvent(IEvent<LP, ?, ?> event) {
// TODO Auto-generated method stub
super.sendEvent(event);
}
@Override
public void run(IEvent<?, ?, ?> event) {
// TODO Auto-generated method stub
if (event instanceof SimpleEvent)
{
setInnerstate(((SimpleEvent)event).changestate(this.getInnerstate()));
}
}
public S getInnerstate() {
return innerstate;
}
public void setInnerstate(S innerstate) {
this.innerstate = innerstate;
}
}
////////////
simpleLogicalProcess
////////////
package generic;
import java.util.ArrayList;
public class simpleLogicalProcess<LP,S extends AbstractState> extends LogicalProcess<LP>{
//WB do i really need the flexibility?
private Integer name;
private S innerstate;
public simpleLogicalProcess() {
super();
// TODO Auto-generated constructor stub
}
public simpleLogicalProcess(Integer id) {
name=id;
// TODO Auto-generated constructor stub
}
@Override
public ArrayList<LP> influenced() {
// TODO Auto-generated method stub
return super.influenced();
}
@Override
public ArrayList<IEvent<LP, ?, ?>> out() {
// TODO Auto-generated method stub
return super.out();
}
@Override
protected void sendEvent(IEvent<LP, ?, ?> event) {
// TODO Auto-generated method stub
//super.sendEvent(event);
}
public void run(IEvent<?, ?, ?> event) {
// TODO Auto-generated method stub
if (event instanceof SimpleEvent)
{
System.out.print("we are running"+((SimpleEvent<SonofState>)event).mark);
setInnerstate(((SimpleEvent<S>)event).changestate(this.getInnerstate()));
}
}
public static void main(String args[])
{
Event fly,land,refly;
simpleLogicalProcess<Integer,SonofState> runner1
=new simpleLogicalProcess<Integer,SonofState>((Integer)1);
simpleLogicalProcess<Integer,SonofState> runner2
=new simpleLogicalProcess<Integer,SonofState>((Integer)2);
fly=new SimpleEvent<SonofState>(2,1,123,1.0);
runner1.run(fly);
}
public S getInnerstate() {
System.out.print("we are getInnerstate");
return innerstate;
}
public void setInnerstate(S Sinnerstate) {
this.innerstate = Sinnerstate;
System.out.print("we are setInnerstate"+Sinnerstate.state1);
}
}
class SimpleEvent<S extends AbstractState> extends Event
{
public int mark=1234;
public SimpleEvent(Integer to,Integer from,Integer news,Double newTime)
{
super( to, from, news, newTime);
}
public S changestate(S raw){
return raw;
}
}
///////////////////////////
package generic;
public class AbstractState {
public static int state1=123;
}
/////////////////////
package generic;
public class SonofState extends AbstractState {
public static int sons=111;
public void printson(){
System.out.print(sons);
}
}
/////////////
package generic;
public class Event implements IEvent<Integer,Integer,Integer> {
private Integer sender,reciever,message;
private Double Time;
public Event(Integer to,Integer from,Integer news,Double newTime)
{
sender=from;
reciever=to;
message=news;
Time=newTime;
}
@Override
public Double getTime() {
// TODO Auto-generated method stub
return Time;
}
}
Iterator<ILogicalProcess<ILogicalProcess,State>> it =pingpong.getSubModelIterator();//just a list
public ArrayList<LP> influenced()
protected void sendEvent(IEvent<LP, ?, ?> event)
public interface ILogicalProcess <S extends AbstractState> extends IModel
{
....
public ArrayList<ILogicalProcess> influenced()
protected void sendEvent(IEvent<ILogicalProcess, ?, ?> event)
....
}