Transducer's behavior is pretty much opposite to that of
Generator. Figure 4.7 shows its state
transition diagram. It has an input port iin and a buffer
Collector as Dictionary<int, List<Job>> to collect
jobs coming in with respect to their types.
public class Transducer: Atomic
{
public InputPort iin;
Dictionary<int, List<Job>> Collector;
public Transducer(string name, TimeUnit tu): base(name, tu)
{
CollectStatistics(true); // default collecting statistics
iin = AddIP("in");
Collector = new Dictionary<int, List<Job>>();
}
Transducer::init() clears all clients in Collector.
Transducer::tau() returns
all the time so it is
passive.
public override void init() { Collector.Clear(); }
public override double tau() { return double.MaxValue; }
Transducer::delta_x() castes the input value x.value
to pv of Job type. It stamps pv with
(``SysOut'',CurrentTime), and pushes pv into
Collector. Since Transducer is always passive, it
has no output, and so delta_y() is not needed here;
public override bool delta_x(PortValue x)
{
Job pv = (Job) x.value;
if(pv != null)
{
//-- (event, time) stamping
pv.TimeMap.Add("SysOut", Devs.TimeCurrent);
if (Collector.ContainsKey(pv.type) == false)
Collector.Add(pv.type, new List<Job>());
Collector[pv.type].Add(pv);
}
//else
// throw new Exception("Type casting Failed!");
return false;
}
Recall that Transducer collects incoming Jobs
stamped with (``SysIn'',arrival-time) by Generator,
(``SysOut'',departure-time) by Transducer. Using these
data, GetPerformance() of Transducers returns
{(``Throughput'', value) and (``Average System Time'', value) }
as follows.
Jobs in
Collector divided by the current time that is the
observation time-length Job in Collector.
Transducer in terms of their job types.
The function Transducer::GetPerformance() returns these
three indices. The source code of GetPerformance() is
available in Transducer.cs.