MAGGen-hub / Gena-CommFSM

A program used for emulating a system of communicating finite state machines and generating a log

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gene-CommFSM

Codacy Badge Build Status

Gene-CommFSM is a tool aimed to emulating behavior of communication of finite state machines. The result of emulation can be saved to a file

How to build

The project uses gradle as a build system. In order to build cli jar use:

# build jar
$ ./gradlew build
# run jar 
$ java -jar CFSM-dist/build/libs/cfsm-1.2.0.jar -help
# example usage with test config
$ java -jar CFSM-dist/build/libs/cfsm-1.2.0.jar -f ./CFSM-parser/src/test/resources/cfsm.json 

Note: make sure you have java 8/9 installed.

Usage

usage: cfsm
 -c,--cases <arg>           amount of cases to generate
 -csv                       Format of logs is csv. Work only with '-d'
                            flag
 -d,--destination <arg>     Path where generated logs will be stored
 -elim,--max-events <arg>   maximum amount of events inside one generation
                            session
 -f,--file <arg>            Path to file with description of model
 -h,--help                  Print help message
 -nv,--no-validation        should config file be validated
 -sc,--show-conditions      Print conditions in csv log. Works only with
                            '-d' and '-csv' flag
 -ss,--show-states          Print states in csv log. Works only with '-d'
                            and '-csv' flag

Example

Let's say you have a configuration file like this:

{
  "protocol": "CFSM 0.3",
  "automata": [
    {
      "name": "A",
      "states": [
        {
          "type": "INITIAL",
          "name": "state1"
        },
        {
          "type": "FINAL",
          "name": "state2"
        }
      ],
      "transitions": [
        {
          "name": "transition1",
          "type": "SENDM",
          "condition": "B ! msg1",
          "from": "state1",
          "to": "state2"
        }
      ]
    },
    {
      "name": "B",
      "states": [
        {
          "type": "INITIAL",
          "name": "state1"
        },
        {
          "type": "GENERAL",
          "name": "state2"
        },
        {
          "type": "FINAL",
          "name": "state3"
        }
      ],
      "transitions": [
        {
          "name": "transition2",
          "type": "RECM",
          "condition": "A ? msg1",
          "from": "state1",
          "to": "state2"
        },
        {
          "name": "transition3",
          "type": "SENDM",
          "condition": "C ! msg1",
          "from": "state2",
          "to": "state3"
        }
      ]
    },
    {
      "name": "C",
      "states": [
        {
          "type": "INITIAL",
          "name": "state1"
        },
        {
          "type": "FINAL",
          "name": "state2"
        }
      ],
      "transitions": [
        {
          "name": "transition4",
          "type": "RECM",
          "condition": "B ? msg1",
          "from": "state1",
          "to": "state2"
        }
      ]
    }
  ]
}

The file can be at CFSM-engine/src/test/resources/cfsm2.json. And you want to generate a logs, the system produce.

That is how it can be done:

Specified path to file is: CFSM-engine/src/test/resources/cfsm2.json
Parsing configuration file......
Valid JSON: OK
Valid syntax: OK
Valid config objects: OK
3 machines found
A: state1 ---> state2
B: state1 ---> state2
B: state2 ---> state3
C: state1 ---> state2

About

A program used for emulating a system of communicating finite state machines and generating a log

License:MIT License


Languages

Language:Java 55.8%Language:Scala 43.8%Language:Shell 0.4%