Exemplo n.º 1
0
  private void checkForDuplicatePlacesInSubModel(
      PrTPanel parentNet, PipeTransition pipeTransition, PrTPanel childNet) {
    // composition places
    ArrayList<String> compositionPlaceNames = getInputPlaces(pipeTransition);
    for (String inhibitorPlaceName : getInhibitorPlaces(pipeTransition))
      if (!compositionPlaceNames.contains(inhibitorPlaceName))
        compositionPlaceNames.add(inhibitorPlaceName);
    for (String outputPlaceName : getOutputPlaces(pipeTransition))
      if (!compositionPlaceNames.contains(outputPlaceName))
        compositionPlaceNames.add(outputPlaceName);

    ArrayList<String> placeNamesInParentNet = new ArrayList<String>();
    PipePlace[] placesInParentNet = parentNet.getModel().getPlaces();
    for (int i = 0; i < placesInParentNet.length; i++)
      placeNamesInParentNet.add(placesInParentNet[i].getName());

    // check non-composition places
    PipePlace[] placesInChildNet = childNet.getModel().getPlaces();
    for (int i = 0; i < placesInChildNet.length; i++) {
      String placeName = placesInChildNet[i].getName();
      if (!compositionPlaceNames.contains(placeName) && placeNamesInParentNet.contains(placeName))
        editor.printInConsoleArea(
            LocaleBundle.bundleString("Warning")
                + ": "
                + modelNameMessage(childNet)
                + placeName
                + ": "
                + LocaleBundle.bundleString("PLACE_OCCURRED_IN_BOTH_LEVELS"));
    }
  }
Exemplo n.º 2
0
 private void checkForDuplicateEvents() {
   if (editor.getKernel().getSystemOptions().isNetHierarchyEnabled()) {
     ArrayList<String> events = new ArrayList<String>();
     PipeTransition[] mainTransitions = mainNet.getModel().getTransitions();
     for (int i = 0; i < mainTransitions.length; i++) events.add(mainTransitions[i].getName());
     for (JPanel subModel : editor.getSubModels())
       if (subModel instanceof PrTPanel) {
         PipeTransition[] subTransitions = ((PrTPanel) subModel).getModel().getTransitions();
         for (int i = 0; i < subTransitions.length; i++) {
           if (events.contains(subTransitions[i].getName())) {
             editor.printInConsoleArea(
                 LocaleBundle.bundleString("Warning")
                     + ": "
                     + modelNameMessage((PrTPanel) subModel)
                     + subTransitions[i].getName()
                     + ": "
                     + LocaleBundle.bundleString("TRANSITION_OCCURRED_IN_MULTIPLE_MODELS"));
           }
         }
         for (int i = 0; i < subTransitions.length; i++) {
           events.add(subTransitions[i].getName());
         }
       }
   }
 }
Exemplo n.º 3
0
  private ArrayList<Predicate> parseGlobalPredicates(MID mid, PrTPanel prtNet)
      throws ParseException {
    String GLOBAL_KEYWORD = "GLOBAL";
    ArrayList<Predicate> globalPredicates = new ArrayList<Predicate>();
    DataLayerInterface net = prtNet.getModel();
    AnnotationNote[] annotationNotes = net.getLabels();
    for (AnnotationNote annotation : annotationNotes) {
      String text = annotation.getText();
      if (text.startsWith(GLOBAL_KEYWORD)) {
        String globalPredicateString = text.substring(GLOBAL_KEYWORD.length()).trim();
        try { // abuse transition declaration for global predicate - same syntax
          Predicate signaturePredicate =
              MIDParser.parseTransitionSignatureString(globalPredicateString);
          globalPredicates.add(signaturePredicate);
          mid.addPlace(signaturePredicate.getName());

        } catch (ParseException e) {
          throw new ParseException(
              modelNameMessage(prtNet)
                  + text
                  + ": "
                  + LocaleBundle.bundleString("Incorrect GLOBAL annotation"));
        }
      }
    }
    return globalPredicates;
  }
Exemplo n.º 4
0
 private Marking parsePlaces(MID mid, PrTPanel netModel) throws ParseException {
   DataLayerInterface net = netModel.getModel();
   Marking initialMarking = new Marking();
   PipePlace[] places = net.getPlaces();
   for (int i = 0; i < places.length; i++) {
     // System.out.println("Place ID: "+places[i].getId()+" Name: "+places[i].getName());
     String placeName = places[i].getName();
     if (!MIDParser.isIdentifier(placeName))
       throw new ParseException(
           modelNameMessage(netModel)
               + placeName
               + " - "
               + LocaleBundle.bundleString("should start with a letter"));
     if (!places[i].getConnectFromIterator().hasNext()
         && !places[i].getConnectToIterator().hasNext())
       throw new ParseException(
           modelNameMessage(netModel)
               + placeName
               + " - "
               + LocaleBundle.bundleString("is not connected"));
     parseTokens(initialMarking, places[i]);
     mid.addPlace(placeName);
   }
   return initialMarking;
 }
Exemplo n.º 5
0
 private void parseTokens(Marking marking, PipePlace place) throws ParseException {
   String activeTokenClassID = CreateGui.getModel().getActiveTokenClassID();
   DataLayerInterface net = mainNet.getModel();
   int pos = net.getPosInList(activeTokenClassID, place.getCurrentMarking());
   if (pos >= 0) {
     String tokenString = place.getCurrentMarking().get(pos).getCurrentMarking().trim();
     if (tokenString != null && !tokenString.equals("")) {
       ArrayList<Tuple> tokenList = new ArrayList<Tuple>();
       try {
         tokenList = MIDParser.parseTokenString(tokenString);
       } catch (ParseException e) {
         throw new ParseException(place.getName() + ": " + tokenString + ". " + e.toString());
       }
       if (tokenList.size() > 0) {
         // check arity consistency
         int firstArity = tokenList.get(0).arity();
         for (int index = 1; index < tokenList.size(); index++)
           if (tokenList.get(0).arity() != firstArity)
             throw new ParseException(
                 place.getName()
                     + " "
                     + LocaleBundle.bundleString("has inconsistent token length"));
         // check duplication
         checkDuplicateTokens(tokenList, place.getName(), tokenString);
       }
       marking.addTuples(place.getName(), tokenList);
     }
   }
 }
Exemplo n.º 6
0
 private void parseMarkingAnnotations(MID mid) throws ParseException {
   DataLayerInterface net = mainNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.INIT_KEYWORD)) parseMainModelAnnotationMarking(mid, text);
   }
   if (editor.getKernel().getSystemOptions().isNetHierarchyEnabled())
     parseSubModelMarkingAnnotations(mid);
 }
Exemplo n.º 7
0
 private int numberOfNumerationAnnotations(PrTPanel prtNet) {
   int numberOfEnumerations = 0;
   DataLayerInterface net = prtNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.ENUM_KEYWORD)) numberOfEnumerations++;
   }
   return numberOfEnumerations;
 }
Exemplo n.º 8
0
 private void parseConstantsAnnotations(PrTPanel prtNet) throws ParseException {
   DataLayerInterface net = prtNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.CONSTANTS_KEYWORD))
       parseConstants(text, XMIDProcessor.CONSTANTS_KEYWORD);
     else if (text.startsWith(XMIDProcessor.ENUM_KEYWORD))
       parseEnumeration(text, XMIDProcessor.ENUM_KEYWORD);
   }
 }
Exemplo n.º 9
0
 protected ArrayList<Marking> parseSubModelMarkingAnnotations(
     PrTPanel subPrtPanel, String markingKeyword) throws ParseException {
   ArrayList<Marking> markings = new ArrayList<Marking>();
   DataLayerInterface net = subPrtPanel.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(markingKeyword)) {
       Marking marking = parseSubModelAnnotationMarking(text, markingKeyword);
       if (marking != null) markings.add(marking);
     }
   }
   return markings;
 }
Exemplo n.º 10
0
 private void parseAssertionPropertyAnnotations(MID mid) throws ParseException {
   DataLayerInterface net = mainNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.ASSERTION_KEYWORD)) {
       String assertionString = text.substring(XMIDProcessor.ASSERTION_KEYWORD.length());
       if (!assertionString.trim().equals("")) {
         try {
           AssertionProperty assertion = MIDParser.parseAssertionPropertyString(assertionString);
           mid.addAssertionProperty(assertion);
         } catch (ParseException e) {
           throw new ParseException(text + ". " + e.toString());
         }
       }
     }
   }
 }
Exemplo n.º 11
0
 private void parseOtherAnnotations(MID mid, PrTPanel prtNet) throws ParseException {
   DataLayerInterface net = prtNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.UNITTESTS_KEYWORD))
       parseUnitTests(mid, text, XMIDProcessor.UNITTESTS_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SINKS_KEYWORD))
       parseSinkEvents(mid, text, XMIDProcessor.SINKS_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SINK_KEYWORD))
       parseSinkEvents(mid, text, XMIDProcessor.SINK_KEYWORD);
     else if (text.startsWith(XMIDProcessor.NONNEGATIVE_KEYWORD))
       parseNonNegativeEvents(mid, text, XMIDProcessor.NONNEGATIVE_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SEQUENCESFILE_KEYWORD))
       parseSequencesFile(mid, text, XMIDProcessor.SEQUENCESFILE_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SEQUENCES_KEYWORD))
       parseSequencesFile(mid, text, XMIDProcessor.SEQUENCES_KEYWORD);
   }
 }
Exemplo n.º 12
0
 private void parseTransitions(MID mid, PrTPanel prtNet) throws ParseException {
   ArrayList<Predicate> globalPredicates = parseGlobalPredicates(mid, prtNet);
   DataLayerInterface net = prtNet.getModel();
   PipeTransition[] pipeTransitions = net.getTransitions();
   for (int i = 0; i < pipeTransitions.length; i++) {
     PipeTransition pipeTransition = pipeTransitions[i];
     if (pipeTransition.hasValidSubnetFile()
         && editor.getKernel().getSystemOptions().isNetHierarchyEnabled()) {
       PrTPanel subModel = editor.findPrTPanelForFile(pipeTransition.getSubnetFileHandler());
       if (subModel != null) {
         // check composition rules, e.g., place names
         checkForCompositionErrors(prtNet, pipeTransition, subModel);
         parseTransitions(mid, subModel);
       }
     } else parsePipeTransition(mid, prtNet, pipeTransition, globalPredicates);
     // System.out.println("Transition ID: "+pipeTransitions[i].getId()+" Name:
     // "+pipeTransitions[i].getName());
   }
 }
Exemplo n.º 13
0
 private void parseDataAnnotations(MID mid) throws ParseException {
   DataLayerInterface net = mainNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.DATA_KEYWORD)) {
       String dataPath = text.substring(XMIDProcessor.DATA_KEYWORD.length()).trim();
       try {
         ExcelTestDataLoader excelTestDataLoader =
             new ExcelTestDataLoader(
                 editor.midFile.getParent() + File.separator + dataPath, mid.getPlaces());
         for (Marking initMarking : excelTestDataLoader.getInitMarkings()) {
           mid.addInitialMarking(initMarking);
         }
       } catch (Exception e) {
         throw new ParseException(text + " -> " + e.getMessage());
       }
     }
   }
 }
Exemplo n.º 14
0
 private PipePlace pipePlaceInSubNet(String placeName, PrTPanel childNetPanel) {
   DataLayerInterface net = childNetPanel.getModel();
   for (PipePlace pipePlace : net.getPlaces())
     if (pipePlace.getName().equals(placeName)) return pipePlace;
   return null;
 }