Traffic.pattern.metamodel 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. {
  2. "types": {
  3. "__pGenerator": [
  4. {
  5. "name": "__pLabel",
  6. "type": "string",
  7. "default": ""
  8. },
  9. {
  10. "name": "__pMatchSubtypes",
  11. "type": "boolean",
  12. "default": false
  13. },
  14. {
  15. "name": "producedCars",
  16. "type": "code",
  17. "default": "getAttr()"
  18. },
  19. {
  20. "name": "position",
  21. "type": "code",
  22. "default": "getAttr()"
  23. }
  24. ],
  25. "__pRoadSegment": [
  26. {
  27. "name": "__pLabel",
  28. "type": "string",
  29. "default": ""
  30. },
  31. {
  32. "name": "__pMatchSubtypes",
  33. "type": "boolean",
  34. "default": false
  35. },
  36. {
  37. "name": "currentCars",
  38. "type": "code",
  39. "default": "getAttr()"
  40. },
  41. {
  42. "name": "position",
  43. "type": "code",
  44. "default": "getAttr()"
  45. }
  46. ],
  47. "__pSink": [
  48. {
  49. "name": "__pLabel",
  50. "type": "string",
  51. "default": ""
  52. },
  53. {
  54. "name": "__pMatchSubtypes",
  55. "type": "boolean",
  56. "default": false
  57. },
  58. {
  59. "name": "consumedCars",
  60. "type": "code",
  61. "default": "getAttr()"
  62. },
  63. {
  64. "name": "position",
  65. "type": "code",
  66. "default": "getAttr()"
  67. }
  68. ],
  69. "__pCar": [
  70. {
  71. "name": "__pLabel",
  72. "type": "string",
  73. "default": ""
  74. },
  75. {
  76. "name": "__pMatchSubtypes",
  77. "type": "boolean",
  78. "default": false
  79. },
  80. {
  81. "name": "color",
  82. "type": "code",
  83. "default": "getAttr()"
  84. },
  85. {
  86. "name": "position",
  87. "type": "code",
  88. "default": "getAttr()"
  89. }
  90. ],
  91. "__pRS2G": [
  92. {
  93. "name": "__pLabel",
  94. "type": "string",
  95. "default": ""
  96. },
  97. {
  98. "name": "__pMatchSubtypes",
  99. "type": "boolean",
  100. "default": false
  101. }
  102. ],
  103. "__pS2RS": [
  104. {
  105. "name": "__pLabel",
  106. "type": "string",
  107. "default": ""
  108. },
  109. {
  110. "name": "__pMatchSubtypes",
  111. "type": "boolean",
  112. "default": false
  113. }
  114. ],
  115. "__pRS2RS": [
  116. {
  117. "name": "__pLabel",
  118. "type": "string",
  119. "default": ""
  120. },
  121. {
  122. "name": "__pMatchSubtypes",
  123. "type": "boolean",
  124. "default": false
  125. }
  126. ],
  127. "__pCarOnRoadSegment": [
  128. {
  129. "name": "__pLabel",
  130. "type": "string",
  131. "default": ""
  132. },
  133. {
  134. "name": "__pMatchSubtypes",
  135. "type": "boolean",
  136. "default": false
  137. }
  138. ],
  139. "__pPositionable": [
  140. {
  141. "name": "__pLabel",
  142. "type": "string",
  143. "default": ""
  144. },
  145. {
  146. "name": "__pMatchSubtypes",
  147. "type": "boolean",
  148. "default": false
  149. },
  150. {
  151. "name": "position",
  152. "type": "code",
  153. "default": "getAttr()"
  154. }
  155. ]
  156. },
  157. "constraints": [
  158. {
  159. "name": "noAbstractInstances",
  160. "event": "pre-create",
  161. "code": "/* comment next line to enable this constraint */\nthrow \"IgnoredConstraint\"\nfalse",
  162. "targetType": "Positionable"
  163. }
  164. ],
  165. "actions": [
  166. {
  167. "name": "snapToTarget",
  168. "event": "post-connect",
  169. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if(! getAttr('$type', neighborLink).match(/CarOnRoadSegment/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0]+(getAttr('$type',neighbor).match(/Generator/) ? 80 : 300),npos[1]]);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ var car = getNeighbors('>','*',neighborLink)[0],/*newline*/ rspos = getAttr('position'),/*newline*/ rspop = getNeighbors('>','/Formalisms/Traffic/Traffic/CarOnRoadSegment').length;/*newline*/ setAttr('position', [rspos[0]+rspop*20,rspos[1]],car);/*newline*/ }/*newline*/}",
  170. "targetType": "__pGenerator"
  171. },
  172. {
  173. "name": "snapToTarget",
  174. "event": "post-connect",
  175. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if(! getAttr('$type', neighborLink).match(/CarOnRoadSegment/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0]+(getAttr('$type',neighbor).match(/Generator/) ? 80 : 300),npos[1]]);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ var car = getNeighbors('>','*',neighborLink)[0],/*newline*/ rspos = getAttr('position'),/*newline*/ rspop = getNeighbors('>','/Formalisms/Traffic/Traffic/CarOnRoadSegment').length;/*newline*/ setAttr('position', [rspos[0]+rspop*20,rspos[1]],car);/*newline*/ }/*newline*/}",
  176. "targetType": "__pRoadSegment"
  177. },
  178. {
  179. "name": "snapToTarget",
  180. "event": "post-connect",
  181. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if(! getAttr('$type', neighborLink).match(/CarOnRoadSegment/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0]+(getAttr('$type',neighbor).match(/Generator/) ? 80 : 300),npos[1]]);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ var car = getNeighbors('>','*',neighborLink)[0],/*newline*/ rspos = getAttr('position'),/*newline*/ rspop = getNeighbors('>','/Formalisms/Traffic/Traffic/CarOnRoadSegment').length;/*newline*/ setAttr('position', [rspos[0]+rspop*20,rspos[1]],car);/*newline*/ }/*newline*/}",
  182. "targetType": "__pSink"
  183. },
  184. {
  185. "name": "snapToTarget",
  186. "event": "post-connect",
  187. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if(! getAttr('$type', neighborLink).match(/CarOnRoadSegment/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0]+(getAttr('$type',neighbor).match(/Generator/) ? 80 : 300),npos[1]]);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ var car = getNeighbors('>','*',neighborLink)[0],/*newline*/ rspos = getAttr('position'),/*newline*/ rspop = getNeighbors('>','/Formalisms/Traffic/Traffic/CarOnRoadSegment').length;/*newline*/ setAttr('position', [rspos[0]+rspop*20,rspos[1]],car);/*newline*/ }/*newline*/}",
  188. "targetType": "__pCar"
  189. },
  190. {
  191. "name": "snapToTarget",
  192. "event": "post-connect",
  193. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if(! getAttr('$type', neighborLink).match(/CarOnRoadSegment/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0]+(getAttr('$type',neighbor).match(/Generator/) ? 80 : 300),npos[1]]);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ var car = getNeighbors('>','*',neighborLink)[0],/*newline*/ rspos = getAttr('position'),/*newline*/ rspop = getNeighbors('>','/Formalisms/Traffic/Traffic/CarOnRoadSegment').length;/*newline*/ setAttr('position', [rspos[0]+rspop*20,rspos[1]],car);/*newline*/ }/*newline*/}",
  194. "targetType": "__pPositionable"
  195. },
  196. {
  197. "name": "distinctPLabels",
  198. "event": "post-create",
  199. "code": "if( getAttr(\"__pLabel\") == \"\" )\n{\n\tvar pLabels = getAllNodes().\n\t\t\t\t\t\t\tfilter( function(n) {return hasAttr(\"__pLabel\",n);} ).\n\t\t\t\t\t\t\t\tmap( function(n) {return getAttr(\"__pLabel\",n);} ),\n\t\t i\t\t\t= \"0\";\n\n\twhile( _utils.contains(pLabels,i) )\n\t\ti = String(parseInt(i)+1);\n\tsetAttr(\"__pLabel\",i);\n}",
  200. "targetType": "*"
  201. }
  202. ],
  203. "cardinalities": {
  204. "__pGenerator": [
  205. {
  206. "dir": "in",
  207. "type": "__pRS2G",
  208. "min": 0,
  209. "max": "1"
  210. }
  211. ],
  212. "__pRoadSegment": [
  213. {
  214. "dir": "out",
  215. "type": "__pRS2G",
  216. "min": 0,
  217. "max": "1"
  218. },
  219. {
  220. "dir": "out",
  221. "type": "__pRS2RS",
  222. "min": 0,
  223. "max": "1"
  224. },
  225. {
  226. "dir": "in",
  227. "type": "__pRS2RS",
  228. "min": 0,
  229. "max": "1"
  230. },
  231. {
  232. "dir": "in",
  233. "type": "__pS2RS",
  234. "min": 0,
  235. "max": "1"
  236. },
  237. {
  238. "dir": "out",
  239. "type": "__pCarOnRoadSegment",
  240. "min": 0,
  241. "max": "Infinity"
  242. }
  243. ],
  244. "__pSink": [
  245. {
  246. "dir": "out",
  247. "type": "__pS2RS",
  248. "min": 0,
  249. "max": "1"
  250. }
  251. ],
  252. "__pCar": [
  253. {
  254. "dir": "in",
  255. "type": "__pCarOnRoadSegment",
  256. "min": 0,
  257. "max": "1"
  258. }
  259. ],
  260. "__pRS2G": [
  261. {
  262. "dir": "in",
  263. "type": "__pRoadSegment",
  264. "min": 0,
  265. "max": "1"
  266. },
  267. {
  268. "dir": "out",
  269. "type": "__pGenerator",
  270. "min": 0,
  271. "max": "1"
  272. }
  273. ],
  274. "__pS2RS": [
  275. {
  276. "dir": "in",
  277. "type": "__pSink",
  278. "min": 0,
  279. "max": "1"
  280. },
  281. {
  282. "dir": "out",
  283. "type": "__pRoadSegment",
  284. "min": 0,
  285. "max": "1"
  286. }
  287. ],
  288. "__pRS2RS": [
  289. {
  290. "dir": "in",
  291. "type": "__pRoadSegment",
  292. "min": 0,
  293. "max": "1"
  294. },
  295. {
  296. "dir": "out",
  297. "type": "__pRoadSegment",
  298. "min": 0,
  299. "max": "1"
  300. }
  301. ],
  302. "__pCarOnRoadSegment": [
  303. {
  304. "dir": "in",
  305. "type": "__pRoadSegment",
  306. "min": 0,
  307. "max": "1"
  308. },
  309. {
  310. "dir": "out",
  311. "type": "__pCar",
  312. "min": 0,
  313. "max": "1"
  314. }
  315. ],
  316. "__pPositionable": []
  317. },
  318. "legalConnections": {
  319. "__pRoadSegment": {
  320. "__pGenerator": [
  321. "__pRS2G"
  322. ],
  323. "__pRoadSegment": [
  324. "__pRS2RS"
  325. ],
  326. "__pCar": [
  327. "__pCarOnRoadSegment"
  328. ]
  329. },
  330. "__pSink": {
  331. "__pRoadSegment": [
  332. "__pS2RS"
  333. ]
  334. }
  335. },
  336. "connectorTypes": {
  337. "__pRS2G": "visual",
  338. "__pS2RS": "visual",
  339. "__pRS2RS": "visual",
  340. "__pCarOnRoadSegment": "containment"
  341. },
  342. "types2parentTypes": {
  343. "__pGenerator": [
  344. "__pPositionable"
  345. ],
  346. "__pRoadSegment": [
  347. "__pPositionable"
  348. ],
  349. "__pSink": [
  350. "__pPositionable"
  351. ],
  352. "__pCar": [
  353. "__pPositionable"
  354. ],
  355. "__pRS2G": [],
  356. "__pS2RS": [],
  357. "__pRS2RS": [],
  358. "__pCarOnRoadSegment": [],
  359. "__pPositionable": []
  360. }
  361. }