summaryrefslogtreecommitdiff
path: root/xpp/utils/zconf/Zaptel/Xpp
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/utils/zconf/Zaptel/Xpp')
-rw-r--r--xpp/utils/zconf/Zaptel/Xpp/Xbus.pm36
-rw-r--r--xpp/utils/zconf/Zaptel/Xpp/Xpd.pm31
2 files changed, 64 insertions, 3 deletions
diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
index 8d9d340..772e050 100644
--- a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
+++ b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
@@ -5,12 +5,15 @@ package Zaptel::Xpp::Xbus;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
use Zaptel::Xpp::Xpd;
my $proc_base = "/proc/xpp";
# Accessors (miniperl does not have Class:Accessor)
+our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = uc($AUTOLOAD);
@@ -27,9 +30,37 @@ sub xpds($) {
return @{$xbus->{XPDS}};
}
+sub by_number($) {
+ my $busnumber = shift;
+ die "Missing xbus number parameter" unless defined $busnumber;
+ my @xbuses = Zaptel::Xpp::xbuses();
+
+ my ($xbus) = grep { $_->num == $busnumber } @xbuses;
+ return $xbus;
+}
+
+sub get_xpd_by_number($$) {
+ my $xbus = shift;
+ my $xpdnum = shift;
+ die "Missing XPD number parameter" unless defined $xpdnum;
+ my @xpds = $xbus->xpds;
+ return $xpds[$xpdnum];
+}
+
sub new($$) {
my $pack = shift or die "Wasn't called as a class method\n";
- my $self = { @_ };
+ my $self = {};
+ while(@_) {
+ my ($k, $v) = @_;
+ shift; shift;
+ # Keys in all caps
+ $k = uc($k);
+ # Some values are in all caps as well
+ if($k =~ /^(STATUS)$/) {
+ $v = uc($v);
+ }
+ $self->{$k} = $v;
+ }
bless $self, $pack;
$self->{NAME} or die "Missing xbus name";
my $prefix = "$proc_base/" . $self->{NAME};
@@ -45,6 +76,7 @@ sub new($$) {
);
push(@{$self->{XPDS}}, $xpd);
}
+ @{$self->{XPDS}} = sort { $a->num <=> $b->num } @{$self->{XPDS}};
return $self;
}
diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
index 180b7ea..94176b8 100644
--- a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
+++ b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
@@ -5,11 +5,14 @@ package Zaptel::Xpp::Xpd;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
my $proc_base = "/proc/xpp";
# Accessors (miniperl does not have Class:Accessor)
+our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = uc($AUTOLOAD);
@@ -21,6 +24,32 @@ sub AUTOLOAD {
}
}
+sub blink($$) {
+ my $self = shift;
+ my $on = shift;
+ my $result;
+
+ my $file = "$proc_base/" . $self->fqn . "/blink";
+ die "$file is missing" unless -f $file;
+ # First query
+ open(F, "$file") or die "Failed to open $file for reading: $!";
+ $result = <F>;
+ chomp $result;
+ close F;
+ if(defined($on) and $on ne $result) { # Now change
+ open(F, ">$file") or die "Failed to open $file for writing: $!";
+ print F ($on)?"1":"0";
+ if(!close(F)) {
+ if($! == 17) { # EEXISTS
+ # good
+ } else {
+ undef $result;
+ }
+ }
+ }
+ return $result;
+}
+
sub zt_registration($$) {
my $self = shift;
my $on = shift;