Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Дмитрий Корытько
/
hware
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
99121cd3
...
99121cd3fe0ddd70f0248430f834510d209af85e
authored
2015-09-29 13:02:55 +0300
by
root
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
save
1 parent
3f2ed6a9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
7 deletions
SzsBb/src/main/java/org/emercit/szs/components/JPnlHeader.java
SzsBb/src/main/java/org/emercit/szs/model/WebPost.java
SzsBb/src/main/java/org/emercit/szs/components/JPnlHeader.java
View file @
99121cd
...
...
@@ -16,14 +16,15 @@ import javax.swing.Icon;
import
javax.swing.ImageIcon
;
import
javax.swing.JFrame
;
import
javax.swing.JPanel
;
import
javax.swing.SwingWorker
;
import
javax.swing.UIManager
;
import
javax.swing.border.Border
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
org.emercit.szs.controldevtools.bean.NotificationBB
;
import
org.emercit.szs.model.Config
;
import
org.emercit.szs.szsterminal.SZSTerminal
;
import
java.net.URL
;
...
...
@@ -33,6 +34,10 @@ public class JPnlHeader extends RoundedPanel3 {
private
JLabel
jlblclock
;
private
JLabel
jlbltitle
;
private
JLabel
jlblconnect
;
private
NotificationBB
notificationbb
=
new
NotificationBB
();
public
JPnlHeader
()
{
this
.
setLayout
(
null
);
...
...
@@ -58,10 +63,10 @@ public class JPnlHeader extends RoundedPanel3 {
add
(
jlbltitle
);
// connect
//
jlblconnect = new JLabel();
// jlblconnect.setBounds(5
, 5, 50, 30);
// ChangeConnectImg(false
);
//
add(jlblconnect);
jlblconnect
=
new
JLabel
();
jlblconnect
.
setBounds
(
650
,
5
,
50
,
30
);
jlblconnect
.
setIcon
(
new
ImageIcon
(
this
.
getClass
().
getResource
(
"/disconnect_service.png"
))
);
add
(
jlblconnect
);
}
static
class
exitApp
implements
ActionListener
{
...
...
@@ -80,4 +85,50 @@ public class JPnlHeader extends RoundedPanel3 {
setBackground
(
new
Color
(
168
,
181
,
224
));
}
public
void
setConnect
()
{
new
SwingWorker
<
Void
,
Void
>()
{
protected
Void
doInBackground
()
throws
Exception
{
jlblconnect
.
setIcon
(
new
ImageIcon
(
this
.
getClass
().
getResource
(
"/connect_service.png"
)));
return
null
;
}
}.
execute
();
}
public
void
setDisconnect
()
{
new
SwingWorker
<
Void
,
Void
>()
{
protected
Void
doInBackground
()
throws
Exception
{
jlblconnect
.
setIcon
(
new
ImageIcon
(
this
.
getClass
().
getResource
(
"/disconnect_service.png"
)));
notificationbb
.
playSiren
();
Thread
.
sleep
(
1000
);
notificationbb
.
stopSiren
();
return
null
;
}
}.
execute
();
}
}
...
...
SzsBb/src/main/java/org/emercit/szs/model/WebPost.java
View file @
99121cd
...
...
@@ -47,6 +47,8 @@ import org.emercit.szs.service.SData;
import
org.emercit.szs.model.MsgSzs
;
import
org.emercit.szs.szsterminal.SZSTerminal
;
public
class
WebPost
{
...
...
@@ -61,6 +63,8 @@ public class WebPost {
private
Gprs
gprs
;
private
int
count
=
0
;
public
WebPost
()
{
...
...
@@ -185,13 +189,30 @@ public class WebPost {
}
}
urlConnection
.
disconnect
();
SZSTerminal
.
jpnlheader
.
setConnect
();
count
=
0
;
}
catch
(
Exception
e
)
{
count
++;
if
(
count
>=
5
)
{
count
=
0
;
SZSTerminal
.
jpnlheader
.
setDisconnect
();
gprs
.
Reconnect
();
}
log
.
error
(
e
.
getMessage
());
log
.
error
(
MsgSzs
.
connectServerError
);
gprs
.
Reconnect
();
}
finally
{
...
...
@@ -205,10 +226,18 @@ public class WebPost {
}
}
catch
(
Exception
ex
)
{
count
++;
if
(
count
>=
5
)
{
count
=
0
;
SZSTerminal
.
jpnlheader
.
setDisconnect
();
gprs
.
Reconnect
();
}
log
.
error
(
ex
.
getMessage
());
log
.
error
(
MsgSzs
.
connectServerError
);
gprs
.
Reconnect
();
}
}
...
...
Please
register
or
sign in
to post a comment