Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SADAPMAP
Interface
Commits
d077b047
Commit
d077b047
authored
Nov 04, 2019
by
Pedro Henrique Kopper
Browse files
Prevenir que o GC mate o gráfico
parent
7ee0c7fe
Changes
7
Hide whitespace changes
Inline
Side-by-side
config.yaml
View file @
d077b047
...
...
@@ -3,13 +3,11 @@ device:
type
:
mock
location
:
"
/dev/ttyACM0"
channels
:
-
id
:
"
PWR
"
name
:
"
Potênci
a"
-
id
:
"
A0
"
name
:
"
Amostr
a"
color
:
"
#FF0000"
unit
:
"
W
"
-
id
:
"
TC
"
name
:
"
Temperatura
"
unit
:
"
V
"
-
id
:
"
A3
"
name
:
"
Pressão
"
color
:
"
#0000FF"
unit
:
"
ºC"
tc
:
18
type
:
"
R"
unit
:
"
bar"
interfaces/SACADA.py
View file @
d077b047
from
random
import
random
from
time
import
sleep
from
sacada
import
SACADA
as
_SACADA
class
SACADA
(
object
):
def
__init__
(
self
,
logger
,
location
,
channels
):
self
.
channels
=
channels
self
.
s
=
_SACADA
(
location
)
self
.
s
.
sendSCPICommand
(
"IN:SCALE A0,V0256"
)
logger
(
"[SACADA]"
,
"Opening SACADA at {}"
.
format
(
location
))
logger
(
"[SACADA]"
,
str
(
self
.
s
.
identify
()))
logger
(
"[SACADA]"
,
"Valor do zero: {}"
.
format
(
self
.
s
.
zero
()))
...
...
@@ -18,6 +20,8 @@ class SACADA(object):
return
0
if
channel
[
"id"
]
==
"PWR"
:
return
self
.
s
.
readVoltage
(
"A3"
)
*
self
.
s
.
readVoltage
(
"A4"
)
if
channel
[
"id"
]
==
"A3"
:
return
self
.
s
.
readVoltage
(
"A3"
)
*
(
250.0
/
10.0
)
return
self
.
s
.
readVoltage
(
channel
[
"id"
])
def
readAll
(
self
):
...
...
resources/UI/Generico.ui
View file @
d077b047
...
...
@@ -258,7 +258,7 @@ font: 10pt "Liberation Mono";</string>
<string
notr=
"true"
/>
</property>
<property
name=
"title"
>
<string>
Temperatu
ra
</string>
<string>
Amost
ra
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing
</set>
...
...
@@ -298,7 +298,7 @@ font: 10pt "Liberation Mono";</string>
<string
notr=
"true"
/>
</property>
<property
name=
"title"
>
<string>
P
otência
</string>
<string>
P
ressão
</string>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
stretch=
"0"
>
<item
alignment=
"Qt::AlignRight"
>
...
...
threads/Graph.py
View file @
d077b047
from
datetime
import
datetime
from
PyQt5.QtCore
import
QTimer
from
pyqtgraph
import
AxisItem
,
InfiniteLine
,
mkColor
,
mkPen
,
setConfigOption
from
interfaces
import
*
...
...
@@ -17,6 +18,9 @@ class Graph():
self
.
axis
=
[]
self
.
config
=
Config
().
data
self
.
device
=
self
.
config
[
"device"
]
today
=
datetime
.
now
().
strftime
(
"%Y-%m-%d-%H:%M:%S"
)
self
.
logFile
=
open
(
"/home/phckopper/logs/{}-calib.csv"
.
format
(
today
),
"w"
)
self
.
_configurePlots
()
self
.
lastupdated
=
0
...
...
@@ -30,14 +34,18 @@ class Graph():
self
.
graph
.
setBackground
((
240
,
240
,
240
))
def
updateGraphs
(
self
):
self
.
logFile
.
write
(
"
\n
"
)
for
i
,
channel
in
enumerate
(
self
.
device
[
"channels"
]):
self
.
dataX
[
i
].
append
(
self
.
dataX
[
i
][
-
1
]
+
self
.
interval
/
1000.0
)
self
.
dataY
[
i
].
append
(
self
.
interface
.
read
(
self
.
device
[
"channels"
][
i
]))
self
.
plots
[
i
].
getViewBox
().
setRange
(
xRange
=
(
self
.
dataX
[
0
][
-
1
]
-
10
,
self
.
dataX
[
0
][
-
1
]))
self
.
plots
[
i
].
setData
(
self
.
dataX
[
i
],
self
.
dataY
[
i
],
clear
=
True
)
#self.plots[i].getViewBox().setRange(xRange=(self.dataX[0][-1] - 10, self.dataX[0][-1]))
self
.
plots
[
i
].
setData
(
self
.
dataX
[
i
],
self
.
dataY
[
i
])
self
.
logFile
.
write
(
"{},"
.
format
(
self
.
dataY
[
i
][
-
1
]))
self
.
logFile
.
write
(
"{}"
.
format
(
self
.
dataX
[
0
][
-
1
]))
self
.
logFile
.
flush
()
self
.
ui
.
forceLabel
.
setText
(
"{:.
4
f}
U
"
.
format
(
self
.
dataY
[
0
][
-
1
]))
self
.
ui
.
calibratorLabel
.
setText
(
"{:.
2
f}
ºC
"
.
format
(
self
.
dataY
[
1
][
-
1
]))
self
.
ui
.
forceLabel
.
setText
(
"{:.
2
f}
bar
"
.
format
(
self
.
dataY
[
1
][
-
1
]))
self
.
ui
.
calibratorLabel
.
setText
(
"{:.
4
f}
mV
"
.
format
(
self
.
dataY
[
0
][
-
1
]
*
1000
))
pg
.
QtGui
.
QApplication
.
processEvents
()
def
setInterval
(
self
,
interval
):
...
...
@@ -62,10 +70,14 @@ class Graph():
self
.
plots
.
append
(
plot
)
plotItem
.
setClipToView
(
True
)
plotItem
.
showGrid
(
True
)
plotItem
.
getViewBox
().
setMouseEnabled
(
False
,
False
)
#
plotItem.getViewBox().setMouseEnabled(False, False)
plotItem
.
getViewBox
().
enableAutoRange
(
plotItem
.
getViewBox
().
YAxis
)
#plotItem.getViewBox().setAutoPan(x=True)
self
.
dataX
.
append
([
0
])
self
.
dataY
.
append
([
0
])
plotItem
.
setLabel
(
"left"
,
text
=
channel
[
"name"
],
units
=
channel
[
"unit"
])
self
.
logger
(
"[GRAPH]"
,
"Added channel {}"
.
format
(
channel
[
"name"
]))
self
.
logFile
.
write
(
"{},"
.
format
(
channel
[
"name"
]))
self
.
logFile
.
write
(
"timestamp"
)
threads/MainThread.py
View file @
d077b047
from
datetime
import
datetime
from
time
import
sleep
from
time
import
sleep
,
time
from
sys
import
exit
from
PyQt5.QtCore
import
QThread
,
QTimer
from
PyQt5.QtWidgets
import
QMessageBox
,
QApplication
...
...
@@ -8,36 +8,36 @@ from config import Config
from
util.Timer
import
Timer
class
MainThread
():
def
__init__
(
self
,
ui
,
parent
=
None
):
def
__init__
(
self
,
ui
,
timer
):
#super(MainThread, self).__init__(parent)
self
.
ui
=
ui
self
.
data
=
[]
self
.
graph
=
Graph
(
self
.
ui
,
10
0
,
self
.
_log
)
self
.
graph
=
Graph
(
self
.
ui
,
25
0
,
self
.
_log
)
#self.upTimer = Timer()
#self.downTimer = Timer(delay=10)
try
:
self
.
config
=
Config
()
except
FileNotFoundError
:
self
.
_fatal
(
"Arquivo de configuração não encontrado!"
)
self
.
graphTimer
=
QT
imer
(
ui
.
mainGraph
)
self
.
graphTimer
=
t
imer
self
.
graphTimer
.
timeout
.
connect
(
self
.
graph
.
updateGraphs
)
self
.
graphTimer
.
start
(
self
.
graph
.
interval
)
self
.
ui
.
samplingCBox
.
currentIndexChanged
.
connect
(
self
.
_updateSamplingRate
)
def
run
(
self
):
pass
#self.ui.startTimerButton.pressed.connect(self._startTimer)
#self.ui.stopTimerButton.pressed.connect(self._stopTimer)
#self.ui.startRegTimerButton.pressed.connect(self._startTimer)
#self.ui.stopRegTimerButton.pressed.connect(self._stopTimer)
#self.ui.playPauseButton.aboutToShow.connect(self._playPause)
#self.ui.finalizeButton.aboutToShow.connect(self._finalize)
#
while True:
while
True
:
#self._updateTimers()
#if self.graph.running:
# self.graph.updateGraphs()
#QApplication.processEvents()
#sleep(self.graph.interval/1000.0) # Updates at 30FPS
QApplication
.
processEvents
()
print
(
time
())
sleep
(
self
.
graph
.
interval
/
1000.0
)
# Updates at 30FPS
def
_updateSamplingRate
(
self
):
MAP
=
[
100
,
200
,
500
,
1000
,
1500
,
2000
,
2500
,
5000
,
10000
]
...
...
ui/GenericoW.py
View file @
d077b047
...
...
@@ -269,9 +269,9 @@ class Ui_Generico(object):
self
.
samplingCBox
.
setItemText
(
7
,
_translate
(
"Generico"
,
"5 seg"
))
self
.
samplingCBox
.
setItemText
(
8
,
_translate
(
"Generico"
,
"10 seg"
))
self
.
absValGBox
.
setTitle
(
_translate
(
"Generico"
,
"Valores Absolutos"
))
self
.
calibratorGBox
.
setTitle
(
_translate
(
"Generico"
,
"
Temperatu
ra"
))
self
.
calibratorGBox
.
setTitle
(
_translate
(
"Generico"
,
"
Amost
ra"
))
self
.
calibratorLabel
.
setText
(
_translate
(
"Generico"
,
"0 mV"
))
self
.
forceGBox
.
setTitle
(
_translate
(
"Generico"
,
"P
otência
"
))
self
.
forceGBox
.
setTitle
(
_translate
(
"Generico"
,
"P
ressão
"
))
self
.
forceLabel
.
setText
(
_translate
(
"Generico"
,
"0 Tonf"
))
self
.
fileMenu
.
setTitle
(
_translate
(
"Generico"
,
"Arquivo"
))
self
.
stageMenu
.
setTitle
(
_translate
(
"Generico"
,
"Etapa"
))
...
...
ui/MainWindow.py
View file @
d077b047
import
sys
from
PyQt5
import
QtWidgets
,
QtCore
from
PyQt5.QtCore
import
QTimer
from
.GenericoW
import
Ui_Generico
from
threads.MainThread
import
MainThread
...
...
@@ -17,8 +18,9 @@ class Ui_MainWindow(object):
self
.
ui
.
setupUi
(
self
.
dialog
)
print
(
self
.
ui
)
main_thread
=
MainThread
(
self
.
ui
)
#main_thread.finished.connect(self.app.exit)
#main_thread.start()
self
.
timer
=
QTimer
(
self
.
app
)
self
.
main_thread
=
MainThread
(
self
.
ui
,
self
.
timer
)
self
.
dialog
.
showMaximized
()
#main_thread.finished.connect(self.app.exit)
#main_thread.start()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment