• For more information about components, see the components part in the user guide.

Extend the file VendingMachine.component with the following text (you may copy the text below):

functional constraints

OperationalConstraintInsertCoin {
    /* InsertCoin Command of IUser returns NOT_OPERATIONAL
     * when IService is not in state Operational
     * Otherwise it returns ACCEPTED or NOT_ACCEPTED
     */
    use events
    command vmUserPort::InsertCoin
    vmUserPort::reply to command InsertCoin

    initial state CoinReply {

        transition trigger: vmUserPort::InsertCoin(int val)
            guard: NOT vmServicePort in Operational
            do:
            vmUserPort::reply (*,CoinResult::NOT_OPERATIONAL)
            next state: CoinReply

        transition trigger: vmUserPort::InsertCoin(int val)
            guard: vmServicePort in Operational
            do:
            vmUserPort::reply (*,CoinResult::ACCEPTED)
            next state: CoinReply
            OR
            do:
            vmUserPort::reply (*,CoinResult::NOT_ACCEPTED)
            next state: CoinReply
    }
}

Improve the lay-out using <CTRL>-<SHIFT>-F.

This specification assumes that interface IService has a state called Operational to represent that the machine is on and not in an error. Replace it with the state name of your model.

The functional constraint restricts the reply to command InsertCoin as indicated in the use events part. The specification expresses that when a reply to InsertCoin occurs, one of the following cases should hold:

To monitor the component constraints, change the file VendingMachine.prj as follows:

Run monitoring and inspect the dashboard with the results in folder comma-gen.