blob: a1e16816a4581bf8c21008f2f5f015a0ec650215 [file]
RoomModel DynAct5 {
import etrice.api.types.string
LogicalSystem LS {
SubSystemRef main: Main
}
SubSystemClass Main {
ActorRef appl: Appl
LogicalThread dflt_thread
}
ActorClass Appl {
Structure {
ActorRef cont: Container
}
Behavior { }
}
ActorClass Container {
Structure {
conjugated Port p0: PC
optional ActorRef opt: Optional
Binding p0 and opt.p0
}
Behavior {
// this method prints the passed message and then dumps the object tree consisting of actors and ports
Operation dumpTree(msg: string) '''
System.out.println(msg);
System.out.println(((org.eclipse.etrice.runtime.java.messaging.RTObject)getRoot()).toStringRecursive());'''
StateMachine {
Transition init: initial -> CreateOptional { }
Transition tr0: CreateOptional -> Done {
triggers {
<hello: p0>
}
action '''
System.out.println(transitionData+"\n");
opt.destroyOptionalActor();
dumpTree("after deletion of Optional2");''' }
State CreateOptional {
entry '''
opt.createOptionalActor("Optional", getThread());
p0.sayHello();'''
}
State Done {
entry '''System.out.println("Done, enter 'quit' to exit"); '''
}
}
}
}
// the class that is referenced as optional by the Container
// It has an external end port and implements the behavior itself
ActorClass Optional {
Interface {
Port p0: PC
}
Structure {
external Port p0
}
Behavior {
StateMachine {
Transition init: initial -> Ready { }
Transition tr0: Ready -> Ready {
triggers {
<sayHello: p0>
}
action '''p0.hello("this is AC1, instance "+getInstancePath());'''
}
State Ready
}
}
}
// a simple protocol that is used to demonstrate that actors are connected
ProtocolClass PC {
incoming {
Message sayHello()
}
outgoing {
Message hello(string)
}
}
}