class Hp34401a def initialize(adrs=22) @gpib=Gpib::new(adrs) # @gpib.pad=(adrs); @gpib.sad=0; @gpib.tmo=Gpib::T1s # @gpib.open(0); sleep 0.1; #@gpib.ibclr @func=function?(); @range=0; @value=0; end attr_reader :func attr_reader :range attr_reader :value #attr_accessor : def reset() @gpib.write(sprintf("*RST")) end def function(str) strs=["VOLT:DC", "VOLT:DC:RAT", "VOLT:AC", "CURR:DC", "CURR:AC", "RES", "FRES", "FREQ", "PER", "CONT", "DIOD"] if strs.include?(str) @gpib.write(sprintf("FUNC \"%s\"",str)) @func=str else print "function is not good.\n" end end def function?() @gpib.write("FUNC?") s=@gpib.read(256) s.gsub!(/\"/){""} return s end def set_range(n) strs=[0.03, 0.3, 3, 30, 300, 3e3, 3e4, 3e5, 3e6, 3e7] if n.class==1.class @gpib.write(sprintf("#{@func}:RANG %.2e",strs[n])) @range=strs[n] else @gpib.write(sprintf("#{@func}:RANG:AUTO ON")) @range="auto" end end def set_resolution(str) if str=="min" @gpib.write(sprintf("#{@func}:RES MIN")) elsif str=="max" @gpib.write(sprintf("#{@func}:RES MAX")) else print "resolution is not good.\n" end end def impedence(str="on") if str=="on" @gpib.write(sprintf("INPUT:IMPEDENCE:AUTO ON")) else @gpib.write(sprintf("INPUT:IMPEDENCE:AUTO OFF")) end end def trigger(str) if str=="bus" @gpib.write(sprintf("trigger:source BUS")) elsif str=="now" @gpib.write(sprintf("trigger:source immediate")) elsif str=="ext" @gpib.write(sprintf("trigger:source external")) else print "resolution is not good.\n" end end def read?() @gpib.write("READ?") # @gpib.write("FETCh?") r=@gpib.read(256) @value=r.to_f return r.to_f end def count(n) # for one triger @gpib.write(sprintf("SAMPLE:COUNT %d",n)) end def initiate() # wait triger @gpib.write("INITIATE") end def points?() @gpib.write("DATA:POINTS?") r=@gpib.read(256) return r.to_i end def fetch?() @gpib.write("FETCh?") r=@gpib.read(256) @value=r.to_f return r.to_f end end #class