[PEAK] External connectors now in Trellis SVN

Phillip J. Eby pje at telecommunity.com
Thu Mar 20 15:25:46 EDT 2008


An experimental version of the Sensor and Effector cell classes is 
now available in Trellis SVN.  There are no docs besides the 
docstrings, and relatively few tests, but they appear to work correctly now.

The simplest way to create an external connection cell is to pass a 
trellis.Connector() as the "rule" of a cell.  For example:

    someattr = trellis.rule(
        trellis.Connector(readfunc,connect,disconnect)
    )

Where readfunc is a 0-argument callable returning a value from the 
external system, connect is a 1-argument callable taking a Sensor 
whose .receive() method should be called with a value whenever the 
external system value changes, and disconnect is a 1-argument 
callable that will take the return value of connect() and stop 
issuing callbacks to the sensor's .receive() method.

This doesn't support write-backs to the external system; you can 
manually create a "Cell(..., writer=writefunc)", however, and 
writefunc() will be called whenever the cell value is changed by 
*setting* it (as opposed to recalculating it).  Currently, the 
writefunc is called during the "observer" (soon to be called 
"performer") transaction phase, meaning it can't change other trellis 
data (because of course, it's intended to write to external systems).

All this stuff is experimental at this point, meaning the APIs might 
change.  Feedback is welcome!




More information about the PEAK mailing list