Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
328adbc5
Commit
328adbc5
authored
7 years ago
by
apvrille
Browse files
Options
Downloads
Patches
Plain Diff
Update on executable code: pressure controller
parent
4da344d7
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
executablecode/example/MainPressureController.java
+16
-39
16 additions, 39 deletions
executablecode/example/MainPressureController.java
with
16 additions
and
39 deletions
executablecode/example/MainPressureController.java
+
16
−
39
View file @
328adbc5
...
...
@@ -17,7 +17,6 @@ public class MainPressureController extends JFrame implements Feeder, ChangeList
static
final
String
ALARM_ON
=
"ALARM ON"
;
static
final
String
ALARM_OFF
=
"alarm off"
;
private
PressureControllerPanel
mp
;
private
DatagramServer
ds
;
private
JSlider
pressureValue
;
...
...
@@ -25,7 +24,7 @@ public class MainPressureController extends JFrame implements Feeder, ChangeList
public
MainPressureController
()
{
super
(
"Pressure Controller demonstration"
);
setSize
(
8
00
,
60
0
);
setSize
(
4
00
,
15
0
);
setVisible
(
true
);
ds
=
new
DatagramServer
();
ds
.
setFeeder
(
this
);
...
...
@@ -51,65 +50,43 @@ public class MainPressureController extends JFrame implements Feeder, ChangeList
add
(
pressureValue
,
BorderLayout
.
NORTH
);
alarm
=
new
JLabel
(
ALARM_OFF
);
add
(
alarm
,
BorderLayout
.
SOUTH
);
alarm
.
setHorizontalAlignment
(
JLabel
.
CENTER
);
alarm
.
setVerticalAlignment
(
JLabel
.
CENTER
);
add
(
alarm
,
BorderLayout
.
CENTER
);
//mp = new PressureControllerPanel();
//mp.addMouseListener(this);
// mp.setPreferredSize(new Dimension(800,600));
//add(mp, BorderLayout.CENTER);
mp
.
revalidate
();
//
mp.revalidate();
}
public
void
setMessage
(
String
msg
)
{
if
(
mp
==
null
)
{
return
;
}
int
index
;
String
s
;
int
duration
;
System
.
out
.
println
(
"Got message:"
+
msg
);
try
{
if
(
msg
.
startsWith
(
"
Duration
"
))
{
if
(
msg
.
startsWith
(
"
+
"
))
{
s
=
msg
.
substring
(
9
,
msg
.
length
());
duration
=
Integer
.
decode
(
s
.
trim
()).
intValue
();
mp
.
setDuration
(
duration
);
mp
.
setStart
(
false
);
//System.out.println("Setting new duration :" + duration);
mp
.
setCookingFinished
(
false
);
}
else
if
(
msg
.
startsWith
(
"Start "
))
{
s
=
msg
.
substring
(
6
,
msg
.
length
());
duration
=
Integer
.
decode
(
s
.
trim
()).
intValue
();
mp
.
setDuration
(
duration
);
mp
.
setStart
(
true
);
mp
.
setCookingFinished
(
false
);
//System.out.println("Setting new duration (start): " + duration);
}
else
if
(
msg
.
startsWith
(
"Magnetron_ON"
))
{
mp
.
setMagnetronON
(
true
);
mp
.
setCookingFinished
(
false
);
}
else
if
(
msg
.
startsWith
(
"Magnetron_OFF"
))
{
mp
.
setMagnetronON
(
false
);
mp
.
setCookingFinished
(
false
);
}
else
if
(
msg
.
startsWith
(
"Open Door"
))
{
mp
.
setDoorOpened
(
true
);
mp
.
setCookingFinished
(
false
);
}
else
if
(
msg
.
startsWith
(
"Close Door"
))
{
mp
.
setDoorOpened
(
false
);
mp
.
setCookingFinished
(
false
);
}
else
if
(
msg
.
startsWith
(
"Dring"
))
{
mp
.
setCookingFinished
(
true
);
}
alarm
.
setText
(
ALARM_ON
);
}
else
if
(
msg
.
startsWith
(
"-"
))
{
alarm
.
setText
(
ALARM_OFF
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Exception when computing message: "
+
e
.
getMessage
());
}
mp
.
repaint
();
}
public
void
stateChanged
(
ChangeEvent
e
)
{
System
.
out
.
println
(
"Value of pressure changed:"
+
pressureValue
.
getValue
());
if
(
ds
!=
null
)
{
ds
.
sendDatagramTo
(
"PRESSURE="
+
pressureValue
.
getValue
());
}
}
/*public void mouseClicked(MouseEvent e){
...
...
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