SRTEngine(Devs model, double ending_t, Callback call_back);The constructor needs three arguments: the first argument is the
Devs model to be simulated, the second is the simulation
terminating time in second, the last is a callback function that
is used to inject a user-input into the simulation model.
The third argument Callback is defined as delegate
which can be seen as a function pointer in C#.
public delegate PortValue Callback(Devs model);
Callback is supposed to return a PortValue which
represents the user input to the model. Thus, PortValue's
port should be an input port of Devs model.
The following example shows that InjectMsg returns a
PortValue whose port is vm's ip input port.
PortValue InjectMsg(Devs md)
{
VM vm = (VM) md;
return PortValue(vm.ip);
}
Then, we can pass the above function pointer of InjectMsg
to an instance of SRTEngine as follows.
SRTEngine simEngine(vm, 10000, InjectMsg);We will see another example to use
Callback in the example
Ex_VendingMachin in Section
3.1.2.