LtiMainLcChannelAgent constructor

LtiMainLcChannelAgent({
  1. required Axi5SystemInterface sys,
  2. required LtiLcChannelInterface lc,
  3. required Component parent,
  4. String name = 'ltiMainLcChannelAgent',
  5. int? timeoutCycles,
  6. int? dropDelayCycles,
})

Constructs a new LtiMainLcChannelAgent.

Implementation

LtiMainLcChannelAgent({
  required this.sys,
  required this.lc,
  required Component parent,
  String name = 'ltiMainLcChannelAgent',
  this.timeoutCycles,
  this.dropDelayCycles,
}) : super(name, parent) {
  // credit tracking per virtual channel
  for (var i = 0; i < lc.vcCount; i++) {
    _creditCounts.add(0);
  }

  sequencer =
      Sequencer<LtiLcChannelPacket>('ltiMainLcChannelAgentSequencer', this);

  driver = LtiLcChannelDriver(
    parent: this,
    sys: sys,
    lc: lc,
    sequencer: sequencer,
    timeoutCycles: timeoutCycles,
    dropDelayCycles: dropDelayCycles,
    hasCredits: () => _creditCounts[0] > 0, // only 1 VC
    updateCredits: () => _creditCounts[0]--,
  );

  monitor = LtiCreditMonitor(sys: sys, trans: lc, parent: this);

  // credit returns
  monitor.stream.listen((c) {
    // only 1 VC
    if (c.credit > 0) {
      _creditCounts[0]++;
    }
  });
}