| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- {
- "types": {
- "Generator": [
- {
- "name": "producedCars",
- "type": "int",
- "default": 0
- },
- {
- "name": "position",
- "type": "list<int>",
- "default": [
- 0,
- 0
- ]
- }
- ],
- "RoadSegment": [
- {
- "name": "currentCars",
- "type": "int",
- "default": 0
- },
- {
- "name": "position",
- "type": "list<int>",
- "default": [
- 0,
- 0
- ]
- }
- ],
- "Sink": [
- {
- "name": "consumedCars",
- "type": "int",
- "default": 0
- },
- {
- "name": "position",
- "type": "list<int>",
- "default": [
- 0,
- 0
- ]
- }
- ],
- "Car": [
- {
- "name": "color",
- "type": "string",
- "default": "#ff0000"
- },
- {
- "name": "position",
- "type": "list<int>",
- "default": [
- 0,
- 0
- ]
- }
- ],
- "RS2G": [],
- "S2RS": [],
- "RS2RS": [],
- "CarOnRoadSegment": [],
- "Positionable": [
- {
- "name": "position",
- "type": "list<int>",
- "default": [
- 0,
- 0
- ]
- }
- ]
- },
- "constraints": [
- {
- "name": "noAbstractInstances",
- "event": "pre-create",
- "code": "false",
- "targetType": "Positionable"
- }
- ],
- "actions": [
- {
- "name": "snapToTarget",
- "event": "post-connect",
- "code": "/*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*/}",
- "targetType": "Generator"
- },
- {
- "name": "snapToTarget",
- "event": "post-connect",
- "code": "/*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*/}",
- "targetType": "RoadSegment"
- },
- {
- "name": "snapToTarget",
- "event": "post-connect",
- "code": "/*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*/}",
- "targetType": "Sink"
- },
- {
- "name": "snapToTarget",
- "event": "post-connect",
- "code": "/*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*/}",
- "targetType": "Car"
- },
- {
- "name": "snapToTarget",
- "event": "post-connect",
- "code": "/*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*/}",
- "targetType": "Positionable"
- }
- ],
- "cardinalities": {
- "Generator": [
- {
- "dir": "in",
- "type": "RS2G",
- "min": "1",
- "max": "1"
- }
- ],
- "RoadSegment": [
- {
- "dir": "out",
- "type": "RS2G",
- "min": "0",
- "max": "1"
- },
- {
- "dir": "out",
- "type": "RS2RS",
- "min": "0",
- "max": "1"
- },
- {
- "dir": "in",
- "type": "RS2RS",
- "min": "0",
- "max": "1"
- },
- {
- "dir": "in",
- "type": "S2RS",
- "min": "0",
- "max": "1"
- },
- {
- "dir": "out",
- "type": "CarOnRoadSegment",
- "min": "0",
- "max": "Infinity"
- }
- ],
- "Sink": [
- {
- "dir": "out",
- "type": "S2RS",
- "min": "1",
- "max": "1"
- }
- ],
- "Car": [
- {
- "dir": "in",
- "type": "CarOnRoadSegment",
- "min": "1",
- "max": "1"
- }
- ],
- "RS2G": [
- {
- "dir": "in",
- "type": "RoadSegment",
- "min": "1",
- "max": "1"
- },
- {
- "dir": "out",
- "type": "Generator",
- "min": "1",
- "max": "1"
- }
- ],
- "S2RS": [
- {
- "dir": "in",
- "type": "Sink",
- "min": "1",
- "max": "1"
- },
- {
- "dir": "out",
- "type": "RoadSegment",
- "min": "1",
- "max": "1"
- }
- ],
- "RS2RS": [
- {
- "dir": "in",
- "type": "RoadSegment",
- "min": "1",
- "max": "1"
- },
- {
- "dir": "out",
- "type": "RoadSegment",
- "min": "1",
- "max": "1"
- }
- ],
- "CarOnRoadSegment": [
- {
- "dir": "in",
- "type": "RoadSegment",
- "min": "1",
- "max": "1"
- },
- {
- "dir": "out",
- "type": "Car",
- "min": "1",
- "max": "1"
- }
- ],
- "Positionable": []
- },
- "legalConnections": {
- "RoadSegment": {
- "Generator": [
- "RS2G"
- ],
- "RoadSegment": [
- "RS2RS"
- ],
- "Car": [
- "CarOnRoadSegment"
- ]
- },
- "Sink": {
- "RoadSegment": [
- "S2RS"
- ]
- }
- },
- "connectorTypes": {
- "RS2G": "visual",
- "S2RS": "visual",
- "RS2RS": "visual",
- "CarOnRoadSegment": "containment"
- },
- "types2parentTypes": {
- "Generator": [
- "Positionable"
- ],
- "RoadSegment": [
- "Positionable"
- ],
- "Sink": [
- "Positionable"
- ],
- "Car": [
- "Positionable"
- ],
- "RS2G": [],
- "S2RS": [],
- "RS2RS": [],
- "CarOnRoadSegment": [],
- "Positionable": []
- }
- }
|