save
Showing
106 changed files
with
4485 additions
and
0 deletions
SZSTerminal/target/classes/Alarm.wav
0 → 100644
No preview for this file type
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 2 | <modelVersion>4.0.0</modelVersion> | ||
| 3 | <groupId>SZSTerminal</groupId> | ||
| 4 | <artifactId>SZSTerminal</artifactId> | ||
| 5 | <version>0.0.1-SNAPSHOT</version> | ||
| 6 | |||
| 7 | |||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | <dependencies> | ||
| 12 | |||
| 13 | |||
| 14 | <dependency> | ||
| 15 | <groupId>junit</groupId> | ||
| 16 | <artifactId>junit</artifactId> | ||
| 17 | <version>3.8.1</version> | ||
| 18 | <scope>test</scope> | ||
| 19 | </dependency> | ||
| 20 | |||
| 21 | <dependency> | ||
| 22 | <groupId>com.google.code.gson</groupId> | ||
| 23 | <artifactId>gson</artifactId> | ||
| 24 | <version>2.3</version> | ||
| 25 | </dependency> | ||
| 26 | |||
| 27 | <dependency> | ||
| 28 | <groupId>com.googlecode.json-simple</groupId> | ||
| 29 | <artifactId>json-simple</artifactId> | ||
| 30 | <version>1.1.1</version> | ||
| 31 | </dependency> | ||
| 32 | |||
| 33 | |||
| 34 | <dependency> | ||
| 35 | <groupId>javax.inject</groupId> | ||
| 36 | <artifactId>javax.inject</artifactId> | ||
| 37 | <version>1</version> | ||
| 38 | </dependency> | ||
| 39 | |||
| 40 | |||
| 41 | <dependency> | ||
| 42 | <groupId>log4j</groupId> | ||
| 43 | <artifactId>log4j</artifactId> | ||
| 44 | <version>1.2.17</version> | ||
| 45 | </dependency> | ||
| 46 | |||
| 47 | </dependencies> | ||
| 48 | |||
| 49 | <pluginRepositories> | ||
| 50 | <pluginRepository> | ||
| 51 | <id>onejar-maven-plugin.googlecode.com</id> | ||
| 52 | <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url> | ||
| 53 | </pluginRepository> | ||
| 54 | </pluginRepositories> | ||
| 55 | |||
| 56 | |||
| 57 | </project> | ||
| 58 | |||
| 59 | |||
| 60 |
SZSTerminal/target/classes/bottom.png
0 → 100644
3.02 KB
SZSTerminal/target/classes/circle.png
0 → 100644
1.32 KB
SZSTerminal/target/classes/clock.png
0 → 100644
2.32 KB
SZSTerminal/target/classes/closedoor.png
0 → 100644
18.3 KB
2.16 KB
SZSTerminal/target/classes/contacts.png
0 → 100644
745 Bytes
SZSTerminal/target/classes/current.png
0 → 100644
1.59 KB
SZSTerminal/target/classes/desktop.ini
0 → 100644
| 1 | [LocalizedFileNames] | ||
| 2 | notify.wav=@%windir%\system32\mmres.dll,-706 | ||
| 3 | Windows Minimize.wav=@%windir%\system32\mmres.dll,-726 | ||
| 4 | Windows Startup.wav=@%windir%\system32\mmres.dll,-735 | ||
| 5 | Windows Notify.wav=@%windir%\system32\mmres.dll,-727 | ||
| 6 | Windows Pop-up Blocked.wav=@%windir%\system32\mmres.dll,-737 | ||
| 7 | tada.wav=@%windir%\system32\mmres.dll,-710 |
1.9 KB
SZSTerminal/target/classes/good.png
0 → 100644
813 Bytes
SZSTerminal/target/classes/green.png
0 → 100644
4.69 KB
SZSTerminal/target/classes/journal.png
0 → 100644
1.99 KB
SZSTerminal/target/classes/notification.png
0 → 100644
4.67 KB
SZSTerminal/target/classes/opendoor.png
0 → 100644
2.96 KB
SZSTerminal/target/classes/red.png
0 → 100644
2.93 KB
SZSTerminal/target/classes/repair.png
0 → 100644
1.03 KB
SZSTerminal/target/classes/river.png
0 → 100644
15.3 KB
SZSTerminal/target/classes/top.png
0 → 100644
3.31 KB
SZSTerminal/target/classes/update.png
0 → 100644
1.3 KB
SZSTerminal/target/classes/veracityfalse.png
0 → 100644
3.82 KB
SZSTerminal/target/classes/veracitytrue.png
0 → 100644
4.59 KB
SZSTerminal/target/classes/yellow.png
0 → 100644
2.11 KB
SzsBb/.classpath
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <classpath> | ||
| 3 | <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
| 4 | <attributes> | ||
| 5 | <attribute name="optional" value="true"/> | ||
| 6 | <attribute name="maven.pomderived" value="true"/> | ||
| 7 | </attributes> | ||
| 8 | </classpathentry> | ||
| 9 | <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| 10 | <attributes> | ||
| 11 | <attribute name="optional" value="true"/> | ||
| 12 | <attribute name="maven.pomderived" value="true"/> | ||
| 13 | </attributes> | ||
| 14 | </classpathentry> | ||
| 15 | <classpathentry including="**/*.java" kind="src" path="src/main/resources"/> | ||
| 16 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
| 17 | <attributes> | ||
| 18 | <attribute name="maven.pomderived" value="true"/> | ||
| 19 | </attributes> | ||
| 20 | </classpathentry> | ||
| 21 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
| 22 | <attributes> | ||
| 23 | <attribute name="maven.pomderived" value="true"/> | ||
| 24 | </attributes> | ||
| 25 | </classpathentry> | ||
| 26 | <classpathentry kind="output" path="target/classes"/> | ||
| 27 | </classpath> |
SzsBb/.gitignore
0 → 100644
| 1 | /target |
SzsBb/.project
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <projectDescription> | ||
| 3 | <name>SzsBb</name> | ||
| 4 | <comment></comment> | ||
| 5 | <projects> | ||
| 6 | </projects> | ||
| 7 | <buildSpec> | ||
| 8 | <buildCommand> | ||
| 9 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
| 10 | <arguments> | ||
| 11 | </arguments> | ||
| 12 | </buildCommand> | ||
| 13 | <buildCommand> | ||
| 14 | <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| 15 | <arguments> | ||
| 16 | </arguments> | ||
| 17 | </buildCommand> | ||
| 18 | </buildSpec> | ||
| 19 | <natures> | ||
| 20 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
| 21 | <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| 22 | </natures> | ||
| 23 | </projectDescription> |
SzsBb/.settings/org.eclipse.jdt.core.prefs
0 → 100644
SzsBb/.settings/org.eclipse.m2e.core.prefs
0 → 100644
SzsBb/pom.xml
0 → 100755
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 2 | <modelVersion>4.0.0</modelVersion> | ||
| 3 | <groupId>Szs</groupId> | ||
| 4 | <artifactId>Szs</artifactId> | ||
| 5 | <version>0.0.1-SNAPSHOT</version> | ||
| 6 | |||
| 7 | <build> | ||
| 8 | <plugins> | ||
| 9 | <plugin> | ||
| 10 | <groupId>org.apache.maven.plugins</groupId> | ||
| 11 | <artifactId>maven-compiler-plugin</artifactId> | ||
| 12 | <configuration> | ||
| 13 | <source>1.7</source> | ||
| 14 | <target>1.7</target> | ||
| 15 | <showDeprecation>true</showDeprecation> | ||
| 16 | <showWarnings>true</showWarnings> | ||
| 17 | <executable>${env.JAVA_HOME_7}/bin/javac</executable> | ||
| 18 | <fork>true</fork> | ||
| 19 | </configuration> | ||
| 20 | </plugin> | ||
| 21 | </plugins> | ||
| 22 | </build> | ||
| 23 | |||
| 24 | <dependencies> | ||
| 25 | |||
| 26 | <dependency> | ||
| 27 | <groupId>junit</groupId> | ||
| 28 | <artifactId>junit</artifactId> | ||
| 29 | <version>3.8.1</version> | ||
| 30 | <scope>test</scope> | ||
| 31 | </dependency> | ||
| 32 | |||
| 33 | <dependency> | ||
| 34 | <groupId>com.google.code.gson</groupId> | ||
| 35 | <artifactId>gson</artifactId> | ||
| 36 | <version>2.3</version> | ||
| 37 | </dependency> | ||
| 38 | |||
| 39 | <dependency> | ||
| 40 | <groupId>com.googlecode.json-simple</groupId> | ||
| 41 | <artifactId>json-simple</artifactId> | ||
| 42 | <version>1.1.1</version> | ||
| 43 | </dependency> | ||
| 44 | |||
| 45 | |||
| 46 | <dependency> | ||
| 47 | <groupId>javax.inject</groupId> | ||
| 48 | <artifactId>javax.inject</artifactId> | ||
| 49 | <version>1</version> | ||
| 50 | </dependency> | ||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | <dependency> | ||
| 55 | <groupId>com.jcraft</groupId> | ||
| 56 | <artifactId>jsch</artifactId> | ||
| 57 | <version>0.1.51</version> | ||
| 58 | </dependency> | ||
| 59 | |||
| 60 | |||
| 61 | <dependency> | ||
| 62 | <groupId>log4j</groupId> | ||
| 63 | <artifactId>log4j</artifactId> | ||
| 64 | <version>1.2.17</version> | ||
| 65 | </dependency> | ||
| 66 | |||
| 67 | <dependency> | ||
| 68 | <groupId>org.emercit</groupId> | ||
| 69 | <artifactId>utilstools</artifactId> | ||
| 70 | <version>1.50</version> | ||
| 71 | </dependency> | ||
| 72 | |||
| 73 | |||
| 74 | </dependencies> | ||
| 75 | |||
| 76 | <pluginRepositories> | ||
| 77 | <pluginRepository> | ||
| 78 | <id>onejar-maven-plugin.googlecode.com</id> | ||
| 79 | <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url> | ||
| 80 | </pluginRepository> | ||
| 81 | </pluginRepositories> | ||
| 82 | |||
| 83 | |||
| 84 | <repositories> | ||
| 85 | <repository> | ||
| 86 | <id>project.local</id> | ||
| 87 | <name>project</name> | ||
| 88 | <url>file:/root/git/hardwareconfig/DevTools/repo</url> | ||
| 89 | </repository> | ||
| 90 | </repositories> | ||
| 91 | |||
| 92 | |||
| 93 | </project> | ||
| 94 | |||
| 95 | |||
| 96 |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.BorderLayout; | ||
| 4 | import java.awt.FlowLayout; | ||
| 5 | import java.awt.GraphicsEnvironment; | ||
| 6 | import java.awt.Image; | ||
| 7 | |||
| 8 | import javax.swing.JButton; | ||
| 9 | import javax.swing.JDialog; | ||
| 10 | import javax.swing.JPanel; | ||
| 11 | import javax.swing.SwingUtilities; | ||
| 12 | import javax.swing.border.EmptyBorder; | ||
| 13 | import javax.swing.border.LineBorder; | ||
| 14 | |||
| 15 | import java.awt.event.ActionListener; | ||
| 16 | import java.awt.event.ActionEvent; | ||
| 17 | |||
| 18 | import javax.swing.SwingConstants; | ||
| 19 | |||
| 20 | import java.awt.event.KeyEvent; | ||
| 21 | import java.awt.Dimension; | ||
| 22 | import java.awt.GridLayout; | ||
| 23 | |||
| 24 | import javax.swing.JLabel; | ||
| 25 | |||
| 26 | import java.awt.ComponentOrientation; | ||
| 27 | import java.awt.Font; | ||
| 28 | |||
| 29 | import javax.swing.UIManager; | ||
| 30 | |||
| 31 | import java.awt.Color; | ||
| 32 | import java.awt.EventQueue; | ||
| 33 | import java.awt.SystemColor; | ||
| 34 | import java.text.DateFormat; | ||
| 35 | import java.text.SimpleDateFormat; | ||
| 36 | import java.util.Calendar; | ||
| 37 | import java.util.Date; | ||
| 38 | import java.util.Timer; | ||
| 39 | import java.util.TimerTask; | ||
| 40 | |||
| 41 | import javax.swing.ImageIcon; | ||
| 42 | import javax.swing.SwingWorker; | ||
| 43 | |||
| 44 | import java.util.ArrayList; | ||
| 45 | import java.io.File; | ||
| 46 | |||
| 47 | import javax.xml.parsers.DocumentBuilder; | ||
| 48 | import javax.xml.parsers.DocumentBuilderFactory; | ||
| 49 | |||
| 50 | import org.w3c.dom.Document; | ||
| 51 | import org.w3c.dom.Element; | ||
| 52 | import org.w3c.dom.Node; | ||
| 53 | import org.w3c.dom.NodeList; | ||
| 54 | |||
| 55 | import com.google.gson.Gson; | ||
| 56 | |||
| 57 | import java.io.BufferedReader; | ||
| 58 | import java.io.InputStreamReader; | ||
| 59 | import java.io.OutputStream; | ||
| 60 | import java.io.OutputStreamWriter; | ||
| 61 | import java.net.HttpURLConnection; | ||
| 62 | import java.net.InetSocketAddress; | ||
| 63 | import java.net.Proxy; | ||
| 64 | import java.net.URL; | ||
| 65 | import java.util.Timer; | ||
| 66 | import java.util.TimerTask; | ||
| 67 | |||
| 68 | import org.emercit.szs.model.*; | ||
| 69 | import org.emercit.szs.service.SData; | ||
| 70 | import org.emercit.szs.szsterminal.SZSTerminal; | ||
| 71 | |||
| 72 | import org.emercit.szs.controldevtools.bean.NotificationBB; | ||
| 73 | |||
| 74 | public class DlgConfirm extends JDialog { | ||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | private Timer timer = new Timer(); | ||
| 79 | |||
| 80 | boolean animate = false; | ||
| 81 | |||
| 82 | private NotificationBB notification=new NotificationBB(); | ||
| 83 | |||
| 84 | private final JPanel contentPanel = new JPanel(); | ||
| 85 | |||
| 86 | JLabel lblTitleAgk = new JLabel(); | ||
| 87 | JLabel lblTitleStatus = new JLabel(); | ||
| 88 | JLabel lblTitleTime = new JLabel(); | ||
| 89 | JLabel lblTitleRiver = new JLabel(); | ||
| 90 | JLabel lblTitleRepair = new JLabel(); | ||
| 91 | JLabel lblTitleOpenDoor = new JLabel(); | ||
| 92 | JLabel lblTitleVeracity = new JLabel(); | ||
| 93 | |||
| 94 | ImageIcon IconNotification = new ImageIcon(getClass().getResource( | ||
| 95 | "/notification.png")); | ||
| 96 | JLabel lblIcon = new JLabel(); | ||
| 97 | |||
| 98 | JButton okButton = new JButton("ПОДТВЕРЖДЕНИЕ"); | ||
| 99 | |||
| 100 | public MdlEvent ev; | ||
| 101 | |||
| 102 | private void setVisibleFalse() { | ||
| 103 | this.setVisible(false); | ||
| 104 | } | ||
| 105 | |||
| 106 | |||
| 107 | private class AnimateTask extends TimerTask { | ||
| 108 | |||
| 109 | @Override | ||
| 110 | public void run() { | ||
| 111 | EventQueue.invokeLater(new Runnable() { | ||
| 112 | |||
| 113 | //@Override | ||
| 114 | public void run() { | ||
| 115 | |||
| 116 | if (ev != null) { | ||
| 117 | |||
| 118 | if (animate) { | ||
| 119 | contentPanel | ||
| 120 | .setBackground(new Color(102, 102, 255)); | ||
| 121 | animate = false; | ||
| 122 | } else { | ||
| 123 | animate = true; | ||
| 124 | contentPanel | ||
| 125 | .setBackground(new Color(204, 102, 102)); | ||
| 126 | } | ||
| 127 | |||
| 128 | int countanimate = ev.getCoundAnimate(); | ||
| 129 | if (countanimate > 0) { | ||
| 130 | ev.setCountAnimate(countanimate - 1); | ||
| 131 | } else { | ||
| 132 | notification.playSiren(); | ||
| 133 | } | ||
| 134 | |||
| 135 | } | ||
| 136 | |||
| 137 | } | ||
| 138 | }); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | public void setEvent(MdlEvent event) { | ||
| 143 | |||
| 144 | SData.INSTANCE.setIsOpenDialog(true); | ||
| 145 | this.ev = event; | ||
| 146 | |||
| 147 | |||
| 148 | lblTitleAgk.setText(event.getTitleAgk()); | ||
| 149 | lblTitleAgk.setForeground(Color.WHITE); | ||
| 150 | |||
| 151 | lblTitleStatus.setText(event.getTitleStatusForConfirm()); | ||
| 152 | lblTitleStatus.setForeground(Color.WHITE); | ||
| 153 | lblTitleStatus.setIcon(event.getIconStatusLarge()); | ||
| 154 | |||
| 155 | lblTitleTime.setText(event.getDateTime()); | ||
| 156 | lblTitleTime.setIcon(event.getIconDateTime()); | ||
| 157 | lblTitleTime.setForeground(Color.WHITE); | ||
| 158 | |||
| 159 | lblTitleRiver.setText(event.getTitleRiver()); | ||
| 160 | lblTitleRiver.setIcon(event.getIconRiver()); | ||
| 161 | lblTitleRiver.setForeground(Color.WHITE); | ||
| 162 | |||
| 163 | lblTitleRepair.setText(event.getTitleRepair()); | ||
| 164 | lblTitleRepair.setForeground(Color.WHITE); | ||
| 165 | lblTitleRepair.setIcon(event.getIconRepairLarge()); | ||
| 166 | |||
| 167 | lblTitleOpenDoor.setText(event.getTitleOpenDorr()); | ||
| 168 | lblTitleOpenDoor.setForeground(Color.WHITE); | ||
| 169 | lblTitleOpenDoor.setIcon(event.getIconOpenDoorLarge()); | ||
| 170 | |||
| 171 | lblTitleVeracity.setText(event.getTitleVeracity()); | ||
| 172 | lblTitleVeracity.setForeground(Color.WHITE); | ||
| 173 | lblTitleVeracity.setIcon(event.getIconVeracityLarge()); | ||
| 174 | |||
| 175 | |||
| 176 | |||
| 177 | } | ||
| 178 | |||
| 179 | |||
| 180 | |||
| 181 | public DlgConfirm( ) { | ||
| 182 | |||
| 183 | |||
| 184 | |||
| 185 | contentPanel.setLayout(null); | ||
| 186 | contentPanel.setBorder(new LineBorder(new Color(100, 149, 237), 10)); | ||
| 187 | |||
| 188 | this.setUndecorated(true); | ||
| 189 | this.setForeground(UIManager.getColor("activeCaption")); | ||
| 190 | this.setBackground(Color.BLUE); | ||
| 191 | this.setLayout(null); | ||
| 192 | this.setSize(500, 370); | ||
| 193 | |||
| 194 | this.setLocationRelativeTo(null); // CENTER | ||
| 195 | |||
| 196 | this.setAlwaysOnTop(true); | ||
| 197 | this.setModal(true); | ||
| 198 | |||
| 199 | lblTitleAgk.setFont(new Font(null, Font.BOLD, 18)); | ||
| 200 | lblTitleStatus.setFont(new Font(null, Font.BOLD, 18)); | ||
| 201 | lblTitleTime.setFont(new Font(null, Font.BOLD, 18)); | ||
| 202 | lblTitleRiver.setFont(new Font(null, Font.BOLD, 18)); | ||
| 203 | |||
| 204 | lblTitleRepair.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 205 | lblTitleVeracity.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 206 | lblTitleOpenDoor.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 207 | |||
| 208 | contentPanel.setForeground(Color.BLUE); | ||
| 209 | |||
| 210 | this.setBackground(Color.BLUE); | ||
| 211 | |||
| 212 | lblTitleAgk.setBounds(15, 15, 300, 35); | ||
| 213 | contentPanel.add(lblTitleAgk); | ||
| 214 | |||
| 215 | lblTitleStatus.setBounds(15, 50, 450, 35); | ||
| 216 | contentPanel.add(lblTitleStatus); | ||
| 217 | |||
| 218 | lblTitleRiver.setBounds(15, 85, 345, 35); | ||
| 219 | contentPanel.add(lblTitleRiver); | ||
| 220 | |||
| 221 | lblTitleTime.setBounds(15, 120, 300, 35); | ||
| 222 | contentPanel.add(lblTitleTime); | ||
| 223 | |||
| 224 | lblTitleRepair.setBounds(15, 155, 300, 35); | ||
| 225 | contentPanel.add(lblTitleRepair); | ||
| 226 | |||
| 227 | lblTitleVeracity.setBounds(15, 190, 300, 35); | ||
| 228 | contentPanel.add(lblTitleVeracity); | ||
| 229 | |||
| 230 | lblTitleOpenDoor.setBounds(15, 225, 300, 35); | ||
| 231 | contentPanel.add(lblTitleOpenDoor); | ||
| 232 | |||
| 233 | lblIcon.setBounds(350, 100, 124, 124); | ||
| 234 | Image img = IconNotification.getImage(); | ||
| 235 | Image newimg = img.getScaledInstance(124, 124, | ||
| 236 | java.awt.Image.SCALE_SMOOTH); | ||
| 237 | IconNotification = new ImageIcon(newimg); | ||
| 238 | lblIcon.setIcon(IconNotification); | ||
| 239 | contentPanel.add(lblIcon); | ||
| 240 | |||
| 241 | contentPanel.setBounds(5, 5, 490, 280); | ||
| 242 | add(contentPanel); | ||
| 243 | |||
| 244 | okButton.setBorder(new LineBorder(new Color(100, 149, 237), 7)); | ||
| 245 | okButton.setFont(new Font("Tahoma", Font.PLAIN, 24)); | ||
| 246 | okButton.setPreferredSize(new Dimension(320, 80)); | ||
| 247 | okButton.setMinimumSize(new Dimension(220, 80)); | ||
| 248 | okButton.setMaximumSize(new Dimension(220, 80)); | ||
| 249 | okButton.setMnemonic(KeyEvent.VK_COMPOSE); | ||
| 250 | okButton.addActionListener(new ActionListener() { | ||
| 251 | public void actionPerformed(ActionEvent arg0) { | ||
| 252 | |||
| 253 | SwingUtilities.invokeLater(new Runnable() { | ||
| 254 | public void run() { | ||
| 255 | |||
| 256 | MdlEvent buff = ev; | ||
| 257 | ev = null; | ||
| 258 | |||
| 259 | notification.stopSiren(); | ||
| 260 | |||
| 261 | EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table | ||
| 262 | .getModel(); | ||
| 263 | model.AddRow(buff); | ||
| 264 | SZSTerminal.jpnllog.Upd(); | ||
| 265 | SZSTerminal.jpnllog.table.updateUI(); | ||
| 266 | |||
| 267 | setVisibleFalse(); | ||
| 268 | |||
| 269 | SData.INSTANCE.Confirm(buff); | ||
| 270 | } | ||
| 271 | |||
| 272 | }); | ||
| 273 | |||
| 274 | } | ||
| 275 | }); | ||
| 276 | |||
| 277 | okButton.setBounds(5, 290, 488, 75); | ||
| 278 | |||
| 279 | add(okButton); | ||
| 280 | |||
| 281 | timer.schedule(new AnimateTask(), 0, 1000); | ||
| 282 | |||
| 283 | } | ||
| 284 | |||
| 285 | } | ||
| 286 | |||
| 287 | |||
| 288 | |||
| 289 | |||
| 290 | |||
| 291 | |||
| 292 | |||
| 293 | |||
| 294 | |||
| 295 | |||
| 296 | |||
| 297 | |||
| 298 | |||
| 299 | |||
| 300 | |||
| 301 |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | import javax.swing.*; | ||
| 11 | |||
| 12 | public class DrawPanel extends JComponent implements Runnable { | ||
| 13 | |||
| 14 | private long t = System.nanoTime(); | ||
| 15 | |||
| 16 | public DrawPanel() { | ||
| 17 | super(); | ||
| 18 | new Thread(this).start(); | ||
| 19 | } | ||
| 20 | |||
| 21 | //@Override | ||
| 22 | public void run() { | ||
| 23 | while (true) { | ||
| 24 | repaint(); | ||
| 25 | try { | ||
| 26 | Thread.sleep(5); | ||
| 27 | } catch (InterruptedException ex) { | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | @Override | ||
| 33 | protected void paintComponent(Graphics g) { | ||
| 34 | super.paintComponent(g); | ||
| 35 | Graphics2D g2d = (Graphics2D) g; | ||
| 36 | |||
| 37 | long tm = System.nanoTime() - t; | ||
| 38 | double angle = tm / 300000000.0; | ||
| 39 | |||
| 40 | double sn = Math.sin(Math.sin(angle) * 0.5); | ||
| 41 | double cs = Math.cos(Math.sin(angle) * 0.5); | ||
| 42 | int x = (int) (250 * sn + 150); | ||
| 43 | int y = (int) (250 * cs); | ||
| 44 | g2d.drawLine(150, 0, x, y); | ||
| 45 | g2d.drawOval(x - 20, y - 20, 40, 40); | ||
| 46 | } | ||
| 47 | } |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | |||
| 10 | import javax.swing.JComponent; | ||
| 11 | import javax.swing.JLabel; | ||
| 12 | import javax.swing.JPanel; | ||
| 13 | |||
| 14 | public class ExtPnlAgk extends JPanel { | ||
| 15 | |||
| 16 | protected int _strokeSize = 1; | ||
| 17 | protected Color _shadowColor = Color.BLACK; | ||
| 18 | protected boolean _shadowed = true; | ||
| 19 | protected boolean _highQuality = true; | ||
| 20 | protected Dimension _arcs = new Dimension(15, 15); | ||
| 21 | protected int _shadowGap = 5; | ||
| 22 | protected int _shadowOffset = 4; | ||
| 23 | protected int _shadowAlpha = 150; | ||
| 24 | |||
| 25 | public Color _backgroundColor = Color.lightGray; | ||
| 26 | |||
| 27 | public ExtPnlAgk() { | ||
| 28 | super(); | ||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | /* | ||
| 33 | * @Override public void setBackground(Color c) { _backgroundColor = c; } | ||
| 34 | */ | ||
| 35 | |||
| 36 | public void setGreen() { | ||
| 37 | _backgroundColor = new Color(51, 204, 102); | ||
| 38 | } | ||
| 39 | |||
| 40 | public void setYellow() { | ||
| 41 | _backgroundColor = new Color(255, 255, 102); | ||
| 42 | } | ||
| 43 | |||
| 44 | public void setRed() { | ||
| 45 | _backgroundColor = new Color(255, 51, 102); | ||
| 46 | } | ||
| 47 | |||
| 48 | @Override | ||
| 49 | protected void paintComponent(Graphics g) { | ||
| 50 | super.paintComponent(g); | ||
| 51 | |||
| 52 | int width = getWidth(); | ||
| 53 | int height = getHeight(); | ||
| 54 | |||
| 55 | int shadowGap = this._shadowGap; | ||
| 56 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 57 | _shadowColor.getGreen(), _shadowColor.getGreen(), _shadowAlpha); | ||
| 58 | Graphics2D graphics = (Graphics2D) g; | ||
| 59 | |||
| 60 | if (_highQuality) { | ||
| 61 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 62 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 63 | } | ||
| 64 | |||
| 65 | if (_shadowed) { | ||
| 66 | graphics.setColor(shadowColorA); | ||
| 67 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 68 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 69 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 70 | } else { | ||
| 71 | _shadowGap = 1; | ||
| 72 | } | ||
| 73 | |||
| 74 | graphics.setColor(_backgroundColor); | ||
| 75 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 76 | _arcs.width, _arcs.height); | ||
| 77 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 78 | graphics.setColor(getForeground()); | ||
| 79 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 80 | _arcs.width, _arcs.height); | ||
| 81 | graphics.setStroke(new BasicStroke()); | ||
| 82 | |||
| 83 | } | ||
| 84 | } |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | |||
| 11 | public class ExtPnlInfo extends JPanel { | ||
| 12 | protected int _strokeSize = 1; | ||
| 13 | protected Color _shadowColor = Color.BLACK; | ||
| 14 | protected boolean _shadowed = true; | ||
| 15 | protected boolean _highQuality = true; | ||
| 16 | protected Dimension _arcs = new Dimension(7, 7); | ||
| 17 | protected int _shadowGap = 3; | ||
| 18 | protected int _shadowOffset = 1; | ||
| 19 | protected int _shadowAlpha = 75; | ||
| 20 | |||
| 21 | public ExtPnlInfo() { | ||
| 22 | super(); | ||
| 23 | setOpaque(false); | ||
| 24 | } | ||
| 25 | |||
| 26 | @Override | ||
| 27 | protected void paintComponent(Graphics g) { | ||
| 28 | super.paintComponent(g); | ||
| 29 | |||
| 30 | int width = getWidth(); | ||
| 31 | int height = getHeight(); | ||
| 32 | int shadowGap = this._shadowGap; | ||
| 33 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 34 | _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha); | ||
| 35 | Graphics2D graphics = (Graphics2D) g; | ||
| 36 | |||
| 37 | if (_highQuality) { | ||
| 38 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 39 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 40 | } | ||
| 41 | |||
| 42 | if (_shadowed) { | ||
| 43 | graphics.setColor(shadowColorA); | ||
| 44 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 45 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 46 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 47 | } else { | ||
| 48 | _shadowGap = 1; | ||
| 49 | } | ||
| 50 | |||
| 51 | graphics.setColor(Color.WHITE); | ||
| 52 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 53 | _arcs.width, _arcs.height); | ||
| 54 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 55 | graphics.setColor(getForeground()); | ||
| 56 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 57 | _arcs.width, _arcs.height); | ||
| 58 | graphics.setStroke(new BasicStroke()); | ||
| 59 | } | ||
| 60 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.ImageIcon; | ||
| 6 | import javax.swing.JLabel; | ||
| 7 | import javax.swing.JPanel; | ||
| 8 | |||
| 9 | import java.awt.Image; | ||
| 10 | import java.awt.Font; | ||
| 11 | |||
| 12 | import org.emercit.szs.model.*; | ||
| 13 | |||
| 14 | import javax.swing.UIManager; | ||
| 15 | |||
| 16 | public class JPnlAgk extends ExtPnlAgk { | ||
| 17 | |||
| 18 | private class JPnlInfoExt extends ExtPnlInfo { | ||
| 19 | |||
| 20 | } | ||
| 21 | |||
| 22 | private int id; | ||
| 23 | private JLabel lblTitleAgk = new JLabel(); | ||
| 24 | private JLabel lblTitleRiver = new JLabel(); | ||
| 25 | private JLabel lblTitleStatus = new JLabel(); | ||
| 26 | private JLabel lblTitleOpenDoor = new JLabel(); | ||
| 27 | private JLabel lblTitleRepair = new JLabel(); | ||
| 28 | private JLabel lblTitleVeracity = new JLabel(); | ||
| 29 | |||
| 30 | private JPnlInfoExt JPnlInfo = new JPnlInfoExt(); | ||
| 31 | |||
| 32 | public JPnlAgk(MdlEvent event) { | ||
| 33 | |||
| 34 | setLayout(null); | ||
| 35 | |||
| 36 | lblTitleAgk.setBounds(7, 47, 70, 15); | ||
| 37 | lblTitleAgk.setText(event.getTitleAgk()); | ||
| 38 | // lblTitleAgk.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 39 | lblTitleAgk.setFont(new Font(null, Font.BOLD, 14)); | ||
| 40 | lblTitleAgk.setForeground(Color.BLACK); | ||
| 41 | |||
| 42 | add(lblTitleAgk); | ||
| 43 | |||
| 44 | JPnlInfo.setLayout(null); | ||
| 45 | JPnlInfo.setBounds(83, 7, 142, 88); | ||
| 46 | |||
| 47 | // River | ||
| 48 | |||
| 49 | lblTitleRiver.setText(event.getTitleRiver()); | ||
| 50 | lblTitleRiver.setForeground(Color.BLACK); | ||
| 51 | |||
| 52 | if (event.getIdStatus() != 0) { | ||
| 53 | |||
| 54 | this.setYellow(); | ||
| 55 | if (event.getIdStatus() == 2) | ||
| 56 | this.setRed(); | ||
| 57 | |||
| 58 | lblTitleRiver.setFont(new Font(null, Font.ITALIC, 12)); | ||
| 59 | lblTitleRiver.setBounds(3, 3, 138, 15); | ||
| 60 | JPnlInfo.add(lblTitleRiver); | ||
| 61 | |||
| 62 | /* | ||
| 63 | * ***************************STATUS*************************** | ||
| 64 | */ | ||
| 65 | lblTitleStatus.setBounds(3, 18, 138, 15); | ||
| 66 | lblTitleStatus.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 67 | |||
| 68 | lblTitleStatus.setText("cтатус:" + event.getTitleStatus()); | ||
| 69 | lblTitleStatus.setForeground(event.getColorStatus()); | ||
| 70 | lblTitleStatus.setIcon(event.getIconStatusSmall()); | ||
| 71 | |||
| 72 | JPnlInfo.add(lblTitleStatus); | ||
| 73 | |||
| 74 | // ********************************************************************************** | ||
| 75 | /* | ||
| 76 | * *****************************DOOR******************************** | ||
| 77 | */ | ||
| 78 | lblTitleOpenDoor.setBounds(3, 34, 138, 15); | ||
| 79 | lblTitleOpenDoor.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 80 | |||
| 81 | lblTitleOpenDoor.setText(event.getTitleOpenDorr()); | ||
| 82 | lblTitleOpenDoor.setForeground(event.getColorOpenDoor()); | ||
| 83 | lblTitleOpenDoor.setIcon(event.getIconOpenDoorSmall()); | ||
| 84 | JPnlInfo.add(lblTitleOpenDoor); | ||
| 85 | // *************************************************************************** | ||
| 86 | |||
| 87 | /* | ||
| 88 | * *****************************REPAIR******************************* | ||
| 89 | * * | ||
| 90 | */ | ||
| 91 | |||
| 92 | lblTitleRepair.setBounds(3, 50, 138, 15); | ||
| 93 | lblTitleRepair.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 94 | |||
| 95 | lblTitleRepair.setText(event.getTitleRepair()); | ||
| 96 | lblTitleRepair.setForeground(event.getColorRepair()); | ||
| 97 | lblTitleRepair.setIcon(event.getIconRepairSmall()); | ||
| 98 | JPnlInfo.add(lblTitleRepair); | ||
| 99 | |||
| 100 | // *************************************************************************** | ||
| 101 | |||
| 102 | /* | ||
| 103 | * ******************************VERACITY**************************** | ||
| 104 | * ********* | ||
| 105 | */ | ||
| 106 | |||
| 107 | lblTitleVeracity.setBounds(3, 66, 138, 15); | ||
| 108 | lblTitleVeracity.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 109 | |||
| 110 | lblTitleVeracity.setText(event.getTitleVeracity()); | ||
| 111 | lblTitleVeracity.setForeground(event.getColorVeracity()); | ||
| 112 | lblTitleVeracity.setIcon(event.getIconVeracitySmall()); | ||
| 113 | JPnlInfo.add(lblTitleVeracity); | ||
| 114 | |||
| 115 | // **************************************************************************** | ||
| 116 | |||
| 117 | add(JPnlInfo); | ||
| 118 | } else { | ||
| 119 | |||
| 120 | this.setGreen(); | ||
| 121 | lblTitleRiver.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 122 | lblTitleRiver.setBounds(83, 47, 138, 15); | ||
| 123 | JPnlInfo.add(lblTitleRiver); | ||
| 124 | add(lblTitleRiver); | ||
| 125 | } | ||
| 126 | |||
| 127 | } | ||
| 128 | |||
| 129 | } |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | import javax.swing.JTextPane; | ||
| 8 | import javax.swing.JScrollPane; | ||
| 9 | |||
| 10 | import java.awt.BasicStroke; | ||
| 11 | import java.awt.BorderLayout; | ||
| 12 | import java.awt.Dimension; | ||
| 13 | import java.awt.EventQueue; | ||
| 14 | import java.awt.FlowLayout; | ||
| 15 | import java.awt.Graphics; | ||
| 16 | import java.awt.Graphics2D; | ||
| 17 | import java.awt.GridLayout; | ||
| 18 | import java.awt.Font; | ||
| 19 | import java.awt.RenderingHints; | ||
| 20 | import java.util.Random; | ||
| 21 | import java.util.TimerTask; | ||
| 22 | import java.io.*; | ||
| 23 | import java.util.*; | ||
| 24 | import java.awt.Toolkit; | ||
| 25 | import java.net.URL; | ||
| 26 | import java.nio.*; | ||
| 27 | import java.net.*; | ||
| 28 | |||
| 29 | import javax.swing.SwingWorker; | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | public class JPnlContacts extends RoundedPanel3 { | ||
| 34 | |||
| 35 | private JTextPane pane = new JTextPane(); | ||
| 36 | |||
| 37 | public JPnlContacts() { | ||
| 38 | |||
| 39 | this.setLayout(null); | ||
| 40 | |||
| 41 | pane.setFont(new Font(null, Font.ITALIC, 22)); | ||
| 42 | // lblContact.setText(SZSTerminal.configmain.getPhone()); | ||
| 43 | pane.setText(""); | ||
| 44 | // pane.setBounds(10, 5, 750, 440); | ||
| 45 | |||
| 46 | JScrollPane sp = new JScrollPane(pane); | ||
| 47 | sp.setBounds(10, 5, 750, 440); | ||
| 48 | |||
| 49 | this.add(sp); | ||
| 50 | |||
| 51 | // setBackground(new Color(168, 181, 224)); // blue | ||
| 52 | |||
| 53 | } | ||
| 54 | |||
| 55 | public void setTitleContact(String title) { | ||
| 56 | try { | ||
| 57 | pane.setEditable(false); | ||
| 58 | |||
| 59 | pane.setText(title); | ||
| 60 | |||
| 61 | } | ||
| 62 | catch(Exception e) { | ||
| 63 | |||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JFrame; | ||
| 6 | import javax.swing.JLabel; | ||
| 7 | import javax.swing.JButton; | ||
| 8 | import javax.swing.JTextPane; | ||
| 9 | import javax.swing.JScrollPane; | ||
| 10 | |||
| 11 | import java.awt.BasicStroke; | ||
| 12 | import java.awt.BorderLayout; | ||
| 13 | import java.awt.Dimension; | ||
| 14 | import java.awt.EventQueue; | ||
| 15 | import java.awt.FlowLayout; | ||
| 16 | import java.awt.Graphics; | ||
| 17 | import java.awt.Graphics2D; | ||
| 18 | import java.awt.GridLayout; | ||
| 19 | import java.awt.Font; | ||
| 20 | import java.awt.RenderingHints; | ||
| 21 | import java.util.Enumeration; | ||
| 22 | import java.util.Random; | ||
| 23 | import java.util.TimerTask; | ||
| 24 | import java.io.*; | ||
| 25 | import java.util.*; | ||
| 26 | import java.awt.Toolkit; | ||
| 27 | import java.awt.event.ActionEvent; | ||
| 28 | import java.awt.event.ActionListener; | ||
| 29 | import java.net.URL; | ||
| 30 | import java.nio.*; | ||
| 31 | import java.net.*; | ||
| 32 | import java.net.*; | ||
| 33 | import java.io.*; | ||
| 34 | import java.util.StringTokenizer; | ||
| 35 | |||
| 36 | import javax.swing.SwingWorker; | ||
| 37 | |||
| 38 | import org.emercit.szs.controldevtools.bean.ControlDeviceBean; | ||
| 39 | import org.emercit.szs.controldevtools.bean.DevToolsBean; | ||
| 40 | import org.emercit.szs.controldevtools.bean.CheckNotification; | ||
| 41 | import org.emercit.szs.service.SData; | ||
| 42 | import org.emercit.szs.szsterminal.SZSTerminal; | ||
| 43 | |||
| 44 | |||
| 45 | public class JPnlControl extends RoundedPanel3 { | ||
| 46 | |||
| 47 | private DevToolsBean pnlDevTools=new DevToolsBean(); | ||
| 48 | |||
| 49 | private ControlDeviceBean pnlControlDevice=new ControlDeviceBean(); | ||
| 50 | |||
| 51 | private CheckNotification checkNotification=new CheckNotification(); | ||
| 52 | |||
| 53 | |||
| 54 | public JPnlControl() { | ||
| 55 | |||
| 56 | this.setLayout(null); | ||
| 57 | |||
| 58 | pnlDevTools.setBounds(10, 20, 660, 150); | ||
| 59 | this.add(pnlDevTools); | ||
| 60 | |||
| 61 | pnlControlDevice.setBounds(10, 190, 450, 150); | ||
| 62 | this.add(pnlControlDevice); | ||
| 63 | |||
| 64 | checkNotification.setBounds(470,190,200,150); | ||
| 65 | this.add(checkNotification); | ||
| 66 | |||
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | |||
| 8 | import java.awt.BasicStroke; | ||
| 9 | import java.awt.BorderLayout; | ||
| 10 | import java.awt.Dimension; | ||
| 11 | import java.awt.EventQueue; | ||
| 12 | import java.awt.FlowLayout; | ||
| 13 | import java.awt.Graphics; | ||
| 14 | import java.awt.Graphics2D; | ||
| 15 | import java.awt.GridLayout; | ||
| 16 | import java.awt.Font; | ||
| 17 | import java.awt.RenderingHints; | ||
| 18 | import java.util.Random; | ||
| 19 | import java.util.TimerTask; | ||
| 20 | import java.io.*; | ||
| 21 | |||
| 22 | import javax.swing.BorderFactory; | ||
| 23 | import javax.swing.Icon; | ||
| 24 | import javax.swing.ImageIcon; | ||
| 25 | import javax.swing.JFrame; | ||
| 26 | import javax.swing.JPanel; | ||
| 27 | import javax.swing.SwingUtilities; | ||
| 28 | import javax.swing.UIManager; | ||
| 29 | import javax.swing.border.Border; | ||
| 30 | |||
| 31 | import java.util.Comparator; | ||
| 32 | |||
| 33 | import org.emercit.szs.model.*; | ||
| 34 | |||
| 35 | import java.awt.event.ActionListener; | ||
| 36 | import java.awt.event.ActionEvent; | ||
| 37 | import java.util.*; | ||
| 38 | import java.awt.Toolkit; | ||
| 39 | import java.net.URL; | ||
| 40 | import java.nio.*; | ||
| 41 | import java.net.*; | ||
| 42 | import java.awt.EventQueue; | ||
| 43 | |||
| 44 | import javax.swing.SwingWorker; | ||
| 45 | |||
| 46 | import java.awt.GridBagLayout; | ||
| 47 | import java.awt.GridBagConstraints; | ||
| 48 | import java.awt.Insets; | ||
| 49 | import java.util.*; | ||
| 50 | |||
| 51 | public class JPnlCurrent extends RoundedPanel3 { | ||
| 52 | |||
| 53 | public class EventComparator1 implements Comparator<MdlEvent> { | ||
| 54 | |||
| 55 | // @Override | ||
| 56 | public int compare(MdlEvent a, MdlEvent b) { | ||
| 57 | |||
| 58 | return Integer.valueOf(a.getIdStatus()).compareTo( | ||
| 59 | Integer.valueOf(b.getIdStatus())); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | private JButton btnDown = new JButton(); | ||
| 64 | private JButton btnUp = new JButton(); | ||
| 65 | private JPanel panel = new JPanel(); | ||
| 66 | |||
| 67 | private int start = 0; | ||
| 68 | private int end = 6; | ||
| 69 | |||
| 70 | private List<MdlEvent> lstevent; | ||
| 71 | |||
| 72 | private EventComparator1 eventComparator1=new EventComparator1(); | ||
| 73 | |||
| 74 | public void setListEventCurrent(List<MdlEvent> lstevent) { | ||
| 75 | this.lstevent = lstevent; | ||
| 76 | try { | ||
| 77 | Update(); | ||
| 78 | } | ||
| 79 | catch(Exception e) { | ||
| 80 | |||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | private void Update()throws Exception { | ||
| 87 | |||
| 88 | |||
| 89 | Collections.sort(lstevent, eventComparator1); | ||
| 90 | |||
| 91 | panel.removeAll(); | ||
| 92 | |||
| 93 | int x = 0; | ||
| 94 | int y = 10; | ||
| 95 | for (int i = start; i < end; i++) { | ||
| 96 | |||
| 97 | try { | ||
| 98 | |||
| 99 | JPnlAgk agk = new JPnlAgk(lstevent.get(i)); | ||
| 100 | |||
| 101 | agk.setBounds(x, y, 240, 105); | ||
| 102 | panel.add(agk); | ||
| 103 | x += 250; | ||
| 104 | if (x > 500) { | ||
| 105 | x = 0; | ||
| 106 | y += 105; | ||
| 107 | } | ||
| 108 | } | ||
| 109 | catch(Exception e) { | ||
| 110 | |||
| 111 | } | ||
| 112 | |||
| 113 | } | ||
| 114 | |||
| 115 | panel.updateUI(); | ||
| 116 | } | ||
| 117 | |||
| 118 | private void Up() throws Exception { | ||
| 119 | |||
| 120 | if (start - 6 <= 0) { | ||
| 121 | start = 0; | ||
| 122 | end = 6; | ||
| 123 | btnUp.setEnabled(false); | ||
| 124 | } else { | ||
| 125 | end = start; | ||
| 126 | start = start - 6; | ||
| 127 | } | ||
| 128 | |||
| 129 | Update(); | ||
| 130 | } | ||
| 131 | |||
| 132 | private void Down() throws Exception { | ||
| 133 | |||
| 134 | if (end + 6 > lstevent.size()) { | ||
| 135 | start = end; | ||
| 136 | end = lstevent.size(); | ||
| 137 | btnDown.setEnabled(false); | ||
| 138 | |||
| 139 | } else { | ||
| 140 | |||
| 141 | start = end; | ||
| 142 | end += 6; | ||
| 143 | } | ||
| 144 | Update(); | ||
| 145 | } | ||
| 146 | |||
| 147 | public JPnlCurrent() { | ||
| 148 | |||
| 149 | btnUp.setEnabled(false); | ||
| 150 | this.setBackground(new Color(168, 181, 224)); | ||
| 151 | this.setLayout(null); | ||
| 152 | |||
| 153 | panel.setBounds(5, 5, 740, 300); | ||
| 154 | panel.setLayout(null); | ||
| 155 | panel.setBackground(new Color(168, 181, 224)); | ||
| 156 | |||
| 157 | this.add(panel); | ||
| 158 | |||
| 159 | panel.updateUI(); | ||
| 160 | |||
| 161 | ImageIcon imgUp = new ImageIcon(this.getClass().getResource("/top.png")); | ||
| 162 | btnUp.setIcon(imgUp); | ||
| 163 | btnUp.setBounds(5, 320, 370, 70); | ||
| 164 | btnUp.addActionListener(new ActionListener() { | ||
| 165 | public void actionPerformed(ActionEvent arg0) { | ||
| 166 | SwingUtilities.invokeLater(new Runnable() { | ||
| 167 | public void run() { | ||
| 168 | try { | ||
| 169 | btnDown.setEnabled(true); | ||
| 170 | Up(); | ||
| 171 | } | ||
| 172 | catch(Exception e) { | ||
| 173 | |||
| 174 | } | ||
| 175 | } | ||
| 176 | }); | ||
| 177 | } | ||
| 178 | |||
| 179 | }); | ||
| 180 | add(btnUp); | ||
| 181 | |||
| 182 | ImageIcon imgDown = new ImageIcon(this.getClass().getResource("/bottom.png")); | ||
| 183 | btnDown.setIcon(imgDown); | ||
| 184 | btnDown.setBounds(385, 320, 370, 70); | ||
| 185 | btnDown.addActionListener(new ActionListener() { | ||
| 186 | public void actionPerformed(ActionEvent arg0) { | ||
| 187 | |||
| 188 | SwingUtilities.invokeLater(new Runnable() { | ||
| 189 | public void run() { | ||
| 190 | try { | ||
| 191 | btnUp.setEnabled(true); | ||
| 192 | Down(); | ||
| 193 | } | ||
| 194 | catch(Exception e) { | ||
| 195 | |||
| 196 | } | ||
| 197 | } | ||
| 198 | }); | ||
| 199 | } | ||
| 200 | |||
| 201 | }); | ||
| 202 | add(btnDown); | ||
| 203 | |||
| 204 | } | ||
| 205 | |||
| 206 | } |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | |||
| 8 | import java.awt.BorderLayout; | ||
| 9 | import java.awt.Dimension; | ||
| 10 | import java.awt.FlowLayout; | ||
| 11 | import java.awt.GridLayout; | ||
| 12 | import java.awt.Font; | ||
| 13 | |||
| 14 | import javax.swing.BorderFactory; | ||
| 15 | import javax.swing.Icon; | ||
| 16 | import javax.swing.ImageIcon; | ||
| 17 | import javax.swing.JFrame; | ||
| 18 | import javax.swing.JPanel; | ||
| 19 | import javax.swing.UIManager; | ||
| 20 | import javax.swing.border.Border; | ||
| 21 | |||
| 22 | import java.awt.event.ActionEvent; | ||
| 23 | import java.awt.event.ActionListener; | ||
| 24 | |||
| 25 | import org.emercit.szs.model.Config; | ||
| 26 | |||
| 27 | import org.emercit.szs.szsterminal.SZSTerminal; | ||
| 28 | |||
| 29 | import java.net.URL; | ||
| 30 | |||
| 31 | public class JPnlHeader extends RoundedPanel3 { | ||
| 32 | |||
| 33 | private JLabel jlblclock; | ||
| 34 | private JLabel jlbltitle; | ||
| 35 | |||
| 36 | public JPnlHeader() { | ||
| 37 | |||
| 38 | this.setLayout(null); | ||
| 39 | |||
| 40 | |||
| 41 | // время | ||
| 42 | jlblclock = new JLabel(); | ||
| 43 | jlblclock.setBounds(10, 2, 300, 30); | ||
| 44 | jlblclock.setText(""); | ||
| 45 | jlblclock.setFont(new Font(null, Font.ITALIC, 13)); | ||
| 46 | jlblclock.setForeground(Color.YELLOW); | ||
| 47 | |||
| 48 | |||
| 49 | jlblclock.setIcon(new ImageIcon(this.getClass().getResource("/clock.png"))); | ||
| 50 | add(jlblclock); | ||
| 51 | |||
| 52 | // название | ||
| 53 | jlbltitle = new JLabel(); | ||
| 54 | jlbltitle.setBounds(320, 2, 250, 30); | ||
| 55 | jlbltitle.setText(Config.devinfobean.getDescription()); | ||
| 56 | jlbltitle.setFont(new Font(null, Font.ITALIC, 13)); | ||
| 57 | jlbltitle.setForeground(Color.YELLOW); | ||
| 58 | add(jlbltitle); | ||
| 59 | |||
| 60 | // connect | ||
| 61 | // jlblconnect = new JLabel(); | ||
| 62 | // jlblconnect.setBounds(5, 5, 50, 30); | ||
| 63 | // ChangeConnectImg(false); | ||
| 64 | // add(jlblconnect); | ||
| 65 | } | ||
| 66 | |||
| 67 | static class exitApp implements ActionListener { | ||
| 68 | public void actionPerformed(ActionEvent e) { | ||
| 69 | System.exit(0); | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | } | ||
| 74 | |||
| 75 | public void UpdateTime(String val) { | ||
| 76 | jlblclock.setText(val); | ||
| 77 | } | ||
| 78 | |||
| 79 | public void SetBlue() { | ||
| 80 | setBackground(new Color(168, 181, 224)); | ||
| 81 | } | ||
| 82 | |||
| 83 | } |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | |||
| 8 | import java.awt.BasicStroke; | ||
| 9 | import java.awt.BorderLayout; | ||
| 10 | import java.awt.Dimension; | ||
| 11 | import java.awt.EventQueue; | ||
| 12 | import java.awt.FlowLayout; | ||
| 13 | import java.awt.Graphics; | ||
| 14 | import java.awt.Graphics2D; | ||
| 15 | import java.awt.GridLayout; | ||
| 16 | import java.awt.Font; | ||
| 17 | import java.awt.RenderingHints; | ||
| 18 | import java.util.ArrayList; | ||
| 19 | import java.util.Random; | ||
| 20 | import java.util.TimerTask; | ||
| 21 | import java.io.*; | ||
| 22 | import java.awt.Color; | ||
| 23 | |||
| 24 | import javax.swing.JLabel; | ||
| 25 | import javax.swing.JButton; | ||
| 26 | import javax.swing.JTable; | ||
| 27 | |||
| 28 | import java.awt.BasicStroke; | ||
| 29 | import java.awt.BorderLayout; | ||
| 30 | import java.awt.Dimension; | ||
| 31 | import java.awt.EventQueue; | ||
| 32 | import java.awt.FlowLayout; | ||
| 33 | import java.awt.Graphics; | ||
| 34 | import java.awt.Graphics2D; | ||
| 35 | import java.awt.GridLayout; | ||
| 36 | import java.awt.Font; | ||
| 37 | import java.awt.RenderingHints; | ||
| 38 | import java.util.Random; | ||
| 39 | import java.util.TimerTask; | ||
| 40 | import java.io.*; | ||
| 41 | |||
| 42 | import javax.swing.BorderFactory; | ||
| 43 | import javax.swing.Icon; | ||
| 44 | import javax.swing.ImageIcon; | ||
| 45 | import javax.swing.JFrame; | ||
| 46 | import javax.swing.JPanel; | ||
| 47 | import javax.swing.SwingUtilities; | ||
| 48 | import javax.swing.UIManager; | ||
| 49 | import javax.swing.border.Border; | ||
| 50 | |||
| 51 | import java.awt.event.ActionListener; | ||
| 52 | import java.awt.event.ActionEvent; | ||
| 53 | import java.util.*; | ||
| 54 | import java.awt.Toolkit; | ||
| 55 | import java.net.URL; | ||
| 56 | import java.nio.*; | ||
| 57 | import java.net.*; | ||
| 58 | import java.awt.EventQueue; | ||
| 59 | |||
| 60 | import javax.swing.SwingWorker; | ||
| 61 | |||
| 62 | import java.awt.GridBagLayout; | ||
| 63 | import java.awt.GridBagConstraints; | ||
| 64 | import java.awt.Insets; | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | import javax.swing.SwingWorker; | ||
| 71 | import javax.swing.table.TableModel; | ||
| 72 | |||
| 73 | import org.emercit.szs.model.*; | ||
| 74 | import org.emercit.szs.szsterminal.*; | ||
| 75 | |||
| 76 | public class JPnlLog extends RoundedPanel3 { | ||
| 77 | |||
| 78 | private JButton btnDown = new JButton(); | ||
| 79 | private JButton btnUp = new JButton(); | ||
| 80 | |||
| 81 | TableModel model = new EventTableModel(); | ||
| 82 | |||
| 83 | public JButton btnBtndown = new JButton(); | ||
| 84 | public JTable table = new JTable(model); | ||
| 85 | |||
| 86 | private int start = 0; | ||
| 87 | private int end = 7; | ||
| 88 | |||
| 89 | public void Upd() { | ||
| 90 | |||
| 91 | EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table.getModel(); | ||
| 92 | model.Update(start, end); | ||
| 93 | SZSTerminal.jpnllog.table.updateUI(); | ||
| 94 | } | ||
| 95 | |||
| 96 | private void Up() { | ||
| 97 | |||
| 98 | if (start - 7 <= 0) { | ||
| 99 | start = 0; | ||
| 100 | end = 7; | ||
| 101 | btnUp.setEnabled(false); | ||
| 102 | } else { | ||
| 103 | end = start; | ||
| 104 | start = start-7; | ||
| 105 | } | ||
| 106 | Upd(); | ||
| 107 | } | ||
| 108 | |||
| 109 | private void Down() { | ||
| 110 | |||
| 111 | EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table | ||
| 112 | .getModel(); | ||
| 113 | int valsize = model.getSize(); | ||
| 114 | |||
| 115 | if (end + 7 > valsize) { | ||
| 116 | start = end; | ||
| 117 | end = valsize; | ||
| 118 | btnDown.setEnabled(false); | ||
| 119 | } else { | ||
| 120 | start = end; | ||
| 121 | end += 7; | ||
| 122 | } | ||
| 123 | |||
| 124 | Upd(); | ||
| 125 | } | ||
| 126 | |||
| 127 | public JPnlLog() { | ||
| 128 | |||
| 129 | btnUp.setEnabled(false); | ||
| 130 | this.setBackground(new Color(168, 181, 224)); | ||
| 131 | this.setLayout(null); | ||
| 132 | |||
| 133 | table.setBounds(5, 5, 760, 300); | ||
| 134 | table.setDefaultRenderer(MdlEvent.class, new EventCellRenderer()); | ||
| 135 | table.setRowHeight(40); | ||
| 136 | table.setBackground(new Color(168, 181, 224)); | ||
| 137 | |||
| 138 | this.add(table); | ||
| 139 | |||
| 140 | ImageIcon imgUp = new ImageIcon(getClass().getResource("/top.png")); | ||
| 141 | |||
| 142 | btnUp.setIcon(imgUp); | ||
| 143 | |||
| 144 | btnUp.setBounds(5, 320, 370, 70); | ||
| 145 | |||
| 146 | btnUp.addActionListener(new ActionListener() { | ||
| 147 | public void actionPerformed(ActionEvent arg0) { | ||
| 148 | SwingUtilities.invokeLater(new Runnable() { | ||
| 149 | public void run() { | ||
| 150 | btnDown.setEnabled(true); | ||
| 151 | Up(); | ||
| 152 | } | ||
| 153 | }); | ||
| 154 | } | ||
| 155 | |||
| 156 | }); | ||
| 157 | add(btnUp); | ||
| 158 | |||
| 159 | ImageIcon imgDown = new ImageIcon(getClass().getResource("/bottom.png")); | ||
| 160 | btnDown.setIcon(imgDown); | ||
| 161 | btnDown.setBounds(385, 320, 370, 70); | ||
| 162 | btnDown.addActionListener(new ActionListener() { | ||
| 163 | public void actionPerformed(ActionEvent arg0) { | ||
| 164 | |||
| 165 | SwingUtilities.invokeLater(new Runnable() { | ||
| 166 | public void run() { | ||
| 167 | btnUp.setEnabled(true); | ||
| 168 | Down(); | ||
| 169 | } | ||
| 170 | }); | ||
| 171 | } | ||
| 172 | }); | ||
| 173 | |||
| 174 | add(btnDown); | ||
| 175 | } | ||
| 176 | |||
| 177 | } | ||
| 178 | |||
| 179 |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | |||
| 11 | public class RoundedPanel2 extends JPanel { | ||
| 12 | protected int _strokeSize = 1; | ||
| 13 | protected Color _shadowColor = Color.BLACK; | ||
| 14 | protected boolean _shadowed = true; | ||
| 15 | protected boolean _highQuality = true; | ||
| 16 | protected Dimension _arcs = new Dimension(15, 15); | ||
| 17 | protected int _shadowGap = 3; | ||
| 18 | protected int _shadowOffset = 1; | ||
| 19 | protected int _shadowAlpha = 75; | ||
| 20 | |||
| 21 | protected Color _backgroundColor = new Color(168, 181, 224); | ||
| 22 | |||
| 23 | public RoundedPanel2() { | ||
| 24 | super(); | ||
| 25 | setOpaque(false); | ||
| 26 | } | ||
| 27 | |||
| 28 | @Override | ||
| 29 | public void setBackground(Color c) { | ||
| 30 | _backgroundColor = c; | ||
| 31 | } | ||
| 32 | |||
| 33 | @Override | ||
| 34 | protected void paintComponent(Graphics g) { | ||
| 35 | super.paintComponent(g); | ||
| 36 | |||
| 37 | int width = getWidth(); | ||
| 38 | int height = getHeight(); | ||
| 39 | int shadowGap = this._shadowGap; | ||
| 40 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 41 | _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha); | ||
| 42 | Graphics2D graphics = (Graphics2D) g; | ||
| 43 | |||
| 44 | if (_highQuality) { | ||
| 45 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 46 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 47 | } | ||
| 48 | |||
| 49 | if (_shadowed) { | ||
| 50 | graphics.setColor(shadowColorA); | ||
| 51 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 52 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 53 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 54 | } else { | ||
| 55 | _shadowGap = 1; | ||
| 56 | } | ||
| 57 | |||
| 58 | graphics.setColor(_backgroundColor); | ||
| 59 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 60 | _arcs.width, _arcs.height); | ||
| 61 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 62 | graphics.setColor(getForeground()); | ||
| 63 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 64 | _arcs.width, _arcs.height); | ||
| 65 | graphics.setStroke(new BasicStroke()); | ||
| 66 | } | ||
| 67 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szs.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | |||
| 11 | public class RoundedPanel3 extends JPanel { | ||
| 12 | protected int _strokeSize = 1; | ||
| 13 | protected Color _shadowColor = Color.BLACK; | ||
| 14 | protected boolean _shadowed = true; | ||
| 15 | protected boolean _highQuality = true; | ||
| 16 | protected Dimension _arcs = new Dimension(30, 30); | ||
| 17 | protected int _shadowGap = 5; | ||
| 18 | protected int _shadowOffset = 4; | ||
| 19 | protected int _shadowAlpha = 150; | ||
| 20 | |||
| 21 | public Color _backgroundColor = Color.LIGHT_GRAY; | ||
| 22 | |||
| 23 | public RoundedPanel3() { | ||
| 24 | super(); | ||
| 25 | setOpaque(false); | ||
| 26 | } | ||
| 27 | |||
| 28 | @Override | ||
| 29 | public void setBackground(Color c) { | ||
| 30 | _backgroundColor = c; | ||
| 31 | } | ||
| 32 | |||
| 33 | @Override | ||
| 34 | protected void paintComponent(Graphics g) { | ||
| 35 | super.paintComponent(g); | ||
| 36 | |||
| 37 | int width = getWidth(); | ||
| 38 | int height = getHeight(); | ||
| 39 | int shadowGap = this._shadowGap; | ||
| 40 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 41 | _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha); | ||
| 42 | Graphics2D graphics = (Graphics2D) g; | ||
| 43 | |||
| 44 | if (_highQuality) { | ||
| 45 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 46 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 47 | } | ||
| 48 | |||
| 49 | if (_shadowed) { | ||
| 50 | graphics.setColor(shadowColorA); | ||
| 51 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 52 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 53 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 54 | } else { | ||
| 55 | _shadowGap = 1; | ||
| 56 | } | ||
| 57 | |||
| 58 | graphics.setColor(_backgroundColor); | ||
| 59 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 60 | _arcs.width, _arcs.height); | ||
| 61 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 62 | graphics.setColor(getForeground()); | ||
| 63 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 64 | _arcs.width, _arcs.height); | ||
| 65 | graphics.setStroke(new BasicStroke()); | ||
| 66 | } | ||
| 67 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szs.controldevtools.bean; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | import java.awt.Dimension; | ||
| 5 | import java.awt.EventQueue; | ||
| 6 | import java.awt.Font; | ||
| 7 | import java.awt.Graphics; | ||
| 8 | import java.awt.event.ActionEvent; | ||
| 9 | import java.awt.event.ActionListener; | ||
| 10 | import java.beans.PropertyChangeListener; | ||
| 11 | import java.beans.PropertyVetoException; | ||
| 12 | import java.beans.VetoableChangeListener; | ||
| 13 | import java.beans.VetoableChangeSupport; | ||
| 14 | import java.io.Externalizable; | ||
| 15 | import java.io.IOException; | ||
| 16 | import java.io.ObjectInput; | ||
| 17 | import java.io.ObjectOutput; | ||
| 18 | import java.util.Timer; | ||
| 19 | import java.util.TimerTask; | ||
| 20 | |||
| 21 | import javax.swing.ImageIcon; | ||
| 22 | import javax.swing.JButton; | ||
| 23 | import javax.swing.JComponent; | ||
| 24 | import javax.swing.JFrame; | ||
| 25 | import javax.swing.JLabel; | ||
| 26 | import javax.swing.SwingWorker; | ||
| 27 | import javax.swing.event.ChangeEvent; | ||
| 28 | import javax.swing.event.ChangeListener; | ||
| 29 | import javax.swing.event.EventListenerList; | ||
| 30 | import javax.swing.event.SwingPropertyChangeSupport; | ||
| 31 | |||
| 32 | import org.apache.log4j.Logger; | ||
| 33 | import org.emercit.utilstools.config.DefSettings; | ||
| 34 | |||
| 35 | import org.emercit.szs.controldevtools.bean.DevToolsBean; | ||
| 36 | |||
| 37 | import org.emercit.szs.controldevtools.bean.RoundPanel; | ||
| 38 | import org.emercit.utilstools.pckutils.checkservice.STService; | ||
| 39 | import org.emercit.utilstools.service.Settings; | ||
| 40 | import org.emercit.utilstools.svmanager.model.SvBean; | ||
| 41 | import org.emercit.utilstools.svmanager.service.Sv; | ||
| 42 | import org.emercit.utilstools.svmanager.service.SvControl; | ||
| 43 | |||
| 44 | import org.emercit.szs.controldevtools.bean.NotificationBB; | ||
| 45 | |||
| 46 | public class CheckNotification extends RoundPanel implements Externalizable { | ||
| 47 | |||
| 48 | private static final Logger log = Logger.getLogger(CheckNotification.class); | ||
| 49 | |||
| 50 | private NotificationBB notificationbb=new NotificationBB(); | ||
| 51 | |||
| 52 | private Dimension beanDimension; // simple | ||
| 53 | |||
| 54 | protected EventListenerList listenerList = new EventListenerList(); | ||
| 55 | |||
| 56 | private JLabel lblTitle=new JLabel(); | ||
| 57 | private JButton btnSound=new JButton(); | ||
| 58 | private JButton btnSiren=new JButton(); | ||
| 59 | |||
| 60 | private Font font = new Font(null, Font.ITALIC, 13); | ||
| 61 | |||
| 62 | public CheckNotification() { | ||
| 63 | |||
| 64 | this.setLayout(null); | ||
| 65 | this.setBackground(new Color(168, 181, 224)); // blue | ||
| 66 | |||
| 67 | beanDimension = new Dimension(200, 130); | ||
| 68 | |||
| 69 | // TITLE | ||
| 70 | font = new Font(null, Font.ITALIC, 18); | ||
| 71 | lblTitle.setBounds(10,10,200,20); | ||
| 72 | lblTitle.setForeground(Color.YELLOW); | ||
| 73 | lblTitle.setText("Диагностика"); | ||
| 74 | lblTitle.setVisible(true); | ||
| 75 | lblTitle.setFont(font); | ||
| 76 | add(lblTitle); | ||
| 77 | |||
| 78 | |||
| 79 | //SOUND | ||
| 80 | btnSound.setIcon(new ImageIcon(ControlDeviceBean.class.getResource("/sound.png"))); | ||
| 81 | btnSound.setBounds(10,30,170,40); | ||
| 82 | btnSound.setFont(font); | ||
| 83 | btnSound.setText("Динамик"); | ||
| 84 | btnSound.setSelected(false); | ||
| 85 | btnSound.addActionListener(new checkSound()); | ||
| 86 | add(btnSound); | ||
| 87 | |||
| 88 | //SIREN | ||
| 89 | btnSiren.setIcon(new ImageIcon(ControlDeviceBean.class.getResource("/siren.png"))); | ||
| 90 | btnSiren.setBounds(10,80,170,40); | ||
| 91 | btnSiren.setFont(font); | ||
| 92 | btnSiren.setText("Сирена"); | ||
| 93 | btnSiren.setSelected(false); | ||
| 94 | btnSiren.addActionListener(new checkSiren()); | ||
| 95 | add(btnSiren); | ||
| 96 | |||
| 97 | } | ||
| 98 | |||
| 99 | public class checkSound implements ActionListener | ||
| 100 | { | ||
| 101 | public void actionPerformed(ActionEvent e) | ||
| 102 | { | ||
| 103 | new SwingWorker<Void, Void>() | ||
| 104 | { | ||
| 105 | protected Void doInBackground() throws Exception | ||
| 106 | { | ||
| 107 | btnSound.setEnabled(false); | ||
| 108 | notificationbb.playSound(); | ||
| 109 | btnSound.setEnabled(true); | ||
| 110 | return null; | ||
| 111 | } | ||
| 112 | }.execute(); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | public class checkSiren implements ActionListener | ||
| 117 | { | ||
| 118 | public void actionPerformed(ActionEvent e) | ||
| 119 | { | ||
| 120 | |||
| 121 | new SwingWorker<Void, Void>() | ||
| 122 | { | ||
| 123 | protected Void doInBackground() throws Exception | ||
| 124 | { | ||
| 125 | btnSiren.setEnabled(false); | ||
| 126 | notificationbb.playSiren(); | ||
| 127 | Thread.sleep(5000); | ||
| 128 | notificationbb.stopSiren(); | ||
| 129 | btnSiren.setEnabled(true); | ||
| 130 | |||
| 131 | return null; | ||
| 132 | } | ||
| 133 | |||
| 134 | }.execute(); | ||
| 135 | |||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | |||
| 140 | public void paintComponent(Graphics g) { | ||
| 141 | super.paintComponent(g); | ||
| 142 | } | ||
| 143 | |||
| 144 | public void setPreferredSize(Dimension dim) { | ||
| 145 | beanDimension = dim; | ||
| 146 | } | ||
| 147 | |||
| 148 | public Dimension getPreferredSize() { | ||
| 149 | return beanDimension; | ||
| 150 | } | ||
| 151 | |||
| 152 | public void setMinimumSize(Dimension dim) { | ||
| 153 | beanDimension = dim; | ||
| 154 | } | ||
| 155 | |||
| 156 | public Dimension getMinimumSize() { | ||
| 157 | return beanDimension; | ||
| 158 | } | ||
| 159 | |||
| 160 | public void addChangeListener(ChangeListener l) { | ||
| 161 | listenerList.add(ChangeListener.class, l); | ||
| 162 | } | ||
| 163 | |||
| 164 | public void removeChangeListener(ChangeListener l) { | ||
| 165 | listenerList.remove(ChangeListener.class, l); | ||
| 166 | } | ||
| 167 | |||
| 168 | public void writeExternal(ObjectOutput out) throws IOException { | ||
| 169 | out.writeObject(beanDimension); | ||
| 170 | } | ||
| 171 | |||
| 172 | public void readExternal(ObjectInput in) throws IOException, | ||
| 173 | ClassNotFoundException { | ||
| 174 | setPreferredSize((Dimension) in.readObject()); | ||
| 175 | setMinimumSize(getPreferredSize()); | ||
| 176 | } | ||
| 177 | |||
| 178 | } |
| 1 | package org.emercit.szs.controldevtools.bean; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | import java.awt.Dimension; | ||
| 5 | import java.awt.EventQueue; | ||
| 6 | import java.awt.Font; | ||
| 7 | import java.awt.Graphics; | ||
| 8 | import java.awt.event.ActionEvent; | ||
| 9 | import java.awt.event.ActionListener; | ||
| 10 | import java.beans.PropertyChangeListener; | ||
| 11 | import java.beans.PropertyVetoException; | ||
| 12 | import java.beans.VetoableChangeListener; | ||
| 13 | import java.beans.VetoableChangeSupport; | ||
| 14 | import java.io.Externalizable; | ||
| 15 | import java.io.IOException; | ||
| 16 | import java.io.ObjectInput; | ||
| 17 | import java.io.ObjectOutput; | ||
| 18 | import java.util.Timer; | ||
| 19 | import java.util.TimerTask; | ||
| 20 | |||
| 21 | import javax.swing.ImageIcon; | ||
| 22 | import javax.swing.JButton; | ||
| 23 | import javax.swing.JComponent; | ||
| 24 | import javax.swing.JFrame; | ||
| 25 | import javax.swing.JLabel; | ||
| 26 | import javax.swing.SwingWorker; | ||
| 27 | import javax.swing.event.ChangeEvent; | ||
| 28 | import javax.swing.event.ChangeListener; | ||
| 29 | import javax.swing.event.EventListenerList; | ||
| 30 | import javax.swing.event.SwingPropertyChangeSupport; | ||
| 31 | |||
| 32 | import org.apache.log4j.Logger; | ||
| 33 | import org.emercit.utilstools.config.DefSettings; | ||
| 34 | |||
| 35 | import org.emercit.szs.controldevtools.bean.DevToolsBean; | ||
| 36 | |||
| 37 | import org.emercit.szs.controldevtools.bean.RoundPanel; | ||
| 38 | import org.emercit.utilstools.pckutils.checkservice.STService; | ||
| 39 | import org.emercit.utilstools.service.Settings; | ||
| 40 | import org.emercit.utilstools.svmanager.model.SvBean; | ||
| 41 | import org.emercit.utilstools.svmanager.service.Sv; | ||
| 42 | import org.emercit.utilstools.svmanager.service.SvControl; | ||
| 43 | import org.emercit.utilstools.sshexec.SSHExec; | ||
| 44 | |||
| 45 | public class ControlDeviceBean extends RoundPanel implements Externalizable { | ||
| 46 | |||
| 47 | private static final Logger log = Logger.getLogger(DevToolsBean.class); | ||
| 48 | |||
| 49 | private Dimension beanDimension; // simple | ||
| 50 | |||
| 51 | protected EventListenerList listenerList = new EventListenerList(); | ||
| 52 | |||
| 53 | private JLabel lblStatus=new JLabel(); | ||
| 54 | private JButton btnOffStart=new JButton(); | ||
| 55 | private JButton btnRebootStart=new JButton(); | ||
| 56 | |||
| 57 | private SSHExec sshecex=new SSHExec(); | ||
| 58 | |||
| 59 | private Font font = new Font(null, Font.ITALIC, 13); | ||
| 60 | |||
| 61 | public ControlDeviceBean() { | ||
| 62 | |||
| 63 | this.setLayout(null); | ||
| 64 | this.setBackground(new Color(168, 181, 224)); // blue | ||
| 65 | |||
| 66 | beanDimension = new Dimension(600, 130); | ||
| 67 | |||
| 68 | // BUTTON OFF | ||
| 69 | btnOffStart.setIcon(new ImageIcon(ControlDeviceBean.class.getResource("/offDevice.png"))); | ||
| 70 | btnOffStart.setBounds(10,30,190,55); | ||
| 71 | btnOffStart.setFont(font); | ||
| 72 | btnOffStart.setText("Выключить"); | ||
| 73 | btnOffStart.setSelected(false); | ||
| 74 | btnOffStart.addActionListener(new Off()); | ||
| 75 | add(btnOffStart); | ||
| 76 | |||
| 77 | // BUTTON REBOOT | ||
| 78 | btnRebootStart.setIcon(new ImageIcon(ControlDeviceBean.class.getResource("/reloadDevice.png"))); | ||
| 79 | btnRebootStart.setBounds(220,30,190,55); | ||
| 80 | btnRebootStart.setFont(font); | ||
| 81 | btnRebootStart.setText("Перезагрузить"); | ||
| 82 | btnRebootStart.setSelected(false); | ||
| 83 | btnRebootStart.addActionListener(new Reboot()); | ||
| 84 | add(btnRebootStart); | ||
| 85 | |||
| 86 | // STATUS | ||
| 87 | font = new Font(null, Font.ITALIC, 18); | ||
| 88 | lblStatus.setBounds(10,80,600,55); | ||
| 89 | lblStatus.setForeground(Color.YELLOW); | ||
| 90 | lblStatus.setText(""); | ||
| 91 | lblStatus.setVisible(true); | ||
| 92 | lblStatus.setFont(font); | ||
| 93 | add(lblStatus); | ||
| 94 | |||
| 95 | } | ||
| 96 | |||
| 97 | public class Off implements ActionListener | ||
| 98 | { | ||
| 99 | public void actionPerformed(ActionEvent e) | ||
| 100 | { | ||
| 101 | new SwingWorker<Void, Void>() | ||
| 102 | { | ||
| 103 | protected Void doInBackground() throws Exception | ||
| 104 | { | ||
| 105 | lblStatus.setText("выполняется выключение..."); | ||
| 106 | sshecex.setCmd("shutdown -h now"); | ||
| 107 | sshecex.Exec(); | ||
| 108 | return null; | ||
| 109 | } | ||
| 110 | }.execute(); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | public class Reboot implements ActionListener | ||
| 115 | { | ||
| 116 | public void actionPerformed(ActionEvent e) | ||
| 117 | { | ||
| 118 | |||
| 119 | new SwingWorker<Void, Void>() | ||
| 120 | { | ||
| 121 | protected Void doInBackground() throws Exception | ||
| 122 | { | ||
| 123 | lblStatus.setText("выполняется перезагрузка..."); | ||
| 124 | sshecex.setCmd("reboot"); | ||
| 125 | sshecex.Exec(); | ||
| 126 | return null; | ||
| 127 | } | ||
| 128 | |||
| 129 | }.execute(); | ||
| 130 | |||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | |||
| 135 | public void paintComponent(Graphics g) { | ||
| 136 | super.paintComponent(g); | ||
| 137 | } | ||
| 138 | |||
| 139 | public void setPreferredSize(Dimension dim) { | ||
| 140 | beanDimension = dim; | ||
| 141 | } | ||
| 142 | |||
| 143 | public Dimension getPreferredSize() { | ||
| 144 | return beanDimension; | ||
| 145 | } | ||
| 146 | |||
| 147 | public void setMinimumSize(Dimension dim) { | ||
| 148 | beanDimension = dim; | ||
| 149 | } | ||
| 150 | |||
| 151 | public Dimension getMinimumSize() { | ||
| 152 | return beanDimension; | ||
| 153 | } | ||
| 154 | |||
| 155 | public void addChangeListener(ChangeListener l) { | ||
| 156 | listenerList.add(ChangeListener.class, l); | ||
| 157 | } | ||
| 158 | |||
| 159 | public void removeChangeListener(ChangeListener l) { | ||
| 160 | listenerList.remove(ChangeListener.class, l); | ||
| 161 | } | ||
| 162 | |||
| 163 | public void writeExternal(ObjectOutput out) throws IOException { | ||
| 164 | out.writeObject(beanDimension); | ||
| 165 | } | ||
| 166 | |||
| 167 | public void readExternal(ObjectInput in) throws IOException, | ||
| 168 | ClassNotFoundException { | ||
| 169 | setPreferredSize((Dimension) in.readObject()); | ||
| 170 | setMinimumSize(getPreferredSize()); | ||
| 171 | } | ||
| 172 | |||
| 173 | |||
| 174 | } |
| 1 | package org.emercit.szs.controldevtools.bean; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | import java.awt.Dimension; | ||
| 5 | import java.awt.EventQueue; | ||
| 6 | import java.awt.Font; | ||
| 7 | import java.awt.Graphics; | ||
| 8 | import java.awt.event.ActionEvent; | ||
| 9 | import java.awt.event.ActionListener; | ||
| 10 | import java.beans.PropertyChangeListener; | ||
| 11 | import java.beans.PropertyVetoException; | ||
| 12 | import java.beans.VetoableChangeListener; | ||
| 13 | import java.beans.VetoableChangeSupport; | ||
| 14 | import java.io.Externalizable; | ||
| 15 | import java.io.IOException; | ||
| 16 | import java.io.ObjectInput; | ||
| 17 | import java.io.ObjectOutput; | ||
| 18 | import java.util.Timer; | ||
| 19 | import java.util.TimerTask; | ||
| 20 | |||
| 21 | import javax.swing.ImageIcon; | ||
| 22 | import javax.swing.JButton; | ||
| 23 | import javax.swing.JComponent; | ||
| 24 | import javax.swing.JFrame; | ||
| 25 | import javax.swing.JLabel; | ||
| 26 | import javax.swing.SwingWorker; | ||
| 27 | import javax.swing.event.ChangeEvent; | ||
| 28 | import javax.swing.event.ChangeListener; | ||
| 29 | import javax.swing.event.EventListenerList; | ||
| 30 | import javax.swing.event.SwingPropertyChangeSupport; | ||
| 31 | |||
| 32 | import org.apache.log4j.Logger; | ||
| 33 | import org.emercit.utilstools.config.DefSettings; | ||
| 34 | |||
| 35 | import org.emercit.szs.controldevtools.bean.DevToolsBean; | ||
| 36 | import org.emercit.szs.controldevtools.bean.RoundPanel; | ||
| 37 | |||
| 38 | import org.emercit.utilstools.pckutils.checkservice.STService; | ||
| 39 | import org.emercit.utilstools.service.Settings; | ||
| 40 | import org.emercit.utilstools.svmanager.model.SvBean; | ||
| 41 | import org.emercit.utilstools.svmanager.service.Sv; | ||
| 42 | import org.emercit.utilstools.svmanager.service.SvControl; | ||
| 43 | |||
| 44 | public class DevToolsBean extends RoundPanel implements Externalizable { | ||
| 45 | |||
| 46 | private static final Logger log = Logger.getLogger(DevToolsBean.class); | ||
| 47 | |||
| 48 | private Dimension beanDimension; // simple | ||
| 49 | |||
| 50 | private JLabel lblTitle=new JLabel(); | ||
| 51 | |||
| 52 | private JLabel lblStatus=new JLabel(); | ||
| 53 | |||
| 54 | private JButton btnStart=new JButton("ЗАПУСТИТЬ"); | ||
| 55 | |||
| 56 | private JButton btnStop=new JButton("ОСТАНОВИТЬ"); | ||
| 57 | |||
| 58 | private JButton btnDefaults=new JButton("СБРОС НАСТРОЕК"); | ||
| 59 | |||
| 60 | private STService stservice=new STService(); | ||
| 61 | |||
| 62 | private Timer timerAnimate=new Timer(); | ||
| 63 | |||
| 64 | private Settings settings=new Settings(); | ||
| 65 | |||
| 66 | protected transient ChangeEvent changeEvent = null; | ||
| 67 | |||
| 68 | public Update update=null; | ||
| 69 | |||
| 70 | public boolean block=false; | ||
| 71 | |||
| 72 | public SvBean svbean; | ||
| 73 | |||
| 74 | public SvControl svcontrol; | ||
| 75 | |||
| 76 | public Sv sv; | ||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | protected EventListenerList listenerList = new EventListenerList(); | ||
| 82 | |||
| 83 | |||
| 84 | public DevToolsBean() { | ||
| 85 | |||
| 86 | this.setLayout(null); | ||
| 87 | this.setBackground(new Color(168, 181, 224)); // blue | ||
| 88 | |||
| 89 | beanDimension = new Dimension(600, 130); | ||
| 90 | |||
| 91 | Font font = new Font(null, Font.ITALIC, 13); | ||
| 92 | lblTitle.setBounds(10, 2, 600, 30); | ||
| 93 | |||
| 94 | lblTitle.setText(DefSettings.devtools_title); | ||
| 95 | lblTitle.setFont(font); | ||
| 96 | lblTitle.setForeground(Color.BLUE); | ||
| 97 | add(lblTitle); | ||
| 98 | |||
| 99 | // BUTTON START | ||
| 100 | btnStart.setIcon(new ImageIcon(DevToolsBean.class.getResource("/start.png"))); | ||
| 101 | btnStart.setBounds(10,30,150,40); | ||
| 102 | btnStart.setFont(font); | ||
| 103 | btnStart.setSelected(false); | ||
| 104 | btnStart.addActionListener(new Start()); | ||
| 105 | add(btnStart); | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | // BUTTON STOP | ||
| 110 | btnStop.setIcon(new ImageIcon(DevToolsBean.class.getResource("/stop.png"))); | ||
| 111 | btnStop.setBounds(170,30,180,40); | ||
| 112 | btnStop.setFont(font); | ||
| 113 | btnStop.setSelected(false); | ||
| 114 | btnStop.addActionListener(new Stop()); | ||
| 115 | add(btnStop); | ||
| 116 | |||
| 117 | |||
| 118 | // BUTTON DEFAULTS | ||
| 119 | btnDefaults.setIcon(new ImageIcon(DevToolsBean.class.getResource("/replay.png"))); | ||
| 120 | btnDefaults.setBounds(360,30,230,40); | ||
| 121 | btnDefaults.setFont(font); | ||
| 122 | btnDefaults.setSelected(false); | ||
| 123 | btnDefaults.addActionListener(new Defaults()); | ||
| 124 | add(btnDefaults); | ||
| 125 | |||
| 126 | // STATUS | ||
| 127 | font = new Font(null, Font.ITALIC, 18); | ||
| 128 | lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/running.png"))); | ||
| 129 | lblStatus.setBounds(10,80,600,55); | ||
| 130 | lblStatus.setForeground(Color.YELLOW); | ||
| 131 | lblStatus.setText(""); | ||
| 132 | lblStatus.setVisible(true); | ||
| 133 | lblStatus.setFont(font); | ||
| 134 | add(lblStatus); | ||
| 135 | |||
| 136 | sv=new Sv(); | ||
| 137 | |||
| 138 | for (SvBean bean:sv.get()) { | ||
| 139 | |||
| 140 | if (bean.getProcess().equals("jetty")) { | ||
| 141 | |||
| 142 | svcontrol=new SvControl(bean); | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | timerAnimate.schedule(new Task(),0,10000); | ||
| 147 | } | ||
| 148 | |||
| 149 | |||
| 150 | public void initCmpEnabled() { | ||
| 151 | |||
| 152 | try { | ||
| 153 | boolean jattyrun=stservice.IsRun(DefSettings.jetty_process); | ||
| 154 | |||
| 155 | if(jattyrun){ | ||
| 156 | |||
| 157 | btnStop.setEnabled(true); | ||
| 158 | btnStart.setEnabled(false); | ||
| 159 | |||
| 160 | lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/up.png"))); | ||
| 161 | lblStatus.setForeground(Color.GREEN); | ||
| 162 | lblStatus.setText("- Web конфигуратор запущен"); | ||
| 163 | |||
| 164 | }else { | ||
| 165 | |||
| 166 | btnStop.setEnabled(false); | ||
| 167 | btnStart.setEnabled(true); | ||
| 168 | |||
| 169 | lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/down.png"))); | ||
| 170 | lblStatus.setForeground(Color.WHITE); | ||
| 171 | lblStatus.setText("- Web конфигуратор не запущен"); | ||
| 172 | } | ||
| 173 | }catch(Exception e){ | ||
| 174 | log.error(e.getMessage()); | ||
| 175 | } | ||
| 176 | |||
| 177 | } | ||
| 178 | |||
| 179 | |||
| 180 | public class Start implements ActionListener | ||
| 181 | { | ||
| 182 | public void actionPerformed(ActionEvent e) | ||
| 183 | { | ||
| 184 | new SwingWorker<Void, Void>() | ||
| 185 | { | ||
| 186 | protected Void doInBackground() throws Exception | ||
| 187 | { | ||
| 188 | |||
| 189 | btnStart.setEnabled(false); | ||
| 190 | btnStop.setEnabled(false); | ||
| 191 | lblStatus.setForeground(Color.YELLOW); | ||
| 192 | lblStatus.setText(" - выполняется запуск Web конфигуратора ..."); | ||
| 193 | |||
| 194 | block=true; | ||
| 195 | |||
| 196 | svcontrol.start(); | ||
| 197 | |||
| 198 | block=false; | ||
| 199 | |||
| 200 | return null; | ||
| 201 | |||
| 202 | } | ||
| 203 | |||
| 204 | }.execute(); | ||
| 205 | |||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | |||
| 210 | public class Stop implements ActionListener | ||
| 211 | { | ||
| 212 | public void actionPerformed(ActionEvent e) | ||
| 213 | { | ||
| 214 | |||
| 215 | new SwingWorker<Void, Void>() | ||
| 216 | { | ||
| 217 | protected Void doInBackground() throws Exception | ||
| 218 | { | ||
| 219 | |||
| 220 | btnStart.setEnabled(false); | ||
| 221 | btnStop.setEnabled(false); | ||
| 222 | lblStatus.setForeground(Color.YELLOW); | ||
| 223 | lblStatus.setText(" - выполняется остановка Web конфигуратора ..."); | ||
| 224 | |||
| 225 | block=true; | ||
| 226 | |||
| 227 | svcontrol.stop(); | ||
| 228 | |||
| 229 | block=false; | ||
| 230 | |||
| 231 | return null; | ||
| 232 | } | ||
| 233 | |||
| 234 | }.execute(); | ||
| 235 | |||
| 236 | |||
| 237 | |||
| 238 | |||
| 239 | |||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | |||
| 244 | public class Defaults implements ActionListener | ||
| 245 | { | ||
| 246 | public void actionPerformed(ActionEvent e) | ||
| 247 | { | ||
| 248 | |||
| 249 | new SwingWorker<Void, Void>() | ||
| 250 | { | ||
| 251 | protected Void doInBackground() throws Exception | ||
| 252 | { | ||
| 253 | block=true; | ||
| 254 | lblStatus.setForeground(Color.YELLOW); | ||
| 255 | lblStatus.setText(" - выполняется сброс настроек ..."); | ||
| 256 | |||
| 257 | btnDefaults.setEnabled(false); | ||
| 258 | btnStart.setEnabled(false); | ||
| 259 | btnStop.setEnabled(false); | ||
| 260 | |||
| 261 | try { | ||
| 262 | settings.init(); | ||
| 263 | |||
| 264 | Thread.sleep(5000); | ||
| 265 | |||
| 266 | }catch(Exception er) { | ||
| 267 | log.error(er.getMessage()); | ||
| 268 | } | ||
| 269 | btnDefaults.setEnabled(true); | ||
| 270 | block=false; | ||
| 271 | return null; | ||
| 272 | |||
| 273 | } | ||
| 274 | |||
| 275 | }.execute(); | ||
| 276 | |||
| 277 | } | ||
| 278 | } | ||
| 279 | |||
| 280 | |||
| 281 | |||
| 282 | |||
| 283 | |||
| 284 | |||
| 285 | public void paintComponent(Graphics g) { | ||
| 286 | super.paintComponent(g); | ||
| 287 | } | ||
| 288 | |||
| 289 | |||
| 290 | public void setPreferredSize(Dimension dim) { | ||
| 291 | beanDimension = dim; | ||
| 292 | } | ||
| 293 | |||
| 294 | public Dimension getPreferredSize() { | ||
| 295 | return beanDimension; | ||
| 296 | } | ||
| 297 | |||
| 298 | public void setMinimumSize(Dimension dim) { | ||
| 299 | beanDimension = dim; | ||
| 300 | } | ||
| 301 | |||
| 302 | public Dimension getMinimumSize() { | ||
| 303 | return beanDimension; | ||
| 304 | } | ||
| 305 | |||
| 306 | |||
| 307 | |||
| 308 | public void addChangeListener(ChangeListener l) { | ||
| 309 | listenerList.add(ChangeListener.class, l); | ||
| 310 | } | ||
| 311 | |||
| 312 | public void removeChangeListener(ChangeListener l) { | ||
| 313 | listenerList.remove(ChangeListener.class, l); | ||
| 314 | } | ||
| 315 | |||
| 316 | |||
| 317 | protected void fireStateChanged() { | ||
| 318 | Object[] listeners = listenerList.getListenerList(); | ||
| 319 | |||
| 320 | for (int i = listeners.length - 2; i >= 0; i -= 2) { | ||
| 321 | if (listeners[i] == ChangeListener.class) { | ||
| 322 | if (changeEvent == null) | ||
| 323 | changeEvent = new ChangeEvent(this); | ||
| 324 | ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent); | ||
| 325 | } | ||
| 326 | } | ||
| 327 | } | ||
| 328 | |||
| 329 | public void writeExternal(ObjectOutput out) throws IOException { | ||
| 330 | |||
| 331 | out.writeObject(beanDimension); | ||
| 332 | |||
| 333 | } | ||
| 334 | |||
| 335 | public void readExternal(ObjectInput in) throws IOException, | ||
| 336 | ClassNotFoundException { | ||
| 337 | |||
| 338 | setPreferredSize((Dimension) in.readObject()); | ||
| 339 | |||
| 340 | setMinimumSize(getPreferredSize()); | ||
| 341 | |||
| 342 | } | ||
| 343 | |||
| 344 | |||
| 345 | |||
| 346 | |||
| 347 | public class Update extends SwingWorker<Void, Void> { | ||
| 348 | @Override | ||
| 349 | public Void doInBackground() | ||
| 350 | { | ||
| 351 | // Если выполняется запуск или остановка, то не проверяем | ||
| 352 | if (!block){ | ||
| 353 | initCmpEnabled(); | ||
| 354 | } | ||
| 355 | |||
| 356 | return null; | ||
| 357 | } | ||
| 358 | |||
| 359 | @Override | ||
| 360 | public void done(){ | ||
| 361 | |||
| 362 | |||
| 363 | } | ||
| 364 | } | ||
| 365 | |||
| 366 | |||
| 367 | |||
| 368 | private class Task extends TimerTask { | ||
| 369 | |||
| 370 | @Override | ||
| 371 | public void run() { | ||
| 372 | EventQueue.invokeLater(new Runnable() { | ||
| 373 | // @Override | ||
| 374 | public void run() { | ||
| 375 | |||
| 376 | update=new Update(); | ||
| 377 | update.execute(); | ||
| 378 | |||
| 379 | |||
| 380 | |||
| 381 | } | ||
| 382 | |||
| 383 | }); | ||
| 384 | } | ||
| 385 | } | ||
| 386 | |||
| 387 | |||
| 388 | |||
| 389 | public static void main(String[] args) { | ||
| 390 | JFrame frame = new JFrame("Управление Web конфигуратором"); | ||
| 391 | frame.getContentPane().add(new DevToolsBean()); | ||
| 392 | frame.setVisible(true); | ||
| 393 | frame.pack(); | ||
| 394 | } | ||
| 395 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szs.controldevtools.bean; | ||
| 2 | |||
| 3 | import java.io.BufferedWriter; | ||
| 4 | import java.io.FileWriter; | ||
| 5 | import java.io.IOException; | ||
| 6 | |||
| 7 | import org.apache.log4j.Logger; | ||
| 8 | import org.emercit.szs.controldevtools.bean.Player; | ||
| 9 | |||
| 10 | public class NotificationBB implements INotification { | ||
| 11 | |||
| 12 | private static final Logger log = Logger.getLogger(NotificationBB.class); | ||
| 13 | |||
| 14 | |||
| 15 | public void playSound() { | ||
| 16 | |||
| 17 | Player player = new Player("/Alarm.wav"); | ||
| 18 | log.info("Sound - up "); | ||
| 19 | player.start(); | ||
| 20 | |||
| 21 | } | ||
| 22 | |||
| 23 | public void playSiren() { | ||
| 24 | try { | ||
| 25 | |||
| 26 | FileWriter fw = new FileWriter("/dev/relay1", true); | ||
| 27 | BufferedWriter output = new BufferedWriter(fw); | ||
| 28 | output.write("1"); | ||
| 29 | output.close(); | ||
| 30 | log.info("Siren - up "); | ||
| 31 | |||
| 32 | } catch (IOException e) { | ||
| 33 | log.error(e.getMessage()); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | public void stopSiren() { | ||
| 38 | try { | ||
| 39 | |||
| 40 | FileWriter fw = new FileWriter("/dev/relay1", true); | ||
| 41 | BufferedWriter output = new BufferedWriter(fw); | ||
| 42 | output.write("0"); | ||
| 43 | output.close(); | ||
| 44 | log.info("Siren - down "); | ||
| 45 | |||
| 46 | } catch (IOException e) { | ||
| 47 | log.error(e.getMessage()); | ||
| 48 | } | ||
| 49 | |||
| 50 | } | ||
| 51 | |||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 |
| 1 | package org.emercit.szs.controldevtools.bean; | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | import java.io.File; | ||
| 6 | import java.io.IOException; | ||
| 7 | |||
| 8 | import javax.sound.sampled.AudioFormat; | ||
| 9 | import javax.sound.sampled.AudioInputStream; | ||
| 10 | import javax.sound.sampled.AudioSystem; | ||
| 11 | import javax.sound.sampled.DataLine; | ||
| 12 | import javax.sound.sampled.FloatControl; | ||
| 13 | import javax.sound.sampled.LineUnavailableException; | ||
| 14 | import javax.sound.sampled.SourceDataLine; | ||
| 15 | import javax.sound.sampled.UnsupportedAudioFileException; | ||
| 16 | |||
| 17 | import org.apache.log4j.Logger; | ||
| 18 | |||
| 19 | import java.net.*; | ||
| 20 | |||
| 21 | public class Player extends Thread { | ||
| 22 | |||
| 23 | |||
| 24 | private static final Logger log = Logger.getLogger(Player.class); | ||
| 25 | |||
| 26 | private String filename; | ||
| 27 | |||
| 28 | private Position curPosition; | ||
| 29 | |||
| 30 | private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb | ||
| 31 | |||
| 32 | enum Position { | ||
| 33 | LEFT, RIGHT, NORMAL | ||
| 34 | }; | ||
| 35 | |||
| 36 | public Player(String wavfile) { | ||
| 37 | filename = wavfile; | ||
| 38 | curPosition = Position.NORMAL; | ||
| 39 | } | ||
| 40 | |||
| 41 | public Player(String wavfile, Position p) { | ||
| 42 | filename = wavfile; | ||
| 43 | curPosition = p; | ||
| 44 | } | ||
| 45 | |||
| 46 | public void run() { | ||
| 47 | |||
| 48 | try { | ||
| 49 | |||
| 50 | File soundFile = new File(getClass().getResource(filename) | ||
| 51 | .getFile()); | ||
| 52 | if (!soundFile.exists()) { | ||
| 53 | log.error("Wave file not found: " + filename); | ||
| 54 | return; | ||
| 55 | } | ||
| 56 | |||
| 57 | AudioInputStream audioInputStream = null; | ||
| 58 | try { | ||
| 59 | audioInputStream = AudioSystem.getAudioInputStream(soundFile); | ||
| 60 | } catch (UnsupportedAudioFileException e1) { | ||
| 61 | e1.printStackTrace(); | ||
| 62 | return; | ||
| 63 | } catch (IOException e1) { | ||
| 64 | log.error(e1.getMessage()); | ||
| 65 | return; | ||
| 66 | } | ||
| 67 | |||
| 68 | AudioFormat format = audioInputStream.getFormat(); | ||
| 69 | SourceDataLine auline = null; | ||
| 70 | DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); | ||
| 71 | |||
| 72 | try { | ||
| 73 | auline = (SourceDataLine) AudioSystem.getLine(info); | ||
| 74 | auline.open(format); | ||
| 75 | } catch (LineUnavailableException e) { | ||
| 76 | e.printStackTrace(); | ||
| 77 | return; | ||
| 78 | } catch (Exception e) { | ||
| 79 | log.error(e.getMessage()); | ||
| 80 | return; | ||
| 81 | } | ||
| 82 | |||
| 83 | if (auline.isControlSupported(FloatControl.Type.PAN)) { | ||
| 84 | FloatControl pan = (FloatControl) auline | ||
| 85 | .getControl(FloatControl.Type.PAN); | ||
| 86 | if (curPosition == Position.RIGHT) | ||
| 87 | pan.setValue(1.0f); | ||
| 88 | else if (curPosition == Position.LEFT) | ||
| 89 | pan.setValue(-1.0f); | ||
| 90 | } | ||
| 91 | |||
| 92 | auline.start(); | ||
| 93 | int nBytesRead = 0; | ||
| 94 | byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; | ||
| 95 | |||
| 96 | try { | ||
| 97 | while (nBytesRead != -1) { | ||
| 98 | nBytesRead = audioInputStream | ||
| 99 | .read(abData, 0, abData.length); | ||
| 100 | if (nBytesRead >= 0) | ||
| 101 | auline.write(abData, 0, nBytesRead); | ||
| 102 | } | ||
| 103 | } catch (IOException e) { | ||
| 104 | log.error(e.getMessage()); | ||
| 105 | return; | ||
| 106 | } finally { | ||
| 107 | auline.drain(); | ||
| 108 | auline.close(); | ||
| 109 | } | ||
| 110 | |||
| 111 | } catch (Exception e1) { | ||
| 112 | log.error(e1.getMessage()); | ||
| 113 | } | ||
| 114 | |||
| 115 | } | ||
| 116 | } |
| 1 | package org.emercit.szs.controldevtools.bean; | ||
| 2 | |||
| 3 | |||
| 4 | import java.awt.BasicStroke; | ||
| 5 | import java.awt.Color; | ||
| 6 | import java.awt.Dimension; | ||
| 7 | import java.awt.Graphics; | ||
| 8 | import java.awt.Graphics2D; | ||
| 9 | import java.awt.RenderingHints; | ||
| 10 | import javax.swing.JPanel; | ||
| 11 | |||
| 12 | public class RoundPanel extends JPanel | ||
| 13 | { | ||
| 14 | protected int _strokeSize = 1; | ||
| 15 | protected Color _shadowColor = Color.BLACK; | ||
| 16 | protected boolean _shadowed = true; | ||
| 17 | protected boolean _highQuality = true; | ||
| 18 | protected Dimension _arcs = new Dimension(15, 15); | ||
| 19 | protected int _shadowGap = 3; | ||
| 20 | protected int _shadowOffset = 4; | ||
| 21 | protected int _shadowAlpha = 100; | ||
| 22 | |||
| 23 | public Color _backgroundColor = Color.WHITE; | ||
| 24 | |||
| 25 | public RoundPanel() | ||
| 26 | { | ||
| 27 | super(); | ||
| 28 | setOpaque(false); | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | @Override | ||
| 33 | public void setBackground(Color c) | ||
| 34 | { | ||
| 35 | _backgroundColor = c; | ||
| 36 | } | ||
| 37 | |||
| 38 | @Override | ||
| 39 | protected void paintComponent(Graphics g) | ||
| 40 | { | ||
| 41 | super.paintComponent(g); | ||
| 42 | |||
| 43 | int width = getWidth(); | ||
| 44 | int height = getHeight(); | ||
| 45 | int shadowGap = this._shadowGap; | ||
| 46 | Color shadowColorA = new Color(_shadowColor.getRed(), _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha); | ||
| 47 | Graphics2D graphics = (Graphics2D) g; | ||
| 48 | |||
| 49 | if(_highQuality) | ||
| 50 | { | ||
| 51 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 52 | } | ||
| 53 | |||
| 54 | if(_shadowed) | ||
| 55 | { | ||
| 56 | graphics.setColor(shadowColorA); | ||
| 57 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width - _strokeSize - _shadowOffset, | ||
| 58 | height - _strokeSize - _shadowOffset, _arcs.width, _arcs.height); | ||
| 59 | } | ||
| 60 | else | ||
| 61 | { | ||
| 62 | _shadowGap = 1; | ||
| 63 | } | ||
| 64 | |||
| 65 | graphics.setColor(_backgroundColor); | ||
| 66 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, _arcs.width, _arcs.height); | ||
| 67 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 68 | graphics.setColor(getForeground()); | ||
| 69 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, _arcs.width, _arcs.height); | ||
| 70 | graphics.setStroke(new BasicStroke()); | ||
| 71 | } | ||
| 72 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | import org.emercit.utilstools.devinfo.service.DevInfo; | ||
| 4 | import org.emercit.utilstools.devinfo.model.DevInfoBean; | ||
| 5 | |||
| 6 | import org.emercit.utilstools.gsmmanager.model.GSMBean; | ||
| 7 | import org.emercit.utilstools.gsmmanager.service.Gsm; | ||
| 8 | |||
| 9 | import org.emercit.utilstools.servers.model.ServerBean; | ||
| 10 | import org.emercit.utilstools.servers.service.Servers; | ||
| 11 | |||
| 12 | |||
| 13 | public class Config { | ||
| 14 | |||
| 15 | |||
| 16 | private static Gsm gsm=new Gsm(); | ||
| 17 | |||
| 18 | private static DevInfo devinfo=new DevInfo(); | ||
| 19 | |||
| 20 | private static Servers servers=new Servers(); | ||
| 21 | |||
| 22 | public final static GSMBean gsmbean=gsm.get(); | ||
| 23 | |||
| 24 | public final static DevInfoBean devinfobean=devinfo.get(); | ||
| 25 | |||
| 26 | public final static ServerBean serverbean=servers.get().firstElement(); | ||
| 27 | |||
| 28 | } |
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | import java.awt.Component; | ||
| 5 | import java.awt.Font; | ||
| 6 | import java.awt.Image; | ||
| 7 | |||
| 8 | import javax.swing.*; | ||
| 9 | import javax.swing.table.DefaultTableCellRenderer; | ||
| 10 | import javax.swing.table.TableCellRenderer; | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | import java.awt.*; | ||
| 15 | |||
| 16 | public class EventCellRenderer implements TableCellRenderer { | ||
| 17 | public Component getTableCellRendererComponent(JTable table, Object value, | ||
| 18 | boolean isSelected, boolean hasFocus, int row, int column) { | ||
| 19 | MdlEvent event = (MdlEvent) value; | ||
| 20 | |||
| 21 | JPanel panel = new JPanel(); | ||
| 22 | panel.setLayout(null); | ||
| 23 | |||
| 24 | // Row1 | ||
| 25 | |||
| 26 | // DateTime | ||
| 27 | JLabel lblTitleDateTime = new JLabel(); | ||
| 28 | lblTitleDateTime.setBounds(5, 0, 170, 17); | ||
| 29 | lblTitleDateTime.setForeground(Color.BLUE); | ||
| 30 | lblTitleDateTime.setIcon(event.getIconDateTimeSmall()); | ||
| 31 | lblTitleDateTime.setText(event.getDateTime()); | ||
| 32 | panel.add(lblTitleDateTime); | ||
| 33 | |||
| 34 | // Title Status | ||
| 35 | JLabel lblTitleStatus = new JLabel(); | ||
| 36 | lblTitleStatus.setBounds(185, 0, 300, 17); | ||
| 37 | lblTitleStatus.setForeground(event.getColorStatus()); | ||
| 38 | lblTitleStatus.setText(event.getTitleStatusForConfirm()); | ||
| 39 | lblTitleStatus.setIcon(event.getIconStatusSmall()); | ||
| 40 | panel.add(lblTitleStatus); | ||
| 41 | |||
| 42 | // TitleRiver | ||
| 43 | JLabel lblTitleRiver = new JLabel(); | ||
| 44 | lblTitleRiver.setBounds(500, 0, 250, 17); | ||
| 45 | lblTitleRiver.setForeground(Color.BLUE); | ||
| 46 | lblTitleRiver.setText(event.getTitleRiver()); | ||
| 47 | lblTitleRiver.setIcon(event.getIconRiverSmall()); | ||
| 48 | panel.add(lblTitleRiver); | ||
| 49 | |||
| 50 | // Row2 | ||
| 51 | |||
| 52 | // TitileAGK | ||
| 53 | JLabel lblTitleAgk = new JLabel(); | ||
| 54 | lblTitleAgk.setBounds(5, 18, 80, 17); | ||
| 55 | lblTitleAgk.setForeground(Color.BLUE); | ||
| 56 | lblTitleAgk.setText(event.getTitleAgk()); | ||
| 57 | lblTitleAgk.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 58 | panel.add(lblTitleAgk); | ||
| 59 | |||
| 60 | // Title Repair | ||
| 61 | |||
| 62 | JLabel lblTitleRepair = new JLabel(); | ||
| 63 | lblTitleRepair.setBounds(100, 18, 170, 17); | ||
| 64 | lblTitleRepair.setForeground(Color.BLUE); | ||
| 65 | lblTitleRepair.setIcon(event.getIconRepairSmall()); | ||
| 66 | lblTitleRepair.setText(event.getTitleRepair()); | ||
| 67 | lblTitleRepair.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 68 | panel.add(lblTitleRepair); | ||
| 69 | |||
| 70 | // Title box | ||
| 71 | |||
| 72 | JLabel lblTitleBox = new JLabel(); | ||
| 73 | lblTitleBox.setBounds(280, 18, 170, 17); | ||
| 74 | lblTitleBox.setForeground(Color.BLUE); | ||
| 75 | lblTitleBox.setIcon(event.getIconOpenDoorSmall()); | ||
| 76 | lblTitleBox.setText(event.getTitleOpenDorr()); | ||
| 77 | lblTitleBox.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 78 | panel.add(lblTitleBox); | ||
| 79 | |||
| 80 | // Title veracity | ||
| 81 | JLabel lblTitleVeracity = new JLabel(); | ||
| 82 | lblTitleVeracity.setBounds(450, 18, 200, 17); | ||
| 83 | lblTitleVeracity.setForeground(Color.BLUE); | ||
| 84 | lblTitleVeracity.setIcon(event.getIconVeracitySmall()); | ||
| 85 | lblTitleVeracity.setText(event.getTitleVeracity()); | ||
| 86 | lblTitleVeracity.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 87 | panel.add(lblTitleVeracity); | ||
| 88 | |||
| 89 | panel.setBackground(event.getColorLogPanel()); | ||
| 90 | |||
| 91 | return panel; | ||
| 92 | } | ||
| 93 | } |
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | import java.util.HashSet; | ||
| 4 | import java.util.List; | ||
| 5 | import java.util.Set; | ||
| 6 | |||
| 7 | import javax.swing.event.TableModelListener; | ||
| 8 | import javax.swing.table.TableModel; | ||
| 9 | import javax.swing.table.TableCellRenderer; | ||
| 10 | |||
| 11 | import java.util.ArrayList; | ||
| 12 | |||
| 13 | import javax.swing.*; | ||
| 14 | import javax.swing.event.TableModelListener; | ||
| 15 | import javax.swing.table.TableCellRenderer; | ||
| 16 | import javax.swing.table.TableModel; | ||
| 17 | import javax.swing.table.AbstractTableModel; | ||
| 18 | |||
| 19 | import java.awt.*; | ||
| 20 | import java.text.MessageFormat; | ||
| 21 | import java.text.NumberFormat; | ||
| 22 | import java.text.SimpleDateFormat; | ||
| 23 | import java.util.Date; | ||
| 24 | |||
| 25 | public class EventTableModel extends AbstractTableModel { | ||
| 26 | |||
| 27 | private Set<TableModelListener> listeners = new HashSet<TableModelListener>(); | ||
| 28 | |||
| 29 | private List<MdlEvent> event; | ||
| 30 | private List<MdlEvent> eventsource; | ||
| 31 | |||
| 32 | private int start = 0; | ||
| 33 | private int end = 9; | ||
| 34 | |||
| 35 | public int getSize() { | ||
| 36 | return eventsource.size(); | ||
| 37 | } | ||
| 38 | |||
| 39 | public void AddRow(MdlEvent event) { | ||
| 40 | eventsource.add(0, event); | ||
| 41 | |||
| 42 | for (int i = 0; i < eventsource.size(); i++) { | ||
| 43 | MdlEvent obj = eventsource.get(i); | ||
| 44 | // if (obj.IsOld()) | ||
| 45 | // eventsource.remove(i); | ||
| 46 | } | ||
| 47 | |||
| 48 | Update(start, end); | ||
| 49 | } | ||
| 50 | |||
| 51 | public void Update(int start, int end) { | ||
| 52 | |||
| 53 | this.start = start; | ||
| 54 | this.end = end; | ||
| 55 | event = new ArrayList<MdlEvent>(); | ||
| 56 | |||
| 57 | try { | ||
| 58 | for (int i = start; i < end; i++) | ||
| 59 | event.add(eventsource.get(i)); | ||
| 60 | } catch (Exception ex) { | ||
| 61 | |||
| 62 | } | ||
| 63 | |||
| 64 | } | ||
| 65 | |||
| 66 | public void Update() { | ||
| 67 | |||
| 68 | event = new ArrayList<MdlEvent>(); | ||
| 69 | |||
| 70 | try { | ||
| 71 | for (int i = start; i < end; i++) | ||
| 72 | event.add(eventsource.get(i)); | ||
| 73 | |||
| 74 | } catch (Exception ex) { | ||
| 75 | |||
| 76 | } | ||
| 77 | |||
| 78 | } | ||
| 79 | |||
| 80 | public void RemoveOld() { | ||
| 81 | try { | ||
| 82 | ArrayList<MdlEvent> buff = new ArrayList<MdlEvent>(); | ||
| 83 | |||
| 84 | for (int i = 0; i < eventsource.size(); i++) | ||
| 85 | buff.add(eventsource.get(i)); | ||
| 86 | |||
| 87 | this.eventsource = buff; | ||
| 88 | |||
| 89 | } catch (Exception e) { | ||
| 90 | } | ||
| 91 | |||
| 92 | } | ||
| 93 | |||
| 94 | public EventTableModel(List<MdlEvent> event) { | ||
| 95 | this.eventsource = event; | ||
| 96 | |||
| 97 | } | ||
| 98 | |||
| 99 | public EventTableModel() { | ||
| 100 | List<MdlEvent> initList = new ArrayList<MdlEvent>(); | ||
| 101 | // for (int i=0;i<100;i++) | ||
| 102 | // { | ||
| 103 | // LRTable lrtable=new | ||
| 104 | // LRTable(i,"River "+i,i,"20.11.2013 8:00","7.5"+i); | ||
| 105 | // initList.add(0,lrtable); | ||
| 106 | // } | ||
| 107 | this.event = initList; | ||
| 108 | this.eventsource = initList; | ||
| 109 | } | ||
| 110 | |||
| 111 | public Class getColumnClass(int columnIndex) { | ||
| 112 | return MdlEvent.class; | ||
| 113 | } | ||
| 114 | |||
| 115 | public int getColumnCount() { | ||
| 116 | return 1; | ||
| 117 | } | ||
| 118 | |||
| 119 | public String getColumnName(int columnIndex) { | ||
| 120 | return "Event"; | ||
| 121 | } | ||
| 122 | |||
| 123 | public int getRowCount() { | ||
| 124 | return (event == null) ? 0 : event.size(); | ||
| 125 | } | ||
| 126 | |||
| 127 | public Object getValueAt(int rowIndex, int columnIndex) { | ||
| 128 | return (event == null) ? null : event.get(rowIndex); | ||
| 129 | } | ||
| 130 | |||
| 131 | public boolean isCellEditable(int columnIndex, int rowIndex) { | ||
| 132 | return true; | ||
| 133 | } | ||
| 134 | |||
| 135 | } |
This diff is collapsed.
Click to expand it.
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | public class MsgSzs { | ||
| 4 | |||
| 5 | public final static String downPpp="Остановка PPP соединения"; | ||
| 6 | public final static String upPpp="Запуск PPP соединения"; | ||
| 7 | public final static String offGsm="Выключение Gsm модема"; | ||
| 8 | public final static String onGms="Включение Gsm модема"; | ||
| 9 | public final static String connectServerError="Связь с сервером потеряна"; | ||
| 10 | } |
No preview for this file type
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | import java.io.*; | ||
| 4 | import java.util.*; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * This class is an auto-resizable String array. It has similar methods to ArrayList | ||
| 8 | * | ||
| 9 | * @author Henry Zheng | ||
| 10 | * @url http://www.ireasoning.com | ||
| 11 | */ | ||
| 12 | |||
| 13 | public class StringArray implements Serializable | ||
| 14 | { | ||
| 15 | public static final int DEFAULT_CAPACITY = 10; | ||
| 16 | |||
| 17 | protected String[] _strings = null; | ||
| 18 | protected int _upperBound = 0; | ||
| 19 | protected int _capacity = DEFAULT_CAPACITY; | ||
| 20 | protected int _initialSize = _capacity; | ||
| 21 | protected float _loadFactory = 1.5F; | ||
| 22 | |||
| 23 | public StringArray () | ||
| 24 | { | ||
| 25 | this(DEFAULT_CAPACITY); | ||
| 26 | } | ||
| 27 | |||
| 28 | public StringArray( int size) | ||
| 29 | { | ||
| 30 | _capacity = size; | ||
| 31 | _initialSize = size; | ||
| 32 | _strings = new String[size]; | ||
| 33 | } | ||
| 34 | |||
| 35 | public synchronized void ensureCapacity(int capacity) | ||
| 36 | { | ||
| 37 | if(_capacity < capacity) | ||
| 38 | { | ||
| 39 | _capacity = (_capacity * 3)/2 + 1; | ||
| 40 | if(_capacity < capacity) | ||
| 41 | { | ||
| 42 | _capacity = capacity; | ||
| 43 | } | ||
| 44 | String [] oldData = _strings; | ||
| 45 | _strings = new String[_capacity]; | ||
| 46 | System.arraycopy(oldData, 0, _strings, 0, _upperBound); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | public synchronized void add(String s) | ||
| 52 | { | ||
| 53 | if(_upperBound == _capacity ) | ||
| 54 | { | ||
| 55 | resize((int) (_capacity * _loadFactory)); | ||
| 56 | } | ||
| 57 | _strings[_upperBound++] = s; | ||
| 58 | } | ||
| 59 | |||
| 60 | public synchronized void add(StringArray sa) | ||
| 61 | { | ||
| 62 | for (int i = 0; i < sa.size() ; i++) | ||
| 63 | { | ||
| 64 | add(sa.get(i)); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | public synchronized String get(int index) | ||
| 69 | { | ||
| 70 | return _strings[index]; | ||
| 71 | } | ||
| 72 | |||
| 73 | public synchronized void set(int index, String newVal) | ||
| 74 | { | ||
| 75 | _strings[index] = newVal; | ||
| 76 | } | ||
| 77 | |||
| 78 | /** Adds all elements in passed string array */ | ||
| 79 | public synchronized void add(String [] strs) | ||
| 80 | { | ||
| 81 | for (int i = 0; i < strs.length ; i++) | ||
| 82 | { | ||
| 83 | add(strs[i]); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | /** Resets this object. */ | ||
| 88 | public synchronized void clear() | ||
| 89 | { | ||
| 90 | _capacity = _initialSize; | ||
| 91 | _strings = new String[_capacity]; | ||
| 92 | _upperBound = 0; | ||
| 93 | |||
| 94 | } | ||
| 95 | |||
| 96 | public synchronized String remove(int index) | ||
| 97 | { | ||
| 98 | if(index >= _upperBound ) | ||
| 99 | { | ||
| 100 | throw new IndexOutOfBoundsException(); | ||
| 101 | } | ||
| 102 | String s = _strings[index]; | ||
| 103 | for (int i = index; i < _upperBound - 1 ; i++) | ||
| 104 | { | ||
| 105 | _strings[i] = _strings[i + 1]; | ||
| 106 | } | ||
| 107 | _upperBound --; | ||
| 108 | return s; | ||
| 109 | } | ||
| 110 | |||
| 111 | /** | ||
| 112 | * Removes the first occurance of passed str | ||
| 113 | * @return the string removed, or null if not found | ||
| 114 | */ | ||
| 115 | public synchronized String remove(String str) | ||
| 116 | { | ||
| 117 | for (int i = 0; i < _upperBound ; i++) | ||
| 118 | { | ||
| 119 | if(_strings[i].equals(str)) | ||
| 120 | { | ||
| 121 | return remove(i); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | return null; | ||
| 125 | } | ||
| 126 | |||
| 127 | public synchronized int size() | ||
| 128 | { | ||
| 129 | return _upperBound; | ||
| 130 | } | ||
| 131 | |||
| 132 | public synchronized boolean isEmpty() | ||
| 133 | { | ||
| 134 | return _upperBound == 0; | ||
| 135 | } | ||
| 136 | |||
| 137 | public synchronized String[] toArray() | ||
| 138 | { | ||
| 139 | String [] ret = new String[_upperBound]; | ||
| 140 | for (int i = 0; i < _upperBound ; i++) | ||
| 141 | { | ||
| 142 | ret[i] = _strings[i]; | ||
| 143 | } | ||
| 144 | return ret; | ||
| 145 | } | ||
| 146 | |||
| 147 | protected synchronized void resize(int newCapacity) | ||
| 148 | { | ||
| 149 | String [] as = new String[newCapacity]; | ||
| 150 | for (int i = 0; i < _strings.length ; i++) | ||
| 151 | { | ||
| 152 | as[i] = _strings[i]; | ||
| 153 | } | ||
| 154 | _strings = as; | ||
| 155 | _capacity = newCapacity; | ||
| 156 | } | ||
| 157 | |||
| 158 | public String toString() | ||
| 159 | { | ||
| 160 | StringBuffer buf = new StringBuffer(); | ||
| 161 | for (int i = 0; i < _upperBound ; i++) | ||
| 162 | { | ||
| 163 | buf.append(_strings[i] + "\n"); | ||
| 164 | } | ||
| 165 | return buf.toString(); | ||
| 166 | } | ||
| 167 | |||
| 168 | public static void main(String[] args) | ||
| 169 | { | ||
| 170 | StringArray as = new StringArray(); | ||
| 171 | String [] ss = null; | ||
| 172 | ss = as.toArray(); | ||
| 173 | // System.out.println( "ss len="+ss.length); | ||
| 174 | // System.out.println( "ss = " + ss); | ||
| 175 | for (int i = 0; i < 10 ; i++) | ||
| 176 | { | ||
| 177 | as.add("" + i); | ||
| 178 | } | ||
| 179 | // System.out.println( "size = " + as.size()); | ||
| 180 | ss = as.toArray(); | ||
| 181 | for (int i = 0; i < ss.length ; i++) | ||
| 182 | { | ||
| 183 | // System.out.println( ss[i]); | ||
| 184 | } | ||
| 185 | // System.out.println( "remove 5th element."); | ||
| 186 | as.remove(5); | ||
| 187 | |||
| 188 | // System.out.println( "size = " + as.size()); | ||
| 189 | ss = as.toArray(); | ||
| 190 | for (int i = 0; i < ss.length ; i++) | ||
| 191 | { | ||
| 192 | // System.out.println( ss[i]); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | }//end of class StringArray | ||
| 196 | |||
| 197 | |||
| 198 |
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | import java.io.*; | ||
| 4 | import java.util.*; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * This class perform similar functionality to StringTokenizer class but faster. | ||
| 8 | * The difference is StringTokenizer doesn't count empty token, but this class does. | ||
| 9 | * | ||
| 10 | * @author Henry Zheng | ||
| 11 | * @url http://www.ireasoning.com | ||
| 12 | */ | ||
| 13 | public class Tokenizer | ||
| 14 | { | ||
| 15 | private Tokenizer() | ||
| 16 | { | ||
| 17 | } | ||
| 18 | |||
| 19 | /** | ||
| 20 | * It's different from the other parse method in that it checks left and right string first, which take higer | ||
| 21 | * priority than the delimiter. For example, if left and right is ", for string a:b:1"c:d"2:3 , | ||
| 22 | * it returns { a, b, 1"c:d"2, 3 } | ||
| 23 | * @param left the openning tag of higher priority token | ||
| 24 | * @param right the closing tag of higher priority token | ||
| 25 | * @trimEachToken if true, each token will be trim by calling String.trim() | ||
| 26 | */ | ||
| 27 | public static String[] parse(String text, char delimiter, boolean trimEachToken, String left, String right) | ||
| 28 | { | ||
| 29 | if(text == null) return null; | ||
| 30 | int len = text.length(); | ||
| 31 | StringArray tokens = new StringArray(); | ||
| 32 | int pos1 = -1; | ||
| 33 | int pos2 = -1; | ||
| 34 | int firstPos = -1; | ||
| 35 | while(true) | ||
| 36 | { | ||
| 37 | pos2 = text.indexOf(delimiter, firstPos + 1); | ||
| 38 | if(pos2 < 0 ) | ||
| 39 | { | ||
| 40 | String str = text.substring(pos1 + 1); | ||
| 41 | if(trimEachToken ) | ||
| 42 | { | ||
| 43 | str = str.trim(); | ||
| 44 | } | ||
| 45 | tokens.add(str); | ||
| 46 | break; | ||
| 47 | } | ||
| 48 | if(pos2 == pos1 + 1) | ||
| 49 | { | ||
| 50 | tokens.add(""); | ||
| 51 | } | ||
| 52 | else | ||
| 53 | { | ||
| 54 | int tagPos1 = text.indexOf(left, firstPos + 1); | ||
| 55 | if(tagPos1 > 0 && tagPos1 < pos2 ) | ||
| 56 | { | ||
| 57 | int tagPos2 = text.indexOf(right, tagPos1 + 1); | ||
| 58 | if(tagPos2 > 0) | ||
| 59 | { | ||
| 60 | firstPos = tagPos2; | ||
| 61 | continue; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | String str = text.substring(pos1 + 1, pos2); | ||
| 65 | if(trimEachToken ) | ||
| 66 | { | ||
| 67 | str = str.trim(); | ||
| 68 | } | ||
| 69 | tokens.add(str); | ||
| 70 | } | ||
| 71 | pos1 = pos2; | ||
| 72 | firstPos = pos1; | ||
| 73 | } | ||
| 74 | String[] ret = tokens.toArray(); | ||
| 75 | return ret; | ||
| 76 | } | ||
| 77 | |||
| 78 | /** | ||
| 79 | * @trimEachToken if true, each token will be trim by calling String.trim() | ||
| 80 | */ | ||
| 81 | public static String[] parse(String text, char delimiter, boolean trimEachToken) | ||
| 82 | { | ||
| 83 | return parse(text, delimiter, trimEachToken, false); | ||
| 84 | } | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @trimEachToken if true, each token will be trim by calling String.trim() | ||
| 88 | */ | ||
| 89 | public static String[] parse(String text, char delimiter, boolean trimEachToken, boolean ignoreEmptyToken) | ||
| 90 | { | ||
| 91 | if(text == null) return null; | ||
| 92 | int len = text.length(); | ||
| 93 | StringArray tokens = new StringArray(); | ||
| 94 | int pos1 = -1; | ||
| 95 | int pos2 = -1; | ||
| 96 | while(true) | ||
| 97 | { | ||
| 98 | pos2 = text.indexOf(delimiter, pos1 + 1); | ||
| 99 | if(pos2 < 0 ) | ||
| 100 | { | ||
| 101 | String str = text.substring(pos1 + 1); | ||
| 102 | if(trimEachToken ) | ||
| 103 | { | ||
| 104 | str = str.trim(); | ||
| 105 | } | ||
| 106 | if(ignoreEmptyToken) | ||
| 107 | { | ||
| 108 | if(str.length() != 0) tokens.add(str); | ||
| 109 | } | ||
| 110 | else | ||
| 111 | { | ||
| 112 | tokens.add(str); | ||
| 113 | } | ||
| 114 | break; | ||
| 115 | } | ||
| 116 | if(pos2 == pos1 + 1) | ||
| 117 | { | ||
| 118 | if(!ignoreEmptyToken) { tokens.add(""); } | ||
| 119 | } | ||
| 120 | else | ||
| 121 | { | ||
| 122 | String str = text.substring(pos1 + 1, pos2); | ||
| 123 | if(trimEachToken ) | ||
| 124 | { | ||
| 125 | str = str.trim(); | ||
| 126 | } | ||
| 127 | if(ignoreEmptyToken) | ||
| 128 | { | ||
| 129 | if(str.length() != 0) tokens.add(str); | ||
| 130 | } | ||
| 131 | else | ||
| 132 | { | ||
| 133 | tokens.add(str); | ||
| 134 | } | ||
| 135 | } | ||
| 136 | pos1 = pos2; | ||
| 137 | } | ||
| 138 | String[] ret = tokens.toArray(); | ||
| 139 | return ret; | ||
| 140 | } | ||
| 141 | |||
| 142 | /** | ||
| 143 | * Does not trim each token. | ||
| 144 | * @see #parse(String, char, boolean) | ||
| 145 | */ | ||
| 146 | public static String[] parse(String text, char delimiter) | ||
| 147 | { | ||
| 148 | return parse(text, delimiter, false); | ||
| 149 | } | ||
| 150 | |||
| 151 | |||
| 152 | public static void main(String[] args) | ||
| 153 | { | ||
| 154 | String str = "1,\"2,\"ab\",ttt1,\"3,,a\"222\",4"; | ||
| 155 | if(args.length > 0) | ||
| 156 | { | ||
| 157 | str = args[0]; | ||
| 158 | } | ||
| 159 | // String [] tokens = Tokenizer.parse(str, ','); | ||
| 160 | // | ||
| 161 | //// System.out.println( "Text = (" + str + ")"); | ||
| 162 | // // System.out.println( "------------------------------------------"); | ||
| 163 | // for (int i = 0; i < tokens.length ; i++) | ||
| 164 | // { | ||
| 165 | // // System.out.println( "(" + tokens[i] + ")"); | ||
| 166 | // } | ||
| 167 | // // System.out.println( "------------------------------------------"); | ||
| 168 | |||
| 169 | // String [] tokens = Tokenizer.parse(str, ',', new String[]{"("}, new String[]{")"}); | ||
| 170 | // | ||
| 171 | // // System.out.println( "Text = [" + str + "]"); | ||
| 172 | // // System.out.println( "------------------------------------------"); | ||
| 173 | // for (int i = 0; i < tokens.length ; i++) | ||
| 174 | // { | ||
| 175 | // // System.out.println( "[" + tokens[i] + "]"); | ||
| 176 | // } | ||
| 177 | // // System.out.println( "------------------------------------------"); | ||
| 178 | |||
| 179 | } | ||
| 180 | }//end of class Tokenizer | ||
| 181 | |||
| 182 | |||
| 183 |
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | import java.util.Random; | ||
| 4 | import java.io.*; | ||
| 5 | |||
| 6 | import org.emercit.szs.szsterminal.*; | ||
| 7 | |||
| 8 | import java.util.regex.*; | ||
| 9 | |||
| 10 | public class Util { | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | public static void SettingsNetwork() { | ||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | } | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | public static final String reverse(String str) { | ||
| 41 | if (str.length() <= 1) | ||
| 42 | return str; | ||
| 43 | |||
| 44 | String result = ""; | ||
| 45 | |||
| 46 | result += str.charAt(str.length() - 1) | ||
| 47 | + reverse(str.substring(0, str.length() - 1)); | ||
| 48 | |||
| 49 | return result; | ||
| 50 | } | ||
| 51 | |||
| 52 | public static boolean[] toBinary(int number, int base) { | ||
| 53 | final boolean[] ret = new boolean[base]; | ||
| 54 | for (int i = 0; i < base; i++) { | ||
| 55 | |||
| 56 | ret[base - 1 - i] = (1 << i & number) != 0; | ||
| 57 | |||
| 58 | } | ||
| 59 | return ret; | ||
| 60 | |||
| 61 | } | ||
| 62 | |||
| 63 | public static double round(double value, int places) { | ||
| 64 | |||
| 65 | if (places < 0) | ||
| 66 | throw new IllegalArgumentException(); | ||
| 67 | |||
| 68 | long factor = (long) Math.pow(10, places); | ||
| 69 | value = value * factor; | ||
| 70 | long tmp = Math.round(value); | ||
| 71 | |||
| 72 | return (double) tmp / factor; | ||
| 73 | } | ||
| 74 | |||
| 75 | public static int randInt(int min, int max) { | ||
| 76 | |||
| 77 | Random rand = new Random(); | ||
| 78 | int randomNum = rand.nextInt((max - min) + 1) + min; | ||
| 79 | |||
| 80 | return randomNum; | ||
| 81 | |||
| 82 | } | ||
| 83 | |||
| 84 | public static String DoubleToString(double d) { | ||
| 85 | |||
| 86 | String result = String.valueOf(d); | ||
| 87 | String buff = ""; | ||
| 88 | int i = 0; | ||
| 89 | while (result.charAt(i) != '.') { | ||
| 90 | buff += result.charAt(i); | ||
| 91 | i++; | ||
| 92 | } | ||
| 93 | buff += result.charAt(i); // '.' | ||
| 94 | buff += result.charAt(i + 1); // 1 число после точки | ||
| 95 | |||
| 96 | return buff; | ||
| 97 | } | ||
| 98 | |||
| 99 | // представление дробной части | ||
| 100 | public static final int Drob(String str) { | ||
| 101 | double j = 0; | ||
| 102 | |||
| 103 | str = reverse(str); | ||
| 104 | |||
| 105 | for (int i = 0; i < str.length(); i++) { | ||
| 106 | if (str.charAt(i) == '1') { | ||
| 107 | j = j + Math.pow(2, str.length() - 1 - i); | ||
| 108 | } | ||
| 109 | |||
| 110 | } | ||
| 111 | return (int) j; | ||
| 112 | } | ||
| 113 | |||
| 114 | public static final byte[] stringToBytesASCII(char[] buffer) { | ||
| 115 | |||
| 116 | byte[] b = new byte[buffer.length]; | ||
| 117 | for (int i = 0; i < b.length; i++) { | ||
| 118 | b[i] = (byte) buffer[i]; | ||
| 119 | } | ||
| 120 | return b; | ||
| 121 | } | ||
| 122 | |||
| 123 | private static String ParserID(String input) { | ||
| 124 | |||
| 125 | String pattern = "id=[0-9]*"; | ||
| 126 | |||
| 127 | Pattern r = Pattern.compile(pattern); | ||
| 128 | |||
| 129 | Matcher m = r.matcher(input); | ||
| 130 | if (m.find()) { | ||
| 131 | |||
| 132 | String buff = m.group(0); | ||
| 133 | if (buff.length() >= 12) { | ||
| 134 | char[] str = buff.toCharArray(); | ||
| 135 | String res = ""; | ||
| 136 | for (int i = 3; i < buff.length(); i++) | ||
| 137 | res += str[i]; | ||
| 138 | |||
| 139 | return res; | ||
| 140 | |||
| 141 | } | ||
| 142 | |||
| 143 | } | ||
| 144 | return ""; | ||
| 145 | } | ||
| 146 | |||
| 147 | |||
| 148 | |||
| 149 | } | ||
| 150 | |||
| 151 | |||
| 152 | |||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | |||
| 161 | |||
| 162 | |||
| 163 | |||
| 164 | |||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | |||
| 169 | |||
| 170 | |||
| 171 | |||
| 172 | |||
| 173 | |||
| 174 | |||
| 175 | |||
| 176 | |||
| 177 | |||
| 178 | |||
| 179 | |||
| 180 | |||
| 181 | |||
| 182 | |||
| 183 | |||
| 184 | |||
| 185 |
| 1 | package org.emercit.szs.model; | ||
| 2 | |||
| 3 | |||
| 4 | import java.io.*; | ||
| 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.*; | ||
| 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.*; | ||
| 36 | |||
| 37 | 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; | ||
| 45 | import org.emercit.szs.service.Gprs; | ||
| 46 | import org.emercit.szs.service.SData; | ||
| 47 | |||
| 48 | import org.emercit.szs.model.MsgSzs; | ||
| 49 | |||
| 50 | |||
| 51 | public class WebPost { | ||
| 52 | |||
| 53 | |||
| 54 | private static final Logger log = Logger.getLogger(WebPost.class); | ||
| 55 | |||
| 56 | private String ip; | ||
| 57 | |||
| 58 | private String guid; | ||
| 59 | |||
| 60 | private String gsm; | ||
| 61 | |||
| 62 | private Gprs gprs; | ||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | public WebPost() { | ||
| 67 | |||
| 68 | this.guid=Config.devinfobean.getGuid(); | ||
| 69 | this.ip=Config.serverbean.getIp()+":"+Config.serverbean.getPort(); | ||
| 70 | this.gsm=Config.gsmbean.getOperator(); | ||
| 71 | this.gprs=new Gprs(this.gsm); | ||
| 72 | |||
| 73 | print(); | ||
| 74 | } | ||
| 75 | |||
| 76 | private void print() { | ||
| 77 | log.info("guid:"+this.guid); | ||
| 78 | log.info("ip:"+this.ip); | ||
| 79 | log.info("gsm:"+this.gsm); | ||
| 80 | |||
| 81 | } | ||
| 82 | |||
| 83 | |||
| 84 | public ModelResponse Request() { | ||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | ModelResponse md = new ModelResponse(); | ||
| 89 | md.lsteventagkconfirm=new ArrayList<EventAgk>(); | ||
| 90 | md.lsteventagkstate=new ArrayList<EventAgk>(); | ||
| 91 | |||
| 92 | StringBuilder sb = new StringBuilder(); | ||
| 93 | |||
| 94 | HttpURLConnection urlConnection = null; | ||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | BufferedReader br=null; | ||
| 99 | |||
| 100 | try { | ||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | URL url = new URL("http://"+ip+"/api/lss_info.php"+"?guid="+guid); | ||
| 105 | |||
| 106 | urlConnection = (HttpURLConnection) url | ||
| 107 | .openConnection(); | ||
| 108 | |||
| 109 | urlConnection.setDoOutput(true); | ||
| 110 | urlConnection.setRequestMethod("GET"); | ||
| 111 | urlConnection.setRequestProperty("Content-Type", "application/xml"); | ||
| 112 | |||
| 113 | urlConnection.setConnectTimeout(45000); | ||
| 114 | urlConnection.setReadTimeout(60000); | ||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | urlConnection.connect(); | ||
| 119 | int HttpResult = urlConnection.getResponseCode(); | ||
| 120 | |||
| 121 | if (HttpResult == HttpURLConnection.HTTP_OK) { | ||
| 122 | |||
| 123 | |||
| 124 | |||
| 125 | InputStream xml = urlConnection.getInputStream(); | ||
| 126 | |||
| 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 | } | ||
| 160 | |||
| 161 | /* | ||
| 162 | * Текущее состояние станций | ||
| 163 | */ | ||
| 164 | list = doc.getElementsByTagName("deviceList"); | ||
| 165 | element = (Element)list.item(0); | ||
| 166 | nl=element.getElementsByTagName("device"); | ||
| 167 | |||
| 168 | if(nl != null && nl.getLength() > 0) { | ||
| 169 | for(int i = 0 ; i < nl.getLength();i++) { | ||
| 170 | |||
| 171 | Element el = (Element)nl.item(i); | ||
| 172 | try { | ||
| 173 | EventAgk event=new EventAgk(); | ||
| 174 | |||
| 175 | event.name=getTextValue(el,"name"); | ||
| 176 | event.id_agk=Integer.valueOf(getTextValue(el,"guid")); | ||
| 177 | event.id_status=Integer.valueOf(getTextValue(el,"alarm")); | ||
| 178 | |||
| 179 | md.lsteventagkstate.add(event); | ||
| 180 | |||
| 181 | } catch(Exception e) { | ||
| 182 | log.error(e.getMessage()); | ||
| 183 | } | ||
| 184 | } | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | urlConnection.disconnect(); | ||
| 189 | |||
| 190 | } catch (Exception e) { | ||
| 191 | log.error(e.getMessage()); | ||
| 192 | log.error(MsgSzs.connectServerError); | ||
| 193 | |||
| 194 | gprs.Reconnect(); | ||
| 195 | |||
| 196 | } finally { | ||
| 197 | |||
| 198 | |||
| 199 | try { | ||
| 200 | if (urlConnection != null) { | ||
| 201 | urlConnection.disconnect(); | ||
| 202 | } | ||
| 203 | if (br!=null) { | ||
| 204 | br.close(); | ||
| 205 | } | ||
| 206 | |||
| 207 | } catch (Exception ex) { | ||
| 208 | log.error(ex.getMessage()); | ||
| 209 | log.error(MsgSzs.connectServerError); | ||
| 210 | |||
| 211 | gprs.Reconnect(); | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | |||
| 216 | |||
| 217 | |||
| 218 | |||
| 219 | |||
| 220 | |||
| 221 | return md; | ||
| 222 | |||
| 223 | } | ||
| 224 | |||
| 225 | |||
| 226 | |||
| 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 | |||
| 246 | |||
| 247 | HttpURLConnection urlConnection = null; | ||
| 248 | try { | ||
| 249 | |||
| 250 | |||
| 251 | URL url = new URL("http://"+ip+"/api/lss_confirm.php"+"?guid="+guid+"&alarm="+alarm); | ||
| 252 | |||
| 253 | urlConnection = (HttpURLConnection) url | ||
| 254 | .openConnection(); | ||
| 255 | |||
| 256 | |||
| 257 | urlConnection.setDoOutput(true); | ||
| 258 | urlConnection.setRequestMethod("GET"); | ||
| 259 | urlConnection.setRequestProperty("Content-Type", | ||
| 260 | "application/json"); | ||
| 261 | |||
| 262 | |||
| 263 | urlConnection.setConnectTimeout(5000); | ||
| 264 | urlConnection.setReadTimeout(10000); | ||
| 265 | |||
| 266 | urlConnection.connect(); | ||
| 267 | |||
| 268 | int HttpResult = urlConnection.getResponseCode(); | ||
| 269 | |||
| 270 | if (HttpResult == HttpURLConnection.HTTP_OK) { | ||
| 271 | |||
| 272 | } | ||
| 273 | |||
| 274 | urlConnection.disconnect(); | ||
| 275 | } catch (Exception e) { | ||
| 276 | |||
| 277 | log.error(e.getMessage()); | ||
| 278 | log.error(MsgSzs.connectServerError); | ||
| 279 | |||
| 280 | } finally { | ||
| 281 | try { | ||
| 282 | if (urlConnection != null) { | ||
| 283 | urlConnection.disconnect(); | ||
| 284 | } | ||
| 285 | } catch (Exception ex) { | ||
| 286 | log.error(ex.getMessage()); | ||
| 287 | log.error(MsgSzs.connectServerError); | ||
| 288 | |||
| 289 | } | ||
| 290 | } | ||
| 291 | |||
| 292 | |||
| 293 | } | ||
| 294 | |||
| 295 | |||
| 296 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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 | } |
| 1 | package org.emercit.szs.service; | ||
| 2 | |||
| 3 | import java.util.ArrayList; | ||
| 4 | import java.util.List; | ||
| 5 | |||
| 6 | import org.emercit.szs.model.EventAgk; | ||
| 7 | import org.emercit.szs.model.MdlEvent; | ||
| 8 | import org.emercit.szs.model.ModelResponse; | ||
| 9 | import org.emercit.szs.model.WebPost; | ||
| 10 | import org.emercit.szs.szsterminal.SZSTerminal; | ||
| 11 | |||
| 12 | |||
| 13 | @javax.inject.Singleton | ||
| 14 | public enum SData { | ||
| 15 | |||
| 16 | INSTANCE; | ||
| 17 | |||
| 18 | |||
| 19 | private ModelResponse data; | ||
| 20 | |||
| 21 | private boolean IsConnect; | ||
| 22 | |||
| 23 | private boolean IsOpenDialog=false; | ||
| 24 | |||
| 25 | private WebPost webpost=new WebPost(); | ||
| 26 | |||
| 27 | /* | ||
| 28 | * Получение данных с веб сервиса | ||
| 29 | */ | ||
| 30 | public void Scan() { | ||
| 31 | if (!IsOpenDialog) { | ||
| 32 | this.data= webpost.Request(); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | /* | ||
| 37 | * Получение текущего состояния датчиков | ||
| 38 | */ | ||
| 39 | public ModelResponse getData() { | ||
| 40 | return this.data; | ||
| 41 | } | ||
| 42 | |||
| 43 | /* | ||
| 44 | * Подтверждение события | ||
| 45 | */ | ||
| 46 | |||
| 47 | public void Confirm(MdlEvent mdlevent) { | ||
| 48 | |||
| 49 | webpost.Confirm(mdlevent.getId()); | ||
| 50 | |||
| 51 | this.IsOpenDialog=false; | ||
| 52 | |||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | /* | ||
| 57 | * Связь с сервисом | ||
| 58 | */ | ||
| 59 | public boolean isConnect() { | ||
| 60 | return this.IsConnect; | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | public void setIsConnect(boolean value) { | ||
| 65 | this.IsConnect=value; | ||
| 66 | } | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Удаление события для подтверждеия | ||
| 70 | */ | ||
| 71 | public void RemoveEvent() { | ||
| 72 | this.data.lsteventagkconfirm.clear(); | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | /* | ||
| 77 | * | ||
| 78 | */ | ||
| 79 | public boolean getIsOpenDialog() { | ||
| 80 | return this.IsOpenDialog; | ||
| 81 | |||
| 82 | } | ||
| 83 | |||
| 84 | /* | ||
| 85 | * | ||
| 86 | */ | ||
| 87 | public void setIsOpenDialog(boolean value) { | ||
| 88 | |||
| 89 | this.IsOpenDialog=value; | ||
| 90 | } | ||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | } | ||
| 97 |
| 1 | package org.emercit.szs.service; | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | import java.io.File; | ||
| 6 | import java.io.FileInputStream; | ||
| 7 | import java.io.FileNotFoundException; | ||
| 8 | import java.io.FileOutputStream; | ||
| 9 | import java.io.IOException; | ||
| 10 | import java.io.InputStream; | ||
| 11 | import java.io.ObjectInputStream; | ||
| 12 | import java.io.ObjectOutputStream; | ||
| 13 | |||
| 14 | import org.apache.log4j.Logger; | ||
| 15 | |||
| 16 | import com.jcraft.jsch.Channel; | ||
| 17 | import com.jcraft.jsch.ChannelExec; | ||
| 18 | import com.jcraft.jsch.JSch; | ||
| 19 | import com.jcraft.jsch.Session; | ||
| 20 | |||
| 21 | |||
| 22 | import java.io.*; | ||
| 23 | |||
| 24 | |||
| 25 | public class Ssh { | ||
| 26 | |||
| 27 | private String host="127.0.0.1"; | ||
| 28 | private String user; | ||
| 29 | private String password; | ||
| 30 | |||
| 31 | public Ssh(String user,String password) { | ||
| 32 | |||
| 33 | this.user=user; | ||
| 34 | this.password=password; | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
| 38 | public boolean ExecCmd(String cmd) { | ||
| 39 | |||
| 40 | try{ | ||
| 41 | |||
| 42 | java.util.Properties config = new java.util.Properties(); | ||
| 43 | config.put("StrictHostKeyChecking", "no"); | ||
| 44 | JSch jsch = new JSch(); | ||
| 45 | Session session=jsch.getSession(user, host, 22); | ||
| 46 | session.setPassword(password); | ||
| 47 | session.setConfig(config); | ||
| 48 | session.connect(); | ||
| 49 | |||
| 50 | Channel channel=session.openChannel("exec"); | ||
| 51 | |||
| 52 | ((ChannelExec)channel).setCommand("sudo -S -p '' "+cmd); | ||
| 53 | |||
| 54 | InputStream in=channel.getInputStream(); | ||
| 55 | OutputStream out=channel.getOutputStream(); | ||
| 56 | ((ChannelExec)channel).setErrStream(System.err); | ||
| 57 | |||
| 58 | channel.connect(); | ||
| 59 | |||
| 60 | out.write((password+"\n").getBytes()); | ||
| 61 | out.flush(); | ||
| 62 | |||
| 63 | byte[] tmp=new byte[1024]; | ||
| 64 | while(true){ | ||
| 65 | while(in.available()>0){ | ||
| 66 | int i=in.read(tmp, 0, 1024); | ||
| 67 | if(i<0)break; | ||
| 68 | // System.out.print(new String(tmp, 0, i)); | ||
| 69 | } | ||
| 70 | if(channel.isClosed()){ | ||
| 71 | |||
| 72 | break; | ||
| 73 | } | ||
| 74 | try{Thread.sleep(1000);}catch(Exception ee){} | ||
| 75 | } | ||
| 76 | channel.disconnect(); | ||
| 77 | session.disconnect(); | ||
| 78 | |||
| 79 | |||
| 80 | }catch(Exception e){ | ||
| 81 | return false; | ||
| 82 | } | ||
| 83 | |||
| 84 | return true; | ||
| 85 | } | ||
| 86 | } |
| 1 | package org.emercit.szs.service; | ||
| 2 | |||
| 3 | |||
| 4 | import org.apache.log4j.Logger; | ||
| 5 | import org.emercit.szs.service.SData; | ||
| 6 | |||
| 7 | |||
| 8 | public class TScan implements Runnable{ | ||
| 9 | |||
| 10 | static final Logger logger = Logger.getLogger(TScan.class); | ||
| 11 | |||
| 12 | public TScan() { | ||
| 13 | |||
| 14 | } | ||
| 15 | |||
| 16 | public void run() { | ||
| 17 | |||
| 18 | while(true) { | ||
| 19 | try { | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | SData.INSTANCE.Scan(); | ||
| 25 | |||
| 26 | |||
| 27 | Thread.sleep(3000); | ||
| 28 | |||
| 29 | } | ||
| 30 | catch(Exception e) { | ||
| 31 | |||
| 32 | //logger.error(e.getMessage()); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szs.szsterminal; | ||
| 2 | |||
| 3 | import java.awt.BorderLayout; | ||
| 4 | import java.awt.EventQueue; | ||
| 5 | |||
| 6 | import javax.swing.JFrame; | ||
| 7 | import javax.swing.JPanel; | ||
| 8 | |||
| 9 | import java.awt.Color; | ||
| 10 | import java.awt.GridLayout; | ||
| 11 | import java.awt.GridBagLayout; | ||
| 12 | import java.awt.GridBagConstraints; | ||
| 13 | |||
| 14 | import javax.swing.border.BevelBorder; | ||
| 15 | import javax.swing.border.CompoundBorder; | ||
| 16 | import javax.swing.border.SoftBevelBorder; | ||
| 17 | import javax.swing.JLabel; | ||
| 18 | import javax.swing.JTable; | ||
| 19 | import javax.swing.border.LineBorder; | ||
| 20 | |||
| 21 | import java.awt.Dimension; | ||
| 22 | |||
| 23 | import javax.swing.table.TableModel; | ||
| 24 | |||
| 25 | import java.util.ArrayList; | ||
| 26 | import java.util.List; | ||
| 27 | import java.util.TimeZone; | ||
| 28 | import java.util.Timer; | ||
| 29 | import java.util.TimerTask; | ||
| 30 | import java.util.Date; | ||
| 31 | import java.text.DateFormat; | ||
| 32 | import java.text.SimpleDateFormat; | ||
| 33 | import java.util.Calendar; | ||
| 34 | |||
| 35 | import javax.swing.SwingWorker; | ||
| 36 | import javax.swing.JButton; | ||
| 37 | import javax.swing.ImageIcon; | ||
| 38 | |||
| 39 | import java.awt.Font; | ||
| 40 | |||
| 41 | import javax.swing.*; | ||
| 42 | |||
| 43 | import java.awt.event.ActionListener; | ||
| 44 | import java.awt.event.ActionEvent; | ||
| 45 | |||
| 46 | import javax.swing.event.ChangeListener; | ||
| 47 | import javax.swing.event.ChangeEvent; | ||
| 48 | |||
| 49 | import java.awt.Toolkit; | ||
| 50 | import java.awt.Rectangle; | ||
| 51 | import java.io.BufferedReader; | ||
| 52 | import java.io.BufferedWriter; | ||
| 53 | import java.io.FileWriter; | ||
| 54 | import java.io.IOException; | ||
| 55 | import java.io.InputStreamReader; | ||
| 56 | import java.io.OutputStreamWriter; | ||
| 57 | import java.io.PrintWriter; | ||
| 58 | import java.net.HttpURLConnection; | ||
| 59 | import java.net.InetSocketAddress; | ||
| 60 | import java.net.Proxy; | ||
| 61 | import java.net.URL; | ||
| 62 | import java.util.Scanner; | ||
| 63 | import java.awt.Dialog.ModalExclusionType; | ||
| 64 | import java.awt.*; | ||
| 65 | import java.awt.event.*; | ||
| 66 | |||
| 67 | import javax.swing.*; | ||
| 68 | |||
| 69 | import com.google.gson.Gson; | ||
| 70 | |||
| 71 | import java.beans.*; | ||
| 72 | |||
| 73 | import org.emercit.szs.components.*; | ||
| 74 | import org.emercit.szs.model.*; | ||
| 75 | import org.emercit.szs.service.*; | ||
| 76 | import org.emercit.utilstools.devinfo.service.DevInfo; | ||
| 77 | import org.apache.log4j.Logger; | ||
| 78 | import org.apache.log4j.BasicConfigurator; | ||
| 79 | import org.apache.log4j.PropertyConfigurator; | ||
| 80 | import org.emercit.szs.model.Config; | ||
| 81 | |||
| 82 | public class SZSTerminal { | ||
| 83 | |||
| 84 | private static final Logger log = Logger.getLogger(SZSTerminal.class); | ||
| 85 | |||
| 86 | private static String version="1.0.0.0"; | ||
| 87 | |||
| 88 | |||
| 89 | |||
| 90 | private static JFrame mainFrame; | ||
| 91 | private static JPanel mainPanel; | ||
| 92 | |||
| 93 | public static JPnlCurrent pnlcurrent; | ||
| 94 | public static JPnlLog jpnllog; | ||
| 95 | public static JPnlContacts jpnlcontacts; | ||
| 96 | public static JPnlControl jpnlcontrol; | ||
| 97 | |||
| 98 | private static Timer ftdTimerMain = new Timer(); | ||
| 99 | |||
| 100 | public static DlgConfirm dlgconfirm; | ||
| 101 | |||
| 102 | public static JPnlHeader jpnlheader = new JPnlHeader(); | ||
| 103 | |||
| 104 | private static class ftdTimerTask extends TimerTask { | ||
| 105 | |||
| 106 | @Override | ||
| 107 | public void run() { | ||
| 108 | EventQueue.invokeLater(new Runnable() { | ||
| 109 | |||
| 110 | // @Override | ||
| 111 | public void run() { | ||
| 112 | |||
| 113 | Calendar calendar = Calendar.getInstance(); | ||
| 114 | |||
| 115 | TimeZone.setDefault(TimeZone.getTimeZone("Europe/Moscow")); | ||
| 116 | |||
| 117 | TimeZone timeZone = calendar.getTimeZone(); | ||
| 118 | |||
| 119 | Date date=calendar.getTime(); | ||
| 120 | jpnlheader.UpdateTime(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date())); | ||
| 121 | |||
| 122 | if (SData.INSTANCE.isConnect()){ | ||
| 123 | |||
| 124 | /* | ||
| 125 | * Текущее состояние датчиков | ||
| 126 | */ | ||
| 127 | new SwingWorker<Void, Void>() | ||
| 128 | { | ||
| 129 | protected Void doInBackground() throws Exception | ||
| 130 | { | ||
| 131 | |||
| 132 | List<MdlEvent> lstEvent = new ArrayList<MdlEvent>(); | ||
| 133 | |||
| 134 | ModelResponse mdl=SData.INSTANCE.getData(); | ||
| 135 | if(mdl.lsteventagkstate.size()!=0) { | ||
| 136 | |||
| 137 | for (EventAgk event:mdl.lsteventagkstate) { | ||
| 138 | MdlEvent ev = new MdlEvent(event.id_agk,event.name,event.id_status); | ||
| 139 | lstEvent.add(ev); | ||
| 140 | } | ||
| 141 | |||
| 142 | pnlcurrent.setListEventCurrent(lstEvent); | ||
| 143 | |||
| 144 | } | ||
| 145 | |||
| 146 | return null; | ||
| 147 | } | ||
| 148 | }.execute(); | ||
| 149 | |||
| 150 | /* | ||
| 151 | * События для подтверждения | ||
| 152 | */ | ||
| 153 | new SwingWorker<Void, Void>() | ||
| 154 | { | ||
| 155 | protected Void doInBackground() throws Exception | ||
| 156 | { | ||
| 157 | |||
| 158 | |||
| 159 | ModelResponse mdl=SData.INSTANCE.getData(); | ||
| 160 | |||
| 161 | |||
| 162 | |||
| 163 | for (EventAgk eventagk : mdl.lsteventagkconfirm) { | ||
| 164 | |||
| 165 | |||
| 166 | SData.INSTANCE.RemoveEvent(); | ||
| 167 | |||
| 168 | MdlEvent ev = new MdlEvent(eventagk.id, | ||
| 169 | eventagk.name, | ||
| 170 | eventagk.id_agk, | ||
| 171 | eventagk.datetime, | ||
| 172 | eventagk.id_status, | ||
| 173 | eventagk.message | ||
| 174 | ); | ||
| 175 | |||
| 176 | ev.setSiren(true); | ||
| 177 | ev.setCountAnimate(15); | ||
| 178 | ev.setCountSound(2); | ||
| 179 | |||
| 180 | |||
| 181 | dlgconfirm.setEvent(ev); | ||
| 182 | |||
| 183 | dlgconfirm.setVisible(true); | ||
| 184 | |||
| 185 | } | ||
| 186 | return null; | ||
| 187 | } | ||
| 188 | |||
| 189 | }.execute(); | ||
| 190 | } | ||
| 191 | |||
| 192 | } | ||
| 193 | }); | ||
| 194 | } | ||
| 195 | |||
| 196 | } | ||
| 197 | |||
| 198 | public static void main(String[] args) { | ||
| 199 | |||
| 200 | EventQueue.invokeLater(new Runnable() { | ||
| 201 | public void run() { | ||
| 202 | |||
| 203 | |||
| 204 | |||
| 205 | |||
| 206 | mainFrame = new JFrame(); | ||
| 207 | mainFrame.setSize(800, 500); | ||
| 208 | mainFrame.setUndecorated(true); | ||
| 209 | mainFrame.setResizable(false); | ||
| 210 | mainFrame.setVisible(true); | ||
| 211 | mainPanel = new JPanel(); | ||
| 212 | |||
| 213 | Toolkit tk = Toolkit.getDefaultToolkit(); | ||
| 214 | |||
| 215 | int xSize = ((int) tk.getScreenSize().getWidth()); | ||
| 216 | int ySize = ((int) tk.getScreenSize().getHeight()); | ||
| 217 | |||
| 218 | //mainFrame.setSize(xSize,ySize); | ||
| 219 | mainPanel.setBackground(UIManager.getColor("Separator.foreground")); | ||
| 220 | mainPanel.setBounds(0, 0, xSize, ySize); | ||
| 221 | |||
| 222 | |||
| 223 | jpnlheader.setBounds(10, 5, 780, 40); | ||
| 224 | jpnlheader.setBackground(new Color(168, 181, 224)); | ||
| 225 | mainPanel.add(jpnlheader); | ||
| 226 | |||
| 227 | // pnlcurrent.setBounds(10, 70, 770, 470); | ||
| 228 | List<Event> lstevent = new ArrayList<Event>(); | ||
| 229 | |||
| 230 | JTabbedPane jtp = new JTabbedPane(); | ||
| 231 | jtp.setFont(new Font("Tahoma", Font.PLAIN, 14)); | ||
| 232 | mainPanel.add(jtp); | ||
| 233 | jtp.setBounds(10, 50, 780, 450); | ||
| 234 | |||
| 235 | ImageIcon imgJournal = new ImageIcon(getClass().getResource( | ||
| 236 | "/journal.png")); | ||
| 237 | ImageIcon imgCurrent = new ImageIcon(getClass().getResource( | ||
| 238 | "/current.png")); | ||
| 239 | // ImageIcon imgContact = new ImageIcon(getClass().getResource( | ||
| 240 | // "/contacts.png")); | ||
| 241 | //ImageIcon imgControl = new ImageIcon(getClass().getResource( | ||
| 242 | // "/update.png")); | ||
| 243 | |||
| 244 | pnlcurrent = new JPnlCurrent(); | ||
| 245 | jtp.addTab("Текущее состояние", imgCurrent, pnlcurrent); | ||
| 246 | |||
| 247 | jpnllog = new JPnlLog(); | ||
| 248 | jtp.addTab("Журнал", imgJournal, jpnllog); | ||
| 249 | |||
| 250 | jpnlcontrol = new JPnlControl(); | ||
| 251 | jtp.addTab("Управление", null, jpnlcontrol); | ||
| 252 | |||
| 253 | mainFrame.setAlwaysOnTop(true); | ||
| 254 | |||
| 255 | dlgconfirm=new DlgConfirm(); | ||
| 256 | |||
| 257 | mainPanel.setBackground(UIManager | ||
| 258 | .getColor("Separator.foreground")); | ||
| 259 | |||
| 260 | |||
| 261 | mainPanel.setLayout(null); | ||
| 262 | mainFrame.getContentPane().add(mainPanel); | ||
| 263 | |||
| 264 | log.info("Запуск приложения CtrlPnl."+ " Версия:"+version); | ||
| 265 | log.info(Config.devinfobean.getDescription()); | ||
| 266 | |||
| 267 | Runnable rTScan = new TScan(); | ||
| 268 | |||
| 269 | Thread tScan = new Thread(rTScan); | ||
| 270 | tScan.start(); | ||
| 271 | |||
| 272 | ftdTimerMain.schedule(new ftdTimerTask(), 0, 1000); | ||
| 273 | |||
| 274 | EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table | ||
| 275 | .getModel(); | ||
| 276 | |||
| 277 | SZSTerminal.jpnllog.Upd(); | ||
| 278 | |||
| 279 | |||
| 280 | } | ||
| 281 | }); | ||
| 282 | } | ||
| 283 | } |
SzsBb/src/main/resources/Alarm.wav
0 → 100755
No preview for this file type
SzsBb/src/main/resources/bottom.png
0 → 100755
3.02 KB
SzsBb/src/main/resources/circle.png
0 → 100755
1.32 KB
SzsBb/src/main/resources/clock.png
0 → 100755
2.32 KB
SzsBb/src/main/resources/closedoor.png
0 → 100755
18.3 KB
SzsBb/src/main/resources/connect_service.png
0 → 100755
2.16 KB
SzsBb/src/main/resources/contacts.png
0 → 100755
745 Bytes
SzsBb/src/main/resources/current.png
0 → 100755
1.59 KB
SzsBb/src/main/resources/desktop.ini
0 → 100755
| 1 | [LocalizedFileNames] | ||
| 2 | notify.wav=@%windir%\system32\mmres.dll,-706 | ||
| 3 | Windows Minimize.wav=@%windir%\system32\mmres.dll,-726 | ||
| 4 | Windows Startup.wav=@%windir%\system32\mmres.dll,-735 | ||
| 5 | Windows Notify.wav=@%windir%\system32\mmres.dll,-727 | ||
| 6 | Windows Pop-up Blocked.wav=@%windir%\system32\mmres.dll,-737 | ||
| 7 | tada.wav=@%windir%\system32\mmres.dll,-710 |
1.9 KB
SzsBb/src/main/resources/down.png
0 → 100755
1.23 KB
SzsBb/src/main/resources/good.png
0 → 100755
813 Bytes
SzsBb/src/main/resources/green.png
0 → 100755
4.69 KB
SzsBb/src/main/resources/journal.png
0 → 100755
1.99 KB
SzsBb/src/main/resources/log4j.properties
0 → 100644
| 1 | log4j.rootLogger=debug,stdout,server | ||
| 2 | |||
| 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
| 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
| 5 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSSS} %p %t %c \u2013 %m%n | ||
| 6 | |||
| 7 | |||
| 8 | log4j.appender.server=org.apache.log4j.net.SocketAppender | ||
| 9 | log4j.appender.server.Port=4560 | ||
| 10 | log4j.appender.server.RemoteHost=localhost | ||
| 11 | log4j.appender.server.ReconnectionDelay=10000 | ||
| 12 | log4j.appender.server.Application=ctrlpnl | ||
| 13 | log4j.appender.server.LocationInfo=true | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
SzsBb/src/main/resources/notification.png
0 → 100755
4.67 KB
SzsBb/src/main/resources/offDevice.png
0 → 100755
6.08 KB
SzsBb/src/main/resources/opendoor.png
0 → 100755
2.96 KB
SzsBb/src/main/resources/red.png
0 → 100755
2.93 KB
SzsBb/src/main/resources/reloadDevice.png
0 → 100755
3.19 KB
SzsBb/src/main/resources/repair.png
0 → 100755
1.03 KB
SzsBb/src/main/resources/replay.png
0 → 100755
1.81 KB
SzsBb/src/main/resources/river.png
0 → 100755
15.3 KB
SzsBb/src/main/resources/running.png
0 → 100755
3.78 KB
SzsBb/src/main/resources/siren.png
0 → 100644
2.39 KB
SzsBb/src/main/resources/sound.png
0 → 100644
1.95 KB
SzsBb/src/main/resources/start.png
0 → 100755
1.47 KB
SzsBb/src/main/resources/stop.png
0 → 100755
424 Bytes
SzsBb/src/main/resources/top.png
0 → 100755
3.31 KB
SzsBb/src/main/resources/up.png
0 → 100755
1.13 KB
SzsBb/src/main/resources/update.png
0 → 100755
1.3 KB
SzsBb/src/main/resources/veracityfalse.png
0 → 100755
3.82 KB
SzsBb/src/main/resources/veracitytrue.png
0 → 100755
4.59 KB
SzsBb/src/main/resources/yellow.png
0 → 100755
2.11 KB
-
Please register or sign in to post a comment