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
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: 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
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