Package joy :: Module plans :: Class SheetPlan
[hide private]
[frames] | no frames]

Class SheetPlan

source code


concrete class SheetPlan implements a Plan that is read from a "sheet" -- a rectangular list-of-lists containing a spreadsheet specifying the planned settings as a function of time.

Sheets can be read from a file using loadCSV(), or from an inline multiline string using inlineCSV()

The first row of the sheet consists of string headings, starting with the heading "t" (for time). Remaining headings specify bindings to properties the Plan should set.

By default, the column headings will get automatically converted into a binding using the format <<heading>>/@set_pos which means that columns are assumed to be names of modules whose position is to be set. WARNING: this default behavior is disabled if ANY bindings are passed to the constructor.

The first column of the sheet (2nd row an on) MUST consist of numbers in increasing order specifying the times at which the settings in that row should be applied.

Empty elements in the sheet (None-s) are skipped.

If no column bindings are provided, column headings are assumed to be module names of servo modules and each of these is bound to <<module>>/@set_pos of the corresponding module. For example, the sheet: >>> sheet = [ ... ["t", "Nx15"], ... [0, 1000], ... [0.5, -1000] ] will generate a +/- 10 degree step into the position of node 0x15

Instance Methods [hide private]
 
__init__(self, app, sheet, *arg, **kw)
Initialize a Plan within some JoyApp application.
source code
 
update(self, sheet, **kw)
Update the sheet specifying the Plan.
source code
 
_autoBinding(self, sheet, fmt="%s/@set_pos")
(private)
source code
 
setRate(self, rate)
Set rate at which sheet should be executed, e.g.
source code
 
getRate(self) source code
 
_doRowSets(self, row)
(private)
source code
 
_parseSheet(self, sheet)
(private)
source code
 
behavior(self)
(final)
source code

Inherited from Plan: forDuration, isRunning, onEvent, onStart, onStop, push, start, step, stop, untilTime

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, app, sheet, *arg, **kw)
(Constructor)

source code 

Initialize a Plan within some JoyApp application.

Overrides: object.__init__
(inherited documentation)

update(self, sheet, **kw)

source code 

Update the sheet specifying the Plan.

NOTE: if the new sheet has different bindings form the old one, Weird Things Will Happen!

_autoBinding(self, sheet, fmt="%s/@set_pos")

source code 

(private)

Given a sheet, automatically treat the column heads as servo module names for which positions must be set

setRate(self, rate)

source code 

Set rate at which sheet should be executed, e.g. rate=2 means execute twice as fast

Only positive rates are allowed. Rate cannot be changed while the Plan isRunning()

_doRowSets(self, row)

source code 

(private)

Perform the set operations associated with a row

_parseSheet(self, sheet)

source code 

(private)

Make sure that the sheet is syntactically correct

OUTPUT: setters, headings, sheet

behavior(self)

source code 

(final)

The behavior of a SheetPlan is defined relative to the Plan's start time and rate. The plan goes down the sheet row by row in the specified rate, sleeping until it is ready to apply the settings in that row.

Once the settings of the final row are applied, the Plan terminates.

The 't' debug topic can be used to display SheetPlan timesteps

Overrides: Plan.behavior