Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-plantsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sellers
python-plantsim
Commits
33b88ea5
Commit
33b88ea5
authored
2 years ago
by
KeSellers
Browse files
Options
Downloads
Patches
Plain Diff
Anpassungen
parent
e7450a1e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
plantsim/plantsim.py
+2
-0
2 additions, 0 deletions
plantsim/plantsim.py
plantsim/table.py
+15
-5
15 additions, 5 deletions
plantsim/table.py
with
17 additions
and
5 deletions
plantsim/plantsim.py
+
2
−
0
View file @
33b88ea5
...
...
@@ -76,6 +76,8 @@ class Plantsim:
raise
Exception
(
'
You need to set an event controller first!
'
)
self
.
plantsim
.
StartSimulation
(
self
.
event_controller
)
def
is_simulation_running
(
self
):
return
(
self
.
plantsim
.
IsSimulationRunning
())
def
get_object
(
self
,
object_name
):
# "Smart" getter that has some limited ability to decide which kind of object to return
...
...
This diff is collapsed.
Click to expand it.
plantsim/table.py
+
15
−
5
View file @
33b88ea5
...
...
@@ -11,30 +11,37 @@ from typing import List, Union, Dict
class
Table
:
def
__init__
(
self
,
plantsim
,
table_name
):
def
__init__
(
self
,
plantsim
,
table_name
,
header
=
[]
):
"""
Table mapping for PlantSim Tables (e.g., DataTable, ExplorerTable)
:param plantsim: Plantsim instance (with loaded model) that is queried
:param table_name: The object name within Plantsim relative to the current path context
"""
self
.
Header
=
header
self
.
_rows
=
[]
self
.
_rows_coldict
=
[]
print
(
plantsim
.
get_value
(
f
'
{
table_name
}
'
))
row_count
=
plantsim
.
get_value
(
f
'
{
table_name
}
.YDim
'
)
col_count
=
plantsim
.
get_value
(
f
'
{
table_name
}
.XDim
'
)
self
.
set_headers
(
col_count
)
if
row_count
>
0
and
col_count
>
0
:
for
row_idx
in
range
(
row_count
+
1
):
for
row_idx
in
range
(
1
,
row_count
):
row
=
[]
row_coldict
=
{}
for
col_idx
in
range
(
col_count
+
1
):
for
col_idx
in
range
(
1
,
col_count
+
1
):
cell_value
=
plantsim
.
get_value
(
f
'
{
table_name
}
[
{
col_idx
}
,
{
row_idx
}
]
'
)
row
.
append
(
cell_value
)
if
row_idx
>
0
:
col_header
=
self
.
rows
[
0
][
col_idx
]
col_header
=
self
.
rows
[
0
][
col_idx
-
1
]
row_coldict
[
col_header
]
=
cell_value
self
.
_rows
.
append
(
row
)
if
row_idx
>
0
:
self
.
_rows_coldict
.
append
(
row_coldict
)
def
set_headers
(
self
,
col_count
):
assert
len
(
self
.
Header
)
==
col_count
self
.
_rows
.
append
(
self
.
Header
)
@property
def
rows
(
self
)
->
List
[
List
]:
...
...
@@ -149,9 +156,12 @@ class Table:
Returns string representation via Texttable
:return: string representation of table
"""
rows
=
self
.
rows
if
self
.
row_count
>
0
:
texttable
=
Texttable
(
200
)
texttable
.
add_rows
(
self
.
rows
)
texttable
.
header
=
rows
[
0
]
texttable
.
set_deco
(
Texttable
.
HEADER
)
return
texttable
.
draw
()
else
:
...
...
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