#============================================================ # Laserstar3APLS #============================================================ package Laserstar3APLS; use Device::DeviceObject; @ISA = qw(DeviceObject); #公開したいサブルーチン @EXPORT = qw(); use strict; use Deps; #============================================================ # コンストラクタ、デストラクタ #============================================================ BEGIN { } sub new { my ($module, @args) = @_; my $this = {}; bless $this; $this->{Mode} = 'Power'; return $this; } sub DESTROY { my $this = shift; $this->Finish(); } #============================================================ # 変数取得関数 #============================================================ sub GetFunctions { return "|LightPower|"; } #============================================================ # 一般関数 #============================================================ sub Initialize { my ($this) = @_; } sub Finish { my ($this) = @_; } sub GetId { my ($this) = @_; $this->print('$II?' . "\n"); } sub SendPower { my ($this) = @_; $this->print('$SP' . "\n"); return $this->read(); } sub SendEnergy { my ($this) = @_; $this->print('$SE' . "\n"); return $this->read(); } sub SendFrequency { my ($this) = @_; $this->print('SF' . "\n"); $this->{Mode} = 'Frequency'; $this->read(); } sub Measure { my($this, $wavelength) = @_; $wavelength = 0 if(!defined $wavelength); $this->SetWavelength($wavelength); my $ret; if($this->{Mode} =~ /power/i) { $ret = $this->SendPower(); } elsif($this->{Mode} =~ /energy/i) { $ret = $this->SendEnergy(); } else { return "Invalid Mode\n"; } Utils::DelSpace($ret); if($ret =~ /^\s*\*\s*(.*)$/) { return $1; } else { return "Data not measured [$ret]\n"; } } sub SetPowerMode { my ($this) = @_; $this->print('$FP' . "\n"); $this->{Mode} = 'Power'; $this->read(); } sub SetEnergyMode { my ($this) = @_; $this->print('$FE' . "\n"); $this->{Mode} = 'Energy'; $this->read(); } sub ChangeChannel { my ($this, $ch) = @_; # $ch = 'A' or 'B' $this->print('$CH ' . "$ch\n"); $this->read(); } sub SetRange { # $iRange: 0: The highest power 1: The second to heist 2: etc: next # -1: Auto -2: dBm my ($this, $iRange) = @_; $iRange = -1 if($iRange =~ /auto/i); $iRange = -2 if($iRange =~ /dbm/i); $this->print('$WN ' . "$iRange\n"); $this->read(); } sub SetWavelength { my ($this, $wavelength) = @_; if(!defined $this->{CurrentWavelength}) { print "SetWavelength($wavelength)\n"; if($wavelength <= 800) { $this->print('$WW <800' . "\n"); $this->read(); } else { $this->print('$WW >800' . "\n"); $this->read(); } $this->{CurrentWavelength} = $wavelength; } elsif($this->{CurrentWavelength} <= 800 and $wavelength <= 800) { } elsif($this->{CurrentWavelength} > 800 and $wavelength > 800) { } else { print "SetWavelength($wavelength)\n"; if($wavelength <= 800) { $this->print('$WW <800' . "\n"); $this->read(); } else { $this->print('$WW >800' . "\n"); $this->read(); } $this->{CurrentWavelength} = $wavelength; } } sub GetWavelengthSettings { my ($this) = @_; $this->print('$AW ?' . "\n"); return $this->read(); } sub ShowInformations { my ($this) = @_; $this->print('$BC' . "\n"); my $ret = "Battery condition: " . $this->read(); $this->print('$RN' . "\n"); $ret .= "Range now: " . $this->read(); $this->print('$VE' . "\n"); $ret .= "Software version: " . $this->read(); $this->print('$AR' . "\n"); $ret .= "All ranges: " . $this->read(); $this->print('$CR' . "\n"); $ret .= "Read channel: " . $this->read(); $this->print('$DQ' . "\n"); $ret .= "Diffuser query: " . $this->read(); $this->print('$HI' . "\n"); $ret .= "Head information: " . $this->read(); $this->print('$HT' . "\n"); $ret .= "Head type: " . $this->read(); $this->print('$II' . "\n"); $ret .= "Instrument information: " . $this->read(); $this->print('$SI' . "\n"); $ret .= "Send units: " . $this->read(); return $ret; } 1;