Next: , Previous: , Up: Individual Armour cases   [Contents]


7.3.5 ArmourISOE (IllegalSynchronousOutEvent)

The context is expected to not generate a synchronous out-event via the requires port but may still do that. The system diagram shows the armour at the requires port of the Dezyne component:

ArmourISOE

We only deal with one void in-event and one void out-event. The Strict interface specifies that the in-event does not lead to a synchronous out-event.

interface IStrict
{
  in void ia();
  out void oa();

  behaviour
  {
    on ia: {}
    on inevitable: oa;
  }
}

The Robust interface allows that in-event either results in a synchronous out-event or no out-event at all.

interface IRobust
{
  in void ia();
  out void oa();

  behaviour
  {
    on ia: {}
    on ia: oa;
    on inevitable: oa;
  }
}

In the armour we use the async keyword to discriminate between out-events that are triggered by an out-event from a requires port from a synchronous out-event. On the receival of an in-event we set a bool and put a request in the async queue. If the async acknowledge triggers and we have not had an out-event from the requires port in between we know the behaviour is according to the strict interface. If we receive an out-event from the requires port in the context of the provides in-event (we know by inspecting the boolean value) then we know it is an error and we deal with it. Otherwise we pass the out-event as normal allowed behaviour.

component ArmourISOE {
    provides IStrict pStrict;
    requires IRobust rRobust;
    requires injected ILogger iLog;

    behaviour {
        requires dzn.async p;

        bool requested = false;
        on pStrict.ia(): {
            rRobust.ia();
            if (!requested) {p.req(); requested = true;}
        }
        on rRobust.oa(): {
            if (!requested) pStrict.oa();
            else {
                requested = false; p.clr();
                iLog.Log($"Foreign comp does sync out-event oa where async oa was expected"$);
            }
        }
        on p.ack(): requested = false;
    }
}

The full armour example code including the client and overall system component is here:

Basic example: ArmourISOE
Example with error handling: ArmourISOEError


Next: , Previous: , Up: Individual Armour cases   [Contents]