diff options
author | etienne | 2003-05-07 15:37:23 +0000 |
---|---|---|
committer | etienne | 2003-05-07 15:37:23 +0000 |
commit | b668e7873d9ffcecbbd848c5a388dba0bf2e77ac (patch) | |
tree | 32b1a80be3647a424234f4013d13a49a73a3aaa0 /src/IvyIO.pm | |
parent | 23abb4b87c7e40ed259dd02f653516f60e55ade4 (diff) | |
download | ivycontrolpanel-b668e7873d9ffcecbbd848c5a388dba0bf2e77ac.zip ivycontrolpanel-b668e7873d9ffcecbbd848c5a388dba0bf2e77ac.tar.gz ivycontrolpanel-b668e7873d9ffcecbbd848c5a388dba0bf2e77ac.tar.bz2 ivycontrolpanel-b668e7873d9ffcecbbd848c5a388dba0bf2e77ac.tar.xz |
Initial revision
Diffstat (limited to 'src/IvyIO.pm')
-rw-r--r-- | src/IvyIO.pm | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/IvyIO.pm b/src/IvyIO.pm new file mode 100644 index 0000000..8283a02 --- /dev/null +++ b/src/IvyIO.pm @@ -0,0 +1,114 @@ +package IvyIO; + +use strict; +use Ivy; + + +my $ivy; + +# init an ivy bus +sub init { + my ($appname, $bus, $conncb, $disconncb) = @_; + Ivy->init(-loopMode => 'TK', + -appName => $appname, + -ivyBus => $bus, + ); + $ivy = Ivy->new(-statusFunc => sub {&_status($conncb, $disconncb, @_);}); + $ivy->start; + +} # end init + +# kill a named agent +sub kill { + my $appname = shift; + $ivy->sendDieTo($appname); + +} # end kill + + +sub _status { + my ($conncb, $disconncb, $ref_array_present, $ref_array_absent, + $ref_hash_present, $agent, $status, $host) = @_; + if ($status eq "new") { + &$conncb($agent, $host); + } elsif ($status eq "died") { + &$disconncb($agent, $host); + } + +} # end _status + +#------------------------------------------------------------------------ +# +# output +# +#------------------------------------------------------------------------ + +sub send_rate { + my ($rate) = shift; + return unless $ivy; + $ivy->sendMsgs("SetClock Rate=$rate"); + +} # end ivy_send_rate + + +sub send_time { + my ($time) = shift; + return unless $ivy; + $ivy->sendMsgs("SetClock Time=$time"); + +} # end send_time + + +sub send_pause { + return unless $ivy; + $ivy->sendMsgs("ClockStop"); + +} # end send_pause + + +sub send_play { + return unless $ivy; + $ivy->sendMsgs("ClockStart"); + +} # end send_play_command + + +#------------------------------------------------------------------------ +# +# input +# +#------------------------------------------------------------------------ + +sub bind_for_play_event { + my $cb = shift; + return unless $cb; + return unless $ivy; + $ivy->bindRegexp("ClockStart", [sub { shift; &$cb(); }]); + +} # end bind_for_play_event + + +sub bind_for_pause_event { + my $cb = shift; + return unless $cb; + return unless $ivy; + $ivy->bindRegexp("ClockStop", [sub { shift; &$cb(); }]); + + +} # end bind_for_pause_event + + +# execute the callback with arguments <time> and <rate> +sub bind_for_clock_and_rate_event { + my $cb = shift; + return unless $cb; + return unless $ivy; + $ivy->bindRegexp('ClockEvent Time=(\d\d):(\d\d):(\d\d) Rate=(.*) Bs=.*', + [sub { shift; &$cb(@_); }]); + $ivy->bindRegexp('ClockDatas Time=(\d\d):(\d\d):(\d\d) Rate=(.*) Bs=.*', + [sub { shift; &$cb(@_); }]); + +} # end bind_for_clock_event + + +1; |