Browse Source

documentation start

Simon Van Mierlo 9 years ago
parent
commit
bbe902c64b

+ 2 - 1
.gitignore

@@ -9,4 +9,5 @@ csharp_tests/test-results
 csharp_tests/bin
 src/build
 **/*target*
-**/*.lprof
+**/*.lprof
+doc/_build

+ 225 - 0
doc/Makefile

@@ -0,0 +1,225 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  applehelp  to make an Apple Help Book"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  epub3      to make an epub3"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  xml        to make Docutils-native XML files"
+	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+	@echo "  coverage   to run coverage check of the documentation (if enabled)"
+	@echo "  dummy      to check syntax errors of document sources"
+
+.PHONY: clean
+clean:
+	rm -rf $(BUILDDIR)/*
+
+.PHONY: html
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+.PHONY: dirhtml
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+.PHONY: singlehtml
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+.PHONY: pickle
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+.PHONY: json
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+.PHONY: htmlhelp
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+.PHONY: qthelp
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/SCCD.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/SCCD.qhc"
+
+.PHONY: applehelp
+applehelp:
+	$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
+	@echo
+	@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
+	@echo "N.B. You won't be able to view it unless you put it in" \
+	      "~/Library/Documentation/Help or install it in your application" \
+	      "bundle."
+
+.PHONY: devhelp
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/SCCD"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/SCCD"
+	@echo "# devhelp"
+
+.PHONY: epub
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+.PHONY: epub3
+epub3:
+	$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
+	@echo
+	@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
+
+.PHONY: latex
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+.PHONY: latexpdf
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+.PHONY: latexpdfja
+latexpdfja:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through platex and dvipdfmx..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+.PHONY: text
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+.PHONY: man
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+.PHONY: texinfo
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+.PHONY: info
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+.PHONY: gettext
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+.PHONY: changes
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+.PHONY: linkcheck
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+.PHONY: doctest
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+
+.PHONY: coverage
+coverage:
+	$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
+	@echo "Testing of coverage in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/coverage/python.txt."
+
+.PHONY: xml
+xml:
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+	@echo
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+.PHONY: pseudoxml
+pseudoxml:
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+	@echo
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
+
+.PHONY: dummy
+dummy:
+	$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
+	@echo
+	@echo "Build finished. Dummy builder generates no files."

+ 11 - 0
doc/_static/mystyle.css

@@ -0,0 +1,11 @@
+table.table-with-borders td, table.table-with-borders th {
+    padding: 1px 8px 1px 5px;
+    border-top: 1px solid #aaa;
+    border-left: 1px solid #aaa;
+    border-right: 1px solid #aaa;
+    border-bottom: 1px solid #aaa;
+}
+
+table.table-with-borders td:blank {
+    background-color: grey;
+}

+ 5 - 0
doc/_templates/layout.html

@@ -0,0 +1,5 @@
+{# layout.html #}
+{# Import the theme's layout. #}
+{% extends "!layout.html" %}
+
+{% set css_files = css_files + ['_static/mystyle.css'] %}

+ 28 - 0
doc/compiler.rst

@@ -0,0 +1,28 @@
+Compiler
+========
+To compile a conforming SCCDXML file, the provided Python compiler can be used. The compiler can compile conforming SCCD models to two languages: Python and Javascript. Three platforms are supported, for more information see :ref:`runtime_platforms`.
+
+The compiler can be used from the command line as follows::
+
+    $python -m sccd.compiler.sccdc --help
+    usage: python -m sccd.compiler.sccdc [-h] [-o OUTPUT] [-v VERBOSE]
+                                         [-p PLATFORM] [-l LANGUAGE]
+                                         input
+
+    positional arguments:
+      input                 The path to the XML file to be compiled.
+
+    optional arguments:
+      -h, --help            show this help message and exit
+      -o OUTPUT, --output OUTPUT
+                            The path to the generated code. Defaults to the same
+                            name as the input file but with matching extension.
+      -v VERBOSE, --verbose VERBOSE
+                            2 = all output; 1 = only warnings and errors; 0 = only
+                            errors; -1 = no output. Defaults to 2.
+      -p PLATFORM, --platform PLATFORM
+                            Let the compiled code run on top of threads, gameloop
+                            or eventloop. The default is eventloop.
+      -l LANGUAGE, --language LANGUAGE
+                            Target language, either "javascript" or "python".
+                            Defaults to the latter.

+ 340 - 0
doc/conf.py

@@ -0,0 +1,340 @@
+# -*- coding: utf-8 -*-
+#
+# SCCD documentation build configuration file, created by
+# sphinx-quickstart on Tue Aug 16 10:17:10 2016.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+# import os
+# import sys
+# sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#
+# needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+    'sphinx.ext.autodoc',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+#
+# source_suffix = ['.rst', '.md']
+source_suffix = '.rst'
+
+# The encoding of source files.
+#
+# source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'SCCD'
+copyright = u'2016, Simon Van Mierlo'
+author = u'Simon Van Mierlo'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = u'0.9'
+# The full version, including alpha/beta/rc tags.
+release = u'0.9'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#
+# today = ''
+#
+# Else, today_fmt is used as the format for a strftime call.
+#
+# today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This patterns also effect to html_static_path and html_extra_path
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#
+# default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#
+# add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#
+# add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#
+# show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+# modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+# keep_warnings = False
+
+# If true, `todo` and `todoList` produce output, else they produce nothing.
+todo_include_todos = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+#
+html_theme = 'classic'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#
+# html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+# html_theme_path = []
+
+# The name for this set of Sphinx documents.
+# "<project> v<release> documentation" by default.
+#
+# html_title = u'SCCD v0.9'
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#
+# html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#
+# html_logo = None
+
+# The name of an image file (relative to this directory) to use as a favicon of
+# the docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#
+# html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#
+# html_extra_path = []
+
+# If not None, a 'Last updated on:' timestamp is inserted at every page
+# bottom, using the given strftime format.
+# The empty string is equivalent to '%b %d, %Y'.
+#
+# html_last_updated_fmt = None
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#
+# html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#
+# html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#
+# html_additional_pages = {}
+
+# If false, no module index is generated.
+#
+# html_domain_indices = True
+
+# If false, no index is generated.
+#
+# html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#
+# html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#
+# html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#
+# html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#
+# html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#
+# html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+# html_file_suffix = None
+
+# Language to be used for generating the HTML full-text search index.
+# Sphinx supports the following languages:
+#   'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
+#   'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
+#
+# html_search_language = 'en'
+
+# A dictionary with options for the search language support, empty by default.
+# 'ja' uses this config value.
+# 'zh' user can custom change `jieba` dictionary path.
+#
+# html_search_options = {'type': 'default'}
+
+# The name of a javascript file (relative to the configuration directory) that
+# implements a search results scorer. If empty, the default will be used.
+#
+# html_search_scorer = 'scorer.js'
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'SCCDdoc'
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+     # The paper size ('letterpaper' or 'a4paper').
+     #
+     # 'papersize': 'letterpaper',
+
+     # The font size ('10pt', '11pt' or '12pt').
+     #
+     # 'pointsize': '10pt',
+
+     # Additional stuff for the LaTeX preamble.
+     #
+     # 'preamble': '',
+
+     # Latex figure (float) alignment
+     #
+     # 'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+    (master_doc, 'SCCD.tex', u'SCCD Documentation',
+     u'Simon Van Mierlo', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#
+# latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#
+# latex_use_parts = False
+
+# If true, show page references after internal links.
+#
+# latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#
+# latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#
+# latex_appendices = []
+
+# It false, will not define \strong, \code, 	itleref, \crossref ... but only
+# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added
+# packages.
+#
+# latex_keep_old_macro_names = True
+
+# If false, no module index is generated.
+#
+# latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    (master_doc, 'sccd', u'SCCD Documentation',
+     [author], 1)
+]
+
+# If true, show URL addresses after external links.
+#
+# man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+    (master_doc, 'SCCD', u'SCCD Documentation',
+     author, 'SCCD', 'One line description of project.',
+     'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#
+# texinfo_appendices = []
+
+# If false, no module index is generated.
+#
+# texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#
+# texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#
+# texinfo_no_detailmenu = False

+ 635 - 0
doc/examples.rst

@@ -0,0 +1,635 @@
+Examples
+========
+
+Timer
+-----
+This example demonstrates the timed behavior of SCCD. It does not have dynamic structure.
+
+We model a clock which prints the current time every 0.05 seconds. Two clocks are printed: the current wall-clock time and the current simulated time. We expect both to (almost) be the same. The user can interrupt the clock by sending an "interrupt" event. The user can resume the clock by sending a "resume" event.
+
+Threads (Python)
+^^^^^^^^^^^^^^^^
+In this version, the model sends the current times to an output port, on which the user listens, to print out these times. *self.getSimulatedTime()* and *time()* return the current time in milliseconds, which we have to convert to seconds.
+
+The SCCD model::
+
+    <?xml version="1.0" ?>
+    <diagram author="Simon Van Mierlo" name="Timer (Threaded Version)">
+        <top>
+            from sccd.runtime.accurate_time import time
+        </top>
+        
+        <inport name="input" />        
+        <outport name="output" />
+
+        <class name="MainApp" default="true">
+            <scxml initial="running">
+                <state id="running">
+                    <transition target="." after="0.05">
+                        <raise event="time_update" port="output">
+                            <parameter expr="self.getSimulatedTime()" />
+                            <parameter expr="time()" />
+                        </raise>
+                    </transition>
+                    <transition target="../interrupted" event="interrupt" port="input">
+                        <raise event="time_update" port="output">
+                            <parameter expr="self.getSimulatedTime()" />
+                            <parameter expr="time()" />
+                        </raise>
+                    </transition>
+                </state>
+                <state id="interrupted">
+                    <transition target="." event="interrupt" port="input">
+                        <raise event="time_update" port="output">
+                            <parameter expr="self.getSimulatedTime()" />
+                            <parameter expr="time()" />
+                        </raise>
+                    </transition>
+                    <transition target="../running" event="continue" port="input">
+                        <raise event="time_update" port="output">
+                            <parameter expr="self.getSimulatedTime()" />
+                            <parameter expr="time()" />
+                        </raise>
+                    </transition>
+                </state>
+            </scxml>
+        </class>
+    </diagram>
+    
+To compile, save this in a file called ``timer.xml`` and run ``python -m sccd.compiler.sccdc -p threads -l python timer.xml``
+
+Then, the following file will run the model::
+
+    import timer
+    from sccd.runtime.statecharts_core import Event
+    import threading
+
+    if __name__ == '__main__':
+        controller = timer.Controller()
+        
+        def raw_inputter():
+            while 1:
+                controller.addInput(Event(raw_input(), "input", []))
+        input_thread = threading.Thread(target=raw_inputter)
+        input_thread.daemon = True
+        input_thread.start()
+        
+        output_listener = controller.addOutputListener(["output"])
+        def outputter():
+            while 1:
+                event = output_listener.fetch(-1)
+                print "SIMTIME: %.2fs" % (event.getParameters()[0] / 1000.0)
+                print "ACTTIME: %.2fs" % (event.getParameters()[1] / 1000.0)
+        output_thread = threading.Thread(target=outputter)
+        output_thread.daemon = True
+        output_thread.start()
+        
+        controller.start()
+        
+The time will be printed to the console. The user can send events by typing the string "interrupt" or "continue" in the console.
+
+Eventloop (Python)
+^^^^^^^^^^^^^^^^^^
+The SCCD model::
+
+    <?xml version="1.0" ?>
+    <diagram author="Simon Van Mierlo" name="Timer (Eventloop Version)">
+        <top>
+            from sccd.runtime.libs.ui import ui
+            from sccd.runtime.accurate_time import time
+        </top>
+        
+        <inport name="ui" />
+
+        <class name="MainApp" default="true">
+            <method name="MainApp">
+                <body>
+                    <![CDATA[
+                    self.canvas = ui.append_canvas(ui.window,100,100,{'background':'#eee'})
+                    self.clock_text = self.canvas.element.create_text(25,25,{'text':'0.0'})
+                    self.actual_clock_text = self.canvas.element.create_text(25,50,{'text':'0.0'})
+                    interrupt_button = ui.append_button(ui.window, 'INTERRUPT');
+                    continue_button = ui.append_button(ui.window, 'CONTINUE');
+                    ui.bind_event(interrupt_button.element, ui.EVENTS.MOUSE_CLICK, self.controller, 'interrupt_clicked');
+                    ui.bind_event(continue_button.element, ui.EVENTS.MOUSE_CLICK, self.controller, 'continue_clicked');
+                    ]]>
+                </body>        
+            </method>
+            <method name="update_timers">
+                <body>
+                    self.canvas.element.itemconfigure(self.clock_text, text=str('%.2f' % (self.getSimulatedTime() / 1000.0)))
+                    self.canvas.element.itemconfigure(self.actual_clock_text, text='%.2f' % (time() / 1000.0))
+                </body>
+            </method>
+            <scxml initial="running">
+                <state id="running">
+                    <transition target="." after="0.05">
+                        <script>
+                            self.update_timers()
+                        </script>
+                    </transition>
+                    <transition target="../interrupted" event="interrupt_clicked" port="ui">
+                        <script>
+                            self.update_timers()
+                        </script>
+                    </transition>
+                </state>
+                <state id="interrupted">
+                    <transition target="." event="interrupt_clicked" port="ui">
+                        <script>
+                            self.update_timers()
+                        </script>
+                    </transition>
+                    <transition target="../running" event="continue_clicked" port="ui">
+                        <script>
+                            self.update_timers()
+                        </script>
+                    </transition>
+                </state>
+            </scxml>
+        </class>
+    </diagram>
+    
+To compile, save this in a file called ``timer.xml`` and run ``python -m sccd.compiler.sccdc -p eventloop -l python timer.xml``
+
+Then, the following file will run the model::
+
+    import Tkinter as tk
+    import timer
+    from sccd.runtime.libs.ui import ui
+    from sccd.runtime.statecharts_core import Event
+    from sccd.runtime.tkinter_eventloop import *
+
+    if __name__ == '__main__':
+        ui.window = tk.Tk()
+
+        controller = timer.Controller(TkEventLoop(ui.window))
+        controller.start()
+        ui.window.mainloop()
+        
+Eventloop (Javascript)
+^^^^^^^^^^^^^^^^^^^^^^
+The SCCD model::
+
+    <?xml version="1.0" ?>
+    <diagram author="Simon Van Mierlo" name="Timer">
+        <inport name="ui" />
+
+        <class name="MainApp" default="true">
+            <method name="MainApp">
+                <body>
+                    <![CDATA[
+                    this.canvas = ui.append_canvas(ui.window,400,150,{'background':'#eee'})
+                    this.clock_text = this.canvas.add_text(25,25,'0.0')
+                    this.actual_clock_text = this.canvas.add_text(25,50,'0.0')
+                    var interrupt_button = ui.append_button(ui.window, 'INTERRUPT');
+                    var continue_button = ui.append_button(ui.window, 'CONTINUE');
+                    ui.bind_event(interrupt_button.element, ui.EVENTS.MOUSE_CLICK, this.controller, 'interrupt_clicked');
+                    ui.bind_event(continue_button.element, ui.EVENTS.MOUSE_CLICK, this.controller, 'continue_clicked');
+                    ]]>
+                </body>
+            </method>
+            <method name="update_timers">
+                <body>
+                    this.clock_text.set_text((this.getSimulatedTime() / 1000).toFixed(2));
+                    this.actual_clock_text.set_text((this.getSimulatedTime() / 1000).toFixed(2));
+                </body>
+            </method>
+            <scxml initial="running">
+                <state id="running">
+                    <transition target="." after="0.05">
+                        <script>
+                            this.update_timers();
+                        </script>
+                    </transition>
+                    <transition target="../interrupted" event="interrupt_clicked" port="ui">
+                        <script>
+                            this.update_timers();
+                        </script>
+                    </transition>
+                </state>
+                <state id="interrupted">
+                    <transition target="." event="interrupt_clicked" port="ui">
+                        <script>
+                            this.update_timers();
+                        </script>
+                    </transition>
+                    <transition target="../running" event="continue_clicked" port="ui">
+                        <script>
+                            this.update_timers();
+                        </script>
+                    </transition>
+                </state>
+            </scxml>
+        </class>
+    </diagram>
+    
+To compile, save this in a file called ``timer.xml`` and run ``python -m sccd.compiler.sccdc -p eventloop -l javascript timer.xml``
+
+Then, the following file will run the model::
+
+    <div>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/HackTimer.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/statecharts_core.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/utils.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/svg.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/ui.js"></script>
+        <script src="timer.js"></script>
+        <script>
+            controller = new Timer.Controller(new JsEventLoop());
+            controller.start();
+        </script> 
+    </div>
+    
+Traffic Lights
+--------------
+The traffic lights example demonstrates most functionality of SCCD. There are three lights (green, yellow, and red). The traffic light autonomously switches between them, but also listens for a police interrupt, which will flash the yellow light. When a second interrupt comes in, the light returns to its last configuration (using a history state).
+
+Python
+^^^^^^
+The SCCD model::
+
+    <?xml version="1.0" ?>
+    <diagram author="Raphael Mannadiar" name="Traffic_Light_Python_Version">
+        <top>
+            from sccd.runtime.libs.ui import ui
+        </top>
+        
+        <inport name="ui" />
+
+        <class name="MainApp" default="true">
+            <relationships>
+                <association name="trafficlight" class="TrafficLight" />
+            </relationships>
+            <method name="MainApp">
+                <body>
+                    <![CDATA[
+                    self.canvas   = ui.append_canvas(ui.window,100,310,{'background':'#eee'});
+                    police_button = ui.append_button(ui.window, 'Police interrupt');
+                    quit_button   = ui.append_button(ui.window, 'Quit');
+                    ui.bind_event(police_button.element, ui.EVENTS.MOUSE_CLICK, self.controller, 'police_interrupt_clicked');
+                    ui.bind_event(quit_button.element,      ui.EVENTS.MOUSE_CLICK, self.controller, 'quit_clicked');
+                    ]]>
+                </body>        
+            </method>
+            <scxml initial="initializing">
+                <state id="initializing">
+                    <transition target="../creating">
+                        <raise scope="cd" event="create_instance">
+                            <parameter expr='"trafficlight"' />
+                            <parameter expr='"TrafficLight"' />
+                            <parameter expr="self.canvas" />
+                        </raise>
+                    </transition>
+                </state>
+                <state id="creating">
+                    <transition event="instance_created" target="../initialized">
+                        <parameter name="association_name" type="string"/>
+                        <raise scope="cd" event="start_instance">
+                            <parameter expr="association_name" />
+                        </raise>
+                        <raise scope="narrow" event="set_association_name" target="association_name">
+                            <parameter expr="association_name" />
+                        </raise>
+                    </transition>
+                </state>
+                <state id="initialized">
+                </state>
+            </scxml>
+        </class>
+
+        <class name="TrafficLight">
+            <relationships>
+            </relationships>
+            <method name="TrafficLight">
+                <parameter name="canvas" />
+                <body>
+                    <![CDATA[
+                    size        = 100;
+                    offset      = size+5;
+                    self.RED    = 0;
+                    self.YELLOW = 1;
+                    self.GREEN  = 2;
+                    self.colors = ['#f00','#ff0','#0f0']
+                    self.lights = [
+                        canvas.add_rectangle(size/2, size/2, size, size, {'fill':'#000'}),
+                        canvas.add_rectangle(size/2, size/2+offset,     size, size, {'fill':'#000'}),
+                        canvas.add_rectangle(size/2, size/2+2*offset, size, size, {'fill':'#000'})];
+                    ]]>
+                </body>
+            </method>
+            <method name="clear">
+                <body>
+                    <![CDATA[
+                    self.lights[self.RED].set_color('#000');
+                    self.lights[self.YELLOW].set_color('#000');
+                    self.lights[self.GREEN].set_color('#000');
+                    ]]>
+                </body>
+            </method>
+            <method name="setGreen">
+                <body>
+                    <![CDATA[
+                    self.clear();
+                    self.lights[self.GREEN].set_color(self.colors[self.GREEN]);
+                    ]]>
+                </body>
+            </method>
+            <method name="setYellow">
+                <body>
+                    <![CDATA[
+                    self.clear();
+                    self.lights[self.YELLOW].set_color(self.colors[self.YELLOW]);
+                    ]]>
+                </body>
+            </method>
+            <method name="setRed">
+                <body>
+                    <![CDATA[
+                    self.clear();
+                    self.lights[self.RED].set_color(self.colors[self.RED]);
+                    ]]>
+                </body>
+            </method>
+            <scxml initial="on">
+                <state id="on" initial="normal">
+                    <state id="normal" initial="red">
+                        <state id="red">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    self.setRed();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='3' target='../green'/>
+                        </state>
+                        <state id="green">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    self.setGreen();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='2' target='../yellow'/>
+                        </state>
+                        <state id="yellow">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    self.setYellow();
+                                    ]]>
+                                </script>
+                            </onentry>
+                        <transition after='1' target='../red'/>
+                        </state>
+                        <transition event='police_interrupt_clicked' port='ui' target='../interrupted'/>
+                        <history id="history"/>
+                    </state>
+                    <state id="interrupted" initial="yellow">
+                        <state id="yellow">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    self.setYellow();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='.5' target='../black'/>
+                        </state>
+                        <state id="black">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    self.clear();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='.5' target='../yellow'/>
+                        </state>
+                        <transition event='police_interrupt_clicked' port='ui' target='../normal/history'/>
+                    </state>
+                    <transition event='quit_clicked' port='ui' target='../off'/>
+                </state>
+                <state id="off">
+                    <onentry>
+                        <script>
+                            <![CDATA[
+                            self.clear();
+                            ]]>
+                        </script>
+                    </onentry>
+                </state>
+            </scxml>
+        </class>
+    </diagram>
+    
+To compile, save this in a file called ``trafficlight.xml`` and run ``python -m sccd.compiler.sccdc -p eventloop -l python trafficlight.xml``
+
+Then, the following file will run the model::
+
+    import Tkinter as tk
+    import trafficlight
+    from sccd.runtime.libs.ui import ui
+    from sccd.runtime.statecharts_core import Event
+    from sccd.runtime.tkinter_eventloop import *
+
+    if __name__ == '__main__':
+        ui.window = tk.Tk()
+
+        controller = trafficlight.Controller(TkEventLoop(ui.window))
+        controller.start()
+        ui.window.mainloop()
+        
+Javascript
+^^^^^^^^^^
+The SCCD model::
+
+    <?xml version="1.0" ?>
+    <diagram author="Raphael Mannadiar" name="Traffic_Light_JavaScript_Version">
+        <inport name="ui" />
+
+        <class name="MainApp" default="true">
+            <relationships>
+                <association name="trafficlight" class="TrafficLight" />
+            </relationships>
+            <method name="MainApp">
+                <body>
+                    <![CDATA[
+                    this.canvas	= ui.append_canvas(ui.window,100,310,{'background':'#eee'});
+                    var police_button = ui.append_button(ui.window, 'Police interrupt');
+                    var quit_button	= ui.append_button(ui.window, 'Quit');
+                    ui.bind_event(police_button.element, ui.EVENTS.MOUSE_CLICK, this.controller, 'police_interrupt_clicked');
+                    ui.bind_event(quit_button.element, 	 ui.EVENTS.MOUSE_CLICK, this.controller, 'quit_clicked');
+                    ]]>
+                </body>		
+            </method>
+            <scxml initial="initializing">
+                <state id="initializing">
+                    <transition target="../creating">
+                        <raise scope="cd" event="create_instance">
+                            <parameter expr='"trafficlight"' />
+                            <parameter expr='"TrafficLight"' />
+                            <parameter expr="this.canvas" />
+                        </raise>
+                    </transition>
+                </state>
+                <state id="creating">
+                    <transition event="instance_created" target="../initialized">
+                        <parameter name="association_name" type="string"/>
+                        <raise scope="cd" event="start_instance">
+                            <parameter expr="association_name" />
+                        </raise>
+                        <raise scope="narrow" event="set_association_name" target="association_name">
+                            <parameter expr="association_name" />
+                        </raise>
+                    </transition>
+                </state>
+                <state id="initialized">
+                </state>
+            </scxml>
+        </class>
+
+        <class name="TrafficLight">
+            <relationships>
+            </relationships>
+            <method name="TrafficLight">
+                <parameter name="canvas" />
+                <body>
+                    <![CDATA[
+                    var size 	= 100;
+                    var offset 	= size+5;
+                    this.RED 	= 0;
+                    this.YELLOW = 1;
+                    this.GREEN 	= 2;
+                    this.colors	= ['#f00','#ff0','#0f0']
+                    this.lights = [canvas.add_rectangle(size/2, size/2, 		 	 size, size, {'fill':'#000'}),
+                                        canvas.add_rectangle(size/2, size/2+offset,	 size, size, {'fill':'#000'}),
+                                        canvas.add_rectangle(size/2, size/2+2*offset, size, size, {'fill':'#000'})];
+                    ]]>
+                </body>
+            </method>
+            <method name="clear">
+                <body>
+                    <![CDATA[
+                    this.lights[this.RED].set_color('#000');
+                    this.lights[this.YELLOW].set_color('#000');
+                    this.lights[this.GREEN].set_color('#000');
+                    ]]>
+                </body>
+            </method>
+            <method name="setGreen">
+                <body>
+                    <![CDATA[
+                    this.clear();
+                    this.lights[this.GREEN].set_color(this.colors[this.GREEN]);
+                    ]]>
+                </body>
+            </method>
+            <method name="setYellow">
+                <body>
+                    <![CDATA[
+                    this.clear();
+                    this.lights[this.YELLOW].set_color(this.colors[this.YELLOW]);
+                    ]]>
+                </body>
+            </method>
+            <method name="setRed">
+                <body>
+                    <![CDATA[
+                    this.clear();
+                    this.lights[this.RED].set_color(this.colors[this.RED]);
+                    ]]>
+                </body>
+            </method>
+            <scxml initial="on">
+                <state id="on" initial="normal">
+                    <state id="normal" initial="red">
+                        <state id="red">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    this.setRed();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='3' target='../green'/>
+                        </state>
+                        <state id="green">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    this.setGreen();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='2' target='../yellow'/>
+                        </state>
+                        <state id="yellow">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    this.setYellow();
+                                    ]]>
+                                </script>
+                            </onentry>
+                        <transition after='1' target='../red'/>
+                        </state>
+                        <transition event='police_interrupt_clicked' port='ui' target='../interrupted'/>
+                        <history id="history"/>
+                    </state>
+                    <state id="interrupted" initial="yellow">
+                        <state id="yellow">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    this.setYellow();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='.5' target='../black'/>
+                        </state>
+                        <state id="black">
+                            <onentry>
+                                <script>
+                                    <![CDATA[
+                                    this.clear();
+                                    ]]>
+                                </script>
+                            </onentry>
+                            <transition after='.5' target='../yellow'/>
+                        </state>
+                        <transition event='police_interrupt_clicked' port='ui' target='../normal/history'/>
+                    </state>
+                    <transition event='quit_clicked' port='ui' target='../off'/>
+                </state>
+                <state id="off">
+                    <onentry>
+                        <script>
+                            <![CDATA[
+                            this.clear();
+                            ]]>
+                        </script>
+                    </onentry>
+                </state>
+            </scxml>
+        </class>
+    </diagram>
+    
+To compile, save this in a file called ``trafficlight.xml`` and run ``python -m sccd.compiler.sccdc -p eventloop -l javascript trafficlight.xml``
+
+Then, the following file will run the model::
+
+    <div>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/HackTimer.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/statecharts_core.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/utils.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/svg.js"></script>
+        <script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/ui.js"></script>
+        <script src="trafficlight.js"></script>
+        <script>
+        controller = new Traffic_Light_JavaScript_Version.Controller(new JsEventLoop());
+        controller.start();
+        </script> 
+    </div>

+ 33 - 0
doc/index.rst

@@ -0,0 +1,33 @@
+.. SCCD documentation master file, created by
+   sphinx-quickstart on Tue Aug 16 10:17:10 2016.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+SCCD Documentation
+==================
+
+SCCD [SCCD]_ is a language that combines the Statecharts [Statecharts]_ language with Class Diagrams. It allows users to model complex, timed, autonomous, reactive, dynamic-structure systems.
+
+The concrete syntax of SCCD is an XML-format loosely based on the `W3C SCXML recommendation <https://www.w3.org/TR/scxml/>`_. A conforming model can be compiled to a number of programming languages, as well as a number of runtime platforms implemented in those languages. This maximizes the number of applications that can be modelled using SCCD, such as user interfaces, the artificial intelligence of game characters, controller software, and much more.
+
+This documentation serves as an introduction to the SCCD language, its compiler, and the different supported runtime platforms.
+
+Contents
+--------
+
+.. toctree::
+   :maxdepth: 2
+
+    Installation <installation>
+    Language Features <language_features>
+    Compiler <compiler>
+    Runtime Platforms <runtime_platforms>
+    Examples <examples>
+    Semantic Options <semantic_options>
+    Internal Documentation <internal_documentation>
+    
+References
+----------
+    
+.. [SCCD] Simon Van Mierlo, Yentl Van Tendeloo, Bart Meyers, Joeri Exelmans, and Hans Vangheluwe. SCCD: SCXML extended with class diagrams. In *3rd Workshop on Engineering Interactive Systems with SCXML, part of EICS 2016*, 2016. [`LINK <http://www.scxmlworkshop.de/eics2016/submissions/SCCD%20SCXML%20Extended%20with%20Class%20Diagrams.pdf>`_]
+.. [Statecharts] David Harel. Statecharts: A visual formalism for complex systems. *Sci. Comput. Program. 8*, 3 (1987), 231–274. [`LINK <http://www.inf.ed.ac.uk/teaching/courses/seoc/2005_2006/resources/statecharts.pdf>`_]

+ 25 - 0
doc/installation.rst

@@ -0,0 +1,25 @@
+Installation
+============
+This section describes the necessary steps for installing SCCD.
+
+Download
+--------
+The current version of SCCD is v0.9. You can download it using this link: https://msdl.uantwerpen.be/git/simon/SCCD/archive/v0.9.zip
+
+Unzip the contents of the archive to a folder of your choice.
+
+Dependencies
+------------
+SCCD depends on Python 2.7, which you can download from https://www.python.org/download/releases/2.7/
+
+SCCD Installation
+--------------------
+Execute the following command inside the *src* folder::
+
+    python setup.py install --user
+    
+Afterwards, SCCD should be installed. This can easily be checked with the command::
+
+    python -c "import sccd"
+    
+If this returns without errors, SCCD is sucessfully installed.

+ 6 - 0
doc/internal_documentation.rst

@@ -0,0 +1,6 @@
+Internal Documentation
+======================
+
+.. toctree::
+
+    Statecharts Core <statecharts_core_int>

+ 436 - 0
doc/language_features.rst

@@ -0,0 +1,436 @@
+Language Features
+=================
+SCCD(XML)'s notation is loosely based on the `W3C SCXML recommendation <https://www.w3.org/TR/scxml/>`_. It adds concepts of Class Diagrams. In essence, an SCCD model consists of a number of classes that are related to each other through associations. Each class has a Statechart, defining its runtime behavior.
+
+One class is the default class. When the system is run, the runtime creates and starts one instance of that class. Instances can create, start, and delete instances of classes (if it's allowed by the constraints modelled on the class diagram). They can also create and delete instances of associations (*i.e.* links between instances). These links are used for one instance to communicate with (an)other instance(s).
+
+Top-Level Elements
+------------------
+
+.. _diagram:
+
+<diagram>
+^^^^^^^^^
+The top-level element of an SCCD model is a ``<diagram>``. It has two attributes:
+
+* *name* specifies the name of the diagram. For models compiled to Python, this is purely informative, while in Javascript this is the name of the namespace to which the compiled classes belong.
+* *author* specifies who authored the model
+
+Children:
+
+* ``[0..1]`` :ref:`description`
+* ``[0..1]`` :ref:`top`
+* ``[0..n]`` :ref:`inport_outport`
+* ``[1..n]`` :ref:`class`
+
+.. _description:
+
+<description>
+^^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`diagram`.
+
+The ``<description>`` element contains a description of the diagram and optionally occurs once. It will be placed as a comment at the top of the compiled file.
+
+.. _top:
+
+<top>
+^^^^^
+.. note:: This is a child element of :ref:`diagram`.
+.. warning:: Python only!
+
+The ``<top>`` element can be used to import additional library modules to be used by the classes modelled in the diagram. It can optionally occur once.
+
+.. _inport_outport:
+
+<inport> and <outport>
+^^^^^^^^^^^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`diagram` or :ref:`class`.
+
+An ``<inport>`` models a communication channel which can receive events from the outside world. An ``<outport>`` models a communication channel with which instances can send event to the outside world.
+
+Ports have one attribute: a *name*. This name can be referenced either in :ref:`transition` (for input ports) or :ref:`raise` (for output ports).
+
+In case the port is a child of a class, the port is local to that class. Each instance of the class will receive a private instance of the port, on which only they can receive events or can send events to.
+
+Class Diagram Concepts
+----------------------
+
+.. _class:
+
+<class>
+^^^^^^^
+Classes are the basic building block of an SCCD diagram. They model structure in the form of attributes and relations with other classes, and behavior in the form of methods (which can change the value of attributes) and a Statecharts model (which governs the runtime behavior of the class).
+
+A ``<class>`` element has three attributes:
+
+* *name*: the name of the class
+* *default*: true if this is the default class (of which one instance is created and started at the start of executing the compiled code)
+* *src*: the location of a separate XML file (relative to the location in which the main diagram is compiled), containing the definition of the class. If this attribute is set, the *name* attribute cannot be set, nor can the class element have any children.
+
+Children:
+
+* ``[0..1]`` :ref:`relationships`
+* ``[0..n]`` :ref:`attribute`
+* ``[0..1]`` :ref:`constructor`
+* ``[0..1]`` :ref:`destructor`
+* ``[0..n]`` :ref:`method`
+
+.. _relationships:
+
+<relationships>
+^^^^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`class`.
+
+Models a number of relationships between its parent class and other classes of the diagram.
+
+Children:
+
+* ``[0..n]`` :ref:`association`
+* ``[0..n]`` :ref:`inheritance`
+
+.. _association:
+
+<association>
+^^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`relationships`.
+
+An association relation can be insantiated in order to link two instances at runtime, and those instances to exchange messages over that link. An association has two attributes:
+
+* *name*: the name of the association
+* *class*: the name of the target class
+* *min*: the minimal cardinality of the association (defaults to 0)
+* *max*: the maximum cardinality of the association (defaults to infinity)
+
+.. _inheritance:
+
+<inheritance>
+^^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`relationships`.
+
+An inhertiance relation allows one class to inherit all methods and attribute from another class. Behaviour (*i.e.*, the :ref:`scxml` element) of the parent is not inherited. An inheritance relation has four attributes:
+
+* *class*: the name of the target class
+* *priority*: allows to specify in which order classes need to be inherited (in case of multiple inheritance). Inheritance relations with higher priority are inherited from first.
+
+.. _attribute:
+
+<attribute>
+^^^^^^^^^^^
+.. note:: This is a child element of :ref:`class`.
+
+An :ref:`attribute` element has two attributes:
+
+* *name*: the name of the attribute
+* *type*: the type of the attribute
+
+.. _constructor:
+
+<constructor>
+^^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`class`.
+
+The constructor is called when an object is instantiated. It is used to initialize the instance's attribute values.
+
+Children:
+
+* ``[0..n]`` :ref:`parameter`
+* ``[1..1]`` :ref:`body`
+
+.. _destructor:
+
+<destructor>
+^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`class`.
+
+The destructor is called just before an object is deleted.
+
+Children:
+
+* ``[1..1]`` :ref:`body`
+
+.. _method:
+
+<method>
+^^^^^^^^
+.. note:: This is a child element of :ref:`class`.
+
+A method is a block of action code that can be called repeatedly in other code blocks that belong to the same class definition. It has two attributes:
+
+* *name*: the name of the method
+* *type*: the type of the return value (optional)
+
+Children:
+
+* ``[0..n]`` :ref:`parameter`
+* ``[1..1]`` :ref:`body` 
+
+.. _body:
+
+<body>
+^^^^^^
+.. note:: This is a child element of :ref:`method`, :ref:`constructor`, or :ref:`destructor`.
+
+A :ref:`body` element is a block of action code in a programming language (depending on the target language to which the model is compiled). It allows to call other functions and change the values of instance variables. If any parameters were defined as children of this element's parent, they can be referenced by name.
+
+Statechart Concepts
+-------------------
+
+.. _scxml:
+
+<scxml>
+^^^^^^^
+.. note:: This is a child element of :ref:`class`.
+
+The top-level element containing the Statecharts definition of its parent class. It has one attribute:
+
+* *initial*: specifies the initial child state of the Statechart (optional). If omitted, the first child in document order is the initial state.
+* *big_step_maximality*: (optional). See :ref:`big_step_maximality`. Allowed values are "take_many" (default), "take_one".
+* *internal_event_lifeline*: (optional). See :ref:`internal_event_lifeline`. Allowed values are "queue" (default), "next_small_step", "next_combo_step".
+* *input_event_lifeline*: (optional). See :ref:`input_event_lifeline`. Allowed values are "first_combo_step" (default), "first_small_step", "whole".
+* *priority*: (optional). See :ref:`priority`. Allowed values are "source_parent" (default), "source_child".
+* *concurrency*: (optional). See :ref:`concurrency`. Allowed values are "single" (default), "many".
+
+Children:
+
+* ``[0..n]`` :ref:`state`.
+* ``[0..n]`` :ref:`parallel`.
+
+.. _state:
+
+<state>
+^^^^^^^
+.. note:: This is a child element of :ref:`scxml`, :ref:`state`, or :ref:`parallel`.
+
+A state is the basic building block of a Statechart. It represents a "mode" the system can be in. A state can be entered (which executes an optional block of executable content) and exited (which executes an optional block of executable content) using transitions (which execute an optional block of executable content). States can be hierarchical (*i.e.*, one state can contain other states). A state has two attributes:
+
+* *id*: the identifier of the state. Needs to be unique with respect to other state ids on the same level (*i.e.*, the parent state cannot have two children with identical ids).
+* *initial*: Specifies the initial child state, if this state is a composite state (optional). If omitted, the first child in document order is the initial state.
+
+Children:
+
+* ``[0..n]`` :ref:`transition`.
+* ``[0..n]`` :ref:`state`.
+* ``[0..n]`` :ref:`parallel`.
+* ``[0..n]`` :ref:`history`.
+* ``[0..1]`` :ref:`onentry`.
+* ``[0..1]`` :ref:`onexit`.
+
+.. _parallel:
+
+<parallel>
+^^^^^^^^^^
+.. note:: This is a child element of :ref:`scxml`, :ref:`state`, or :ref:`parallel`.
+
+A parallel state's children run, as the name reveals, in parallel. This means that each child of the parallel state is able to execute a transition *at the same time*. This is useful to naturally model concurrent behavior, such as animating elements on a canvas while also listening for user input. A paralle state has one attribute:
+
+* *id*: the identifier of the parallel state. Needs to be unique with respect to other state ids on the same level (*i.e.*, the parent state cannot have two children with identical ids).
+
+Children:
+
+* ``[0..n]`` :ref:`transition`.
+* ``[0..n]`` :ref:`state`. These children **must** be composite.
+* ``[0..n]`` :ref:`parallel`.
+* ``[0..n]`` :ref:`history`.
+* ``[0..1]`` :ref:`onentry`.
+* ``[0..1]`` :ref:`onexit`.
+
+.. warning:: A transition from a child state cannot exit the parallel region, as this breaks encapsulation and can interfere with the behavior of other children of the parallel state. Only transitions directly from the parallel state can exit the parallel region (which will automatically exit its children as well).
+
+.. _transition:
+
+<transition>
+^^^^^^^^^^^^
+.. note:: This is a child element of :ref:`scxml`, :ref:`state`, or :ref:`parallel`.
+
+A transition allows the system to change state (*i.e.*, go from one "mode" to the next). Transitions are *triggered* by an event or a timeout, or can be spontaneous. They can optionally specify a condition that additionally needs to evaluate to true. A transition can have five attributes:
+
+* *target*: the target state of the transition. See :ref:`state_referencing` for more details.
+* *after*: (optional) an amount of seconds that need to pass before this transition is triggered. Cannot occur together with *event*. Note that the timer starts counting when the parent state is entered. The timer is cancelled when the state is exited.
+* *event*: (optional) the name of the event that triggers this transitions. Cannot occur together with *after*.
+* *port*: (optional) specifies the name of the port on which the event that triggers this transition will arrive. Needs to occur together with *event*, and cannot occur together with *after*.
+* *cond*: (optional) a condition that evaluates to a boolean value. Can make use of instance variables, and names of parameters passed to the transition.
+
+Children:
+
+* ``[0..n]`` :ref:`parameter`
+* ``[0..n]`` :ref:`raise`
+* ``[0..n]`` :ref:`script`
+* ``[0..n]`` :ref:`log`
+
+The semantics of executing a transition are as follows:
+
+#. The exit set consists of the active descendants of the least-common ancestor state of the transition's source and target state. All states in the exit set are exited in order ("youngest" child first), executing their exit actions.
+#. All executable content of the transition is executed in document order.
+#. The enter set consists of the transition's target state, its children, and its ancestors that are not an ancestor of the source state. They are entered in order ("oldest" state first), executing their enter actions.
+
+.. _history:
+
+<history>
+^^^^^^^^^
+.. note:: This is a child element of :ref:`state`, or :ref:`parallel`.
+
+A history state keeps track of the current configuration when its parent state is exited. If a transition has the history state as a target, the configuration that was saved is restored. If no configuration was saved yet, the default state is entered instead. A history state has two attributes:
+
+* *id*: the identifier of the state. Needs to be unique with respect to other state ids on the same level (*i.e.*, the parent state cannot have two children with identical ids).
+* *type*: (optional) either "shallow" (default) or "deep". A shallow history state only saves the active states on its level (not the active children of those states). A deep history state saves the active states on its level, and all active states on lower levels.
+
+A history state cannot have children.
+
+.. _onentry:
+
+<onentry>
+^^^^^^^^^
+.. note:: This is a child element of :ref:`state`, or :ref:`parallel`.
+
+An entry action is executed when a state is entered. Executable content is executed in document order.
+
+Children:
+
+* ``[0..n]`` :ref:`raise`
+* ``[0..n]`` :ref:`script`
+* ``[0..n]`` :ref:`log`
+
+.. _onexit:
+
+<onexit>
+^^^^^^^^^
+.. note:: This is a child element of :ref:`state`, or :ref:`parallel`.
+
+An exit action is executed when a state is exited. Executable content is executed in document order.
+
+Children:
+
+* ``[0..n]`` :ref:`raise`
+* ``[0..n]`` :ref:`script`
+* ``[0..n]`` :ref:`log`
+
+.. _state_referencing:
+
+State Referencing
+^^^^^^^^^^^^^^^^^
+
+States need to be referenced when they are the target of a :ref:`transition` or appear in INSTATE :ref:`macros`. SCCD identifies states hierarchically and evaluates state references in the context of the state where the state reference occurs.
+
+* ``.`` is the state itself
+* ``<empty string>`` is the root (*i.e.*, the :ref:`scxml` element)
+* ``..`` goes up one level (to the parent state)
+* ``a`` is the child with id 'a'
+* ``a/b`` with *a* and *b* arbitrary state expressions evaluates state expression *b* in the context of the state found with state expression *a*.
+
+Examples:
+
+* ``../A`` will look for a state with id 'A' in the parent state
+* ``/A`` will look for a state with id 'A' in the root
+* ``A/B`` will look for a state with id 'B' in child with id 'A'
+
+
+Executable Content
+------------------
+
+Actions are executed when a :ref:`transition` is executed. There are three types of actions: event raises (which can in turn trigger other transitions), scripts (which can call functions and update instance variables) and log statements.
+
+.. _raise:
+
+<raise>
+^^^^^^^
+.. note:: This is a child element of :ref:`transition`, :ref:`onentry`, or ref:`onexit`.
+
+Raising an event allows to notify the outside world, the Statechart, or another instance. An event has a name, and optionally parameter values that are sent along with the event. As a result, a :ref:`transition` can be triggered elsewhere in the Statechart or in the receiving instance.
+
+A ref:`raise` element can have three attributes: *scope*, *port*, and *target*. They are used to explicitly define the scope of the raised event. Either the event is local to the Statechart, it is broadcast to all instances in the diagram, it is narrowcast to a specific instance, to the :ref:`object_manager`, or to an output port.
+
+The table bellow summarizes how the different scopes are specified.
+
+.. rst-class:: table-with-borders
+
++-------------+-------+-----------+-------------+-----------------+-------------+
+| attr/scope  | local | broadcast | narrowcast  | object manager  | output      |
++=============+=======+===========+=============+=================+=============+
+| *scope*     |\-\-\- | "broad"   | "narrow"    | "cd"            | "output"    |
++-------------+-------+-----------+-------------+-----------------+-------------+
+| *port*      |\-\-\- |\-\-\-\-\- |\-\-\-\-\-\- |\-\-\-\-\-\-\-\- | port_name   |
++-------------+-------+-----------+-------------+-----------------+-------------+
+| *target*    |\-\-\- |\-\-\-\-\- | link_name   |\-\-\-\-\-\-\-\- |\-\-\-\-\-\- |
++-------------+-------+-----------+-------------+-----------------+-------------+
+
+A "link name" identifies a specific (set of) connected instance(s) of the instance that raised the event. For example, if class "A" and "B" are connected via an association "A_to_B", valid values for "link_name could be:
+
+* "'A_to_B'" to send to all instances of B with which the instance of A that raises the event is connected
+* "'A_to_B[idx]'" where *idx* is a valid link index, which is sent by the :ref:`object_manager` as a reply to a *create_instance* request.
+* "self.the_link_name" if this evaluates to a legal link name.
+
+.. _script:
+
+<script>
+^^^^^^^^
+.. note:: This is a child element of :ref:`transition`, :ref:`onentry`, or ref:`onexit`.
+
+A :ref:`script` element is similar to a :ref:`body` element: a block of action code in a programming language (depending on the target language to which the model is compiled). It allows to call other functions and change the values of instance variables. If any parameters were defined as children of this element's parent (in the case of a :ref:`transition`), they can be referenced by name.
+
+.. _log:
+
+<log>
+^^^^^
+.. note:: This is a child element of :ref:`transition`, :ref:`onentry`, or ref:`onexit`.
+
+Allows to log a string.
+
+.. _parameter:
+
+<parameter>
+^^^^^^^^^^^
+.. note:: This is a child element of :ref:`transition`, :ref:`raise`, :ref:`method`, or :ref:`constructor`.
+
+Depending on where the :ref:`parameter` element is placed, it is either a formal parameter, or an actual parameter value.
+
+In the case it is a child of a :ref:`transition`, :ref:`method`, or :ref:`constructor`, it is a formal parameter. It then has three attributes:
+
+* *name*: the name of the parameter
+* *type*: (optional) the type of the parameter
+* *default*: (optional) the default value of the parameter
+
+.. note:: Parameters are positional.
+
+In the case it is a child of a :ref:`raise`, it is an actual parameter value. It then has one attribute:
+
+* *expr*: an expression that evaluates to the actual parameter value.
+
+.. _macros:
+
+Macros
+------
+Two macros are defined that can be used in the *cond* attribute of :ref:`transition` and the *expr* attribute of :ref:`parameter`:
+
+* *INSTATE(state_reference)* returns true if the system is currently in the referenced state (see :ref:`state_referencing`).
+* *SELF* returns the current object. This is useful to write platform-independent expressions. 
+
+.. _object_manager:
+
+Object Manager
+--------------
+
+The object manager is responsible for managing objects and links while the application is running. The instances can communicate with the object manager by raising events using the *cd* scope (see :ref:`raise`).
+
+The object manager accepts four events:
+
+* **create_instance**
+    * Parameters:
+        * *association_name*: an expression that evaluates to the name of the association that needs to be instantiated
+        * *class_name*: (optional) an expression that evaluates to the name of the class to instantiate. If omitted, the target class of the association is instantiated.
+        * *parameters*: (optional) the actual constructor parameter values
+    * Returns Event:
+        * **instance_created**\(*link_id*)
+* **start_instance**
+    * Parameters:
+        * *link_id*: the identifier of the link with which the instance to be started is connected to the requesting instance
+    * Returns Event:
+        * **instance_started**\(*link_id*)
+* **delete_instance**
+    * Parameters:
+        * *link_id*: the identifier of the link with which the instance to be deleted is connected to the requesting instance
+    * Returns Event:
+        * **instance_deleted**\(*link_id*)
+* **associate_instance**
+    * Parameters:
+        * *link_expression_dst*: an expression evaluating to a set of links, of which the targets need to be associated
+        * *link_expression_src*: an expression evaluating to an association, which needs to be instantiated to connect the source of the association to the targets that were evaluated in the expression above

+ 281 - 0
doc/make.bat

@@ -0,0 +1,281 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html       to make standalone HTML files
+	echo.  dirhtml    to make HTML files named index.html in directories
+	echo.  singlehtml to make a single large HTML file
+	echo.  pickle     to make pickle files
+	echo.  json       to make JSON files
+	echo.  htmlhelp   to make HTML files and a HTML help project
+	echo.  qthelp     to make HTML files and a qthelp project
+	echo.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  epub3      to make an epub3
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over all changed/added/deprecated items
+	echo.  xml        to make Docutils-native XML files
+	echo.  pseudoxml  to make pseudoxml-XML files for display purposes
+	echo.  linkcheck  to check all external links for integrity
+	echo.  doctest    to run all doctests embedded in the documentation if enabled
+	echo.  coverage   to run coverage check of the documentation if enabled
+	echo.  dummy      to check syntax errors of document sources
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+
+REM Check if sphinx-build is available and fallback to Python version if any
+%SPHINXBUILD% 1>NUL 2>NUL
+if errorlevel 9009 goto sphinx_python
+goto sphinx_ok
+
+:sphinx_python
+
+set SPHINXBUILD=python -m sphinx.__init__
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 (
+	echo.
+	echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+	echo.installed, then set the SPHINXBUILD environment variable to point
+	echo.to the full path of the 'sphinx-build' executable. Alternatively you
+	echo.may add the Sphinx directory to PATH.
+	echo.
+	echo.If you don't have Sphinx installed, grab it from
+	echo.http://sphinx-doc.org/
+	exit /b 1
+)
+
+:sphinx_ok
+
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "singlehtml" (
+	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\SCCD.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\SCCD.ghc
+	goto end
+)
+
+if "%1" == "devhelp" (
+	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished.
+	goto end
+)
+
+if "%1" == "epub" (
+	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub file is in %BUILDDIR%/epub.
+	goto end
+)
+
+if "%1" == "epub3" (
+	%SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub3 file is in %BUILDDIR%/epub3.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "latexpdf" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	cd %BUILDDIR%/latex
+	make all-pdf
+	cd %~dp0
+	echo.
+	echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "latexpdfja" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	cd %BUILDDIR%/latex
+	make all-pdf-ja
+	cd %~dp0
+	echo.
+	echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "text" (
+	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The text files are in %BUILDDIR%/text.
+	goto end
+)
+
+if "%1" == "man" (
+	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The manual pages are in %BUILDDIR%/man.
+	goto end
+)
+
+if "%1" == "texinfo" (
+	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+	goto end
+)
+
+if "%1" == "gettext" (
+	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+if "%1" == "coverage" (
+	%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of coverage in the sources finished, look at the ^
+results in %BUILDDIR%/coverage/python.txt.
+	goto end
+)
+
+if "%1" == "xml" (
+	%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The XML files are in %BUILDDIR%/xml.
+	goto end
+)
+
+if "%1" == "pseudoxml" (
+	%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
+	goto end
+)
+
+if "%1" == "dummy" (
+	%SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. Dummy builder generates no files.
+	goto end
+)
+
+:end

File diff suppressed because it is too large
+ 75 - 0
doc/runtime_platforms.rst


+ 31 - 0
doc/semantic_options.rst

@@ -0,0 +1,31 @@
+Semantic Options
+================
+
+Please see [SemanticOptions]_ for more information on the several semantic options.
+
+.. _big_step_maximality:
+
+Big Step Maximality
+-------------------
+
+.. _internal_event_lifeline:
+
+Internal Event Lifeline
+-----------------------
+
+.. _input_event_lifeline:
+
+Input Event Lifeline
+--------------------
+
+.. _priority:
+
+Priority
+--------
+
+.. _concurrency:
+
+Concurrency
+-----------
+
+.. [SemanticOptions] Esmaeilsabzali, S., Day, N. A., Atlee, J. M., and Niu, J. *Deconstructing the semantics of big-step modelling languages*. Requirements Engineering 15, 2 (2010), 235–265. [`LINK <https://cs.uwaterloo.ca/~sesmaeil/publications/2010/REJ10.pdf>`_] 

+ 5 - 0
doc/statecharts_core_int.rst

@@ -0,0 +1,5 @@
+Statecharts Core
+================
+
+.. automodule:: sccd.runtime.statecharts_core
+    :members:

+ 1 - 1
examples/HTTP_client/client.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 10 11:44:23 2016
+Date:   Wed Aug 17 13:32:50 2016
 
 Model author: Yentl Van Tendeloo
 Model name:   HTTP client

+ 1 - 1
examples/HTTP_server/server.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 10 11:44:23 2016
+Date:   Wed Aug 17 13:32:50 2016
 
 Model author: Yentl Van Tendeloo
 Model name:   HTTP Server

+ 1 - 1
examples/tanks/ai_controller.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 10 11:44:23 2016
+Date:   Wed Aug 17 13:32:51 2016
 
 Model author: Glenn De Jonghe
 Model name:   AI Tank

+ 1 - 1
examples/tanks/player_controller.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Aug 10 11:44:24 2016
+Date:   Wed Aug 17 13:32:51 2016
 
 Model author: Glenn De Jonghe
 Model name:   Player Tank

+ 15 - 9
examples/timer-threads/python/runner.py

@@ -1,19 +1,25 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''
-
 import target_py.target as target
 from sccd.runtime.statecharts_core import Event
 import threading
 
 if __name__ == '__main__':
     controller = target.Controller()
+    
     def raw_inputter():
         while 1:
             controller.addInput(Event(raw_input(), "input", []))
-    thread = threading.Thread(target=raw_inputter)
-    thread.daemon = True
-    thread.start()
+    input_thread = threading.Thread(target=raw_inputter)
+    input_thread.daemon = True
+    input_thread.start()
+    
+    output_listener = controller.addOutputListener(["output"])
+    def outputter():
+        while 1:
+            event = output_listener.fetch(-1)
+            print "SIMTIME: %.2fs" % (event.getParameters()[0] / 1000.0)
+            print "ACTTIME: %.2fs" % (event.getParameters()[1] / 1000.0)
+    output_thread = threading.Thread(target=outputter)
+    output_thread.daemon = True
+    output_thread.start()
+    
     controller.start()

+ 21 - 29
examples/timer-threads/python/sccd.xml

@@ -1,50 +1,42 @@
 <?xml version="1.0" ?>
 <diagram author="Simon Van Mierlo" name="Timer (Threaded Version)">
-    <description>
-    </description>
     <top>
         from sccd.runtime.accurate_time import time
-    </top>    
-    <inport name="input" />
+    </top>
+    
+    <inport name="input" />        
+    <outport name="output" />
 
     <class name="MainApp" default="true">
-        <method name="MainApp">
-            <body>
-                <![CDATA[
-                ]]>
-            </body>        
-        </method>
-        <method name="update_timers">
-            <body>
-                print 'SIMTIME = %.2f' % get_simulated_time()
-                print 'ACTTIME = %.2f' % time()
-            </body>
-        </method>
         <scxml initial="running">
             <state id="running">
                 <transition target="." after="0.05">
-                    <script>
-                        self.update_timers()
-                    </script>
+                    <raise event="time_update" port="output">
+                        <parameter expr="self.getSimulatedTime()" />
+                        <parameter expr="time()" />
+                    </raise>
                 </transition>
                 <transition target="../interrupted" event="interrupt" port="input">
-                    <script>
-                        self.update_timers()
-                    </script>
+                    <raise event="time_update" port="output">
+                        <parameter expr="self.getSimulatedTime()" />
+                        <parameter expr="time()" />
+                    </raise>
                 </transition>
             </state>
             <state id="interrupted">
                 <transition target="." event="interrupt" port="input">
-                    <script>
-                        self.update_timers()
-                    </script>
+                    <raise event="time_update" port="output">
+                        <parameter expr="self.getSimulatedTime()" />
+                        <parameter expr="time()" />
+                    </raise>
                 </transition>
                 <transition target="../running" event="continue" port="input">
-                    <script>
-                        self.update_timers()
-                    </script>
+                    <raise event="time_update" port="output">
+                        <parameter expr="self.getSimulatedTime()" />
+                        <parameter expr="time()" />
+                    </raise>
                 </transition>
             </state>
         </scxml>
     </class>
-</diagram>
+</diagram>

+ 5 - 4
examples/timer/js/index.html

@@ -1,8 +1,9 @@
 <div>
-<script src="../../../src/javascript_sccd_runtime/statecharts_core.js"></script>
-<script src="../../../src/javascript_sccd_runtime/libs/utils.js"></script>
-<script src="../../../src/javascript_sccd_runtime/libs/svg.js"></script>
-<script src="../../../src/javascript_sccd_runtime/libs/ui.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/HackTimer.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/statecharts_core.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/utils.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/svg.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/ui.js"></script>
 <script src="target_js/target.js"></script>
 <script>
 controller = new Timer.Controller(new JsEventLoop());

+ 2 - 14
examples/timer/js/sccd.xml

@@ -1,7 +1,5 @@
 <?xml version="1.0" ?>
 <diagram author="Simon Van Mierlo" name="Timer">
-    <description>
-    </description>
     <inport name="ui" />
 
     <class name="MainApp" default="true">
@@ -20,8 +18,8 @@
         </method>
         <method name="update_timers">
             <body>
-                this.clock_text.set_text(get_simulated_time().toFixed(2));
-                this.actual_clock_text.set_text(time().toFixed(2));
+                this.clock_text.set_text((this.getSimulatedTime() / 1000).toFixed(2));
+                this.actual_clock_text.set_text((this.getSimulatedTime() / 1000).toFixed(2));
             </body>
         </method>
         <scxml initial="running">
@@ -38,16 +36,6 @@
                 </transition>
             </state>
             <state id="interrupted">
-                <onentry>
-                    <script>
-                        console.log("entering interrupted");
-                    </script>
-                </onentry>
-                <onexit>
-                    <script>
-                        console.log("entering interrupted");
-                    </script>
-                </onexit>
                 <transition target="." event="interrupt_clicked" port="ui">
                     <script>
                         this.update_timers();

+ 0 - 6
examples/timer/python/runner.py

@@ -1,9 +1,3 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''
-
 import Tkinter as tk
 import target_py.target as target
 from sccd.runtime.libs.ui import ui

+ 5 - 7
examples/timer/python/sccd.xml

@@ -1,12 +1,10 @@
 <?xml version="1.0" ?>
-<diagram author="Simon Van Mierlo" name="Timer">
-    <description>
-    </description>
+<diagram author="Simon Van Mierlo" name="Timer (Eventloop Version)">
     <top>
         from sccd.runtime.libs.ui import ui
         from sccd.runtime.accurate_time import time
-        from sccd.runtime.statecharts_core import get_simulated_time
-    </top>    
+    </top>
+    
     <inport name="ui" />
 
     <class name="MainApp" default="true">
@@ -25,8 +23,8 @@
         </method>
         <method name="update_timers">
             <body>
-                self.canvas.element.itemconfigure(self.clock_text, text=str('%.2f' % get_simulated_time()))
-                self.canvas.element.itemconfigure(self.actual_clock_text, text='%.2f' % time())
+                self.canvas.element.itemconfigure(self.clock_text, text=str('%.2f' % (self.getSimulatedTime() / 1000.0)))
+                self.canvas.element.itemconfigure(self.actual_clock_text, text='%.2f' % (time() / 1000.0))
             </body>
         </method>
         <scxml initial="running">

+ 5 - 4
examples/trafficlights/js/index.html

@@ -1,8 +1,9 @@
 <div>
-<script src="../../../src/javascript_sccd_runtime/statecharts_core.js"></script>
-<script src="../../../src/javascript_sccd_runtime/libs/utils.js"></script>
-<script src="../../../src/javascript_sccd_runtime/libs/svg.js"></script>
-<script src="../../../src/javascript_sccd_runtime/libs/ui.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/HackTimer.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/statecharts_core.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/utils.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/svg.js"></script>
+<script src="https://msdl.uantwerpen.be/git/simon/SCCD/raw/v0.9/src/javascript_sccd_runtime/libs/ui.js"></script>
 <script src="target_js/target.js"></script>
 <script>
 controller = new Traffic_Light_JavaScript_Version.Controller(new JsEventLoop());

+ 0 - 4
examples/trafficlights/js/sccd.xml

@@ -1,9 +1,5 @@
 <?xml version="1.0" ?>
 <diagram author="Raphael Mannadiar" name="Traffic_Light_JavaScript_Version">
-	<description>
-	</description>
-	<top>
-	</top>	
 	<inport name="ui" />
 
 	<class name="MainApp" default="true">

+ 0 - 6
examples/trafficlights/python/runner.py

@@ -1,9 +1,3 @@
-'''
-Created on 27-jul.-2014
-
-@author: Simon
-'''
-
 import Tkinter as tk
 import target_py.target as target
 from sccd.runtime.libs.ui import ui

+ 29 - 1
src/python_sccd/python_sccd_runtime/statecharts_core.py

@@ -1,3 +1,7 @@
+"""
+The classes and functions needed to run (compiled) SCCD models.
+"""
+
 import abc
 import re
 import threading
@@ -11,26 +15,50 @@ from sccd.runtime.event_queue import EventQueue
 import sccd.runtime.accurate_time as accurate_time
 
 class RuntimeException(Exception):
+    """
+    Base class for runtime exceptions.
+    """
     def __init__(self, message):
         self.message = message
     def __str__(self):
         return repr(self.message)
 
 class AssociationException(RuntimeException):
+    """
+    Exception class thrown when an error occurs in a CRUD operation on associations.
+    """
     pass
 
 class AssociationReferenceException(RuntimeException):
+    """
+    Exception class thrown when an error occurs when resolving an association reference.
+    """
     pass
 
 class ParameterException(RuntimeException):
+    """
+    Exception class thrown when an error occurs when passing parameters.
+    """
     pass
 
 class InputException(RuntimeException):
+    """
+    Exception class thrown when an error occurs during input processing.
+    """
     pass
 
 class Association(object):
-    # wrapper object for one association relation
+    """
+    Class representing an SCCD association.
+    """
     def __init__(self, to_class, min_card, max_card):
+        """
+        Constructor
+        
+        :param to_class: the name of the target class
+        :param min_card: the minimal cardinality
+        :param max_card: the maximal cardinality
+        """
         self.to_class = to_class
         self.min_card = min_card
         self.max_card = max_card