blob: d15d6065340c3f08daa86d0ba5f90d25ff23633d [file] [log] [blame]
[comment encoding = UTF-8 /]
[comment
-----------------------------------------------------------------------
-- Ada infrastructural code generator --
-- for the CHESS component model --
-- --
-- Copyright (C) 2011-2012 --
-- University of Padova, ITALY --
-- --
-- Author: Marco Panunzio panunzio@math.unipd.it --
-- --
-- All rights reserved. This program and the accompanying materials --
-- are made available under the terms of the Eclipse Public License --
-- v1.0 which accompanies this distribution, and is available at --
-- http://www.eclipse.org/legal/epl-v10.html --
-----------------------------------------------------------------------
/]
[module Deployment('http://www.eclipse.org/uml2/3.0.0/UML', 'http://www.eclipse.org/papyrus/GCM/1')]
[import org::polarsys::chess::codegen::ada::main::Copyright /]
[template public generateDeployment(model : Model, procNode: InstanceSpecification, compInstInputList : Sequence(OclAny), connectorInstInputList: Sequence(OclAny)) {
procNodeName : String = procNode.name;
clSvPortStName : String = 'MARTE::MARTE_DesignModel::GCM::ClientServerPort';
assignStName : String = 'MARTE::MARTE_Foundations::Alloc::Assign';
compImplStName : String = 'CHESS::ComponentModel::ComponentImplementation';
chHwProcessorStName : String = 'CHESS::Predictability::DeploymentConfiguration::HardwareBaseline::CH_HwProcessor';
isSingleNodeSystem : Boolean = isSingleNodeSystem(InstanceSpecification.allInstances()->asSequence(), chHwProcessorStName);
compInstList : Sequence(InstanceSpecification) = compInstInputList->filter(InstanceSpecification);
requiredInterfaceSlotList : Sequence(Slot) = getRequiredInterfaceSlotList(compInstList, clSvPortStName)->filter(Slot);
providedInterfaceSlotList : Sequence(Slot) = getProvidedInterfaceSlotList(compInstList, clSvPortStName)->filter(Slot);
connectorInstList : Sequence(InstanceSpecification) = connectorInstInputList->filter(InstanceSpecification);
isRemoteMsgClientNecessary : Boolean = isRemoteMsgClientNecessary(requiredInterfaceSlotList, procNode, connectorInstList, Comment.allInstances()->asSequence(), assignStName);
isRemoteMsgServerNecessary : Boolean = isRemoteMsgServerNecessary(providedInterfaceSlotList, procNode, connectorInstList, Comment.allInstances()->asSequence(), assignStName);
}
]
[comment Deployment .ads /]
[file (procNodeName.concat('/src/deployment/deployment.ads').toLower(), false, 'UTF-8')]
[generateCopyrightAda(model)/]
package Deployment is
procedure Initialize;
procedure Set_RI;
[if (not isSingleNodeSystem)]
procedure Init_Remote_Msg_Client;
procedure Set_Remote_Msg_Client_Binding;
procedure Set_Remote_Msg_Server_Binding;
[/if]
end Deployment;
[/file]
[comment Deployment .adb /]
[file (procNodeName.concat('/src/deployment/deployment.adb').toLower(), false, 'UTF-8')]
[generateCopyrightAda(model)/]
--with Ada.Text_IO;
[for (instSpec : InstanceSpecification | compInstList)]
with ['CT_'.concat(instSpec.name).replaceAll('\\.', '_').concat('s')/];
[/for]
[if (isRemoteMsgServerNecessary)]
with Remote_Msg_Server;
[/if]
[if (isRemoteMsgClientNecessary)]
with Remote_Msg_Client;
[/if]
package body Deployment is
procedure Initialize is
begin
[for (instSpec : InstanceSpecification | compInstList)]
['CT_'.concat(instSpec.name).replaceAll('\\.', '_').concat('s')/].Initialize_Container;
[/for]
end Initialize;
-- Setting RI of Containers (for the component instance embedded therein)
procedure Set_RI is
begin
--Ada.Text_IO.Put_Line("Deployment: Initializing RI of component instances");
null;
[for (sl : Slot | requiredInterfaceSlotList)]
[let boundSlot : Slot = getBoundPIslot(sl, connectorInstList)]
[if (getDeploymentProcessingNode(boundSlot, Comment.allInstances()->asSequence(), assignStName) = procNode)]
[let st : Stereotype = boundSlot.definingFeature.getAppliedStereotype(clSvPortStName)]
['CT_'.concat(sl.owningInstance.name).replaceAll('\\.', '_').concat('s')/].Set_[sl.definingFeature.name/](['CT_'.concat(boundSlot.owningInstance.name).replaceAll('\\.', '_').concat('s')/].Get_[getProvidedInterface((boundSlot.definingFeature.oclAsType(Port)), clSvPortStName).name/]);
[/let]
[/if]
[/let]
[/for]
end Set_RI;
[if (not isSingleNodeSystem)]
procedure Set_Remote_Msg_Client_Binding is
begin
[if (not isRemoteMsgClientNecessary)]
null;
[else]
[for (sl : Slot | requiredInterfaceSlotList)]
[let boundSlot : Slot = getBoundPIslot(sl, connectorInstList)]
[if (getDeploymentProcessingNode(boundSlot, Comment.allInstances()->asSequence(), assignStName) <> procNode)]
[let st : Stereotype = boundSlot.definingFeature.getAppliedStereotype(clSvPortStName)]
['CT_'.concat(sl.owningInstance.name).replaceAll('\\.', '_').concat('s')/].Set_[sl.definingFeature.name/](Remote_Msg_Client.Get_[getProvidedInterface((boundSlot.definingFeature.oclAsType(Port)), clSvPortStName).name/]);
[/let]
[/if]
[/let]
[/for]
[/if]
end Set_Remote_Msg_Client_Binding;
procedure Init_Remote_Msg_Client is
begin
[if (not isRemoteMsgClientNecessary)]
null;
[else]
Remote_Msg_Client.Init_Remote_Msg_Client;
[/if]
end Init_Remote_Msg_Client;
procedure Set_Remote_Msg_Server_Binding is
begin
[if (not isRemoteMsgServerNecessary)]
null;
[else]
[for (sl : Slot | providedInterfaceSlotList)]
[let boundSlot : Sequence(Slot) = getBoundRIslotList(sl, connectorInstList)->filter(Slot)]
[if (isRemoteCommNecessary(boundSlot, procNode, Comment.allInstances()->asSequence(), assignStName))]
Remote_Msg_Server.Set_[sl.definingFeature.name/](['CT_'.concat(sl.owningInstance.name.replaceAll('\\.', '_')).concat('s')/].Get_[getProvidedInterface((sl.definingFeature.oclAsType(Port)), clSvPortStName).name/]);
[/if]
[/let]
[/for]
[/if]
end Set_Remote_Msg_Server_Binding;
[/if]
end Deployment;
[/file]
[/template]
[query public isSingleNodeSystem(arg0 : Sequence(OclAny), arg1 : String) : Boolean
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'isSingleNodeSystem(java.util.List, java.lang.String)', Sequence{arg0, arg1}) /]
[query public getDeploymentProcessingNode(arg0: Slot, arg1 : Sequence(OclAny), arg2 : String) : InstanceSpecification
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'getDeploymentProcessingNode(org.eclipse.uml2.uml.Slot, java.util.List, java.lang.String)', Sequence{arg0, arg1, arg2}) /]
[query public getProvidedInterface(arg0 : Port, arg1 : String) : Interface
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'getProvidedInterface(org.eclipse.uml2.uml.Port, java.lang.String)', Sequence{arg0, arg1}) /]
[query public getRequiredInterfaceSlotList(arg0 : Sequence(OclAny), arg1 : String) : Sequence(OclAny)
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'getRequiredInterfaceSlotList(java.util.List, java.lang.String)', Sequence{arg0, arg1}) /]
[query public getProvidedInterfaceSlotList(arg0 : Sequence(OclAny), arg1 : String) : Sequence(OclAny)
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'getProvidedInterfaceSlotList(java.util.List, java.lang.String)', Sequence{arg0, arg1}) /]
[query public getBoundPIslot(arg0 : Slot, arg1 : Sequence(OclAny)) : Slot
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'getBoundPIslot(org.eclipse.uml2.uml.Slot, java.util.List)', Sequence{arg0, arg1}) /]
[query public getBoundRIslotList(arg0 : Slot, arg1 : Sequence(OclAny)) : Sequence(OclAny)
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'getBoundRIslotList(org.eclipse.uml2.uml.Slot, java.util.List)', Sequence{arg0, arg1}) /]
[query public isRemoteCommNecessary(arg0: Sequence(OclAny), arg1 : InstanceSpecification, arg2 : Sequence(OclAny), arg3 : String) : Boolean
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'isRemoteCommNecessary(java.util.List, org.eclipse.uml2.uml.InstanceSpecification, java.util.List, java.lang.String)', Sequence{arg0, arg1, arg2, arg3}) /]
[query public isRemoteMsgServerNecessary(arg0: Sequence(OclAny), arg1 : InstanceSpecification, arg2 : Sequence(OclAny), arg3 : Sequence(OclAny), arg4 : String) : Boolean
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'isRemoteMsgServerNecessary(java.util.List, org.eclipse.uml2.uml.InstanceSpecification, java.util.List, java.util.List, java.lang.String)', Sequence{arg0, arg1, arg2, arg3, arg4}) /]
[query public isRemoteMsgClientNecessary(arg0: Sequence(OclAny), arg1 : InstanceSpecification, arg2 : Sequence(OclAny), arg3 : Sequence(OclAny), arg4 : String) : Boolean
= invoke('org.polarsys.chess.codegen.ada.service.UML2Service', 'isRemoteMsgClientNecessary(java.util.List, org.eclipse.uml2.uml.InstanceSpecification, java.util.List, java.util.List, java.lang.String)', Sequence{arg0, arg1, arg2, arg3, arg4}) /]