osate / osate2

Open Source AADL2 Tool Environment
http://osate.org
Eclipse Public License 2.0
36 stars 8 forks source link

Inconsistent error messages for behavior_specification on non-thread types #2279

Open smithdtyler opened 4 years ago

smithdtyler commented 4 years ago

Summary

OSATE warns me that I need complete states on behavior specifications for device and memory types (those are all I've tested). When I add complete states, it tells me that I am not allowed to have complete states on those types of components.

MWE

package BehaviorsOnThings
public

    abstract tiger
    end tiger;

    abstract implementation tiger.white_tiger
    end tiger.white_tiger;

    memory brain
        features
            hunger_status_in: in data port;
    end brain;

    -- I am seeing some odd errors/warnings from the behavior annex
    -- Sometimes it asks for complete states, other times it says they are not allowed.
    memory implementation brain.tiger
        annex behavior_specification {**
            states
            hunting : initial state;
            playing : state;
            resting : state;
        transitions 
            t1 : hunting -[hunger_status_in=1]-> resting;
            t2 : playing -[hunger_status_in=1]-> resting;
            t3 : resting  -[hunger_status_in=1]-> hunting;
            t4 : playing  -[hunger_status_in=1]-> hunting;
        **};
    end brain.tiger;

    device mouth
    end mouth;

    device stomach
        features
            hunger_status: out data port;
            food_in: in event data port;

        annex behavior_specification {**
            states
                hungry : initial state;
                not_hungry :  state;
            transitions
                t1: hungry -[food_in=1]-> not_hungry;
                t2: not_hungry -[]-> hungry;
            **};
    end stomach;

    system hobbes
    end hobbes;

    system implementation hobbes.comic
        subcomponents
            stomach : device stomach;
            brain : memory brain.tiger;
    end hobbes.comic;
end BehaviorsOnThings;

Description Resource Path Location Type BehaviorsOnThings::stomach has no complete state : Behavior Annex D.3.(L3) legality rule failed. BehaviorsOnThings.aadl /com.adventiumlabs.sliced.unittest.modes line: 46 /com.adventiumlabs.sliced.unittest.modes/BehaviorsOnThings.aadl Xtext Check (fast)

If I add a complete state:

annex behavior_specification {**
    states
        hungry : initial state;
        not_hungry : complete state;
    transitions
        t1: hungry -[food_in=1]-> not_hungry;
         t2: not_hungry -[]-> hungry;
**};

Then I get

Description Resource Path Location Type Transitions out of complete states must have dispatch condition : Behavior Annex D.3.(L7) legality rule failed. BehaviorsOnThings.aadl /com.adventiumlabs.sliced.unittest.modes line: 52 /com.adventiumlabs.sliced.unittest.modes/BehaviorsOnThings.aadl Xtext Check (fast)

And then adding on dispatch

annex behavior_specification {**
    states
        hungry : initial state;
       not_hungry : complete state;
    transitions
        t1: hungry -[food_in=1]-> not_hungry;
        t2: not_hungry -[on dispatch]-> hungry;
**};

Description Resource Path Location Type device components cannot contain a dispatch condition in any of their transitions: they cannot be dispatched (extension of Behavior Annex D.3.(L5) legality rule). BehaviorsOnThings.aadl /com.adventiumlabs.sliced.unittest.modes line: 52 /com.adventiumlabs.sliced.unittest.modes/BehaviorsOnThings.aadl Xtext Check (fast)

Environment

Etienne13 commented 4 years ago

Hi Tyler,

when it comes to memory components, I think the issue is that the error message does not help to understand what is wrong: if you want to use a BA in a memory component, the purpose is to define a state machine for the component's modes. So your states should represent modes and you transitions should represent mode transitions.

when it comes to the devices components, the error is due to the fact the BA plugin did not manage to find that the Dispatch_Protocol property can apply to devices. We should investigate why. This reminded me of #2151 which I experienced some time ago but I was not able to reproduce it.

Etienne13 commented 4 years ago

I have tried to reproduce the issue but that was not fruitful: after performing the two modifications suggested by Tyler in the provided model, I get no error message (none for the memory component, and none for the device component).

@smithdtyler for the memory component, I could add a rule to check there is at least one complete state. I would then improve the error messages to guide towards mode transitions out of this complete state. Is this ok for you?

@lwrage I only tested with OSATE 2.7.0-vfinal (product version) on Linux. The only difference I see with Tyler's environment is the OS (Windows 10). Can you see if you get an error message with the following model? @smithdtyler are there specific steps (e.g. edition/opening/closing the aadl file) to reproduce the issue?

package BehaviorsOnThings
public

    abstract tiger
    end tiger;

    abstract implementation tiger.white_tiger
    end tiger.white_tiger;

    memory brain
        features
            hunger_status_in: in data port;
    end brain;

    -- I am seeing some odd errors/warnings from the behavior annex
    -- Sometimes it asks for complete states, other times it says they are not allowed.
    memory implementation brain.tiger
        annex behavior_specification {**        
        states
            hunting : initial state;
            playing : state;
            resting : state;
        transitions 
            t1 : hunting -[hunger_status_in=1]-> resting;
            t2 : playing -[hunger_status_in=1]-> resting;
            t3 : resting  -[hunger_status_in=1]-> hunting;
            t4 : playing  -[hunger_status_in=1]-> hunting;

        **};

    end brain.tiger;

    device mouth
    end mouth;

    device stomach
        features
            hunger_status: out data port;
            food_in: in event data port;

        annex behavior_specification {**            
            states
                hungry : initial state;
                not_hungry : complete state;
            transitions
                t1: hungry -[food_in=1]-> not_hungry;
                t2: not_hungry -[on dispatch]-> hungry;

            **};

    end stomach;

    system hobbes
    end hobbes;

    system implementation hobbes.comic
        subcomponents
            stomach : device stomach;
            brain : memory brain.tiger;
    end hobbes.comic;
end BehaviorsOnThings;
smithdtyler commented 4 years ago

@smithdtyler for the memory component, I could add a rule to check there is at least one complete state. I would then improve the error messages to guide towards mode transitions out of this complete state. Is this ok for you?

Yes, apologies for the slow response.

@smithdtyler are there specific steps (e.g. edition/opening/closing the aadl file) to reproduce the issue?

I observed variations in behavior depending on the order of clean/build/open/close, but I do not recall a specific set of steps to get this problem.