Implementation of an approach to translate statecharts and class diagrams to classic DEVS using the PyDEVS framework.

sampieters 4d3c534e4e fixed the elif in generator and fixed the "lag" in the ball for external transition 1 year ago
.idea a5db0bebb9 Initial commit 1 year ago
examples 4d3c534e4e fixed the elif in generator and fixed the "lag" in the ball for external transition 1 year ago
paper c15cf032d2 Changed DEVSGenerator to newest verison, problem with tkinter 1 year ago
sccd 4d3c534e4e fixed the elif in generator and fixed the "lag" in the ball for external transition 1 year ago
.gitattributes a5db0bebb9 Initial commit 1 year ago
.gitignore 9d7d02a12f Added pypdevs examples, need to fix ValueError: cannot convert float NaN to integer 1 year ago
README.md 4d3c534e4e fixed the elif in generator and fixed the "lag" in the ball for external transition 1 year ago

README.md

SCCD2DEVS

This project focuses on the conversion of SCCD XML files into a format compatible with pypDEVS, a Python implementation of the Parallel DEVS (pypDEVS) formalism. The SCCD XML format is commonly used for describing the configuration and behavior of complex systems, while pypDEVS provides a framework for modeling and simulating discrete-event systems.

In this thesis project, we explore the process of transforming SCCD XML files into pypDEVS models, enabling seamless integration of SCCD-based system descriptions into the pDEVS simulation environment. By leveraging the capabilities of both SCCD and pypDEVS, we aim to facilitate the analysis and simulation of intricate systems, contributing to the advancement of modeling and simulation techniques in various domains.

A small documentation for the project can be found here, providing insights into the conversion methodology, implementation details, and examples of utilizing the converted models within the pypDEVS framework. Through this work, we endeavor to bridge the gap between SCCD-based system specifications and the pypDEVS simulation paradigm, fostering greater flexibility and efficiency in system analysis and design processes.

Compiler

To compile a conforming SCCD XML file, the provided Python compiler can be used. The compiler can compile conforming SCCD models to two languages: Python and Javascript. Four platforms are supported, TODO: fill in provided 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
                        , eventloop or pypDEVS. The default is eventloop. PypDEVS is only supported for python
  -l LANGUAGE, --language LANGUAGE
                        Target language, either "javascript" or "python".
                        Defaults to the latter.

Runtime Platforms

PypDEVS

The PypDEVS platform works only in the Python language. The platform works both with and without combination of a UI system that allows for scheduling events. Default implementations are provided for the Tkinter UI library on Python.

Examples

All of the examples need two files: A runner.py and a target.py. The target is generated by the compiler and the runner needs to be made seperatelly.

BouncingBalls

To compile the BouncingBallsexample, run the following command

python3 sccds.py -o "./examples/BouncingBalls/PyDEVS/target.py" -p "pypDEVS" "./examples/BouncingBalls/sccd.xml"

This will generate a target for the runner which can be composed as follows:

from pypdevs.simulator import Simulator
import target as target

from tkinter import *
from sccd.runtime.libs.ui_v2 import UI

class OutputListener:
	def __init__(self, ui):
		self.ui = ui

	def add(self, event):
		if event.port == "ui":
			method = getattr(self.ui, event.name)
			method(*event.parameters)

if __name__ == '__main__':
	model = target.Controller(name="controller")
	refs = {"ui": model.ui, "field_ui": model.atomic1.field_ui}

	tkroot = Tk()
	tkroot.withdraw()
	sim = Simulator(model)
	sim.setRealTime(True)
	sim.setRealTimeInputFile(None)
	sim.setRealTimePorts(refs)
	sim.setVerbose(None)
	sim.setRealTimePlatformTk(tkroot)


	#controller = target.Controller(TkEventLoop(tkroot))
	ui = UI(tkroot, "controller")
	#controller.addMyOwnOutputListener(OutputListener(ui))
	#controller.start()
	sim.simulate()
	tkroot.mainloop()

To finally run the sccd in pypDEVS, run the following command:

python3 runner.py

Timer

TODO

1) fill parameters in constructor (e.g. Button, Ball). 2) self.inports["elem"] should only be "elem" 3) Convert DEVui_v2 to ui_v2