Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
uppaal2jetracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Dold
uppaal2jetracer
Commits
a23e3465
Commit
a23e3465
authored
2 months ago
by
Louis Kevin Fink
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of gitlab.kit.edu:unmsq/uppaal2jetracer
parents
38a2ac15
4cc3a421
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#407102
failed
2 months ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
uppaal2jetracer/command_system.py
+34
-22
34 additions, 22 deletions
uppaal2jetracer/command_system.py
uppaal2jetracer/webinterface/app/sockets.py
+3
-0
3 additions, 0 deletions
uppaal2jetracer/webinterface/app/sockets.py
with
37 additions
and
22 deletions
uppaal2jetracer/command_system.py
+
34
−
22
View file @
a23e3465
...
...
@@ -8,11 +8,11 @@ This file can be imported as a module and contains the following classes:
* CommandResult: Result of uppaal2jetracer commands.
* CommandResultType: Result type of uppaal2jetracer commands.
* Command: Interface for all uppaal2jetracer commands.
* ParseCommand: Command for parsing
uppaal
automata.
* ParseRunCommand: Command for parsing and running an
uppaal
system.
* ParseCommand: Command for parsing
UPPAAL
automata.
* ParseRunCommand: Command for parsing and running an
UPPAAL
system.
* ProjectCommand: Command for managing projects.
* QuitCommand: Command for quitting uppaal2jetracer.
* RunCommand: Command for running a parsed
uppaal
system.
* RunCommand: Command for running a parsed
UPPAAL
system.
* VersionCommand: Command for managing versions of parsed automata.
"""
...
...
@@ -30,13 +30,14 @@ from bs4 import BeautifulSoup
from
uppaal2jetracer.controller.executor
import
Executor
,
HardwareCallError
from
uppaal2jetracer.controller.uppaal_controller
import
SystemController
from
uppaal2jetracer.parser.parser
import
SystemParser
from
uppaal2jetracer.parser.parser
import
SystemParser
,
XMLParseError
from
uppaal2jetracer.uppaalmodel.system
import
System
from
uppaal2jetracer.versioncontrol.versioncontrol
import
VersionManager
,
ProjectManager
,
ResponseObject
,
\
ProjectResponse
,
ResponseType
,
VersionResponse
,
GlobalResponse
from
uppaal2jetracer.versioncontrol.versioncontrol
import
VersionManager
,
ProjectManager
,
\
ResponseObject
,
ProjectResponse
,
ResponseType
,
VersionResponse
,
GlobalResponse
logger
=
logging
.
getLogger
(
"
user_command
"
)
class
CommandHandler
(
ABC
):
"""
Abstract base class for all command handlers.
...
...
@@ -234,10 +235,12 @@ class Command(ABC):
_ERROR_ARG_COUNT
=
"
Invalid number of arguments provided.
"
_ERROR_FILE_NOT_FOUND
=
"'
{}
'
is not a valid file.
"
_ERROR_HARDWARE_FAIL
=
"
Execution of hardware command failed.
"
_ERROR_INVALID_ARG
=
"'
{}
'
is not a valid argument.
"
_ERROR_EXECUTION_FAIL
=
"
Execution of
'
{}
'
failed.
"
_SUCCESS_RUN
=
"
Successfully terminated execution of
'
{}
'
.
"
_SUCCESS_TERMINATED
=
"
Successfully terminated execution of
'
{}
'
.
"
_SUCCESS_RUN
=
"
Successfully ran
'
{}
'
.
"
@abstractmethod
def
execute
(
self
,
args
:
List
[
str
])
->
CommandResult
:
...
...
@@ -275,14 +278,14 @@ class Command(ABC):
class
ParseCommand
(
Command
):
"""
A command to parse an
uppaal
system to an executable
uppaal
model.
A command to parse an
UPPAAL
system to an executable
UPPAAL
model.
"""
__slots__
=
(
"
_version_manager
"
,)
_HELP_MESSAGE
=
"""
Usage: parse <path> [-d | --debug] [-h | --help]
The parse command parses an
uppaal
system to an executable
uppaal
model.
The parse command parses an
UPPAAL
system to an executable
UPPAAL
model.
Options: -d, --debug Log debug messages.
-h, --help Show this message.
"""
...
...
@@ -292,6 +295,7 @@ Options: -d, --debug Log debug messages.
_BS_BUILDER
=
"
lxml-xml
"
_ERROR_FILE_TYPE
=
"'
{}
'
is not a valid xml file.
"
_ERROR_UPPAAL_XML
=
"'
{}
'
is not a valid UPPAAL xml.
"
_SUCCESS_MESSAGE
=
"
Parsed successfully and saved in
'
{}
'
.
"
...
...
@@ -309,7 +313,11 @@ Options: -d, --debug Log debug messages.
return
CommandResult
(
self
.
_ERROR_FILE_TYPE
.
format
(
args
[
0
]),
CommandResultType
.
FAILURE
)
with
open
(
args
[
0
],
"
r
"
,
encoding
=
"
utf-8
"
)
as
file
:
system
=
SystemParser
.
parse
(
BeautifulSoup
(
file
,
self
.
_BS_BUILDER
))
try
:
system
=
SystemParser
.
parse
(
BeautifulSoup
(
file
,
self
.
_BS_BUILDER
))
except
XMLParseError
:
return
CommandResult
(
self
.
_ERROR_UPPAAL_XML
.
format
(
args
[
0
]),
CommandResultType
.
FAILURE
)
pkl_file
=
args
[
0
].
replace
(
self
.
_XML_FILE_KEY
,
self
.
_PKL_FILE_KEY
)
with
open
(
pkl_file
,
"
wb
"
)
as
file
:
file
.
write
(
pickle
.
dumps
(
system
))
...
...
@@ -324,14 +332,14 @@ Options: -d, --debug Log debug messages.
class
ParseRunCommand
(
Command
):
"""
A command to parse and execute an
uppaal
system.
A command to parse and execute an
UPPAAL
system.
"""
__slots__
=
(
"
_parse_command
"
,
"
_run_command
"
,)
_HELP_MESSAGE
=
"""
Usage: pnr <path> [-d | --debug] [-h | --help]
The parse and run command parses an
uppaal
system and runs it.
The parse and run command parses an
UPPAAL
system and runs it.
Options: -d, --debug Log debug messages.
-h, --help Show this message.
"""
...
...
@@ -363,7 +371,7 @@ class ProjectCommand(Command):
_HELP_MESSAGE
=
"""
Usage: prj (list | current | config | max <int > 0> | open <name> |
new <name> | delete <name>) [-d | --debug] [-h | --help]
The project command manages projects which contain versions of parsed
uppaal
systems.
The project command manages projects which contain versions of parsed
UPPAAL
systems.
Commands: list Lists all projects.
current Shows the current project.
...
...
@@ -514,12 +522,12 @@ Options: -h, --help Show this message."""
class
RunCommand
(
Command
):
"""
A command to run an
uppaal
system.
A command to run an
UPPAAL
system.
"""
_HELP_MESSAGE
=
"""
Usage: run <path> [-d | --debug] [-h | --help]
The run command starts the execution of an
uppaal
system.
The run command starts the execution of an
UPPAAL
system.
Options: -d, --debug Log debug messages.
-h, --help Show this message.
"""
...
...
@@ -527,7 +535,6 @@ Options: -d, --debug Log debug messages.
_LOGGERS
=
[
"
executor
"
,
"
jetracer
"
]
_ERROR_FILE_TYPE
=
"'
{}
'
is not a valid pkl file.
"
_ERROR_HARDWARE_FAIL
=
"
Execution of hardware command failed.
"
def
__init__
(
self
):
logger
.
info
(
"
Initialized run command.
"
)
...
...
@@ -548,15 +555,16 @@ Options: -d, --debug Log debug messages.
controller
.
run_system
()
except
KeyboardInterrupt
:
Executor
.
stop
()
return
CommandResult
(
self
.
_SUCCESS_RUN
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
return
CommandResult
(
self
.
_SUCCESS_TERMINATED
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
except
HardwareCallError
:
return
CommandResult
(
self
.
_ERROR_HARDWARE_FAIL
,
CommandResultType
.
FAILURE
)
return
CommandResult
(
self
.
_
ERROR_EXECUTION_FAIL
,
CommandResultType
.
SUCCESS
)
return
CommandResult
(
self
.
_
SUCCESS_RUN
.
format
(
args
[
0
])
,
CommandResultType
.
SUCCESS
)
class
VersionCommand
(
Command
):
"""
A command to manage versions of parsed
uppaal
systems.
A command to manage versions of parsed
UPPAAL
systems.
"""
__slots__
=
(
"
_version_manager
"
,)
...
...
@@ -564,7 +572,7 @@ class VersionCommand(Command):
_HELP_MESSAGE
=
"""
Usage: ver (list | run <id> | fav <id> | delete <id>)
[-d | --debug] [-h | --help]
The version command manages parsed versions of
uppaal
systems.
The version command manages parsed versions of
UPPAAL
systems.
Commands: list List all versions in current project.
run Run an existing version.
...
...
@@ -625,8 +633,12 @@ Options: -d, --debug Log debug messages.
try
:
controller
.
run_system
()
except
KeyboardInterrupt
:
return
CommandResult
(
self
.
_SUCCESS_RUN
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
return
CommandResult
(
self
.
_ERROR_EXECUTION_FAIL
,
CommandResultType
.
SUCCESS
)
Executor
.
stop
()
return
CommandResult
(
self
.
_SUCCESS_TERMINATED
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
except
HardwareCallError
:
return
CommandResult
(
self
.
_ERROR_HARDWARE_FAIL
,
CommandResultType
.
FAILURE
)
return
CommandResult
(
self
.
_SUCCESS_RUN
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
def
_execute_fav
(
self
,
args
:
List
[
str
])
->
CommandResult
:
if
not
len
(
args
)
==
1
:
...
...
This diff is collapsed.
Click to expand it.
uppaal2jetracer/webinterface/app/sockets.py
+
3
−
0
View file @
a23e3465
...
...
@@ -5,6 +5,7 @@ This file holds all interactions via socket requests.
import
sqlalchemy
as
sa
from
uppaal2jetracer.controller.executor
import
Executor
from
uppaal2jetracer.webinterface.app
import
socketio
,
db
,
app
from
uppaal2jetracer.webinterface.app.models
import
Global
...
...
@@ -45,6 +46,8 @@ def disconnect(reason: str):
app
.
config
[
"
RUNNING_THREAD
"
]
=
None
Executor
.
stop
()
print
(
"
Client disconnected, reason:
"
,
reason
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment