Пример #1
0
 private Color getNodeColor(Node node) {
   if (node instanceof SignalTransition) {
     SignalTransition transition = (SignalTransition) node;
     return getTypeColor(transition.getSignalType());
   }
   return Color.BLACK;
 }
Пример #2
0
  public void updateSignalState() {
    initialiseSignalState();
    ArrayList<String> combinedTrace = new ArrayList<>();
    if (!mainTrace.isEmpty()) {
      combinedTrace.addAll(mainTrace.subList(0, mainTrace.getPosition()));
    }
    if (!branchTrace.isEmpty()) {
      combinedTrace.addAll(branchTrace.subList(0, branchTrace.getPosition()));
    }

    for (String ref : combinedTrace) {
      Node node = getUnderlyingStg().getNodeByReference(ref);
      if (node instanceof SignalTransition) {
        SignalTransition transition = (SignalTransition) node;
        String signalReference = getUnderlyingStg().getSignalReference(transition);
        SignalData signalState = signalDataMap.get(signalReference);
        if (signalState != null) {
          switch (transition.getDirection()) {
            case MINUS:
              signalState.value = SignalState.LOW;
              break;
            case PLUS:
              signalState.value = SignalState.HIGH;
              break;
            case TOGGLE:
              signalState.value = signalState.value.toggle();
              break;
            default:
              break;
          }
        }
      }
    }

    for (Node node : getUnderlyingStg().getTransitions()) {
      if (node instanceof SignalTransition) {
        SignalTransition transition = (SignalTransition) node;
        String signalReference = getUnderlyingStg().getSignalReference(transition);
        SignalData signalData = signalDataMap.get(signalReference);
        if (signalData != null) {
          signalData.excited |= isEnabledNode(transition);
        }
      }
    }
  }