my_petrinet_with_MM_and_constraints.mvc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import models/SimpleClassDiagrams as SCD
  2. include "primitives.alh"
  3. SCD PetriNets{
  4. SimpleAttribute Natural {
  5. constraint =
  6. $
  7. include "primitives.alh"
  8. String function constraint_Natural(model : Element, name : String):
  9. Element self
  10. self = model["model"][name]
  11. if (is_physical_int(self)):
  12. if (integer_gte(self, 0)):
  13. return "OK"!
  14. else:
  15. return "Natural number not larger than or equal to zero"!
  16. else:
  17. return "Natural number not larger than or equal to zero"!
  18. $
  19. }
  20. Class Place{
  21. tokens : Natural
  22. }
  23. Class Transition{}
  24. Association P2T (Place, Transition) {
  25. weight : Natural
  26. }
  27. Association T2P (Transition, Place) {
  28. weight : Natural
  29. }
  30. }
  31. PetriNets my_petrinet {
  32. Place p1 {
  33. tokens = 1
  34. }
  35. Place p2 {
  36. tokens = 3
  37. }
  38. Transition t1 {}
  39. P2T (p1, t1) {
  40. weight = 1
  41. }
  42. T2P (t1, p2) {
  43. weight = 2
  44. }
  45. }
  46. export my_petrinet to models/my_petrinet