A screen shot from the Mongoose 2000 project, we now have most of the ‘pup focal’ interfaces working and syncing their data via the Raspberry Pi. This is the interface for recording a pup aggression event – including the identity of the aggressive mongoose and some information on the cause and severity. Each mongoose has a code, and we’re using sliding toggle button interfaces for quickly picking them – these can be filtered to restrict them to adults, pups, males or females where required.

The interface was written using “starwisp” – my system for building android applications in Scheme. The Mongoose 2000 app has lots of reusable interfaces, so it’s mostly constructed from fragments. There are no specialised database tables, so I can simply add or modify the widgets here and the data automagically appears in the Raspberry Pi export, which makes it very fast to build. I’ve abstracted the mongoose button grid selectors and tristate buttons (yes/no/maybe) as they are used in a lot of places. Here is the entire definition of the fragment for the interface above, the code includes everything for creating and recording the database entity for this event and all the android callbacks it needs to respond to external events.
(fragment
"ev-pupaggr"
;; define the interface layout first
(linear-layout
(make-id "") 'vertical fillwrap pf-col
(list
(mtitle "title" "Event: Pup aggression")
(build-grid-selector "pf-pupaggr-partner"
"single" "Aggressive mongoose")
(linear-layout
(make-id "") 'horizontal
(layout 'fill-parent 100 '1 'left 0) trans-col
(list
(vert
(mtext "" "Fighting over")
(spinner (make-id "pf-pupaggr-over")
(list "Food" "Escort" "Nothing" "Other") fillwrap
(lambda (v)
(entity-add-value! "over" "varchar" v) '())))
(vert
(mtext "" "Level")
(spinner (make-id "pf-pupaggr-level")
(list "Block" "Snap" "Chase" "Push" "Fight") fillwrap
(lambda (v)
(entity-add-value! "level" "varchar" v) '())))
(tri-state "pf-pupaggr-in" "Initiate?" "initiate")
(tri-state "pf-pupaggr-win" "Win?" "win")))
(spacer 20)
(horiz
(mbutton "pf-pupaggr-done" "Done"
(lambda ()
(entity-add-value! "parent" "varchar"
(get-current 'pup-focal-id ""))
(entity-record-values db "stream" "pup-focal-pupaggr")
(list (replace-fragment (get-id "event-holder")
"events"))))
(mbutton "pf-pupaggr-cancel" "Cancel"
(lambda ()
(list (replace-fragment (get-id "event-holder")
"events")))))))
;; define the fragment's event callbacks
(lambda (fragment arg) ;; on create, return layout for building
(activity-layout fragment))
;; on start - update contents from the db
(lambda (fragment arg)
(entity-reset!)
(list
(populate-grid-selector
"pf-pupaggr-partner" "single" ;; select single mongoose
(db-mongooses-by-pack) #t ;; from the whole pack
(lambda (individual) ;; <- called when selected
(entity-add-value! "id-with" "varchar"
(ktv-get individual "unique_id"))
(list)))
))
(lambda (fragment) '()) ;; on stop
(lambda (fragment) '()) ;; on resume
(lambda (fragment) '()) ;; on pause
(lambda (fragment) '())) ;; on destroy