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


7.3.6 ArmourMAOE (MissingAsynchronousOutEvent)

The foreign component is expected to generate an out-event asynchronously via the requires port but may not do that. The system diagram shows the armour at the requires port of the Dezyne component:

ArmourMAOE

We only deal with one void in-event and one void out-event. The Strict interface specifies that an in-event must lead to an asynchronous out-event. As a consequence a next in-event is only allowed after such an asynchronous out-event has happened.

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

  behaviour
  {
    bool ia_called = false;

    [!ia_called] on ia: {ia_called = true;}
    [ia_called] {
        on ia: illegal;
        on inevitable: {oa; ia_called = false;}
    }
  }
}

The Robust interface allows any occurrance of in-events and asynchronous out-events. We do allow to use multiple in-events without asynchronous out-events in between but the Dezyne component on top (the armour) will not issue multiple in-events.

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

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

In the strict sense we can never determine that an out-event is not coming anymore but a practical solution is to use a timeout period. After an in-event we start waiting for the asynchronous out-event from the requires port but we only wait for a given timeout period. If the timeout occurs we consider it an error; we log it and generate the missing out-event. If the out-event occurs within the deadline we pass it on and reset the armour top wait for a next in-event.

component ArmourMAOE {
    provides IStrict pStrict;
    requires IRobust rRobust;
    requires ITimer it;
    requires injected ILogger iLog;

    behaviour {
        bool waiting_for_oa = false;

        on it.timeout(): {
            iLog.Log($"timeout on expected oa"$);
            pStrict.oa(); waiting_for_oa = false;
        }
        [waiting_for_oa]
            on rRobust.oa(): {pStrict.oa(); it.cancel(); waiting_for_oa = false;}
        [!waiting_for_oa]{
            on pStrict.ia(): {rRobust.ia(); it.start(); waiting_for_oa = true;}
            on rRobust.oa(): {}
        }
    }
}

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

Basic example: ArmourMAOE
Example with error handling: ArmourMAOEError


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