@Override public void entryAdded(ModelEvent event, Value[] values) { if (chronoFrame.isRealTimeMode() && (sysclkPos >= 0)) { try { // update gui only on sysclk change if (!values[sysclkPos].toString().equals(lastSysclk)) { lastSysclk = values[sysclkPos].toString(); int pos = 0; for (Value v : values) { chronoData.appendValueToSignal(signalNamesKeepOrder[pos++], v.toString()); } chronoFrame.getChronoData().updateRealTimeExpandedBus(); chronoFrame.repaintAll(false); } } catch (Exception ex) { ex.printStackTrace(); } } }
public ChronoModelEventHandler(ChronoFrame chronoFrame, Model model, Project prj) throws NoSysclkException { this.chronoFrame = chronoFrame; this.chronoData = chronoFrame.getChronoData(); model.addModelListener(this); Selection sel = model.getSelection(); int columns = sel.size(); signalNamesKeepOrder = new String[columns]; for (int i = 0; i < columns; i++) { String name = ""; Component[] path = sel.get(i).getPath(); for (int k = 0; k < path.length; k++) { SubcircuitFactory circFact = (SubcircuitFactory) path[k].getFactory(); name += circFact.getDisplayName() + "/"; } name += sel.get(i).toShortString(); signalNamesKeepOrder[i] = name; String value = sel.get(i).fetchValue(model.getCircuitState()).toString(); // is the entry a bus? if (value.length() > 1) chronoData.put(name, new SignalDataBus(name, new ArrayList<String>())); else chronoData.put(name, new SignalData(name, new ArrayList<String>())); // add initial data chronoData.appendValueToSignal(name, value); chronoData.appendValueToSignal(name, value); // save sysclk position in signalNamesKeepOrder if (name.equals("sysclk")) sysclkPos = i; } if (sysclkPos == -1) throw new NoSysclkException("No sysclk signal found"); // store signal order chronoData.setSignalOrder(new ArrayList<String>(Arrays.asList(signalNamesKeepOrder))); }