Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Spencer Du
control software
Commits
cb138566
Commit
cb138566
authored
Oct 26, 2019
by
Spencer Du
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
6f445e86
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
13 deletions
+151
-13
GUI.ipynb.py
GUI.ipynb.py
+113
-0
__pycache__/laserEmbedded.cpython-38.pyc
__pycache__/laserEmbedded.cpython-38.pyc
+0
-0
__pycache__/mqtt2.cpython-38.pyc
__pycache__/mqtt2.cpython-38.pyc
+0
-0
camerasEmbedded.py
camerasEmbedded.py
+13
-5
filterwheelEmbedded.py
filterwheelEmbedded.py
+12
-4
laserEmbedded.py
laserEmbedded.py
+12
-4
list_of_device(s)_currently_active.txt
list_of_device(s)_currently_active.txt
+1
-0
No files found.
GUI.ipynb.py
0 → 100644
View file @
cb138566
import
paho.mqtt.client
as
mqtt
import
os
import
sys
import
PyQt5
from
PyQt5.QtWidgets
import
*
from
PyQt5.QtCore
import
*
from
PyQt5
import
QtWidgets
,
uic
,
QtCore
from
mqtt
import
*
import
json
import
time
if
hasattr
(
QtCore
.
Qt
,
'AA_EnableHighDpiScaling'
):
PyQt5
.
QtWidgets
.
QApplication
.
setAttribute
(
QtCore
.
Qt
.
AA_EnableHighDpiScaling
,
True
)
if
hasattr
(
QtCore
.
Qt
,
'AA_UseHighDpiPixmaps'
):
PyQt5
.
QtWidgets
.
QApplication
.
setAttribute
(
QtCore
.
Qt
.
AA_UseHighDpiPixmaps
,
True
)
class
MainWindow
(
QtWidgets
.
QMainWindow
):
def
__init__
(
self
,
parent
=
None
):
QMainWindow
.
__init__
(
self
)
super
(
MainWindow
,
self
).
__init__
(
parent
)
self
.
mdi
=
QMdiArea
()
self
.
setCentralWidget
(
self
.
mdi
)
self
.
setMinimumSize
(
QSize
(
800
,
600
))
self
.
setWindowTitle
(
"PyQt button example - pythonprogramminglanguage.com"
)
client
=
device
()
client
.
run
()
client
.
loop_start
()
print
(
"Connected to broker"
)
time
.
sleep
(
1
)
print
(
"Subscribing to topic"
,
"microscope/light_sheet_microscope/UI/devices"
)
client
.
subscribe
(
"microscope/light_sheet_microscope/UI/devices"
)
print
(
"Publishing message to topic"
,
"microscope/light_sheet_microscope/UI/devices"
)
client
.
publish
(
"microscope/light_sheet_microscope/UI/devices"
,
json
.
dumps
({
"type"
:
"system"
,
"payload"
:{
"cmd"
:
"get all devices"
}},
indent
=
2
))
time
.
sleep
(
1
)
pybutton
=
QPushButton
(
'Add device'
,
self
)
pybutton
.
clicked
.
connect
(
self
.
importbutton
)
pybutton
.
move
(
100
,
400
)
pybutton
.
resize
(
150
,
32
)
self
.
combo
=
QComboBox
(
self
)
self
.
combo
.
move
(
100
,
350
)
self
.
combo
.
resize
(
100
,
32
)
menubar
=
self
.
menuBar
()
devicesMenu
=
menubar
.
addMenu
(
"Devices"
)
def
readFile
(
fname
):
try
:
with
open
(
fname
,
"r"
)
as
f
:
for
item
in
f
:
self
.
combo
.
addItem
(
item
,
self
.
importbutton
)
except
:
print
(
"No devices active"
)
readFile
(
"list_of_device(s)_currently_active.txt"
)
def
importbutton
(
self
):
if
not
os
.
path
.
exists
(
"laser.ini"
):
client
=
device
()
client
.
run
()
client
.
loop_start
()
print
(
"
\n
"
+
"Connected to broker"
)
time
.
sleep
(
1
)
print
(
"Subscribing to topic"
,
"microscope/light_sheet_microscope/UI/add device"
)
client
.
subscribe
(
"microscope/light_sheet_microscope/UI/add device"
)
print
(
"Publishing message to topic"
,
"microscope/light_sheet_microscope/UI/add device"
)
client
.
publish
(
"microscope/light_sheet_microscope/UI/add device"
,
json
.
dumps
({
"type"
:
"system"
,
"payload"
:{
"cmd"
:
"init device panel"
}},
indent
=
2
))
time
.
sleep
(
1
)
client
.
loop_stop
()
self
.
fileName_UI
=
self
.
combo
.
currentText
()
self
.
loadGUI
()
print
(
"Device panel initialised"
+
"
\n
"
)
else
:
if
os
.
path
.
exists
(
"laser.ini"
):
client
=
device
()
client
.
run
()
client
.
loop_start
()
print
(
"
\n
"
+
"Connected to broker"
)
time
.
sleep
(
1
)
print
(
"Subscribing to topic"
,
"microscope/light_sheet_microscope/UI/laser"
)
client
.
subscribe
(
"microscope/light_sheet_microscope/UI/laser"
)
print
(
"Publishing message to topic"
,
"microscope/light_sheet_microscope/UI/laser"
)
client
.
publish
(
"microscope/light_sheet_microscope/UI/laser"
,
json
.
dumps
({
"type"
:
"device"
,
"payload"
:{
"name"
:
"laser"
,
"cmd"
:
"set config"
}},
indent
=
2
))
time
.
sleep
(
1
)
client
.
loop_stop
()
self
.
fileName_UI
=
self
.
combo
.
currentText
()
self
.
loadGUI
()
print
(
"Laser config set"
+
"
\n
"
)
def
loadGUI
(
self
):
module
=
__import__
(
self
.
fileName_UI
.
rstrip
(
"
\n
"
))
my_class
=
getattr
(
module
,
"SubWindow"
)
sub
=
QMdiSubWindow
()
sub
.
setWidget
(
my_class
())
sub
.
setWindowTitle
(
self
.
fileName_UI
)
self
.
mdi
.
addSubWindow
(
sub
)
sub
.
show
()
if
__name__
==
"__main__"
:
app
=
QApplication
(
sys
.
argv
)
mainWin
=
MainWindow
()
mainWin
.
show
()
# publishedMessage = mainWin.getGUIFilename()
sys
.
exit
(
app
.
exec_
())
\ No newline at end of file
__pycache__/laserEmbedded.cpython-38.pyc
0 → 100644
View file @
cb138566
File added
__pycache__/mqtt2.cpython-38.pyc
View file @
cb138566
No preview for this file type
camerasEmbedded.py
View file @
cb138566
import
random
import
asyncio
from
actorio
import
Actor
,
Message
,
DataMessage
,
ask
,
EndMainLoop
,
Reference
class
Cameras
:
async
def
Cameras
(
):
print
(
"Camera"
)
class
Cameras
(
Actor
)
:
async
def
handle_message
(
self
,
message
:
Message
):
print
(
"Camera
s
"
)
await
asyncio
.
sleep
(
2
)
print
(
"Unitialised"
)
await
asyncio
.
sleep
(
2
)
...
...
@@ -14,5 +16,11 @@ class Cameras:
await
asyncio
.
sleep
(
2
)
print
(
"Configured"
)
await
asyncio
.
sleep
(
2
)
print
(
"Hello World Im a camera!"
+
"
\n
"
)
asyncio
.
run
(
Cameras
())
\ No newline at end of file
await
message
.
sender
.
tell
(
DataMessage
(
data
=
"Hello World Im a camera!"
+
"
\n
"
,
sender
=
self
))
async
def
main
():
# Let's create an instance of a Greeter actor and start it.
async
with
Cameras
()
as
cameras
:
# Then we'll just send it an empty message and wait for a response
reply
:
DataMessage
=
await
ask
(
cameras
,
Message
())
print
(
reply
.
data
)
asyncio
.
get_event_loop
().
run_until_complete
(
main
())
\ No newline at end of file
filterwheelEmbedded.py
View file @
cb138566
import
random
import
asyncio
from
actorio
import
Actor
,
Message
,
DataMessage
,
ask
,
EndMainLoop
,
Reference
class
FW
:
async
def
FW
(
):
class
FW
(
Actor
)
:
async
def
handle_message
(
self
,
message
:
Message
):
print
(
"Filter wheel"
)
await
asyncio
.
sleep
(
2
)
print
(
"Unitialised"
)
...
...
@@ -14,5 +16,11 @@ class FW:
await
asyncio
.
sleep
(
2
)
print
(
"Configured"
)
await
asyncio
.
sleep
(
2
)
print
(
"Hello World Im a filter wheel!"
+
"
\n
"
)
asyncio
.
run
(
FW
())
\ No newline at end of file
await
message
.
sender
.
tell
(
DataMessage
(
data
=
"Hello World Im a filter wheel!"
+
"
\n
"
,
sender
=
self
))
async
def
main
():
# Let's create an instance of a Greeter actor and start it.
async
with
FW
()
as
fw
:
# Then we'll just send it an empty message and wait for a response
reply
:
DataMessage
=
await
ask
(
fw
,
Message
())
print
(
reply
.
data
)
asyncio
.
get_event_loop
().
run_until_complete
(
main
())
\ No newline at end of file
laserEmbedded.py
View file @
cb138566
import
random
import
asyncio
from
actorio
import
Actor
,
Message
,
DataMessage
,
ask
,
EndMainLoop
,
Reference
from
mqtt2
import
*
class
Laser
:
async
def
Laser
(
):
class
Laser
(
Actor
)
:
async
def
handle_message
(
self
,
message
:
Message
):
print
(
"Laser"
)
await
asyncio
.
sleep
(
2
)
print
(
"Unitialised"
)
...
...
@@ -15,8 +17,14 @@ class Laser:
await
asyncio
.
sleep
(
2
)
print
(
"Configured"
)
await
asyncio
.
sleep
(
2
)
print
(
"Hello World Im a laser!"
+
"
\n
"
)
asyncio
.
run
(
Laser
())
await
message
.
sender
.
tell
(
DataMessage
(
data
=
"Hello World Im a laser!"
+
"
\n
"
,
sender
=
self
))
async
def
main
():
# Let's create an instance of a Greeter actor and start it.
async
with
Laser
()
as
laser
:
# Then we'll just send it an empty message and wait for a response
reply
:
DataMessage
=
await
ask
(
laser
,
Message
())
print
(
reply
.
data
)
asyncio
.
get_event_loop
().
run_until_complete
(
main
())
def
subscribe
():
client
=
embedded
()
...
...
list_of_device(s)_currently_active.txt
0 → 100644
View file @
cb138566
laser
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