Example #1
0
  /**
   * Augments the CFSM with a tracking channel and send synthetic messages on this channel to keep
   * track of the two events that are part of the binary invariant inv. Adds the synthetic events to
   * the CFSM alphabet.
   */
  private void augmentWithBinInvTracing(BinaryInvariant inv) {
    DistEventType e1 = inv.getFirst();
    DistEventType e2 = inv.getSecond();

    assert alphabet.contains(e1);
    assert alphabet.contains(e2);
    assert e1.getPid() < fsms.size();
    assert e2.getPid() < fsms.size();
    assert !invs.contains(invs);

    invs.add(inv);

    int scmId = this.channelIds.size();

    if (firstSyntheticChIndex > scmId) {
      firstSyntheticChIndex = scmId;
    }

    // Create and add a new invariant-specific channel.
    ChannelId invCid = new InvChannelId(inv, scmId);
    this.channelIds.add(invCid);

    // Update the FSM corresponding to e1.
    Set<FSMState> visited = Util.newSet();
    FSM f1 = this.fsms.get(e1.getPid());
    DistEventType e1Tracer1 = DistEventType.SynthSendEvent(e1, invCid, true);
    DistEventType e1Tracer2 = DistEventType.SynthSendEvent(e1, invCid, false);
    addSendToEventTx(f1, e1, e1Tracer1, e1Tracer2, visited);
    this.alphabet.add(e1Tracer1);
    this.alphabet.add(e1Tracer2);

    // Update the FSM corresponding to e2.
    visited.clear();
    FSM f2 = this.fsms.get(e2.getPid());
    DistEventType e2Tracer1 = DistEventType.SynthSendEvent(e2, invCid, true);
    DistEventType e2Tracer2 = DistEventType.SynthSendEvent(e2, invCid, false);
    addSendToEventTx(f2, e2, e2Tracer1, e2Tracer2, visited);
    this.alphabet.add(e2Tracer1);
    this.alphabet.add(e2Tracer2);

    inv.setFirstSynthTracers(e1Tracer1, e1Tracer2);
    inv.setSecondSynthTracers(e2Tracer1, e2Tracer2);
  }