Commit c7078924 c70789245d58c65ec28db5d75ed15a584dd39f41 by root

save

1 parent 3f2ed6a9
...@@ -2,11 +2,17 @@ package org.emercit.szs.model; ...@@ -2,11 +2,17 @@ package org.emercit.szs.model;
2 2
3 public class EventAgk { 3 public class EventAgk {
4 4
5 public int id; 5 public long id;
6 public int id_agk; 6 public int id_agk;
7 public String name; 7
8 public String message; 8 public String river;
9 public String datetime; 9 public String datetime;
10 public String value;
11
10 public int id_status; // 0-norm, 1-nj-2, oj; 12 public int id_status; // 0-norm, 1-nj-2, oj;
13 public boolean repair; // true -repair; false- no repair
14 public boolean opendoor; // true - open; false-close
15 public boolean veracity; // veracity -true, no veracity -false;
16
11 17
12 } 18 }
......
1 package org.emercit.szs.model; 1 package org.emercit.szs.model;
2 2
3
3 import java.awt.Color; 4 import java.awt.Color;
4 import java.awt.Component; 5 import java.awt.Component;
5 import java.awt.Font; 6 import java.awt.Font;
......
1 package org.emercit.szs.model;
2
3 public class SirenJNI {
4 static {
5 System.loadLibrary("siren");
6
7 }
8
9 public native void sirenOn();
10
11 public native void sirenOff();
12
13 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,54 +3,17 @@ package org.emercit.szs.model; ...@@ -3,54 +3,17 @@ package org.emercit.szs.model;
3 3
4 import java.io.*; 4 import java.io.*;
5 import java.net.*; 5 import java.net.*;
6 import java.io.BufferedOutputStream;
7 import java.io.BufferedReader;
8 import java.io.File;
9 import java.io.IOException;
10 import java.io.InputStreamReader;
11 import java.io.OutputStream;
12 import java.io.OutputStreamWriter;
13 import java.net.HttpURLConnection;
14 import java.net.InetSocketAddress;
15 import java.net.Proxy;
16 import java.net.URL;
17 import java.net.URLEncoder;
18 import java.util.Map;
19 import java.util.Map;
20
21 import org.json.simple.*; 6 import org.json.simple.*;
22
23 import java.io.IOException;
24 import java.io.StringReader;
25
26 import javax.xml.parsers.DocumentBuilder;
27 import javax.xml.parsers.DocumentBuilderFactory;
28 import javax.xml.parsers.ParserConfigurationException;
29
30 import org.w3c.dom.Document;
31 import org.w3c.dom.NodeList;
32 import org.xml.sax.InputSource;
33 import org.xml.sax.SAXException;
34
35 import com.google.gson.*; 7 import com.google.gson.*;
36
37 import org.apache.log4j.Logger; 8 import org.apache.log4j.Logger;
38 import org.w3c.dom.Node;
39 import org.w3c.dom.NodeList;
40 import org.w3c.dom.Element;
41
42 import java.util.ArrayList;
43
44 import org.emercit.szs.model.Config; 9 import org.emercit.szs.model.Config;
45 import org.emercit.szs.service.Gprs;
46 import org.emercit.szs.service.SData; 10 import org.emercit.szs.service.SData;
47
48 import org.emercit.szs.model.MsgSzs; 11 import org.emercit.szs.model.MsgSzs;
49 12
13 import org.emercit.szs.szsterminal.SZSTerminal;
50 14
51 public class WebPost { 15 public class WebPost {
52 16
53
54 private static final Logger log = Logger.getLogger(WebPost.class); 17 private static final Logger log = Logger.getLogger(WebPost.class);
55 18
56 private String ip; 19 private String ip;
...@@ -59,8 +22,7 @@ public class WebPost { ...@@ -59,8 +22,7 @@ public class WebPost {
59 22
60 private String gsm; 23 private String gsm;
61 24
62 private Gprs gprs; 25 private String version;
63
64 26
65 27
66 public WebPost() { 28 public WebPost() {
...@@ -68,7 +30,7 @@ public class WebPost { ...@@ -68,7 +30,7 @@ public class WebPost {
68 this.guid=Config.devinfobean.getGuid(); 30 this.guid=Config.devinfobean.getGuid();
69 this.ip=Config.serverbean.getIp()+":"+Config.serverbean.getPort(); 31 this.ip=Config.serverbean.getIp()+":"+Config.serverbean.getPort();
70 this.gsm=Config.gsmbean.getOperator(); 32 this.gsm=Config.gsmbean.getOperator();
71 this.gprs=new Gprs(this.gsm); 33 this.version=SZSTerminal.version;
72 34
73 print(); 35 print();
74 } 36 }
...@@ -80,118 +42,73 @@ public class WebPost { ...@@ -80,118 +42,73 @@ public class WebPost {
80 42
81 } 43 }
82 44
83
84 public ModelResponse Request() { 45 public ModelResponse Request() {
85 46
86 47 ModelResponse md = null;
87
88 ModelResponse md = new ModelResponse();
89 md.lsteventagkconfirm=new ArrayList<EventAgk>();
90 md.lsteventagkstate=new ArrayList<EventAgk>();
91 48
92 StringBuilder sb = new StringBuilder(); 49 StringBuilder sb = new StringBuilder();
93 50
94 HttpURLConnection urlConnection = null; 51 HttpURLConnection urlConnection = null;
95 52
96
97
98 BufferedReader br=null; 53 BufferedReader br=null;
99 54
100 try { 55 try {
56 URL url = new URL("http://"+this.ip+"/api/DataSzs/");
101 57
58 urlConnection = (HttpURLConnection) url.openConnection();
102 59
60 urlConnection.setDoOutput(true);
61 urlConnection.setRequestMethod("POST");
62 urlConnection.setRequestProperty("Content-Type", "application/json");
103 63
104 URL url = new URL("http://"+ip+"/api/lss_info.php"+"?guid="+guid); 64 urlConnection.setConnectTimeout(5000);
65 urlConnection.setReadTimeout(10000);
105 66
106 urlConnection = (HttpURLConnection) url 67 JSONObject jsonParam = new JSONObject();
107 .openConnection();
108 68
109 urlConnection.setDoOutput(true); 69 jsonParam.put("RegKey", this.guid);
110 urlConnection.setRequestMethod("GET"); 70 jsonParam.put("SoftVersion",this.version);
111 urlConnection.setRequestProperty("Content-Type", "application/xml"); 71 jsonParam.put("IDTeamViewer","");
112 72
113 urlConnection.setConnectTimeout(45000); 73 OutputStreamWriter out = new OutputStreamWriter(
114 urlConnection.setReadTimeout(60000); 74 urlConnection.getOutputStream());
75 out.write(jsonParam.toString());
76 out.close();
115 77
116 78
117
118 urlConnection.connect();
119 int HttpResult = urlConnection.getResponseCode(); 79 int HttpResult = urlConnection.getResponseCode();
120 80
121 if (HttpResult == HttpURLConnection.HTTP_OK) { 81 if (HttpResult == HttpURLConnection.HTTP_OK) {
122 82
83 br = new BufferedReader(new InputStreamReader(
84 urlConnection.getInputStream(), "utf-8"));
123 85
86 String line = null;
124 87
125 InputStream xml = urlConnection.getInputStream(); 88 while ((line = br.readLine()) != null) {
126 89 sb.append(line + "\n");
127 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
128 DocumentBuilder db = dbf.newDocumentBuilder();
129 Document doc = db.parse(xml);
130 SData.INSTANCE.setIsConnect(true);
131 /*
132 * Неподтвержденные события
133 */
134 NodeList list = doc.getElementsByTagName("alarmList");
135 Element element = (Element)list.item(0);
136 NodeList nl=element.getElementsByTagName("alarm");
137 if(nl != null && nl.getLength() > 0) {
138 for(int i = 0 ; i < nl.getLength();i++) {
139
140 Element el = (Element)nl.item(i);
141 try {
142 EventAgk event=new EventAgk();
143
144 event.id=Integer.valueOf(getTextValue(el,"id"));
145 event.name=getTextValue(el,"name");
146 event.id_agk=Integer.valueOf(getTextValue(el,"guid"));
147 event.datetime=getTextValue(el,"datetime");
148 event.id_status=Integer.valueOf(getTextValue(el,"status"));
149 event.message=getTextValue(el,"message");
150
151
152
153 md.lsteventagkconfirm.add(event);
154 }
155 catch(Exception e) {
156 log.error(e.getMessage());
157 }
158 }
159 } 90 }
160 91
161 /*
162 * Текущее состояние станций
163 */
164 list = doc.getElementsByTagName("deviceList");
165 element = (Element)list.item(0);
166 nl=element.getElementsByTagName("device");
167 92
168 if(nl != null && nl.getLength() > 0) { 93 br.close();
169 for(int i = 0 ; i < nl.getLength();i++) {
170 94
171 Element el = (Element)nl.item(i); 95 Gson gson = new Gson();
172 try {
173 EventAgk event=new EventAgk();
174 96
175 event.name=getTextValue(el,"name"); 97 md = gson.fromJson(sb.toString(), ModelResponse.class);
176 event.id_agk=Integer.valueOf(getTextValue(el,"guid"));
177 event.id_status=Integer.valueOf(getTextValue(el,"alarm"));
178 98
179 md.lsteventagkstate.add(event);
180 99
181 } catch(Exception e) {
182 log.error(e.getMessage());
183 } 100 }
184 } 101 br.close();
185 }
186 }
187
188 urlConnection.disconnect(); 102 urlConnection.disconnect();
189 103
104 SData.INSTANCE.setIsConnect(true);
105
190 } catch (Exception e) { 106 } catch (Exception e) {
107
191 log.error(e.getMessage()); 108 log.error(e.getMessage());
192 log.error(MsgSzs.connectServerError); 109 log.error(MsgSzs.connectServerError);
193 110
194 gprs.Reconnect(); 111 SData.INSTANCE.setIsConnect(false);
195 112
196 } finally { 113 } finally {
197 114
...@@ -205,65 +122,51 @@ public class WebPost { ...@@ -205,65 +122,51 @@ public class WebPost {
205 } 122 }
206 123
207 } catch (Exception ex) { 124 } catch (Exception ex) {
125
208 log.error(ex.getMessage()); 126 log.error(ex.getMessage());
209 log.error(MsgSzs.connectServerError); 127 log.error(MsgSzs.connectServerError);
210 128
211 gprs.Reconnect(); 129 SData.INSTANCE.setIsConnect(false);
130
212 } 131 }
213 } 132 }
214 133
215
216
217
218
219
220
221 return md; 134 return md;
222 135
223 } 136 }
224 137
225 138
226 139 public void Confirm(MdlEvent event) {
227
228
229
230 private String getTextValue(Element ele, String tagName) {
231 String textVal = null;
232 NodeList nl = ele.getElementsByTagName(tagName);
233 if(nl != null && nl.getLength() > 0) {
234 Element el = (Element)nl.item(0);
235 textVal = el.getFirstChild().getNodeValue();
236 }
237
238 return textVal;
239 }
240
241
242
243
244 public void Confirm(long alarm) {
245 140
246 141
247 HttpURLConnection urlConnection = null; 142 HttpURLConnection urlConnection = null;
248 try { 143 try {
249 144
250 145
251 URL url = new URL("http://"+ip+"/api/lss_confirm.php"+"?guid="+guid+"&alarm="+alarm);
252
253 urlConnection = (HttpURLConnection) url
254 .openConnection();
255 146
147 URL url = new URL("http://"+this.ip+"/api/ConfirmLevelsRivers/");
256 148
149 urlConnection = (HttpURLConnection) url.openConnection();
257 urlConnection.setDoOutput(true); 150 urlConnection.setDoOutput(true);
258 urlConnection.setRequestMethod("GET"); 151 urlConnection.setRequestMethod("POST");
259 urlConnection.setRequestProperty("Content-Type", 152 urlConnection.setRequestProperty("Content-Type",
260 "application/json"); 153 "application/json");
261 154
262
263 urlConnection.setConnectTimeout(5000); 155 urlConnection.setConnectTimeout(5000);
264 urlConnection.setReadTimeout(10000); 156 urlConnection.setReadTimeout(10000);
265 157
266 urlConnection.connect(); 158
159 // Create JSONObject here
160 JSONObject jsonParam = new JSONObject();
161
162 jsonParam.put("RegKey",this.guid);
163 jsonParam.put("id_agk", event.getIdAgk());
164 jsonParam.put("id_webapi_message", event.getId());
165
166 OutputStreamWriter out = new OutputStreamWriter(
167 urlConnection.getOutputStream());
168 out.write(jsonParam.toString());
169 out.close();
267 170
268 int HttpResult = urlConnection.getResponseCode(); 171 int HttpResult = urlConnection.getResponseCode();
269 172
...@@ -271,6 +174,7 @@ public class WebPost { ...@@ -271,6 +174,7 @@ public class WebPost {
271 174
272 } 175 }
273 176
177
274 urlConnection.disconnect(); 178 urlConnection.disconnect();
275 } catch (Exception e) { 179 } catch (Exception e) {
276 180
...@@ -282,7 +186,9 @@ public class WebPost { ...@@ -282,7 +186,9 @@ public class WebPost {
282 if (urlConnection != null) { 186 if (urlConnection != null) {
283 urlConnection.disconnect(); 187 urlConnection.disconnect();
284 } 188 }
189
285 } catch (Exception ex) { 190 } catch (Exception ex) {
191
286 log.error(ex.getMessage()); 192 log.error(ex.getMessage());
287 log.error(MsgSzs.connectServerError); 193 log.error(MsgSzs.connectServerError);
288 194
...@@ -294,3 +200,11 @@ public class WebPost { ...@@ -294,3 +200,11 @@ public class WebPost {
294 200
295 201
296 } 202 }
203
204
205
206
207
208
209
210
......
1 package org.emercit.szs.service;
2
3
4 import java.io.File;
5 import java.io.FileInputStream;
6 import java.io.FileNotFoundException;
7 import java.io.FileOutputStream;
8 import java.io.IOException;
9 import java.io.InputStream;
10 import java.io.ObjectInputStream;
11 import java.io.ObjectOutputStream;
12
13 import org.apache.log4j.Logger;
14
15 import com.jcraft.jsch.Channel;
16 import com.jcraft.jsch.ChannelExec;
17 import com.jcraft.jsch.JSch;
18 import com.jcraft.jsch.Session;
19 import org.emercit.szs.model.MsgSzs;
20
21
22 import java.io.*;
23
24 public class Gprs {
25
26 static final Logger logger = Logger.getLogger(Gprs.class);
27
28 private static final int BUFFER_SIZE = 10000;
29
30 private String host="127.0.0.1";
31 private String user="debian";
32 private String password="temppwd";
33
34 private String operator;
35
36 public Gprs(String operator){
37
38 this.operator=operator;
39 }
40
41
42 public void Reconnect() {
43
44 try {
45
46 logger.info(MsgSzs.downPpp);
47 OffLine();
48 Thread.sleep(3000);
49 logger.info(MsgSzs.offGsm);
50 OffGsm();
51 Thread.sleep(3000);
52 logger.info(MsgSzs.onGms);
53 PowerGsm();
54 Thread.sleep(60000);
55 logger.info(MsgSzs.upPpp);
56 OnLine();
57 Thread.sleep(30000);
58
59 }catch(Exception e) {
60
61 logger.error(e.getMessage());
62 }
63
64 }
65
66
67 /*
68 * Подключение к интернету
69 */
70 private void OnLine() {
71 ExecCmd("pon "+this.operator);
72 }
73 /*
74 * Отключение от интернета
75 */
76 private void OffLine() {
77 ExecCmd("poff "+this.operator);
78 }
79
80
81 /*
82 * Включение Gsm терминала
83 */
84 private void PowerGsm() {
85 ExecCmd("echo 1 > /dev/gsm-modem-ctl");
86 }
87
88 /*
89 * Выключение GSM
90 */
91 private void OffGsm() {
92 ExecCmd("echo 0 > /dev/gsm-modem-ctl");
93 }
94
95 private void ExcCmd(String value) {
96 ExecCmd(value);
97 }
98
99 private void ExecCmd(String cmd) {
100
101 try{
102
103 java.util.Properties config = new java.util.Properties();
104 config.put("StrictHostKeyChecking", "no");
105 JSch jsch = new JSch();
106 Session session=jsch.getSession(user, host, 22);
107 session.setPassword(password);
108 session.setConfig(config);
109 session.connect();
110
111 Channel channel=session.openChannel("exec");
112
113 ((ChannelExec)channel).setCommand("sudo -S -p '' "+cmd);
114
115 InputStream in=channel.getInputStream();
116 OutputStream out=channel.getOutputStream();
117 ((ChannelExec)channel).setErrStream(System.err);
118
119 channel.connect();
120
121 out.write((password+"\n").getBytes());
122 out.flush();
123
124
125 byte[] tmp=new byte[1024];
126 while(true){
127 while(in.available()>0){
128 int i=in.read(tmp, 0, 1024);
129 if(i<0)break;
130 System.out.print(new String(tmp, 0, i));
131 }
132 if(channel.isClosed()){
133
134 break;
135 }
136 try{Thread.sleep(1000);}catch(Exception ee){}
137 }
138 channel.disconnect();
139 session.disconnect();
140
141 }catch(Exception e){
142 logger.error(e.getMessage());
143 }
144 }
145 }
...@@ -45,14 +45,10 @@ public enum SData { ...@@ -45,14 +45,10 @@ public enum SData {
45 */ 45 */
46 46
47 public void Confirm(MdlEvent mdlevent) { 47 public void Confirm(MdlEvent mdlevent) {
48 48 webpost.Confirm(mdlevent);
49 webpost.Confirm(mdlevent.getId());
50
51 this.IsOpenDialog=false; 49 this.IsOpenDialog=false;
52
53 } 50 }
54 51
55
56 /* 52 /*
57 * Связь с сервисом 53 * Связь с сервисом
58 */ 54 */
......
...@@ -60,6 +60,9 @@ import java.net.InetSocketAddress; ...@@ -60,6 +60,9 @@ import java.net.InetSocketAddress;
60 import java.net.Proxy; 60 import java.net.Proxy;
61 import java.net.URL; 61 import java.net.URL;
62 import java.util.Scanner; 62 import java.util.Scanner;
63
64 import org.emercit.szs.components.*;
65
63 import java.awt.Dialog.ModalExclusionType; 66 import java.awt.Dialog.ModalExclusionType;
64 import java.awt.*; 67 import java.awt.*;
65 import java.awt.event.*; 68 import java.awt.event.*;
...@@ -70,36 +73,33 @@ import com.google.gson.Gson; ...@@ -70,36 +73,33 @@ import com.google.gson.Gson;
70 73
71 import java.beans.*; 74 import java.beans.*;
72 75
73 import org.emercit.szs.components.*;
74 import org.emercit.szs.model.*; 76 import org.emercit.szs.model.*;
75 import org.emercit.szs.service.*; 77 import org.emercit.szs.service.*;
76 import org.emercit.utilstools.devinfo.service.DevInfo;
77 import org.apache.log4j.Logger; 78 import org.apache.log4j.Logger;
78 import org.apache.log4j.BasicConfigurator; 79 import org.apache.log4j.BasicConfigurator;
79 import org.apache.log4j.PropertyConfigurator; 80 import org.apache.log4j.PropertyConfigurator;
80 import org.emercit.szs.model.Config;
81 81
82 public class SZSTerminal { 82 public class SZSTerminal {
83 83
84 private static final Logger log = Logger.getLogger(SZSTerminal.class); 84 public static final String version="1.0.0.0";
85
86 private static String version="1.0.0.0";
87
88
89 85
90 private static JFrame mainFrame; 86 private static JFrame mainFrame;
91 private static JPanel mainPanel; 87 private static JPanel mainPanel;
88 public static JPnlHeader jpnlheader;
89
92 90
93 public static JPnlCurrent pnlcurrent; 91 public static JPnlCurrent pnlcurrent = new JPnlCurrent();
94 public static JPnlLog jpnllog; 92 public static JPnlLog jpnllog = new JPnlLog();
95 public static JPnlContacts jpnlcontacts; 93 public static JPnlContacts jpnlcontacts = new JPnlContacts();
96 public static JPnlControl jpnlcontrol; 94 public static JPnlControl jpnlcontrol = new JPnlControl();
95
96 public static SirenJNI siren = new SirenJNI();
97 97
98 private static Timer ftdTimerMain = new Timer(); 98 private static Timer ftdTimerMain = new Timer();
99 99
100 public static DlgConfirm dlgconfirm; 100 public static DlgConfirm dlgconfirm = new DlgConfirm();
101
101 102
102 public static JPnlHeader jpnlheader = new JPnlHeader();
103 103
104 private static class ftdTimerTask extends TimerTask { 104 private static class ftdTimerTask extends TimerTask {
105 105
...@@ -110,6 +110,8 @@ public class SZSTerminal { ...@@ -110,6 +110,8 @@ public class SZSTerminal {
110 // @Override 110 // @Override
111 public void run() { 111 public void run() {
112 112
113
114
113 Calendar calendar = Calendar.getInstance(); 115 Calendar calendar = Calendar.getInstance();
114 116
115 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Moscow")); 117 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Moscow"));
...@@ -119,8 +121,10 @@ public class SZSTerminal { ...@@ -119,8 +121,10 @@ public class SZSTerminal {
119 Date date=calendar.getTime(); 121 Date date=calendar.getTime();
120 jpnlheader.UpdateTime(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date())); 122 jpnlheader.UpdateTime(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date()));
121 123
124
122 if (SData.INSTANCE.isConnect()){ 125 if (SData.INSTANCE.isConnect()){
123 126
127
124 /* 128 /*
125 * Текущее состояние датчиков 129 * Текущее состояние датчиков
126 */ 130 */
...@@ -132,21 +136,31 @@ public class SZSTerminal { ...@@ -132,21 +136,31 @@ public class SZSTerminal {
132 List<MdlEvent> lstEvent = new ArrayList<MdlEvent>(); 136 List<MdlEvent> lstEvent = new ArrayList<MdlEvent>();
133 137
134 ModelResponse mdl=SData.INSTANCE.getData(); 138 ModelResponse mdl=SData.INSTANCE.getData();
135 if(mdl.lsteventagkstate.size()!=0) { 139 for (EventAgk eventagk : mdl.lsteventagkstate) {
140
141 MdlEvent ev = new MdlEvent(eventagk.id,
142 eventagk.id_agk,
143 eventagk.river,
144 eventagk.datetime,
145 eventagk.value,
146 eventagk.id_status,
147 eventagk.repair,
148 eventagk.opendoor,
149 eventagk.veracity);
136 150
137 for (EventAgk event:mdl.lsteventagkstate) {
138 MdlEvent ev = new MdlEvent(event.id_agk,event.name,event.id_status);
139 lstEvent.add(ev); 151 lstEvent.add(ev);
140 } 152 }
141 153
142 pnlcurrent.setListEventCurrent(lstEvent); 154 pnlcurrent.setListEventCurrent(lstEvent);
143 155
144 }
145
146 return null; 156 return null;
157
147 } 158 }
159
148 }.execute(); 160 }.execute();
149 161
162
163
150 /* 164 /*
151 * События для подтверждения 165 * События для подтверждения
152 */ 166 */
...@@ -165,25 +179,24 @@ public class SZSTerminal { ...@@ -165,25 +179,24 @@ public class SZSTerminal {
165 179
166 SData.INSTANCE.RemoveEvent(); 180 SData.INSTANCE.RemoveEvent();
167 181
168 MdlEvent ev = new MdlEvent(eventagk.id, 182 MdlEvent ev = new MdlEvent(eventagk.id, eventagk.id_agk,
169 eventagk.name, 183 eventagk.river, eventagk.datetime, eventagk.value,
170 eventagk.id_agk, 184 eventagk.id_status, eventagk.repair, eventagk.opendoor,
171 eventagk.datetime, 185 eventagk.veracity);
172 eventagk.id_status,
173 eventagk.message
174 );
175 186
176 ev.setSiren(true); 187 ev.setSiren(mdl.siren);
177 ev.setCountAnimate(15);
178 ev.setCountSound(2);
179 188
180 189
181 dlgconfirm.setEvent(ev); 190 dlgconfirm.setEvent(ev);
182 191
183 dlgconfirm.setVisible(true); 192 dlgconfirm.setVisible(true);
184 193
194
195
185 } 196 }
197
186 return null; 198 return null;
199
187 } 200 }
188 201
189 }.execute(); 202 }.execute();
...@@ -197,72 +210,81 @@ public class SZSTerminal { ...@@ -197,72 +210,81 @@ public class SZSTerminal {
197 210
198 public static void main(String[] args) { 211 public static void main(String[] args) {
199 212
213
214
215
216 PropertyConfigurator.configure("log4j.properties");
217
218
219
220
221
222
200 EventQueue.invokeLater(new Runnable() { 223 EventQueue.invokeLater(new Runnable() {
201 public void run() { 224 public void run() {
225 try {
226 // siren.sirenOff();
202 227
228 } catch (Exception e) {
229
230 }
203 231
204 232
205 233
206 mainFrame = new JFrame(); 234 mainFrame = new JFrame();
207 mainFrame.setSize(800, 500); 235 mainFrame.setSize(800, 600);
208 mainFrame.setUndecorated(true); 236 mainFrame.setUndecorated(false);
209 mainFrame.setResizable(false); 237 mainFrame.setResizable(false);
210 mainFrame.setVisible(true); 238 mainFrame.setVisible(true);
211 mainPanel = new JPanel(); 239 mainPanel = new JPanel();
212
213 Toolkit tk = Toolkit.getDefaultToolkit(); 240 Toolkit tk = Toolkit.getDefaultToolkit();
214
215 int xSize = ((int) tk.getScreenSize().getWidth()); 241 int xSize = ((int) tk.getScreenSize().getWidth());
216 int ySize = ((int) tk.getScreenSize().getHeight()); 242 int ySize = ((int) tk.getScreenSize().getHeight());
243 // mainFrame.setSize(xSize,ySize);
217 244
218 //mainFrame.setSize(xSize,ySize); 245 mainPanel.setBackground(UIManager
219 mainPanel.setBackground(UIManager.getColor("Separator.foreground")); 246 .getColor("Separator.foreground"));
220 mainPanel.setBounds(0, 0, xSize, ySize);
221 247
248 mainPanel.setBounds(0, 0, xSize, ySize);
222 249
223 jpnlheader.setBounds(10, 5, 780, 40); 250 jpnlheader = new JPnlHeader();
251 jpnlheader.setBounds(10, 10, 770, 50);
224 jpnlheader.setBackground(new Color(168, 181, 224)); 252 jpnlheader.setBackground(new Color(168, 181, 224));
225 mainPanel.add(jpnlheader); 253 mainPanel.add(jpnlheader);
226 254
227 // pnlcurrent.setBounds(10, 70, 770, 470); 255 // pnlcurrent.setBounds(10, 70, 770, 470);
228 List<Event> lstevent = new ArrayList<Event>(); 256 List<Event> lstevent = new ArrayList<Event>();
229 257
258
259
230 JTabbedPane jtp = new JTabbedPane(); 260 JTabbedPane jtp = new JTabbedPane();
231 jtp.setFont(new Font("Tahoma", Font.PLAIN, 14)); 261 jtp.setFont(new Font("Tahoma", Font.PLAIN, 14));
232 mainPanel.add(jtp); 262 mainPanel.add(jtp);
233 jtp.setBounds(10, 50, 780, 450); 263 jtp.setBounds(10, 70, 780, 520);
234 264
235 ImageIcon imgJournal = new ImageIcon(getClass().getResource( 265 ImageIcon imgJournal = new ImageIcon(getClass().getResource(
236 "/journal.png")); 266 "/journal.png"));
237 ImageIcon imgCurrent = new ImageIcon(getClass().getResource( 267 ImageIcon imgCurrent = new ImageIcon(getClass().getResource(
238 "/current.png")); 268 "/current.png"));
239 // ImageIcon imgContact = new ImageIcon(getClass().getResource( 269 ImageIcon imgContact = new ImageIcon(getClass().getResource(
240 // "/contacts.png")); 270 "/contacts.png"));
241 //ImageIcon imgControl = new ImageIcon(getClass().getResource( 271 ImageIcon imgControl = new ImageIcon(getClass().getResource(
242 // "/update.png")); 272 "/update.png"));
243 273
244 pnlcurrent = new JPnlCurrent();
245 jtp.addTab("Текущее состояние", imgCurrent, pnlcurrent); 274 jtp.addTab("Текущее состояние", imgCurrent, pnlcurrent);
246
247 jpnllog = new JPnlLog();
248 jtp.addTab("Журнал", imgJournal, jpnllog); 275 jtp.addTab("Журнал", imgJournal, jpnllog);
249 276 jtp.addTab("Контакты", imgContact, jpnlcontacts);
250 jpnlcontrol = new JPnlControl(); 277 jtp.addTab("Управление", imgControl, jpnlcontrol);
251 jtp.addTab("Управление", null, jpnlcontrol);
252 278
253 mainFrame.setAlwaysOnTop(true); 279 mainFrame.setAlwaysOnTop(true);
254 280
255 dlgconfirm=new DlgConfirm();
256
257 mainPanel.setBackground(UIManager 281 mainPanel.setBackground(UIManager
258 .getColor("Separator.foreground")); 282 .getColor("Separator.foreground"));
259 283 jpnlheader.SetBlue();
260 284
261 mainPanel.setLayout(null); 285 mainPanel.setLayout(null);
262 mainFrame.getContentPane().add(mainPanel); 286 mainFrame.getContentPane().add(mainPanel);
263 287
264 log.info("Запуск приложения CtrlPnl."+ " Версия:"+version);
265 log.info(Config.devinfobean.getDescription());
266 288
267 Runnable rTScan = new TScan(); 289 Runnable rTScan = new TScan();
268 290
...@@ -271,12 +293,6 @@ public class SZSTerminal { ...@@ -271,12 +293,6 @@ public class SZSTerminal {
271 293
272 ftdTimerMain.schedule(new ftdTimerTask(), 0, 1000); 294 ftdTimerMain.schedule(new ftdTimerTask(), 0, 1000);
273 295
274 EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table
275 .getModel();
276
277 SZSTerminal.jpnllog.Upd();
278
279
280 } 296 }
281 }); 297 });
282 } 298 }
......