Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
cd2bb6bb
Commit
cd2bb6bb
authored
3 years ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
fix zoom issue in plotter
+ update deprecated GTK code
parent
9face6cc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Ccs/plotter.py
+21
-28
21 additions, 28 deletions
Ccs/plotter.py
with
21 additions
and
28 deletions
Ccs/plotter.py
+
21
−
28
View file @
cd2bb6bb
import
os
import
json
import
json
import
struct
import
struct
import
threading
import
threading
import
subprocess
import
time
import
time
import
dbus
import
dbus
...
@@ -10,14 +8,10 @@ import dbus.service
...
@@ -10,14 +8,10 @@ import dbus.service
from
dbus.mainloop.glib
import
DBusGMainLoop
from
dbus.mainloop.glib
import
DBusGMainLoop
import
DBus_Basic
import
DBus_Basic
#from ccs_function_lib import General_Functions
#cfl = General_Functions()
import
ccs_function_lib
as
cfl
import
ccs_function_lib
as
cfl
from
typing
import
NamedTuple
from
typing
import
NamedTuple
import
confignator
import
confignator
import
configparser
import
gi
import
gi
import
sys
import
sys
...
@@ -29,34 +23,27 @@ from matplotlib.figure import Figure
...
@@ -29,34 +23,27 @@ from matplotlib.figure import Figure
# from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
# from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
from
matplotlib.backends.backend_gtk3agg
import
FigureCanvasGTK3Agg
as
FigureCanvas
from
matplotlib.backends.backend_gtk3agg
import
FigureCanvasGTK3Agg
as
FigureCanvas
from
matplotlib.backends.backend_gtk3
import
NavigationToolbar2GTK3
as
NavigationToolbar
from
matplotlib.backends.backend_gtk3
import
NavigationToolbar2GTK3
as
NavigationToolbar
from
matplotlib.backends.backend_gtk3
import
cursord
import
numpy
as
np
import
numpy
as
np
from
database.tm_db
import
DbTelemetryPool
,
DbTelemetry
,
scoped_session_maker
from
database.tm_db
import
DbTelemetryPool
,
DbTelemetry
,
scoped_session_maker
from
sqlalchemy.sql.expression
import
func
from
sqlalchemy.sql.expression
import
func
from
sqlalchemy.orm
import
load_only
#
from sqlalchemy.orm import load_only
import
importlib
import
importlib
#check_cfg = configparser.ConfigParser()
#check_cfg.read('egse.cfg')
#check_cfg.source = 'egse.cfg'
check_cfg
=
confignator
.
get_config
(
file_path
=
confignator
.
get_option
(
'
config-files
'
,
'
ccs
'
))
check_cfg
=
confignator
.
get_config
(
file_path
=
confignator
.
get_option
(
'
config-files
'
,
'
ccs
'
))
project
=
check_cfg
.
get
(
'
ccs-database
'
,
'
project
'
)
project
=
check_cfg
.
get
(
'
ccs-database
'
,
'
project
'
)
project
=
'
packet_config_
'
+
str
(
project
)
project
=
'
packet_config_
'
+
str
(
project
)
packet_config
=
importlib
.
import_module
(
project
)
packet_config
=
importlib
.
import_module
(
project
)
TM_HEADER_LEN
,
TC_HEADER_LEN
,
PEC_LEN
=
[
packet_config
.
TM_HEADER_LEN
,
packet_config
.
TC_HEADER_LEN
,
packet_config
.
PEC_LEN
]
TM_HEADER_LEN
,
TC_HEADER_LEN
,
PEC_LEN
=
[
packet_config
.
TM_HEADER_LEN
,
packet_config
.
TC_HEADER_LEN
,
packet_config
.
PEC_LEN
]
#from packet_config import TM_HEADER_LEN, TC_HEADER_LEN, PEC_LEN
gi
.
require_version
(
'
Gtk
'
,
'
3.0
'
)
gi
.
require_version
(
'
Gtk
'
,
'
3.0
'
)
gi
.
require_version
(
'
Notify
'
,
'
0.7
'
)
gi
.
require_version
(
'
Notify
'
,
'
0.7
'
)
from
gi.repository
import
Gtk
,
Gdk
,
GdkPixbuf
,
GLib
,
Notify
# NOQA
from
gi.repository
import
Gtk
,
Gdk
,
GdkPixbuf
,
GLib
,
Notify
# NOQA
from
event_storm_squasher
import
delayed
from
event_storm_squasher
import
delayed
import
logging.handlers
import
logging.handlers
ActivePoolInfo
=
NamedTuple
(
ActivePoolInfo
=
NamedTuple
(
...
@@ -70,11 +57,10 @@ fmtlist = {'INT8': 'b', 'UINT8': 'B', 'INT16': 'h', 'UINT16': 'H', 'INT32': 'i',
...
@@ -70,11 +57,10 @@ fmtlist = {'INT8': 'b', 'UINT8': 'B', 'INT16': 'h', 'UINT16': 'H', 'INT32': 'i',
'
UINT64
'
:
'
Q
'
,
'
FLOAT
'
:
'
f
'
,
'
DOUBLE
'
:
'
d
'
,
'
INT24
'
:
'
i24
'
,
'
UINT24
'
:
'
I24
'
,
'
bit*
'
:
'
bit
'
}
'
UINT64
'
:
'
Q
'
,
'
FLOAT
'
:
'
f
'
,
'
DOUBLE
'
:
'
d
'
,
'
INT24
'
:
'
i24
'
,
'
UINT24
'
:
'
I24
'
,
'
bit*
'
:
'
bit
'
}
class
PlotViewer
(
Gtk
.
Window
):
class
PlotViewer
(
Gtk
.
Window
):
def
__init__
(
self
,
loaded_pool
=
None
,
parent
=
None
,
poolmgr
=
None
,
given_cfg
=
None
,
refresh_rate
=
1
,
parameters
=
{},
def
__init__
(
self
,
loaded_pool
=
None
,
parent
=
None
,
poolmgr
=
None
,
given_cfg
=
None
,
refresh_rate
=
1
,
parameters
=
{},
start_live
=
False
,
logger
=
None
):
start_live
=
False
,
logger
=
None
):
Gtk
.
Window
.
__init__
(
self
)
Gtk
.
Window
.
__init__
(
self
)
Notify
.
init
(
'
PlotViewer
'
)
Notify
.
init
(
'
PlotViewer
'
)
...
@@ -96,7 +82,7 @@ class PlotViewer(Gtk.Window):
...
@@ -96,7 +82,7 @@ class PlotViewer(Gtk.Window):
self
.
logger
=
cfl
.
start_logging
(
'
ParameterPlotter
'
)
self
.
logger
=
cfl
.
start_logging
(
'
ParameterPlotter
'
)
# Specify which Pool should be used
# Specify which Pool should be used
if
loaded_pool
!=
None
:
if
loaded_pool
is
not
None
:
self
.
loaded_pool
=
loaded_pool
self
.
loaded_pool
=
loaded_pool
else
:
else
:
self
.
loaded_pool
=
None
self
.
loaded_pool
=
None
...
@@ -164,7 +150,6 @@ class PlotViewer(Gtk.Window):
...
@@ -164,7 +150,6 @@ class PlotViewer(Gtk.Window):
# [pools.append([pool]) for pool in self.pool.keys()]
# [pools.append([pool]) for pool in self.pool.keys()]
# self.pool_box.set_model(pools)
# self.pool_box.set_model(pools)
self
.
pool_selector
=
Gtk
.
ComboBoxText
(
tooltip_text
=
'
Select Pool to Plot
'
)
self
.
pool_selector
=
Gtk
.
ComboBoxText
(
tooltip_text
=
'
Select Pool to Plot
'
)
self
.
pool_selector_pools
=
Gtk
.
ListStore
(
str
,
int
,
str
,
bool
)
self
.
pool_selector_pools
=
Gtk
.
ListStore
(
str
,
int
,
str
,
bool
)
...
@@ -207,7 +192,7 @@ class PlotViewer(Gtk.Window):
...
@@ -207,7 +192,7 @@ class PlotViewer(Gtk.Window):
toolbar
.
pack_start
(
Gtk
.
Separator
.
new
(
Gtk
.
Orientation
.
VERTICAL
),
0
,
0
,
0
)
toolbar
.
pack_start
(
Gtk
.
Separator
.
new
(
Gtk
.
Orientation
.
VERTICAL
),
0
,
0
,
0
)
max_data_label
=
Gtk
.
Label
(
'
NMAX:
'
)
max_data_label
=
Gtk
.
Label
(
label
=
'
NMAX:
'
)
max_data_label
.
set_tooltip_text
(
'
At most ~NMAX data points plotted (0 for unlimited)
'
)
max_data_label
.
set_tooltip_text
(
'
At most ~NMAX data points plotted (0 for unlimited)
'
)
self
.
max_data
=
Gtk
.
Entry
()
self
.
max_data
=
Gtk
.
Entry
()
self
.
max_data
.
set_width_chars
(
6
)
self
.
max_data
.
set_width_chars
(
6
)
...
@@ -221,7 +206,7 @@ class PlotViewer(Gtk.Window):
...
@@ -221,7 +206,7 @@ class PlotViewer(Gtk.Window):
self
.
live_plot_switch
=
Gtk
.
Switch
()
self
.
live_plot_switch
=
Gtk
.
Switch
()
self
.
live_plot_switch
.
set_tooltip_text
(
'
Toggle real time parameter plotting
'
)
self
.
live_plot_switch
.
set_tooltip_text
(
'
Toggle real time parameter plotting
'
)
self
.
live_plot_switch
.
connect
(
"
state-set
"
,
self
.
on_switch_liveplot
)
self
.
live_plot_switch
.
connect
(
"
state-set
"
,
self
.
on_switch_liveplot
)
live_plot_label
=
Gtk
.
Label
(
'
Live plot:
'
)
live_plot_label
=
Gtk
.
Label
(
label
=
'
Live plot:
'
)
live_plot
=
Gtk
.
HBox
()
live_plot
=
Gtk
.
HBox
()
live_plot
.
pack_start
(
live_plot_label
,
0
,
0
,
5
)
live_plot
.
pack_start
(
live_plot_label
,
0
,
0
,
5
)
...
@@ -248,26 +233,27 @@ class PlotViewer(Gtk.Window):
...
@@ -248,26 +233,27 @@ class PlotViewer(Gtk.Window):
return
canvas
return
canvas
def
_create_navbar
(
self
):
def
_create_navbar
(
self
):
navbar
=
NavigationToolbarX
(
self
.
canvas
,
self
)
# navbar = NavigationToolbarX(self.canvas, self)
navbar
=
NavigationToolbar
(
self
.
canvas
,
self
)
limits
=
Gtk
.
HBox
()
limits
=
Gtk
.
HBox
()
self
.
xmin
=
Gtk
.
Entry
()
self
.
xmin
=
Gtk
.
Entry
()
self
.
xmin
.
set_width_chars
(
9
)
self
.
xmin
.
set_width_chars
(
9
)
self
.
xmin
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
self
.
xmin
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
xmin_label
=
Gtk
.
Label
(
'
xmin:
'
)
xmin_label
=
Gtk
.
Label
(
label
=
'
xmin:
'
)
self
.
xmax
=
Gtk
.
Entry
()
self
.
xmax
=
Gtk
.
Entry
()
self
.
xmax
.
set_width_chars
(
9
)
self
.
xmax
.
set_width_chars
(
9
)
self
.
xmax
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
self
.
xmax
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
xmax_label
=
Gtk
.
Label
(
'
xmax:
'
)
xmax_label
=
Gtk
.
Label
(
label
=
'
xmax:
'
)
self
.
ymin
=
Gtk
.
Entry
()
self
.
ymin
=
Gtk
.
Entry
()
self
.
ymin
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
self
.
ymin
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
self
.
ymin
.
set_width_chars
(
9
)
self
.
ymin
.
set_width_chars
(
9
)
ymin_label
=
Gtk
.
Label
(
'
ymin:
'
)
ymin_label
=
Gtk
.
Label
(
label
=
'
ymin:
'
)
self
.
ymax
=
Gtk
.
Entry
()
self
.
ymax
=
Gtk
.
Entry
()
self
.
ymax
.
set_width_chars
(
9
)
self
.
ymax
.
set_width_chars
(
9
)
self
.
ymax
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
self
.
ymax
.
connect
(
'
activate
'
,
self
.
set_plot_limits
)
ymax_label
=
Gtk
.
Label
(
'
ymax:
'
)
ymax_label
=
Gtk
.
Label
(
label
=
'
ymax:
'
)
[
i
.
set_text
(
'
{:.1f}
'
.
format
(
j
))
for
j
,
i
in
[
i
.
set_text
(
'
{:.1f}
'
.
format
(
j
))
for
j
,
i
in
zip
(
self
.
subplot
.
get_xlim
()
+
self
.
subplot
.
get_ylim
(),
(
self
.
xmin
,
self
.
xmax
,
self
.
ymin
,
self
.
ymax
))]
zip
(
self
.
subplot
.
get_xlim
()
+
self
.
subplot
.
get_ylim
(),
(
self
.
xmin
,
self
.
xmax
,
self
.
ymin
,
self
.
ymax
))]
...
@@ -287,7 +273,7 @@ class PlotViewer(Gtk.Window):
...
@@ -287,7 +273,7 @@ class PlotViewer(Gtk.Window):
return
navbar
return
navbar
def
create_param_view
(
self
):
def
create_param_view
(
self
):
self
.
treeview
=
Gtk
.
TreeView
(
self
.
create_parameter_model
())
self
.
treeview
=
Gtk
.
TreeView
(
model
=
self
.
create_parameter_model
())
self
.
treeview
.
append_column
(
Gtk
.
TreeViewColumn
(
"
Parameters
"
,
Gtk
.
CellRendererText
(),
text
=
0
))
self
.
treeview
.
append_column
(
Gtk
.
TreeViewColumn
(
"
Parameters
"
,
Gtk
.
CellRendererText
(),
text
=
0
))
...
@@ -1216,18 +1202,25 @@ class PlotViewer(Gtk.Window):
...
@@ -1216,18 +1202,25 @@ class PlotViewer(Gtk.Window):
GLib
.
timeout_add_seconds
(
5
,
self
.
update_pool_view
)
GLib
.
timeout_add_seconds
(
5
,
self
.
update_pool_view
)
return
return
# This class seems to be no longer needed
class
NavigationToolbarX
(
NavigationToolbar
):
class
NavigationToolbarX
(
NavigationToolbar
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
NavigationToolbarX
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
_ids_zoom
=
[]
# override this function to avoid call to Gtk.main_iteration,
# override this function to avoid call to Gtk.main_iteration,
# which causes crash when multiple PlotViewer instances are running
# which causes crash when multiple PlotViewer instances are running
def
set_cursor
(
self
,
cursor
):
def
set_cursor
(
self
,
cursor
):
self
.
canvas
.
get_property
(
"
window
"
).
set_cursor
(
cursord
[
cursor
])
# self.canvas.get_property("window").set_cursor(cursord[cursor])
self
.
canvas
.
set_cursor
(
cursor
)
def
release_zoom
(
self
,
event
):
def
release_zoom
(
self
,
event
):
"""
the release mouse button callback in zoom to rect mode
"""
"""
the release mouse button callback in zoom to rect mode
"""
for
zoom_id
in
self
.
_ids_zoom
:
for
zoom_id
in
self
.
_ids_zoom
:
self
.
canvas
.
mpl_disconnect
(
zoom_id
)
self
.
canvas
.
mpl_disconnect
(
zoom_id
)
self
.
_ids_zoom
=
[]
#
self._ids_zoom = []
self
.
remove_rubberband
()
self
.
remove_rubberband
()
...
...
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