Skip to content

Commit b34b1d6

Browse files
committed
[net] addPlace
1 parent 8716585 commit b34b1d6

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed

TODO.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# net
22

3-
[net] addPlace
43
[net] addTransition
54

65
[connect] connectTransitionToPlaces(net: Net, transition: Transition, place: Place)

src/lang/net/Net.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type Net = {
1717
}
1818

1919
export type TransitionEntry = {
20+
modId: string
2021
id: string
2122
name: string
2223
inputParameters: Array<Parameter>
@@ -26,10 +27,11 @@ export type TransitionEntry = {
2627
}
2728

2829
export type PlaceEntry = {
30+
modId: string
2931
id: string
3032
name: string
31-
inputs: Array<TransitionEntry>
32-
outputs: Array<TransitionEntry>
3333
t: Value
3434
queue: Array<Value>
35+
inputs: Array<TransitionEntry>
36+
outputs: Array<TransitionEntry>
3537
}

src/lang/net/addPlace.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Mod } from "../mod"
2+
import { Net } from "../net"
3+
import { Node } from "../node"
4+
import { createNodeId } from "../node/createNodeId"
5+
import { nodeKey } from "../node/nodeKey"
6+
import { Place } from "../place"
7+
import { Value } from "../value"
8+
9+
export function addPlace(net: Net, mod: Mod, name: string, t: Value): Node {
10+
const modId = mod.url.href
11+
const id = createNodeId(name)
12+
13+
const place: Place = {
14+
"@type": "Value",
15+
"@kind": "Place",
16+
modId,
17+
id,
18+
name,
19+
}
20+
21+
net.placeEntries.set(nodeKey(place), {
22+
modId,
23+
id,
24+
name,
25+
t,
26+
queue: [],
27+
inputs: [],
28+
outputs: [],
29+
})
30+
31+
return place
32+
}

src/lang/net/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from "./Net"
22
export * from "./createNet"
3-
// export * from "./addPlace"
3+
export * from "./addPlace"

src/lang/place/Place.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export type Place = {
2+
"@type": "Value",
3+
"@kind": "Place",
24
modId: string
35
id: string
46
name: string

src/lang/transition/Transition.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export type Transition = {
2+
"@type": "Value",
3+
"@kind": "Transition",
24
modId: string
35
id: string
46
name: string

0 commit comments

Comments
 (0)