| /* |
| * Copyright (c) 2022 CEA LIST. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Florian Pauker (TU Wien) pauker@ift.at |
| * Thomas Fruhwirth (TU Wien) thomas.fruehwirth@tuwien.ac.at |
| *******************************************************************************/ |
| |
| library StateMachines; |
| |
| import Common.Helpers; |
| import States; |
| import Transitions; |
| |
| modeltype UML uses 'http://www.eclipse.org/uml2/5.0.0/UML'; |
| modeltype OPCUA uses set('http://opcfoundation.org/UA/2011/03/UANodeSet.xsd'); |
| |
| |
| // State machines in OPC UA are UAObjects of Supertype FiniteStateMachineType |
| mapping UML::StateMachine::statemachine2FiniteStateMachineType(inout nodeset : OPCUA::UANodeSetType) : OPCUA::UAObjectType { |
| log("statemachine2FiniteStateMachineType for UML element " + self.name); |
| |
| // set attributes of the OPCUA::UAObjectType |
| browseName := self.createBrowseName(); |
| nodeId := self.createNodeId(); |
| displayName := object OPCUA::LocalizedText{value := browseName}; |
| |
| // create the list of references object and add FiniteStateMachineType as supertype |
| _references := object OPCUA::ListOfReferences{}; |
| _references.reference += object OPCUA::Reference{referenceType := getIdOrAlias("HasSubtype"); value := getIdOrAlias("FiniteStateMachineType"); isForward := false}; |
| |
| // create an OPCUA::Object of type InitialStateType for each state |
| nodeset.uAObject += self.ownedElement->selectByType(UML::Region).ownedElement->selectByKind(UML::Pseudostate)->map pseudostate2InitialState(result); |
| nodeset.uAObject += self.ownedElement->selectByType(UML::Region).ownedElement->selectByKind(UML::State)->map state2State(result); |
| nodeset.uAObject += self.ownedElement->selectByType(UML::Region).ownedElement->selectByKind(UML::Transition)->map transition2Transition(nodeset, result); |
| |
| } |