{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# FTG generation from a PM\n", "In this example notebook, we show how to generate an FTG out of a PM." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialization\n", "As usual, we start with the initialization of the Modelverse and the definition of the *view* operation for SVG." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.append(\"../wrappers\")\n", "from modelverse import *\n", "\n", "init()\n", "login(None, None)\n", "\n", "from IPython.display import SVG, display\n", "\n", "def view(model_name):\n", " svg = SVG()\n", " svg.data = show(model_name)\n", " display(svg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add models\n", "We add the models that we will be using: the process model that we want to fetch the FTG of, and we also load the FTG formalism." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "model_add(\"~/models/pm_powerwindow\", \"formalisms/ProcessModel\", open(\"../models/PowerWindow/PM_analyze.mvc\", 'r').read())\n", "model_add(\"~/formalisms/FormalismTransformationGraph\", \"formalisms/SimpleClassDiagrams\", open(\"../models/FTGPM/metamodels/FTG_MM.mvc\", 'r').read())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add transformation\n", "We now add the transformation that will generate the FTG part." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def add_traceability(model):\n", " instantiate(model, \"Association\", edge=(\"PM/Exec\", \"FTG/Activity\"), ID=\"activity_link\")\n", " instantiate(model, \"Association\", edge=(\"PM/Data\", \"FTG/Formalism\"), ID=\"formalism_link\")\n", "\n", "transformation_add_AL({\"PM\": \"formalisms/ProcessModel\"}, {\"FTG\": \"~/formalisms/FormalismTransformationGraph\"}, \"~/models/generate_FTG\", open(\"../models/FTGPM/transformations/PM_to_FTG.alc\", 'r').read(), add_traceability)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Execute transformation\n", "Finally we execute the transformation, thereby generating the FTG.\n", "The FTG model is subsequently visualized." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "__5818928 : Activityname = "models/revise_req"__5818997 : Activityname = "models/make_initial_models"__5819066 : Activityname = "models/revise_plant"__5819135 : Activityname = "models/revise_environment"__5819204 : Activityname = "models/revise_control"__5819273 : Activityname = "models/revise_query"__5819342 : Activityname = "models/revise_architecture"__5819411 : Activityname = "models/plant_to_EPN"__5819480 : Activityname = "models/environment_to_EPN"__5819549 : Activityname = "models/control_to_EPN"__5819618 : Activityname = "models/merge_EPN"__5819687 : Activityname = "models/combine_EPN"__5819756 : Activityname = "models/EPN_to_PN"__5819825 : Activityname = "models/reachability"__5819894 : Activityname = "models/match"__5819963 : Activityname = "models/bfs"__5820127 : Formalismname = "formalisms/Requirements"__5820196 : Formalismname = "formalisms/PW_Plant"__5820265 : Formalismname = "formalisms/PW_Environment"__5820334 : Formalismname = "formalisms/PW_Control"__5820403 : Formalismname = "formalisms/Encapsulated_PetriNet"__5820476 : Formalismname = "formalisms/PetriNet"__5820545 : Formalismname = "formalisms/ReachabilityGraph"__5820614 : Formalismname = "formalisms/Query"__5820683 : Formalismname = "formalisms/Architecture"" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "transformation_execute_AL(\"~/models/generate_FTG\", {\"PM\": \"~/models/pm_powerwindow\"}, {\"FTG\": \"~/models/ftg_powerwindow\"})\n", "view(\"~/models/ftg_powerwindow\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }