@Override public void run() { try { receive(); } catch (IOException ioException) { JOptionPane.showMessageDialog(null, "Problems with a server"); } catch (InterruptedException interruptedException) { JOptionPane.showMessageDialog(null, "Interrupted exception thrown"); } catch (ParserConfigurationException parserException) { parserException.printStackTrace(); } catch (SAXException saxException) { saxException.printStackTrace(); } }
@Override protected void handleInitComponentError( final Throwable ex, final boolean fatal, final String componentClassName) { if (PluginManager.isPluginClass(componentClassName)) { LOG.error(ex); PluginId pluginId = PluginManager.getPluginByClassName(componentClassName); @NonNls final String errorMessage = "Plugin " + pluginId.getIdString() + " failed to initialize and will be disabled:\n" + ex.getMessage() + "\nPlease restart " + ApplicationNamesInfo.getInstance().getFullProductName() + "."; PluginManager.disablePlugin(pluginId.getIdString()); if (!myHeadlessMode) { JOptionPane.showMessageDialog(null, errorMessage); } else { //noinspection UseOfSystemOutOrSystemErr System.out.println(errorMessage); System.exit(1); } return; // do not call super } if (fatal) { LOG.error(ex); @NonNls final String errorMessage = "Fatal error initializing class " + componentClassName + ":\n" + ex.toString() + "\nComplete error stacktrace was written to idea.log"; if (!myHeadlessMode) { JOptionPane.showMessageDialog(null, errorMessage); } else { //noinspection UseOfSystemOutOrSystemErr System.out.println(errorMessage); } } super.handleInitComponentError(ex, fatal, componentClassName); }
public TaskWrite(Map map1, Map m_max, Map m_min, DBCollection coll, ModbusSlaveSet slave) { try { synchronized (slave) { Calendar calener = Calendar.getInstance(); Date d1 = calener.getTime(); Date d2 = new Date(calener.getTime().getTime() - 5000); BasicDBObject b2 = new BasicDBObject(); b2.put("$gte", d2); b2.put("$lte", d1); DBCursor cursor = coll.find(new BasicDBObject("_id", b2)).sort(new BasicDBObject("_id", -1)).limit(1); while (cursor.hasNext()) { DBObject dbo = cursor.next(); Set set1 = map1.entrySet(); Iterator it1 = set1.iterator(); while (it1.hasNext()) { Map.Entry<String, Map<String, String>> entry = (Map.Entry<String, Map<String, String>>) it1.next(); Map<String, String> map2 = entry.getValue(); for (Iterator it2 = map2.entrySet().iterator(); it2.hasNext(); ) { Map.Entry<String, String> entry2 = (Map.Entry<String, String>) it2.next(); String name = entry2.getKey().toString(); String paramAddr = entry2.getValue().toString(); int fun = (int) (Double.parseDouble(paramAddr)); if (paramAddr.substring(0, 1).equals("4")) { double value = Double.parseDouble(dbo.get(name).toString()); double dmax = (Double) m_max.get(name); double dmin = (Double) m_min.get(name); double dValue = 0; if (value > dmax || value < dmin) { if (value >= 0) { dValue = 32000 * (int) (value / dmax); } if (value < 0) { dValue = -32000 * (int) (value / dmin); } // slave.getProcessImage(3).setInputRegister(fun % 10000, (short) dValue); } else { /// 参数超限报警 JOptionPane.showMessageDialog(null, "参数超限"); slave.stop(); } } if (paramAddr.substring(0, 1).equals("3")) { double value = Double.parseDouble(dbo.get(name).toString()); double dmax = (Double) m_max.get(name); double dmin = (Double) m_min.get(name); double dValue = 0; if (value > dmax || value < dmin) { if (value >= 0) { dValue = 32000 * (int) (value / dmax); } if (value < 0) { dValue = -32000 * (int) (value / dmin); } // slave.getProcessImage(3).setHoldingRegister(fun % 10000, (short) dValue); } else { /// 参数超限报警 JOptionPane.showMessageDialog(null, "参数超限"); slave.stop(); } ; } if (paramAddr.substring(0, 1).equals("2")) { String value = dbo.get(name).toString(); /// slave.getProcessImage(4).setInput(fun % 10000, Boolean.valueOf(value)); } if (paramAddr.substring(0, 1).equals("1")) { String value = dbo.get(name).toString(); // slave.getProcessImage(4).setCoil(fun % 10000, Boolean.valueOf(value)); } } } } } } catch (Exception ex) { } }