Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IC-Interface Control
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
João Santos
IC-Interface Control
Commits
b96ab0c6
Commit
b96ab0c6
authored
Oct 21, 2022
by
Mateus Goto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Updated] New array acquisition
parent
60e5851e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
91 additions
and
39 deletions
+91
-39
NHR9400series/NHR9400.py
NHR9400series/NHR9400.py
+10
-3
NHR9400series/__pycache__/NHR9400.cpython-310.pyc
NHR9400series/__pycache__/NHR9400.cpython-310.pyc
+0
-0
main.py
main.py
+1
-1
test/realtime_graph/NHR9400series/NHR9400.py
test/realtime_graph/NHR9400series/NHR9400.py
+10
-4
test/realtime_graph/graph/__pycache__/consumers.cpython-310.pyc
...ealtime_graph/graph/__pycache__/consumers.cpython-310.pyc
+0
-0
test/realtime_graph/graph/consumers.py
test/realtime_graph/graph/consumers.py
+6
-2
test/realtime_graph/static/JavaScript/main.js
test/realtime_graph/static/JavaScript/main.js
+63
-28
test/realtime_graph/templates/base.html
test/realtime_graph/templates/base.html
+1
-1
No files found.
NHR9400series/NHR9400.py
View file @
b96ab0c6
...
...
@@ -501,9 +501,16 @@ class NHR9400():
return
self
.
receiveFloat
(
value
)
def
getVoltageArray
(
self
):
self
.
__s
.
send
(
"FETC:ARR:VOLT?
\n
"
.
encode
())
value
=
self
.
__s
.
recv
(
1024
)
return
self
.
receiveArray
(
value
)
array
=
[]
self
.
__s
.
send
(
"SENSe:SWEep:POINts?
\n
"
.
encode
())
points
=
self
.
__s
.
recv
(
1024
)
points
=
self
.
receiveFloat
(
points
)
for
i
in
range
(
int
(
points
/
130
)):
self
.
__s
.
send
((
"FETC:ARR:VOLT? "
+
str
(
i
*
130
)
+
"
\n
"
).
encode
())
value
=
self
.
__s
.
recv
(
1024
)
value
=
self
.
receiveArray
(
value
)
array
=
array
+
value
return
array
#Fetch the average power of all channels
...
...
NHR9400series/__pycache__/NHR9400.cpython-310.pyc
View file @
b96ab0c6
No preview for this file type
main.py
View file @
b96ab0c6
...
...
@@ -16,7 +16,7 @@ def main():
nhr10
=
[]
nhr30
=
[]
nhr10
=
interface
.
getNhr9410
()
nhr30
=
interface
.
getNhr9430
()
#
nhr30 = interface.getNhr9430()
for
elem
in
nhr10
:
...
...
test/realtime_graph/NHR9400series/NHR9400.py
View file @
b96ab0c6
...
...
@@ -501,10 +501,16 @@ class NHR9400():
return
self
.
receiveFloat
(
value
)
def
getVoltageArray
(
self
):
self
.
__s
.
send
(
"FETC:ARR:VOLT?
\n
"
.
encode
())
value
=
self
.
__s
.
recv
(
1024
)
return
self
.
receiveArray
(
value
)
array
=
[]
self
.
__s
.
send
(
"SENSe:SWEep:POINts?
\n
"
.
encode
())
points
=
self
.
__s
.
recv
(
1024
)
points
=
self
.
receiveFloat
(
points
)
for
i
in
range
(
int
(
points
/
130
)):
self
.
__s
.
send
((
"FETC:ARR:VOLT? "
+
str
(
i
*
130
)
+
"
\n
"
).
encode
())
value
=
self
.
__s
.
recv
(
1024
)
value
=
self
.
receiveArray
(
value
)
array
=
array
+
value
return
array
#Fetch the average power of all channels
def
getPower
(
self
):
...
...
test/realtime_graph/graph/__pycache__/consumers.cpython-310.pyc
View file @
b96ab0c6
No preview for this file type
test/realtime_graph/graph/consumers.py
View file @
b96ab0c6
...
...
@@ -16,5 +16,9 @@ class GraphConsumer(AsyncWebsocketConsumer):
await
self
.
accept
()
for
i
in
range
(
1000
):
await
self
.
send
(
json
.
dumps
({
'value'
:
randint
(
0
,
40
)}))
await
sleep
(
1
)
array
=
nhr10
[
0
].
getVoltageArray
()
print
(
len
(
array
)
/
10
)
for
j
in
range
(
int
(
len
(
array
)
/
4
)):
await
self
.
send
(
json
.
dumps
({
'value'
:
array
[
j
*
4
]}))
await
sleep
(
0.1
)
test/realtime_graph/static/JavaScript/main.js
View file @
b96ab0c6
var
data_array
=
[]
var
label_array
=
[]
var
dps
=
Array
(
130
)
var
graph_data
=
{
type
:
'
line
'
,
data
:
{
labels
:
Array
.
from
(
Array
(
100
).
keys
()),
datasets
:
[{
label
:
'
Prototype
'
,
data
:
data_array
,
tension
:
0.4
,
backgroundColor
:
'
rgba(255, 99, 132, 0.2)
'
,
borderWidth
:
5
}]
},
var
myChart
=
new
CanvasJS
.
Chart
(
"
chartContainer
"
,{
title
:
{
text
:
"
Live Data
"
},
axisY
:
{
gridThickness
:
0
},
data
:
[{
type
:
"
spline
"
,
dataPoints
:
dps
}]
});
myChart
.
render
();
}
const
config
=
{
type
:
'
line
'
,
data
:
graph_data
,
bezierCurve
:
true
,
tension
:
0.5
,
options
:
{
animations
:
{
tension
:
{
duration
:
1000
,
easing
:
'
easeInSine
'
,
loop
:
true
}
},
scales
:
{
y
:
{
// defining min and max so hiding the dataset does not change scale range
min
:
0
,
max
:
100
},
x
:
{
type
:
'
time
'
,
ticks
:
{
autoSkip
:
true
,
maxTicksLimit
:
100
}
}
}
}
};
var
socket
=
new
WebSocket
(
'
ws://localhost:7000/ws/graph/
'
);
var
updateInterval
=
500
;
const
ctx
=
document
.
getElementById
(
'
myChart
'
).
getContext
(
'
2d
'
);
const
myChart
=
new
Chart
(
ctx
,
graph_data
,
config
);
var
socket
=
new
WebSocket
(
'
ws://localhost:7000/ws/graph/
'
)
socket
.
onmessage
=
function
(
e
){
var
djangoData
=
JSON
.
parse
(
e
.
data
);
console
.
log
(
djangoData
.
value
);
var
updatedDps
=
[];
myChart
.
options
.
data
[
0
].
dataPoints
=
[];
for
(
var
i
=
0
;
i
<
dps
.
length
;
i
++
)
updatedDps
.
push
(
djangoData
.
value
[
i
]);
console
.
log
(
djangoData
.
value
[
i
]);
myChart
.
options
.
data
[
0
].
dataPoints
=
updatedDps
;
myChart
.
render
();
};
setInterval
(
function
(
e
){
socket
.
onmessage
()},
updateInterval
);
\ No newline at end of file
var
newGraphData
=
graph_data
.
data
.
datasets
[
0
].
data
;
if
(
newGraphData
.
length
>
99
){
newGraphData
.
shift
();
}
newGraphData
.
push
(
djangoData
.
value
);
console
.
log
(
newGraphData
);
graph_data
.
data
.
datasets
[
0
].
data
=
newGraphData
;
myChart
.
update
();
}
test/realtime_graph/templates/base.html
View file @
b96ab0c6
...
...
@@ -17,7 +17,7 @@
<div
class=
"row"
>
<div
class=
"col-10 mx-auto mt-5"
>
<h1
id=
"app"
>
{{ text }}
</h1>
<canvas
id=
"
chartContainer
"
width=
"400"
height=
"200"
></canvas>
<canvas
id=
"
myChart
"
width=
"400"
height=
"200"
></canvas>
</div>
...
...
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