Merge lp:~tapaal-contributor/tapaal/cpn-gui-dev into lp:tapaal
- cpn-gui-dev
- Merge into trunk
Status: | Merged |
---|---|
Merge reported by: | Kenneth Yrke Jørgensen |
Merged at revision: | not available |
Proposed branch: | lp:~tapaal-contributor/tapaal/cpn-gui-dev |
Merge into: | lp:tapaal |
Diff against target: |
54815 lines (+28398/-10092) 463 files modified
build.gradle (+33/-57) gradle/wrapper/gradle-wrapper.properties (+5/-6) gradlew (+2/-0) gradlew.bat (+4/-18) src/dk/aau/cs/util/ExecutabilityChecker.java (+0/-42) src/main/java/dk/aau/cs/TCTL/AritmeticOperator.java (+1/-1) src/main/java/dk/aau/cs/TCTL/LTLGNode.java (+1/-1) src/main/java/dk/aau/cs/TCTL/LTLUNode.java (+1/-1) src/main/java/dk/aau/cs/TCTL/StringPosition.java (+2/-3) src/main/java/dk/aau/cs/TCTL/TCTLAUNode.java (+1/-1) src/main/java/dk/aau/cs/TCTL/TCTLAbstractProperty.java (+0/-2) src/main/java/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java (+0/-14) src/main/java/dk/aau/cs/TCTL/TCTLAndListNode.java (+1/-2) src/main/java/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java (+0/-25) src/main/java/dk/aau/cs/TCTL/TCTLConstNode.java (+1/-1) src/main/java/dk/aau/cs/TCTL/TCTLEFNode.java (+0/-2) src/main/java/dk/aau/cs/TCTL/TCTLOrListNode.java (+1/-2) src/main/java/dk/aau/cs/TCTL/TCTLPlusListNode.java (+1/-1) src/main/java/dk/aau/cs/TCTL/TCTLTermListNode.java (+1/-1) src/main/java/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java (+36/-34) src/main/java/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java (+1/-1) src/main/java/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java (+2/-2) src/main/java/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java (+265/-248) src/main/java/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java (+7/-7) src/main/java/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java (+10/-7) src/main/java/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java (+4/-3) src/main/java/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java (+1/-1) src/main/java/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java (+1/-10) src/main/java/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java (+1/-1) src/main/java/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java (+1/-1) src/main/java/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java (+1/-1) src/main/java/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java (+100/-89) src/main/java/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java (+2/-2) src/main/java/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java (+2/-2) src/main/java/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java (+2/-2) src/main/java/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java (+1/-1) src/main/java/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java (+4/-5) src/main/java/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java (+4/-5) src/main/java/dk/aau/cs/approximation/ApproximationWorker.java (+185/-117) src/main/java/dk/aau/cs/approximation/OverApproximation.java (+10/-9) src/main/java/dk/aau/cs/approximation/UnderApproximation.java (+43/-55) src/main/java/dk/aau/cs/io/LoadTACPN.java (+439/-0) src/main/java/dk/aau/cs/io/LoadedModel.java (+11/-9) src/main/java/dk/aau/cs/io/LoadedQueries.java (+1/-2) src/main/java/dk/aau/cs/io/ModelLoader.java (+3/-3) src/main/java/dk/aau/cs/io/NetWriter.java (+3/-3) src/main/java/dk/aau/cs/io/PNMLWriter.java (+150/-26) src/main/java/dk/aau/cs/io/PNMLoader.java (+521/-453) src/main/java/dk/aau/cs/io/TapnEngineXmlLoader.java (+993/-0) src/main/java/dk/aau/cs/io/TapnLegacyXmlLoader.java (+58/-54) src/main/java/dk/aau/cs/io/TapnXmlLoader.java (+397/-110) src/main/java/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java (+146/-39) src/main/java/dk/aau/cs/io/TraceImportExport.java (+25/-22) src/main/java/dk/aau/cs/io/XMLFormatter.java (+1/-1) src/main/java/dk/aau/cs/io/batchProcessing/BatchProcessingResultsExporter.java (+4/-4) src/main/java/dk/aau/cs/io/batchProcessing/LoadedBatchProcessingModel.java (+1/-1) src/main/java/dk/aau/cs/io/queries/QueryLoader.java (+2/-5) src/main/java/dk/aau/cs/io/queries/SUMOQueryLoader.java (+10/-12) src/main/java/dk/aau/cs/io/queries/TAPNQueryLoader.java (+35/-16) src/main/java/dk/aau/cs/io/queries/XMLQueryLoader.java (+37/-18) src/main/java/dk/aau/cs/io/writeTACPN.java (+455/-0) src/main/java/dk/aau/cs/model/CPN/Color.java (+137/-0) src/main/java/dk/aau/cs/model/CPN/ColorMultiset.java (+144/-0) src/main/java/dk/aau/cs/model/CPN/ColorType.java (+142/-0) src/main/java/dk/aau/cs/model/CPN/ColoredTimeInterval.java (+148/-0) src/main/java/dk/aau/cs/model/CPN/ColoredTimeInvariant.java (+108/-0) src/main/java/dk/aau/cs/model/CPN/ExpressionSupport/ExprStringPosition.java (+35/-0) src/main/java/dk/aau/cs/model/CPN/ExpressionSupport/ExprValues.java (+40/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/AddExpression.java (+185/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/AllExpression.java (+137/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/AndExpression.java (+124/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/ArcExpression.java (+37/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/ColorExpression.java (+62/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/DotConstantExpression.java (+107/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/EqualityExpression.java (+119/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/Expression.java (+64/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/ExpressionContext.java (+31/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanEqExpression.java (+118/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanExpression.java (+121/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/GuardExpression.java (+30/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/InequalityExpression.java (+117/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/LeftRightGuardExpression.java (+6/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/LessThanEqExpression.java (+120/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/LessThanExpression.java (+121/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/NotExpression.java (+87/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/NumberOfExpression.java (+182/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/OrExpression.java (+124/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/PlaceHolderArcExpression.java (+76/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/PlaceHolderColorExpression.java (+106/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/PlaceHolderExpression.java (+5/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/PlaceHolderGuardExpression.java (+75/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/PredecessorExpression.java (+127/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/ScalarProductExpression.java (+114/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/SubtractExpression.java (+138/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/SuccessorExpression.java (+125/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/TupleExpression.java (+238/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/UserOperatorExpression.java (+140/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/UserSortExpression.java (+92/-0) src/main/java/dk/aau/cs/model/CPN/Expressions/VariableExpression.java (+180/-0) src/main/java/dk/aau/cs/model/CPN/ProductType.java (+188/-0) src/main/java/dk/aau/cs/model/CPN/Variable.java (+34/-0) src/main/java/dk/aau/cs/model/NTA/Location.java (+1/-1) src/main/java/dk/aau/cs/model/NTA/trace/SymbolicState.java (+5/-5) src/main/java/dk/aau/cs/model/NTA/trace/TimeDelayFiringAction.java (+2/-2) src/main/java/dk/aau/cs/model/NTA/trace/TraceToken.java (+4/-11) src/main/java/dk/aau/cs/model/NTA/trace/TransitionFiring.java (+5/-13) src/main/java/dk/aau/cs/model/tapn/ConstantStore.java (+11/-12) src/main/java/dk/aau/cs/model/tapn/IntWeight.java (+1/-1) src/main/java/dk/aau/cs/model/tapn/LocalTimedMarking.java (+2/-2) src/main/java/dk/aau/cs/model/tapn/LocalTimedPlace.java (+42/-5) src/main/java/dk/aau/cs/model/tapn/NetworkMarking.java (+3/-3) src/main/java/dk/aau/cs/model/tapn/RatBound.java (+4/-4) src/main/java/dk/aau/cs/model/tapn/SharedPlace.java (+51/-13) src/main/java/dk/aau/cs/model/tapn/SharedTransition.java (+20/-12) src/main/java/dk/aau/cs/model/tapn/TAPNQuery.java (+1/-1) src/main/java/dk/aau/cs/model/tapn/TimeInterval.java (+3/-3) src/main/java/dk/aau/cs/model/tapn/TimeInvariant.java (+3/-3) src/main/java/dk/aau/cs/model/tapn/TimedArcPetriNet.java (+65/-10) src/main/java/dk/aau/cs/model/tapn/TimedArcPetriNetNetwork.java (+355/-18) src/main/java/dk/aau/cs/model/tapn/TimedInhibitorArc.java (+12/-7) src/main/java/dk/aau/cs/model/tapn/TimedInputArc.java (+58/-12) src/main/java/dk/aau/cs/model/tapn/TimedOutputArc.java (+30/-3) src/main/java/dk/aau/cs/model/tapn/TimedPlace.java (+55/-7) src/main/java/dk/aau/cs/model/tapn/TimedToken.java (+50/-12) src/main/java/dk/aau/cs/model/tapn/TimedTransition.java (+49/-10) src/main/java/dk/aau/cs/model/tapn/TransportArc.java (+72/-10) src/main/java/dk/aau/cs/model/tapn/simulation/ManualDelayMode.java (+6/-6) src/main/java/dk/aau/cs/model/tapn/simulation/ShortestDelayMode.java (+2/-2) src/main/java/dk/aau/cs/model/tapn/simulation/TAPNNetworkTimeDelayStep.java (+0/-4) src/main/java/dk/aau/cs/model/tapn/simulation/TimeDelayStep.java (+3/-3) src/main/java/dk/aau/cs/model/tapn/simulation/TimedArcPetriNetTrace.java (+2/-6) src/main/java/dk/aau/cs/model/tapn/simulation/TimedTAPNNetworkTrace.java (+1/-1) src/main/java/dk/aau/cs/translations/Degree2Converter.java (+14/-12) src/main/java/dk/aau/cs/translations/ReductionOption.java (+1/-1) src/main/java/dk/aau/cs/translations/tapn/BroadcastTranslation.java (+6/-5) src/main/java/dk/aau/cs/translations/tapn/CombiTranslation.java (+6/-6) src/main/java/dk/aau/cs/translations/tapn/Degree2BroadcastTranslation.java (+4/-3) src/main/java/dk/aau/cs/translations/tapn/OptimizedStandardTranslation.java (+2/-1) src/main/java/dk/aau/cs/translations/tapn/StandardTranslation.java (+2/-1) src/main/java/dk/aau/cs/translations/tapn/TAPNToTimedConservativeTAPNConverter.java (+2/-0) src/main/java/dk/aau/cs/util/FormatException.java (+4/-0) src/main/java/dk/aau/cs/util/IntervalOperations.java (+8/-8) src/main/java/dk/aau/cs/util/MemoryMonitor.java (+1/-2) src/main/java/dk/aau/cs/util/Require.java (+0/-4) src/main/java/dk/aau/cs/verification/BoundednessAnalysisResult.java (+3/-3) src/main/java/dk/aau/cs/verification/BufferDrain.java (+7/-2) src/main/java/dk/aau/cs/verification/EngineHelperFunctions.java (+94/-0) src/main/java/dk/aau/cs/verification/ITAPNComposer.java (+2/-0) src/main/java/dk/aau/cs/verification/IconSelector.java (+4/-4) src/main/java/dk/aau/cs/verification/ModelChecker.java (+6/-3) src/main/java/dk/aau/cs/verification/ProcessRunner.java (+2/-2) src/main/java/dk/aau/cs/verification/QueryResult.java (+29/-7) src/main/java/dk/aau/cs/verification/ReductionStats.java (+27/-30) src/main/java/dk/aau/cs/verification/Stats.java (+9/-23) src/main/java/dk/aau/cs/verification/TAPNComposer.java (+85/-65) src/main/java/dk/aau/cs/verification/TAPNTraceDecomposer.java (+3/-2) src/main/java/dk/aau/cs/verification/TraceConverter.java (+3/-2) src/main/java/dk/aau/cs/verification/UPPAAL/UppaalIconSelector.java (+1/-1) src/main/java/dk/aau/cs/verification/UPPAAL/Verifyta.java (+37/-88) src/main/java/dk/aau/cs/verification/UPPAAL/VerifytaOptions.java (+4/-4) src/main/java/dk/aau/cs/verification/UPPAAL/VerifytaTraceInterpreter.java (+3/-2) src/main/java/dk/aau/cs/verification/VerificationOptions.java (+12/-6) src/main/java/dk/aau/cs/verification/VerificationResult.java (+45/-29) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyCPNExporter.java (+149/-0) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPN.java (+144/-150) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPNOptions.java (+95/-22) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyDTAPNUnfoldOptions.java (+68/-0) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyPN.java (+463/-429) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyPNCTLOutputParser.java (+8/-1) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyPNExporter.java (+5/-1) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyPNOptions.java (+152/-79) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyPNOutputParser.java (+8/-1) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyPNUnfoldOptions.java (+100/-0) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyTACPNExporter.java (+32/-0) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyTAPN.java (+151/-144) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNExporter.java (+81/-74) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOptions.java (+52/-21) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNOutputParser.java (+19/-2) src/main/java/dk/aau/cs/verification/VerifyTAPN/VerifyTAPNTraceParser.java (+3/-1) src/main/java/dk/aau/cs/verification/batchProcessing/BatchProcessingVerificationOptions.java (+3/-8) src/main/java/dk/aau/cs/verification/batchProcessing/BatchProcessingVerificationResult.java (+1/-1) src/main/java/dk/aau/cs/verification/batchProcessing/BatchProcessingWorker.java (+61/-66) src/main/java/net/tapaal/Preferences.java (+8/-0) src/main/java/net/tapaal/TAPAAL.java (+20/-26) src/main/java/net/tapaal/copypaste/CopyPastImportExport.kt (+312/-0) src/main/java/net/tapaal/export/TikZExporter.java (+215/-147) src/main/java/net/tapaal/gui/DrawingSurfaceManager/AbstractDrawingSurfaceManager.java (+9/-4) src/main/java/net/tapaal/gui/FileDropTarget.kt (+53/-0) src/main/java/net/tapaal/gui/GuiFrameActions.java (+16/-10) src/main/java/net/tapaal/gui/GuiFrameController.java (+149/-110) src/main/java/net/tapaal/gui/GuiFrameControllerActions.java (+12/-7) src/main/java/net/tapaal/gui/SafeGuiFrameActions.java (+3/-3) src/main/java/net/tapaal/gui/TabActions.java (+28/-12) src/main/java/net/tapaal/gui/debug/Debug.kt (+32/-0) src/main/java/net/tapaal/gui/debug/UndoRedoSpy.kt (+53/-0) src/main/java/net/tapaal/gui/petrinet/Context.java (+10/-9) src/main/java/net/tapaal/gui/petrinet/NameGenerator.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/TAPNLens.java (+27/-0) src/main/java/net/tapaal/gui/petrinet/TabTransformer.java (+185/-11) src/main/java/net/tapaal/gui/petrinet/Template.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/animation/AnimationTokenSelectDialog.java (+3/-3) src/main/java/net/tapaal/gui/petrinet/animation/ArcTokenSelector.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/animation/DelayEnabledTransitionControl.java (+3/-3) src/main/java/net/tapaal/gui/petrinet/animation/TransitionFiringComponent.java (+15/-14) src/main/java/net/tapaal/gui/petrinet/dialog/BatchProcessingDialog.java (+80/-122) src/main/java/net/tapaal/gui/petrinet/dialog/BatchProcessingResultsTableModel.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/dialog/ExportBatchDialog.java (+25/-21) src/main/java/net/tapaal/gui/petrinet/dialog/ExportBatchResultTableModel.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/dialog/FileNameCellRenderer.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/dialog/NameVisibilityPanel.java (+7/-7) src/main/java/net/tapaal/gui/petrinet/dialog/NewTAPNPanel.java (+93/-31) src/main/java/net/tapaal/gui/petrinet/dialog/QueryDialog.java (+319/-205) src/main/java/net/tapaal/gui/petrinet/dialog/StatisticsPanel.java (+16/-16) src/main/java/net/tapaal/gui/petrinet/dialog/UnfoldDialog.java (+179/-0) src/main/java/net/tapaal/gui/petrinet/dialog/WorkflowDialog.java (+63/-55) src/main/java/net/tapaal/gui/petrinet/editor/ColorComboBoxRenderer.java (+52/-0) src/main/java/net/tapaal/gui/petrinet/editor/ColorComboboxPanel.java (+192/-0) src/main/java/net/tapaal/gui/petrinet/editor/ColorTypeDialogPanel.java (+1145/-0) src/main/java/net/tapaal/gui/petrinet/editor/ColoredArcGuardPanel.java (+1203/-0) src/main/java/net/tapaal/gui/petrinet/editor/ColoredTimeIntervalDialogPanel.java (+446/-0) src/main/java/net/tapaal/gui/petrinet/editor/ColoredTimeInvariantDialogPanel.java (+318/-0) src/main/java/net/tapaal/gui/petrinet/editor/ColoredTransitionGuardPanel.java (+1015/-0) src/main/java/net/tapaal/gui/petrinet/editor/ColortypeListCellRenderer.java (+59/-0) src/main/java/net/tapaal/gui/petrinet/editor/ConstantsDialogPanel.java (+36/-34) src/main/java/net/tapaal/gui/petrinet/editor/ConstantsListModel.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/editor/ConstantsPane.java (+669/-213) src/main/java/net/tapaal/gui/petrinet/editor/DeleteSharedPlaceOrTransitionAction.java (+49/-36) src/main/java/net/tapaal/gui/petrinet/editor/SharedPlaceNamePanel.java (+8/-12) src/main/java/net/tapaal/gui/petrinet/editor/SharedPlacesAndTransitionsPanel.java (+29/-41) src/main/java/net/tapaal/gui/petrinet/editor/SharedTransitionNamePanel.java (+12/-15) src/main/java/net/tapaal/gui/petrinet/editor/TemplateExplorer.java (+135/-278) src/main/java/net/tapaal/gui/petrinet/editor/VariablesDialogPanel.java (+328/-0) src/main/java/net/tapaal/gui/petrinet/model/GuiModelManager.java (+523/-0) src/main/java/net/tapaal/gui/petrinet/model/ModelViolation.java (+19/-0) src/main/java/net/tapaal/gui/petrinet/model/RequirementChecker.java (+28/-0) src/main/java/net/tapaal/gui/petrinet/model/Result.java (+29/-0) src/main/java/net/tapaal/gui/petrinet/smartdraw/SmartDrawDialog.java (+90/-289) src/main/java/net/tapaal/gui/petrinet/smartdraw/SmartDrawListener.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/smartdraw/SmartDrawWorker.java (+65/-51) src/main/java/net/tapaal/gui/petrinet/undo/AddConstantEditCommand.java (+6/-7) src/main/java/net/tapaal/gui/petrinet/undo/AddFileBatchProcessingCommand.java (+4/-4) src/main/java/net/tapaal/gui/petrinet/undo/AddFileExportBatchCommand.java (+2/-3) src/main/java/net/tapaal/gui/petrinet/undo/AddQueryCommand.java (+5/-6) src/main/java/net/tapaal/gui/petrinet/undo/AddSharedPlaceCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/AddSharedTransitionCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/AddTemplateCommand.java (+3/-4) src/main/java/net/tapaal/gui/petrinet/undo/AddTimedInhibitorArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/AddTimedInputArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/AddTimedOutputArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/AddTimedPlaceCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/AddTimedTransitionCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/AddTransportArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/ChangeAllNamesVisibilityCommand.java (+7/-7) src/main/java/net/tapaal/gui/petrinet/undo/ChangeSpacingEditCommand.java (+7/-8) src/main/java/net/tapaal/gui/petrinet/undo/ChangedInvariantCommand.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/undo/Colored/AddColorTypeCommand.java (+30/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/AddVariableCommand.java (+29/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/ColoredPlaceMarkingEditCommand.java (+78/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/RemoveColorTypeFromNetworkCommand.java (+33/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/RemoveVariableFromNetworkCommand.java (+33/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/SetArcExpressionCommand.java (+29/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/SetColoredArcIntervalsCommand.java (+30/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/SetTransitionExpressionCommand.java (+29/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/SetTransportArcExpressionsCommand.java (+35/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/UpdateColorTypeCommand.java (+78/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/UpdatePTColorTypeCommand.java (+31/-0) src/main/java/net/tapaal/gui/petrinet/undo/Colored/UpdateVariableCommand.java (+40/-0) src/main/java/net/tapaal/gui/petrinet/undo/Command.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/undo/DeleteQueriesCommand.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/undo/DeleteSharedPlaceCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/DeleteSharedTransitionCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/DeleteTimedInhibitorArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/DeleteTimedInputArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/DeleteTimedOutputArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/DeleteTimedPlaceCommand.java (+12/-10) src/main/java/net/tapaal/gui/petrinet/undo/DeleteTimedTransitionCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/DeleteTransportArcCommand.java (+4/-3) src/main/java/net/tapaal/gui/petrinet/undo/MakePlaceNewSharedCommand.java (+17/-9) src/main/java/net/tapaal/gui/petrinet/undo/MakePlaceNewSharedMultiCommand.java (+14/-7) src/main/java/net/tapaal/gui/petrinet/undo/MakePlaceSharedCommand.java (+7/-7) src/main/java/net/tapaal/gui/petrinet/undo/MakeTransitionNewSharedCommand.java (+4/-4) src/main/java/net/tapaal/gui/petrinet/undo/MakeTransitionNewSharedMultiCommand.java (+6/-6) src/main/java/net/tapaal/gui/petrinet/undo/MakeTransitionSharedCommand.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/undo/MoveElementDownCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/MoveElementUpCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/MovePlaceTransitionObjectCommand.java (+14/-13) src/main/java/net/tapaal/gui/petrinet/undo/RemoveConstantEditCommand.java (+6/-7) src/main/java/net/tapaal/gui/petrinet/undo/RemoveFileBatchProcessingCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/RemoveFileExportBatchCommand.java (+2/-3) src/main/java/net/tapaal/gui/petrinet/undo/RemoveQueriesCommand.java (+8/-9) src/main/java/net/tapaal/gui/petrinet/undo/RemoveTemplateCommand.java (+7/-7) src/main/java/net/tapaal/gui/petrinet/undo/RenameSharedPlaceCommand.java (+6/-6) src/main/java/net/tapaal/gui/petrinet/undo/RenameSharedTransitionCommand.java (+6/-6) src/main/java/net/tapaal/gui/petrinet/undo/RenameTemplateCommand.java (+6/-7) src/main/java/net/tapaal/gui/petrinet/undo/RenameTimedPlaceCommand.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/undo/RenameTimedTransitionCommand.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/undo/SortConstantsCommand.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/undo/SortQueriesCommand.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/undo/SortSharedPlacesCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/SortSharedTransitionsCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/SortTemplatesCommand.java (+6/-6) src/main/java/net/tapaal/gui/petrinet/undo/TimedPlaceMarkingEditCommand.java (+4/-4) src/main/java/net/tapaal/gui/petrinet/undo/ToggleTemplateActivationCommand.java (+3/-4) src/main/java/net/tapaal/gui/petrinet/undo/ToggleTransitionUncontrollableCommand.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/undo/ToggleTransitionUrgentCommand.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/undo/UndoRedoBuffer.java (+95/-0) src/main/java/net/tapaal/gui/petrinet/undo/UnsharePlaceCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/undo/UnshareTransitionCommand.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/undo/UpdateConstantEditCommand.java (+7/-8) src/main/java/net/tapaal/gui/petrinet/undo/UpdateNameLabelOffsetCommand.java (+2/-2) src/main/java/net/tapaal/gui/petrinet/verification/ChooseInclusionPlacesDialog.java (+17/-21) src/main/java/net/tapaal/gui/petrinet/verification/EngineDialogPanel.java (+16/-13) src/main/java/net/tapaal/gui/petrinet/verification/EngineSupportOptions.java (+5/-5) src/main/java/net/tapaal/gui/petrinet/verification/InclusionPlaces.java (+1/-1) src/main/java/net/tapaal/gui/petrinet/verification/KBoundAnalyzer.java (+36/-23) src/main/java/net/tapaal/gui/petrinet/verification/RunKBoundAnalysis.java (+12/-8) src/main/java/net/tapaal/gui/petrinet/verification/RunVerification.java (+157/-152) src/main/java/net/tapaal/gui/petrinet/verification/RunVerificationBase.java (+172/-146) src/main/java/net/tapaal/gui/petrinet/verification/RunningVerificationDialog.java (+12/-6) src/main/java/net/tapaal/gui/petrinet/verification/TAPNQuery.java (+78/-15) src/main/java/net/tapaal/gui/petrinet/verification/UPPAAALStandardOptions.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/verification/UPPAALBroadcastDegree2Options.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/verification/UPPAALBroadcastOptions.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/verification/UPPAALCombiOptions.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/verification/UPPAALOptimizedStandardOptions.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/verification/UnfoldNet.java (+354/-0) src/main/java/net/tapaal/gui/petrinet/verification/Verifier.java (+229/-199) src/main/java/net/tapaal/gui/petrinet/verification/VerifyDTAPNEngineOptions.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/verification/VerifyPNEngineOptions.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/verification/VerifyTAPNEngineOptions.java (+3/-2) src/main/java/net/tapaal/gui/petrinet/widgets/QueryPane.java (+43/-56) src/main/java/net/tapaal/gui/petrinet/widgets/SidePane.java (+1/-1) src/main/java/net/tapaal/gui/swingcomponents/BugHandledJXMultisplitPane.java (+1/-1) src/main/java/net/tapaal/gui/swingcomponents/MultiLineAutoWrappingToolTip.java (+1/-1) src/main/java/net/tapaal/gui/swingcomponents/MultiLineAutoWrappingTooltipUI.java (+1/-1) src/main/java/net/tapaal/gui/swingcomponents/NonsearchableJComboBox.java (+1/-1) src/main/java/net/tapaal/gui/swingcomponents/NonsearchableJList.java (+1/-1) src/main/java/net/tapaal/resourcemanager/ResourceManager.java (+1/-1) src/main/java/net/tapaal/swinghelpers/CustomJSpinner.java (+0/-1) src/main/java/net/tapaal/swinghelpers/DecimalOnlyDocumentFilter.java (+43/-47) src/main/java/net/tapaal/swinghelpers/DispatchEventsToParentHandler.java (+36/-36) src/main/java/net/tapaal/swinghelpers/GridBagHelper.java (+12/-6) src/main/java/net/tapaal/swinghelpers/RequestFocusListener.java (+0/-3) src/main/java/net/tapaal/swinghelpers/ToggleButtonWithoutText.java (+0/-1) src/main/java/net/tapaal/versioncheck/VersionChecker.java (+2/-2) src/main/java/pipe/gui/Constants.java (+10/-16) src/main/java/pipe/gui/FileFinder.java (+1/-1) src/main/java/pipe/gui/GuiFrame.java (+283/-176) src/main/java/pipe/gui/MessengerImpl.java (+1/-1) src/main/java/pipe/gui/TAPAALGUI.java (+30/-83) src/main/java/pipe/gui/TabComponent.java (+4/-3) src/main/java/pipe/gui/canvas/Canvas.java (+1/-1) src/main/java/pipe/gui/canvas/DrawingSurfaceImpl.java (+78/-172) src/main/java/pipe/gui/canvas/Grid.java (+10/-25) src/main/java/pipe/gui/canvas/PrototypeCanvas.java (+1/-1) src/main/java/pipe/gui/canvas/SelectionManager.java (+78/-98) src/main/java/pipe/gui/canvas/Zoomer.java (+7/-5) src/main/java/pipe/gui/petrinet/Export.java (+96/-102) src/main/java/pipe/gui/petrinet/PetriNetTab.java (+963/-1115) src/main/java/pipe/gui/petrinet/action/EditAnnotationBackgroundAction.java (+2/-2) src/main/java/pipe/gui/petrinet/action/EditAnnotationBorderAction.java (+4/-4) src/main/java/pipe/gui/petrinet/action/EditNoteAction.java (+2/-2) src/main/java/pipe/gui/petrinet/action/GuiAction.java (+1/-2) src/main/java/pipe/gui/petrinet/action/ShowHideInfoAction.java (+2/-2) src/main/java/pipe/gui/petrinet/action/SplitArcAction.java (+5/-5) src/main/java/pipe/gui/petrinet/action/SplitArcPointAction.java (+4/-4) src/main/java/pipe/gui/petrinet/action/ToggleArcPointAction.java (+4/-4) src/main/java/pipe/gui/petrinet/animation/AnimationControlSidePanel.java (+24/-22) src/main/java/pipe/gui/petrinet/animation/AnimationHistoryList.java (+11/-10) src/main/java/pipe/gui/petrinet/animation/AnimationHistorySidePanel.java (+11/-7) src/main/java/pipe/gui/petrinet/animation/AnimationSettingsDialog.java (+11/-9) src/main/java/pipe/gui/petrinet/animation/Animator.java (+35/-33) src/main/java/pipe/gui/petrinet/animation/EnabledTransitionsList.java (+12/-10) src/main/java/pipe/gui/petrinet/animation/SimulationControl.java (+10/-11) src/main/java/pipe/gui/petrinet/animation/SimulatorFocusTraversalPolicy.java (+21/-12) src/main/java/pipe/gui/petrinet/dataLayer/DataLayer.java (+11/-33) src/main/java/pipe/gui/petrinet/editor/AnnotationPanel.java (+2/-2) src/main/java/pipe/gui/petrinet/editor/EditorFocusTraversalPolicy.java (+8/-6) src/main/java/pipe/gui/petrinet/editor/GuardDialogue.java (+112/-92) src/main/java/pipe/gui/petrinet/editor/PlaceEditorPanel.java (+715/-81) src/main/java/pipe/gui/petrinet/editor/TAPNTransitionEditor.java (+61/-38) src/main/java/pipe/gui/petrinet/graphicElements/AnnotationNote.java (+66/-51) src/main/java/pipe/gui/petrinet/graphicElements/Arc.java (+56/-22) src/main/java/pipe/gui/petrinet/graphicElements/ArcPath.java (+18/-15) src/main/java/pipe/gui/petrinet/graphicElements/ArcPathPoint.java (+60/-20) src/main/java/pipe/gui/petrinet/graphicElements/Drawable.java (+1/-1) src/main/java/pipe/gui/petrinet/graphicElements/GraphicalElement.java (+1/-17) src/main/java/pipe/gui/petrinet/graphicElements/NameLabel.java (+8/-9) src/main/java/pipe/gui/petrinet/graphicElements/Note.java (+26/-30) src/main/java/pipe/gui/petrinet/graphicElements/PetriNetObject.java (+37/-79) src/main/java/pipe/gui/petrinet/graphicElements/PetriNetObjectWithLabel.java (+9/-9) src/main/java/pipe/gui/petrinet/graphicElements/Place.java (+38/-19) src/main/java/pipe/gui/petrinet/graphicElements/PlaceTransitionObject.java (+38/-7) src/main/java/pipe/gui/petrinet/graphicElements/Transition.java (+45/-22) src/main/java/pipe/gui/petrinet/graphicElements/Translatable.java (+1/-1) src/main/java/pipe/gui/petrinet/graphicElements/Zoomable.java (+1/-1) src/main/java/pipe/gui/petrinet/graphicElements/tapn/TimedInhibitorArcComponent.java (+36/-32) src/main/java/pipe/gui/petrinet/graphicElements/tapn/TimedInputArcComponent.java (+54/-27) src/main/java/pipe/gui/petrinet/graphicElements/tapn/TimedOutputArcComponent.java (+54/-34) src/main/java/pipe/gui/petrinet/graphicElements/tapn/TimedPlaceComponent.java (+379/-285) src/main/java/pipe/gui/petrinet/graphicElements/tapn/TimedTransitionComponent.java (+99/-37) src/main/java/pipe/gui/petrinet/graphicElements/tapn/TimedTransportArcComponent.java (+106/-83) src/main/java/pipe/gui/petrinet/handler/LabelHandler.java (+10/-10) src/main/java/pipe/gui/petrinet/undo/AddAnnotationNoteCommand.java (+4/-4) src/main/java/pipe/gui/petrinet/undo/AddArcPathPointEditCommand.java (+8/-8) src/main/java/pipe/gui/petrinet/undo/AnnotationBorderEditCommand.java (+5/-5) src/main/java/pipe/gui/petrinet/undo/AnnotationTextEditCommand.java (+6/-6) src/main/java/pipe/gui/petrinet/undo/ArcPathPointTypeEditCommand.java (+5/-5) src/main/java/pipe/gui/petrinet/undo/ArcTimeIntervalEditCommand.java (+6/-6) src/main/java/pipe/gui/petrinet/undo/CompundCommand.java (+29/-0) src/main/java/pipe/gui/petrinet/undo/DeleteAnnotationNoteCommand.java (+4/-4) src/main/java/pipe/gui/petrinet/undo/DeleteArcPathPointEditCommand.java (+11/-11) src/main/java/pipe/gui/petrinet/undo/TAPNElementCommand.java (+3/-3) src/main/java/pipe/gui/petrinet/undo/TransitionRotationEditCommand.java (+5/-5) src/main/java/pipe/gui/petrinet/undo/TranslatePetriNetObjectEditCommand.java (+6/-6) src/main/java/pipe/gui/petrinet/undo/UndoManager.java (+16/-11) src/main/java/pipe/gui/swingcomponents/EscapableDialog.java (+49/-0) src/main/java/pipe/gui/swingcomponents/WidthAdjustingComboBox.java (+60/-0) src/main/java/pipe/gui/swingcomponents/filebrowser/FileBrowser.java (+187/-0) src/main/javacc/dk/aau/cs/TCTL/Parsing/TAPAALQueryParser.jj (+6/-6) src/main/javacc/dk/aau/cs/model/CPN/ArcExpressionParser/ArcExpressionParser.jj (+273/-0) src/main/javacc/dk/aau/cs/model/CPN/GuardExpressionParser/GuardExpressionParser.jj (+223/-0) src/main/resources/Example nets/ERK.tapn (+1/-1) src/main/resources/Example nets/alternating-bit-protocol-components.tapn (+1/-1) src/main/resources/Example nets/alternating-bit-protocol-transport.tapn (+1/-1) src/main/resources/Example nets/alternating-bit-protocol.tapn (+1/-1) src/main/resources/Example nets/cpn-packet.tapn (+351/-0) src/main/resources/Example nets/fischer-protocol.tapn (+1/-1) src/main/resources/Example nets/game-harddisk.tapn (+1/-1) src/main/resources/Example nets/home-construction.tapn (+1/-1) src/main/resources/Example nets/intro-example.tapn (+2/-2) src/main/resources/Example nets/package-delivery.tapn (+1/-1) src/main/resources/Example nets/philosophers.tapn (+539/-0) src/main/resources/Example nets/producer-consumer.tapn (+1/-1) src/main/resources/Example nets/referendum-colored.tapn (+285/-0) src/main/resources/Example nets/referendum-timed-colored.tapn (+223/-0) src/main/resources/Example nets/shortest-path.tapn (+1/-1) src/main/resources/Example nets/token-ring.tapn (+437/-0) src/main/resources/Example nets/train-level-crossing.tapn (+1/-1) src/main/resources/Example nets/two-phase-locking.tapn (+1/-1) src/main/resources/Example nets/untimedGame.tapn (+1/-1) src/main/resources/Example nets/webserver.tapn (+1/-1) src/main/resources/Example nets/workflow-advanced.tapn (+1/-1) src/main/resources/Example nets/workflow-complaint.tapn (+1/-1) src/main/resources/Example nets/workflow-medical.tapn (+1/-1) src/main/resources/Example nets/workflow-payment.tapn (+1/-1) src/main/resources/Example nets/workflow-simple.tapn (+1/-1) src/pipe/gui/handler/AnnotationNoteHandler.java (+0/-56) src/pipe/gui/handler/ArcHandler.java (+0/-77) src/pipe/gui/handler/ArcPathPointHandler.java (+0/-95) src/pipe/gui/handler/NoteHandler.java (+0/-13) src/pipe/gui/handler/PetriNetObjectHandler.java (+0/-168) src/pipe/gui/handler/PlaceHandler.java (+0/-45) src/pipe/gui/handler/PlaceTransitionObjectHandler.java (+0/-57) src/pipe/gui/handler/TimedArcHandler.java (+0/-31) src/pipe/gui/handler/TransitionHandler.java (+0/-44) src/pipe/gui/undo/TimedPlaceInvariantEdit.java (+0/-33) src/pipe/gui/widgets/EscapableDialog.java (+0/-49) src/pipe/gui/widgets/filebrowser/FileBrowser.java (+0/-53) src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java (+0/-178) src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java (+0/-191) src/test/java/dk/aau/cs/io/TapnXmlLoaderTest.kt (+1/-1) src/test/java/dk/aau/cs/model/tapn/LocalTimedPlaceTest.kt (+107/-0) |
To merge this branch: | bzr merge lp:~tapaal-contributor/tapaal/cpn-gui-dev |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Peter Haahr Taankvist | Pending | ||
Jiri Srba | Pending | ||
Thomas Pedersen | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2021-06-15.
Commit message
Proposal of complete colored GUI including: Colortypes, variables, arc expression and colored arc intervals menu, guard expression menu, place and colored invariant menu, verification of colored nets and unfolding of colored nets.
To use all the features described in: https:/
you will need verifydtapn with colors: https:/
(Org branched from https:/
and verifypn with colors: https:/
Description of the change
I added a milestone for specifically to track bugs, so that we can keep the log in the pull request for code specific changes.
When creating a new bug related to the CPN branch, select the milestone TAPAAL CPN, this way we can easly filter bugs related to the branch, use this link: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kenneth Yrke Jørgensen (yrke) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kenneth Yrke Jørgensen (yrke) wrote : Posted in a previous version of this proposal | # |
File: ColoredArcGuard
Function deleteSelections(), line 752
This "if" seems to have an flow error:
if (currentSelecti
replacement = getSpecificChil
}
else if (currentSelecti
replacement = new PlaceHolderColo
}
Second branch can't be reached, as it has the same guad as first branch. This must be a logical error.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kenneth Yrke Jørgensen (yrke) wrote (last edit ): Posted in a previous version of this proposal | # |
I noticed there seem to be a lot of TODO comments related to how colors should be handled.
I guess theses should all be adresse and can be removed safely?
If we leave in TODO comments for stuff that is already implemented or adresse elsewhere it can lead to confusion when we later revisit the code, as it might not be clear that the TODO comment is handled.
Intellij has a feature to list all todo/fixme etc. If there really is a todo, please add details about what is missing.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kenneth Yrke Jørgensen (yrke) wrote : Posted in a previous version of this proposal | # |
It seems some shortcuts are updated, please remember to update documentation: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kenneth Yrke Jørgensen (yrke) wrote : Posted in a previous version of this proposal | # |
I added a few more test to test out the api for new colors. I found a few problems in the interal consistency. Could you please have a look at this.
- 1625. By Jiri Srba
-
added explanation which color type cannot be removed (in case of multiple color type removal)
- 1626. By Kenneth Yrke Jørgensen
-
Potential fix for issue #1964937
Allow filter to be blank for selecting executable files in linux and macos
- 1627. By Jiri Srba
-
merged in lp:~tapaal-contributor/tapaal/cpn-remove-add fixing the transition guard dialog
- 1628. By Kenneth Yrke Jørgensen
-
Fixed bug #1964937
Iteration over a list that would be removed in the step above (list are references)
- 1629. By Lena Ernstsen
-
Fixed arc guard dialog not being able to display product colors
- 1630. By Lena Ernstsen
-
Fixed tuple selection problem in transition guard dialog
- 1631. By Lena Ernstsen
-
Fixed infinite loop when updating the color of an arc expression
- 1632. By Kenneth Yrke Jørgensen
-
Moved src files to gradle java project structure
- 1633. By Kenneth Yrke Jørgensen
-
Fixed what seems to be a logical error in selecting exporter
- 1634. By Kenneth Yrke Jørgensen
-
Fixed an issue where A E quantifiers would not show trace
- 1635. By Kenneth Yrke Jørgensen
-
Code cleanup
- 1636. By Kenneth Yrke Jørgensen
-
Fix for issue 1968474 Keep query cat when unfolding
- 1637. By Kenneth Yrke Jørgensen
-
Fixes #1968473, wrong filter applied in engine selection menu on windows
- 1638. By Kenneth Yrke Jørgensen
-
Fixed #1971420 unfolding empty net leads to error
It seems the unfolder genreates a dummy query to not have a empty list,
that query uses to reference the first templates first place, (which might not exist eg. net empty).
Insted change the dummy query to be E<>true. - 1639. By Kenneth Yrke Jørgensen
-
Workarround for #1971422, need to make a propper fix later
- 1640. By Kenneth Yrke Jørgensen
-
Fixed a possible NPE
- 1641. By Jiri Srba
-
merged in lp:~tapaal-contributor/tapaal/conjunction-button-fix fixing a problem with and/or buttons in query dialog
- 1642. By Jiri Srba
-
merged in lp:~tapaal-contributor/tapaal/fix-product-display-1971421 fixing product colors editing in transitions guards
- 1643. By Kenneth Yrke Jørgensen
-
Added null check
- 1644. By Kenneth Yrke Jørgensen
-
refixed #1940418 via workarround
- 1645. By Jiri Srba
-
merged with trunk (fixing copying of components with environemnatl transitions)
- 1646. By Jiri Srba
-
merged with trunk (fixing editing of LTL queries)
- 1647. By Kenneth Yrke Jørgensen
-
Fixed long line error messages
- 1648. By Kenneth Yrke Jørgensen
-
Fixed an issue where shared transiations was "added" double due to parent network being reused when flatting net
- 1649. By Kenneth Yrke Jørgensen
-
Upgraded project dependency, removed junit4
- 1650. By Kenneth Yrke Jørgensen
-
Added support for opening files by dragging then on the canvas
Preview Diff
1 | === modified file 'build.gradle' | |||
2 | --- build.gradle 2021-08-11 11:19:19 +0000 | |||
3 | +++ build.gradle 2022-07-21 13:30:11 +0000 | |||
4 | @@ -1,94 +1,70 @@ | |||
5 | 1 | plugins { | 1 | plugins { |
6 | 2 | id 'java' | 2 | id 'java' |
7 | 3 | id 'application' | 3 | id 'application' |
9 | 4 | id 'org.jetbrains.kotlin.jvm' version '1.3.71' | 4 | id 'org.jetbrains.kotlin.jvm' version '1.6.10' |
10 | 5 | id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.10' | ||
11 | 5 | id "ca.coglinc.javacc" version "2.4.0" | 6 | id "ca.coglinc.javacc" version "2.4.0" |
12 | 6 | } | 7 | } |
13 | 7 | 8 | ||
14 | 8 | group 'net.tapaal' | 9 | group 'net.tapaal' |
15 | 9 | version '4.0-SNAPSHOT' | 10 | version '4.0-SNAPSHOT' |
16 | 10 | 11 | ||
17 | 12 | var targetJavaVersion = JavaVersion.VERSION_11 | ||
18 | 13 | var targetKotlinVersion = "1.6" | ||
19 | 11 | java { | 14 | java { |
23 | 12 | sourceCompatibility = JavaVersion.VERSION_11 | 15 | sourceCompatibility = targetJavaVersion |
24 | 13 | targetCompatibility = JavaVersion.VERSION_11 | 16 | targetCompatibility = targetJavaVersion |
25 | 14 | } | 17 | } |
26 | 18 | |||
27 | 19 | compileKotlin { | ||
28 | 20 | sourceCompatibility = targetJavaVersion | ||
29 | 21 | targetCompatibility = targetJavaVersion | ||
30 | 22 | |||
31 | 23 | kotlinOptions { | ||
32 | 24 | jvmTarget = targetJavaVersion | ||
33 | 25 | apiVersion = targetKotlinVersion | ||
34 | 26 | languageVersion = targetKotlinVersion | ||
35 | 27 | } | ||
36 | 28 | } | ||
37 | 29 | |||
38 | 30 | mainClassName = 'TAPAAL' | ||
39 | 15 | 31 | ||
40 | 16 | repositories { | 32 | repositories { |
41 | 17 | mavenCentral() | 33 | mavenCentral() |
42 | 18 | } | 34 | } |
43 | 19 | 35 | ||
44 | 20 | compileJavacc { | ||
45 | 21 | inputDirectory = file('src/') | ||
46 | 22 | //outputDirectory = file(project.buildDir.absolutePath + '/generated/javacc') | ||
47 | 23 | } | ||
48 | 24 | |||
49 | 25 | //Set the soruce and resource dir | ||
50 | 26 | sourceSets { | 36 | sourceSets { |
51 | 27 | main { | 37 | main { |
52 | 28 | java { | 38 | java { |
66 | 29 | srcDirs = ['src/', compileJavacc.outputDirectory] | 39 | srcDir compileJavacc.outputDirectory |
54 | 30 | exclude("resources/") | ||
55 | 31 | } | ||
56 | 32 | resources { | ||
57 | 33 | //Resources should be in folder called resources, so only add the resources folder | ||
58 | 34 | //adding srv/resources will places content of the folder in root of jar file | ||
59 | 35 | srcDirs = ['src/'] | ||
60 | 36 | include("resources/") | ||
61 | 37 | } | ||
62 | 38 | test { | ||
63 | 39 | java { | ||
64 | 40 | srcDirs = ['tests/'] | ||
65 | 41 | } | ||
67 | 42 | } | 40 | } |
68 | 43 | } | 41 | } |
69 | 44 | } | 42 | } |
70 | 45 | 43 | ||
71 | 46 | mainClassName = 'TAPAAL' | ||
72 | 47 | |||
73 | 48 | jar { | 44 | jar { |
74 | 49 | exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF' | 45 | exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF' |
75 | 50 | 46 | ||
76 | 51 | //Sets the main call for the Jar, you can double click to run the jar file | 47 | //Sets the main call for the Jar, you can double click to run the jar file |
77 | 52 | manifest { | 48 | manifest { |
79 | 53 | attributes 'Main-Class': 'TAPAAL' | 49 | attributes ( |
80 | 50 | 'Main-Class': mainClassName | ||
81 | 51 | ) | ||
82 | 54 | } | 52 | } |
83 | 55 | //The following lines makes libs a part of the build jar file (standalone jar) | 53 | //The following lines makes libs a part of the build jar file (standalone jar) |
84 | 56 | //from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } | 54 | //from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } |
85 | 57 | } | 55 | } |
86 | 58 | 56 | ||
87 | 59 | dependencies { | 57 | dependencies { |
106 | 60 | implementation group: 'commons-cli', name: 'commons-cli', version: '1.4' | 58 | implementation 'commons-cli:commons-cli:1.5.0' |
107 | 61 | implementation group: 'org.swinglabs.swingx', name: 'swingx-all', version: '1.6.5-1' | 59 | implementation 'org.swinglabs.swingx:swingx-all:1.6.5-1' |
108 | 62 | implementation group: 'net.java.dev.jna', name: 'jna', version: '4.5.1' | 60 | implementation 'net.java.dev.jna:jna:5.11.0' |
109 | 63 | implementation 'org.jetbrains:annotations:16.0.2' | 61 | implementation 'org.jetbrains:annotations:23.0.0' |
110 | 64 | //compile group: 'com.apple', name: 'AppleJavaExtensions', version: '1.4' // Not working | 62 | implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3' |
111 | 65 | 63 | ||
112 | 66 | //Add jars from libs dir | 64 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' |
113 | 67 | implementation fileTree(dir: 'libs', include: ['*.jar']) | 65 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' |
96 | 68 | |||
97 | 69 | //Junit | ||
98 | 70 | testImplementation( | ||
99 | 71 | 'org.junit.jupiter:junit-jupiter-api:5.4.2' | ||
100 | 72 | ) | ||
101 | 73 | testRuntimeOnly( | ||
102 | 74 | 'org.junit.jupiter:junit-jupiter-engine:5.4.2', | ||
103 | 75 | 'org.junit.vintage:junit-vintage-engine:5.4.2' | ||
104 | 76 | ) | ||
105 | 77 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" | ||
114 | 78 | } | 66 | } |
115 | 67 | |||
116 | 79 | test { | 68 | test { |
117 | 80 | useJUnitPlatform() | 69 | useJUnitPlatform() |
118 | 81 | afterTest { desc, result -> | ||
119 | 82 | logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}" | ||
120 | 83 | } | ||
121 | 84 | } | ||
122 | 85 | compileKotlin { | ||
123 | 86 | kotlinOptions { | ||
124 | 87 | jvmTarget = JavaVersion.VERSION_11 | ||
125 | 88 | } | ||
126 | 89 | } | ||
127 | 90 | compileTestKotlin { | ||
128 | 91 | kotlinOptions { | ||
129 | 92 | jvmTarget = JavaVersion.VERSION_11 | ||
130 | 93 | } | ||
131 | 94 | } | 70 | } |
132 | 95 | 71 | ||
133 | === modified file 'gradle/wrapper/gradle-wrapper.jar' | |||
134 | 96 | Binary files gradle/wrapper/gradle-wrapper.jar and gradle/wrapper/gradle-wrapper.jar differ | 72 | Binary files gradle/wrapper/gradle-wrapper.jar and gradle/wrapper/gradle-wrapper.jar differ |
135 | === modified file 'gradle/wrapper/gradle-wrapper.properties' | |||
136 | --- gradle/wrapper/gradle-wrapper.properties 2020-04-06 12:41:08 +0000 | |||
137 | +++ gradle/wrapper/gradle-wrapper.properties 2022-07-21 13:30:11 +0000 | |||
138 | @@ -1,6 +1,5 @@ | |||
145 | 1 | #Mon Apr 06 14:40:09 CEST 2020 | 1 | distributionBase=GRADLE_USER_HOME |
146 | 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip | 2 | distributionPath=wrapper/dists |
147 | 3 | distributionBase=GRADLE_USER_HOME | 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip |
148 | 4 | distributionPath=wrapper/dists | 4 | zipStoreBase=GRADLE_USER_HOME |
149 | 5 | zipStorePath=wrapper/dists | 5 | zipStorePath=wrapper/dists |
144 | 6 | zipStoreBase=GRADLE_USER_HOME | ||
150 | 7 | 6 | ||
151 | === modified file 'gradlew' | |||
152 | --- gradlew 2020-09-01 08:14:52 +0000 | |||
153 | +++ gradlew 2022-07-21 13:30:11 +0000 | |||
154 | @@ -82,6 +82,7 @@ | |||
155 | 82 | 82 | ||
156 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar |
157 | 84 | 84 | ||
158 | 85 | |||
159 | 85 | # Determine the Java command to use to start the JVM. | 86 | # Determine the Java command to use to start the JVM. |
160 | 86 | if [ -n "$JAVA_HOME" ] ; then | 87 | if [ -n "$JAVA_HOME" ] ; then |
161 | 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then |
162 | @@ -129,6 +130,7 @@ | |||
163 | 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then | 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then |
164 | 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` | 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` |
165 | 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` |
166 | 133 | |||
167 | 132 | JAVACMD=`cygpath --unix "$JAVACMD"` | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` |
168 | 133 | 135 | ||
169 | 134 | # We build the pattern for arguments to be converted via cygpath | 136 | # We build the pattern for arguments to be converted via cygpath |
170 | 135 | 137 | ||
171 | === modified file 'gradlew.bat' | |||
172 | --- gradlew.bat 2020-03-28 10:29:30 +0000 | |||
173 | +++ gradlew.bat 2022-07-21 13:30:11 +0000 | |||
174 | @@ -40,7 +40,7 @@ | |||
175 | 40 | 40 | ||
176 | 41 | set JAVA_EXE=java.exe | 41 | set JAVA_EXE=java.exe |
177 | 42 | %JAVA_EXE% -version >NUL 2>&1 | 42 | %JAVA_EXE% -version >NUL 2>&1 |
179 | 43 | if "%ERRORLEVEL%" == "0" goto init | 43 | if "%ERRORLEVEL%" == "0" goto execute |
180 | 44 | 44 | ||
181 | 45 | echo. | 45 | echo. |
182 | 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
183 | @@ -54,7 +54,7 @@ | |||
184 | 54 | set JAVA_HOME=%JAVA_HOME:"=% | 54 | set JAVA_HOME=%JAVA_HOME:"=% |
185 | 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe | 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe |
186 | 56 | 56 | ||
188 | 57 | if exist "%JAVA_EXE%" goto init | 57 | if exist "%JAVA_EXE%" goto execute |
189 | 58 | 58 | ||
190 | 59 | echo. | 59 | echo. |
191 | 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% |
192 | @@ -64,28 +64,14 @@ | |||
193 | 64 | 64 | ||
194 | 65 | goto fail | 65 | goto fail |
195 | 66 | 66 | ||
196 | 67 | :init | ||
197 | 68 | @rem Get command-line arguments, handling Windows variants | ||
198 | 69 | |||
199 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args | ||
200 | 71 | |||
201 | 72 | :win9xME_args | ||
202 | 73 | @rem Slurp the command line arguments. | ||
203 | 74 | set CMD_LINE_ARGS= | ||
204 | 75 | set _SKIP=2 | ||
205 | 76 | |||
206 | 77 | :win9xME_args_slurp | ||
207 | 78 | if "x%~1" == "x" goto execute | ||
208 | 79 | |||
209 | 80 | set CMD_LINE_ARGS=%* | ||
210 | 81 | |||
211 | 82 | :execute | 67 | :execute |
212 | 83 | @rem Setup the command line | 68 | @rem Setup the command line |
213 | 84 | 69 | ||
214 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar |
215 | 86 | 71 | ||
216 | 72 | |||
217 | 87 | @rem Execute Gradle | 73 | @rem Execute Gradle |
219 | 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* |
220 | 89 | 75 | ||
221 | 90 | :end | 76 | :end |
222 | 91 | @rem End local scope for the variables with windows NT shell | 77 | @rem End local scope for the variables with windows NT shell |
223 | 92 | 78 | ||
224 | === removed directory 'src/dk/aau/cs/gui' | |||
225 | === removed directory 'src/dk/aau/cs/gui/components' | |||
226 | === removed directory 'src/dk/aau/cs/gui/components/handlers' | |||
227 | === removed directory 'src/dk/aau/cs/gui/smartDraw' | |||
228 | === removed directory 'src/dk/aau/cs/gui/undo' | |||
229 | === removed file 'src/dk/aau/cs/util/ExecutabilityChecker.java' | |||
230 | --- src/dk/aau/cs/util/ExecutabilityChecker.java 2016-03-16 18:05:19 +0000 | |||
231 | +++ src/dk/aau/cs/util/ExecutabilityChecker.java 1970-01-01 00:00:00 +0000 | |||
232 | @@ -1,42 +0,0 @@ | |||
233 | 1 | package dk.aau.cs.util; | ||
234 | 2 | |||
235 | 3 | import java.io.BufferedReader; | ||
236 | 4 | import java.io.InputStream; | ||
237 | 5 | import java.io.InputStreamReader; | ||
238 | 6 | |||
239 | 7 | public class ExecutabilityChecker { | ||
240 | 8 | public static void check(String path) throws IllegalArgumentException{ | ||
241 | 9 | int rcode = -1; | ||
242 | 10 | try { | ||
243 | 11 | Process p = Runtime.getRuntime().exec(new String[] { path, "-v" }); | ||
244 | 12 | |||
245 | 13 | // Because some native platforms only provide limited buffer size | ||
246 | 14 | // for standard input and output streams, failure to promptly write | ||
247 | 15 | // the input stream or read the output stream of the subprocess may | ||
248 | 16 | // cause the subprocess to block, and even deadlock. | ||
249 | 17 | |||
250 | 18 | InputStream stream = p.getInputStream(); | ||
251 | 19 | InputStreamReader isr = new InputStreamReader(stream); | ||
252 | 20 | BufferedReader br = new BufferedReader(isr); | ||
253 | 21 | while (br.readLine() != null){} | ||
254 | 22 | |||
255 | 23 | stream = p.getErrorStream(); | ||
256 | 24 | isr = new InputStreamReader(stream); | ||
257 | 25 | br = new BufferedReader(isr); | ||
258 | 26 | while (br.readLine() != null){} | ||
259 | 27 | |||
260 | 28 | rcode = p.waitFor(); // Requires binary to accept -v flag | ||
261 | 29 | } catch (Exception e) { | ||
262 | 30 | // Do nothing | ||
263 | 31 | } | ||
264 | 32 | // Detect executable issues | ||
265 | 33 | switch(rcode){ | ||
266 | 34 | case 0: | ||
267 | 35 | break; | ||
268 | 36 | case 126: | ||
269 | 37 | throw new IllegalArgumentException("The selected file is not executable on this system."); | ||
270 | 38 | default: | ||
271 | 39 | throw new IllegalArgumentException("The selected file is not executable or not compatible with your system (return value "+rcode+")."); | ||
272 | 40 | } | ||
273 | 41 | } | ||
274 | 42 | } | ||
275 | 43 | \ No newline at end of file | 0 | \ No newline at end of file |
276 | 44 | 1 | ||
277 | === added directory 'src/main' | |||
278 | === added directory 'src/main/java' | |||
279 | === renamed file 'src/TAPAAL.java' => 'src/main/java/TAPAAL.java' | |||
280 | === renamed directory 'src/dk' => 'src/main/java/dk' | |||
281 | === modified file 'src/main/java/dk/aau/cs/TCTL/AritmeticOperator.java' | |||
282 | --- src/dk/aau/cs/TCTL/AritmeticOperator.java 2020-11-06 19:41:50 +0000 | |||
283 | +++ src/main/java/dk/aau/cs/TCTL/AritmeticOperator.java 2022-07-21 13:30:11 +0000 | |||
284 | @@ -4,7 +4,7 @@ | |||
285 | 4 | 4 | ||
286 | 5 | public class AritmeticOperator extends TCTLAbstractStateProperty { | 5 | public class AritmeticOperator extends TCTLAbstractStateProperty { |
287 | 6 | 6 | ||
289 | 7 | String operator; | 7 | final String operator; |
290 | 8 | 8 | ||
291 | 9 | public AritmeticOperator(String operator) { | 9 | public AritmeticOperator(String operator) { |
292 | 10 | this.operator = operator; | 10 | this.operator = operator; |
293 | 11 | 11 | ||
294 | === modified file 'src/main/java/dk/aau/cs/TCTL/LTLGNode.java' | |||
295 | --- src/dk/aau/cs/TCTL/LTLGNode.java 2021-10-08 06:26:14 +0000 | |||
296 | +++ src/main/java/dk/aau/cs/TCTL/LTLGNode.java 2022-07-21 13:30:11 +0000 | |||
297 | @@ -20,7 +20,7 @@ | |||
298 | 20 | } | 20 | } |
299 | 21 | 21 | ||
300 | 22 | public LTLGNode() { | 22 | public LTLGNode() { |
302 | 23 | this.property = new TCTLStatePlaceHolder();; | 23 | this.property = new TCTLStatePlaceHolder(); |
303 | 24 | this.property.setParent(this); | 24 | this.property.setParent(this); |
304 | 25 | } | 25 | } |
305 | 26 | 26 | ||
306 | 27 | 27 | ||
307 | === modified file 'src/main/java/dk/aau/cs/TCTL/LTLUNode.java' | |||
308 | --- src/dk/aau/cs/TCTL/LTLUNode.java 2021-10-08 06:26:14 +0000 | |||
309 | +++ src/main/java/dk/aau/cs/TCTL/LTLUNode.java 2022-07-21 13:30:11 +0000 | |||
310 | @@ -54,7 +54,7 @@ | |||
311 | 54 | StringPosition leftPos = new StringPosition(leftStart, leftEnd, left); | 54 | StringPosition leftPos = new StringPosition(leftStart, leftEnd, left); |
312 | 55 | 55 | ||
313 | 56 | int rightStart = right.isSimpleProperty() ? 0 : 1; | 56 | int rightStart = right.isSimpleProperty() ? 0 : 1; |
315 | 57 | rightStart += leftEnd + 3 + + (left.isSimpleProperty() ? 0 : 1); | 57 | rightStart += leftEnd + 3 + (left.isSimpleProperty() ? 0 : 1); |
316 | 58 | int rightEnd = rightStart + right.toString().length(); | 58 | int rightEnd = rightStart + right.toString().length(); |
317 | 59 | StringPosition rightPos = new StringPosition(rightStart, rightEnd, right); | 59 | StringPosition rightPos = new StringPosition(rightStart, rightEnd, right); |
318 | 60 | 60 | ||
319 | 61 | 61 | ||
320 | === modified file 'src/main/java/dk/aau/cs/TCTL/StringPosition.java' | |||
321 | --- src/dk/aau/cs/TCTL/StringPosition.java 2011-02-03 19:03:15 +0000 | |||
322 | +++ src/main/java/dk/aau/cs/TCTL/StringPosition.java 2022-07-21 13:30:11 +0000 | |||
323 | @@ -4,10 +4,9 @@ | |||
324 | 4 | 4 | ||
325 | 5 | private int startIndex; | 5 | private int startIndex; |
326 | 6 | private int endIndex; | 6 | private int endIndex; |
328 | 7 | private TCTLAbstractProperty object; | 7 | private final TCTLAbstractProperty object; |
329 | 8 | 8 | ||
332 | 9 | public StringPosition(int startIndex, int endIndex, | 9 | public StringPosition(int startIndex, int endIndex, TCTLAbstractProperty object) { |
331 | 10 | TCTLAbstractProperty object) { | ||
333 | 11 | this.startIndex = startIndex; | 10 | this.startIndex = startIndex; |
334 | 12 | this.endIndex = endIndex; | 11 | this.endIndex = endIndex; |
335 | 13 | this.object = object; | 12 | this.object = object; |
336 | 14 | 13 | ||
337 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLAUNode.java' | |||
338 | --- src/dk/aau/cs/TCTL/TCTLAUNode.java 2020-11-06 19:41:50 +0000 | |||
339 | +++ src/main/java/dk/aau/cs/TCTL/TCTLAUNode.java 2022-07-21 13:30:11 +0000 | |||
340 | @@ -50,7 +50,7 @@ | |||
341 | 50 | StringPosition leftPos = new StringPosition(leftStart, leftEnd, left); | 50 | StringPosition leftPos = new StringPosition(leftStart, leftEnd, left); |
342 | 51 | 51 | ||
343 | 52 | int rightStart = right.isSimpleProperty() ? 0 : 1; | 52 | int rightStart = right.isSimpleProperty() ? 0 : 1; |
345 | 53 | rightStart += leftEnd + 3 + + (left.isSimpleProperty() ? 0 : 1); | 53 | rightStart += leftEnd + 3 + (left.isSimpleProperty() ? 0 : 1); |
346 | 54 | int rightEnd = rightStart + right.toString().length(); | 54 | int rightEnd = rightStart + right.toString().length(); |
347 | 55 | StringPosition rightPos = new StringPosition(rightStart, rightEnd, right); | 55 | StringPosition rightPos = new StringPosition(rightStart, rightEnd, right); |
348 | 56 | 56 | ||
349 | 57 | 57 | ||
350 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLAbstractProperty.java' | |||
351 | --- src/dk/aau/cs/TCTL/TCTLAbstractProperty.java 2021-08-16 07:29:37 +0000 | |||
352 | +++ src/main/java/dk/aau/cs/TCTL/TCTLAbstractProperty.java 2022-07-21 13:30:11 +0000 | |||
353 | @@ -2,8 +2,6 @@ | |||
354 | 2 | 2 | ||
355 | 3 | import dk.aau.cs.TCTL.visitors.ITCTLVisitor; | 3 | import dk.aau.cs.TCTL.visitors.ITCTLVisitor; |
356 | 4 | 4 | ||
357 | 5 | import java.util.Locale; | ||
358 | 6 | |||
359 | 7 | public abstract class TCTLAbstractProperty { | 5 | public abstract class TCTLAbstractProperty { |
360 | 8 | 6 | ||
361 | 9 | // used to determine whether to put parenthesis around the property | 7 | // used to determine whether to put parenthesis around the property |
362 | 10 | 8 | ||
363 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java' | |||
364 | --- src/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java 2011-02-03 19:03:15 +0000 | |||
365 | +++ src/main/java/dk/aau/cs/TCTL/TCTLAbstractStateProperty.java 2022-07-21 13:30:11 +0000 | |||
366 | @@ -18,18 +18,4 @@ | |||
367 | 18 | 18 | ||
368 | 19 | @Override | 19 | @Override |
369 | 20 | public abstract TCTLAbstractStateProperty copy(); | 20 | public abstract TCTLAbstractStateProperty copy(); |
370 | 21 | |||
371 | 22 | // public abstract void accept(ICSLVisitor visitor) throws | ||
372 | 23 | // ModelCheckingException; | ||
373 | 24 | |||
374 | 25 | // protected abstract void setCompositionality(boolean | ||
375 | 26 | // withinSteadyStateOperator); | ||
376 | 27 | |||
377 | 28 | // public void setCompositionality() { | ||
378 | 29 | // setCompositionality(false); | ||
379 | 30 | // } | ||
380 | 31 | // | ||
381 | 32 | // public boolean isCompositional() { | ||
382 | 33 | // return isCompositional; | ||
383 | 34 | // } | ||
384 | 35 | } | 21 | } |
385 | 36 | 22 | ||
386 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLAndListNode.java' | |||
387 | --- src/dk/aau/cs/TCTL/TCTLAndListNode.java 2020-11-06 19:41:50 +0000 | |||
388 | +++ src/main/java/dk/aau/cs/TCTL/TCTLAndListNode.java 2022-07-21 13:30:11 +0000 | |||
389 | @@ -77,8 +77,7 @@ | |||
390 | 77 | s.append(" and "); | 77 | s.append(" and "); |
391 | 78 | } | 78 | } |
392 | 79 | 79 | ||
395 | 80 | s.append(prop.isSimpleProperty() ? prop.toString() : "(" | 80 | s.append(prop.isSimpleProperty() ? prop.toString() : "(" + prop + ")"); |
394 | 81 | + prop.toString() + ")"); | ||
396 | 82 | firstTime = false; | 81 | firstTime = false; |
397 | 83 | } | 82 | } |
398 | 84 | 83 | ||
399 | 85 | 84 | ||
400 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java' | |||
401 | --- src/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java 2020-11-06 19:41:50 +0000 | |||
402 | +++ src/main/java/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.java 2022-07-21 13:30:11 +0000 | |||
403 | @@ -94,31 +94,6 @@ | |||
404 | 94 | return false; | 94 | return false; |
405 | 95 | } | 95 | } |
406 | 96 | 96 | ||
407 | 97 | /* @Override | ||
408 | 98 | public StringPosition[] getChildren() { | ||
409 | 99 | StringPosition[] children = new StringPosition[2]; | ||
410 | 100 | |||
411 | 101 | int start = 0; | ||
412 | 102 | int end = 0; | ||
413 | 103 | boolean leftSimpleProperty = left.isSimpleProperty(); | ||
414 | 104 | |||
415 | 105 | start = leftSimpleProperty ? 0 : 1; | ||
416 | 106 | end = start + left.toString().length(); | ||
417 | 107 | |||
418 | 108 | StringPosition posLeft = new StringPosition(start, end, left); | ||
419 | 109 | |||
420 | 110 | start = end + 5 + (right.isSimpleProperty() ? 0 : 1) | ||
421 | 111 | + (leftSimpleProperty ? 0 : 1); | ||
422 | 112 | |||
423 | 113 | end = start + right.toString().length(); | ||
424 | 114 | |||
425 | 115 | StringPosition posRight = new StringPosition(start, end, right); | ||
426 | 116 | |||
427 | 117 | children[0] = posLeft; | ||
428 | 118 | children[1] = posRight; | ||
429 | 119 | return children; | ||
430 | 120 | }*/ | ||
431 | 121 | |||
432 | 122 | @Override | 97 | @Override |
433 | 123 | public TCTLAbstractProperty findFirstPlaceHolder() { | 98 | public TCTLAbstractProperty findFirstPlaceHolder() { |
434 | 124 | TCTLAbstractProperty rightP = right.findFirstPlaceHolder(); | 99 | TCTLAbstractProperty rightP = right.findFirstPlaceHolder(); |
435 | 125 | 100 | ||
436 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLConstNode.java' | |||
437 | --- src/dk/aau/cs/TCTL/TCTLConstNode.java 2020-11-06 19:41:50 +0000 | |||
438 | +++ src/main/java/dk/aau/cs/TCTL/TCTLConstNode.java 2022-07-21 13:30:11 +0000 | |||
439 | @@ -4,7 +4,7 @@ | |||
440 | 4 | 4 | ||
441 | 5 | public class TCTLConstNode extends TCTLAbstractStateProperty { | 5 | public class TCTLConstNode extends TCTLAbstractStateProperty { |
442 | 6 | 6 | ||
444 | 7 | int constant; | 7 | final int constant; |
445 | 8 | 8 | ||
446 | 9 | public TCTLConstNode(int constant) { | 9 | public TCTLConstNode(int constant) { |
447 | 10 | this.constant = constant; | 10 | this.constant = constant; |
448 | 11 | 11 | ||
449 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLEFNode.java' | |||
450 | --- src/dk/aau/cs/TCTL/TCTLEFNode.java 2021-09-14 20:13:01 +0000 | |||
451 | +++ src/main/java/dk/aau/cs/TCTL/TCTLEFNode.java 2022-07-21 13:30:11 +0000 | |||
452 | @@ -2,8 +2,6 @@ | |||
453 | 2 | 2 | ||
454 | 3 | import dk.aau.cs.TCTL.visitors.ITCTLVisitor; | 3 | import dk.aau.cs.TCTL.visitors.ITCTLVisitor; |
455 | 4 | 4 | ||
456 | 5 | import java.util.HashMap; | ||
457 | 6 | |||
458 | 7 | public class TCTLEFNode extends TCTLAbstractPathProperty { | 5 | public class TCTLEFNode extends TCTLAbstractPathProperty { |
459 | 8 | 6 | ||
460 | 9 | private TCTLAbstractStateProperty property; | 7 | private TCTLAbstractStateProperty property; |
461 | 10 | 8 | ||
462 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLOrListNode.java' | |||
463 | --- src/dk/aau/cs/TCTL/TCTLOrListNode.java 2020-11-06 19:41:50 +0000 | |||
464 | +++ src/main/java/dk/aau/cs/TCTL/TCTLOrListNode.java 2022-07-21 13:30:11 +0000 | |||
465 | @@ -77,8 +77,7 @@ | |||
466 | 77 | s.append(" or "); | 77 | s.append(" or "); |
467 | 78 | } | 78 | } |
468 | 79 | 79 | ||
471 | 80 | s.append(prop.isSimpleProperty() ? prop.toString() : "(" | 80 | s.append(prop.isSimpleProperty() ? prop.toString() : "(" + prop + ")"); |
470 | 81 | + prop.toString() + ")"); | ||
472 | 82 | firstTime = false; | 81 | firstTime = false; |
473 | 83 | } | 82 | } |
474 | 84 | 83 | ||
475 | 85 | 84 | ||
476 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLPlusListNode.java' | |||
477 | --- src/dk/aau/cs/TCTL/TCTLPlusListNode.java 2020-11-06 19:41:50 +0000 | |||
478 | +++ src/main/java/dk/aau/cs/TCTL/TCTLPlusListNode.java 2022-07-21 13:30:11 +0000 | |||
479 | @@ -8,7 +8,7 @@ | |||
480 | 8 | //Represents a list of terms and the operators between then, these are all stored in the terms list | 8 | //Represents a list of terms and the operators between then, these are all stored in the terms list |
481 | 9 | public class TCTLPlusListNode extends TCTLAbstractStateProperty { | 9 | public class TCTLPlusListNode extends TCTLAbstractStateProperty { |
482 | 10 | 10 | ||
484 | 11 | ArrayList<TCTLAbstractStateProperty> terms; | 11 | final ArrayList<TCTLAbstractStateProperty> terms; |
485 | 12 | 12 | ||
486 | 13 | public TCTLPlusListNode(ArrayList<TCTLAbstractStateProperty> terms) { | 13 | public TCTLPlusListNode(ArrayList<TCTLAbstractStateProperty> terms) { |
487 | 14 | this.terms = terms; | 14 | this.terms = terms; |
488 | 15 | 15 | ||
489 | === modified file 'src/main/java/dk/aau/cs/TCTL/TCTLTermListNode.java' | |||
490 | --- src/dk/aau/cs/TCTL/TCTLTermListNode.java 2020-11-06 19:41:50 +0000 | |||
491 | +++ src/main/java/dk/aau/cs/TCTL/TCTLTermListNode.java 2022-07-21 13:30:11 +0000 | |||
492 | @@ -8,7 +8,7 @@ | |||
493 | 8 | //Represents a list of factors and the operators between then, these are all stored in the factors list | 8 | //Represents a list of factors and the operators between then, these are all stored in the factors list |
494 | 9 | public class TCTLTermListNode extends TCTLAbstractStateProperty { | 9 | public class TCTLTermListNode extends TCTLAbstractStateProperty { |
495 | 10 | 10 | ||
497 | 11 | ArrayList<TCTLAbstractStateProperty> factors; | 11 | final ArrayList<TCTLAbstractStateProperty> factors; |
498 | 12 | 12 | ||
499 | 13 | public TCTLTermListNode(ArrayList<TCTLAbstractStateProperty> factors) { | 13 | public TCTLTermListNode(ArrayList<TCTLAbstractStateProperty> factors) { |
500 | 14 | this.factors = factors; | 14 | this.factors = factors; |
501 | 15 | 15 | ||
502 | === modified file 'src/main/java/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java' | |||
503 | --- src/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java 2017-05-14 19:42:09 +0000 | |||
504 | +++ src/main/java/dk/aau/cs/TCTL/XMLParsing/XMLCTLQueryParser.java 2022-07-21 13:30:11 +0000 | |||
505 | @@ -44,9 +44,9 @@ | |||
506 | 44 | XMLCTLQueryParser parser = new XMLCTLQueryParser(prop, queryWrapper); | 44 | XMLCTLQueryParser parser = new XMLCTLQueryParser(prop, queryWrapper); |
507 | 45 | queryWrapper.setName(parser.parsePropertyName()); | 45 | queryWrapper.setName(parser.parsePropertyName()); |
508 | 46 | 46 | ||
510 | 47 | try{ | 47 | try { |
511 | 48 | queryWrapper.setProp(parser.AbstractProperty()); | 48 | queryWrapper.setProp(parser.AbstractProperty()); |
513 | 49 | } catch (XMLQueryParseException e){ | 49 | } catch (XMLQueryParseException e) { |
514 | 50 | queryWrapper.setException(e); | 50 | queryWrapper.setException(e); |
515 | 51 | Logger.log(e); | 51 | Logger.log(e); |
516 | 52 | return false; | 52 | return false; |
517 | @@ -87,14 +87,14 @@ | |||
518 | 87 | } | 87 | } |
519 | 88 | 88 | ||
520 | 89 | private TCTLAbstractProperty parseFormula(Node property) | 89 | private TCTLAbstractProperty parseFormula(Node property) |
522 | 90 | throws XMLQueryParseException{ | 90 | throws XMLQueryParseException { |
523 | 91 | 91 | ||
524 | 92 | TCTLAbstractProperty childProperty; | 92 | TCTLAbstractProperty childProperty; |
525 | 93 | Node child = getFirstChildNode(property); | 93 | Node child = getFirstChildNode(property); |
526 | 94 | String nodeName = property.getNodeName(); | 94 | String nodeName = property.getNodeName(); |
527 | 95 | 95 | ||
528 | 96 | String childNodeName = ""; | 96 | String childNodeName = ""; |
530 | 97 | if(child != null){ | 97 | if (child != null) { |
531 | 98 | childNodeName = child.getNodeName(); | 98 | childNodeName = child.getNodeName(); |
532 | 99 | } | 99 | } |
533 | 100 | 100 | ||
534 | @@ -366,38 +366,40 @@ | |||
535 | 366 | } else if(nodeName.equals("integer-ge")){ | 366 | } else if(nodeName.equals("integer-ge")){ |
536 | 367 | return new TCTLAtomicPropositionNode(subformula1, ">=", subformula2); | 367 | return new TCTLAtomicPropositionNode(subformula1, ">=", subformula2); |
537 | 368 | } | 368 | } |
544 | 369 | } else if (nodeName.equals("is-fireable")){ | 369 | } else if (nodeName.equals("is-fireable")) { |
545 | 370 | // Construct a nested disjunction of transitions. | 370 | // Construct a nested disjunction of transitions. |
546 | 371 | 371 | ||
547 | 372 | children = getAllChildren(property); | 372 | children = getAllChildren(property); |
548 | 373 | 373 | ||
549 | 374 | if(children.isEmpty()){ | 374 | if (children.isEmpty()) { |
550 | 375 | throw new XMLQueryParseException(ERROR_MESSAGE + nodeName); | 375 | throw new XMLQueryParseException(ERROR_MESSAGE + nodeName); |
557 | 376 | } else if(children.size() == 1) { | 376 | } else if (children.size() == 1) { |
558 | 377 | String[] splits = getText(children.get(0)).replace("\n", "").split("\\."); | 377 | String[] splits = getText(children.get(0)).replace("\n", "").split("\\."); |
559 | 378 | 378 | ||
560 | 379 | // Check if transition contains a template name | 379 | // Check if transition contains a template name |
561 | 380 | if(splits.length > 1){ | 380 | if (splits.length > 1) { |
562 | 381 | return new TCTLTransitionNode(splits[0], splits[1]); | 381 | return new TCTLTransitionNode(splits[0], splits[1]); |
563 | 382 | } else { | 382 | } else { |
582 | 383 | return new TCTLTransitionNode(splits[0]); | 383 | return new TCTLTransitionNode(splits[0]); |
583 | 384 | } | 384 | } |
584 | 385 | } else { | 385 | } else { |
585 | 386 | ArrayList<TCTLAbstractStateProperty> transitions = new ArrayList<TCTLAbstractStateProperty>(); | 386 | ArrayList<TCTLAbstractStateProperty> transitions = new ArrayList<TCTLAbstractStateProperty>(); |
586 | 387 | 387 | ||
587 | 388 | for(Node n : children) { | 388 | for (Node n : children) { |
588 | 389 | String[] splits = getText(n).replace("\n", "").split("\\."); | 389 | String[] splits = getText(n).replace("\n", "").split("\\."); |
589 | 390 | 390 | ||
590 | 391 | // Check if transition contains a template name | 391 | // Check if transition contains a template name |
591 | 392 | if(splits.length > 1){ | 392 | if (splits.length > 1) { |
592 | 393 | transitions.add(new TCTLTransitionNode(splits[0], splits[1])); | 393 | transitions.add(new TCTLTransitionNode(splits[0], splits[1])); |
593 | 394 | } else { | 394 | } else { |
594 | 395 | transitions.add(new TCTLTransitionNode(splits[0])); | 395 | transitions.add(new TCTLTransitionNode(splits[0])); |
595 | 396 | } | 396 | } |
596 | 397 | } | 397 | } |
597 | 398 | return new TCTLOrListNode(transitions); | 398 | return new TCTLOrListNode(transitions); |
598 | 399 | } | 399 | } |
599 | 400 | } else{ | 400 | } else if (nodeName.equals("control")) { |
600 | 401 | return parseFormula(child); | ||
601 | 402 | }else{ | ||
602 | 401 | parseFormula(property); | 403 | parseFormula(property); |
603 | 402 | } | 404 | } |
604 | 403 | 405 | ||
605 | 404 | 406 | ||
606 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java' | |||
607 | --- src/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java 2014-05-22 20:26:41 +0000 | |||
608 | +++ src/main/java/dk/aau/cs/TCTL/visitors/AddTemplateVisitor.java 2022-07-21 13:30:11 +0000 | |||
609 | @@ -3,7 +3,7 @@ | |||
610 | 3 | import dk.aau.cs.TCTL.TCTLPlaceNode; | 3 | import dk.aau.cs.TCTL.TCTLPlaceNode; |
611 | 4 | 4 | ||
612 | 5 | public class AddTemplateVisitor extends VisitorBase { | 5 | public class AddTemplateVisitor extends VisitorBase { |
614 | 6 | private String templateName; | 6 | private final String templateName; |
615 | 7 | 7 | ||
616 | 8 | public AddTemplateVisitor(String templateName) { | 8 | public AddTemplateVisitor(String templateName) { |
617 | 9 | this.templateName = templateName; | 9 | this.templateName = templateName; |
618 | 10 | 10 | ||
619 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java' | |||
620 | --- src/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java 2019-03-22 10:13:18 +0000 | |||
621 | +++ src/main/java/dk/aau/cs/TCTL/visitors/BroadcastTranslationQueryVisitor.java 2022-07-21 13:30:11 +0000 | |||
622 | @@ -7,8 +7,8 @@ | |||
623 | 7 | protected static final String PLOCK = "P_lock"; | 7 | protected static final String PLOCK = "P_lock"; |
624 | 8 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; | 8 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; |
625 | 9 | 9 | ||
628 | 10 | private boolean useSymmetry; | 10 | private final boolean useSymmetry; |
629 | 11 | private int totalTokens; | 11 | private final int totalTokens; |
630 | 12 | 12 | ||
631 | 13 | public BroadcastTranslationQueryVisitor(boolean useSymmetry, int totalTokens) { | 13 | public BroadcastTranslationQueryVisitor(boolean useSymmetry, int totalTokens) { |
632 | 14 | this.useSymmetry = useSymmetry; | 14 | this.useSymmetry = useSymmetry; |
633 | 15 | 15 | ||
634 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java' | |||
635 | --- src/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java 2021-10-08 06:22:05 +0000 | |||
636 | +++ src/main/java/dk/aau/cs/TCTL/visitors/CTLQueryVisitor.java 2022-07-21 13:30:11 +0000 | |||
637 | @@ -1,271 +1,288 @@ | |||
638 | 1 | package dk.aau.cs.TCTL.visitors; | 1 | package dk.aau.cs.TCTL.visitors; |
639 | 2 | 2 | ||
640 | 3 | import java.util.List; | ||
641 | 4 | |||
642 | 5 | import dk.aau.cs.TCTL.*; | 3 | import dk.aau.cs.TCTL.*; |
643 | 6 | import dk.aau.cs.io.XMLFormatter; | 4 | import dk.aau.cs.io.XMLFormatter; |
644 | 7 | 5 | ||
645 | 6 | import java.util.List; | ||
646 | 7 | |||
647 | 8 | public class CTLQueryVisitor extends VisitorBase { | 8 | public class CTLQueryVisitor extends VisitorBase { |
774 | 9 | 9 | ||
775 | 10 | private static final String XML_NS = "xmlns=\"http://tapaal.net/\""; | 10 | private static final String XML_NS = "xmlns=\"http://tapaal.net/\""; |
776 | 11 | private static final String XML_PROPSET = "property-set"; | 11 | private static final String XML_PROPSET = "property-set"; |
777 | 12 | private static final String XML_PROP = "property"; | 12 | private static final String XML_PROP = "property"; |
778 | 13 | private static final String XML_PROPID = "id"; | 13 | private static final String XML_PROPID = "id"; |
779 | 14 | private static final String XML_PROPDESC = "description"; | 14 | private static final String XML_PROPDESC = "description"; |
780 | 15 | private static final String XML_FORMULA = "formula"; | 15 | private static final String XML_FORMULA = "formula"; |
781 | 16 | private static final String XML_ALLPATHS = "all-paths"; | 16 | private static final String XML_ALLPATHS = "all-paths"; |
782 | 17 | private static final String XML_EXISTSPATH = "exists-path"; | 17 | private static final String XML_EXISTSPATH = "exists-path"; |
783 | 18 | private static final String XML_NEGATION = "negation"; | 18 | private static final String XML_NEGATION = "negation"; |
784 | 19 | private static final String XML_CONJUNCTION = "conjunction"; | 19 | private static final String XML_CONJUNCTION = "conjunction"; |
785 | 20 | private static final String XML_DISJUNCTION = "disjunction"; | 20 | private static final String XML_DISJUNCTION = "disjunction"; |
786 | 21 | private static final String XML_GLOBALLY = "globally"; | 21 | private static final String XML_GLOBALLY = "globally"; |
787 | 22 | private static final String XML_FINALLY = "finally"; | 22 | private static final String XML_FINALLY = "finally"; |
788 | 23 | private static final String XML_NEXT = "next"; | 23 | private static final String XML_NEXT = "next"; |
789 | 24 | private static final String XML_UNTIL = "until"; | 24 | private static final String XML_UNTIL = "until"; |
790 | 25 | private static final String XML_BEFORE = "before"; | 25 | private static final String XML_BEFORE = "before"; |
791 | 26 | private static final String XML_REACH = "reach"; | 26 | private static final String XML_REACH = "reach"; |
792 | 27 | private static final String XML_DEADLOCK = "deadlock"; | 27 | private static final String XML_DEADLOCK = "deadlock"; |
793 | 28 | private static final String XML_TRUE = "true"; | 28 | private static final String XML_TRUE = "true"; |
794 | 29 | private static final String XML_FALSE = "false"; | 29 | private static final String XML_FALSE = "false"; |
795 | 30 | private static final String XML_INTEGERLT = "integer-lt"; | 30 | private static final String XML_INTEGERLT = "integer-lt"; |
796 | 31 | private static final String XML_INTEGERLE = "integer-le"; | 31 | private static final String XML_INTEGERLE = "integer-le"; |
797 | 32 | private static final String XML_INTEGEREQ = "integer-eq"; | 32 | private static final String XML_INTEGEREQ = "integer-eq"; |
798 | 33 | private static final String XML_INTEGERNE = "integer-ne"; | 33 | private static final String XML_INTEGERNE = "integer-ne"; |
799 | 34 | private static final String XML_INTEGERGT = "integer-gt"; | 34 | private static final String XML_INTEGERGT = "integer-gt"; |
800 | 35 | private static final String XML_INTEGERGE = "integer-ge"; | 35 | private static final String XML_INTEGERGE = "integer-ge"; |
801 | 36 | private static final String XML_ISFIREABLE = "is-fireable"; | 36 | private static final String XML_ISFIREABLE = "is-fireable"; |
802 | 37 | private static final String XML_INTEGERCONSTANT = "integer-constant"; | 37 | private static final String XML_INTEGERCONSTANT = "integer-constant"; |
803 | 38 | private static final String XML_TOKENSCOUNT = "tokens-count"; | 38 | private static final String XML_TOKENSCOUNT = "tokens-count"; |
804 | 39 | private static final String XML_PLACE = "place"; | 39 | private static final String XML_PLACE = "place"; |
805 | 40 | private static final String XML_TRANSITION = "transition"; | 40 | private static final String XML_TRANSITION = "transition"; |
806 | 41 | private static final String XML_INTEGERSUM = "integer-sum"; | 41 | private static final String XML_INTEGERSUM = "integer-sum"; |
807 | 42 | private static final String XML_INTEGERPRODUCT = "integer-product"; | 42 | private static final String XML_INTEGERPRODUCT = "integer-product"; |
808 | 43 | private static final String XML_INTEGERDIFFERENCE = "integer-difference"; | 43 | private static final String XML_INTEGERDIFFERENCE = "integer-difference"; |
809 | 44 | 44 | private static final String CONTROL = "control"; | |
810 | 45 | private StringBuffer XMLQuery; | 45 | |
811 | 46 | 46 | private final StringBuffer xmlQuery = new StringBuffer(); | |
812 | 47 | public CTLQueryVisitor() { | 47 | |
813 | 48 | this.XMLQuery = new StringBuffer(); | 48 | public CTLQueryVisitor() { |
814 | 49 | } | 49 | super(); |
815 | 50 | 50 | } | |
816 | 51 | public String getXMLQueryFor(TCTLAbstractProperty property, String queryName) { | 51 | |
817 | 52 | buildXMLQuery(property, queryName); | 52 | public String getXMLQueryFor(TCTLAbstractProperty property, String queryName, boolean control) { |
818 | 53 | return getFormatted(); | 53 | buildXMLQuery(property, queryName, control); |
819 | 54 | } | 54 | return getFormatted(); |
820 | 55 | 55 | } | |
821 | 56 | public void buildXMLQuery(TCTLAbstractProperty property, String queryName) { | 56 | |
822 | 57 | XMLQuery.append(startTag(XML_PROP) + queryInfo(queryName) + startTag(XML_FORMULA)); | 57 | public void buildXMLQuery(TCTLAbstractProperty property, String queryName, boolean control) { |
823 | 58 | property.accept(this, null); | 58 | xmlQuery.append(startTag(XML_PROP) + queryInfo(queryName) + startTag(XML_FORMULA)); |
824 | 59 | XMLQuery.append(endTag(XML_FORMULA) + endTag(XML_PROP)); | 59 | if (control) xmlQuery.append(startTag(CONTROL)); |
825 | 60 | } | 60 | property.accept(this, null); |
826 | 61 | 61 | if (control) xmlQuery.append(endTag(CONTROL)); | |
827 | 62 | public String getFormatted() { | 62 | xmlQuery.append(endTag(XML_FORMULA) + endTag(XML_PROP)); |
828 | 63 | XMLFormatter formatter = new XMLFormatter(); | 63 | } |
829 | 64 | return formatter.format(getStartTag() + XMLQuery.toString() + getEndTag()); | 64 | |
830 | 65 | } | 65 | public String getFormatted() { |
831 | 66 | 66 | XMLFormatter formatter = new XMLFormatter(); | |
832 | 67 | public StringBuffer getXMLQuery() { | 67 | return formatter.format(getStartTag() + xmlQuery.toString() + getEndTag()); |
833 | 68 | return XMLQuery; | 68 | } |
834 | 69 | } | 69 | |
835 | 70 | 70 | public StringBuffer getXMLQuery() { | |
836 | 71 | public String getStartTag(){ | 71 | return xmlQuery; |
837 | 72 | return startTag(XML_PROPSET + " " + XML_NS) + "\n"; | 72 | } |
838 | 73 | } | 73 | |
839 | 74 | 74 | public String getStartTag() { | |
840 | 75 | public String getEndTag(){ | 75 | return startTag(XML_PROPSET + " " + XML_NS) + "\n"; |
841 | 76 | return endTag(XML_PROPSET) + "\n"; | 76 | } |
842 | 77 | } | 77 | |
843 | 78 | 78 | public String getEndTag() { | |
844 | 79 | private String queryInfo(String queryName){ | 79 | return endTag(XML_PROPSET) + "\n"; |
845 | 80 | String nameToPrint = (queryName == null) ? "Query Comment/Name Here" : queryName; | 80 | } |
846 | 81 | return wrapInTag(nameToPrint, XML_PROPID) + wrapInTag(nameToPrint, XML_PROPDESC); | 81 | |
847 | 82 | } | 82 | private String queryInfo(String queryName) { |
848 | 83 | 83 | String nameToPrint = (queryName == null) ? "Query Comment/Name Here" : queryName; | |
849 | 84 | public void visit(TCTLAFNode afNode, Object context) { | 84 | return wrapInTag(nameToPrint, XML_PROPID) + wrapInTag(nameToPrint, XML_PROPDESC); |
850 | 85 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_FINALLY)); | 85 | } |
851 | 86 | afNode.getProperty().accept(this, context); | 86 | |
852 | 87 | XMLQuery.append(endTag(XML_FINALLY) + endTag(XML_ALLPATHS)); | 87 | public void visit(TCTLAFNode afNode, Object context) { |
853 | 88 | } | 88 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_FINALLY)); |
854 | 89 | 89 | afNode.getProperty().accept(this, context); | |
855 | 90 | public void visit(TCTLAGNode agNode, Object context) { | 90 | xmlQuery.append(endTag(XML_FINALLY) + endTag(XML_ALLPATHS)); |
856 | 91 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_GLOBALLY)); | 91 | } |
857 | 92 | agNode.getProperty().accept(this, context); | 92 | |
858 | 93 | XMLQuery.append(endTag(XML_GLOBALLY) + endTag(XML_ALLPATHS)); | 93 | public void visit(TCTLAGNode agNode, Object context) { |
859 | 94 | } | 94 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_GLOBALLY)); |
860 | 95 | 95 | agNode.getProperty().accept(this, context); | |
861 | 96 | public void visit(TCTLAXNode axNode, Object context) { | 96 | xmlQuery.append(endTag(XML_GLOBALLY) + endTag(XML_ALLPATHS)); |
862 | 97 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_NEXT)); | 97 | } |
863 | 98 | axNode.getProperty().accept(this, context); | 98 | |
864 | 99 | XMLQuery.append(endTag(XML_NEXT) + endTag(XML_ALLPATHS)); | 99 | public void visit(TCTLAXNode axNode, Object context) { |
865 | 100 | } | 100 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_NEXT)); |
866 | 101 | 101 | axNode.getProperty().accept(this, context); | |
867 | 102 | public void visit(TCTLAUNode auNode, Object context) { | 102 | xmlQuery.append(endTag(XML_NEXT) + endTag(XML_ALLPATHS)); |
868 | 103 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_UNTIL) + startTag(XML_BEFORE)); | 103 | } |
869 | 104 | auNode.getLeft().accept(this, context); | 104 | |
870 | 105 | XMLQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); | 105 | public void visit(TCTLAUNode auNode, Object context) { |
871 | 106 | auNode.getRight().accept(this, context); | 106 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_UNTIL) + startTag(XML_BEFORE)); |
872 | 107 | XMLQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_ALLPATHS)); | 107 | auNode.getLeft().accept(this, context); |
873 | 108 | } | 108 | xmlQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); |
874 | 109 | 109 | auNode.getRight().accept(this, context); | |
875 | 110 | public void visit(TCTLEFNode efNode, Object context) { | 110 | xmlQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_ALLPATHS)); |
876 | 111 | XMLQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_FINALLY)); | 111 | } |
877 | 112 | efNode.getProperty().accept(this, context); | 112 | |
878 | 113 | XMLQuery.append(endTag(XML_FINALLY) + endTag(XML_EXISTSPATH)); | 113 | public void visit(TCTLEFNode efNode, Object context) { |
879 | 114 | } | 114 | xmlQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_FINALLY)); |
880 | 115 | 115 | efNode.getProperty().accept(this, context); | |
881 | 116 | public void visit(TCTLEGNode egNode, Object context) { | 116 | xmlQuery.append(endTag(XML_FINALLY) + endTag(XML_EXISTSPATH)); |
882 | 117 | XMLQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_GLOBALLY)); | 117 | } |
883 | 118 | egNode.getProperty().accept(this, context); | 118 | |
884 | 119 | XMLQuery.append(endTag(XML_GLOBALLY) + endTag(XML_EXISTSPATH)); | 119 | public void visit(TCTLEGNode egNode, Object context) { |
885 | 120 | } | 120 | xmlQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_GLOBALLY)); |
886 | 121 | 121 | egNode.getProperty().accept(this, context); | |
887 | 122 | public void visit(TCTLEXNode exNode, Object context) { | 122 | xmlQuery.append(endTag(XML_GLOBALLY) + endTag(XML_EXISTSPATH)); |
888 | 123 | XMLQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_NEXT)); | 123 | } |
889 | 124 | exNode.getProperty().accept(this, context); | 124 | |
890 | 125 | XMLQuery.append(endTag(XML_NEXT) + endTag(XML_EXISTSPATH)); | 125 | public void visit(TCTLEXNode exNode, Object context) { |
891 | 126 | } | 126 | xmlQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_NEXT)); |
892 | 127 | 127 | exNode.getProperty().accept(this, context); | |
893 | 128 | public void visit(TCTLEUNode euNode, Object context) { | 128 | xmlQuery.append(endTag(XML_NEXT) + endTag(XML_EXISTSPATH)); |
894 | 129 | XMLQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_UNTIL) + startTag(XML_BEFORE)); | 129 | } |
895 | 130 | euNode.getLeft().accept(this, context); | 130 | |
896 | 131 | XMLQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); | 131 | public void visit(TCTLEUNode euNode, Object context) { |
897 | 132 | euNode.getRight().accept(this, context); | 132 | xmlQuery.append(startTag(XML_EXISTSPATH) + startTag(XML_UNTIL) + startTag(XML_BEFORE)); |
898 | 133 | XMLQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_EXISTSPATH)); | 133 | euNode.getLeft().accept(this, context); |
899 | 134 | } | 134 | xmlQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); |
900 | 135 | euNode.getRight().accept(this, context); | ||
901 | 136 | xmlQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_EXISTSPATH)); | ||
902 | 137 | } | ||
903 | 135 | 138 | ||
904 | 136 | public void visit(LTLFNode afNode, Object context) { | 139 | public void visit(LTLFNode afNode, Object context) { |
906 | 137 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_FINALLY)); | 140 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_FINALLY)); |
907 | 138 | afNode.getProperty().accept(this, context); | 141 | afNode.getProperty().accept(this, context); |
909 | 139 | XMLQuery.append(endTag(XML_FINALLY) + endTag(XML_ALLPATHS)); | 142 | xmlQuery.append(endTag(XML_FINALLY) + endTag(XML_ALLPATHS)); |
910 | 140 | } | 143 | } |
911 | 141 | 144 | ||
912 | 142 | public void visit(LTLGNode agNode, Object context) { | 145 | public void visit(LTLGNode agNode, Object context) { |
914 | 143 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_GLOBALLY)); | 146 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_GLOBALLY)); |
915 | 144 | agNode.getProperty().accept(this, context); | 147 | agNode.getProperty().accept(this, context); |
917 | 145 | XMLQuery.append(endTag(XML_GLOBALLY) + endTag(XML_ALLPATHS)); | 148 | xmlQuery.append(endTag(XML_GLOBALLY) + endTag(XML_ALLPATHS)); |
918 | 146 | } | 149 | } |
919 | 147 | 150 | ||
920 | 148 | public void visit(LTLXNode axNode, Object context) { | 151 | public void visit(LTLXNode axNode, Object context) { |
922 | 149 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_NEXT)); | 152 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_NEXT)); |
923 | 150 | axNode.getProperty().accept(this, context); | 153 | axNode.getProperty().accept(this, context); |
925 | 151 | XMLQuery.append(endTag(XML_NEXT) + endTag(XML_ALLPATHS)); | 154 | xmlQuery.append(endTag(XML_NEXT) + endTag(XML_ALLPATHS)); |
926 | 152 | } | 155 | } |
927 | 153 | 156 | ||
928 | 154 | public void visit(LTLUNode auNode, Object context) { | 157 | public void visit(LTLUNode auNode, Object context) { |
930 | 155 | XMLQuery.append(startTag(XML_ALLPATHS) + startTag(XML_UNTIL) + startTag(XML_BEFORE)); | 158 | xmlQuery.append(startTag(XML_ALLPATHS) + startTag(XML_UNTIL) + startTag(XML_BEFORE)); |
931 | 156 | auNode.getLeft().accept(this, context); | 159 | auNode.getLeft().accept(this, context); |
933 | 157 | XMLQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); | 160 | xmlQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); |
934 | 158 | auNode.getRight().accept(this, context); | 161 | auNode.getRight().accept(this, context); |
1047 | 159 | XMLQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_ALLPATHS)); | 162 | xmlQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL) + endTag(XML_ALLPATHS)); |
1048 | 160 | } | 163 | } |
1049 | 161 | 164 | ||
1050 | 162 | public void visit(TCTLPathToStateConverter pathConverter, Object context) { | 165 | public void visit(TCTLPathToStateConverter pathConverter, Object context) { |
1051 | 163 | pathConverter.getProperty().accept(this, context); | 166 | pathConverter.getProperty().accept(this, context); |
1052 | 164 | } | 167 | } |
1053 | 165 | 168 | ||
1054 | 166 | public void visit(TCTLAndListNode andListNode, Object context) { | 169 | public void visit(TCTLAndListNode andListNode, Object context) { |
1055 | 167 | createList(andListNode.getProperties(), context, XML_CONJUNCTION); | 170 | createList(andListNode.getProperties(), context, XML_CONJUNCTION); |
1056 | 168 | } | 171 | } |
1057 | 169 | 172 | ||
1058 | 170 | public void visit(TCTLOrListNode orListNode, Object context) { | 173 | public void visit(TCTLOrListNode orListNode, Object context) { |
1059 | 171 | createList(orListNode.getProperties(), context, XML_DISJUNCTION); | 174 | createList(orListNode.getProperties(), context, XML_DISJUNCTION); |
1060 | 172 | } | 175 | } |
1061 | 173 | 176 | ||
1062 | 174 | public void visit(TCTLTermListNode termListNode, Object context) { | 177 | public void visit(TCTLTermListNode termListNode, Object context) { |
1063 | 175 | assert termListNode.getProperties().get(1) instanceof AritmeticOperator; | 178 | assert termListNode.getProperties().get(1) instanceof AritmeticOperator; |
1064 | 176 | AritmeticOperator operator = (AritmeticOperator)termListNode.getProperties().get(1); | 179 | AritmeticOperator operator = (AritmeticOperator) termListNode.getProperties().get(1); |
1065 | 177 | String op = operator.toString(); | 180 | String op = operator.toString(); |
1066 | 178 | if (op.equals("+")) { | 181 | switch (op) { |
1067 | 179 | createList(termListNode.getProperties(), context, XML_INTEGERSUM); | 182 | case "+": |
1068 | 180 | } else if (op.equals("*")) { | 183 | createList(termListNode.getProperties(), context, XML_INTEGERSUM); |
1069 | 181 | createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT); | 184 | break; |
1070 | 182 | } else if (op.equals("-")) { | 185 | case "*": |
1071 | 183 | createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE); | 186 | createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT); |
1072 | 184 | } | 187 | break; |
1073 | 185 | } | 188 | case "-": |
1074 | 186 | 189 | createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE); | |
1075 | 187 | private void createList(List<TCTLAbstractStateProperty> properties, Object context, String seperator) { | 190 | break; |
1076 | 188 | XMLQuery.append(startTag(seperator)); | 191 | } |
1077 | 189 | 192 | } | |
1078 | 190 | for (TCTLAbstractStateProperty p : properties) { | 193 | |
1079 | 191 | p.accept(this, context); | 194 | private void createList(List<TCTLAbstractStateProperty> properties, Object context, String seperator) { |
1080 | 192 | } | 195 | xmlQuery.append(startTag(seperator)); |
1081 | 193 | 196 | ||
1082 | 194 | XMLQuery.append(endTag(seperator)); | 197 | for (TCTLAbstractStateProperty p : properties) { |
1083 | 195 | } | 198 | p.accept(this, context); |
1084 | 196 | 199 | } | |
1085 | 197 | public void visit(TCTLNotNode notNode, Object context) { | 200 | |
1086 | 198 | XMLQuery.append(startTag(XML_NEGATION)); | 201 | xmlQuery.append(endTag(seperator)); |
1087 | 199 | notNode.getProperty().accept(this, context); | 202 | } |
1088 | 200 | XMLQuery.append(endTag(XML_NEGATION)); | 203 | |
1089 | 201 | } | 204 | public void visit(TCTLNotNode notNode, Object context) { |
1090 | 202 | 205 | xmlQuery.append(startTag(XML_NEGATION)); | |
1091 | 203 | public void visit(TCTLTrueNode tctlTrueNode, Object context) { | 206 | notNode.getProperty().accept(this, context); |
1092 | 204 | XMLQuery.append(emptyElement(XML_TRUE)); | 207 | xmlQuery.append(endTag(XML_NEGATION)); |
1093 | 205 | } | 208 | } |
1094 | 206 | 209 | ||
1095 | 207 | public void visit(TCTLFalseNode tctlFalseNode, Object context) { | 210 | public void visit(TCTLTrueNode tctlTrueNode, Object context) { |
1096 | 208 | XMLQuery.append(emptyElement(XML_FALSE)); | 211 | xmlQuery.append(emptyElement(XML_TRUE)); |
1097 | 209 | } | 212 | } |
1098 | 210 | 213 | ||
1099 | 211 | public void visit(TCTLDeadlockNode tctlDeadLockNode, Object context) { | 214 | public void visit(TCTLFalseNode tctlFalseNode, Object context) { |
1100 | 212 | XMLQuery.append(emptyElement(XML_DEADLOCK)); | 215 | xmlQuery.append(emptyElement(XML_FALSE)); |
1101 | 213 | } | 216 | } |
1102 | 214 | 217 | ||
1103 | 215 | public void visit(TCTLConstNode tctlConstNode, Object context){ | 218 | public void visit(TCTLDeadlockNode tctlDeadLockNode, Object context) { |
1104 | 216 | XMLQuery.append(wrapInTag(String.valueOf(tctlConstNode.getConstant()) + "", XML_INTEGERCONSTANT)); | 219 | xmlQuery.append(emptyElement(XML_DEADLOCK)); |
1105 | 217 | } | 220 | } |
1106 | 218 | 221 | ||
1107 | 219 | public void visit(TCTLPlaceNode tctlPlaceNode, Object context){ | 222 | public void visit(TCTLConstNode tctlConstNode, Object context) { |
1108 | 220 | XMLQuery.append(startTag(XML_TOKENSCOUNT)); | 223 | xmlQuery.append(wrapInTag(tctlConstNode.getConstant() + "", XML_INTEGERCONSTANT)); |
1109 | 221 | XMLQuery.append(wrapInTag(tctlPlaceNode.toString() + "", XML_PLACE)); | 224 | } |
1110 | 222 | XMLQuery.append(endTag(XML_TOKENSCOUNT)); | 225 | |
1111 | 223 | } | 226 | public void visit(TCTLPlaceNode tctlPlaceNode, Object context) { |
1112 | 224 | 227 | xmlQuery.append(startTag(XML_TOKENSCOUNT)); | |
1113 | 225 | public void visit(TCTLTransitionNode tctlTransitionNode, Object context){ | 228 | xmlQuery.append(wrapInTag(tctlPlaceNode.toString() + "", XML_PLACE)); |
1114 | 226 | XMLQuery.append(startTag(XML_ISFIREABLE)); | 229 | xmlQuery.append(endTag(XML_TOKENSCOUNT)); |
1115 | 227 | XMLQuery.append(wrapInTag(tctlTransitionNode.toString() + "", XML_TRANSITION)); | 230 | } |
1116 | 228 | XMLQuery.append(endTag(XML_ISFIREABLE)); | 231 | |
1117 | 229 | } | 232 | public void visit(TCTLTransitionNode tctlTransitionNode, Object context) { |
1118 | 230 | 233 | xmlQuery.append(startTag(XML_ISFIREABLE)); | |
1119 | 231 | @Override | 234 | xmlQuery.append(wrapInTag(tctlTransitionNode.toString() + "", XML_TRANSITION)); |
1120 | 232 | public void visit(TCTLAtomicPropositionNode atomicPropositionNode, | 235 | xmlQuery.append(endTag(XML_ISFIREABLE)); |
1121 | 233 | Object context) { | 236 | } |
1122 | 234 | String opTest = atomicPropositionNode.getOp(); | 237 | |
1123 | 235 | String op = new String(); | 238 | @Override |
1124 | 236 | 239 | public void visit(TCTLAtomicPropositionNode atomicPropositionNode, Object context) { | |
1125 | 237 | if (opTest.equals("<")){ | 240 | String opTest = atomicPropositionNode.getOp(); |
1126 | 238 | op = XML_INTEGERLT; | 241 | String op; |
1127 | 239 | } else if(opTest.equals("<=")){ | 242 | |
1128 | 240 | op = XML_INTEGERLE; | 243 | switch (opTest) { |
1129 | 241 | } else if(opTest.equals("=")){ | 244 | case "<": |
1130 | 242 | op = XML_INTEGEREQ; | 245 | op = XML_INTEGERLT; |
1131 | 243 | } else if(opTest.equals("!=")){ | 246 | break; |
1132 | 244 | op = XML_INTEGERNE; | 247 | case "<=": |
1133 | 245 | } else if(opTest.equals(">")){ | 248 | op = XML_INTEGERLE; |
1134 | 246 | op = XML_INTEGERGT; | 249 | break; |
1135 | 247 | } else if(opTest.equals(">=")){ | 250 | case "=": |
1136 | 248 | op = XML_INTEGERGE; | 251 | op = XML_INTEGEREQ; |
1137 | 249 | } else { | 252 | break; |
1138 | 250 | op = "MISSING_OPERATOR"; | 253 | case "!=": |
1139 | 251 | } | 254 | op = XML_INTEGERNE; |
1140 | 252 | 255 | break; | |
1141 | 253 | XMLQuery.append(startTag(op)); | 256 | case ">": |
1142 | 254 | atomicPropositionNode.getLeft().accept(this, context); | 257 | op = XML_INTEGERGT; |
1143 | 255 | atomicPropositionNode.getRight().accept(this, context); | 258 | break; |
1144 | 256 | XMLQuery.append(endTag(op)); | 259 | case ">=": |
1145 | 257 | } | 260 | op = XML_INTEGERGE; |
1146 | 258 | 261 | break; | |
1147 | 259 | private String wrapInTag(String str, String tag){ | 262 | default: |
1148 | 260 | return startTag(tag) + str + endTag(tag); | 263 | op = "MISSING_OPERATOR"; |
1149 | 261 | } | 264 | break; |
1150 | 262 | private String startTag(String tag){ | 265 | } |
1151 | 263 | return "<" + tag + ">"; | 266 | |
1152 | 264 | } | 267 | xmlQuery.append(startTag(op)); |
1153 | 265 | private String endTag(String tag){ | 268 | atomicPropositionNode.getLeft().accept(this, context); |
1154 | 266 | return "</" + tag + ">"; | 269 | atomicPropositionNode.getRight().accept(this, context); |
1155 | 267 | } | 270 | xmlQuery.append(endTag(op)); |
1156 | 268 | private String emptyElement(String tag){ | 271 | } |
1157 | 269 | return startTag(tag + "/"); | 272 | |
1158 | 270 | } | 273 | private String wrapInTag(String str, String tag) { |
1159 | 274 | return startTag(tag) + str + endTag(tag); | ||
1160 | 275 | } | ||
1161 | 276 | |||
1162 | 277 | private String startTag(String tag) { | ||
1163 | 278 | return "<" + tag + ">"; | ||
1164 | 279 | } | ||
1165 | 280 | |||
1166 | 281 | private String endTag(String tag) { | ||
1167 | 282 | return "</" + tag + ">"; | ||
1168 | 283 | } | ||
1169 | 284 | |||
1170 | 285 | private String emptyElement(String tag) { | ||
1171 | 286 | return startTag(tag + "/"); | ||
1172 | 287 | } | ||
1173 | 271 | } | 288 | } |
1174 | 272 | 289 | ||
1175 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java' | |||
1176 | --- src/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java 2019-03-22 10:13:18 +0000 | |||
1177 | +++ src/main/java/dk/aau/cs/TCTL/visitors/CombiTranslationQueryVisitor.java 2022-07-21 13:30:11 +0000 | |||
1178 | @@ -11,13 +11,13 @@ | |||
1179 | 11 | protected static final String PLOCK = "P_lock"; | 11 | protected static final String PLOCK = "P_lock"; |
1180 | 12 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; | 12 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; |
1181 | 13 | 13 | ||
1189 | 14 | private boolean useSymmetry; | 14 | private final boolean useSymmetry; |
1190 | 15 | private int totalTokens; | 15 | private final int totalTokens; |
1191 | 16 | private TimedArcPetriNet model; | 16 | private final TimedArcPetriNet model; |
1192 | 17 | private Hashtable<String, Boolean> placeNameToTimed; | 17 | private final Hashtable<String, Boolean> placeNameToTimed; |
1193 | 18 | private int maxDegDif; | 18 | private final int maxDegDif; |
1194 | 19 | private int initTransitions; | 19 | private final int initTransitions; |
1195 | 20 | private int maxTimeIn; | 20 | private final int maxTimeIn; |
1196 | 21 | 21 | ||
1197 | 22 | public CombiTranslationQueryVisitor(boolean useSymmetry, int totalTokens, TimedArcPetriNet model, Hashtable<String, Boolean> placeNameToTimed, int maxDegDif, int initTransitions, int maxTimeIn) { | 22 | public CombiTranslationQueryVisitor(boolean useSymmetry, int totalTokens, TimedArcPetriNet model, Hashtable<String, Boolean> placeNameToTimed, int maxDegDif, int initTransitions, int maxTimeIn) { |
1198 | 23 | this.useSymmetry = useSymmetry; | 23 | this.useSymmetry = useSymmetry; |
1199 | 24 | 24 | ||
1200 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java' | |||
1201 | --- src/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java 2014-05-22 20:26:41 +0000 | |||
1202 | +++ src/main/java/dk/aau/cs/TCTL/visitors/ContainsPlaceWithDisabledTemplateVisitor.java 2022-07-21 13:30:11 +0000 | |||
1203 | @@ -6,7 +6,7 @@ | |||
1204 | 6 | 6 | ||
1205 | 7 | public class ContainsPlaceWithDisabledTemplateVisitor extends VisitorBase implements ITCTLVisitor { | 7 | public class ContainsPlaceWithDisabledTemplateVisitor extends VisitorBase implements ITCTLVisitor { |
1206 | 8 | 8 | ||
1208 | 9 | private TimedArcPetriNetNetwork network; | 9 | private final TimedArcPetriNetNetwork network; |
1209 | 10 | 10 | ||
1210 | 11 | public ContainsPlaceWithDisabledTemplateVisitor(TimedArcPetriNetNetwork network){ | 11 | public ContainsPlaceWithDisabledTemplateVisitor(TimedArcPetriNetNetwork network){ |
1211 | 12 | this.network = network; | 12 | this.network = network; |
1212 | @@ -14,15 +14,18 @@ | |||
1213 | 14 | 14 | ||
1214 | 15 | @Override | 15 | @Override |
1215 | 16 | public void visit(TCTLPlaceNode placeNode, Object context) { | 16 | public void visit(TCTLPlaceNode placeNode, Object context) { |
1218 | 17 | if(placeNode.getTemplate().equals("") && network.getSharedPlaceByName(placeNode.getPlace()) != null) | 17 | if(placeNode.getTemplate().equals("") && network.getSharedPlaceByName(placeNode.getPlace()) != null) { |
1219 | 18 | return; | 18 | return; |
1220 | 19 | } | ||
1221 | 19 | 20 | ||
1222 | 20 | for(TimedArcPetriNet net : network.activeTemplates()) { | 21 | for(TimedArcPetriNet net : network.activeTemplates()) { |
1225 | 21 | if(placeNode.getTemplate().equals(net.name()) && net.getPlaceByName(placeNode.getPlace()) != null) | 22 | if(placeNode.getTemplate().equals(net.name()) && net.getPlaceByName(placeNode.getPlace()) != null) { |
1226 | 22 | return; | 23 | return; |
1227 | 24 | } | ||
1228 | 23 | } | 25 | } |
1229 | 24 | 26 | ||
1232 | 25 | if(context instanceof BooleanResult) | 27 | if(context instanceof BooleanResult) { |
1233 | 26 | ((BooleanResult)context).setResult(false); | 28 | ((BooleanResult)context).setResult(false); |
1234 | 29 | } | ||
1235 | 27 | } | 30 | } |
1236 | 28 | } | 31 | } |
1237 | 29 | 32 | ||
1238 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java' | |||
1239 | --- src/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java 2014-05-22 20:26:41 +0000 | |||
1240 | +++ src/main/java/dk/aau/cs/TCTL/visitors/ContainsSharedPlaceVisitor.java 2022-07-21 13:30:11 +0000 | |||
1241 | @@ -3,7 +3,7 @@ | |||
1242 | 3 | import dk.aau.cs.TCTL.TCTLPlaceNode; | 3 | import dk.aau.cs.TCTL.TCTLPlaceNode; |
1243 | 4 | 4 | ||
1244 | 5 | public class ContainsSharedPlaceVisitor extends VisitorBase implements ITCTLVisitor { | 5 | public class ContainsSharedPlaceVisitor extends VisitorBase implements ITCTLVisitor { |
1246 | 6 | private String sharedPlaceName; | 6 | private final String sharedPlaceName; |
1247 | 7 | 7 | ||
1248 | 8 | public ContainsSharedPlaceVisitor(String sharedPlaceName){ | 8 | public ContainsSharedPlaceVisitor(String sharedPlaceName){ |
1249 | 9 | this.sharedPlaceName = sharedPlaceName; | 9 | this.sharedPlaceName = sharedPlaceName; |
1250 | @@ -11,8 +11,9 @@ | |||
1251 | 11 | 11 | ||
1252 | 12 | @Override | 12 | @Override |
1253 | 13 | public void visit(TCTLPlaceNode placeNode, Object context) { | 13 | public void visit(TCTLPlaceNode placeNode, Object context) { |
1256 | 14 | if(placeNode.getTemplate().equals("") && placeNode.getPlace().equals(sharedPlaceName)) | 14 | if(placeNode.getTemplate().equals("") && placeNode.getPlace().equals(sharedPlaceName)) { |
1257 | 15 | ((BooleanResult)context).setResult(true); | 15 | ((BooleanResult)context).setResult(true); |
1258 | 16 | } | ||
1259 | 16 | } | 17 | } |
1260 | 17 | 18 | ||
1261 | 18 | } | 19 | } |
1262 | 19 | 20 | ||
1263 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java' | |||
1264 | --- src/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java 2017-03-12 00:33:00 +0000 | |||
1265 | +++ src/main/java/dk/aau/cs/TCTL/visitors/ContainsSharedTransitionVisitor.java 2022-07-21 13:30:11 +0000 | |||
1266 | @@ -3,7 +3,7 @@ | |||
1267 | 3 | import dk.aau.cs.TCTL.TCTLTransitionNode; | 3 | import dk.aau.cs.TCTL.TCTLTransitionNode; |
1268 | 4 | 4 | ||
1269 | 5 | public class ContainsSharedTransitionVisitor extends VisitorBase implements ITCTLVisitor { | 5 | public class ContainsSharedTransitionVisitor extends VisitorBase implements ITCTLVisitor { |
1271 | 6 | private String sharedTransitionName; | 6 | private final String sharedTransitionName; |
1272 | 7 | 7 | ||
1273 | 8 | public ContainsSharedTransitionVisitor(String sharedTransitionName){ | 8 | public ContainsSharedTransitionVisitor(String sharedTransitionName){ |
1274 | 9 | this.sharedTransitionName = sharedTransitionName; | 9 | this.sharedTransitionName = sharedTransitionName; |
1275 | 10 | 10 | ||
1276 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java' | |||
1277 | --- src/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java 2014-11-01 09:31:54 +0000 | |||
1278 | +++ src/main/java/dk/aau/cs/TCTL/visitors/FixAbbrivPlaceNames.java 2022-07-21 13:30:11 +0000 | |||
1279 | @@ -1,8 +1,3 @@ | |||
1280 | 1 | /* | ||
1281 | 2 | * To change this license header, choose License Headers in Project Properties. | ||
1282 | 3 | * To change this template file, choose Tools | Templates | ||
1283 | 4 | * and open the template in the editor. | ||
1284 | 5 | */ | ||
1285 | 6 | package dk.aau.cs.TCTL.visitors; | 1 | package dk.aau.cs.TCTL.visitors; |
1286 | 7 | 2 | ||
1287 | 8 | import dk.aau.cs.TCTL.TCTLAbstractProperty; | 3 | import dk.aau.cs.TCTL.TCTLAbstractProperty; |
1288 | @@ -10,13 +5,9 @@ | |||
1289 | 10 | import dk.aau.cs.util.Tuple; | 5 | import dk.aau.cs.util.Tuple; |
1290 | 11 | import java.util.ArrayList; | 6 | import java.util.ArrayList; |
1291 | 12 | 7 | ||
1292 | 13 | /** | ||
1293 | 14 | * | ||
1294 | 15 | * @author jakob | ||
1295 | 16 | */ | ||
1296 | 17 | public class FixAbbrivPlaceNames extends VisitorBase { | 8 | public class FixAbbrivPlaceNames extends VisitorBase { |
1297 | 18 | 9 | ||
1299 | 19 | private ArrayList<Tuple<String, String>> templatePlaceNames; | 10 | private final ArrayList<Tuple<String, String>> templatePlaceNames; |
1300 | 20 | 11 | ||
1301 | 21 | public FixAbbrivPlaceNames(ArrayList<Tuple<String, String>> templatePlaceNames) { | 12 | public FixAbbrivPlaceNames(ArrayList<Tuple<String, String>> templatePlaceNames) { |
1302 | 22 | this.templatePlaceNames = templatePlaceNames; | 13 | this.templatePlaceNames = templatePlaceNames; |
1303 | 23 | 14 | ||
1304 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java' | |||
1305 | --- src/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java 2017-03-12 00:33:00 +0000 | |||
1306 | +++ src/main/java/dk/aau/cs/TCTL/visitors/FixAbbrivTransitionNames.java 2022-07-21 13:30:11 +0000 | |||
1307 | @@ -12,7 +12,7 @@ | |||
1308 | 12 | 12 | ||
1309 | 13 | public class FixAbbrivTransitionNames extends VisitorBase { | 13 | public class FixAbbrivTransitionNames extends VisitorBase { |
1310 | 14 | 14 | ||
1312 | 15 | private ArrayList<Tuple<String, String>> templateTransitionNames; | 15 | private final ArrayList<Tuple<String, String>> templateTransitionNames; |
1313 | 16 | 16 | ||
1314 | 17 | public FixAbbrivTransitionNames(ArrayList<Tuple<String, String>> templateTransitionNames) { | 17 | public FixAbbrivTransitionNames(ArrayList<Tuple<String, String>> templateTransitionNames) { |
1315 | 18 | this.templateTransitionNames = templateTransitionNames; | 18 | this.templateTransitionNames = templateTransitionNames; |
1316 | 19 | 19 | ||
1317 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java' | |||
1318 | --- src/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java 2013-05-18 21:26:56 +0000 | |||
1319 | +++ src/main/java/dk/aau/cs/TCTL/visitors/HasDeadlockVisitor.java 2022-07-21 13:30:11 +0000 | |||
1320 | @@ -16,7 +16,7 @@ | |||
1321 | 16 | ((Context)context).hasDeadlock = true; | 16 | ((Context)context).hasDeadlock = true; |
1322 | 17 | } | 17 | } |
1323 | 18 | 18 | ||
1325 | 19 | private class Context{ | 19 | private static class Context{ |
1326 | 20 | public boolean hasDeadlock = true; | 20 | public boolean hasDeadlock = true; |
1327 | 21 | } | 21 | } |
1328 | 22 | } | 22 | } |
1329 | 23 | 23 | ||
1330 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java' | |||
1331 | --- src/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java 2017-08-03 11:48:35 +0000 | |||
1332 | +++ src/main/java/dk/aau/cs/TCTL/visitors/IsReachabilityVisitor.java 2022-07-21 13:30:11 +0000 | |||
1333 | @@ -4,7 +4,7 @@ | |||
1334 | 4 | 4 | ||
1335 | 5 | public class IsReachabilityVisitor extends VisitorBase { | 5 | public class IsReachabilityVisitor extends VisitorBase { |
1336 | 6 | 6 | ||
1338 | 7 | private class Context{ | 7 | private static class Context{ |
1339 | 8 | public boolean isReachability = true; | 8 | public boolean isReachability = true; |
1340 | 9 | public int nTempOp = 0; // number of temporal operators | 9 | public int nTempOp = 0; // number of temporal operators |
1341 | 10 | } | 10 | } |
1342 | 11 | 11 | ||
1343 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java' | |||
1344 | --- src/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java 2021-10-14 06:28:05 +0000 | |||
1345 | +++ src/main/java/dk/aau/cs/TCTL/visitors/LTLQueryVisitor.java 2022-07-21 13:30:11 +0000 | |||
1346 | @@ -7,45 +7,45 @@ | |||
1347 | 7 | 7 | ||
1348 | 8 | public class LTLQueryVisitor extends VisitorBase { | 8 | public class LTLQueryVisitor extends VisitorBase { |
1349 | 9 | 9 | ||
1359 | 10 | private static final String XML_NS = "xmlns=\"http://tapaal.net/\""; | 10 | private static final String XML_NS = "xmlns=\"http://tapaal.net/\""; |
1360 | 11 | private static final String XML_PROPSET = "property-set"; | 11 | private static final String XML_PROPSET = "property-set"; |
1361 | 12 | private static final String XML_PROP = "property"; | 12 | private static final String XML_PROP = "property"; |
1362 | 13 | private static final String XML_PROPID = "id"; | 13 | private static final String XML_PROPID = "id"; |
1363 | 14 | private static final String XML_PROPDESC = "description"; | 14 | private static final String XML_PROPDESC = "description"; |
1364 | 15 | private static final String XML_FORMULA = "formula"; | 15 | private static final String XML_FORMULA = "formula"; |
1365 | 16 | private static final String XML_ALLPATHS = "all-paths"; | 16 | private static final String XML_ALLPATHS = "all-paths"; |
1366 | 17 | private static final String XML_EXISTSPATH = "exists-path"; | 17 | private static final String XML_EXISTSPATH = "exists-path"; |
1367 | 18 | private static final String XML_NEGATION = "negation"; | 18 | private static final String XML_NEGATION = "negation"; |
1368 | 19 | private static final String XML_CONJUNCTION = "conjunction"; | 19 | private static final String XML_CONJUNCTION = "conjunction"; |
1369 | 20 | private static final String XML_DISJUNCTION = "disjunction"; | 20 | private static final String XML_DISJUNCTION = "disjunction"; |
1386 | 21 | private static final String XML_GLOBALLY = "globally"; | 21 | private static final String XML_GLOBALLY = "globally"; |
1387 | 22 | private static final String XML_FINALLY = "finally"; | 22 | private static final String XML_FINALLY = "finally"; |
1388 | 23 | private static final String XML_NEXT = "next"; | 23 | private static final String XML_NEXT = "next"; |
1389 | 24 | private static final String XML_UNTIL = "until"; | 24 | private static final String XML_UNTIL = "until"; |
1390 | 25 | private static final String XML_BEFORE = "before"; | 25 | private static final String XML_BEFORE = "before"; |
1391 | 26 | private static final String XML_REACH = "reach"; | 26 | private static final String XML_REACH = "reach"; |
1392 | 27 | private static final String XML_DEADLOCK = "deadlock"; | 27 | private static final String XML_DEADLOCK = "deadlock"; |
1393 | 28 | private static final String XML_TRUE = "true"; | 28 | private static final String XML_TRUE = "true"; |
1394 | 29 | private static final String XML_FALSE = "false"; | 29 | private static final String XML_FALSE = "false"; |
1395 | 30 | private static final String XML_INTEGERLT = "integer-lt"; | 30 | private static final String XML_INTEGERLT = "integer-lt"; |
1396 | 31 | private static final String XML_INTEGERLE = "integer-le"; | 31 | private static final String XML_INTEGERLE = "integer-le"; |
1397 | 32 | private static final String XML_INTEGEREQ = "integer-eq"; | 32 | private static final String XML_INTEGEREQ = "integer-eq"; |
1398 | 33 | private static final String XML_INTEGERNE = "integer-ne"; | 33 | private static final String XML_INTEGERNE = "integer-ne"; |
1399 | 34 | private static final String XML_INTEGERGT = "integer-gt"; | 34 | private static final String XML_INTEGERGT = "integer-gt"; |
1400 | 35 | private static final String XML_INTEGERGE = "integer-ge"; | 35 | private static final String XML_INTEGERGE = "integer-ge"; |
1401 | 36 | private static final String XML_ISFIREABLE = "is-fireable"; | 36 | private static final String XML_ISFIREABLE = "is-fireable"; |
1402 | 37 | private static final String XML_INTEGERCONSTANT = "integer-constant"; | 37 | private static final String XML_INTEGERCONSTANT = "integer-constant"; |
1403 | 38 | private static final String XML_TOKENSCOUNT = "tokens-count"; | 38 | private static final String XML_TOKENSCOUNT = "tokens-count"; |
1409 | 39 | private static final String XML_PLACE = "place"; | 39 | private static final String XML_PLACE = "place"; |
1410 | 40 | private static final String XML_TRANSITION = "transition"; | 40 | private static final String XML_TRANSITION = "transition"; |
1411 | 41 | private static final String XML_INTEGERSUM = "integer-sum"; | 41 | private static final String XML_INTEGERSUM = "integer-sum"; |
1412 | 42 | private static final String XML_INTEGERPRODUCT = "integer-product"; | 42 | private static final String XML_INTEGERPRODUCT = "integer-product"; |
1413 | 43 | private static final String XML_INTEGERDIFFERENCE = "integer-difference"; | 43 | private static final String XML_INTEGERDIFFERENCE = "integer-difference"; |
1414 | 44 | 44 | ||
1416 | 45 | private StringBuffer XMLQuery; | 45 | private final StringBuffer xmlQuery = new StringBuffer(); |
1417 | 46 | 46 | ||
1418 | 47 | public LTLQueryVisitor() { | 47 | public LTLQueryVisitor() { |
1420 | 48 | this.XMLQuery = new StringBuffer(); | 48 | super(); |
1421 | 49 | } | 49 | } |
1422 | 50 | 50 | ||
1423 | 51 | public String getXMLQueryFor(TCTLAbstractProperty property, String queryName) { | 51 | public String getXMLQueryFor(TCTLAbstractProperty property, String queryName) { |
1424 | @@ -54,20 +54,20 @@ | |||
1425 | 54 | } | 54 | } |
1426 | 55 | 55 | ||
1427 | 56 | public void buildXMLQuery(TCTLAbstractProperty property, String queryName) { | 56 | public void buildXMLQuery(TCTLAbstractProperty property, String queryName) { |
1429 | 57 | XMLQuery.append(startTag(XML_PROP) + queryInfo(queryName) + startTag(XML_FORMULA)); | 57 | xmlQuery.append(startTag(XML_PROP) + queryInfo(queryName) + startTag(XML_FORMULA)); |
1430 | 58 | property.accept(this, null); | 58 | property.accept(this, null); |
1432 | 59 | XMLQuery.append(endTag(XML_FORMULA) + endTag(XML_PROP)); | 59 | xmlQuery.append(endTag(XML_FORMULA) + endTag(XML_PROP)); |
1433 | 60 | } | 60 | } |
1434 | 61 | 61 | ||
1435 | 62 | public String getFormatted() { | 62 | public String getFormatted() { |
1436 | 63 | XMLFormatter formatter = new XMLFormatter(); | 63 | XMLFormatter formatter = new XMLFormatter(); |
1438 | 64 | return formatter.format(getStartTag() + XMLQuery.toString() + getEndTag()); | 64 | return formatter.format(getStartTag() + xmlQuery.toString() + getEndTag()); |
1439 | 65 | } | 65 | } |
1440 | 66 | 66 | ||
1441 | 67 | public String getFormatted(StringBuffer CTLQueries) { | 67 | public String getFormatted(StringBuffer CTLQueries) { |
1442 | 68 | XMLFormatter formatter = new XMLFormatter(); | 68 | XMLFormatter formatter = new XMLFormatter(); |
1445 | 69 | XMLQuery.append(CTLQueries); | 69 | xmlQuery.append(CTLQueries); |
1446 | 70 | return formatter.format(getStartTag() + XMLQuery.toString() + getEndTag()); | 70 | return formatter.format(getStartTag() + xmlQuery.toString() + getEndTag()); |
1447 | 71 | } | 71 | } |
1448 | 72 | 72 | ||
1449 | 73 | public String getStartTag(){ | 73 | public String getStartTag(){ |
1450 | @@ -84,41 +84,41 @@ | |||
1451 | 84 | } | 84 | } |
1452 | 85 | 85 | ||
1453 | 86 | public void visit(LTLANode aNode, Object context) { | 86 | public void visit(LTLANode aNode, Object context) { |
1455 | 87 | XMLQuery.append(startTag(XML_ALLPATHS)); | 87 | xmlQuery.append(startTag(XML_ALLPATHS)); |
1456 | 88 | aNode.getProperty().accept(this, context); | 88 | aNode.getProperty().accept(this, context); |
1458 | 89 | XMLQuery.append(endTag(XML_ALLPATHS)); | 89 | xmlQuery.append(endTag(XML_ALLPATHS)); |
1459 | 90 | } | 90 | } |
1460 | 91 | 91 | ||
1461 | 92 | public void visit(LTLENode eNode, Object context) { | 92 | public void visit(LTLENode eNode, Object context) { |
1463 | 93 | XMLQuery.append(startTag(XML_EXISTSPATH)); | 93 | xmlQuery.append(startTag(XML_EXISTSPATH)); |
1464 | 94 | eNode.getProperty().accept(this, context); | 94 | eNode.getProperty().accept(this, context); |
1466 | 95 | XMLQuery.append(endTag(XML_EXISTSPATH)); | 95 | xmlQuery.append(endTag(XML_EXISTSPATH)); |
1467 | 96 | } | 96 | } |
1468 | 97 | 97 | ||
1469 | 98 | public void visit(LTLFNode afNode, Object context) { | 98 | public void visit(LTLFNode afNode, Object context) { |
1471 | 99 | XMLQuery.append(startTag(XML_FINALLY)); | 99 | xmlQuery.append(startTag(XML_FINALLY)); |
1472 | 100 | afNode.getProperty().accept(this, context); | 100 | afNode.getProperty().accept(this, context); |
1474 | 101 | XMLQuery.append(endTag(XML_FINALLY)); | 101 | xmlQuery.append(endTag(XML_FINALLY)); |
1475 | 102 | } | 102 | } |
1476 | 103 | 103 | ||
1477 | 104 | public void visit(LTLGNode agNode, Object context) { | 104 | public void visit(LTLGNode agNode, Object context) { |
1479 | 105 | XMLQuery.append(startTag(XML_GLOBALLY)); | 105 | xmlQuery.append(startTag(XML_GLOBALLY)); |
1480 | 106 | agNode.getProperty().accept(this, context); | 106 | agNode.getProperty().accept(this, context); |
1482 | 107 | XMLQuery.append(endTag(XML_GLOBALLY)); | 107 | xmlQuery.append(endTag(XML_GLOBALLY)); |
1483 | 108 | } | 108 | } |
1484 | 109 | 109 | ||
1485 | 110 | public void visit(LTLXNode axNode, Object context) { | 110 | public void visit(LTLXNode axNode, Object context) { |
1487 | 111 | XMLQuery.append(startTag(XML_NEXT)); | 111 | xmlQuery.append(startTag(XML_NEXT)); |
1488 | 112 | axNode.getProperty().accept(this, context); | 112 | axNode.getProperty().accept(this, context); |
1490 | 113 | XMLQuery.append(endTag(XML_NEXT)); | 113 | xmlQuery.append(endTag(XML_NEXT)); |
1491 | 114 | } | 114 | } |
1492 | 115 | 115 | ||
1493 | 116 | public void visit(LTLUNode auNode, Object context) { | 116 | public void visit(LTLUNode auNode, Object context) { |
1495 | 117 | XMLQuery.append(startTag(XML_UNTIL) + startTag(XML_BEFORE)); | 117 | xmlQuery.append(startTag(XML_UNTIL) + startTag(XML_BEFORE)); |
1496 | 118 | auNode.getLeft().accept(this, context); | 118 | auNode.getLeft().accept(this, context); |
1498 | 119 | XMLQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); | 119 | xmlQuery.append(endTag(XML_BEFORE) + startTag(XML_REACH)); |
1499 | 120 | auNode.getRight().accept(this, context); | 120 | auNode.getRight().accept(this, context); |
1501 | 121 | XMLQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL)); | 121 | xmlQuery.append(endTag(XML_REACH) + endTag(XML_UNTIL)); |
1502 | 122 | } | 122 | } |
1503 | 123 | 123 | ||
1504 | 124 | public void visit(TCTLPathToStateConverter pathConverter, Object context) { | 124 | public void visit(TCTLPathToStateConverter pathConverter, Object context) { |
1505 | @@ -137,85 +137,96 @@ | |||
1506 | 137 | assert termListNode.getProperties().get(1) instanceof AritmeticOperator; | 137 | assert termListNode.getProperties().get(1) instanceof AritmeticOperator; |
1507 | 138 | AritmeticOperator operator = (AritmeticOperator)termListNode.getProperties().get(1); | 138 | AritmeticOperator operator = (AritmeticOperator)termListNode.getProperties().get(1); |
1508 | 139 | String op = operator.toString(); | 139 | String op = operator.toString(); |
1515 | 140 | if (op.equals("+")) { | 140 | switch (op) { |
1516 | 141 | createList(termListNode.getProperties(), context, XML_INTEGERSUM); | 141 | case "+": |
1517 | 142 | } else if (op.equals("*")) { | 142 | createList(termListNode.getProperties(), context, XML_INTEGERSUM); |
1518 | 143 | createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT); | 143 | break; |
1519 | 144 | } else if (op.equals("-")) { | 144 | case "*": |
1520 | 145 | createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE); | 145 | createList(termListNode.getProperties(), context, XML_INTEGERPRODUCT); |
1521 | 146 | break; | ||
1522 | 147 | case "-": | ||
1523 | 148 | createList(termListNode.getProperties(), context, XML_INTEGERDIFFERENCE); | ||
1524 | 149 | break; | ||
1525 | 146 | } | 150 | } |
1526 | 147 | } | 151 | } |
1527 | 148 | 152 | ||
1528 | 149 | private void createList(List<TCTLAbstractStateProperty> properties, Object context, String seperator) { | 153 | private void createList(List<TCTLAbstractStateProperty> properties, Object context, String seperator) { |
1530 | 150 | XMLQuery.append(startTag(seperator)); | 154 | xmlQuery.append(startTag(seperator)); |
1531 | 151 | 155 | ||
1532 | 152 | for (TCTLAbstractStateProperty p : properties) { | 156 | for (TCTLAbstractStateProperty p : properties) { |
1533 | 153 | p.accept(this, context); | 157 | p.accept(this, context); |
1534 | 154 | } | 158 | } |
1535 | 155 | 159 | ||
1537 | 156 | XMLQuery.append(endTag(seperator)); | 160 | xmlQuery.append(endTag(seperator)); |
1538 | 157 | } | 161 | } |
1539 | 158 | 162 | ||
1540 | 159 | public void visit(TCTLNotNode notNode, Object context) { | 163 | public void visit(TCTLNotNode notNode, Object context) { |
1542 | 160 | XMLQuery.append(startTag(XML_NEGATION)); | 164 | xmlQuery.append(startTag(XML_NEGATION)); |
1543 | 161 | notNode.getProperty().accept(this, context); | 165 | notNode.getProperty().accept(this, context); |
1545 | 162 | XMLQuery.append(endTag(XML_NEGATION)); | 166 | xmlQuery.append(endTag(XML_NEGATION)); |
1546 | 163 | } | 167 | } |
1547 | 164 | 168 | ||
1548 | 165 | public void visit(TCTLTrueNode tctlTrueNode, Object context) { | 169 | public void visit(TCTLTrueNode tctlTrueNode, Object context) { |
1550 | 166 | XMLQuery.append(emptyElement(XML_TRUE)); | 170 | xmlQuery.append(emptyElement(XML_TRUE)); |
1551 | 167 | } | 171 | } |
1552 | 168 | 172 | ||
1553 | 169 | public void visit(TCTLFalseNode tctlFalseNode, Object context) { | 173 | public void visit(TCTLFalseNode tctlFalseNode, Object context) { |
1555 | 170 | XMLQuery.append(emptyElement(XML_FALSE)); | 174 | xmlQuery.append(emptyElement(XML_FALSE)); |
1556 | 171 | } | 175 | } |
1557 | 172 | 176 | ||
1558 | 173 | public void visit(TCTLDeadlockNode tctlDeadLockNode, Object context) { | 177 | public void visit(TCTLDeadlockNode tctlDeadLockNode, Object context) { |
1560 | 174 | XMLQuery.append(emptyElement(XML_DEADLOCK)); | 178 | xmlQuery.append(emptyElement(XML_DEADLOCK)); |
1561 | 175 | } | 179 | } |
1562 | 176 | 180 | ||
1563 | 177 | public void visit(TCTLConstNode tctlConstNode, Object context){ | 181 | public void visit(TCTLConstNode tctlConstNode, Object context){ |
1565 | 178 | XMLQuery.append(wrapInTag(String.valueOf(tctlConstNode.getConstant()) + "", XML_INTEGERCONSTANT)); | 182 | xmlQuery.append(wrapInTag(tctlConstNode.getConstant() + "", XML_INTEGERCONSTANT)); |
1566 | 179 | } | 183 | } |
1567 | 180 | 184 | ||
1568 | 181 | public void visit(TCTLPlaceNode tctlPlaceNode, Object context){ | 185 | public void visit(TCTLPlaceNode tctlPlaceNode, Object context){ |
1572 | 182 | XMLQuery.append(startTag(XML_TOKENSCOUNT)); | 186 | xmlQuery.append(startTag(XML_TOKENSCOUNT)); |
1573 | 183 | XMLQuery.append(wrapInTag(tctlPlaceNode.toString() + "", XML_PLACE)); | 187 | xmlQuery.append(wrapInTag(tctlPlaceNode.toString() + "", XML_PLACE)); |
1574 | 184 | XMLQuery.append(endTag(XML_TOKENSCOUNT)); | 188 | xmlQuery.append(endTag(XML_TOKENSCOUNT)); |
1575 | 185 | } | 189 | } |
1576 | 186 | 190 | ||
1577 | 187 | public void visit(TCTLTransitionNode tctlTransitionNode, Object context){ | 191 | public void visit(TCTLTransitionNode tctlTransitionNode, Object context){ |
1581 | 188 | XMLQuery.append(startTag(XML_ISFIREABLE)); | 192 | xmlQuery.append(startTag(XML_ISFIREABLE)); |
1582 | 189 | XMLQuery.append(wrapInTag(tctlTransitionNode.toString() + "", XML_TRANSITION)); | 193 | xmlQuery.append(wrapInTag(tctlTransitionNode.toString() + "", XML_TRANSITION)); |
1583 | 190 | XMLQuery.append(endTag(XML_ISFIREABLE)); | 194 | xmlQuery.append(endTag(XML_ISFIREABLE)); |
1584 | 191 | } | 195 | } |
1585 | 192 | 196 | ||
1586 | 193 | @Override | 197 | @Override |
1589 | 194 | public void visit(TCTLAtomicPropositionNode atomicPropositionNode, | 198 | public void visit(TCTLAtomicPropositionNode atomicPropositionNode, Object context) { |
1588 | 195 | Object context) { | ||
1590 | 196 | String opTest = atomicPropositionNode.getOp(); | 199 | String opTest = atomicPropositionNode.getOp(); |
1592 | 197 | String op = new String(); | 200 | String op; |
1593 | 198 | 201 | ||
1608 | 199 | if (opTest.equals("<")){ | 202 | switch (opTest) { |
1609 | 200 | op = XML_INTEGERLT; | 203 | case "<": |
1610 | 201 | } else if(opTest.equals("<=")){ | 204 | op = XML_INTEGERLT; |
1611 | 202 | op = XML_INTEGERLE; | 205 | break; |
1612 | 203 | } else if(opTest.equals("=")){ | 206 | case "<=": |
1613 | 204 | op = XML_INTEGEREQ; | 207 | op = XML_INTEGERLE; |
1614 | 205 | } else if(opTest.equals("!=")){ | 208 | break; |
1615 | 206 | op = XML_INTEGERNE; | 209 | case "=": |
1616 | 207 | } else if(opTest.equals(">")){ | 210 | op = XML_INTEGEREQ; |
1617 | 208 | op = XML_INTEGERGT; | 211 | break; |
1618 | 209 | } else if(opTest.equals(">=")){ | 212 | case "!=": |
1619 | 210 | op = XML_INTEGERGE; | 213 | op = XML_INTEGERNE; |
1620 | 211 | } else { | 214 | break; |
1621 | 212 | op = "MISSING_OPERATOR"; | 215 | case ">": |
1622 | 216 | op = XML_INTEGERGT; | ||
1623 | 217 | break; | ||
1624 | 218 | case ">=": | ||
1625 | 219 | op = XML_INTEGERGE; | ||
1626 | 220 | break; | ||
1627 | 221 | default: | ||
1628 | 222 | op = "MISSING_OPERATOR"; | ||
1629 | 223 | break; | ||
1630 | 213 | } | 224 | } |
1631 | 214 | 225 | ||
1633 | 215 | XMLQuery.append(startTag(op)); | 226 | xmlQuery.append(startTag(op)); |
1634 | 216 | atomicPropositionNode.getLeft().accept(this, context); | 227 | atomicPropositionNode.getLeft().accept(this, context); |
1635 | 217 | atomicPropositionNode.getRight().accept(this, context); | 228 | atomicPropositionNode.getRight().accept(this, context); |
1637 | 218 | XMLQuery.append(endTag(op)); | 229 | xmlQuery.append(endTag(op)); |
1638 | 219 | } | 230 | } |
1639 | 220 | 231 | ||
1640 | 221 | private String wrapInTag(String str, String tag){ | 232 | private String wrapInTag(String str, String tag){ |
1641 | 222 | 233 | ||
1642 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java' | |||
1643 | --- src/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java 2019-03-23 07:51:29 +0000 | |||
1644 | +++ src/main/java/dk/aau/cs/TCTL/visitors/OptimizedStandardTranslationQueryVisitor.java 2022-07-21 13:30:11 +0000 | |||
1645 | @@ -11,8 +11,8 @@ | |||
1646 | 11 | protected static final String LOCK_BOOL = "lock"; | 11 | protected static final String LOCK_BOOL = "lock"; |
1647 | 12 | 12 | ||
1648 | 13 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; | 13 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; |
1651 | 14 | private boolean useSymmetry; | 14 | private final boolean useSymmetry; |
1652 | 15 | private int totalTokens; | 15 | private final int totalTokens; |
1653 | 16 | 16 | ||
1654 | 17 | public OptimizedStandardTranslationQueryVisitor(int totalTokens, boolean useSymmetry) { | 17 | public OptimizedStandardTranslationQueryVisitor(int totalTokens, boolean useSymmetry) { |
1655 | 18 | this.useSymmetry = useSymmetry; | 18 | this.useSymmetry = useSymmetry; |
1656 | 19 | 19 | ||
1657 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java' | |||
1658 | --- src/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java 2014-05-22 20:26:41 +0000 | |||
1659 | +++ src/main/java/dk/aau/cs/TCTL/visitors/RenamePlaceTCTLVisitor.java 2022-07-21 13:30:11 +0000 | |||
1660 | @@ -4,8 +4,8 @@ | |||
1661 | 4 | 4 | ||
1662 | 5 | public class RenamePlaceTCTLVisitor extends VisitorBase{ | 5 | public class RenamePlaceTCTLVisitor extends VisitorBase{ |
1663 | 6 | 6 | ||
1666 | 7 | private String oldPlaceName; | 7 | private final String oldPlaceName; |
1667 | 8 | private String newPlaceName; | 8 | private final String newPlaceName; |
1668 | 9 | 9 | ||
1669 | 10 | public RenamePlaceTCTLVisitor(String oldName, String newName) { | 10 | public RenamePlaceTCTLVisitor(String oldName, String newName) { |
1670 | 11 | oldPlaceName = oldName; | 11 | oldPlaceName = oldName; |
1671 | 12 | 12 | ||
1672 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java' | |||
1673 | --- src/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java 2017-03-12 00:33:00 +0000 | |||
1674 | +++ src/main/java/dk/aau/cs/TCTL/visitors/RenameTransitionTCTLVisitor.java 2022-07-21 13:30:11 +0000 | |||
1675 | @@ -4,8 +4,8 @@ | |||
1676 | 4 | 4 | ||
1677 | 5 | public class RenameTransitionTCTLVisitor extends VisitorBase{ | 5 | public class RenameTransitionTCTLVisitor extends VisitorBase{ |
1678 | 6 | 6 | ||
1681 | 7 | private String oldTransitionName; | 7 | private final String oldTransitionName; |
1682 | 8 | private String newTransitionName; | 8 | private final String newTransitionName; |
1683 | 9 | 9 | ||
1684 | 10 | public RenameTransitionTCTLVisitor(String oldName, String newName) { | 10 | public RenameTransitionTCTLVisitor(String oldName, String newName) { |
1685 | 11 | oldTransitionName = oldName; | 11 | oldTransitionName = oldName; |
1686 | 12 | 12 | ||
1687 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java' | |||
1688 | --- src/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java 2019-03-23 07:51:29 +0000 | |||
1689 | +++ src/main/java/dk/aau/cs/TCTL/visitors/StandardTranslationQueryVisitor.java 2022-07-21 13:30:11 +0000 | |||
1690 | @@ -12,7 +12,7 @@ | |||
1691 | 12 | 12 | ||
1692 | 13 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; | 13 | protected static final String TOKEN_TEMPLATE_NAME = "Token"; |
1693 | 14 | 14 | ||
1695 | 15 | private int totalTokens; | 15 | private final int totalTokens; |
1696 | 16 | 16 | ||
1697 | 17 | public StandardTranslationQueryVisitor(int totalTokens) { | 17 | public StandardTranslationQueryVisitor(int totalTokens) { |
1698 | 18 | this.totalTokens = totalTokens; | 18 | this.totalTokens = totalTokens; |
1699 | 19 | 19 | ||
1700 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java' | |||
1701 | --- src/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java 2017-03-12 00:33:00 +0000 | |||
1702 | +++ src/main/java/dk/aau/cs/TCTL/visitors/VerifyPlaceNamesVisitor.java 2022-07-21 13:30:11 +0000 | |||
1703 | @@ -9,7 +9,7 @@ | |||
1704 | 9 | 9 | ||
1705 | 10 | public class VerifyPlaceNamesVisitor extends VisitorBase { | 10 | public class VerifyPlaceNamesVisitor extends VisitorBase { |
1706 | 11 | 11 | ||
1708 | 12 | private ArrayList<Tuple<String, String>> templatePlaceNames; | 12 | private final ArrayList<Tuple<String, String>> templatePlaceNames; |
1709 | 13 | 13 | ||
1710 | 14 | public VerifyPlaceNamesVisitor(ArrayList<Tuple<String, String>> templatePlaceNames) { | 14 | public VerifyPlaceNamesVisitor(ArrayList<Tuple<String, String>> templatePlaceNames) { |
1711 | 15 | this.templatePlaceNames = templatePlaceNames; | 15 | this.templatePlaceNames = templatePlaceNames; |
1712 | @@ -31,11 +31,10 @@ | |||
1713 | 31 | c.setResult(false); | 31 | c.setResult(false); |
1714 | 32 | } | 32 | } |
1715 | 33 | } | 33 | } |
1719 | 34 | 34 | ||
1720 | 35 | // / context class | 35 | public static class Context { |
1718 | 36 | public class Context { | ||
1721 | 37 | private Boolean result; | 36 | private Boolean result; |
1723 | 38 | private HashSet<String> incorrectPlaceNames; | 37 | private final HashSet<String> incorrectPlaceNames; |
1724 | 39 | 38 | ||
1725 | 40 | public Boolean getResult() { | 39 | public Boolean getResult() { |
1726 | 41 | return result; | 40 | return result; |
1727 | 42 | 41 | ||
1728 | === modified file 'src/main/java/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java' | |||
1729 | --- src/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java 2017-03-12 00:33:00 +0000 | |||
1730 | +++ src/main/java/dk/aau/cs/TCTL/visitors/VerifyTransitionNamesVisitor.java 2022-07-21 13:30:11 +0000 | |||
1731 | @@ -8,7 +8,7 @@ | |||
1732 | 8 | import dk.aau.cs.util.Tuple; | 8 | import dk.aau.cs.util.Tuple; |
1733 | 9 | 9 | ||
1734 | 10 | public class VerifyTransitionNamesVisitor extends VisitorBase { | 10 | public class VerifyTransitionNamesVisitor extends VisitorBase { |
1736 | 11 | private ArrayList<Tuple<String, String>> templateTransitionNames; | 11 | private final ArrayList<Tuple<String, String>> templateTransitionNames; |
1737 | 12 | 12 | ||
1738 | 13 | public VerifyTransitionNamesVisitor(ArrayList<Tuple<String, String>> templateTransitionNames) { | 13 | public VerifyTransitionNamesVisitor(ArrayList<Tuple<String, String>> templateTransitionNames) { |
1739 | 14 | this.templateTransitionNames = templateTransitionNames; | 14 | this.templateTransitionNames = templateTransitionNames; |
1740 | @@ -30,11 +30,10 @@ | |||
1741 | 30 | c.setResult(false); | 30 | c.setResult(false); |
1742 | 31 | } | 31 | } |
1743 | 32 | } | 32 | } |
1747 | 33 | 33 | ||
1748 | 34 | // / context class | 34 | public static class Context { |
1746 | 35 | public class Context { | ||
1749 | 36 | private Boolean result; | 35 | private Boolean result; |
1751 | 37 | private HashSet<String> incorrectTransitionNames; | 36 | private final HashSet<String> incorrectTransitionNames; |
1752 | 38 | 37 | ||
1753 | 39 | public Boolean getResult() { | 38 | public Boolean getResult() { |
1754 | 40 | return result; | 39 | return result; |
1755 | 41 | 40 | ||
1756 | === modified file 'src/main/java/dk/aau/cs/approximation/ApproximationWorker.java' | |||
1757 | --- src/dk/aau/cs/approximation/ApproximationWorker.java 2020-12-16 21:11:57 +0000 | |||
1758 | +++ src/main/java/dk/aau/cs/approximation/ApproximationWorker.java 2022-07-21 13:30:11 +0000 | |||
1759 | @@ -2,9 +2,12 @@ | |||
1760 | 2 | 2 | ||
1761 | 3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
1762 | 4 | 4 | ||
1766 | 5 | import pipe.dataLayer.TAPNQuery.TraceOption; | 5 | import net.tapaal.gui.petrinet.TAPNLens; |
1767 | 6 | import pipe.gui.RunVerificationBase; | 6 | import pipe.gui.petrinet.dataLayer.DataLayer; |
1768 | 7 | import pipe.gui.widgets.InclusionPlaces; | 7 | import net.tapaal.gui.petrinet.verification.TAPNQuery.TraceOption; |
1769 | 8 | import pipe.gui.TAPAALGUI; | ||
1770 | 9 | import net.tapaal.gui.petrinet.verification.RunVerificationBase; | ||
1771 | 10 | import net.tapaal.gui.petrinet.verification.InclusionPlaces; | ||
1772 | 8 | import dk.aau.cs.Messenger; | 11 | import dk.aau.cs.Messenger; |
1773 | 9 | import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel; | 12 | import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel; |
1774 | 10 | import dk.aau.cs.model.tapn.TAPNQuery; | 13 | import dk.aau.cs.model.tapn.TAPNQuery; |
1775 | @@ -32,14 +35,17 @@ | |||
1776 | 32 | 35 | ||
1777 | 33 | public class ApproximationWorker { | 36 | public class ApproximationWorker { |
1778 | 34 | public VerificationResult<TAPNNetworkTrace> normalWorker( | 37 | public VerificationResult<TAPNNetworkTrace> normalWorker( |
1787 | 35 | VerificationOptions options, | 38 | VerificationOptions options, |
1788 | 36 | ModelChecker modelChecker, | 39 | ModelChecker modelChecker, |
1789 | 37 | Tuple<TimedArcPetriNet, NameMapping> transformedModel, | 40 | Tuple<TimedArcPetriNet, NameMapping> transformedModel, |
1790 | 38 | ITAPNComposer composer, | 41 | ITAPNComposer composer, |
1791 | 39 | TAPNQuery clonedQuery, | 42 | TAPNQuery clonedQuery, |
1792 | 40 | RunVerificationBase verificationBase, | 43 | RunVerificationBase verificationBase, |
1793 | 41 | TimedArcPetriNetNetwork model | 44 | TimedArcPetriNetNetwork model, |
1794 | 42 | ) throws Exception { | 45 | DataLayer guiModel, |
1795 | 46 | net.tapaal.gui.petrinet.verification.TAPNQuery dataLayerQuery, | ||
1796 | 47 | TAPNLens lens | ||
1797 | 48 | ) throws Exception { | ||
1798 | 43 | 49 | ||
1799 | 44 | // If options is of an instance of VerifyTAPNOptions then save the inclusion places before verify alters them | 50 | // If options is of an instance of VerifyTAPNOptions then save the inclusion places before verify alters them |
1800 | 45 | InclusionPlaces oldInclusionPlaces = null; | 51 | InclusionPlaces oldInclusionPlaces = null; |
1801 | @@ -53,7 +59,9 @@ | |||
1802 | 53 | } | 59 | } |
1803 | 54 | 60 | ||
1804 | 55 | VerificationResult<TAPNNetworkTrace> toReturn = null; | 61 | VerificationResult<TAPNNetworkTrace> toReturn = null; |
1806 | 56 | VerificationResult<TimedArcPetriNetTrace> result = modelChecker.verify(options, transformedModel, clonedQuery); | 62 | VerificationResult<TimedArcPetriNetTrace> result; |
1807 | 63 | |||
1808 | 64 | result = modelChecker.verify(options, transformedModel, clonedQuery, guiModel, dataLayerQuery, lens); | ||
1809 | 57 | 65 | ||
1810 | 58 | if (result.error()) { | 66 | if (result.error()) { |
1811 | 59 | options.setTraceOption(oldTraceOption); | 67 | options.setTraceOption(oldTraceOption); |
1812 | @@ -66,14 +74,19 @@ | |||
1813 | 66 | // If r = 1 | 74 | // If r = 1 |
1814 | 67 | // No matter what it answered -> return that answer | 75 | // No matter what it answered -> return that answer |
1815 | 68 | QueryResult queryResult = result.getQueryResult(); | 76 | QueryResult queryResult = result.getQueryResult(); |
1824 | 69 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 77 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); |
1825 | 70 | queryResult, | 78 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; |
1826 | 71 | decomposeTrace(result.getTrace(), transformedModel.value2(), model), | 79 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
1827 | 72 | decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model), | 80 | queryResult, |
1828 | 73 | result.verificationTime(), | 81 | decomposeTrace(result.getTrace(), nameMapping, netNetwork), |
1829 | 74 | result.stats(), | 82 | decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork), |
1830 | 75 | result.isSolvedUsingStateEquation()); | 83 | result.verificationTime(), |
1831 | 76 | toReturn.setNameMapping(transformedModel.value2()); | 84 | result.stats(), |
1832 | 85 | false, | ||
1833 | 86 | result.getUnfoldedModel()); | ||
1834 | 87 | toReturn.setNameMapping(transformedModel.value2()); | ||
1835 | 88 | |||
1836 | 89 | |||
1837 | 77 | } else { | 90 | } else { |
1838 | 78 | // If r > 1 | 91 | // If r > 1 |
1839 | 79 | if (result.getTrace() != null && (((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && result.getQueryResult().isQuerySatisfied()) | 92 | if (result.getTrace() != null && (((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && result.getQueryResult().isQuerySatisfied()) |
1840 | @@ -82,14 +95,17 @@ | |||
1841 | 82 | // The results are inconclusive, but we get a trace and can use trace TAPN for verification. | 95 | // The results are inconclusive, but we get a trace and can use trace TAPN for verification. |
1842 | 83 | 96 | ||
1843 | 84 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; | 97 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; |
1852 | 85 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 98 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); |
1853 | 86 | approxResult.getQueryResult(), | 99 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; |
1854 | 87 | decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model), | 100 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
1855 | 88 | decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model), | 101 | approxResult.getQueryResult(), |
1856 | 89 | approxResult.verificationTime(), | 102 | decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork), |
1857 | 90 | approxResult.stats(), | 103 | decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork), |
1858 | 91 | approxResult.isSolvedUsingStateEquation()); | 104 | approxResult.verificationTime(), |
1859 | 92 | toReturn.setNameMapping(transformedModel.value2()); | 105 | approxResult.stats(), |
1860 | 106 | false, | ||
1861 | 107 | approxResult.getUnfoldedModel()); | ||
1862 | 108 | toReturn.setNameMapping(nameMapping); | ||
1863 | 93 | 109 | ||
1864 | 94 | OverApproximation overaprx = new OverApproximation(); | 110 | OverApproximation overaprx = new OverApproximation(); |
1865 | 95 | 111 | ||
1866 | @@ -103,7 +119,7 @@ | |||
1867 | 103 | 119 | ||
1868 | 104 | // run model checker again for trace TAPN | 120 | // run model checker again for trace TAPN |
1869 | 105 | MemoryMonitor.cumulateMemory(); | 121 | MemoryMonitor.cumulateMemory(); |
1871 | 106 | result = modelChecker.verify(options, transformedOriginalModel, clonedQuery); | 122 | result = modelChecker.verify(options, transformedOriginalModel, clonedQuery, guiModel, dataLayerQuery, null); |
1872 | 107 | 123 | ||
1873 | 108 | if (result.error()) { | 124 | if (result.error()) { |
1874 | 109 | options.setTraceOption(oldTraceOption); | 125 | options.setTraceOption(oldTraceOption); |
1875 | @@ -127,14 +143,17 @@ | |||
1876 | 127 | 143 | ||
1877 | 128 | // If satisfied trace -> Return result | 144 | // If satisfied trace -> Return result |
1878 | 129 | // This is satisfied for EF and EG and not satisfied for AG and AF | 145 | // This is satisfied for EF and EG and not satisfied for AG and AF |
1887 | 130 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 146 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
1888 | 131 | queryResult, | 147 | queryResult, |
1889 | 132 | decomposeTrace(result.getTrace(), transformedModel.value2(), model), | 148 | decomposeTrace(result.getTrace(), nameMapping, netNetwork), |
1890 | 133 | decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model), | 149 | decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork), |
1891 | 134 | approxResult.verificationTime() + result.verificationTime(), | 150 | approxResult.verificationTime() + result.verificationTime(), |
1892 | 135 | approxResult.stats(), | 151 | approxResult.stats(), |
1893 | 136 | approxResult.isSolvedUsingStateEquation()); | 152 | false, |
1894 | 137 | toReturn.setNameMapping(transformedModel.value2()); | 153 | approxResult.getUnfoldedModel()); |
1895 | 154 | toReturn.setNameMapping(nameMapping); | ||
1896 | 155 | |||
1897 | 156 | |||
1898 | 138 | } | 157 | } |
1899 | 139 | else if (((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && !result.getQueryResult().isQuerySatisfied()) | 158 | else if (((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && !result.getQueryResult().isQuerySatisfied()) |
1900 | 140 | || ((result.getQueryResult().queryType() == QueryType.AG || result.getQueryResult().queryType() == QueryType.AF) && result.getQueryResult().isQuerySatisfied())) { | 159 | || ((result.getQueryResult().queryType() == QueryType.AG || result.getQueryResult().queryType() == QueryType.AF) && result.getQueryResult().isQuerySatisfied())) { |
1901 | @@ -147,14 +166,19 @@ | |||
1902 | 147 | } | 166 | } |
1903 | 148 | 167 | ||
1904 | 149 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; | 168 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; |
1913 | 150 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 169 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); |
1914 | 151 | approxResult.getQueryResult(), | 170 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; |
1915 | 152 | decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model), | 171 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
1916 | 153 | decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model), | 172 | approxResult.getQueryResult(), |
1917 | 154 | approxResult.verificationTime(), | 173 | decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork), |
1918 | 155 | approxResult.stats(), | 174 | decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork), |
1919 | 156 | approxResult.isSolvedUsingStateEquation()); | 175 | approxResult.verificationTime(), |
1920 | 157 | toReturn.setNameMapping(transformedModel.value2()); | 176 | approxResult.stats(), |
1921 | 177 | false, | ||
1922 | 178 | approxResult.getUnfoldedModel()); | ||
1923 | 179 | toReturn.setNameMapping(nameMapping); | ||
1924 | 180 | |||
1925 | 181 | |||
1926 | 158 | } else { | 182 | } else { |
1927 | 159 | // We cannot use the result directly, and did not get a trace. | 183 | // We cannot use the result directly, and did not get a trace. |
1928 | 160 | 184 | ||
1929 | @@ -162,15 +186,18 @@ | |||
1930 | 162 | queryResult.setApproximationInconclusive(true); | 186 | queryResult.setApproximationInconclusive(true); |
1931 | 163 | 187 | ||
1932 | 164 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; | 188 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; |
1942 | 165 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 189 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); |
1943 | 166 | approxResult.getQueryResult(), | 190 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; |
1944 | 167 | decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model), | 191 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
1945 | 168 | decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model), | 192 | approxResult.getQueryResult(), |
1946 | 169 | approxResult.verificationTime(), | 193 | decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork), |
1947 | 170 | approxResult.stats(), | 194 | decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork), |
1948 | 171 | approxResult.isSolvedUsingStateEquation()); | 195 | approxResult.verificationTime(), |
1949 | 172 | toReturn.setNameMapping(transformedModel.value2()); | 196 | approxResult.stats(), |
1950 | 173 | 197 | false, | |
1951 | 198 | approxResult.getUnfoldedModel()); | ||
1952 | 199 | toReturn.setNameMapping(nameMapping); | ||
1953 | 200 | |||
1954 | 174 | } | 201 | } |
1955 | 175 | } | 202 | } |
1956 | 176 | } | 203 | } |
1957 | @@ -194,14 +221,19 @@ | |||
1958 | 194 | // If r = 1 | 221 | // If r = 1 |
1959 | 195 | // No matter it answered -> return that answer | 222 | // No matter it answered -> return that answer |
1960 | 196 | QueryResult queryResult= result.getQueryResult(); | 223 | QueryResult queryResult= result.getQueryResult(); |
1969 | 197 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 224 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); |
1970 | 198 | queryResult, | 225 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; |
1971 | 199 | decomposeTrace(result.getTrace(), transformedModel.value2(), model), | 226 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
1972 | 200 | decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model), | 227 | queryResult, |
1973 | 201 | result.verificationTime(), | 228 | decomposeTrace(result.getTrace(), nameMapping, netNetwork), |
1974 | 202 | result.stats(), | 229 | decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork), |
1975 | 203 | result.isSolvedUsingStateEquation()); | 230 | result.verificationTime(), |
1976 | 204 | toReturn.setNameMapping(transformedModel.value2()); | 231 | result.stats(), |
1977 | 232 | false, | ||
1978 | 233 | result.getUnfoldedModel()); | ||
1979 | 234 | toReturn.setNameMapping(nameMapping); | ||
1980 | 235 | |||
1981 | 236 | |||
1982 | 205 | } | 237 | } |
1983 | 206 | else { | 238 | else { |
1984 | 207 | // If r > 1 | 239 | // If r > 1 |
1985 | @@ -210,14 +242,18 @@ | |||
1986 | 210 | // If ((EF OR EG) AND not satisfied) OR ((AG OR AF) and satisfied) -> Inconclusive | 242 | // If ((EF OR EG) AND not satisfied) OR ((AG OR AF) and satisfied) -> Inconclusive |
1987 | 211 | QueryResult queryResult= result.getQueryResult(); | 243 | QueryResult queryResult= result.getQueryResult(); |
1988 | 212 | queryResult.setApproximationInconclusive(true); | 244 | queryResult.setApproximationInconclusive(true); |
1997 | 213 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 245 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); |
1998 | 214 | queryResult, | 246 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; |
1999 | 215 | decomposeTrace(result.getTrace(), transformedModel.value2(), model), | 247 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
2000 | 216 | decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model), | 248 | queryResult, |
2001 | 217 | result.verificationTime(), | 249 | decomposeTrace(result.getTrace(), nameMapping, netNetwork), |
2002 | 218 | result.stats(), | 250 | decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork), |
2003 | 219 | result.isSolvedUsingStateEquation()); | 251 | result.verificationTime(), |
2004 | 220 | toReturn.setNameMapping(transformedModel.value2()); | 252 | result.stats(), |
2005 | 253 | false, | ||
2006 | 254 | result.getUnfoldedModel()); | ||
2007 | 255 | toReturn.setNameMapping(nameMapping); | ||
2008 | 256 | |||
2009 | 221 | } else if ((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && result.getQueryResult().isQuerySatisfied() | 257 | } else if ((result.getQueryResult().queryType() == QueryType.EF || result.getQueryResult().queryType() == QueryType.EG) && result.getQueryResult().isQuerySatisfied() |
2010 | 222 | || ((result.getQueryResult().queryType() == QueryType.AG || result.getQueryResult().queryType() == QueryType.AF) && ! result.getQueryResult().isQuerySatisfied())) { | 258 | || ((result.getQueryResult().queryType() == QueryType.AG || result.getQueryResult().queryType() == QueryType.AF) && ! result.getQueryResult().isQuerySatisfied())) { |
2011 | 223 | 259 | ||
2012 | @@ -225,14 +261,19 @@ | |||
2013 | 225 | // If query does have deadlock or EG or AF a trace -> create trace TAPN | 261 | // If query does have deadlock or EG or AF a trace -> create trace TAPN |
2014 | 226 | //Create the verification satisfied result for the approximation | 262 | //Create the verification satisfied result for the approximation |
2015 | 227 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; | 263 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; |
2024 | 228 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 264 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); |
2025 | 229 | approxResult.getQueryResult(), | 265 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; |
2026 | 230 | decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model), | 266 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
2027 | 231 | decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model), | 267 | approxResult.getQueryResult(), |
2028 | 232 | approxResult.verificationTime(), | 268 | decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork), |
2029 | 233 | approxResult.stats(), | 269 | decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork), |
2030 | 234 | result.isSolvedUsingStateEquation()); | 270 | approxResult.verificationTime(), |
2031 | 235 | toReturn.setNameMapping(transformedModel.value2()); | 271 | approxResult.stats(), |
2032 | 272 | false, | ||
2033 | 273 | result.getUnfoldedModel()); | ||
2034 | 274 | toReturn.setNameMapping(nameMapping); | ||
2035 | 275 | |||
2036 | 276 | |||
2037 | 236 | 277 | ||
2038 | 237 | OverApproximation overaprx = new OverApproximation(); | 278 | OverApproximation overaprx = new OverApproximation(); |
2039 | 238 | 279 | ||
2040 | @@ -247,7 +288,7 @@ | |||
2041 | 247 | 288 | ||
2042 | 248 | //run model checker again for trace TAPN | 289 | //run model checker again for trace TAPN |
2043 | 249 | MemoryMonitor.cumulateMemory(); | 290 | MemoryMonitor.cumulateMemory(); |
2045 | 250 | result = modelChecker.verify(options, transformedOriginalModel, clonedQuery); | 291 | result = modelChecker.verify(options, transformedOriginalModel, clonedQuery, guiModel, dataLayerQuery, null); |
2046 | 251 | 292 | ||
2047 | 252 | if (result.error()) { | 293 | if (result.error()) { |
2048 | 253 | options.setTraceOption(oldTraceOption); | 294 | options.setTraceOption(oldTraceOption); |
2049 | @@ -271,16 +312,17 @@ | |||
2050 | 271 | || (result.getQueryResult().queryType() == QueryType.AF && queryResult.isQuerySatisfied())) { | 312 | || (result.getQueryResult().queryType() == QueryType.AF && queryResult.isQuerySatisfied())) { |
2051 | 272 | queryResult.setApproximationInconclusive(true); | 313 | queryResult.setApproximationInconclusive(true); |
2052 | 273 | } | 314 | } |
2054 | 274 | 315 | ||
2055 | 275 | // If satisfied trace) -> Return result | 316 | // If satisfied trace) -> Return result |
2056 | 276 | // This is satisfied for EF and EG and not satisfied for AG and AF | 317 | // This is satisfied for EF and EG and not satisfied for AG and AF |
2057 | 277 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 318 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
2058 | 278 | queryResult, | 319 | queryResult, |
2061 | 279 | decomposeTrace(result.getTrace(), transformedModel.value2(), model), | 320 | decomposeTrace(result.getTrace(), nameMapping, netNetwork), |
2062 | 280 | decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model), | 321 | decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork), |
2063 | 281 | approxResult.verificationTime() + result.verificationTime(), | 322 | approxResult.verificationTime() + result.verificationTime(), |
2064 | 282 | approxResult.stats(), | 323 | approxResult.stats(), |
2066 | 283 | approxResult.isSolvedUsingStateEquation()); | 324 | false, |
2067 | 325 | approxResult.getUnfoldedModel()); | ||
2068 | 284 | toReturn.setNameMapping(transformedModel.value2()); | 326 | toReturn.setNameMapping(transformedModel.value2()); |
2069 | 285 | } | 327 | } |
2070 | 286 | else { | 328 | else { |
2071 | @@ -289,28 +331,36 @@ | |||
2072 | 289 | queryResult.setApproximationInconclusive(true); | 331 | queryResult.setApproximationInconclusive(true); |
2073 | 290 | 332 | ||
2074 | 291 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; | 333 | VerificationResult<TimedArcPetriNetTrace> approxResult = result; |
2075 | 334 | NameMapping nameMapping = model.isColored()? result.getUnfoldedModel().value2(): transformedModel.value2(); | ||
2076 | 335 | TimedArcPetriNetNetwork netNetwork = model.isColored()? result.getUnfoldedModel().value1().parentNetwork(): model; | ||
2077 | 336 | |||
2078 | 292 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 337 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
2079 | 293 | approxResult.getQueryResult(), | 338 | approxResult.getQueryResult(), |
2082 | 294 | decomposeTrace(approxResult.getTrace(), transformedModel.value2(), model), | 339 | decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork), |
2083 | 295 | decomposeTrace(approxResult.getSecondaryTrace(), transformedModel.value2(), model), | 340 | decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork), |
2084 | 296 | approxResult.verificationTime(), | 341 | approxResult.verificationTime(), |
2085 | 297 | approxResult.stats(), | 342 | approxResult.stats(), |
2088 | 298 | approxResult.isSolvedUsingStateEquation()); | 343 | false, |
2089 | 299 | toReturn.setNameMapping(transformedModel.value2()); | 344 | approxResult.getUnfoldedModel()); |
2090 | 345 | toReturn.setNameMapping(nameMapping); | ||
2091 | 300 | } | 346 | } |
2092 | 301 | } | 347 | } |
2093 | 302 | } | 348 | } |
2094 | 303 | } | 349 | } |
2095 | 304 | else { | 350 | else { |
2096 | 351 | boolean isColored = (lens != null && lens.isColored() || model.isColored()); | ||
2097 | 352 | NameMapping nameMapping = isColored? result.getUnfoldedModel().value2(): transformedModel.value2(); | ||
2098 | 353 | TimedArcPetriNetNetwork netNetwork = isColored? result.getUnfoldedModel().value1().parentNetwork(): model; | ||
2099 | 305 | toReturn = new VerificationResult<TAPNNetworkTrace>( | 354 | toReturn = new VerificationResult<TAPNNetworkTrace>( |
2100 | 306 | result.getQueryResult(), | 355 | result.getQueryResult(), |
2103 | 307 | decomposeTrace(result.getTrace(), transformedModel.value2(), model), | 356 | decomposeTrace(result.getTrace(), nameMapping, netNetwork), |
2104 | 308 | decomposeTrace(result.getSecondaryTrace(), transformedModel.value2(), model), | 357 | decomposeTrace(result.getSecondaryTrace(), nameMapping, netNetwork), |
2105 | 309 | result.verificationTime(), | 358 | result.verificationTime(), |
2106 | 310 | result.stats(), | 359 | result.stats(), |
2110 | 311 | result.isSolvedUsingStateEquation(), | 360 | false, |
2111 | 312 | result.getRawOutput()); | 361 | result.getRawOutput(), |
2112 | 313 | toReturn.setNameMapping(transformedModel.value2()); | 362 | result.getUnfoldedModel()); |
2113 | 363 | toReturn.setNameMapping(nameMapping); | ||
2114 | 314 | } | 364 | } |
2115 | 315 | 365 | ||
2116 | 316 | options.setTraceOption(oldTraceOption); | 366 | options.setTraceOption(oldTraceOption); |
2117 | @@ -326,7 +376,7 @@ | |||
2118 | 326 | public VerificationResult<TimedArcPetriNetTrace> batchWorker( | 376 | public VerificationResult<TimedArcPetriNetTrace> batchWorker( |
2119 | 327 | Tuple<TimedArcPetriNet, NameMapping> composedModel, | 377 | Tuple<TimedArcPetriNet, NameMapping> composedModel, |
2120 | 328 | VerificationOptions options, | 378 | VerificationOptions options, |
2122 | 329 | pipe.dataLayer.TAPNQuery query, | 379 | net.tapaal.gui.petrinet.verification.TAPNQuery query, |
2123 | 330 | LoadedBatchProcessingModel model, | 380 | LoadedBatchProcessingModel model, |
2124 | 331 | ModelChecker modelChecker, | 381 | ModelChecker modelChecker, |
2125 | 332 | TAPNQuery queryToVerify, | 382 | TAPNQuery queryToVerify, |
2126 | @@ -354,7 +404,7 @@ | |||
2127 | 354 | options.setTraceOption(TraceOption.SOME); | 404 | options.setTraceOption(TraceOption.SOME); |
2128 | 355 | } | 405 | } |
2129 | 356 | 406 | ||
2131 | 357 | VerificationResult<TimedArcPetriNetTrace> verificationResult = modelChecker.verify(options, composedModel, queryToVerify); | 407 | VerificationResult<TimedArcPetriNetTrace> verificationResult = modelChecker.verify(options, composedModel, queryToVerify, null, query, null); |
2132 | 358 | 408 | ||
2133 | 359 | VerificationResult<TAPNNetworkTrace> valueNetwork = null; //The final result is meant to be a PetriNetTrace but to make traceTAPN we make a networktrace | 409 | VerificationResult<TAPNNetworkTrace> valueNetwork = null; //The final result is meant to be a PetriNetTrace but to make traceTAPN we make a networktrace |
2134 | 360 | VerificationResult<TimedArcPetriNetTrace> value = null; | 410 | VerificationResult<TimedArcPetriNetTrace> value = null; |
2135 | @@ -376,7 +426,8 @@ | |||
2136 | 376 | verificationResult.getSecondaryTrace(), | 426 | verificationResult.getSecondaryTrace(), |
2137 | 377 | verificationResult.verificationTime(), | 427 | verificationResult.verificationTime(), |
2138 | 378 | verificationResult.stats(), | 428 | verificationResult.stats(), |
2140 | 379 | verificationResult.isSolvedUsingStateEquation()); | 429 | false, |
2141 | 430 | verificationResult.getUnfoldedModel()); | ||
2142 | 380 | value.setNameMapping(composedModel.value2()); | 431 | value.setNameMapping(composedModel.value2()); |
2143 | 381 | } else { | 432 | } else { |
2144 | 382 | // If r > 1 | 433 | // If r > 1 |
2145 | @@ -385,14 +436,17 @@ | |||
2146 | 385 | // If ((EF OR EG) AND satisfied) OR ((AG OR AF) AND not satisfied) | 436 | // If ((EF OR EG) AND satisfied) OR ((AG OR AF) AND not satisfied) |
2147 | 386 | //Create the verification satisfied result for the approximation | 437 | //Create the verification satisfied result for the approximation |
2148 | 387 | VerificationResult<TimedArcPetriNetTrace> approxResult = verificationResult; | 438 | VerificationResult<TimedArcPetriNetTrace> approxResult = verificationResult; |
2149 | 439 | NameMapping nameMapping = model.network().isColored()? verificationResult.getUnfoldedModel().value2(): composedModel.value2(); | ||
2150 | 440 | TimedArcPetriNetNetwork netNetwork = model.network().isColored()? verificationResult.getUnfoldedModel().value1().parentNetwork(): model.network(); | ||
2151 | 388 | valueNetwork = new VerificationResult<TAPNNetworkTrace>( | 441 | valueNetwork = new VerificationResult<TAPNNetworkTrace>( |
2152 | 389 | approxResult.getQueryResult(), | 442 | approxResult.getQueryResult(), |
2155 | 390 | decomposeTrace(approxResult.getTrace(), composedModel.value2(), model.network()), | 443 | decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork), |
2156 | 391 | decomposeTrace(approxResult.getSecondaryTrace(), composedModel.value2(), model.network()), | 444 | decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork), |
2157 | 392 | approxResult.verificationTime(), | 445 | approxResult.verificationTime(), |
2158 | 393 | approxResult.stats(), | 446 | approxResult.stats(), |
2161 | 394 | verificationResult.isSolvedUsingStateEquation()); | 447 | false, |
2162 | 395 | valueNetwork.setNameMapping(composedModel.value2()); | 448 | verificationResult.getUnfoldedModel()); |
2163 | 449 | valueNetwork.setNameMapping(nameMapping); | ||
2164 | 396 | 450 | ||
2165 | 397 | OverApproximation overaprx = new OverApproximation(); | 451 | OverApproximation overaprx = new OverApproximation(); |
2166 | 398 | 452 | ||
2167 | @@ -406,7 +460,7 @@ | |||
2168 | 406 | 460 | ||
2169 | 407 | //run model checker again for trace TAPN | 461 | //run model checker again for trace TAPN |
2170 | 408 | MemoryMonitor.cumulateMemory(); | 462 | MemoryMonitor.cumulateMemory(); |
2172 | 409 | verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery); | 463 | verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery, null, query, null); |
2173 | 410 | 464 | ||
2174 | 411 | if (verificationResult.error()) { | 465 | if (verificationResult.error()) { |
2175 | 412 | options.setTraceOption(oldTraceOption); | 466 | options.setTraceOption(oldTraceOption); |
2176 | @@ -432,7 +486,8 @@ | |||
2177 | 432 | approxResult.getSecondaryTrace(), | 486 | approxResult.getSecondaryTrace(), |
2178 | 433 | approxResult.verificationTime() + verificationResult.verificationTime(), | 487 | approxResult.verificationTime() + verificationResult.verificationTime(), |
2179 | 434 | approxResult.stats(), | 488 | approxResult.stats(), |
2181 | 435 | verificationResult.isSolvedUsingStateEquation()); | 489 | false, |
2182 | 490 | verificationResult.getUnfoldedModel()); | ||
2183 | 436 | value.setNameMapping(composedModel.value2()); | 491 | value.setNameMapping(composedModel.value2()); |
2184 | 437 | } | 492 | } |
2185 | 438 | else if (((verificationResult.getQueryResult().queryType() == QueryType.EF || verificationResult.getQueryResult().queryType() == QueryType.EG) && !verificationResult.getQueryResult().isQuerySatisfied()) | 493 | else if (((verificationResult.getQueryResult().queryType() == QueryType.EF || verificationResult.getQueryResult().queryType() == QueryType.EG) && !verificationResult.getQueryResult().isQuerySatisfied()) |
2186 | @@ -451,7 +506,8 @@ | |||
2187 | 451 | verificationResult.getSecondaryTrace(), | 506 | verificationResult.getSecondaryTrace(), |
2188 | 452 | verificationResult.verificationTime(), | 507 | verificationResult.verificationTime(), |
2189 | 453 | verificationResult.stats(), | 508 | verificationResult.stats(), |
2191 | 454 | verificationResult.isSolvedUsingStateEquation()); | 509 | false, |
2192 | 510 | verificationResult.getUnfoldedModel()); | ||
2193 | 455 | value.setNameMapping(composedModel.value2()); | 511 | value.setNameMapping(composedModel.value2()); |
2194 | 456 | } | 512 | } |
2195 | 457 | else { | 513 | else { |
2196 | @@ -467,7 +523,8 @@ | |||
2197 | 467 | verificationResult.getSecondaryTrace(), | 523 | verificationResult.getSecondaryTrace(), |
2198 | 468 | verificationResult.verificationTime(), | 524 | verificationResult.verificationTime(), |
2199 | 469 | verificationResult.stats(), | 525 | verificationResult.stats(), |
2201 | 470 | verificationResult.isSolvedUsingStateEquation()); | 526 | false, |
2202 | 527 | verificationResult.getUnfoldedModel()); | ||
2203 | 471 | value.setNameMapping(composedModel.value2()); | 528 | value.setNameMapping(composedModel.value2()); |
2204 | 472 | } | 529 | } |
2205 | 473 | } | 530 | } |
2206 | @@ -485,7 +542,8 @@ | |||
2207 | 485 | verificationResult.getSecondaryTrace(), | 542 | verificationResult.getSecondaryTrace(), |
2208 | 486 | verificationResult.verificationTime(), | 543 | verificationResult.verificationTime(), |
2209 | 487 | verificationResult.stats(), | 544 | verificationResult.stats(), |
2211 | 488 | verificationResult.isSolvedUsingStateEquation()); | 545 | false, |
2212 | 546 | verificationResult.getUnfoldedModel()); | ||
2213 | 489 | value.setNameMapping(composedModel.value2()); | 547 | value.setNameMapping(composedModel.value2()); |
2214 | 490 | } | 548 | } |
2215 | 491 | else { | 549 | else { |
2216 | @@ -502,7 +560,8 @@ | |||
2217 | 502 | verificationResult.getSecondaryTrace(), | 560 | verificationResult.getSecondaryTrace(), |
2218 | 503 | verificationResult.verificationTime(), | 561 | verificationResult.verificationTime(), |
2219 | 504 | verificationResult.stats(), | 562 | verificationResult.stats(), |
2221 | 505 | verificationResult.isSolvedUsingStateEquation()); | 563 | false, |
2222 | 564 | verificationResult.getUnfoldedModel()); | ||
2223 | 506 | value.setNameMapping(composedModel.value2()); | 565 | value.setNameMapping(composedModel.value2()); |
2224 | 507 | 566 | ||
2225 | 508 | } | 567 | } |
2226 | @@ -514,14 +573,20 @@ | |||
2227 | 514 | // If query does have deadlock -> create trace TAPN | 573 | // If query does have deadlock -> create trace TAPN |
2228 | 515 | //Create the verification satisfied result for the approximation | 574 | //Create the verification satisfied result for the approximation |
2229 | 516 | VerificationResult<TimedArcPetriNetTrace> approxResult = verificationResult; | 575 | VerificationResult<TimedArcPetriNetTrace> approxResult = verificationResult; |
2238 | 517 | valueNetwork = new VerificationResult<TAPNNetworkTrace>( | 576 | |
2239 | 518 | approxResult.getQueryResult(), | 577 | NameMapping nameMapping = model.network().isColored()? verificationResult.getUnfoldedModel().value2(): composedModel.value2(); |
2240 | 519 | decomposeTrace(approxResult.getTrace(), composedModel.value2(), model.network()), | 578 | TimedArcPetriNetNetwork netNetwork = model.network().isColored()? verificationResult.getUnfoldedModel().value1().parentNetwork(): model.network(); |
2241 | 520 | decomposeTrace(approxResult.getSecondaryTrace(), composedModel.value2(), model.network()), | 579 | valueNetwork = new VerificationResult<TAPNNetworkTrace>( |
2242 | 521 | approxResult.verificationTime(), | 580 | approxResult.getQueryResult(), |
2243 | 522 | approxResult.stats(), | 581 | decomposeTrace(approxResult.getTrace(), nameMapping, netNetwork), |
2244 | 523 | approxResult.isSolvedUsingStateEquation()); | 582 | decomposeTrace(approxResult.getSecondaryTrace(), nameMapping, netNetwork), |
2245 | 524 | valueNetwork.setNameMapping(composedModel.value2()); | 583 | approxResult.verificationTime(), |
2246 | 584 | approxResult.stats(), | ||
2247 | 585 | false, | ||
2248 | 586 | verificationResult.getUnfoldedModel()); | ||
2249 | 587 | valueNetwork.setNameMapping(nameMapping); | ||
2250 | 588 | |||
2251 | 589 | |||
2252 | 525 | 590 | ||
2253 | 526 | OverApproximation overaprx = new OverApproximation(); | 591 | OverApproximation overaprx = new OverApproximation(); |
2254 | 527 | 592 | ||
2255 | @@ -534,7 +599,7 @@ | |||
2256 | 534 | 599 | ||
2257 | 535 | //run model checker again for trace TAPN | 600 | //run model checker again for trace TAPN |
2258 | 536 | MemoryMonitor.cumulateMemory(); | 601 | MemoryMonitor.cumulateMemory(); |
2260 | 537 | verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery); | 602 | verificationResult = modelChecker.verify(options, transformedOriginalModel, clonedQuery, null, query, null); |
2261 | 538 | 603 | ||
2262 | 539 | if (verificationResult.error()) { | 604 | if (verificationResult.error()) { |
2263 | 540 | options.setTraceOption(oldTraceOption); | 605 | options.setTraceOption(oldTraceOption); |
2264 | @@ -564,7 +629,8 @@ | |||
2265 | 564 | verificationResult.getSecondaryTrace(), | 629 | verificationResult.getSecondaryTrace(), |
2266 | 565 | verificationResult.verificationTime() + approxResult.verificationTime(), | 630 | verificationResult.verificationTime() + approxResult.verificationTime(), |
2267 | 566 | verificationResult.stats(), | 631 | verificationResult.stats(), |
2269 | 567 | verificationResult.isSolvedUsingStateEquation()); | 632 | false, |
2270 | 633 | verificationResult.getUnfoldedModel()); | ||
2271 | 568 | value.setNameMapping(composedModel.value2()); | 634 | value.setNameMapping(composedModel.value2()); |
2272 | 569 | } | 635 | } |
2273 | 570 | else { | 636 | else { |
2274 | @@ -578,7 +644,8 @@ | |||
2275 | 578 | verificationResult.getSecondaryTrace(), | 644 | verificationResult.getSecondaryTrace(), |
2276 | 579 | verificationResult.verificationTime(), | 645 | verificationResult.verificationTime(), |
2277 | 580 | verificationResult.stats(), | 646 | verificationResult.stats(), |
2279 | 581 | verificationResult.isSolvedUsingStateEquation()); | 647 | false, |
2280 | 648 | verificationResult.getUnfoldedModel()); | ||
2281 | 582 | value.setNameMapping(composedModel.value2()); | 649 | value.setNameMapping(composedModel.value2()); |
2282 | 583 | } | 650 | } |
2283 | 584 | } | 651 | } |
2284 | @@ -591,7 +658,8 @@ | |||
2285 | 591 | verificationResult.getSecondaryTrace(), | 658 | verificationResult.getSecondaryTrace(), |
2286 | 592 | verificationResult.verificationTime(), | 659 | verificationResult.verificationTime(), |
2287 | 593 | verificationResult.stats(), | 660 | verificationResult.stats(), |
2289 | 594 | verificationResult.isSolvedUsingStateEquation()); | 661 | false, |
2290 | 662 | verificationResult.getUnfoldedModel()); | ||
2291 | 595 | value.setNameMapping(composedModel.value2()); | 663 | value.setNameMapping(composedModel.value2()); |
2292 | 596 | } | 664 | } |
2293 | 597 | 665 | ||
2294 | 598 | 666 | ||
2295 | === modified file 'src/main/java/dk/aau/cs/approximation/OverApproximation.java' | |||
2296 | --- src/dk/aau/cs/approximation/OverApproximation.java 2020-07-20 12:17:24 +0000 | |||
2297 | +++ src/main/java/dk/aau/cs/approximation/OverApproximation.java 2022-07-21 13:30:11 +0000 | |||
2298 | @@ -13,6 +13,7 @@ | |||
2299 | 13 | import dk.aau.cs.TCTL.TCTLNotNode; | 13 | import dk.aau.cs.TCTL.TCTLNotNode; |
2300 | 14 | import dk.aau.cs.TCTL.TCTLOrListNode; | 14 | import dk.aau.cs.TCTL.TCTLOrListNode; |
2301 | 15 | import dk.aau.cs.TCTL.TCTLPlaceNode; | 15 | import dk.aau.cs.TCTL.TCTLPlaceNode; |
2302 | 16 | import dk.aau.cs.model.CPN.ColorType; | ||
2303 | 16 | import dk.aau.cs.model.tapn.*; | 17 | import dk.aau.cs.model.tapn.*; |
2304 | 17 | import dk.aau.cs.model.tapn.simulation.*; | 18 | import dk.aau.cs.model.tapn.simulation.*; |
2305 | 18 | import dk.aau.cs.util.Tuple; | 19 | import dk.aau.cs.util.Tuple; |
2306 | @@ -69,18 +70,18 @@ | |||
2307 | 69 | oldInterval.isUpperBoundNonStrict() | 70 | oldInterval.isUpperBoundNonStrict() |
2308 | 70 | ); | 71 | ); |
2309 | 71 | } | 72 | } |
2311 | 72 | 73 | ||
2312 | 73 | public void makeTraceTAPN(Tuple<TimedArcPetriNet, NameMapping> transformedModel, VerificationResult<TAPNNetworkTrace> result, dk.aau.cs.model.tapn.TAPNQuery query) { | 74 | public void makeTraceTAPN(Tuple<TimedArcPetriNet, NameMapping> transformedModel, VerificationResult<TAPNNetworkTrace> result, dk.aau.cs.model.tapn.TAPNQuery query) { |
2313 | 74 | TimedArcPetriNet net = transformedModel.value1(); | 75 | TimedArcPetriNet net = transformedModel.value1(); |
2314 | 75 | 76 | ||
2315 | 76 | LocalTimedPlace currentPlace = new LocalTimedPlace("PTRACE0"); | 77 | LocalTimedPlace currentPlace = new LocalTimedPlace("PTRACE0"); |
2317 | 77 | TimedToken currentToken = new TimedToken(currentPlace); | 78 | TimedToken currentToken = new TimedToken(currentPlace, ColorType.COLORTYPE_DOT.getFirstColor()); |
2318 | 78 | net.add(currentPlace); | 79 | net.add(currentPlace); |
2319 | 79 | currentPlace.addToken(currentToken); | 80 | currentPlace.addToken(currentToken); |
2320 | 80 | 81 | ||
2321 | 81 | // Block place, which secures the net makes at most one transition not in the trace. | 82 | // Block place, which secures the net makes at most one transition not in the trace. |
2324 | 82 | LocalTimedPlace blockPlace = new LocalTimedPlace("PBLOCK", TimeInvariant.LESS_THAN_INFINITY); | 83 | LocalTimedPlace blockPlace = new LocalTimedPlace("PBLOCK"); |
2325 | 83 | TimedToken blockToken = new TimedToken(blockPlace); | 84 | TimedToken blockToken = new TimedToken(blockPlace, ColorType.COLORTYPE_DOT.getFirstColor()); |
2326 | 84 | net.add(blockPlace); | 85 | net.add(blockPlace); |
2327 | 85 | blockPlace.addToken(blockToken); | 86 | blockPlace.addToken(blockToken); |
2328 | 86 | 87 | ||
2329 | @@ -140,7 +141,7 @@ | |||
2330 | 140 | (((TAPNNetworkTimedTransitionStep) step).getTransition().sharedTransition() == null ? tmpStep.getTransition().model().name() : ""), | 141 | (((TAPNNetworkTimedTransitionStep) step).getTransition().sharedTransition() == null ? tmpStep.getTransition().model().name() : ""), |
2331 | 141 | tmpStep.getTransition().name()); | 142 | tmpStep.getTransition().name()); |
2332 | 142 | TimedTransition firedTransition = net.getTransitionByName(nameMap.get(key)); | 143 | TimedTransition firedTransition = net.getTransitionByName(nameMap.get(key)); |
2334 | 143 | TimedTransition copyTransition = new TimedTransition(firedTransition.name() + "_traceNet_" + Integer.toString(++transitionInteger), firedTransition.isUrgent()); | 144 | TimedTransition copyTransition = new TimedTransition(firedTransition.name() + "_traceNet_" + Integer.toString(++transitionInteger), firedTransition.isUrgent(), null); |
2335 | 144 | 145 | ||
2336 | 145 | net.add(copyTransition); | 146 | net.add(copyTransition); |
2337 | 146 | net.add(new TimedInputArc(currentPlace, copyTransition, TimeInterval.ZERO_INF)); | 147 | net.add(new TimedInputArc(currentPlace, copyTransition, TimeInterval.ZERO_INF)); |
2338 | @@ -163,17 +164,17 @@ | |||
2339 | 163 | 164 | ||
2340 | 164 | for (TimedInputArc arc : originalInput) { | 165 | for (TimedInputArc arc : originalInput) { |
2341 | 165 | if (arc.destination() == firedTransition) { | 166 | if (arc.destination() == firedTransition) { |
2343 | 166 | net.add(new TimedInputArc(arc.source(), copyTransition, arc.interval(), arc.getWeight())); | 167 | net.add(new TimedInputArc(arc.source(), copyTransition, arc.interval(), arc.getWeight(), arc.getArcExpression())); |
2344 | 167 | } | 168 | } |
2345 | 168 | } | 169 | } |
2346 | 169 | for (TimedOutputArc arc : originalOutput) { | 170 | for (TimedOutputArc arc : originalOutput) { |
2347 | 170 | if (arc.source() == firedTransition) { | 171 | if (arc.source() == firedTransition) { |
2349 | 171 | net.add(new TimedOutputArc(copyTransition, arc.destination(), arc.getWeight())); | 172 | net.add(new TimedOutputArc(copyTransition, arc.destination(), arc.getWeight(), arc.getExpression())); |
2350 | 172 | } | 173 | } |
2351 | 173 | } | 174 | } |
2352 | 174 | for (TimedInhibitorArc arc : originalInhibitor) { | 175 | for (TimedInhibitorArc arc : originalInhibitor) { |
2353 | 175 | if (arc.destination() == firedTransition) { | 176 | if (arc.destination() == firedTransition) { |
2355 | 176 | net.add(new TimedInhibitorArc(arc.source(), copyTransition, arc.interval(), arc.getWeight())); | 177 | net.add(new TimedInhibitorArc(arc.source(), copyTransition, arc.interval(), arc.getWeight(), arc.getArcExpression())); |
2356 | 177 | } | 178 | } |
2357 | 178 | } | 179 | } |
2358 | 179 | for (TransportArc arc : originalTransport) { | 180 | for (TransportArc arc : originalTransport) { |
2359 | @@ -200,7 +201,7 @@ | |||
2360 | 200 | 201 | ||
2361 | 201 | // An input arc from pBlock to all original transitions makes sure, that we can do deadlock checks. | 202 | // An input arc from pBlock to all original transitions makes sure, that we can do deadlock checks. |
2362 | 202 | for (TimedTransition transition : originalTransitions) { | 203 | for (TimedTransition transition : originalTransitions) { |
2364 | 203 | net.add(new TimedInputArc(blockPlace, transition, TimeInterval.ZERO_INF)); | 204 | net.add(new TimedInputArc(blockPlace, transition, TimeInterval.ZERO_INF)); |
2365 | 204 | } | 205 | } |
2366 | 205 | } | 206 | } |
2367 | 206 | 207 | ||
2368 | 207 | 208 | ||
2369 | === modified file 'src/main/java/dk/aau/cs/approximation/UnderApproximation.java' | |||
2370 | --- src/dk/aau/cs/approximation/UnderApproximation.java 2020-07-20 12:17:24 +0000 | |||
2371 | +++ src/main/java/dk/aau/cs/approximation/UnderApproximation.java 2022-07-21 13:30:11 +0000 | |||
2372 | @@ -1,23 +1,13 @@ | |||
2373 | 1 | package dk.aau.cs.approximation; | 1 | package dk.aau.cs.approximation; |
2374 | 2 | 2 | ||
2375 | 3 | import dk.aau.cs.model.tapn.*; | ||
2376 | 4 | import pipe.gui.petrinet.dataLayer.DataLayer; | ||
2377 | 5 | import pipe.gui.petrinet.graphicElements.Arc; | ||
2378 | 6 | import pipe.gui.petrinet.graphicElements.Place; | ||
2379 | 7 | import pipe.gui.petrinet.graphicElements.Transition; | ||
2380 | 8 | |||
2381 | 3 | import java.util.ArrayList; | 9 | import java.util.ArrayList; |
2382 | 4 | 10 | ||
2383 | 5 | import dk.aau.cs.model.tapn.Bound; | ||
2384 | 6 | import dk.aau.cs.model.tapn.IntBound; | ||
2385 | 7 | import dk.aau.cs.model.tapn.TimeInterval; | ||
2386 | 8 | import dk.aau.cs.model.tapn.TimeInvariant; | ||
2387 | 9 | import dk.aau.cs.model.tapn.TimedArcPetriNet; | ||
2388 | 10 | import dk.aau.cs.model.tapn.TimedInhibitorArc; | ||
2389 | 11 | import dk.aau.cs.model.tapn.TimedInputArc; | ||
2390 | 12 | import dk.aau.cs.model.tapn.TimedOutputArc; | ||
2391 | 13 | import dk.aau.cs.model.tapn.TimedPlace; | ||
2392 | 14 | import dk.aau.cs.model.tapn.TimedTransition; | ||
2393 | 15 | import dk.aau.cs.model.tapn.TransportArc; | ||
2394 | 16 | import pipe.dataLayer.DataLayer; | ||
2395 | 17 | import pipe.gui.graphicElements.Arc; | ||
2396 | 18 | import pipe.gui.graphicElements.Place; | ||
2397 | 19 | import pipe.gui.graphicElements.Transition; | ||
2398 | 20 | |||
2399 | 21 | public class UnderApproximation implements ITAPNApproximation { | 11 | public class UnderApproximation implements ITAPNApproximation { |
2400 | 22 | @Override | 12 | @Override |
2401 | 23 | public void modifyTAPN(TimedArcPetriNet net, int approximationDenominator) { | 13 | public void modifyTAPN(TimedArcPetriNet net, int approximationDenominator) { |
2402 | @@ -141,44 +131,42 @@ | |||
2403 | 141 | } | 131 | } |
2404 | 142 | 132 | ||
2405 | 143 | //Returns a copy of an approximated interval | 133 | //Returns a copy of an approximated interval |
2445 | 144 | private TimeInterval modifyIntervals(TimeInterval oldInterval, int denominator){ | 134 | private TimeInterval modifyIntervals(TimeInterval oldInterval, int denominator) { |
2446 | 145 | Bound newUpperBound; | 135 | Bound newUpperBound; |
2447 | 146 | // Do not calculate upper bound for infinite | 136 | // Do not calculate upper bound for infinite |
2448 | 147 | if ( ! (oldInterval.upperBound() instanceof Bound.InfBound)) { | 137 | if (!(oldInterval.upperBound() instanceof Bound.InfBound)) { |
2449 | 148 | 138 | ||
2450 | 149 | // Calculate the new upper bound value. | 139 | // Calculate the new upper bound value. |
2451 | 150 | int oldUpperBoundValue = oldInterval.upperBound().value(); | 140 | int oldUpperBoundValue = oldInterval.upperBound().value(); |
2452 | 151 | newUpperBound = new IntBound((int) Math.floor((double)oldUpperBoundValue / denominator)); | 141 | newUpperBound = new IntBound((int) Math.floor((double) oldUpperBoundValue / denominator)); |
2453 | 152 | } | 142 | } else { |
2454 | 153 | else | 143 | newUpperBound = Bound.Infinity; |
2455 | 154 | newUpperBound = Bound.Infinity; | 144 | } |
2456 | 155 | 145 | ||
2457 | 156 | // Calculate the new lower bound | 146 | // Calculate the new lower bound |
2458 | 157 | IntBound newLowerBound = new IntBound((int) Math.ceil((double)oldInterval.lowerBound().value() / denominator)); | 147 | IntBound newLowerBound = new IntBound((int) Math.ceil((double) oldInterval.lowerBound().value() / denominator)); |
2459 | 158 | 148 | ||
2460 | 159 | // if the lower bound has become greater than the upper bound by rounding | 149 | // if the lower bound has become greater than the upper bound by rounding |
2461 | 160 | if ( ! (oldInterval.upperBound() instanceof Bound.InfBound) && newLowerBound.value() > newUpperBound.value()) | 150 | if (!(oldInterval.upperBound() instanceof Bound.InfBound) && newLowerBound.value() > newUpperBound.value()) { |
2462 | 161 | { | 151 | newLowerBound = new IntBound((int) Math.floor((double) oldInterval.lowerBound().value() / denominator)); |
2463 | 162 | newLowerBound = new IntBound((int) Math.floor((double)oldInterval.lowerBound().value() / denominator)); | 152 | newUpperBound = new IntBound((int) Math.floor((double) oldInterval.upperBound().value() / denominator)); |
2464 | 163 | newUpperBound = new IntBound((int) Math.floor((double)oldInterval.upperBound().value() / denominator)); | 153 | } |
2465 | 164 | } | 154 | |
2466 | 165 | 155 | boolean isLowerBoundNonStrict = oldInterval.isLowerBoundNonStrict(); | |
2467 | 166 | boolean isLowerBoundNonStrict = oldInterval.isLowerBoundNonStrict(); | 156 | boolean isUpperBoundNonStrict = oldInterval.isUpperBoundNonStrict(); |
2468 | 167 | boolean isUpperBoundNonStrict = oldInterval.isUpperBoundNonStrict(); | 157 | |
2469 | 168 | 158 | // if the interval becomes too small we make it a bit bigger to secure, that we do not have to delete the arc | |
2470 | 169 | // if the interval becomes too small we make it a bit bigger to secure, that we do not have to delete the arc | 159 | if ((newUpperBound.value() == newLowerBound.value()) && !(oldInterval.isLowerBoundNonStrict() && oldInterval.isUpperBoundNonStrict())) { |
2471 | 170 | if ( (newUpperBound.value() == newLowerBound.value()) && !(oldInterval.isLowerBoundNonStrict() && oldInterval.isUpperBoundNonStrict())) | 160 | isUpperBoundNonStrict = true; |
2472 | 171 | { | 161 | isLowerBoundNonStrict = true; |
2473 | 172 | isUpperBoundNonStrict = true; | 162 | } |
2474 | 173 | isLowerBoundNonStrict = true; | 163 | |
2475 | 174 | } | 164 | return new TimeInterval( |
2476 | 175 | 165 | isLowerBoundNonStrict, | |
2477 | 176 | return new TimeInterval( | 166 | newLowerBound, |
2478 | 177 | isLowerBoundNonStrict, | 167 | newUpperBound, |
2479 | 178 | newLowerBound, | 168 | isUpperBoundNonStrict |
2480 | 179 | newUpperBound, | 169 | ); |
2481 | 180 | isUpperBoundNonStrict | 170 | } |
2443 | 181 | ); | ||
2444 | 182 | } | ||
2482 | 183 | 171 | ||
2483 | 184 | } | 172 | } |
2484 | 185 | 173 | ||
2485 | === added file 'src/main/java/dk/aau/cs/io/LoadTACPN.java' | |||
2486 | --- src/main/java/dk/aau/cs/io/LoadTACPN.java 1970-01-01 00:00:00 +0000 | |||
2487 | +++ src/main/java/dk/aau/cs/io/LoadTACPN.java 2022-07-21 13:30:11 +0000 | |||
2488 | @@ -0,0 +1,439 @@ | |||
2489 | 1 | package dk.aau.cs.io; | ||
2490 | 2 | |||
2491 | 3 | import dk.aau.cs.model.CPN.*; | ||
2492 | 4 | import dk.aau.cs.model.CPN.Expressions.*; | ||
2493 | 5 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; | ||
2494 | 6 | import dk.aau.cs.util.FormatException; | ||
2495 | 7 | import dk.aau.cs.util.Require; | ||
2496 | 8 | import dk.aau.cs.util.Tuple; | ||
2497 | 9 | import org.w3c.dom.Element; | ||
2498 | 10 | import org.w3c.dom.Node; | ||
2499 | 11 | |||
2500 | 12 | import java.util.*; | ||
2501 | 13 | |||
2502 | 14 | public class LoadTACPN { //the import feature for CPN and load for TACPN share similarities. These similarities are shared here. Feel free to find a better name for this class | ||
2503 | 15 | |||
2504 | 16 | private final HashMap<String, ColorType> colortypes = new HashMap<>(); | ||
2505 | 17 | private final HashMap<String, Variable> variables = new HashMap<>(); | ||
2506 | 18 | private final HashMap<String, ColorExpression> tupleVarExpressions = new HashMap<>(); | ||
2507 | 19 | private final Collection<String> messages = new ArrayList<>(10); | ||
2508 | 20 | |||
2509 | 21 | public HashMap<String, ColorType> getColortypes() { | ||
2510 | 22 | return colortypes; | ||
2511 | 23 | } | ||
2512 | 24 | |||
2513 | 25 | public HashMap<String, Variable> getVariables() { | ||
2514 | 26 | return variables; | ||
2515 | 27 | } | ||
2516 | 28 | |||
2517 | 29 | public Collection<String> getMessages() {return messages;} | ||
2518 | 30 | //skipWS | ||
2519 | 31 | // Takes a given node and returns it if it is an element, | ||
2520 | 32 | // otherwise returns its first element sibling. | ||
2521 | 33 | // This allows skipping past whitespace nodes. | ||
2522 | 34 | private static Node skipWS(Node node) { | ||
2523 | 35 | if (node != null && !(node instanceof Element)) { | ||
2524 | 36 | return skipWS(node.getNextSibling()); | ||
2525 | 37 | } else { | ||
2526 | 38 | return node; | ||
2527 | 39 | } | ||
2528 | 40 | } | ||
2529 | 41 | |||
2530 | 42 | private static Node getAttribute(Node node, String attribute) { | ||
2531 | 43 | return node.getAttributes().getNamedItem(attribute); | ||
2532 | 44 | } | ||
2533 | 45 | |||
2534 | 46 | public void parseDeclarations(Node node, TimedArcPetriNetNetwork network) throws FormatException { | ||
2535 | 47 | if(!(node instanceof Element)){ | ||
2536 | 48 | return; | ||
2537 | 49 | } | ||
2538 | 50 | Node child = skipWS(node.getFirstChild()); | ||
2539 | 51 | while(child != null){ | ||
2540 | 52 | String childName = child.getNodeName(); | ||
2541 | 53 | if (childName.equals("namedsort")){ | ||
2542 | 54 | parseNamedSort(child, network); | ||
2543 | 55 | } else if (childName.equals("variabledecl")){ | ||
2544 | 56 | String id = getAttribute(child, "id").getNodeValue(); | ||
2545 | 57 | String name = getAttribute(child, "name").getNodeValue(); | ||
2546 | 58 | ColorType ct = parseUserSort(child); | ||
2547 | 59 | Variable var = new Variable(name, id, ct); | ||
2548 | 60 | Require.that(variables.put(id, var) == null, "the id " + id + ", was already used"); | ||
2549 | 61 | network.add(var); | ||
2550 | 62 | } else { | ||
2551 | 63 | parseDeclarations(child, network); | ||
2552 | 64 | } | ||
2553 | 65 | |||
2554 | 66 | child = skipWS(child.getNextSibling()); | ||
2555 | 67 | } | ||
2556 | 68 | Vector<String> variablesForRemoval = new Vector<>(); | ||
2557 | 69 | HashMap<String, Variable> newVars = new HashMap<>(); | ||
2558 | 70 | StringBuilder renameWarnings = new StringBuilder(); | ||
2559 | 71 | // Convert product variables into variables for the constituent of the product | ||
2560 | 72 | for(String varName : variables.keySet()){ | ||
2561 | 73 | Variable var = variables.get(varName); | ||
2562 | 74 | if(var.getColorType().isProductColorType()){ | ||
2563 | 75 | int constituentCounter = 1; | ||
2564 | 76 | |||
2565 | 77 | Vector<ColorExpression> constituentVarExpressions = new Vector<>(); | ||
2566 | 78 | renameWarnings.append("The product variable ").append(var.getName()).append(", was unfolded to ("); | ||
2567 | 79 | |||
2568 | 80 | for(ColorType colorType : var.getColorType().getProductColorTypes()){ | ||
2569 | 81 | StringBuilder elementSubstring = new StringBuilder("_" + constituentCounter); | ||
2570 | 82 | while (variables.containsKey(varName + elementSubstring) || newVars.containsKey(varName + elementSubstring)){ | ||
2571 | 83 | elementSubstring.append("_1"); | ||
2572 | 84 | } | ||
2573 | 85 | |||
2574 | 86 | renameWarnings.append(varName).append(elementSubstring).append(","); | ||
2575 | 87 | |||
2576 | 88 | Variable newVar = new Variable(var.getName() + elementSubstring, varName + elementSubstring, colorType); | ||
2577 | 89 | Require.that(newVars.put(varName + elementSubstring, newVar) == null, "the id " + varName + elementSubstring + ", was already used"); | ||
2578 | 90 | network.add(newVar); | ||
2579 | 91 | constituentVarExpressions.addElement(new VariableExpression(newVar)); | ||
2580 | 92 | constituentCounter++; | ||
2581 | 93 | } | ||
2582 | 94 | renameWarnings.deleteCharAt(renameWarnings.length()-1); | ||
2583 | 95 | renameWarnings.append(")\n"); | ||
2584 | 96 | |||
2585 | 97 | tupleVarExpressions.put(varName, new TupleExpression(constituentVarExpressions)); | ||
2586 | 98 | network.remove(var); | ||
2587 | 99 | variablesForRemoval.addElement(varName); | ||
2588 | 100 | } | ||
2589 | 101 | } | ||
2590 | 102 | for(String varName : variablesForRemoval){ | ||
2591 | 103 | variables.remove(varName); | ||
2592 | 104 | } | ||
2593 | 105 | for(String varName : newVars.keySet()){ | ||
2594 | 106 | variables.put(varName, newVars.get(varName)); | ||
2595 | 107 | } | ||
2596 | 108 | |||
2597 | 109 | if(renameWarnings.length() > 0){ | ||
2598 | 110 | messages.add(renameWarnings.toString()); | ||
2599 | 111 | //JOptionPane.showConfirmDialog(CreateGui.getApp(), renameWarnings.toString(), "Product Variables unfolded", JOptionPane.OK_OPTION, JOptionPane.WARNING_MESSAGE); | ||
2600 | 112 | } | ||
2601 | 113 | } | ||
2602 | 114 | private void parseNamedSort(Node node, TimedArcPetriNetNetwork network) throws FormatException { | ||
2603 | 115 | //We always use the dot colortype | ||
2604 | 116 | colortypes.put("dot", ColorType.COLORTYPE_DOT); | ||
2605 | 117 | network.add(ColorType.COLORTYPE_DOT); | ||
2606 | 118 | |||
2607 | 119 | Node type = skipWS(node.getFirstChild()); | ||
2608 | 120 | String typetag = type.getNodeName(); | ||
2609 | 121 | String name = getAttribute(node, "name").getNodeValue(); | ||
2610 | 122 | String id = getAttribute(node, "id").getNodeValue(); | ||
2611 | 123 | |||
2612 | 124 | if (typetag.equals("productsort")) { | ||
2613 | 125 | ProductType pt = new ProductType(name); | ||
2614 | 126 | Node typechild = skipWS(type.getFirstChild()); | ||
2615 | 127 | while (typechild != null) { | ||
2616 | 128 | if (typechild.getNodeName().equals("usersort")) { | ||
2617 | 129 | String constituent = getAttribute(typechild, "declaration").getNodeValue(); | ||
2618 | 130 | pt.addType(colortypes.get(constituent)); | ||
2619 | 131 | } | ||
2620 | 132 | typechild = skipWS(typechild.getNextSibling()); | ||
2621 | 133 | } | ||
2622 | 134 | Require.that(colortypes.put(id, pt) == null, "the name " + id + ", was already used"); | ||
2623 | 135 | network.add(pt); | ||
2624 | 136 | } else { | ||
2625 | 137 | ColorType ct = new ColorType(name, id); | ||
2626 | 138 | if (typetag.equals("dot")) { | ||
2627 | 139 | return; | ||
2628 | 140 | } else if (typetag.equals("finiteintrange")){ | ||
2629 | 141 | int start = Integer.parseInt(getAttribute(type, "start").getNodeValue()); | ||
2630 | 142 | int end = Integer.parseInt(getAttribute(type, "end").getNodeValue()); | ||
2631 | 143 | for(int i = start; i <= end; i++){ | ||
2632 | 144 | ct.addColor(String.valueOf(i)); | ||
2633 | 145 | } | ||
2634 | 146 | } else { | ||
2635 | 147 | Node typechild = skipWS(type.getFirstChild()); | ||
2636 | 148 | while (typechild != null) { | ||
2637 | 149 | Node colorId = getAttribute(typechild, "id"); | ||
2638 | 150 | if (colorId != null) { | ||
2639 | 151 | ct.addColor(colorId.getNodeValue()); | ||
2640 | 152 | typechild = skipWS(typechild.getNextSibling()); | ||
2641 | 153 | } else { | ||
2642 | 154 | throw new FormatException(String.format("No id found on %s\n", typechild.getNodeName())); | ||
2643 | 155 | } | ||
2644 | 156 | } | ||
2645 | 157 | } | ||
2646 | 158 | Require.that(colortypes.put(id, ct) == null, "the name " + id + ", was already used"); | ||
2647 | 159 | network.add(ct); | ||
2648 | 160 | } | ||
2649 | 161 | } | ||
2650 | 162 | |||
2651 | 163 | public ColorType parseUserSort(Node node) throws FormatException { | ||
2652 | 164 | if (node instanceof Element) { | ||
2653 | 165 | Node child = skipWS(node.getFirstChild()); | ||
2654 | 166 | while (child != null) { | ||
2655 | 167 | String name = child.getNodeName(); | ||
2656 | 168 | if (name.equals("usersort")) { | ||
2657 | 169 | Node decl = getAttribute(child, "declaration"); | ||
2658 | 170 | return colortypes.get(decl.getNodeValue()); | ||
2659 | 171 | } else if (name.matches("structure|type|subterm")) { | ||
2660 | 172 | return parseUserSort(child); | ||
2661 | 173 | } | ||
2662 | 174 | child = skipWS(child.getNextSibling()); | ||
2663 | 175 | } | ||
2664 | 176 | } | ||
2665 | 177 | throw new FormatException(String.format("Could not parse %s as an usersort\n", node.getNodeName())); | ||
2666 | 178 | } | ||
2667 | 179 | |||
2668 | 180 | public ArcExpression parseArcExpression(Node node) throws FormatException { | ||
2669 | 181 | String name = node.getNodeName(); | ||
2670 | 182 | if (name.equals("numberof")) { | ||
2671 | 183 | return parseNumberOfExpression(node); | ||
2672 | 184 | } else if (name.equals("add")) { | ||
2673 | 185 | Vector<ArcExpression> constituents = new Vector<>(); | ||
2674 | 186 | |||
2675 | 187 | Node child = skipWS(node.getFirstChild()); | ||
2676 | 188 | while (child != null) { | ||
2677 | 189 | ArcExpression subterm = parseArcExpression(child); | ||
2678 | 190 | constituents.add(subterm); | ||
2679 | 191 | child = skipWS(child.getNextSibling()); | ||
2680 | 192 | } | ||
2681 | 193 | return new AddExpression(constituents); | ||
2682 | 194 | } else if (name.equals("subtract")) { | ||
2683 | 195 | Node headchild = skipWS(node.getFirstChild()); | ||
2684 | 196 | ArcExpression headexp = parseArcExpression(headchild); | ||
2685 | 197 | |||
2686 | 198 | Node nextchild = skipWS(headchild.getNextSibling()); | ||
2687 | 199 | while (nextchild != null) { | ||
2688 | 200 | ArcExpression nextexp = parseArcExpression(nextchild); | ||
2689 | 201 | headexp = new SubtractExpression(headexp, nextexp); | ||
2690 | 202 | nextchild = skipWS(nextchild.getNextSibling()); | ||
2691 | 203 | } | ||
2692 | 204 | return headexp; | ||
2693 | 205 | } else if (name.equals("scalarproduct")) { | ||
2694 | 206 | Node scalar = skipWS(node.getFirstChild()); | ||
2695 | 207 | Integer scalarval = parseNumberConstantExpression(scalar); | ||
2696 | 208 | |||
2697 | 209 | Node child = skipWS(scalar.getNextSibling()); | ||
2698 | 210 | ArcExpression childexp = parseArcExpression(child); | ||
2699 | 211 | |||
2700 | 212 | return new ScalarProductExpression(scalarval, childexp); | ||
2701 | 213 | }else if (name.equals("all")){ | ||
2702 | 214 | ColorType ct = parseUserSort(node); | ||
2703 | 215 | Vector<ColorExpression> ceVector = new Vector<>(); | ||
2704 | 216 | ceVector.add(new AllExpression(ct)); | ||
2705 | 217 | return new NumberOfExpression(1,ceVector); | ||
2706 | 218 | |||
2707 | 219 | } else if (name.matches("subterm|structure")) { | ||
2708 | 220 | Node child = skipWS(node.getFirstChild()); | ||
2709 | 221 | return parseArcExpression(child); | ||
2710 | 222 | } else if (name.matches("tuple")){ | ||
2711 | 223 | Vector<ColorExpression> ceVector = new Vector<>(); | ||
2712 | 224 | ceVector.add(parseColorExpression(node)); | ||
2713 | 225 | return new NumberOfExpression(1, ceVector); | ||
2714 | 226 | } else{ | ||
2715 | 227 | throw new FormatException(String.format("Could not parse %s as an arc expression\n", name)); | ||
2716 | 228 | } | ||
2717 | 229 | } | ||
2718 | 230 | |||
2719 | 231 | private NumberOfExpression parseNumberOfExpression(Node node) throws FormatException { | ||
2720 | 232 | Node number = skipWS(node.getFirstChild()); | ||
2721 | 233 | //The number constant may be omitted. | ||
2722 | 234 | //In that case, this parsing returns null. | ||
2723 | 235 | Integer numberval = parseNumberConstantExpression(number); | ||
2724 | 236 | Node subnode; | ||
2725 | 237 | if (numberval != null) { | ||
2726 | 238 | //The subexpression comes after the number constant. | ||
2727 | 239 | subnode = skipWS(number.getNextSibling()); | ||
2728 | 240 | } else { | ||
2729 | 241 | //The number we read was actually the subexpression. | ||
2730 | 242 | subnode = number; | ||
2731 | 243 | numberval = 1; | ||
2732 | 244 | } | ||
2733 | 245 | Vector<ColorExpression> colorexps = new Vector<>(); | ||
2734 | 246 | while (subnode != null) { | ||
2735 | 247 | ColorExpression colorexp = parseColorExpression(subnode); | ||
2736 | 248 | colorexps.add(colorexp); | ||
2737 | 249 | subnode = skipWS(subnode.getNextSibling()); | ||
2738 | 250 | } | ||
2739 | 251 | return new NumberOfExpression(numberval, colorexps); | ||
2740 | 252 | |||
2741 | 253 | } | ||
2742 | 254 | |||
2743 | 255 | private Integer parseNumberConstantExpression(Node node) { | ||
2744 | 256 | String name = node.getNodeName(); | ||
2745 | 257 | if (name.equals("numberconstant")) { | ||
2746 | 258 | String value = getAttribute(node, "value").getNodeValue(); | ||
2747 | 259 | return Integer.valueOf(value); | ||
2748 | 260 | } else if (name.equals("subterm")) { | ||
2749 | 261 | Node child = skipWS(node.getFirstChild()); | ||
2750 | 262 | return parseNumberConstantExpression(child); | ||
2751 | 263 | } else { | ||
2752 | 264 | return null; | ||
2753 | 265 | } | ||
2754 | 266 | } | ||
2755 | 267 | |||
2756 | 268 | private ColorExpression parseColorExpression(Node node) throws FormatException { | ||
2757 | 269 | String name = node.getNodeName(); | ||
2758 | 270 | if (name.equals("dotconstant")) { | ||
2759 | 271 | return new DotConstantExpression(); | ||
2760 | 272 | } else if (name.equals("variable")) { | ||
2761 | 273 | String varname = getAttribute(node, "refvariable").getNodeValue(); | ||
2762 | 274 | Variable var = variables.get(varname); | ||
2763 | 275 | if(var != null){ | ||
2764 | 276 | return new VariableExpression(var); | ||
2765 | 277 | } else { | ||
2766 | 278 | return tupleVarExpressions.get(varname); | ||
2767 | 279 | } | ||
2768 | 280 | } else if (name.equals("useroperator")) { | ||
2769 | 281 | String colorname = getAttribute(node, "declaration").getNodeValue(); | ||
2770 | 282 | Color color = getColor(colorname); | ||
2771 | 283 | return new UserOperatorExpression(color); | ||
2772 | 284 | } else if (name.equals("successor")) { | ||
2773 | 285 | Node child = skipWS(node.getFirstChild()); | ||
2774 | 286 | ColorExpression childexp = parseColorExpression(child); | ||
2775 | 287 | return new SuccessorExpression(childexp); | ||
2776 | 288 | } else if (name.equals("predecessor")) { | ||
2777 | 289 | Node child = skipWS(node.getFirstChild()); | ||
2778 | 290 | ColorExpression childexp = parseColorExpression(child); | ||
2779 | 291 | return new PredecessorExpression(childexp); | ||
2780 | 292 | } else if(name.equals("all")){ | ||
2781 | 293 | ColorType ct = parseUserSort(node); | ||
2782 | 294 | return new AllExpression(ct); | ||
2783 | 295 | } else if (name.equals("tuple")) { | ||
2784 | 296 | Vector<ColorExpression> colorexps = new Vector<>(); | ||
2785 | 297 | |||
2786 | 298 | Node child = skipWS(node.getFirstChild()); | ||
2787 | 299 | while (child != null) { | ||
2788 | 300 | ColorExpression colorexp = parseColorExpression(child); | ||
2789 | 301 | colorexps.add(colorexp); | ||
2790 | 302 | child = skipWS(child.getNextSibling()); | ||
2791 | 303 | } | ||
2792 | 304 | //Sometimes PNML nets have tuples with only 1 color, we just remove the tuple | ||
2793 | 305 | if(colorexps.size() < 2){ | ||
2794 | 306 | return colorexps.get(0); | ||
2795 | 307 | } | ||
2796 | 308 | return new TupleExpression(colorexps); | ||
2797 | 309 | } else if (name.matches("subterm|structure")) { | ||
2798 | 310 | Node child = skipWS(node.getFirstChild()); | ||
2799 | 311 | return parseColorExpression(child); | ||
2800 | 312 | } else if (name.equals("finiteintrangeconstant")){ | ||
2801 | 313 | String value = getAttribute(node, "value").getNodeValue(); | ||
2802 | 314 | //we assume first child is finiteintrange | ||
2803 | 315 | Node intRangeElement = skipWS(node.getFirstChild()); | ||
2804 | 316 | String start = getAttribute(intRangeElement, "start").getNodeValue(); | ||
2805 | 317 | String end = getAttribute(intRangeElement, "end").getNodeValue(); | ||
2806 | 318 | return new UserOperatorExpression(findColorForIntRange(value,start,end)); | ||
2807 | 319 | |||
2808 | 320 | } else { | ||
2809 | 321 | throw new FormatException(String.format("Could not parse %s as an color expression\n", name)); | ||
2810 | 322 | } | ||
2811 | 323 | } | ||
2812 | 324 | |||
2813 | 325 | /// This will select the wrong color if the is overlap in naming, eg for IntegerRangeExpr (1,2,3,4) & (1,2) | ||
2814 | 326 | private dk.aau.cs.model.CPN.Color getColor(String colorname) throws FormatException { | ||
2815 | 327 | for (ColorType ct : colortypes.values()) { | ||
2816 | 328 | for (dk.aau.cs.model.CPN.Color c : ct) { | ||
2817 | 329 | if (c.getName().equals(colorname)) { | ||
2818 | 330 | return c; | ||
2819 | 331 | } | ||
2820 | 332 | } | ||
2821 | 333 | } | ||
2822 | 334 | throw new FormatException(String.format("The color \"%s\" was not declared\n", colorname)); | ||
2823 | 335 | } | ||
2824 | 336 | |||
2825 | 337 | public GuardExpression parseGuardExpression(Node node) throws FormatException { | ||
2826 | 338 | String name = node.getNodeName(); | ||
2827 | 339 | if (name.matches("lt|lessthan")) { | ||
2828 | 340 | Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node); | ||
2829 | 341 | return new LessThanExpression(subexps.value1(), subexps.value2()); | ||
2830 | 342 | } else if (name.matches("gt|greaterthan")) { | ||
2831 | 343 | Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node); | ||
2832 | 344 | return new GreaterThanExpression(subexps.value1(), subexps.value2()); | ||
2833 | 345 | } else if (name.matches("leq|lessthanorequal")) { | ||
2834 | 346 | Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node); | ||
2835 | 347 | return new LessThanEqExpression(subexps.value1(), subexps.value2()); | ||
2836 | 348 | } else if (name.matches("geq|greaterthanorequal")) { | ||
2837 | 349 | Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node); | ||
2838 | 350 | return new GreaterThanEqExpression(subexps.value1(), subexps.value2()); | ||
2839 | 351 | } else if (name.matches("eq|equality")) { | ||
2840 | 352 | Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node); | ||
2841 | 353 | return new EqualityExpression(subexps.value1(), subexps.value2()); | ||
2842 | 354 | } else if (name.matches("neq|inequality")) { | ||
2843 | 355 | Tuple<ColorExpression, ColorExpression> subexps = parseLRColorExpressions(node); | ||
2844 | 356 | return new InequalityExpression(subexps.value1(), subexps.value2()); | ||
2845 | 357 | } else if (name.equals("not")) { | ||
2846 | 358 | Node child = skipWS(node.getFirstChild()); | ||
2847 | 359 | GuardExpression childexp = parseGuardExpression(child); | ||
2848 | 360 | return new NotExpression(childexp); | ||
2849 | 361 | } else if (name.equals("and")) { | ||
2850 | 362 | Tuple<GuardExpression, GuardExpression> subexps = parseLRGuardExpressions(node); | ||
2851 | 363 | return new AndExpression(subexps.value1(), subexps.value2()); | ||
2852 | 364 | } else if (name.equals("or")) { | ||
2853 | 365 | Node left = skipWS(node.getFirstChild()); | ||
2854 | 366 | Node right = skipWS(left.getNextSibling()); | ||
2855 | 367 | if(right == null){ | ||
2856 | 368 | return parseGuardExpression(left); | ||
2857 | 369 | } | ||
2858 | 370 | GuardExpression parentOr = new OrExpression(parseGuardExpression(left), parseGuardExpression(right)); | ||
2859 | 371 | for (var it = skipWS(right.getNextSibling()); it != null; it = skipWS(it.getNextSibling())){ | ||
2860 | 372 | parentOr = new OrExpression(parentOr, parseGuardExpression(it)); | ||
2861 | 373 | } | ||
2862 | 374 | return parentOr; | ||
2863 | 375 | } else if (name.matches("subterm|structure")) { | ||
2864 | 376 | Node child = skipWS(node.getFirstChild()); | ||
2865 | 377 | return parseGuardExpression(child); | ||
2866 | 378 | } else { | ||
2867 | 379 | throw new FormatException(String.format("Could not parse %s as a guard expression\n", name)); | ||
2868 | 380 | } | ||
2869 | 381 | } | ||
2870 | 382 | |||
2871 | 383 | private Tuple<ColorExpression,ColorExpression> parseLRColorExpressions(Node node) throws FormatException { | ||
2872 | 384 | Node left = skipWS(node.getFirstChild()); | ||
2873 | 385 | ColorExpression leftexp = parseColorExpression(left); | ||
2874 | 386 | Node right = skipWS(left.getNextSibling()); | ||
2875 | 387 | ColorExpression rightexp = parseColorExpression(right); | ||
2876 | 388 | return new Tuple<>(leftexp, rightexp); | ||
2877 | 389 | } | ||
2878 | 390 | |||
2879 | 391 | private Tuple<GuardExpression,GuardExpression> parseLRGuardExpressions(Node node) throws FormatException { | ||
2880 | 392 | Node left = skipWS(node.getFirstChild()); | ||
2881 | 393 | GuardExpression leftexp = parseGuardExpression(left); | ||
2882 | 394 | Node right = skipWS(left.getNextSibling()); | ||
2883 | 395 | GuardExpression rightexp = parseGuardExpression(right); | ||
2884 | 396 | return new Tuple<>(leftexp, rightexp); | ||
2885 | 397 | } | ||
2886 | 398 | |||
2887 | 399 | Color findColorForIntRange(String value, String start, String end) throws FormatException { | ||
2888 | 400 | for(var ct : colortypes.values()){ | ||
2889 | 401 | if(ct.getColors().get(0).getColorName().equals(start) && ct.getColors().get(ct.getColors().size()-1).getColorName().equals(end)){ | ||
2890 | 402 | for (dk.aau.cs.model.CPN.Color c : ct) { | ||
2891 | 403 | if (c.getName().equals(value)) { | ||
2892 | 404 | return c; | ||
2893 | 405 | } | ||
2894 | 406 | } | ||
2895 | 407 | } | ||
2896 | 408 | } | ||
2897 | 409 | throw new FormatException(String.format("The color \"%s\" was not declared in an int range\n", value)); | ||
2898 | 410 | } | ||
2899 | 411 | |||
2900 | 412 | public AddExpression constructCleanAddExpression(ColorType ct, ColorMultiset multiset){ | ||
2901 | 413 | Vector<ArcExpression> coloredTokenList = new Vector<>(); | ||
2902 | 414 | |||
2903 | 415 | for(Color c : ct.getColors()){ | ||
2904 | 416 | int numberOf = multiset.get(c); | ||
2905 | 417 | if(numberOf < 1){ | ||
2906 | 418 | continue; | ||
2907 | 419 | } | ||
2908 | 420 | Vector<ColorExpression> v = new Vector<>(); | ||
2909 | 421 | if(ct.isProductColorType()){ | ||
2910 | 422 | Vector<ColorExpression> tupleColors = new Vector<>(); | ||
2911 | 423 | for(Color tupleCol : c.getTuple()){ | ||
2912 | 424 | UserOperatorExpression color = new UserOperatorExpression(tupleCol); | ||
2913 | 425 | tupleColors.add(color); | ||
2914 | 426 | } | ||
2915 | 427 | TupleExpression tupleExpr = new TupleExpression(tupleColors); | ||
2916 | 428 | v.add(tupleExpr); | ||
2917 | 429 | } else { | ||
2918 | 430 | UserOperatorExpression color = new UserOperatorExpression(c); | ||
2919 | 431 | v.add(color); | ||
2920 | 432 | } | ||
2921 | 433 | NumberOfExpression numOf = new NumberOfExpression(numberOf,v); | ||
2922 | 434 | coloredTokenList.add(numOf); | ||
2923 | 435 | |||
2924 | 436 | } | ||
2925 | 437 | return new AddExpression(coloredTokenList); | ||
2926 | 438 | } | ||
2927 | 439 | } | ||
2928 | 0 | 440 | ||
2929 | === modified file 'src/main/java/dk/aau/cs/io/LoadedModel.java' | |||
2930 | --- src/dk/aau/cs/io/LoadedModel.java 2020-08-26 12:29:25 +0000 | |||
2931 | +++ src/main/java/dk/aau/cs/io/LoadedModel.java 2022-07-21 13:30:11 +0000 | |||
2932 | @@ -1,12 +1,11 @@ | |||
2933 | 1 | package dk.aau.cs.io; | 1 | package dk.aau.cs.io; |
2934 | 2 | 2 | ||
2935 | 3 | import java.util.Collection; | 3 | import java.util.Collection; |
2936 | 4 | import java.util.List; | ||
2937 | 5 | 4 | ||
2939 | 6 | import dk.aau.cs.gui.TabContent; | 5 | import net.tapaal.gui.petrinet.TAPNLens; |
2940 | 7 | import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel; | 6 | import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel; |
2943 | 8 | import pipe.dataLayer.TAPNQuery; | 7 | import net.tapaal.gui.petrinet.verification.TAPNQuery; |
2944 | 9 | import pipe.dataLayer.Template; | 8 | import net.tapaal.gui.petrinet.Template; |
2945 | 10 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; | 9 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; |
2946 | 11 | 10 | ||
2947 | 12 | public class LoadedModel implements LoadedBatchProcessingModel { | 11 | public class LoadedModel implements LoadedBatchProcessingModel { |
2948 | @@ -15,9 +14,9 @@ | |||
2949 | 15 | private final Collection<TAPNQuery> queries; | 14 | private final Collection<TAPNQuery> queries; |
2950 | 16 | private final TimedArcPetriNetNetwork network; | 15 | private final TimedArcPetriNetNetwork network; |
2951 | 17 | private final Collection<String> messages; | 16 | private final Collection<String> messages; |
2953 | 18 | private final TabContent.TAPNLens lens; | 17 | private final TAPNLens lens; |
2954 | 19 | 18 | ||
2956 | 20 | public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages, TabContent.TAPNLens lens){ | 19 | public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages, TAPNLens lens){ |
2957 | 21 | this.templates = templates; | 20 | this.templates = templates; |
2958 | 22 | this.network = network; | 21 | this.network = network; |
2959 | 23 | this.queries = queries; | 22 | this.queries = queries; |
2960 | @@ -30,15 +29,18 @@ | |||
2961 | 30 | public TimedArcPetriNetNetwork network(){ return network; } | 29 | public TimedArcPetriNetNetwork network(){ return network; } |
2962 | 31 | public Collection<String> getMessages() { return messages; } | 30 | public Collection<String> getMessages() { return messages; } |
2963 | 32 | 31 | ||
2965 | 33 | public TabContent.TAPNLens getLens(){ | 32 | public TAPNLens getLens(){ |
2966 | 34 | if (lens != null) { | 33 | if (lens != null) { |
2967 | 35 | return lens; | 34 | return lens; |
2968 | 36 | } else { | 35 | } else { |
2969 | 37 | boolean isNetTimed = !network().isUntimed(); | 36 | boolean isNetTimed = !network().isUntimed(); |
2970 | 38 | boolean isNetGame = network().hasUncontrollableTransitions(); | 37 | boolean isNetGame = network().hasUncontrollableTransitions(); |
2971 | 38 | boolean isNetColored = network.isColored(); | ||
2972 | 39 | 39 | ||
2974 | 40 | return new TabContent.TAPNLens(isNetTimed, isNetGame); | 40 | return new TAPNLens(isNetTimed, isNetGame, isNetColored); |
2975 | 41 | } | 41 | } |
2976 | 42 | } | 42 | } |
2978 | 43 | 43 | public boolean isColored(){ | |
2979 | 44 | return lens.isColored(); | ||
2980 | 45 | } | ||
2981 | 44 | } | 46 | } |
2982 | 45 | \ No newline at end of file | 47 | \ No newline at end of file |
2983 | 46 | 48 | ||
2984 | === modified file 'src/main/java/dk/aau/cs/io/LoadedQueries.java' | |||
2985 | --- src/dk/aau/cs/io/LoadedQueries.java 2020-10-09 07:59:49 +0000 | |||
2986 | +++ src/main/java/dk/aau/cs/io/LoadedQueries.java 2022-07-21 13:30:11 +0000 | |||
2987 | @@ -1,6 +1,5 @@ | |||
2988 | 1 | package dk.aau.cs.io; | 1 | package dk.aau.cs.io; |
2991 | 2 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; | 2 | import net.tapaal.gui.petrinet.verification.TAPNQuery; |
2990 | 3 | import pipe.dataLayer.TAPNQuery; | ||
2992 | 4 | import java.util.Collection; | 3 | import java.util.Collection; |
2993 | 5 | 4 | ||
2994 | 6 | public class LoadedQueries { | 5 | public class LoadedQueries { |
2995 | 7 | 6 | ||
2996 | === modified file 'src/main/java/dk/aau/cs/io/ModelLoader.java' | |||
2997 | --- src/dk/aau/cs/io/ModelLoader.java 2021-08-10 11:37:11 +0000 | |||
2998 | +++ src/main/java/dk/aau/cs/io/ModelLoader.java 2022-07-21 13:30:11 +0000 | |||
2999 | @@ -7,7 +7,7 @@ | |||
3000 | 7 | import java.io.InputStream; | 7 | import java.io.InputStream; |
3001 | 8 | 8 | ||
3002 | 9 | import dk.aau.cs.TCTL.Parsing.ParseException; | 9 | import dk.aau.cs.TCTL.Parsing.ParseException; |
3004 | 10 | import dk.aau.cs.gui.TabContent; | 10 | import net.tapaal.gui.petrinet.TAPNLens; |
3005 | 11 | 11 | ||
3006 | 12 | public class ModelLoader { | 12 | public class ModelLoader { |
3007 | 13 | 13 | ||
3008 | @@ -52,12 +52,12 @@ | |||
3009 | 52 | return oldFormatLoader.load(new ByteArrayInputStream(baos.toByteArray())); | 52 | return oldFormatLoader.load(new ByteArrayInputStream(baos.toByteArray())); |
3010 | 53 | 53 | ||
3011 | 54 | } catch(Throwable e2) { | 54 | } catch(Throwable e2) { |
3013 | 55 | throw new ParseException(e1.getMessage()); | 55 | throw new Exception(e1.getMessage(), e1); |
3014 | 56 | } | 56 | } |
3015 | 57 | } | 57 | } |
3016 | 58 | } | 58 | } |
3017 | 59 | 59 | ||
3019 | 60 | public TabContent.TAPNLens loadLens(InputStream file) throws Exception{ | 60 | public TAPNLens loadLens(InputStream file) throws Exception{ |
3020 | 61 | TapnXmlLoader newFormatLoader = new TapnXmlLoader(); | 61 | TapnXmlLoader newFormatLoader = new TapnXmlLoader(); |
3021 | 62 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 62 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
3022 | 63 | byte[] buffer = new byte[1024]; | 63 | byte[] buffer = new byte[1024]; |
3023 | 64 | 64 | ||
3024 | === renamed file 'src/pipe/dataLayer/NetWriter.java' => 'src/main/java/dk/aau/cs/io/NetWriter.java' | |||
3025 | --- src/pipe/dataLayer/NetWriter.java 2014-05-22 21:26:05 +0000 | |||
3026 | +++ src/main/java/dk/aau/cs/io/NetWriter.java 2022-07-21 13:30:11 +0000 | |||
3027 | @@ -1,4 +1,4 @@ | |||
3029 | 1 | package pipe.dataLayer; | 1 | package dk.aau.cs.io; |
3030 | 2 | 2 | ||
3031 | 3 | import java.io.ByteArrayOutputStream; | 3 | import java.io.ByteArrayOutputStream; |
3032 | 4 | import java.io.File; | 4 | import java.io.File; |
3033 | @@ -12,7 +12,7 @@ | |||
3034 | 12 | public interface NetWriter { | 12 | public interface NetWriter { |
3035 | 13 | void savePNML(File file) throws NullPointerException, IOException, | 13 | void savePNML(File file) throws NullPointerException, IOException, |
3036 | 14 | ParserConfigurationException, DOMException, | 14 | ParserConfigurationException, DOMException, |
3038 | 15 | TransformerConfigurationException, TransformerException; | 15 | TransformerException; |
3039 | 16 | 16 | ||
3041 | 17 | ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException; | 17 | ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerException; |
3042 | 18 | } | 18 | } |
3043 | 19 | 19 | ||
3044 | === modified file 'src/main/java/dk/aau/cs/io/PNMLWriter.java' | |||
3045 | --- src/dk/aau/cs/io/PNMLWriter.java 2020-07-13 13:58:47 +0000 | |||
3046 | +++ src/main/java/dk/aau/cs/io/PNMLWriter.java 2022-07-21 13:30:11 +0000 | |||
3047 | @@ -17,20 +17,20 @@ | |||
3048 | 17 | import javax.xml.transform.dom.DOMSource; | 17 | import javax.xml.transform.dom.DOMSource; |
3049 | 18 | import javax.xml.transform.stream.StreamResult; | 18 | import javax.xml.transform.stream.StreamResult; |
3050 | 19 | 19 | ||
3051 | 20 | import net.tapaal.gui.petrinet.TAPNLens; | ||
3052 | 20 | import org.w3c.dom.DOMException; | 21 | import org.w3c.dom.DOMException; |
3053 | 21 | import org.w3c.dom.Document; | 22 | import org.w3c.dom.Document; |
3054 | 22 | import org.w3c.dom.Element; | 23 | import org.w3c.dom.Element; |
3055 | 23 | 24 | ||
3058 | 24 | import pipe.dataLayer.DataLayer; | 25 | import pipe.gui.petrinet.dataLayer.DataLayer; |
3057 | 25 | import pipe.dataLayer.NetWriter; | ||
3059 | 26 | import pipe.gui.MessengerImpl; | 26 | import pipe.gui.MessengerImpl; |
3067 | 27 | import pipe.gui.graphicElements.Arc; | 27 | import pipe.gui.petrinet.graphicElements.Arc; |
3068 | 28 | import pipe.gui.graphicElements.Place; | 28 | import pipe.gui.petrinet.graphicElements.Place; |
3069 | 29 | import pipe.gui.graphicElements.Transition; | 29 | import pipe.gui.petrinet.graphicElements.Transition; |
3070 | 30 | import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent; | 30 | import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent; |
3071 | 31 | import pipe.gui.graphicElements.tapn.TimedOutputArcComponent; | 31 | import pipe.gui.petrinet.graphicElements.tapn.TimedOutputArcComponent; |
3072 | 32 | import pipe.gui.graphicElements.tapn.TimedPlaceComponent; | 32 | import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent; |
3073 | 33 | import pipe.gui.graphicElements.tapn.TimedTransitionComponent; | 33 | import pipe.gui.petrinet.graphicElements.tapn.TimedTransitionComponent; |
3074 | 34 | import dk.aau.cs.model.tapn.TimedArcPetriNet; | 34 | import dk.aau.cs.model.tapn.TimedArcPetriNet; |
3075 | 35 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; | 35 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; |
3076 | 36 | import dk.aau.cs.util.Require; | 36 | import dk.aau.cs.util.Require; |
3077 | @@ -41,19 +41,21 @@ | |||
3078 | 41 | private final TimedArcPetriNetNetwork network; | 41 | private final TimedArcPetriNetNetwork network; |
3079 | 42 | private TimedArcPetriNet composedNetwork; | 42 | private TimedArcPetriNet composedNetwork; |
3080 | 43 | private final HashMap<TimedArcPetriNet, DataLayer> guiModels; | 43 | private final HashMap<TimedArcPetriNet, DataLayer> guiModels; |
3081 | 44 | private final TAPNLens lens; | ||
3082 | 45 | private final writeTACPN writeTACPN; | ||
3083 | 44 | 46 | ||
3087 | 45 | public PNMLWriter( | 47 | public PNMLWriter(TimedArcPetriNetNetwork network, HashMap<TimedArcPetriNet, DataLayer> guiModels, TAPNLens lens) { |
3085 | 46 | TimedArcPetriNetNetwork network, | ||
3086 | 47 | HashMap<TimedArcPetriNet, DataLayer> guiModels) { | ||
3088 | 48 | this.network = network; | 48 | this.network = network; |
3089 | 49 | this.guiModels = guiModels; | 49 | this.guiModels = guiModels; |
3090 | 50 | this.lens = lens; | ||
3091 | 51 | writeTACPN = new writeTACPN(network); | ||
3092 | 50 | } | 52 | } |
3093 | 51 | 53 | ||
3095 | 52 | public ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException { | 54 | public ByteArrayOutputStream savePNML() throws ParserConfigurationException, DOMException, TransformerException { |
3096 | 53 | Document document = null; | 55 | Document document = null; |
3097 | 54 | Transformer transformer = null; | 56 | Transformer transformer = null; |
3098 | 55 | ByteArrayOutputStream os = new ByteArrayOutputStream(); | 57 | ByteArrayOutputStream os = new ByteArrayOutputStream(); |
3100 | 56 | TAPNComposer composer = new TAPNComposer(new MessengerImpl(), guiModels, true, true); | 58 | TAPNComposer composer = new TAPNComposer(new MessengerImpl(), guiModels, lens, true, true); |
3101 | 57 | composedNetwork = composer.transformModel(network).value1(); | 59 | composedNetwork = composer.transformModel(network).value1(); |
3102 | 58 | 60 | ||
3103 | 59 | // Build a Petri Net XML Document | 61 | // Build a Petri Net XML Document |
3104 | @@ -69,17 +71,21 @@ | |||
3105 | 69 | pnmlRootNode.appendChild(netNode); | 71 | pnmlRootNode.appendChild(netNode); |
3106 | 70 | netNode.setAttribute("id", composedNetwork.name()); | 72 | netNode.setAttribute("id", composedNetwork.name()); |
3107 | 71 | netNode.setAttribute("type", "http://www.pnml.org/version-2009/grammar/ptnet"); | 73 | netNode.setAttribute("type", "http://www.pnml.org/version-2009/grammar/ptnet"); |
3109 | 72 | 74 | ||
3110 | 75 | Element nameNode = document.createElement("name"); //Name of the net | ||
3111 | 76 | netNode.appendChild(nameNode); | ||
3112 | 77 | Element nameText = document.createElement("text"); | ||
3113 | 78 | nameNode.appendChild(nameText); | ||
3114 | 79 | nameText.setTextContent(composedNetwork.name()); | ||
3115 | 80 | |||
3116 | 81 | if(lens.isColored()) { | ||
3117 | 82 | writeTACPN.appendDeclarations(document, netNode); | ||
3118 | 83 | } | ||
3119 | 84 | |||
3120 | 73 | Element pageNode = document.createElement("page"); //Page node | 85 | Element pageNode = document.createElement("page"); //Page node |
3121 | 74 | netNode.appendChild(pageNode); | 86 | netNode.appendChild(pageNode); |
3122 | 75 | pageNode.setAttribute("id", "page0"); | 87 | pageNode.setAttribute("id", "page0"); |
3130 | 76 | 88 | ||
3124 | 77 | Element nameNode = document.createElement("name"); //Name of the net | ||
3125 | 78 | netNode.appendChild(nameNode); | ||
3126 | 79 | Element nameText = document.createElement("text"); | ||
3127 | 80 | nameNode.appendChild(nameText); | ||
3128 | 81 | nameText.setTextContent(composedNetwork.name()); | ||
3129 | 82 | |||
3131 | 83 | appendPlaces(document, composer.getGuiModel(), pageNode); | 89 | appendPlaces(document, composer.getGuiModel(), pageNode); |
3132 | 84 | appendTransitions(document, composer.getGuiModel(), pageNode); | 90 | appendTransitions(document, composer.getGuiModel(), pageNode); |
3133 | 85 | appendArcs(document, composer.getGuiModel(), pageNode); | 91 | appendArcs(document, composer.getGuiModel(), pageNode); |
3134 | @@ -96,7 +102,7 @@ | |||
3135 | 96 | return os; | 102 | return os; |
3136 | 97 | } | 103 | } |
3137 | 98 | 104 | ||
3139 | 99 | public void savePNML(File file) throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException { | 105 | public void savePNML(File file) throws IOException, ParserConfigurationException, DOMException, TransformerException { |
3140 | 100 | Require.that(file != null, "Error: file to save to was null"); | 106 | Require.that(file != null, "Error: file to save to was null"); |
3141 | 101 | 107 | ||
3142 | 102 | try { | 108 | try { |
3143 | @@ -130,21 +136,36 @@ | |||
3144 | 130 | private void appendPlaces(Document document, DataLayer guiModel, Element NET) { | 136 | private void appendPlaces(Document document, DataLayer guiModel, Element NET) { |
3145 | 131 | Place[] places = guiModel.getPlaces(); | 137 | Place[] places = guiModel.getPlaces(); |
3146 | 132 | for (Place place : places) { | 138 | for (Place place : places) { |
3148 | 133 | NET.appendChild(createPlaceElement((TimedPlaceComponent) place, guiModel, document)); | 139 | if (lens.isColored()){ |
3149 | 140 | NET.appendChild(createColorPlaceElement((TimedPlaceComponent) place, guiModel, document)); | ||
3150 | 141 | } | ||
3151 | 142 | else { | ||
3152 | 143 | NET.appendChild(createPlaceElement((TimedPlaceComponent) place, guiModel, document)); | ||
3153 | 144 | } | ||
3154 | 134 | } | 145 | } |
3155 | 135 | } | 146 | } |
3156 | 136 | 147 | ||
3157 | 137 | private void appendTransitions(Document document, DataLayer guiModel, Element NET) { | 148 | private void appendTransitions(Document document, DataLayer guiModel, Element NET) { |
3158 | 138 | Transition[] transitions = guiModel.getTransitions(); | 149 | Transition[] transitions = guiModel.getTransitions(); |
3159 | 139 | for (Transition transition : transitions) { | 150 | for (Transition transition : transitions) { |
3161 | 140 | NET.appendChild(createTransitionElement((TimedTransitionComponent) transition, document)); | 151 | if(lens.isColored()) { |
3162 | 152 | NET.appendChild(createColoredTransitionElement((TimedTransitionComponent) transition, document)); | ||
3163 | 153 | } | ||
3164 | 154 | else { | ||
3165 | 155 | NET.appendChild(createTransitionElement((TimedTransitionComponent) transition, document)); | ||
3166 | 156 | } | ||
3167 | 141 | } | 157 | } |
3168 | 142 | } | 158 | } |
3169 | 143 | 159 | ||
3170 | 144 | private void appendArcs(Document document, DataLayer guiModel, Element NET) { | 160 | private void appendArcs(Document document, DataLayer guiModel, Element NET) { |
3171 | 145 | Arc[] arcs = guiModel.getArcs(); | 161 | Arc[] arcs = guiModel.getArcs(); |
3172 | 146 | for (Arc arc : arcs) { | 162 | for (Arc arc : arcs) { |
3174 | 147 | NET.appendChild(createArcElement(arc, guiModel, document)); | 163 | if(lens.isColored()) { |
3175 | 164 | NET.appendChild(createColoredArcElement(arc,guiModel , document)); | ||
3176 | 165 | } | ||
3177 | 166 | else { | ||
3178 | 167 | NET.appendChild(createArcElement(arc, guiModel, document)); | ||
3179 | 168 | } | ||
3180 | 148 | } | 169 | } |
3181 | 149 | } | 170 | } |
3182 | 150 | 171 | ||
3183 | @@ -188,6 +209,38 @@ | |||
3184 | 188 | return placeElement; | 209 | return placeElement; |
3185 | 189 | } | 210 | } |
3186 | 190 | 211 | ||
3187 | 212 | private Element createColorPlaceElement(TimedPlaceComponent inputPlace, DataLayer guiModel, Document document) { | ||
3188 | 213 | Require.that(inputPlace != null, "Error: inputPlace was null"); | ||
3189 | 214 | Require.that(guiModel != null, "Error: guiModel was null"); | ||
3190 | 215 | Require.that(document != null, "Error: document was null"); | ||
3191 | 216 | |||
3192 | 217 | Element placeElement = document.createElement("place"); | ||
3193 | 218 | placeElement.setAttribute("id", (inputPlace.getId() != null ? inputPlace.getId() : inputPlace.getName())); | ||
3194 | 219 | |||
3195 | 220 | |||
3196 | 221 | Element name = document.createElement("name"); //Name | ||
3197 | 222 | placeElement.appendChild(name); | ||
3198 | 223 | Element nameText = document.createElement("text"); | ||
3199 | 224 | name.appendChild(nameText); | ||
3200 | 225 | nameText.setTextContent(inputPlace.underlyingPlace().name()); | ||
3201 | 226 | Element nameGraphics = document.createElement("graphics"); | ||
3202 | 227 | name.appendChild(nameGraphics); | ||
3203 | 228 | Element nameOffset = document.createElement("offset"); | ||
3204 | 229 | nameGraphics.appendChild(nameOffset); | ||
3205 | 230 | nameOffset.setAttribute("x", String.valueOf(Math.round(inputPlace.getNameOffsetX()))); | ||
3206 | 231 | nameOffset.setAttribute("y", String.valueOf(Math.round(inputPlace.getNameOffsetY()))); | ||
3207 | 232 | |||
3208 | 233 | Element graphics = document.createElement("graphics"); | ||
3209 | 234 | placeElement.appendChild(graphics); | ||
3210 | 235 | Element offset = document.createElement("position"); | ||
3211 | 236 | graphics.appendChild(offset); | ||
3212 | 237 | offset.setAttribute("x", String.valueOf(Math.round(inputPlace.getPositionX()))); | ||
3213 | 238 | offset.setAttribute("y", String.valueOf(Math.round(inputPlace.getPositionY()))); | ||
3214 | 239 | |||
3215 | 240 | writeTACPN.appendColoredPlaceDependencies(inputPlace.underlyingPlace(), document, placeElement); | ||
3216 | 241 | return placeElement; | ||
3217 | 242 | } | ||
3218 | 243 | |||
3219 | 191 | private Element createTransitionElement(TimedTransitionComponent inputTransition, Document document) { | 244 | private Element createTransitionElement(TimedTransitionComponent inputTransition, Document document) { |
3220 | 192 | Require.that(inputTransition != null, "Error: inputTransition was null"); | 245 | Require.that(inputTransition != null, "Error: inputTransition was null"); |
3221 | 193 | Require.that(document != null, "Error: document was null"); | 246 | Require.that(document != null, "Error: document was null"); |
3222 | @@ -217,6 +270,36 @@ | |||
3223 | 217 | return transitionElement; | 270 | return transitionElement; |
3224 | 218 | } | 271 | } |
3225 | 219 | 272 | ||
3226 | 273 | private Element createColoredTransitionElement (TimedTransitionComponent inputTransition, Document document) { | ||
3227 | 274 | Require.that(inputTransition != null, "Error: inputTransition was null"); | ||
3228 | 275 | Require.that(document != null, "Error: document was null"); | ||
3229 | 276 | |||
3230 | 277 | Element transitionElement = document.createElement("transition"); | ||
3231 | 278 | transitionElement.setAttribute("id", (inputTransition.getId() != null ? inputTransition.getId() : "error")); | ||
3232 | 279 | |||
3233 | 280 | Element name = document.createElement("name"); //Name | ||
3234 | 281 | transitionElement.appendChild(name); | ||
3235 | 282 | Element nameGraphics = document.createElement("graphics"); | ||
3236 | 283 | name.appendChild(nameGraphics); | ||
3237 | 284 | Element nameOffset = document.createElement("offset"); | ||
3238 | 285 | nameGraphics.appendChild(nameOffset); | ||
3239 | 286 | nameOffset.setAttribute("x", String.valueOf(Math.round(inputTransition.getNameOffsetX()))); | ||
3240 | 287 | nameOffset.setAttribute("y", String.valueOf(Math.round(inputTransition.getNameOffsetY()))); | ||
3241 | 288 | Element nameText = document.createElement("text"); | ||
3242 | 289 | name.appendChild(nameText); | ||
3243 | 290 | nameText.setTextContent(inputTransition.underlyingTransition().name()); | ||
3244 | 291 | |||
3245 | 292 | Element graphics = document.createElement("graphics"); | ||
3246 | 293 | transitionElement.appendChild(graphics); | ||
3247 | 294 | Element offset = document.createElement("position"); | ||
3248 | 295 | graphics.appendChild(offset); | ||
3249 | 296 | offset.setAttribute("x", String.valueOf(Math.round(inputTransition.getPositionX()))); | ||
3250 | 297 | offset.setAttribute("y", String.valueOf(Math.round(inputTransition.getPositionY()))); | ||
3251 | 298 | |||
3252 | 299 | writeTACPN.appendColoredTransitionDependencies(inputTransition.underlyingTransition(), document, transitionElement); | ||
3253 | 300 | return transitionElement; | ||
3254 | 301 | } | ||
3255 | 302 | |||
3256 | 220 | private Element createArcElement(Arc arc, DataLayer guiModel, Document document) { | 303 | private Element createArcElement(Arc arc, DataLayer guiModel, Document document) { |
3257 | 221 | Require.that(arc != null, "Error: inputArc was null"); | 304 | Require.that(arc != null, "Error: inputArc was null"); |
3258 | 222 | Require.that(guiModel != null, "Error: guiModel was null"); | 305 | Require.that(guiModel != null, "Error: guiModel was null"); |
3259 | @@ -258,6 +341,47 @@ | |||
3260 | 258 | 341 | ||
3261 | 259 | return arcElement; | 342 | return arcElement; |
3262 | 260 | } | 343 | } |
3263 | 344 | |||
3264 | 345 | private Element createColoredArcElement(Arc arc, DataLayer guiModel, Document document) { | ||
3265 | 346 | Require.that(arc != null, "Error: inputArc was null"); | ||
3266 | 347 | Require.that(guiModel != null, "Error: guiModel was null"); | ||
3267 | 348 | Require.that(document != null, "Error: document was null"); | ||
3268 | 349 | |||
3269 | 350 | Element arcElement = document.createElement("arc"); | ||
3270 | 351 | arcElement.setAttribute("id", (arc.getId() != null ? arc.getId() : "error")); | ||
3271 | 352 | arcElement.setAttribute("source", (arc.getSource().getId() != null ? arc.getSource().getId() : "")); | ||
3272 | 353 | arcElement.setAttribute("target", (arc.getTarget().getId() != null ? arc.getTarget().getId() : "")); | ||
3273 | 354 | |||
3274 | 355 | writeTACPN.appendColoredArcsDependencies(arc, guiModel, document, arcElement); | ||
3275 | 356 | |||
3276 | 357 | if (arc instanceof TimedOutputArcComponent && arc.getWeight().value() > 1 ) { | ||
3277 | 358 | Element inscription = document.createElement("inscription"); | ||
3278 | 359 | arcElement.appendChild(inscription); | ||
3279 | 360 | Element text = document.createElement("text"); | ||
3280 | 361 | inscription.appendChild(text); | ||
3281 | 362 | text.setTextContent(arc.getWeight().nameForSaving(false)+""); | ||
3282 | 363 | } | ||
3283 | 364 | |||
3284 | 365 | if(arc instanceof TimedInhibitorArcComponent){ | ||
3285 | 366 | arcElement.setAttribute("type", "inhibitor"); | ||
3286 | 367 | } else { | ||
3287 | 368 | arcElement.setAttribute("type", "normal"); | ||
3288 | 369 | } | ||
3289 | 370 | |||
3290 | 371 | //ArcPath | ||
3291 | 372 | int arcPoints = arc.getArcPath().getArcPathDetails().length; | ||
3292 | 373 | if (arcPoints > 2) { | ||
3293 | 374 | Element graphics = document.createElement("graphics"); | ||
3294 | 375 | arcElement.appendChild(graphics); | ||
3295 | 376 | |||
3296 | 377 | String[][] point = arc.getArcPath().getArcPathDetails(); | ||
3297 | 378 | for (int j = 1; j < arcPoints-1; j++) { // Do not write the first and last point | ||
3298 | 379 | graphics.appendChild(createArcPoint(point[j][0], | ||
3299 | 380 | point[j][1], point[j][2], document, j)); | ||
3300 | 381 | } | ||
3301 | 382 | } | ||
3302 | 383 | return arcElement; | ||
3303 | 384 | } | ||
3304 | 261 | 385 | ||
3305 | 262 | private Element createArcPoint(String x, String y, String type, Document document, int id) { | 386 | private Element createArcPoint(String x, String y, String type, Document document, int id) { |
3306 | 263 | Require.that(document != null, "Error: document was null"); | 387 | Require.that(document != null, "Error: document was null"); |
3307 | 264 | 388 | ||
3308 | === modified file 'src/main/java/dk/aau/cs/io/PNMLoader.java' | |||
3309 | --- src/dk/aau/cs/io/PNMLoader.java 2020-08-26 12:29:25 +0000 | |||
3310 | +++ src/main/java/dk/aau/cs/io/PNMLoader.java 2022-07-21 13:30:11 +0000 | |||
3311 | @@ -6,28 +6,25 @@ | |||
3312 | 6 | import java.io.FileNotFoundException; | 6 | import java.io.FileNotFoundException; |
3313 | 7 | import java.io.IOException; | 7 | import java.io.IOException; |
3314 | 8 | import java.io.InputStream; | 8 | import java.io.InputStream; |
3319 | 9 | import java.util.ArrayList; | 9 | import java.util.*; |
3316 | 10 | import java.util.Arrays; | ||
3317 | 11 | import java.util.HashMap; | ||
3318 | 12 | import java.util.HashSet; | ||
3320 | 13 | 10 | ||
3321 | 14 | import javax.xml.parsers.DocumentBuilder; | 11 | import javax.xml.parsers.DocumentBuilder; |
3322 | 15 | import javax.xml.parsers.DocumentBuilderFactory; | 12 | import javax.xml.parsers.DocumentBuilderFactory; |
3323 | 16 | import javax.xml.parsers.ParserConfigurationException; | 13 | import javax.xml.parsers.ParserConfigurationException; |
3324 | 17 | 14 | ||
3326 | 18 | import dk.aau.cs.gui.TabContent; | 15 | import net.tapaal.gui.petrinet.TAPNLens; |
3327 | 16 | import dk.aau.cs.model.CPN.*; | ||
3328 | 17 | import dk.aau.cs.model.CPN.Expressions.*; | ||
3329 | 19 | import org.w3c.dom.Document; | 18 | import org.w3c.dom.Document; |
3330 | 20 | import org.w3c.dom.Element; | 19 | import org.w3c.dom.Element; |
3331 | 21 | import org.w3c.dom.Node; | 20 | import org.w3c.dom.Node; |
3332 | 22 | import org.w3c.dom.NodeList; | 21 | import org.w3c.dom.NodeList; |
3333 | 23 | import org.xml.sax.SAXException; | 22 | import org.xml.sax.SAXException; |
3334 | 24 | 23 | ||
3337 | 25 | import dk.aau.cs.gui.NameGenerator; | 24 | import net.tapaal.gui.petrinet.NameGenerator; |
3336 | 26 | import dk.aau.cs.model.tapn.Bound; | ||
3338 | 27 | import dk.aau.cs.model.tapn.IntWeight; | 25 | import dk.aau.cs.model.tapn.IntWeight; |
3339 | 28 | import dk.aau.cs.model.tapn.LocalTimedPlace; | 26 | import dk.aau.cs.model.tapn.LocalTimedPlace; |
3340 | 29 | import dk.aau.cs.model.tapn.TimeInterval; | 27 | import dk.aau.cs.model.tapn.TimeInterval; |
3341 | 30 | import dk.aau.cs.model.tapn.TimeInvariant; | ||
3342 | 31 | import dk.aau.cs.model.tapn.TimedArcPetriNet; | 28 | import dk.aau.cs.model.tapn.TimedArcPetriNet; |
3343 | 32 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; | 29 | import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; |
3344 | 33 | import dk.aau.cs.model.tapn.TimedInhibitorArc; | 30 | import dk.aau.cs.model.tapn.TimedInhibitorArc; |
3345 | @@ -38,463 +35,534 @@ | |||
3346 | 38 | import dk.aau.cs.model.tapn.TimedTransition; | 35 | import dk.aau.cs.model.tapn.TimedTransition; |
3347 | 39 | import dk.aau.cs.util.FormatException; | 36 | import dk.aau.cs.util.FormatException; |
3348 | 40 | import dk.aau.cs.util.Require; | 37 | import dk.aau.cs.util.Require; |
3361 | 41 | import pipe.dataLayer.DataLayer; | 38 | import pipe.gui.petrinet.dataLayer.DataLayer; |
3362 | 42 | import pipe.dataLayer.TAPNQuery; | 39 | import net.tapaal.gui.petrinet.verification.TAPNQuery; |
3363 | 43 | import pipe.dataLayer.Template; | 40 | import net.tapaal.gui.petrinet.Template; |
3364 | 44 | import pipe.gui.Pipe; | 41 | import pipe.gui.Constants; |
3365 | 45 | import pipe.gui.Zoomer; | 42 | import pipe.gui.canvas.Zoomer; |
3366 | 46 | import pipe.gui.graphicElements.Arc; | 43 | import pipe.gui.petrinet.graphicElements.Arc; |
3367 | 47 | import pipe.gui.graphicElements.PlaceTransitionObject; | 44 | import pipe.gui.petrinet.graphicElements.PlaceTransitionObject; |
3368 | 48 | import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent; | 45 | import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent; |
3369 | 49 | import pipe.gui.graphicElements.tapn.TimedInputArcComponent; | 46 | import pipe.gui.petrinet.graphicElements.tapn.TimedInputArcComponent; |
3370 | 50 | import pipe.gui.graphicElements.tapn.TimedOutputArcComponent; | 47 | import pipe.gui.petrinet.graphicElements.tapn.TimedOutputArcComponent; |
3371 | 51 | import pipe.gui.graphicElements.tapn.TimedPlaceComponent; | 48 | import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent; |
3372 | 52 | import pipe.gui.graphicElements.tapn.TimedTransitionComponent; | 49 | import pipe.gui.petrinet.graphicElements.tapn.TimedTransitionComponent; |
3373 | 53 | 50 | ||
3374 | 54 | public class PNMLoader { | 51 | public class PNMLoader { |
3377 | 55 | 52 | private TAPNLens lens; | |
3376 | 56 | private final TabContent.TAPNLens lens = TabContent.TAPNLens.Default; | ||
3378 | 57 | 53 | ||
3379 | 58 | enum GraphicsType { Position, Offset } | 54 | enum GraphicsType { Position, Offset } |
3380 | 59 | 55 | ||
3601 | 60 | private final NameGenerator nameGenerator = new NameGenerator(); | 56 | private final NameGenerator nameGenerator = new NameGenerator(); |
3602 | 61 | private final IdResolver idResolver = new IdResolver(); | 57 | private final IdResolver idResolver = new IdResolver(); |
3603 | 62 | private final HashSet<String> arcs = new HashSet<String>(); | 58 | private final HashSet<String> arcs = new HashSet<String>(); |
3604 | 63 | private final HashMap<String, TimedPlace> places = new HashMap<String, TimedPlace>(); | 59 | private final HashMap<String, TimedPlace> places = new HashMap<String, TimedPlace>(); |
3605 | 64 | private final HashMap<String, TimedTransition> transitions = new HashMap<String, TimedTransition>(); | 60 | private final HashMap<String, TimedTransition> transitions = new HashMap<String, TimedTransition>(); |
3606 | 65 | 61 | private final HashMap<String, ColorType> colortypes = new HashMap<String, ColorType>(); | |
3607 | 66 | //If the net is too big, do not make the graphics | 62 | private final HashMap<String, Variable> variables = new HashMap<String, Variable>(); |
3608 | 67 | private int netSize = 0; | 63 | |
3609 | 68 | private final int maxNetSize = 4000; | 64 | //If the net is too big, do not make the graphics |
3610 | 69 | private boolean hasPositionalInfo = false; | 65 | private int netSize = 0; |
3611 | 70 | 66 | private final int maxNetSize = 4000; | |
3612 | 71 | public PNMLoader() { | 67 | private boolean hasPositionalInfo = false; |
3613 | 72 | } | 68 | private final LoadTACPN loadTACPN; |
3614 | 73 | 69 | ||
3615 | 74 | public LoadedModel load(File file) throws FormatException{ | 70 | public PNMLoader() { |
3616 | 75 | try{ | 71 | this.lens = TAPNLens.Default; |
3617 | 76 | return load(new FileInputStream(file)); | 72 | loadTACPN = new LoadTACPN(); |
3618 | 77 | } catch (FileNotFoundException e){ | 73 | } |
3619 | 78 | return null; | 74 | |
3620 | 79 | } catch (NullPointerException e){ | 75 | public LoadedModel load(File file) throws FormatException{ |
3621 | 80 | throw new FormatException("the PNML file cannot be parsed due to syntax errors"); | 76 | try{ |
3622 | 81 | } | 77 | return load(new FileInputStream(file)); |
3623 | 82 | } | 78 | } catch (FileNotFoundException e){ |
3624 | 83 | 79 | return null; | |
3625 | 84 | public LoadedModel load(InputStream file) throws FormatException{ | 80 | } catch (NullPointerException e){ |
3626 | 85 | Document doc = loadDocument(file); | 81 | throw new FormatException("the PNML file cannot be parsed due to syntax errors", e); |
3627 | 86 | 82 | } | |
3628 | 87 | return parse(doc); | 83 | } |
3629 | 88 | } | 84 | |
3630 | 89 | 85 | public LoadedModel load(InputStream file) throws FormatException{ | |
3631 | 90 | private Document loadDocument(InputStream file) { | 86 | Document doc = loadDocument(file); |
3632 | 91 | try { | 87 | |
3633 | 92 | DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); | 88 | return parse(doc); |
3634 | 93 | return builder.parse(file); | 89 | } |
3635 | 94 | } catch (ParserConfigurationException | IOException | SAXException e) { | 90 | |
3636 | 95 | return null; | 91 | private Document loadDocument(InputStream file) { |
3637 | 96 | } | 92 | try { |
3638 | 97 | } | 93 | DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
3639 | 98 | 94 | return builder.parse(file); | |
3640 | 99 | private LoadedModel parse(Document doc) throws FormatException { | 95 | } catch (ParserConfigurationException | IOException | SAXException e) { |
3641 | 100 | idResolver.clear(); | 96 | return null; |
3642 | 101 | 97 | } | |
3643 | 102 | TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(); | 98 | } |
3644 | 103 | 99 | ||
3645 | 104 | //We assume there is only one net per file (this is what we call a TAPN Network) | 100 | private LoadedModel parse(Document doc) throws FormatException { |
3646 | 105 | Node pnmlElement = doc.getElementsByTagName("pnml").item(0); | 101 | idResolver.clear(); |
3647 | 106 | Node netNode = getFirstDirectChild(pnmlElement, "net"); | 102 | |
3648 | 107 | 103 | TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(); | |
3649 | 108 | String name = getTAPNName(netNode); | 104 | |
3650 | 109 | 105 | //We assume there is only one net per file (this is what we call a TAPN Network) | |
3651 | 110 | TimedArcPetriNet tapn = new TimedArcPetriNet(name); | 106 | Node pnmlElement = doc.getElementsByTagName("pnml").item(0); |
3652 | 111 | tapn.setCheckNames(false); | 107 | Node netNode = getFirstDirectChild(pnmlElement, "net"); |
3653 | 112 | network.add(tapn); | 108 | |
3654 | 113 | nameGenerator.add(tapn); | 109 | lens = new TAPNLens(false, false, getFirstDirectChild(netNode, "declaration") != null); |
3655 | 114 | 110 | ||
3656 | 115 | //We assume there is only one page pr. file (this is what we call a net) | 111 | String name = getTAPNName(netNode); |
3657 | 116 | Template template = new Template(tapn, new DataLayer(), new Zoomer()); | 112 | |
3658 | 117 | 113 | TimedArcPetriNet tapn = new TimedArcPetriNet(name); | |
3659 | 118 | parseTimedArcPetriNet(netNode, tapn, template); | 114 | tapn.setCheckNames(false); |
3660 | 119 | template.setHasPositionalInfo(hasPositionalInfo); | 115 | network.add(tapn); |
3661 | 120 | 116 | nameGenerator.add(tapn); | |
3662 | 121 | network.setPaintNet(isNetDrawable()); | 117 | |
3663 | 122 | tapn.setCheckNames(true); | 118 | //We assume there is only one page pr. file (this is what we call a net) |
3664 | 123 | return new LoadedModel(network, Arrays.asList(template), new ArrayList<TAPNQuery>(), new ArrayList<>(), null); | 119 | Template template = new Template(tapn, new DataLayer(), new Zoomer()); |
3665 | 124 | } | 120 | |
3666 | 125 | 121 | parseTimedArcPetriNet(netNode, tapn, template, network); | |
3667 | 126 | private String getTAPNName(Node netNode) { | 122 | template.setHasPositionalInfo(hasPositionalInfo); |
3668 | 127 | if(!(netNode instanceof Element)){ | 123 | |
3669 | 128 | return nameGenerator.getNewTemplateName(); | 124 | network.setPaintNet(isNetDrawable()); |
3670 | 129 | } | 125 | tapn.setCheckNames(true); |
3671 | 130 | String result = null; | 126 | |
3672 | 131 | 127 | return new LoadedModel(network, List.of(template), new ArrayList<TAPNQuery>(), new ArrayList<>(), lens); | |
3673 | 132 | Node name = getFirstDirectChild(netNode, "name"); | 128 | } |
3674 | 133 | if(name != null){ | 129 | |
3675 | 134 | result = getFirstDirectChild(name, "text").getTextContent(); | 130 | private String getTAPNName(Node netNode) { |
3676 | 135 | } | 131 | if(!(netNode instanceof Element)){ |
3677 | 136 | 132 | return nameGenerator.getNewTemplateName(); | |
3678 | 137 | if(name == null || name.equals("")){ | 133 | } |
3679 | 138 | return nameGenerator.getNewTemplateName(); | 134 | String result = null; |
3680 | 139 | } | 135 | |
3681 | 140 | 136 | Node name = getFirstDirectChild(netNode, "name"); | |
3682 | 141 | return NamePurifier.purify(result); | 137 | if(name != null){ |
3683 | 142 | } | 138 | result = getFirstDirectChild(name, "text").getTextContent(); |
3684 | 143 | 139 | } | |
3685 | 144 | private void parseTimedArcPetriNet(Node netNode, TimedArcPetriNet tapn, Template template) throws FormatException { | 140 | |
3686 | 145 | //We assume there is only one page pr. file (this is what we call a net) | 141 | if(name == null || name.equals("")){ |
3687 | 146 | Node node = getFirstDirectChild(netNode, "page").getFirstChild(); | 142 | return nameGenerator.getNewTemplateName(); |
3688 | 147 | Node first = node; | 143 | } |
3689 | 148 | 144 | ||
3690 | 149 | //Calculate netsize | 145 | return NamePurifier.purify(result); |
3691 | 150 | while(node != null){ | 146 | } |
3692 | 151 | netSize += 1; | 147 | |
3693 | 152 | node = node.getNextSibling(); | 148 | private void parseTimedArcPetriNet(Node netNode, TimedArcPetriNet tapn, Template template, TimedArcPetriNetNetwork network) throws FormatException { |
3694 | 153 | } | 149 | if (lens.isColored()) { |
3695 | 154 | 150 | Node declarations = getFirstDirectChild(netNode, "declaration"); | |
3696 | 155 | node = first; | 151 | loadTACPN.parseDeclarations(declarations, network); |
3697 | 156 | //We parse the places and transitions first | 152 | } |
3698 | 157 | while(node != null){ | 153 | |
3699 | 158 | String tag = node.getNodeName(); | 154 | //We assume there is only one page pr. file (this is what we call a net) |
3700 | 159 | if(tag.equals("place")){ | 155 | Node node = getFirstDirectChild(netNode, "page").getFirstChild(); |
3701 | 160 | parsePlace(node, tapn, template); | 156 | Node first = node; |
3702 | 161 | } else if(tag.equals("transition")){ | 157 | |
3703 | 162 | parseTransition(node, tapn, template); | 158 | //Calculate netsize |
3704 | 163 | } | 159 | while(node != null){ |
3705 | 164 | node = node.getNextSibling(); | 160 | netSize += 1; |
3706 | 165 | } | 161 | node = node.getNextSibling(); |
3707 | 166 | 162 | } | |
3708 | 167 | //We parse the transitions last, as we need the places and transitions it refers to | 163 | |
3709 | 168 | node = first; | 164 | node = first; |
3710 | 169 | while(node != null){ | 165 | //We parse the places and transitions first |
3711 | 170 | String tag = node.getNodeName(); | 166 | while(node != null){ |
3712 | 171 | if(tag.equals("arc")){ | 167 | String tag = node.getNodeName(); |
3713 | 172 | parseArc(node, template); | 168 | if(tag.equals("place")){ |
3714 | 173 | } | 169 | parsePlace(node, tapn, template); |
3715 | 174 | node = node.getNextSibling(); | 170 | } else if(tag.equals("transition")){ |
3716 | 175 | } | 171 | parseTransition(node, tapn, template); |
3717 | 176 | } | 172 | } |
3718 | 177 | 173 | node = node.getNextSibling(); | |
3719 | 178 | private void parsePlace(Node node, TimedArcPetriNet tapn, Template template) { | 174 | } |
3720 | 179 | if(!(node instanceof Element)){ | 175 | //We parse the transitions last, as we need the places and transitions it refers to |
3721 | 180 | return; | 176 | node = first; |
3722 | 181 | } | 177 | while(node != null){ |
3723 | 182 | 178 | String tag = node.getNodeName(); | |
3724 | 183 | Name name = parseName(getFirstDirectChild(node, "name")); | 179 | if(tag.equals("arc")){ |
3725 | 184 | if(name == null){ | 180 | parseArc(node, template); |
3726 | 185 | name = new Name(nameGenerator.getNewPlaceName(template.model())); | 181 | } |
3727 | 186 | } | 182 | node = node.getNextSibling(); |
3728 | 187 | Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position); | 183 | } |
3729 | 188 | String id = NamePurifier.purify(((Element) node).getAttribute("id")); | 184 | } |
3730 | 189 | InitialMarking marking = parseMarking(getFirstDirectChild(node, "initialMarking")); | 185 | private void parsePlace(Node node, TimedArcPetriNet tapn, Template template) throws FormatException { |
3731 | 190 | 186 | if (!(node instanceof Element)) { | |
3732 | 191 | TimedPlace place = new LocalTimedPlace(id, new TimeInvariant(false, new Bound.InfBound())); | 187 | return; |
3733 | 192 | Require.that(places.put(id, place) == null && !transitions.containsKey(id), | 188 | } |
3734 | 193 | "The name: " + id + ", was already used"); | 189 | |
3735 | 194 | tapn.add(place); | 190 | Name name = parseName(getFirstDirectChild(node, "name")); |
3736 | 195 | 191 | if (name == null) { | |
3737 | 196 | if(isNetDrawable()){ | 192 | name = new Name(nameGenerator.getNewPlaceName(template.model())); |
3738 | 197 | //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique | 193 | } |
3739 | 198 | TimedPlaceComponent placeComponent = new TimedPlaceComponent(position.x, position.y, id, name.point.x, name.point.y, lens); | 194 | Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position); |
3740 | 199 | placeComponent.setUnderlyingPlace(place); | 195 | String id = NamePurifier.purify(((Element) node).getAttribute("id")); |
3741 | 200 | template.guiModel().addPetriNetObject(placeComponent); | 196 | ArcExpression colorMarking = null; |
3742 | 201 | } | 197 | Point markingOffset = null; |
3743 | 202 | 198 | TimedPlace place; | |
3744 | 203 | idResolver.add(tapn.name(), id, id); | 199 | InitialMarking marking = parseMarking(getFirstDirectChild(node, "initialMarking")); |
3745 | 204 | 200 | ColorType colorType = ColorType.COLORTYPE_DOT; | |
3746 | 205 | for (int i = 0; i < marking.marking; i++) { | 201 | Node typeNode = getFirstDirectChild(node, "type"); |
3747 | 206 | tapn.parentNetwork().marking().add(new TimedToken(place)); | 202 | if (typeNode != null) { |
3748 | 207 | } | 203 | try { |
3749 | 208 | } | 204 | colorType = loadTACPN.parseUserSort(typeNode); |
3750 | 209 | 205 | } catch (FormatException e) { | |
3751 | 210 | private InitialMarking parseMarking(Node node) { | 206 | e.printStackTrace(); |
3752 | 211 | if(!(node instanceof Element)){ | 207 | } |
3753 | 212 | return new InitialMarking(); | 208 | } |
3754 | 213 | } | 209 | Node markingNode = getFirstDirectChild(node, "hlinitialMarking"); |
3755 | 214 | 210 | if (markingNode instanceof Element) { | |
3756 | 215 | Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset); | 211 | try { |
3757 | 216 | 212 | colorMarking = loadTACPN.parseArcExpression(((Element) markingNode).getElementsByTagName("structure").item(0)); | |
3758 | 217 | int marking = Integer.parseInt(getFirstDirectChild(node, "text").getTextContent()); | 213 | } catch (FormatException e) { |
3759 | 218 | 214 | e.printStackTrace(); | |
3760 | 219 | return new InitialMarking(marking, offset); | 215 | } |
3761 | 220 | } | 216 | } |
3762 | 221 | 217 | place = new LocalTimedPlace(id, colorType); | |
3763 | 222 | private void parseTransition(Node node, TimedArcPetriNet tapn, Template template) { | 218 | |
3764 | 223 | if(!(node instanceof Element)){ | 219 | Require.that(places.put(id, place) == null && !transitions.containsKey(id), |
3765 | 224 | return; | 220 | "The name: " + id + ", was already used"); |
3766 | 225 | } | 221 | tapn.add(place); |
3767 | 226 | 222 | ||
3768 | 227 | Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position); | 223 | if (isNetDrawable()) { |
3769 | 228 | Name name = parseName(getFirstDirectChild(node, "name")); | 224 | //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique |
3770 | 229 | if(name == null){ | 225 | TimedPlaceComponent placeComponent; |
3771 | 230 | name = new Name(nameGenerator.getNewTransitionName(template.model())); | 226 | placeComponent = new TimedPlaceComponent(position.x, position.y, id, name.point.x, name.point.y, lens); |
3772 | 231 | } | 227 | placeComponent.setUnderlyingPlace(place); |
3773 | 232 | String id = NamePurifier.purify(((Element) node).getAttribute("id")); | 228 | template.guiModel().addPetriNetObject(placeComponent); |
3774 | 233 | 229 | } | |
3775 | 234 | TimedTransition transition = new TimedTransition(id); | 230 | |
3776 | 235 | Require.that(transitions.put(id, transition) == null && !places.containsKey(id), | 231 | idResolver.add(tapn.name(), id, id); |
3777 | 236 | "The id: " + id + ", was already used"); | 232 | |
3778 | 237 | tapn.add(transition); | 233 | |
3779 | 238 | 234 | if (colorMarking != null) { | |
3780 | 239 | if(isNetDrawable()){ | 235 | ExpressionContext context = new ExpressionContext(new HashMap<String, Color>(), loadTACPN.getColortypes()); |
3781 | 240 | TimedTransitionComponent transitionComponent = | 236 | ColorMultiset cm = colorMarking.eval(context); |
3782 | 241 | //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique | 237 | place.setTokenExpression(loadTACPN.constructCleanAddExpression(colorType,cm)); |
3783 | 242 | new TimedTransitionComponent(position.x, position.y, id, name.point.x, name.point.y, true, false, 0, 0, lens); | 238 | for (TimedToken ct : cm.getTokens(place)) { |
3784 | 243 | transitionComponent.setUnderlyingTransition(transition); | 239 | tapn.parentNetwork().marking().add(ct); |
3785 | 244 | template.guiModel().addPetriNetObject(transitionComponent); | 240 | } |
3786 | 245 | } | 241 | |
3787 | 246 | idResolver.add(tapn.name(), id, id); | 242 | } else { |
3788 | 247 | } | 243 | for (int i = 0; i < marking.marking; i++) { |
3789 | 248 | 244 | tapn.parentNetwork().marking().add(new TimedToken(place, ColorType.COLORTYPE_DOT.getFirstColor())); | |
3790 | 249 | private void parseArc(Node node, Template template) throws FormatException { | 245 | } |
3791 | 250 | if(!(node instanceof Element)){ | 246 | if (marking.marking > 1) { |
3792 | 251 | return; | 247 | Vector<ColorExpression> v = new Vector<>(); |
3793 | 252 | } | 248 | v.add(new DotConstantExpression()); |
3794 | 253 | 249 | Vector<ArcExpression> numbOfExpression = new Vector<>(); | |
3795 | 254 | Element element = (Element) node; | 250 | numbOfExpression.add(new NumberOfExpression(marking.marking, v)); |
3796 | 255 | 251 | place.setTokenExpression(new AddExpression(numbOfExpression)); | |
3797 | 256 | String id = element.getAttribute("id"); | 252 | } |
3798 | 257 | String sourceId = NamePurifier.purify(element.getAttribute("source")); | 253 | } |
3799 | 258 | String targetId = NamePurifier.purify(element.getAttribute("target")); | 254 | } |
3800 | 259 | String type = element.getAttribute("type"); | 255 | |
3801 | 260 | 256 | ||
3802 | 261 | String sourceName = idResolver.get(template.model().name(), sourceId); | 257 | private static Node skipWS(Node node) { |
3803 | 262 | String targetName = idResolver.get(template.model().name(), targetId); | 258 | if (node != null && !(node instanceof Element)) { |
3804 | 263 | 259 | return skipWS(node.getNextSibling()); | |
3805 | 264 | TimedPlace sourcePlace = places.get(sourceName); | 260 | } else { |
3806 | 265 | TimedPlace targetPlace = places.get(targetName); | 261 | return node; |
3807 | 266 | 262 | } | |
3808 | 267 | TimedTransition sourceTransition = transitions.get(sourceName); | 263 | } |
3809 | 268 | TimedTransition targetTransition = transitions.get(targetName); | 264 | |
3810 | 269 | 265 | private static Node getAttribute(Node node, String attribute) { | |
3811 | 270 | PlaceTransitionObject source = template.guiModel().getPlaceTransitionObject(sourceName); | 266 | return node.getAttributes().getNamedItem(attribute); |
3812 | 271 | PlaceTransitionObject target = template.guiModel().getPlaceTransitionObject(targetName); | 267 | } |
3813 | 272 | 268 | ||
3814 | 273 | //Inscription | 269 | |
3815 | 274 | int weight = 1; | 270 | private InitialMarking parseMarking(Node node) { |
3816 | 275 | Node inscription = getFirstDirectChild(node, "inscription"); | 271 | if(!(node instanceof Element)){ |
3817 | 276 | if(inscription != null){ | 272 | return new InitialMarking(); |
3818 | 277 | Node text = getFirstDirectChild(inscription, "text"); | 273 | } |
3819 | 278 | if(text != null){ | 274 | |
3820 | 279 | String weightString = text.getTextContent().trim(); | 275 | Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset); |
3821 | 276 | |||
3822 | 277 | int marking = Integer.parseInt(getFirstDirectChild(node, "text").getTextContent()); | ||
3823 | 278 | |||
3824 | 279 | return new InitialMarking(marking, offset); | ||
3825 | 280 | } | ||
3826 | 281 | |||
3827 | 282 | private void parseTransition(Node node, TimedArcPetriNet tapn, Template template) throws FormatException { | ||
3828 | 283 | if(!(node instanceof Element)){ | ||
3829 | 284 | return; | ||
3830 | 285 | } | ||
3831 | 286 | |||
3832 | 287 | Point position = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Position); | ||
3833 | 288 | Name name = parseName(getFirstDirectChild(node, "name")); | ||
3834 | 289 | if(name == null){ | ||
3835 | 290 | name = new Name(nameGenerator.getNewTransitionName(template.model())); | ||
3836 | 291 | } | ||
3837 | 292 | String id = NamePurifier.purify(((Element) node).getAttribute("id")); | ||
3838 | 293 | |||
3839 | 294 | GuardExpression guardExpression = null; | ||
3840 | 295 | Node conditionNode = getFirstDirectChild(node, "condition"); | ||
3841 | 296 | if (conditionNode != null) { | ||
3842 | 297 | guardExpression = loadTACPN.parseGuardExpression(getFirstDirectChild(conditionNode, "structure")); | ||
3843 | 298 | } | ||
3844 | 299 | |||
3845 | 300 | TimedTransition transition = new TimedTransition(id, guardExpression); | ||
3846 | 301 | Require.that(transitions.put(id, transition) == null && !places.containsKey(id), | ||
3847 | 302 | "The id: " + id + ", was already used"); | ||
3848 | 303 | tapn.add(transition); | ||
3849 | 304 | |||
3850 | 305 | if(isNetDrawable()){ | ||
3851 | 306 | TimedTransitionComponent transitionComponent = | ||
3852 | 307 | //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique | ||
3853 | 308 | new TimedTransitionComponent(position.x, position.y, id, name.point.x, name.point.y, 0, lens); | ||
3854 | 309 | transitionComponent.setUnderlyingTransition(transition); | ||
3855 | 310 | template.guiModel().addPetriNetObject(transitionComponent); | ||
3856 | 311 | } | ||
3857 | 312 | idResolver.add(tapn.name(), id, id); | ||
3858 | 313 | } | ||
3859 | 314 | |||
3860 | 315 | private void parseArc(Node node, Template template) throws FormatException { | ||
3861 | 316 | if(!(node instanceof Element)){ | ||
3862 | 317 | return; | ||
3863 | 318 | } | ||
3864 | 319 | |||
3865 | 320 | Element element = (Element) node; | ||
3866 | 321 | |||
3867 | 322 | String id = element.getAttribute("id"); | ||
3868 | 323 | String sourceId = NamePurifier.purify(element.getAttribute("source")); | ||
3869 | 324 | String targetId = NamePurifier.purify(element.getAttribute("target")); | ||
3870 | 325 | String type = element.getAttribute("type"); | ||
3871 | 326 | |||
3872 | 327 | String sourceName = idResolver.get(template.model().name(), sourceId); | ||
3873 | 328 | String targetName = idResolver.get(template.model().name(), targetId); | ||
3874 | 329 | |||
3875 | 330 | TimedPlace sourcePlace = places.get(sourceName); | ||
3876 | 331 | TimedPlace targetPlace = places.get(targetName); | ||
3877 | 332 | |||
3878 | 333 | TimedTransition sourceTransition = transitions.get(sourceName); | ||
3879 | 334 | TimedTransition targetTransition = transitions.get(targetName); | ||
3880 | 335 | |||
3881 | 336 | PlaceTransitionObject source = template.guiModel().getPlaceTransitionObject(sourceName); | ||
3882 | 337 | PlaceTransitionObject target = template.guiModel().getPlaceTransitionObject(targetName); | ||
3883 | 338 | |||
3884 | 339 | //Inscription | ||
3885 | 340 | int weight = 1; | ||
3886 | 341 | Node inscription = getFirstDirectChild(node, "inscription"); | ||
3887 | 342 | if(inscription != null){ | ||
3888 | 343 | Node text = getFirstDirectChild(inscription, "text"); | ||
3889 | 344 | if(text != null){ | ||
3890 | 345 | String weightString = text.getTextContent().trim(); | ||
3891 | 280 | try { | 346 | try { |
3892 | 281 | weight = Integer.parseInt(weightString); | 347 | weight = Integer.parseInt(weightString); |
3893 | 282 | } catch (NumberFormatException ignored) {} //Default values is 1 | 348 | } catch (NumberFormatException ignored) {} //Default values is 1 |
3937 | 283 | } | 349 | } |
3938 | 284 | } | 350 | } |
3939 | 285 | 351 | ||
3940 | 286 | int _startx = 0, _starty = 0, _endx = 0, _endy = 0; | 352 | int _startx = 0, _starty = 0, _endx = 0, _endy = 0; |
3941 | 287 | 353 | ||
3942 | 288 | if(isNetDrawable()){ | 354 | if(isNetDrawable()){ |
3943 | 289 | // add the insets and offset | 355 | // add the insets and offset |
3944 | 290 | _startx = source.getX() + source.centreOffsetLeft(); | 356 | _startx = source.getX() + source.centreOffsetLeft(); |
3945 | 291 | _starty = source.getY() + source.centreOffsetTop(); | 357 | _starty = source.getY() + source.centreOffsetTop(); |
3946 | 292 | 358 | ||
3947 | 293 | _endx = target.getX() + target.centreOffsetLeft(); | 359 | _endx = target.getX() + target.centreOffsetLeft(); |
3948 | 294 | _endy = target.getY() + target.centreOffsetTop(); | 360 | _endy = target.getY() + target.centreOffsetTop(); |
3949 | 295 | } | 361 | } |
3950 | 296 | 362 | ||
3951 | 297 | Arc tempArc; | 363 | Arc tempArc; |
3952 | 298 | 364 | ArcExpression arcExpression = null; | |
3953 | 299 | if(type != null && type.equals("inhibitor")) { | 365 | Node hlInscriptionNode = getFirstDirectChild(node, "hlinscription"); |
3954 | 300 | tempArc = parseAndAddTimedInhibitorArc(id, sourcePlace, targetTransition, source, target, weight, _endx, _endy, template); | 366 | if (hlInscriptionNode != null) { |
3955 | 301 | } else if(sourcePlace != null && targetTransition != null) { | 367 | arcExpression = loadTACPN.parseArcExpression(getFirstDirectChild(hlInscriptionNode, "structure")); |
3956 | 302 | tempArc = parseInputArc(id, sourcePlace, targetTransition, source, target, weight, _endx, _endy, template); | 368 | } |
3957 | 303 | } else if(sourceTransition != null && targetPlace != null) { | 369 | |
3958 | 304 | tempArc = parseOutputArc(id, sourceTransition, targetPlace, source, target, weight, _endx, _endy, template); | 370 | if(type != null && type.equals("inhibitor")) { |
3959 | 305 | } else { | 371 | tempArc = parseAndAddTimedInhibitorArc(id, sourcePlace, targetTransition, source, target, weight, arcExpression, _endx, _endy, template); |
3960 | 306 | throw new FormatException("Arcs must be only between places and transitions"); | 372 | } else if(sourcePlace != null && targetTransition != null) { |
3961 | 307 | } | 373 | tempArc = parseInputArc(id, sourcePlace, targetTransition, source, target, weight, arcExpression, _endx, _endy, template); |
3962 | 308 | 374 | } else if(sourceTransition != null && targetPlace != null) { | |
3963 | 309 | if(isNetDrawable()) parseArcPath(element, tempArc); | 375 | tempArc = parseOutputArc(id, sourceTransition, targetPlace, source, target, weight, arcExpression, _endx, _endy, template); |
3964 | 310 | } | 376 | } else { |
3965 | 311 | 377 | throw new FormatException("Arcs must be only between places and transitions"); | |
3966 | 312 | private void parseArcPath(Element arc, Arc tempArc) { | 378 | } |
3967 | 313 | Element element = (Element) getFirstDirectChild(arc, "graphics"); | 379 | |
3968 | 314 | if(element == null) return; | 380 | if(isNetDrawable()) parseArcPath(element, tempArc); |
3969 | 315 | NodeList nodelist = element.getElementsByTagName("position"); | 381 | } |
3970 | 316 | if (nodelist.getLength() > 0) { | 382 | |
3971 | 317 | for (int i = 0; i < nodelist.getLength(); i++) { | 383 | private void parseArcPath(Element arc, Arc tempArc) { |
3972 | 318 | Node node = nodelist.item(i); | 384 | Element element = (Element) getFirstDirectChild(arc, "graphics"); |
3973 | 319 | if (node instanceof Element) { | 385 | if(element == null) return; |
3974 | 320 | Element position = (Element) node; | 386 | NodeList nodelist = element.getElementsByTagName("position"); |
3975 | 321 | if ("position".equals(position.getNodeName())) { | 387 | if (nodelist.getLength() > 0) { |
3976 | 322 | String arcTempX = position.getAttribute("x"); | 388 | for (int i = 0; i < nodelist.getLength(); i++) { |
3977 | 323 | String arcTempY = position.getAttribute("y"); | 389 | Node node = nodelist.item(i); |
3978 | 324 | 390 | if (node instanceof Element) { | |
3979 | 325 | double arcPointX = Double.parseDouble(arcTempX); | 391 | Element position = (Element) node; |
3980 | 392 | if ("position".equals(position.getNodeName())) { | ||
3981 | 393 | String arcTempX = position.getAttribute("x"); | ||
3982 | 394 | String arcTempY = position.getAttribute("y"); | ||
3983 | 395 | |||
3984 | 396 | double arcPointX = Double.parseDouble(arcTempX); | ||
3985 | 326 | double arcPointY = Double.parseDouble(arcTempY); | 397 | double arcPointY = Double.parseDouble(arcTempY); |
4074 | 327 | arcPointX += Pipe.ARC_CONTROL_POINT_CONSTANT + 1; | 398 | arcPointX += Constants.ARC_CONTROL_POINT_CONSTANT + 1; |
4075 | 328 | arcPointY += Pipe.ARC_CONTROL_POINT_CONSTANT + 1; | 399 | arcPointY += Constants.ARC_CONTROL_POINT_CONSTANT + 1; |
4076 | 329 | 400 | ||
4077 | 330 | //We add the point at i+1 as the starting and end points of | 401 | //We add the point at i+1 as the starting and end points of |
4078 | 331 | //the arc is already in the path as point number 0 and 1 | 402 | //the arc is already in the path as point number 0 and 1 |
4079 | 332 | tempArc.getArcPath().addPoint(i+1,arcPointX, arcPointY, false); | 403 | tempArc.getArcPath().addPoint(i+1,arcPointX, arcPointY, false); |
4080 | 333 | } | 404 | } |
4081 | 334 | } | 405 | } |
4082 | 335 | } | 406 | } |
4083 | 336 | } | 407 | } |
4084 | 337 | } | 408 | } |
4085 | 338 | 409 | ||
4086 | 339 | private Name parseName(Node node){ | 410 | private Name parseName(Node node){ |
4087 | 340 | if(!(node instanceof Element)){ | 411 | if(!(node instanceof Element)){ |
4088 | 341 | return null; | 412 | return null; |
4089 | 342 | } | 413 | } |
4090 | 343 | Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset); | 414 | Point offset = parseGraphics(getFirstDirectChild(node, "graphics"), GraphicsType.Offset); |
4091 | 344 | 415 | ||
4092 | 345 | String name = getFirstDirectChild(node, "text").getTextContent(); | 416 | String name = getFirstDirectChild(node, "text").getTextContent(); |
4093 | 346 | if(name == null || name.equals("")){ | 417 | if(name == null || name.equals("")){ |
4094 | 347 | return null; | 418 | return null; |
4095 | 348 | } | 419 | } |
4096 | 349 | 420 | ||
4097 | 350 | name = NamePurifier.purify(name); | 421 | name = NamePurifier.purify(name); |
4098 | 351 | return new Name(name, offset); | 422 | return new Name(name, offset); |
4099 | 352 | } | 423 | } |
4100 | 353 | 424 | ||
4101 | 354 | private Point parseGraphics(Node node, GraphicsType type){ | 425 | private Point parseGraphics(Node node, GraphicsType type){ |
4102 | 355 | if(!(node instanceof Element)){ | 426 | if(!(node instanceof Element)){ |
4103 | 356 | if(type == GraphicsType.Offset) | 427 | if(type == GraphicsType.Offset) |
4104 | 357 | return new Point(0, -10); | 428 | return new Point(0, -10); |
4105 | 358 | else | 429 | else |
4106 | 359 | return new Point(100, 100); | 430 | return new Point(100, 100); |
4107 | 360 | } | 431 | } |
4108 | 361 | 432 | ||
4109 | 362 | hasPositionalInfo = true; | 433 | hasPositionalInfo = true; |
4110 | 363 | Element offset = (Element)getFirstDirectChild(node, type == GraphicsType.Offset ? "offset" : "position"); | 434 | Element offset = (Element)getFirstDirectChild(node, type == GraphicsType.Offset ? "offset" : "position"); |
4111 | 364 | 435 | ||
4112 | 365 | String x = offset.getAttribute("x"); | 436 | String x = offset.getAttribute("x"); |
4113 | 366 | String y = offset.getAttribute("y"); | 437 | String y = offset.getAttribute("y"); |
4114 | 367 | 438 | ||
4115 | 368 | int xd = Math.round(Float.parseFloat(x)); | 439 | int xd = Math.round(Float.parseFloat(x)); |
4116 | 369 | int yd = Math.round(Float.parseFloat(y)); | 440 | int yd = Math.round(Float.parseFloat(y)); |
4117 | 370 | 441 | ||
4118 | 371 | return new Point(xd, yd); | 442 | return new Point(xd, yd); |
4119 | 372 | } | 443 | } |
4120 | 373 | 444 | ||
4121 | 374 | private static class Name{ | 445 | private static class Name{ |
4122 | 375 | String name; | 446 | final String name; |
4123 | 376 | Point point; | 447 | final Point point; |
4124 | 377 | 448 | ||
4125 | 378 | public Name(String newPlaceName) { | 449 | public Name(String newPlaceName) { |
4126 | 379 | this(newPlaceName, new Point()); | 450 | this(newPlaceName, new Point()); |
4127 | 380 | } | 451 | } |
4128 | 381 | 452 | ||
4129 | 382 | public Name(String name, Point p) { | 453 | public Name(String name, Point p) { |
4130 | 383 | this.name = name; | 454 | this.name = name; |
4131 | 384 | this.point = p; | 455 | this.point = p; |
4132 | 385 | } | 456 | } |
4133 | 386 | 457 | ||
4134 | 387 | @Override | 458 | @Override |
4135 | 388 | public String toString() { | 459 | public String toString() { |
4136 | 389 | return name + ";" + point; | 460 | return name + ";" + point; |
4137 | 390 | } | 461 | } |
4138 | 391 | } | 462 | } |
4139 | 392 | 463 | ||
4140 | 393 | private static class InitialMarking{ | 464 | private static class InitialMarking{ |
4141 | 394 | int marking; | 465 | final int marking; |
4142 | 395 | Point point; | 466 | final Point point; |
4143 | 396 | 467 | ||
4144 | 397 | public InitialMarking() { | 468 | public InitialMarking() { |
4145 | 398 | this(0, new Point()); | 469 | this(0, new Point()); |
4146 | 399 | } | 470 | } |
4147 | 400 | 471 | ||
4148 | 401 | 472 | ||
4149 | 402 | public InitialMarking(int marking, Point p) { | 473 | public InitialMarking(int marking, Point p) { |
4150 | 403 | this.marking = marking; | 474 | this.marking = marking; |
4151 | 404 | this.point = p; | 475 | this.point = p; |
4152 | 405 | } | 476 | } |
4153 | 406 | 477 | ||
4154 | 407 | @Override | 478 | @Override |
4155 | 408 | public String toString() { | 479 | public String toString() { |
4156 | 409 | return marking + ";" + point; | 480 | return marking + ";" + point; |
4157 | 410 | } | 481 | } |
4158 | 411 | } | 482 | } |
4159 | 412 | 483 | ||
4160 | 413 | private TimedInputArcComponent parseInputArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source, | 484 | private TimedInputArcComponent parseInputArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source, |
4161 | 414 | PlaceTransitionObject target, int weight, int _endx, | 485 | PlaceTransitionObject target, int weight, ArcExpression arcExpression, int _endx, |
4162 | 415 | int _endy, Template template) throws FormatException { | 486 | int _endy, Template template) throws FormatException { |
4190 | 416 | 487 | TimedInputArc inputArc = new TimedInputArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight), arcExpression); | |
4191 | 417 | TimedInputArc inputArc = new TimedInputArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight)); | 488 | |
4192 | 418 | 489 | Require.that(places.containsKey(inputArc.source().name()), "The source place must be part of the petri net."); | |
4193 | 419 | Require.that(places.containsKey(inputArc.source().name()), "The source place must be part of the petri net."); | 490 | Require.that(transitions.containsKey(inputArc.destination().name()), "The destination transition must be part of the petri net"); |
4194 | 420 | Require.that(transitions.containsKey(inputArc.destination().name()), "The destination transition must be part of the petri net"); | 491 | if(!arcs.add(inputArc.source().name() + "-in-" + inputArc.destination().name())) { |
4195 | 421 | if(!arcs.add(inputArc.source().name() + "-in-" + inputArc.destination().name())) { | 492 | throw new FormatException("Multiple arcs between a place and a transition is not allowed"); |
4196 | 422 | throw new FormatException("Multiple arcs between a place and a transition is not allowed"); | 493 | } |
4197 | 423 | } | 494 | |
4198 | 424 | 495 | TimedInputArcComponent arc = null; | |
4199 | 425 | TimedInputArcComponent arc = null; | 496 | |
4200 | 426 | 497 | if(isNetDrawable()){ | |
4201 | 427 | if(isNetDrawable()){ | 498 | arc = new TimedInputArcComponent(new TimedOutputArcComponent(source, target, weight, arcId), lens); |
4202 | 428 | arc = new TimedInputArcComponent(new TimedOutputArcComponent(source, target, weight, arcId), lens); | 499 | arc.setUnderlyingArc(inputArc); |
4203 | 429 | arc.setUnderlyingArc(inputArc); | 500 | |
4204 | 430 | 501 | template.guiModel().addPetriNetObject(arc); | |
4205 | 431 | template.guiModel().addPetriNetObject(arc); | 502 | } |
4206 | 432 | } | 503 | |
4207 | 433 | 504 | template.model().add(inputArc); | |
4208 | 434 | template.model().add(inputArc); | 505 | |
4209 | 435 | 506 | return arc; | |
4210 | 436 | return arc; | 507 | |
4211 | 437 | 508 | ||
4212 | 438 | 509 | } | |
4213 | 439 | } | 510 | |
4214 | 440 | 511 | private Arc parseOutputArc(String arcId, TimedTransition transition, TimedPlace place, PlaceTransitionObject source, | |
4215 | 441 | private Arc parseOutputArc(String arcId, TimedTransition transition, TimedPlace place, PlaceTransitionObject source, | 512 | PlaceTransitionObject target, int weight, ArcExpression arcExpression, int _endx, |
4189 | 442 | PlaceTransitionObject target, int weight, int _endx, | ||
4216 | 443 | int _endy, Template template) throws FormatException { | 513 | int _endy, Template template) throws FormatException { |
4230 | 444 | 514 | TimedOutputArc outputArc = new TimedOutputArc(transition, place, new IntWeight(weight),arcExpression); | |
4231 | 445 | TimedOutputArc outputArc = new TimedOutputArc(transition, place, new IntWeight(weight)); | 515 | |
4232 | 446 | 516 | Require.that(places.containsKey(outputArc.destination().name()), "The destination place must be part of the petri net."); | |
4233 | 447 | Require.that(places.containsKey(outputArc.destination().name()), "The destination place must be part of the petri net."); | 517 | Require.that(transitions.containsKey(outputArc.source().name()), "The source transition must be part of the petri net"); |
4234 | 448 | Require.that(transitions.containsKey(outputArc.source().name()), "The source transition must be part of the petri net"); | 518 | if(!arcs.add(outputArc.source().name() + "-out-" + outputArc.destination().name())) { |
4235 | 449 | if(!arcs.add(outputArc.source().name() + "-out-" + outputArc.destination().name())) { | 519 | throw new FormatException("Multiple arcs between a place and a transition is not allowed"); |
4236 | 450 | throw new FormatException("Multiple arcs between a place and a transition is not allowed"); | 520 | } |
4237 | 451 | } | 521 | |
4238 | 452 | 522 | TimedOutputArcComponent arc = null; | |
4239 | 453 | TimedOutputArcComponent arc = null; | 523 | |
4240 | 454 | 524 | if(isNetDrawable()){ | |
4241 | 455 | if(isNetDrawable()){ | 525 | arc = new TimedOutputArcComponent( |
4229 | 456 | arc = new TimedOutputArcComponent( | ||
4242 | 457 | source, target, weight, arcId); | 526 | source, target, weight, arcId); |
4255 | 458 | arc.setUnderlyingArc(outputArc); | 527 | arc.setUnderlyingArc(outputArc); |
4256 | 459 | 528 | ||
4257 | 460 | template.guiModel().addPetriNetObject(arc); | 529 | template.guiModel().addPetriNetObject(arc); |
4258 | 461 | 530 | ||
4259 | 462 | } | 531 | } |
4260 | 463 | 532 | ||
4261 | 464 | template.model().add(outputArc); | 533 | template.model().add(outputArc); |
4262 | 465 | return arc; | 534 | return arc; |
4263 | 466 | } | 535 | } |
4264 | 467 | 536 | ||
4265 | 468 | private Arc parseAndAddTimedInhibitorArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source, | 537 | private Arc parseAndAddTimedInhibitorArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source, |
4266 | 469 | PlaceTransitionObject target, int weight, int _endx, | 538 | PlaceTransitionObject target, int weight, ArcExpression arcExpression, int _endx, |
4267 | 470 | int _endy, Template template) { | 539 | int _endy, Template template) { |
4296 | 471 | TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent( | 540 | TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent( |
4297 | 472 | new TimedInputArcComponent( | 541 | new TimedInputArcComponent( |
4298 | 473 | new TimedOutputArcComponent(source, target, weight, arcId) | 542 | new TimedOutputArcComponent(source, target, weight, arcId) |
4299 | 474 | ), | 543 | )); |
4300 | 475 | ("")); | 544 | |
4301 | 476 | 545 | TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight), arcExpression); | |
4302 | 477 | TimedInhibitorArc inhibArc = new TimedInhibitorArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight)); | 546 | |
4303 | 478 | 547 | tempArc.setUnderlyingArc(inhibArc); | |
4304 | 479 | tempArc.setUnderlyingArc(inhibArc); | 548 | template.guiModel().addPetriNetObject(tempArc); |
4305 | 480 | template.guiModel().addPetriNetObject(tempArc); | 549 | template.model().add(inhibArc); |
4306 | 481 | template.model().add(inhibArc); | 550 | |
4307 | 482 | 551 | return tempArc; | |
4308 | 483 | return tempArc; | 552 | } |
4309 | 484 | } | 553 | |
4310 | 485 | 554 | private boolean isNetDrawable(){ | |
4311 | 486 | private boolean isNetDrawable(){ | 555 | return netSize <= maxNetSize; |
4312 | 487 | return netSize <= maxNetSize; | 556 | } |
4313 | 488 | } | 557 | |
4314 | 489 | 558 | Node getFirstDirectChild(Node parent, String tagName){ | |
4315 | 490 | Node getFirstDirectChild(Node parent, String tagName){ | 559 | NodeList children = parent.getChildNodes(); |
4316 | 491 | NodeList children = parent.getChildNodes(); | 560 | for(int i = 0; i < children.getLength(); i++){ |
4317 | 492 | for(int i = 0; i < children.getLength(); i++){ | 561 | if(children.item(i).getNodeName().equals(tagName)){ |
4318 | 493 | if(children.item(i).getNodeName().equals(tagName)){ | 562 | return children.item(i); |
4319 | 494 | return children.item(i); | 563 | } |
4320 | 495 | } | 564 | } |
4321 | 496 | } | 565 | return null; |
4322 | 497 | return null; | 566 | } |
4295 | 498 | } | ||
4323 | 499 | 567 | ||
4324 | 500 | } | 568 | } |
4325 | 501 | 569 | ||
4326 | === added file 'src/main/java/dk/aau/cs/io/TapnEngineXmlLoader.java' | |||
4327 | --- src/main/java/dk/aau/cs/io/TapnEngineXmlLoader.java 1970-01-01 00:00:00 +0000 | |||
4328 | +++ src/main/java/dk/aau/cs/io/TapnEngineXmlLoader.java 2022-07-21 13:30:11 +0000 | |||
4329 | @@ -0,0 +1,993 @@ | |||
4330 | 1 | package dk.aau.cs.io; | ||
4331 | 2 | |||
4332 | 3 | import net.tapaal.gui.petrinet.NameGenerator; | ||
4333 | 4 | import net.tapaal.gui.petrinet.TAPNLens; | ||
4334 | 5 | import dk.aau.cs.io.queries.TAPNQueryLoader; | ||
4335 | 6 | import dk.aau.cs.model.CPN.*; | ||
4336 | 7 | import dk.aau.cs.model.CPN.Expressions.*; | ||
4337 | 8 | import dk.aau.cs.model.tapn.*; | ||
4338 | 9 | import dk.aau.cs.util.FormatException; | ||
4339 | 10 | import dk.aau.cs.util.Require; | ||
4340 | 11 | import kotlin.Pair; | ||
4341 | 12 | import org.w3c.dom.Document; | ||
4342 | 13 | import org.w3c.dom.Element; | ||
4343 | 14 | import org.w3c.dom.Node; | ||
4344 | 15 | import org.w3c.dom.NodeList; | ||
4345 | 16 | import org.xml.sax.SAXException; | ||
4346 | 17 | import pipe.gui.petrinet.dataLayer.DataLayer; | ||
4347 | 18 | import net.tapaal.gui.petrinet.Template; | ||
4348 | 19 | import pipe.gui.Constants; | ||
4349 | 20 | import pipe.gui.canvas.Zoomer; | ||
4350 | 21 | import pipe.gui.petrinet.graphicElements.AnnotationNote; | ||
4351 | 22 | import pipe.gui.petrinet.graphicElements.Arc; | ||
4352 | 23 | import pipe.gui.petrinet.graphicElements.Place; | ||
4353 | 24 | import pipe.gui.petrinet.graphicElements.PlaceTransitionObject; | ||
4354 | 25 | import pipe.gui.petrinet.graphicElements.tapn.*; | ||
4355 | 26 | |||
4356 | 27 | import javax.xml.parsers.DocumentBuilder; | ||
4357 | 28 | import javax.xml.parsers.DocumentBuilderFactory; | ||
4358 | 29 | import javax.xml.parsers.ParserConfigurationException; | ||
4359 | 30 | import java.io.File; | ||
4360 | 31 | import java.io.IOException; | ||
4361 | 32 | import java.util.*; | ||
4362 | 33 | |||
4363 | 34 | /* | ||
4364 | 35 | This is a huge quick hack to allow reading an unfolded net from then engine. | ||
4365 | 36 | The engine format uses <graphics> tags to store elements unlike the tapn format. | ||
4366 | 37 | |||
4367 | 38 | It feel like this should not work, but it seems to do, and we needed a quick hack to get it working. | ||
4368 | 39 | |||
4369 | 40 | */ | ||
4370 | 41 | |||
4371 | 42 | public class TapnEngineXmlLoader { | ||
4372 | 43 | private static final String PLACENAME_ERROR_MESSAGE = "The keywords \"true\" and \"false\" are reserved and can not be used as place names.\nPlaces with these names will be renamed to \"_true\" and \"_false\" respectively.\n\n Note that any queries using these places may not be parsed correctly."; | ||
4373 | 44 | |||
4374 | 45 | private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>(); | ||
4375 | 46 | private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>(); | ||
4376 | 47 | private final HashMap<TimedTransportArcComponent, TimeInterval> transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>(); | ||
4377 | 48 | private final HashMap<TimedTransportArcComponent, List<ColoredTimeInterval>> coloredTransportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, List<ColoredTimeInterval>>(); | ||
4378 | 49 | private ArcExpression transportExpr; | ||
4379 | 50 | |||
4380 | 51 | private final NameGenerator nameGenerator = new NameGenerator(); | ||
4381 | 52 | private boolean firstInhibitorIntervalWarning = true; | ||
4382 | 53 | private boolean firstPlaceRenameWarning = true; | ||
4383 | 54 | private final IdResolver idResolver = new IdResolver(); | ||
4384 | 55 | private final Collection<String> messages = new ArrayList<>(10); | ||
4385 | 56 | private final LoadTACPN loadTACPN = new LoadTACPN(); | ||
4386 | 57 | |||
4387 | 58 | boolean hasFeatureTag = false; | ||
4388 | 59 | private TAPNLens lens = TAPNLens.Default; | ||
4389 | 60 | |||
4390 | 61 | public TapnEngineXmlLoader() {} | ||
4391 | 62 | |||
4392 | 63 | public LoadedModel load(File file) throws Exception { | ||
4393 | 64 | Require.that(file != null && file.exists(), "file must be non-null and exist"); | ||
4394 | 65 | |||
4395 | 66 | Document doc = loadDocument(file); | ||
4396 | 67 | if(doc == null) return null; | ||
4397 | 68 | try { | ||
4398 | 69 | return parse(doc); | ||
4399 | 70 | } catch (FormatException | NullPointerException e) { | ||
4400 | 71 | throw e; | ||
4401 | 72 | } catch (Exception e) { | ||
4402 | 73 | throw new Exception("One or more necessary attributes were not found\n - One or more attribute values have an incorrect type", e); | ||
4403 | 74 | } | ||
4404 | 75 | } | ||
4405 | 76 | |||
4406 | 77 | private Document loadDocument(File file) { | ||
4407 | 78 | try { | ||
4408 | 79 | DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); | ||
4409 | 80 | return builder.parse(file); | ||
4410 | 81 | } catch (ParserConfigurationException | IOException | SAXException e) { | ||
4411 | 82 | return null; | ||
4412 | 83 | } | ||
4413 | 84 | } | ||
4414 | 85 | |||
4415 | 86 | private LoadedModel parse(Document doc) throws FormatException { | ||
4416 | 87 | idResolver.clear(); | ||
4417 | 88 | |||
4418 | 89 | ConstantStore constants = new ConstantStore(parseConstants(doc)); | ||
4419 | 90 | TimedArcPetriNetNetwork network = new TimedArcPetriNetNetwork(constants, new ArrayList<>()); | ||
4420 | 91 | NodeList declarations = doc.getElementsByTagName("declaration"); | ||
4421 | 92 | |||
4422 | 93 | if (declarations.getLength() > 0) { | ||
4423 | 94 | for (int i = 0; i < declarations.getLength(); i++) { | ||
4424 | 95 | Node node = declarations.item(i); | ||
4425 | 96 | if (node.getNodeName().equals("declaration")) { | ||
4426 | 97 | loadTACPN.parseDeclarations(node, network); | ||
4427 | 98 | } | ||
4428 | 99 | } | ||
4429 | 100 | for(String message : loadTACPN.getMessages()){ | ||
4430 | 101 | messages.add(message); | ||
4431 | 102 | } | ||
4432 | 103 | } else{ | ||
4433 | 104 | network.add(ColorType.COLORTYPE_DOT); | ||
4434 | 105 | } | ||
4435 | 106 | parseSharedPlaces(doc, network, constants); | ||
4436 | 107 | parseSharedTransitions(doc, network); | ||
4437 | 108 | |||
4438 | 109 | Collection<Template> templates = parseTemplates(doc, network, constants); | ||
4439 | 110 | LoadedQueries loadedQueries = new TAPNQueryLoader(doc, network).parseQueries(); | ||
4440 | 111 | |||
4441 | 112 | if (loadedQueries != null) { | ||
4442 | 113 | for (String message : loadedQueries.getMessages()) { | ||
4443 | 114 | messages.add(message); | ||
4444 | 115 | } | ||
4445 | 116 | } | ||
4446 | 117 | network.buildConstraints(); | ||
4447 | 118 | |||
4448 | 119 | parseBound(doc, network); | ||
4449 | 120 | |||
4450 | 121 | parseFeature(doc, network); | ||
4451 | 122 | |||
4452 | 123 | if (hasFeatureTag) { | ||
4453 | 124 | return new LoadedModel(network, templates, loadedQueries.getQueries(), messages, lens); | ||
4454 | 125 | } else { | ||
4455 | 126 | return new LoadedModel(network, templates, loadedQueries.getQueries(), messages, null); | ||
4456 | 127 | } | ||
4457 | 128 | } | ||
4458 | 129 | |||
4459 | 130 | private void parseBound(Document doc, TimedArcPetriNetNetwork network){ | ||
4460 | 131 | if(doc.getElementsByTagName("k-bound").getLength() > 0){ | ||
4461 | 132 | int i = Integer.parseInt(doc.getElementsByTagName("k-bound").item(0).getAttributes().getNamedItem("bound").getNodeValue()); | ||
4462 | 133 | network.setDefaultBound(i); | ||
4463 | 134 | } | ||
4464 | 135 | } | ||
4465 | 136 | |||
4466 | 137 | private void parseFeature(Document doc, TimedArcPetriNetNetwork network) { | ||
4467 | 138 | if (doc.getElementsByTagName("feature").getLength() > 0) { | ||
4468 | 139 | NodeList nodeList = doc.getElementsByTagName("feature"); | ||
4469 | 140 | |||
4470 | 141 | hasFeatureTag = true; | ||
4471 | 142 | |||
4472 | 143 | var isTimedElement = nodeList.item(0).getAttributes().getNamedItem("isTimed"); | ||
4473 | 144 | boolean isTimed = isTimedElement == null ? network.isTimed() : Boolean.parseBoolean(isTimedElement.getNodeValue()); | ||
4474 | 145 | |||
4475 | 146 | var isGameElement = nodeList.item(0).getAttributes().getNamedItem("isGame"); | ||
4476 | 147 | boolean isGame = isGameElement == null ? network.hasUncontrollableTransitions() : Boolean.parseBoolean(isGameElement.getNodeValue()); | ||
4477 | 148 | |||
4478 | 149 | var isColoredElement = nodeList.item(0).getAttributes().getNamedItem("isColored"); | ||
4479 | 150 | boolean isColored = isColoredElement == null ? network.isColored() : Boolean.parseBoolean(isColoredElement.getNodeValue()); | ||
4480 | 151 | |||
4481 | 152 | lens = new TAPNLens(isTimed, isGame, isColored); | ||
4482 | 153 | } | ||
4483 | 154 | } | ||
4484 | 155 | |||
4485 | 156 | private void parseFeature(Document doc) { | ||
4486 | 157 | if (doc.getElementsByTagName("feature").getLength() > 0) { | ||
4487 | 158 | NodeList nodeList = doc.getElementsByTagName("feature"); | ||
4488 | 159 | |||
4489 | 160 | hasFeatureTag = true; | ||
4490 | 161 | |||
4491 | 162 | var isTimed = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isTimed").getNodeValue()); | ||
4492 | 163 | var isGame = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isGame").getNodeValue()); | ||
4493 | 164 | var isColored = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isColored").getNodeValue()); | ||
4494 | 165 | |||
4495 | 166 | lens = new TAPNLens(isTimed, isGame, isColored); | ||
4496 | 167 | } | ||
4497 | 168 | } | ||
4498 | 169 | |||
4499 | 170 | private void parseSharedPlaces(Document doc, TimedArcPetriNetNetwork network, ConstantStore constants) { | ||
4500 | 171 | NodeList sharedPlaceNodes = doc.getElementsByTagName("shared-place"); | ||
4501 | 172 | |||
4502 | 173 | for(int i = 0; i < sharedPlaceNodes.getLength(); i++){ | ||
4503 | 174 | Node node = sharedPlaceNodes.item(i); | ||
4504 | 175 | |||
4505 | 176 | if(node instanceof Element){ | ||
4506 | 177 | SharedPlace place = parseSharedPlace((Element)node, network, constants); | ||
4507 | 178 | network.add(place); | ||
4508 | 179 | } | ||
4509 | 180 | } | ||
4510 | 181 | } | ||
4511 | 182 | |||
4512 | 183 | private SharedPlace parseSharedPlace(Element element, TimedArcPetriNetNetwork network, ConstantStore constants) { | ||
4513 | 184 | String name = element.getAttribute("name"); | ||
4514 | 185 | TimeInvariant invariant = TimeInvariant.parse(element.getAttribute("invariant"), constants); | ||
4515 | 186 | //int numberOfTokens = Integer.parseInt(element.getAttribute("initialMarking")); | ||
4516 | 187 | |||
4517 | 188 | if(name.equalsIgnoreCase("true") || name.equalsIgnoreCase("false")) { | ||
4518 | 189 | name = "_" + name; | ||
4519 | 190 | if(firstPlaceRenameWarning) { | ||
4520 | 191 | messages.add(PLACENAME_ERROR_MESSAGE); | ||
4521 | 192 | firstPlaceRenameWarning = false; | ||
4522 | 193 | } | ||
4523 | 194 | } | ||
4524 | 195 | SharedPlace place = new SharedPlace(name, invariant); | ||
4525 | 196 | place.setCurrentMarking(network.marking()); | ||
4526 | 197 | place.setColorType(parsePlaceColorType(element)); | ||
4527 | 198 | //place.addTokens(numbesrOfTokens); | ||
4528 | 199 | addColoredDependencies(place,element, network, constants); | ||
4529 | 200 | |||
4530 | 201 | |||
4531 | 202 | return place; | ||
4532 | 203 | } | ||
4533 | 204 | |||
4534 | 205 | private void parseSharedTransitions(Document doc, TimedArcPetriNetNetwork network) { | ||
4535 | 206 | NodeList sharedTransitionNodes = doc.getElementsByTagName("shared-transition"); | ||
4536 | 207 | |||
4537 | 208 | for(int i = 0; i < sharedTransitionNodes.getLength(); i++){ | ||
4538 | 209 | Node node = sharedTransitionNodes.item(i); | ||
4539 | 210 | |||
4540 | 211 | if(node instanceof Element){ | ||
4541 | 212 | SharedTransition transition = parseSharedTransition((Element)node); | ||
4542 | 213 | network.add(transition); | ||
4543 | 214 | } | ||
4544 | 215 | } | ||
4545 | 216 | } | ||
4546 | 217 | |||
4547 | 218 | private SharedTransition parseSharedTransition(Element element) { | ||
4548 | 219 | String name = element.getAttribute("name"); | ||
4549 | 220 | boolean urgent = Boolean.parseBoolean(element.getAttribute("urgent")); | ||
4550 | 221 | boolean isUncontrollable = element.getAttribute("player").equals("1"); | ||
4551 | 222 | |||
4552 | 223 | SharedTransition st = new SharedTransition(name); | ||
4553 | 224 | st.setUrgent(urgent); | ||
4554 | 225 | st.setUncontrollable(isUncontrollable); | ||
4555 | 226 | return st; | ||
4556 | 227 | } | ||
4557 | 228 | |||
4558 | 229 | private Collection<Template> parseTemplates(Document doc, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException { | ||
4559 | 230 | Collection<Template> templates = new ArrayList<Template>(); | ||
4560 | 231 | NodeList nets = doc.getElementsByTagName("net"); | ||
4561 | 232 | |||
4562 | 233 | if(nets.getLength() <= 0) | ||
4563 | 234 | throw new FormatException("File did not contain any TAPN components."); | ||
4564 | 235 | |||
4565 | 236 | for (int i = 0; i < nets.getLength(); i++) { | ||
4566 | 237 | Template template = parseTimedArcPetriNet(nets.item(i), network, constants); | ||
4567 | 238 | template.setHasPositionalInfo(true); //We assume that all templates have positional info | ||
4568 | 239 | templates.add(template); | ||
4569 | 240 | } | ||
4570 | 241 | return templates; | ||
4571 | 242 | } | ||
4572 | 243 | |||
4573 | 244 | private List<Constant> parseConstants(Document doc) { | ||
4574 | 245 | List<Constant> constants = new ArrayList<Constant>(); | ||
4575 | 246 | NodeList constantNodes = doc.getElementsByTagName("constant"); | ||
4576 | 247 | for (int i = 0; i < constantNodes.getLength(); i++) { | ||
4577 | 248 | Node c = constantNodes.item(i); | ||
4578 | 249 | |||
4579 | 250 | if (c instanceof Element) { | ||
4580 | 251 | Constant constant = parseConstant((Element) c); | ||
4581 | 252 | constants.add(constant); | ||
4582 | 253 | } | ||
4583 | 254 | } | ||
4584 | 255 | return constants; | ||
4585 | 256 | } | ||
4586 | 257 | |||
4587 | 258 | private Template parseTimedArcPetriNet(Node tapnNode, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException { | ||
4588 | 259 | String name = getTAPNName(tapnNode); | ||
4589 | 260 | |||
4590 | 261 | boolean active = getActiveStatus(tapnNode); | ||
4591 | 262 | |||
4592 | 263 | TimedArcPetriNet tapn = new TimedArcPetriNet(name); | ||
4593 | 264 | tapn.setActive(active); | ||
4594 | 265 | network.add(tapn); | ||
4595 | 266 | nameGenerator.add(tapn); | ||
4596 | 267 | |||
4597 | 268 | DataLayer guiModel = new DataLayer(); | ||
4598 | 269 | Template template = new Template(tapn, guiModel, new Zoomer()); | ||
4599 | 270 | |||
4600 | 271 | NodeList nodeList = tapnNode.getChildNodes(); | ||
4601 | 272 | for (int i = 0; i < nodeList.getLength(); i++) { | ||
4602 | 273 | |||
4603 | 274 | Node node = nodeList.item(i); | ||
4604 | 275 | if(node instanceof Element){ | ||
4605 | 276 | parseElement((Element)node, template, network, constants); | ||
4606 | 277 | } | ||
4607 | 278 | } | ||
4608 | 279 | |||
4609 | 280 | return template; | ||
4610 | 281 | } | ||
4611 | 282 | |||
4612 | 283 | private boolean getActiveStatus(Node tapnNode) { | ||
4613 | 284 | if (tapnNode instanceof Element) { | ||
4614 | 285 | Element element = (Element)tapnNode; | ||
4615 | 286 | String activeString = element.getAttribute("active"); | ||
4616 | 287 | |||
4617 | 288 | if (activeString == null || activeString.equals("")) | ||
4618 | 289 | return true; | ||
4619 | 290 | else | ||
4620 | 291 | return activeString.equals("true"); | ||
4621 | 292 | } else { | ||
4622 | 293 | return true; | ||
4623 | 294 | } | ||
4624 | 295 | } | ||
4625 | 296 | |||
4626 | 297 | private void parseElement(Element element, Template template, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException { | ||
4627 | 298 | if ("labels".equals(element.getNodeName())) { | ||
4628 | 299 | AnnotationNote note = parseAnnotation(element); | ||
4629 | 300 | template.guiModel().addPetriNetObject(note); | ||
4630 | 301 | } else if ("place".equals(element.getNodeName())) { | ||
4631 | 302 | TimedPlaceComponent place = parsePlace(element, network, template.model(), constants); | ||
4632 | 303 | template.guiModel().addPetriNetObject(place); | ||
4633 | 304 | } else if ("transition".equals(element.getNodeName())) { | ||
4634 | 305 | TimedTransitionComponent transition = parseTransition(element, network, template.model()); | ||
4635 | 306 | template.guiModel().addPetriNetObject(transition); | ||
4636 | 307 | } else if (element.getNodeName().matches("arc|outputArc|inputArc|inhibitorArc|transportArc")) { | ||
4637 | 308 | parseAndAddArc(element, template, constants, network); | ||
4638 | 309 | } | ||
4639 | 310 | } | ||
4640 | 311 | |||
4641 | 312 | private boolean isNameAllowed(String name) { | ||
4642 | 313 | Require.that(name != null, "name was null"); | ||
4643 | 314 | |||
4644 | 315 | return !name.isEmpty() && java.util.regex.Pattern.matches("[a-zA-Z]([_a-zA-Z0-9])*", name); | ||
4645 | 316 | } | ||
4646 | 317 | |||
4647 | 318 | |||
4648 | 319 | private String getTAPNName(Node tapnNode) { | ||
4649 | 320 | if (tapnNode instanceof Element) { | ||
4650 | 321 | Element element = (Element)tapnNode; | ||
4651 | 322 | String name = element.getAttribute("name"); | ||
4652 | 323 | |||
4653 | 324 | if (name == null || name.equals("")) | ||
4654 | 325 | name = element.getAttribute("id"); | ||
4655 | 326 | |||
4656 | 327 | if(!isNameAllowed(name)){ | ||
4657 | 328 | name = nameGenerator.getNewTemplateName(); | ||
4658 | 329 | } | ||
4659 | 330 | nameGenerator.updateTemplateIndex(name); | ||
4660 | 331 | return name; | ||
4661 | 332 | } else { | ||
4662 | 333 | return nameGenerator.getNewTemplateName(); | ||
4663 | 334 | } | ||
4664 | 335 | } | ||
4665 | 336 | |||
4666 | 337 | private AnnotationNote parseAnnotation(Element annotation) { | ||
4667 | 338 | int positionXInput = 0; | ||
4668 | 339 | int positionYInput = 0; | ||
4669 | 340 | int widthInput = 0; | ||
4670 | 341 | int heightInput = 0; | ||
4671 | 342 | boolean borderInput = true; | ||
4672 | 343 | |||
4673 | 344 | String positionXTempStorage = annotation.getAttribute("positionX"); | ||
4674 | 345 | String positionYTempStorage = annotation.getAttribute("positionY"); | ||
4675 | 346 | String widthTemp = annotation.getAttribute("width"); | ||
4676 | 347 | String heightTemp = annotation.getAttribute("height"); | ||
4677 | 348 | String borderTemp = annotation.getAttribute("border"); | ||
4678 | 349 | |||
4679 | 350 | String text = annotation.getTextContent(); | ||
4680 | 351 | |||
4681 | 352 | if (positionXTempStorage.length() > 0) { | ||
4682 | 353 | positionXInput = Integer.parseInt(positionXTempStorage) + 1; | ||
4683 | 354 | } | ||
4684 | 355 | |||
4685 | 356 | if (positionYTempStorage.length() > 0) { | ||
4686 | 357 | positionYInput = Integer.parseInt(positionYTempStorage) + 1; | ||
4687 | 358 | } | ||
4688 | 359 | |||
4689 | 360 | if (widthTemp.length() > 0) { | ||
4690 | 361 | widthInput = Integer.parseInt(widthTemp) + 1; | ||
4691 | 362 | } | ||
4692 | 363 | |||
4693 | 364 | if (heightTemp.length() > 0) { | ||
4694 | 365 | heightInput = Integer.parseInt(heightTemp) + 1; | ||
4695 | 366 | } | ||
4696 | 367 | |||
4697 | 368 | if (borderTemp.length() > 0) { | ||
4698 | 369 | borderInput = Boolean.parseBoolean(borderTemp); | ||
4699 | 370 | } else { | ||
4700 | 371 | borderInput = true; | ||
4701 | 372 | } | ||
4702 | 373 | return new AnnotationNote(text, positionXInput, positionYInput, widthInput, heightInput, borderInput); | ||
4703 | 374 | } | ||
4704 | 375 | |||
4705 | 376 | private TimedTransitionComponent parseTransition(Element transition, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn) { | ||
4706 | 377 | String posX = transition.getAttribute("positionX"); | ||
4707 | 378 | String posY = transition.getAttribute("positionY"); | ||
4708 | 379 | String nameOffsetX = transition.getAttribute("nameOffsetX"); | ||
4709 | 380 | String nameOffsetY = transition.getAttribute("nameOffsetY"); | ||
4710 | 381 | String angleStr = transition.getAttribute("angle"); | ||
4711 | 382 | String priorityStr = transition.getAttribute("priority"); | ||
4712 | 383 | int positionXInput = 0; | ||
4713 | 384 | int positionYInput = 0; | ||
4714 | 385 | int nameOffsetXInput = 0; | ||
4715 | 386 | int nameOffsetYInput = 0; | ||
4716 | 387 | int angle = 0; | ||
4717 | 388 | int priority = 0; | ||
4718 | 389 | if(!posX.isEmpty()){ | ||
4719 | 390 | positionXInput = (int)Double.parseDouble(posX); | ||
4720 | 391 | } | ||
4721 | 392 | if(!posY.isEmpty()){ | ||
4722 | 393 | positionYInput = (int)Double.parseDouble(posY); | ||
4723 | 394 | } | ||
4724 | 395 | |||
4725 | 396 | var g = transition.getElementsByTagName("position"); | ||
4726 | 397 | if (g.getLength() > 0) { | ||
4727 | 398 | positionXInput = Integer.parseInt(((Element) g.item(0)).getAttribute("x")); | ||
4728 | 399 | positionYInput = Integer.parseInt(((Element) g.item(0)).getAttribute("y")); | ||
4729 | 400 | } | ||
4730 | 401 | |||
4731 | 402 | if(!nameOffsetX.isEmpty()){ | ||
4732 | 403 | nameOffsetXInput = (int)Double.parseDouble(nameOffsetX); | ||
4733 | 404 | } | ||
4734 | 405 | if(!nameOffsetY.isEmpty()){ | ||
4735 | 406 | nameOffsetYInput = (int)Double.parseDouble(nameOffsetY); | ||
4736 | 407 | } | ||
4737 | 408 | if(!angleStr.isEmpty()){ | ||
4738 | 409 | angle = Integer.parseInt(angleStr); | ||
4739 | 410 | } | ||
4740 | 411 | if(!priorityStr.isEmpty()){ | ||
4741 | 412 | priority = Integer.parseInt(priorityStr); | ||
4742 | 413 | } | ||
4743 | 414 | String idInput = transition.getAttribute("id"); | ||
4744 | 415 | String nameInput = transition.getAttribute("name"); | ||
4745 | 416 | boolean isUrgent = Boolean.parseBoolean(transition.getAttribute("urgent")); | ||
4746 | 417 | |||
4747 | 418 | String player = transition.getAttribute("player"); | ||
4748 | 419 | |||
4749 | 420 | idResolver.add(tapn.name(), idInput, nameInput); | ||
4750 | 421 | |||
4751 | 422 | boolean infiniteServer = transition.getAttribute("infiniteServer").equals("true"); | ||
4752 | 423 | |||
4753 | 424 | boolean displayName = transition.getAttribute("displayName").equals("false") ? false : true; | ||
4754 | 425 | |||
4755 | 426 | |||
4756 | 427 | if (idInput.length() == 0 && nameInput.length() > 0) { | ||
4757 | 428 | idInput = nameInput; | ||
4758 | 429 | } | ||
4759 | 430 | |||
4760 | 431 | if (nameInput.length() == 0 && idInput.length() > 0) { | ||
4761 | 432 | nameInput = idInput; | ||
4762 | 433 | } | ||
4763 | 434 | GuardExpression guardExpr = null; | ||
4764 | 435 | |||
4765 | 436 | Node conditionNode = getFirstDirectChild(transition, "condition"); | ||
4766 | 437 | if (conditionNode != null) { | ||
4767 | 438 | try { | ||
4768 | 439 | guardExpr = loadTACPN.parseGuardExpression(getFirstDirectChild(conditionNode, "structure")); | ||
4769 | 440 | } catch (FormatException e) { | ||
4770 | 441 | e.printStackTrace(); | ||
4771 | 442 | } | ||
4772 | 443 | } | ||
4773 | 444 | |||
4774 | 445 | TimedTransition t = new TimedTransition(nameInput, guardExpr); | ||
4775 | 446 | t.setUrgent(isUrgent); | ||
4776 | 447 | t.setUncontrollable(player.equals("1")); | ||
4777 | 448 | if(network.isNameUsedForShared(nameInput)){ | ||
4778 | 449 | t.setName(nameGenerator.getNewTransitionName(tapn)); // introduce temporary name to avoid exceptions | ||
4779 | 450 | tapn.add(t); | ||
4780 | 451 | network.getSharedTransitionByName(nameInput).makeShared(t); | ||
4781 | 452 | }else{ | ||
4782 | 453 | tapn.add(t); | ||
4783 | 454 | } | ||
4784 | 455 | nameGenerator.updateIndicesForAllModels(nameInput); | ||
4785 | 456 | TimedTransitionComponent transitionComponent = new TimedTransitionComponent( | ||
4786 | 457 | positionXInput, positionYInput, idInput, | ||
4787 | 458 | nameOffsetXInput, nameOffsetYInput, | ||
4788 | 459 | angle, lens); | ||
4789 | 460 | transitionComponent.setUnderlyingTransition(t); | ||
4790 | 461 | |||
4791 | 462 | if (!displayName){ | ||
4792 | 463 | transitionComponent.setAttributesVisible(false); | ||
4793 | 464 | } | ||
4794 | 465 | return transitionComponent; | ||
4795 | 466 | } | ||
4796 | 467 | |||
4797 | 468 | private TimedPlaceComponent parsePlace(Element place, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn, ConstantStore constants) { | ||
4798 | 469 | String placePosX = place.getAttribute("positionX"); | ||
4799 | 470 | String placePosY = place.getAttribute("positionY"); | ||
4800 | 471 | String nameOffsetX = place.getAttribute("nameOffsetX"); | ||
4801 | 472 | String nameOffsetY = place.getAttribute("nameOffsetY"); | ||
4802 | 473 | int positionXInput = 0; | ||
4803 | 474 | int positionYInput = 0; | ||
4804 | 475 | if(!placePosX.isBlank()){ | ||
4805 | 476 | positionXInput = (int)Double.parseDouble(placePosX); | ||
4806 | 477 | } | ||
4807 | 478 | if(!placePosY.isBlank()){ | ||
4808 | 479 | positionYInput = (int)Double.parseDouble(placePosY); | ||
4809 | 480 | } | ||
4810 | 481 | |||
4811 | 482 | var g = place.getElementsByTagName("position"); | ||
4812 | 483 | if (g.getLength() > 0) { | ||
4813 | 484 | positionXInput = Integer.parseInt(((Element) g.item(0)).getAttribute("x")); | ||
4814 | 485 | positionYInput = Integer.parseInt(((Element) g.item(0)).getAttribute("y")); | ||
4815 | 486 | } | ||
4816 | 487 | |||
4817 | 488 | String idInput = place.getAttribute("id"); | ||
4818 | 489 | String nameInput = place.getAttribute("name"); | ||
4819 | 490 | |||
4820 | 491 | int nameOffsetXInput = 0; | ||
4821 | 492 | int nameOffsetYInput = 0; | ||
4822 | 493 | if(!nameOffsetX.isEmpty()){ | ||
4823 | 494 | nameOffsetXInput = (int)Double.parseDouble(nameOffsetX); | ||
4824 | 495 | } | ||
4825 | 496 | if(!nameOffsetY.isEmpty()){ | ||
4826 | 497 | nameOffsetYInput = (int)Double.parseDouble(nameOffsetY); | ||
4827 | 498 | } | ||
4828 | 499 | |||
4829 | 500 | String invariant = place.getAttribute("invariant"); | ||
4830 | 501 | boolean displayName = place.getAttribute("displayName").equals("false") ? false : true; | ||
4831 | 502 | |||
4832 | 503 | if (idInput.length() == 0 && nameInput.length() > 0) { | ||
4833 | 504 | idInput = nameInput; | ||
4834 | 505 | } | ||
4835 | 506 | |||
4836 | 507 | if (nameInput.length() == 0 && idInput.length() > 0) { | ||
4837 | 508 | nameInput = idInput; | ||
4838 | 509 | } | ||
4839 | 510 | |||
4840 | 511 | if(nameInput.equalsIgnoreCase("true") || nameInput.equalsIgnoreCase("false")) { | ||
4841 | 512 | nameInput = "_" + nameInput; | ||
4842 | 513 | if(firstPlaceRenameWarning) { | ||
4843 | 514 | messages.add(PLACENAME_ERROR_MESSAGE); | ||
4844 | 515 | firstPlaceRenameWarning = false; | ||
4845 | 516 | } | ||
4846 | 517 | } | ||
4847 | 518 | |||
4848 | 519 | idResolver.add(tapn.name(), idInput, nameInput); | ||
4849 | 520 | |||
4850 | 521 | TimedPlace p; | ||
4851 | 522 | if(network.isNameUsedForShared(nameInput)){ | ||
4852 | 523 | p = network.getSharedPlaceByName(nameInput); | ||
4853 | 524 | tapn.add(p); | ||
4854 | 525 | }else{ | ||
4855 | 526 | p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants), parsePlaceColorType(place)); | ||
4856 | 527 | tapn.add(p); | ||
4857 | 528 | addColoredDependencies(p,place, network, constants); | ||
4858 | 529 | |||
4859 | 530 | } | ||
4860 | 531 | nameGenerator.updateIndicesForAllModels(nameInput); | ||
4861 | 532 | TimedPlaceComponent placeComponent = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput, lens); | ||
4862 | 533 | placeComponent.setUnderlyingPlace(p); | ||
4863 | 534 | |||
4864 | 535 | if (!displayName){ | ||
4865 | 536 | placeComponent.setAttributesVisible(false); | ||
4866 | 537 | } | ||
4867 | 538 | |||
4868 | 539 | return placeComponent; | ||
4869 | 540 | } | ||
4870 | 541 | |||
4871 | 542 | private ColorType parsePlaceColorType(Element element){ | ||
4872 | 543 | ColorType ct = ColorType.COLORTYPE_DOT; | ||
4873 | 544 | Node typeNode = element.getElementsByTagName("type").item(0); | ||
4874 | 545 | if (typeNode != null) { | ||
4875 | 546 | try { | ||
4876 | 547 | ct = loadTACPN.parseUserSort(typeNode); | ||
4877 | 548 | } catch (FormatException e) { | ||
4878 | 549 | e.printStackTrace(); | ||
4879 | 550 | } | ||
4880 | 551 | } | ||
4881 | 552 | return ct; | ||
4882 | 553 | } | ||
4883 | 554 | |||
4884 | 555 | private void addColoredDependencies(TimedPlace p, Element place, TimedArcPetriNetNetwork network, ConstantStore constants){ | ||
4885 | 556 | List<ColoredTimeInvariant> ctiList = new ArrayList<ColoredTimeInvariant>(); | ||
4886 | 557 | int initialMarkingInput = Integer.parseInt(place.getAttribute("initialMarking")); | ||
4887 | 558 | |||
4888 | 559 | ArcExpression colorMarking = null; | ||
4889 | 560 | NodeList nodes = place.getElementsByTagName("colorinvariant"); | ||
4890 | 561 | if (nodes != null) { | ||
4891 | 562 | for (int i = 0; i < nodes.getLength(); i++) { | ||
4892 | 563 | Pair<String, Vector<Color>> pair = parseColorInvariant((Element) nodes.item(i), network); | ||
4893 | 564 | ColoredTimeInvariant cti = ColoredTimeInvariant.parse(pair.getFirst(), constants, pair.getSecond()); | ||
4894 | 565 | ctiList.add(cti); | ||
4895 | 566 | } | ||
4896 | 567 | } | ||
4897 | 568 | if (place.getAttribute("inscription").length() > 0) { | ||
4898 | 569 | ctiList.add(ColoredTimeInvariant.parse(place.getAttribute("inscription"), constants, new Vector<Color>() {{ | ||
4899 | 570 | add(Color.STAR_COLOR); | ||
4900 | 571 | }})); | ||
4901 | 572 | } | ||
4902 | 573 | Node hlInitialMarkingNode = place.getElementsByTagName("hlinitialMarking").item(0); | ||
4903 | 574 | |||
4904 | 575 | if (hlInitialMarkingNode instanceof Element) { | ||
4905 | 576 | try { | ||
4906 | 577 | colorMarking = loadTACPN.parseArcExpression(((Element)hlInitialMarkingNode).getElementsByTagName("structure").item(0)); | ||
4907 | 578 | } catch (FormatException e) { | ||
4908 | 579 | e.printStackTrace(); | ||
4909 | 580 | } | ||
4910 | 581 | } | ||
4911 | 582 | |||
4912 | 583 | |||
4913 | 584 | p.setCtiList(ctiList); | ||
4914 | 585 | ExpressionContext context = new ExpressionContext(new HashMap<String, Color>(), loadTACPN.getColortypes()); | ||
4915 | 586 | if(colorMarking!= null){ | ||
4916 | 587 | ColorMultiset cm = colorMarking.eval(context); | ||
4917 | 588 | |||
4918 | 589 | p.setTokenExpression(loadTACPN.constructCleanAddExpression(p.getColorType(),cm)); | ||
4919 | 590 | |||
4920 | 591 | |||
4921 | 592 | for (TimedToken ctElement : cm.getTokens(p)) { | ||
4922 | 593 | network.marking().add(ctElement); | ||
4923 | 594 | //p.addToken(ctElement); | ||
4924 | 595 | } | ||
4925 | 596 | |||
4926 | 597 | } else { | ||
4927 | 598 | for (int i = 0; i < initialMarkingInput; i++) { | ||
4928 | 599 | //Regular tokens will just be dotconstant | ||
4929 | 600 | network.marking().add(new TimedToken(p, ColorType.COLORTYPE_DOT.getFirstColor())); | ||
4930 | 601 | } | ||
4931 | 602 | if(initialMarkingInput > 1) { | ||
4932 | 603 | Vector<ColorExpression> v = new Vector<>(); | ||
4933 | 604 | v.add(new DotConstantExpression()); | ||
4934 | 605 | Vector<ArcExpression> numbOfExpression = new Vector<>(); | ||
4935 | 606 | numbOfExpression.add(new NumberOfExpression(initialMarkingInput, v)); | ||
4936 | 607 | p.setTokenExpression(new AddExpression(numbOfExpression)); | ||
4937 | 608 | } | ||
4938 | 609 | } | ||
4939 | 610 | } | ||
4940 | 611 | |||
4941 | 612 | private void parseAndAddArc(Element arc, Template template, ConstantStore constants, TimedArcPetriNetNetwork network) throws FormatException { | ||
4942 | 613 | String idInput = arc.getAttribute("id"); | ||
4943 | 614 | String sourceInput = arc.getAttribute("source"); | ||
4944 | 615 | String targetInput = arc.getAttribute("target"); | ||
4945 | 616 | boolean taggedArc = arc.getAttribute("tagged").equals("true") ? true : false; | ||
4946 | 617 | String inscriptionTempStorage = arc.getAttribute("inscription"); | ||
4947 | 618 | String type = arc.getAttribute("type"); | ||
4948 | 619 | if(type.isEmpty()){ | ||
4949 | 620 | switch (arc.getNodeName()) { | ||
4950 | 621 | case "transportArc": | ||
4951 | 622 | type = "transport"; | ||
4952 | 623 | break; | ||
4953 | 624 | case "inhibitorArc": | ||
4954 | 625 | type = "inhibitor"; | ||
4955 | 626 | break; | ||
4956 | 627 | case "inputArc": | ||
4957 | 628 | type = "timed"; | ||
4958 | 629 | break; | ||
4959 | 630 | default: | ||
4960 | 631 | type = ""; | ||
4961 | 632 | break; | ||
4962 | 633 | } | ||
4963 | 634 | } | ||
4964 | 635 | int nameOffsetXInput; | ||
4965 | 636 | int nameOffsetYInput; | ||
4966 | 637 | |||
4967 | 638 | //This check is done, as arcs in nets saved before this change do not have a nameOffset | ||
4968 | 639 | if(!arc.getAttribute("nameOffsetX").equals("") && !arc.getAttribute("nameOffsetY").equals("")) { | ||
4969 | 640 | nameOffsetXInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetX")); | ||
4970 | 641 | nameOffsetYInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetY")); | ||
4971 | 642 | } else { | ||
4972 | 643 | nameOffsetXInput = 0; | ||
4973 | 644 | nameOffsetYInput = 0; | ||
4974 | 645 | } | ||
4975 | 646 | |||
4976 | 647 | sourceInput = idResolver.get(template.model().name(), sourceInput); | ||
4977 | 648 | targetInput = idResolver.get(template.model().name(), targetInput); | ||
4978 | 649 | |||
4979 | 650 | PlaceTransitionObject sourceIn = template.guiModel().getPlaceTransitionObject(sourceInput); | ||
4980 | 651 | PlaceTransitionObject targetIn = template.guiModel().getPlaceTransitionObject(targetInput); | ||
4981 | 652 | |||
4982 | 653 | // add the insets and offset | ||
4983 | 654 | int _startx = sourceIn.getX() + sourceIn.centreOffsetLeft(); | ||
4984 | 655 | int _starty = sourceIn.getY() + sourceIn.centreOffsetTop(); | ||
4985 | 656 | |||
4986 | 657 | int _endx = targetIn.getX() + targetIn.centreOffsetLeft(); | ||
4987 | 658 | int _endy = targetIn.getY() + targetIn.centreOffsetTop(); | ||
4988 | 659 | |||
4989 | 660 | //Get weight if any | ||
4990 | 661 | Weight weight = new IntWeight(1); | ||
4991 | 662 | if(arc.hasAttribute("weight")){ | ||
4992 | 663 | weight = Weight.parseWeight(arc.getAttribute("weight"), constants); | ||
4993 | 664 | } | ||
4994 | 665 | ArcExpression arcExpr = null; | ||
4995 | 666 | List<ColoredTimeInterval> ctiList = new ArrayList<ColoredTimeInterval>(); | ||
4996 | 667 | Node hlInscription = getFirstDirectChild(arc, "hlinscription"); | ||
4997 | 668 | if (hlInscription != null) | ||
4998 | 669 | hlInscription = getFirstDirectChild(hlInscription, "structure"); | ||
4999 | 670 | if (hlInscription != null) | ||
5000 | 671 | arcExpr = loadTACPN.parseArcExpression(hlInscription); |
All code only comments should be removed, unless it directly relates to something being explained.
Or if used for specialized debug. If for debug, please mark the beginning of block with DEBUG.
Internal members not mutated should be marked final.
(I will make a patch that fixes these to issues)