Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cuttlefish
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
squidworks
cuttlefish
Commits
7832cd0d
Commit
7832cd0d
authored
5 years ago
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
sync, await
parent
1473143a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
hunks/flowcontrol/syncawait.js
+148
-0
148 additions, 0 deletions
hunks/flowcontrol/syncawait.js
hunks/math/plusequals.js
+7
-3
7 additions, 3 deletions
hunks/math/plusequals.js
save/systems/dex-test-awaitingflow.json
+1208
-0
1208 additions, 0 deletions
save/systems/dex-test-awaitingflow.json
with
1363 additions
and
3 deletions
hunks/flowcontrol/syncawait.js
0 → 100644
+
148
−
0
View file @
7832cd0d
/*
always on
*/
import
{
Hunkify
,
Input
,
Output
,
State
}
from
'
../hunks.js
'
import
{
TSET
,
findPhy
}
from
'
../../typeset.js
'
// synchronous pressure .. polymorphic
export
default
function
Pressure
()
{
Hunkify
(
this
)
// the hack is that boolean states are often just used as buttons ...
let
startup
=
false
let
runState
=
new
State
(
'
boolean
'
,
'
run
'
,
false
)
runState
.
onChange
=
(
value
)
=>
{
// always a toggle, then
if
(
runState
.
value
){
runState
.
set
(
false
)
startup
=
false
}
else
{
runState
.
set
(
true
)
startup
=
true
}
}
this
.
states
.
push
(
runState
)
// and setup:
let
status
=
new
State
(
'
string
'
,
'
status
'
,
''
)
let
aType
=
new
State
(
'
string
'
,
'
await
'
,
'
boolean
'
)
let
pTypes
=
new
State
(
'
string
'
,
'
types
'
,
'
boolean, number
'
)
let
pVals
=
new
State
(
'
string
'
,
'
values
'
,
'
true, 4
'
)
this
.
states
.
push
(
status
,
aType
,
pTypes
,
pVals
)
let
values
=
[]
let
setup
=
(
init
)
=>
{
let
pt
=
pTypes
.
value
.
split
(
'
,
'
)
let
pv
=
pVals
.
value
.
split
(
'
,
'
)
// tough, we want to check that all types exist, and can convert from some string to whatever else we put in here...
if
(
pt
.
length
==
pv
.
length
)
{
let
count
=
0
let
candOutputs
=
[]
let
candValues
=
[]
for
(
let
t
in
pt
)
{
// take leading spaces out,
if
(
pt
[
t
].
indexOf
(
'
'
)
>
-
1
)
pt
[
t
]
=
pt
[
t
].
substring
(
pt
[
t
].
indexOf
(
'
'
)
+
1
)
if
(
findPhy
(
pt
[
t
]))
{
candOutputs
.
push
(
new
Output
(
pt
[
t
],
pt
[
t
],
this
))
}
}
if
(
candOutputs
.
length
!=
pv
.
length
)
{
status
.
set
(
'
missing some outputs...
'
)
return
}
for
(
let
v
in
pv
)
{
// let's use the string copy f'ns for this
let
strphy
=
findPhy
(
'
string
'
)
// a method to write values from strings exists?
if
(
strphy
.
copy
[
pt
[
v
]])
{
candValues
.
push
(
strphy
.
copy
[
pt
[
v
]](
pv
[
v
]))
}
else
{
console
.
log
(
`no string-to-
${
pt
[
v
]}
exists`
)
}
}
if
(
candValues
.
length
!=
pv
.
length
)
{
status
.
set
(
'
missing some values...
'
)
}
status
.
set
(
'
type, value sets OK
'
)
this
.
outputs
=
candOutputs
values
=
candValues
// if we call this during init the system becomes confused
if
(
!
init
)
this
.
mgr
.
evaluateHunk
(
this
)
}
else
{
status
.
set
(
'
mistmatched lists...
'
)
// mismatched lists, probably ...
// here's a case where it would be great to repl- with an error...
}
}
pTypes
.
onChange
=
(
value
)
=>
{
pTypes
.
set
(
value
)
setup
()
}
pVals
.
onChange
=
(
value
)
=>
{
pVals
.
set
(
value
)
setup
()
}
let
setupAwait
=
(
init
)
=>
{
if
(
findPhy
(
aType
.
value
))
{
this
.
inputs
[
0
]
=
new
Input
(
aType
.
value
,
'
await
'
,
this
)
if
(
!
init
)
this
.
mgr
.
evaluateHunk
(
this
)
}
else
{
status
.
set
(
'
bad await type
'
)
}
}
aType
.
onChange
=
(
value
)
=>
{
aType
.
set
(
value
)
setupAwait
()
}
this
.
init
=
()
=>
{
runState
.
set
(
false
)
setup
(
true
)
setupAwait
(
true
)
}
this
.
loop
=
()
=>
{
let
clear
=
0
for
(
let
op
of
this
.
outputs
)
{
if
(
!
op
.
io
())
clear
++
}
// have special rules for this,
if
(
startup
)
{
if
(
clear
)
{
// contact!
for
(
let
o
in
this
.
outputs
)
{
this
.
outputs
[
o
].
put
(
values
[
o
])
}
startup
=
false
}
}
else
if
(
runState
.
value
)
{
if
(
clear
&&
clear
>=
this
.
outputs
.
length
&&
this
.
inputs
[
0
].
io
())
{
// contact!
this
.
inputs
[
0
].
get
()
for
(
let
o
in
this
.
outputs
)
{
this
.
outputs
[
o
].
put
(
values
[
o
])
}
}
}
else
{
// not running, clear all gates regardless ...
if
(
this
.
inputs
[
0
].
io
()){
this
.
inputs
[
0
].
get
()
}
}
}
}
This diff is collapsed.
Click to expand it.
hunks/math/plusequals.js
+
7
−
3
View file @
7832cd0d
...
@@ -17,16 +17,16 @@ export default function PlusEquals() {
...
@@ -17,16 +17,16 @@ export default function PlusEquals() {
let
internalValue
=
0
let
internalValue
=
0
let
hasUpdate
=
false
let
hasUpdate
=
false
let
resetLine
=
new
Input
(
'
boolean
'
,
'
reset
'
,
this
)
let
input
=
new
Input
(
'
number
'
,
'
plus
'
,
this
)
let
input
=
new
Input
(
'
number
'
,
'
plus
'
,
this
)
this
.
inputs
.
push
(
input
)
this
.
inputs
.
push
(
resetLine
,
input
)
let
output
=
new
Output
(
'
number
'
,
'
result
'
,
this
)
let
output
=
new
Output
(
'
number
'
,
'
equals
'
,
this
)
this
.
outputs
.
push
(
output
)
this
.
outputs
.
push
(
output
)
let
reset
=
new
State
(
'
boolean
'
,
'
reset
'
,
false
)
let
reset
=
new
State
(
'
boolean
'
,
'
reset
'
,
false
)
reset
.
onChange
=
(
value
)
=>
{
reset
.
onChange
=
(
value
)
=>
{
internalValue
=
0
internalValue
=
0
hasUpdate
=
true
}
}
this
.
states
.
push
(
reset
)
this
.
states
.
push
(
reset
)
...
@@ -35,6 +35,10 @@ export default function PlusEquals() {
...
@@ -35,6 +35,10 @@ export default function PlusEquals() {
}
}
this
.
loop
=
()
=>
{
this
.
loop
=
()
=>
{
if
(
resetLine
.
io
()){
resetLine
.
get
()
internalValue
=
0
}
if
(
input
.
io
()){
if
(
input
.
io
()){
internalValue
+=
input
.
get
()
internalValue
+=
input
.
get
()
hasUpdate
=
true
hasUpdate
=
true
...
...
This diff is collapsed.
Click to expand it.
save/systems/dex-test-awaitingflow.json
0 → 100644
+
1208
−
0
View file @
7832cd0d
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment