#============================================================ # GPIBDevice #============================================================ package Device; #use Exporter; #use MyGPIB::GPIBDeviceObject; #@ISA = qw(Exporter GPIBDeviceObject); #公開したいサブルーチン @EXPORT = qw(); use lib 'd:/Program/Perl/lib'; use lib 'd:/Program/Perl/lib2.0'; use lib '.'; use strict; use Deps; use Common2; use MyGPIB::GPIBDevice; use MyGPIB::RS232C; #============================================================ # コンストラクタ、デストラクタ #============================================================ sub new { my ($module, @args) = @_; $this = {}; bless $this; Common2::ReadKeyedArgs($this, @args); my $dev; if($this->{Port} =~ /GPIB(\d+)/i) { $this->{GPIBInterface} = 'ni' if(!defined $this->{GPIBInterface}); $this->{GPIBTimeOut} = GPIB->T1s if(!defined $this->{GPIBTimeOut}); $this->{GPIBEOT} = 1 if(!defined $this->{GPIBEOT}); $this->{GPIBEOT} = 1 if(!defined $this->{GPIBEOS}); $dev = new GPIBDevice($this->{GPIBInterface}, $this->{DeviceName}, $this->{GPIBTimeOut}, $this->{GPIBEOT}, $this->{GPIBEOT}, $this->{GPIBEOS}); if(!defined $dev) { $App->print("Error in Device::new: GPIB can not be opened. " ."[$this->{Port}: $this->{GPIBInterface}: $this->{DeviceName}]\n"); return undef; } } elsif($this->{Port} =~ /(COM\d+)/i) { $dev = new RS232C(); my ret = $com->Open($this->{ConfFile}, $this->{COMPort}, $this->{BaudRate}, $this->{Parity}, $this->{DataBits}, $this->{StopBits}, $this->{HandShake}); if(!$ret) { $App->print("Error in Device::new: COMPort can not be opened. " ."[$this->{Port}: $this->{DeviceName}]\n"); return undef; } } else { $App->print("Error in Device::new: Invalid Port [$this->{Port}]\n"); return undef; } Common2::ReadKeyedArgs($dev, @args); return $dev; } sub DESTROY { my $this = shift; } 1;