Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change program id to "tag-$id" #151

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions virtual-programs/programs.folk
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@


When (non-capturing) /type/ /obj/ has a program {
puts "Added $type $obj"
On unmatch { puts "Removed $type $obj" }
When (non-capturing) /obj/ has a program {
puts "Added $obj"
On unmatch { puts "Removed $obj" }

# Backwards compatibility
if {[regexp {tag-(\d+)} $obj -> id]} {
set fname $id
} else {
set fname $obj
}

try {
if {[file exists "$::env(HOME)/folk-printed-programs/$obj.folk.temp"]} {
set fd [open "$::env(HOME)/folk-printed-programs/$obj.folk.temp" r]
if {[file exists "$::env(HOME)/folk-printed-programs/$fname.folk.temp"]} {
set fd [open "$::env(HOME)/folk-printed-programs/$fname.folk.temp" r]
} else {
# HACK: localhost is folk-live for now. idk why.
if {![file exists "$::env(HOME)/folk-printed-programs/$obj.folk"] &&
if {![file exists "$::env(HOME)/folk-printed-programs/$fname.folk"] &&
($::thisNode in [list "folk-beads" "folk-convivial" "localhost" "gadget-red" "gadget-blue"])} {
# HACK: 'Page fault' to folk0, try getting page from
# there. Ideally we would have some general (Avahi?)
# way of finding the 'authoritative' node on the local
# network, or broadcasting out, and getting pages from
# there.
exec curl --output "$::env(HOME)/folk-printed-programs/$obj.folk" \
"http://folk0.local:4273/printed-programs/$obj.folk"
exec curl --output "$::env(HOME)/folk-printed-programs/$fname.folk" \
"http://folk0.local:4273/printed-programs/$fname.folk"
}
set fd [open "$::env(HOME)/folk-printed-programs/$obj.folk" r]
set fd [open "$::env(HOME)/folk-printed-programs/$fname.folk" r]
}
set code [read $fd]
close $fd

Claim $obj has program code $code
} on error error {
puts stderr "No code for $type $obj"
puts stderr "No code for $obj"
Claim $obj has program code ""
}
}

Expand Down
7 changes: 4 additions & 3 deletions virtual-programs/tags-and-calibration.folk
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ When (non-capturing) tag /tag/ has corners /corners/ {
set angle [expr {atan2(-[lindex $vecBottom 1], [lindex $vecBottom 0])}]
set region [region create $corners $edges $angle]

Claim $tag has region $region
Claim tag $tag has a program
Claim tag $tag is a tag
set id "tag-$tag"
Claim $id is a tag
Claim $id has region $region
Claim $id has a program
}