petrinets_constraints.mvc 917 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import models/SimpleClassDiagrams as SCD
  2. include "primitives.alh"
  3. SCD PetriNets{
  4. SimpleAttribute Natural {
  5. constraint =
  6. $
  7. String function constraint_Natural(model : Element, name : String):
  8. Element self
  9. self = model["model"][name]
  10. if (is_physical_int(self)):
  11. if (integer_gte(self, 0)):
  12. return "OK"!
  13. else:
  14. return "Natural number not larger than or equal to zero"!
  15. else:
  16. return "Natural number not larger than or equal to zero"!
  17. $
  18. }
  19. Class Place{
  20. tokens : Natural
  21. }
  22. Class Transition{}
  23. Association P2T (Place, Transition) {
  24. weight : Natural
  25. }
  26. Association T2P (Transition, Place) {
  27. weight : Natural
  28. }
  29. }
  30. export PetriNets to models/PetriNets