#============================================================ # DeviceObject #============================================================ package DeviceObject; use Common2; @ISA = qw(Common2); #公開したいサブルーチン @EXPORT = qw(); use strict; use Deps; #============================================================ # 一般関数 #============================================================ sub DeviceName { return shift->ModuleName(); } sub GetFunctions { my ($this) = @_; my $DeviceName = $this->DeviceName(); return "GetFunctions: Not implemented for [$DeviceName]"; } #============================================================ # コンストラクタ、デストラクタ #============================================================ sub new { my ($module, @args) = @_; my $this = {}; bless $this; return $this; } sub DESTROY { my $this = shift; $this->Finish(); } #============================================================ # 互換性維持関数 #============================================================ sub GetId { return shift->GetIdentification(); } sub SetDCCurrentMode { my ($this, $ZeroCheck) = @_; return $this->SetSourceDCCurrentMode(); } sub SetACCurrentMode { my ($this, $ZeroCheck) = @_; return $this->SetSourceACCurrentMode(); } sub SeADCVoltageMode { my ($this, $ZeroCheck) = @_; return $this->SetSourceACVoltageMode(); } sub SetDCVoltageMode { my ($this, $ZeroCheck) = @_; return $this->SetSourceDCVoltageMode(); } sub SetVSourceIMeasureMode { my ($this, $ZeroCheck) = @_; return $this->SetMeasureDCCurrentMode(); } sub SetISourceVMeasureMode { my ($this, $ZeroCheck) = @_; return $this->SetMeasureDCVoltageMode(); } sub ApplySource { my ($this, $mode) = @_; return $this->NotImplementedError("ApplySource"); } sub StopSource { my ($this) = @_; return $this->NotImplementedError("StopSource"); } sub SetSource { my ($this, $val) = @_; return $this->NotImplementedError("SetSource"); } sub SetSourceCurrent { my ($this, $I) = @_; return $this->SetISource($I); } sub SetCurrent { my ($this, $I) = @_; return $this->SetISource($I); } sub SetVoltage { my ($this, $V) = @_; retrun $this->SetVSource($V); } sub SetSourceVoltage { my ($this, $V) = @_; retrun $this->SetVSource($V); } sub SetAutoRangeForCurrent { my ($this, $f) = @_; # $f = 'ON' or 'OFF' return $this->NotImplementedError("SetAutoRangeForCurrent"); } sub SetAutoRangeForVoltage { my ($this, $f) = @_; # $f = 'ON' or 'OFF' return $this->NotImplementedError("SetAutoRangeForVoltage"); } sub SetCurrentLimit { my ($this, $limit) = @_; return $this->SetIMeasureLimit($limit); } sub SetVoltageLimit { my ($this, $limit) = @_; return $this->SetVMeasureLimit($limit); } #============================================================ # 一般関数 #============================================================ sub SetReadMode { my($this,$mode)=@_; return $this->{CommObject}->SetReadMode($mode); } sub ReadMode { return shift->{CommObject}->ReadMode(); } sub SetCommObject { my ($this, $comm) = @_; return $this->{CommObject} = $comm; } sub CommObject { return shift->{CommObject}; } sub read { my ($this, @args) = @_; #print "DeviceObject::read [$this->{CommObject}]\n"; return if(!defined $this->{CommObject}); return $this->{CommObject}->read(@args); } sub print { my ($this, @args) = @_; #print "args: ", join(',', @args), "\n"; return if(!defined $this->{CommObject}); return $this->{CommObject}->print(@args); } sub printf { my ($this, @args) = @_; return $this->{CommObject}->printf(@args); } sub NotImplementedError { my ($this, $FuncName) = @_; my $name = $this->DeviceName(); print "DeviceObject::$FuncName: This function is not implemented for [$name].\n"; return undef; } sub Initialize { my ($this) = @_; delete $this->{LastMeasureAveragedValue}; delete $this->{LastMeasuredValue}; delete $this->{VSourceLimit}; delete $this->{ISourceLimit}; delete $this->{VMeasureLimit}; delete $this->{IMeasureLimit}; delete $this->{PresentVoltage}; delete $this->{PresentCurrent}; $this->Clear(); $this->Reset(); $this->SetVSourceOutput("off"); $this->SetSourceVoltage(0.0); } sub Finish { my ($this) = @_; $this->SetVSourceOutput("off"); $this->SetSourceVoltage(0.0); $this->Initialize(); } sub Clear { my ($this) = @_; } sub Reset { my ($this) = @_; } sub PrintInfo { my ($this) = @_; print "Device Information:\n"; print " Comm : $this->{CommObject}\n"; print " Object : $this\n"; } sub GetIdentification { my ($this) = @_; $this->NotImplementedError("GetIdentification"); return "undefined"; } sub MeterConnect { my ($this, $f) = @_; # $f = 'on' or 'off' return $this->NotImplementedError("SetAutoRangeForCurrent"); } sub InitSource { my ($this) = @_; return $this->NotImplementedError("InitSource"); } sub SetISourceOutput { my ($this, $f) = @_; # $f = 'on' or 'off'; return $this->ApplySource($f); } sub SetVSourceOutput { my ($this, $f) = @_; # $f = 'on' or 'off'; return $this->ApplySource($f); } sub SetISource { my ($this, $I) = @_; return $this->NotImplementedError("SetISource"); # $this->{PresentCurrent} = $I; } sub SetVSource { my ($this, $V) = @_; return $this->NotImplementedError("SetVSource"); # $this->{PresentVoltage} = $V } sub SetZeroCheckDVM { my ($this, $mode) = @_; return $this->NotImplementedError("SetZeroCheckDVM"); } sub SetZeroCheckDCM { my ($this) = @_; return $this->NotImplementedError("SetZeroCheckDCM"); } sub SetCurrentRange { my ($this, $I) = @_; if(!defined $I or $I eq 'auto') { return $this->SetAutoRangeForCurrent(); } return $this->NotImplementedError("SetCurrentRange"); } sub SetISourceLimit { my ($this, $limit) = @_; return $this->NotImplementedError("SetISourceLimit"); # $this->{ISourceLimit} = $limit; } sub SetIMeasureLimit { my ($this, $limit) = @_; return $this->NotImplementedError("SetIMeasureLimit"); # $this->{IMeasureLimit} = $limit; } sub SetVoltageRange { my ($this, $V) = @_; if(!defined $V or $V eq 'auto') { return $this->SetAutoRangeForVoltage(); } return $this->NotImplementedError("SetVoltageRange"); } sub SetVMeasureLimit { my ($this, $limit) = @_; return $this->NotImplementedError("SetVMeasureLimit"); # $this->{VMeasureLimit} = $limit; } sub SetVSourceLimit { my ($this, $limit) = @_; return $this->NotImplementedError("SetVSourceLimit"); # $this->{VSourceLimit} = $limit; } sub SetSourceDCCurrentMode { my ($this, $ZeroCheck) = @_; return $this->NotImplementedError("SetSourceDCCurrentMode"); } sub SetMeasureDCCurrentMode { my ($this, $ZeroCheck) = @_; return $this->NotImplementedError("SetMeasureDCCurrentMode"); } sub SetSourceDCVoltageMode { my ($this, $ZeroCheck) = @_; return $this->NotImplementedError("SetSourceDCVoltageMode"); } sub SetMeasureDCVoltageMode { my ($this, $ZeroCheck) = @_; return $this->NotImplementedError("SetMeasureDCVoltageMode"); } sub SetIReference { my ($this, $f) = @_; return $this->NotImplementedError("SetIReference"); } sub SetVReference { my ($this, $f) = @_; return $this->NotImplementedError("SetVReference"); } sub Measure { my ($this) = @_; return $this->NotImplementedError("Measure"); # $this->{IMeasureLimit} = 1.0e-3 if($this->{IMeasureLimit} <= 0.0); #$this->{LastMeasuredValue} = ; } sub MeasureAveraged { my ($this, $nAverage) = @_; my $avrI = 0.0; for(my $i = 0 ; $i < $nAverage ; $i++) { #print "i=$i [$nAverage]\n"; my $I = $this->Measure(); $avrI += $I; } return $this->{LastMeasureAveragedValue} = $avrI / $nAverage; } 1;