| /******************************************************************************* |
| * Copyright (c) 2014-2016 Akos Horvath, Abel Hegedus, Akos Menyhert, Zoltan Ujhelyi, IncQuery Labs Ltd. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-v20.html. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| *******************************************************************************/ |
| package org.eclipse.viatra.examples.cps.generator.queries |
| |
| import "http://org.eclipse.viatra/model/cps" |
| |
| pattern Transitions(t : Transition, SM : StateMachine) { |
| StateMachine.states.outgoingTransitions(SM, t); |
| } |
| |
| pattern AllocatedAppInstances(A : ApplicationInstance, HI : HostInstance) { |
| ApplicationInstance.allocatedTo(A, HI); |
| } |
| |
| pattern ConnectedHosts(H : HostInstance, Trg : HostInstance) { |
| HostInstance.communicateWith(H, Trg); |
| H != Trg; |
| } |
| |
| pattern ReachableAppTypes(From : ApplicationType, To : ApplicationType) { |
| find appTypesOfHostInstanceApplications(FromH, From); |
| find appTypesOfHostInstanceApplications(ToH, To); |
| find ConnectedHosts(FromH, ToH); |
| } |
| |
| pattern appTypesOfHostInstanceApplications(HostInstance : HostInstance, AppType : ApplicationType) { |
| find AllocatedAppInstances(App, HostInstance); |
| ApplicationInstance.type(App,AppType); |
| } |
| |
| pattern AppTypesOfTransition(T : Transition, P : ApplicationType) { |
| find outTransitionsOfAppTypeSM(P,_SM,T); |
| } |
| |
| pattern ReceiverTransition(AppType : ApplicationType, Transition : Transition, SM : StateMachine){ |
| find outTransitionsOfAppTypeSM(AppType,SM,Transition); |
| neg find TransitionWithAction(Transition); |
| } |
| |
| pattern PossibleReceiverType(Sender : Transition, ReceiverAppType : ApplicationType){ |
| find ConnectedHosts(HSrc, HDst); |
| find TransitionOnAHost(HSrc,Sender,_); |
| find TransitionOnAHost(HDst,Receiver, ReceiverAppType); |
| Sender != Receiver; |
| } |
| |
| pattern TransitionOnAHost(H : HostInstance, T : Transition, AppType : ApplicationType){ |
| find appTypesOfHostInstanceApplications(H, AppType); |
| find outTransitionsOfAppTypeSM(AppType,_SM,T); |
| } |
| |
| pattern outTransitionsOfAppTypeSM(AppType : ApplicationType, SM : StateMachine, T : Transition) { |
| ApplicationType.behavior(AppType,SM); |
| find Transitions(T, SM); |
| } |
| |
| pattern TransitionWithoutAction(t:Transition){ |
| neg find TransitionWithAction(t); |
| } |
| |
| pattern TransitionWithAction(t:Transition){ |
| Transition.action(t,_action); |
| } |
| |
| pattern AppTypes(appType : ApplicationType) { |
| ApplicationType(appType); |
| } |
| |
| pattern AppInstances(A : ApplicationInstance) { |
| ApplicationInstance(A); |
| } |
| |
| pattern HostTypes(hostType : HostType) { |
| HostType(hostType); |
| } |
| |
| pattern HostInstances(hostInstance : HostInstance) { |
| HostInstance(hostInstance); |
| } |
| |
| pattern States(s : State) { |
| State(s); |
| } |