{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Jupyter Integration"
   ]
  },
  {
   "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(\"admin\", \"admin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_add(\"formalisms/FSA/metamodel\", \"formalisms/SimpleClassDiagrams\", open(\"../modelverse_GUI/models/FSA_MM.mvc\", 'r').read())\n",
    "transformation_add_AL({\"FSA\": \"formalisms/FSA/metamodel\"}, {}, \"formalisms/FSA/simulate\", open(\"../modelverse_GUI/models/FSA_simulate.alc\", 'r').read())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_add(\"models/my_FSA\", \"formalisms/FSA/metamodel\", \"\"\"\n",
    "    State a {\n",
    "        name = \"state_a\"\n",
    "        initial = True\n",
    "    }\n",
    "    State b {\n",
    "        name = \"state_b\"\n",
    "        initial = False\n",
    "    }\n",
    "    Transition (a, b) {\n",
    "        trigger = \"a\"\n",
    "        raise = \"b\"\n",
    "        script = $\n",
    "            include \"primitives.alh\"\n",
    "            include \"io.alh\"\n",
    "            Void function m():\n",
    "                output(\"TRANSITION\")\n",
    "                return!\n",
    "        $\n",
    "    }\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"96\" width=\"394\"><marker id=\"triangle\" orient=\"auto\" refX=\"0.0\" refY=\"0.0\" style=\"overflow:visible;\"><path d=\"M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z \" id=\"path941\" style=\"fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1\" transform=\"scale(0.8) rotate(180) translate(12.5,0)\"/></marker><line stroke=\"black\" style=\"marker-end:url(#triangle)\" x1=\"103\" x2=\"200.0\" y1=\"33\" y2=\"33.0\"/><line stroke=\"black\" x1=\"200.0\" x2=\"297\" y1=\"33.0\" y2=\"33\"/><rect fill=\"white\" height=\"90\" stroke=\"black\" width=\"154\" x=\"3\" y=\"3\"/><rect fill=\"white\" height=\"90\" stroke=\"black\" width=\"154\" x=\"197\" y=\"3\"/><line stroke=\"black\" x1=\"3\" x2=\"157\" y1=\"33\" y2=\"33\"/><line stroke=\"black\" x1=\"3\" x2=\"157\" y1=\"23\" y2=\"23\"/><line stroke=\"black\" x1=\"197\" x2=\"351\" y1=\"33\" y2=\"33\"/><line stroke=\"black\" x1=\"197\" x2=\"351\" y1=\"23\" y2=\"23\"/><text fill=\"black\" x=\"13\" y=\"18\">a : State</text><text fill=\"black\" x=\"13\" y=\"55.5\">name = &quot;state_a&quot;</text><text fill=\"black\" x=\"13\" y=\"70.5\">initial = true</text><text fill=\"black\" x=\"207\" y=\"18\">b : State</text><text fill=\"black\" x=\"207\" y=\"55.5\">name = &quot;state_b&quot;</text><text fill=\"black\" x=\"207\" y=\"70.5\">initial = false</text></svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.display import SVG, display\n",
    "svg = SVG()\n",
    "svg.data = show(\"models/my_FSA\")\n",
    "display(svg)"
   ]
  }
 ],
 "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
}
