Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
valve-control
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
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
Corby Schmitz
valve-control
Commits
57f3e945
Commit
57f3e945
authored
4 months ago
by
Corby Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
Updating documentation in python style.
parent
4c4345cd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client-code/gui-orchestrator.py
+36
-7
36 additions, 7 deletions
client-code/gui-orchestrator.py
with
36 additions
and
7 deletions
client-code/gui-orchestrator.py
+
36
−
7
View file @
57f3e945
...
...
@@ -8,8 +8,14 @@ import glob
# Used for iterative operations ... can be ammended if needed
valves
=
[
"
Valve01
"
,
"
Valve02
"
,
"
Valve03
"
,
"
Valve04
"
]
#
Event handler for selecting a valve from the drop-down list on the Change Valves dialogue
#
def
on_select
(
event
):
"""
Event handler for selecting a valve from the drop-down
list on the Change Valves dialogue
:returns:
void
"""
selected_item
=
updateComboBox
.
get
()
labelUpdate
.
config
(
text
=
"
Selected Item:
"
+
selected_item
)
updateOpenTime
.
set
(
currentStatus
[
updateComboBox
.
current
()][
1
])
...
...
@@ -78,8 +84,12 @@ except serial.SerialException:
print
(
port
)
sys
.
exit
(
1
)
# Function to process a clean exit from the GUI, destroying both windows (even if hidden)
def
leave
():
"""
Cleans up and exits the program, destroying both windows (even if hidden)
:returns:
void
"""
try
:
s
.
close
()
# Close the serial port (if possible)
except
serial
.
SerialException
:
...
...
@@ -94,17 +104,31 @@ window.protocol('WM_DELETE_WINDOW', leave) # Handler for clicking the x
label
=
tk
.
Label
(
window
,
text
=
"
Valve Orchestrator
"
)
# Label showing the window title
label
.
pack
()
# Place label at top middle of the window
# Reveals the sub-dialogue for setting valve specifications
def
show
():
"""
Reveals the sub-dialogue for setting directives
:returns:
void
"""
updateWindow
.
deiconify
()
# Hides the sub-dialogue for setting valve specifications
def
hide
():
"""
Hides the sub-dialogue for setting directives
:returns:
void
"""
updateWindow
.
withdraw
()
# When the update button is clicked, this function runs to set the new valve directives
# At the end, it hides the dialog and returns focus to the main window
def
change
():
"""
Event handler for Commit Changes button.
When the update button is clicked, this function runs to set
the new valve directive. At the end, it hides the dialogue
and returns focus to the main window.
:returns:
void
"""
writable
=
(
str
(
updateComboBox
.
current
()
+
1
)
+
"
,
"
+
str
(
updateOpenTime
.
get
())
+
"
,
"
+
str
(
updateCloseTime
.
get
())
+
"
\r
"
).
encode
(
encoding
=
"
ascii
"
,
errors
=
"
strict
"
)
s
.
write
(
writable
)
updateWindow
.
withdraw
()
...
...
@@ -221,8 +245,13 @@ exitButton.place(x=585, y=280)
# Variable to hold the status data, multidimentional array
currentStatus
=
[[],[],[],[]]
# Core function to run the overall program
def
custom_mainloop
():
"""
Main loop for processing updated metrics and orchestrating
control of the valve system
:returns:
void
"""
global
currentStatus
# Use global status data
inputData
=
s
.
readline
().
decode
(
"
utf-8
"
)
# Read information from the serial port connected to valve control
# Example data from the controller
...
...
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