Hi,
I've been attempting to create a wrapper library for the IXIA product.
Ixia only has TCL libraries.
I believe this issue is not specific to Tcl.
It seems to be a problem for me to call inline procs as via the object...
I've had to include wrapper routines to every proc - which seems incorrect -
I should be
able to simply call them with something like $obj->procRoutine() should I
not?
Here is the library (brief):
package Test::IXIA2;
use vars qw($self);
sub new {
my($class, %args) = @_;
my $self = bless {}, $class;
return $self;
}
sub setupIxiaEnvironment{
my($self)[EMAIL PROTECTED];
&_setupIxiaEnvironment();
}
sub connectToChassis{
my($self)[EMAIL PROTECTED];
&_connectToChassis();
}
sub _takeOwnership{
my($self)[EMAIL PROTECTED];
&_takeOwnership();
}
use Inline Tcl => <<END;
proc _setupIxiaEnvironment { } {
global env
global auto_path
set ixiaHome /home/regress/cfg/install/ixia
set ixiaVersion 4.10.250.18
lappend auto_path [file join \$ixiaHome "lib"]
set env(IXIA_HOME) /home/regress/cfg/install/ixia
set env(IXIA_VERSION) 4.10.250.18
set env(IXIA_TCL_DIR) [file join \$ixiaHome "lib"]
puts \$::env(IXIA_HOME)
puts \$::env(IXIA_VERSION)
puts \$::env(IXIA_TCL_DIR)
if { [catch {package require IxTclHal} res] != 0 } {
puts stderr "Can't load package IxTclHal: \$res"
return 1
}
return 0
}
proc _connectToChassis { } {
if { [ixConnectToTclServer 10.1.213.251] != 0 } {
puts "Failed to connect to Tcl Server at 10.1.213.251]"
return 1
}
if { [ixConnectToChassis 10.1.213.251] != 0 } {
puts "Failed to connect to Ixia at 10.1.213.251"
return 1
}
}
proc _takeOwnership { } {
if { [ixLogin testuser ] != 0 } {
puts "Failed to login testuser to Ixia "
return 1
}
puts "logged into ixia"
if { [ixTakeOwnership {{1 7 2}} "force"] != 0 } {
puts "Failed to take ownership of {{1 7 1}}"
return 1
}
if { [ixClearOwnership {{1 7 2}} ] != 0 } {
puts "Failed to clear ownership of {{1 7 2}} "
return 1
}
}
END
1;
And here is how I've tried to exercise it:
#!/usr/bin/perl -w
my $ixiaTest = new Test::IXIA2();
# When I try the following, which are direct calls to the procs - it does
not work
$ixiaTest->_setupIxiaEnvironment();
$ixiaTest->_connectToChassis();
$ixiaTest->_takeOwnership();
# When I use the wrapper routines - it does work
$ixiaTest->setupIxiaEnvironment();
$ixiaTest->connectToChassis();
$ixiaTest->takeOwnership();
exit 1;
How can I make the first instance work (do I have to pass a reference to
self into the procs?
Any help would be appreciated.
Thanks.