# HG changeset patch # User Heiko Schlittermann # Date 1230200615 -3600 # Node ID 352d5517f1f2f57add1b2e93cc01408b1ecc6e2f # Parent d32454497bebae815e12e27d8a8599af7d99d192 Added API proposal about tied arrays and scalars. And additionally I renamed the api proposal file. diff -r d32454497beb -r 352d5517f1f2 doc/api --- a/doc/api Wed Dec 24 23:45:16 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -What do we need? - -* outputs are addressed from 0..64 -* values for outputs are {"on", 1} or {"off", 0} - -* set/clear single outputs (set_bit?) - - # $state: "on", "off", 0, 1 - # $output: 0..63 - - set($state => $output, ...) - set($state => [$output, ...]) - - Examples - - # setting single outputs - set(on => 0, off => 1, on => 2, off => 3, ....., off => 7); - set(on => [0, 2], off => [1, 3 .. 7]); - - # alternate form of the above - set(1 => 0, 0 => 1, 1 => 2, 0 => 3, ...., 0 => 7); - set(1 => [0, 2], on => [1, 3 ... 7]); - - - # explicitly switch on - on(0, 2); - # .. or off single values - off(1, 3 ... 7); - -* read a single output (get_bit?) - - $result = get($output); - @result = get($output, ...); - - Examples - - $result = get(0); - @result = get(0 .. 7); - -* setting several outputs in a row (set_block, write_block?) - - # $block: 0 .. 7 - # $value: 8, 16, ... 64 bit integer - - # setting several outputs in a row, $output has to be - - write($value => $block); - - Examples - - write(0x05 => 0); - write(5 => 0); - -# get several outputs in a row (get_block, read_block?) - - $result = read(0, 8); # read 8 bit and return it as a number - - diff -r d32454497beb -r 352d5517f1f2 doc/api.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/api.txt Thu Dec 25 11:23:35 2008 +0100 @@ -0,0 +1,77 @@ +What do we need? + +* outputs are addressed from 0..64 +* values for outputs are {"on", 1} or {"off", 0} + +* set/clear single outputs (set_bit?) + + # $state: "on", "off", 0, 1 + # $output: 0..63 + + set($state => $output, ...) + set($state => [$output, ...]) + + Examples + + # setting single outputs + set(on => 0, off => 1, on => 2, off => 3, ....., off => 7); + set(on => [0, 2], off => [1, 3 .. 7]); + + # alternate form of the above + set(1 => 0, 0 => 1, 1 => 2, 0 => 3, ...., 0 => 7); + set(1 => [0, 2], on => [1, 3 ... 7]); + + + # explicitly switch on + on(0, 2); + # .. or off single values + off(1, 3 ... 7); + +* read a single output (get_bit?) + + $result = get($output); + @result = get($output, ...); + + Examples + + $result = get(0); + @result = get(0 .. 7); + +* setting several outputs in a row (set_block, write_block?) + + # $block: 0 .. 7 + # $value: 8, 16, ... 64 bit integer + + # setting several outputs in a row, $output has to be + + write($value => $block); + + Examples + + write(0x05 => 0); + write(5 => 0); + +# get several outputs in a row (get_block, read_block?) + + $result = read(0, 8); # read 8 bit and return it as a number + + +**** Other (or additional) proposal: + + + my @outputs; + tie @outputs => "Quancom" $ip_address; + # or: @outputs = Quancom::outputs($ip_address); + + $outputs[0] = 1; + @outputs = (1, 0, 1, 0, 0, 0); + + my $block0; + tie $block => "Quancom" $ip_address, $block, $len; + # or: $block = Quancom::block($ip_address, $block, $len); + + $block = 0xFF; + + + +