// =============================================================== // =============================================================== void putPoolThreadInfo() { // ToDo // Get configuration from tree int nbThreads = root.getChildCount(); ArrayList<String> lines = new ArrayList<String>(); for (int i = 0; i < root.getChildCount(); i++) { DefaultMutableTreeNode threadNode = (DefaultMutableTreeNode) root.getChildAt(i); int deviceNumber = threadNode.getChildCount(); if (deviceNumber > 0) { String s = ""; for (int j = 0; j < deviceNumber; j++) { s += threadNode.getChildAt(j).toString(); if (j < deviceNumber - 1) s += ","; } lines.add(s); } } // Check for maximum length of lines lines = manageMaxLength(lines); // Convert tree to device(admin) property. String[] config = new String[lines.size()]; for (int i = 0; i < lines.size(); i++) config[i] = lines.get(i); // And send it to database. try { DbDatum[] argin = new DbDatum[2]; argin[0] = new DbDatum(propertyNames[NB_THREADS], nbThreads); argin[1] = new DbDatum(propertyNames[THREADS_CONFIG], config); server.put_property(argin); } catch (DevFailed e) { ErrorPane.showErrorMessage(parent, null, e); } }
// =========================================================== private PoolThreadsInfo(TangoServer server) throws DevFailed { DbDatum[] data = server.get_property(propertyNames); String[] config = new String[0]; int threadsNumber = 1; if (data[NB_THREADS].is_empty() && data[THREADS_CONFIG].is_empty()) { // If no property --> get device list from db String[] s = server.queryDeviceFromDb(); // and set all for on thread StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length; i++) { sb.append(s[i]); if (i < s.length - 1) sb.append(','); } config = new String[] {sb.toString()}; } if (!data[NB_THREADS].is_empty()) threadsNumber = data[NB_THREADS].extractLong(); if (!data[THREADS_CONFIG].is_empty()) config = data[THREADS_CONFIG].extractStringArray(); buildConfig(config, threadsNumber); }