class Ppms def initialize(adrs=15) @gpib=Gpib::new @gpib.pad=(adrs); @gpib.sad=0; @gpib.tmo=Gpib::T1s @gpib.open(0); sleep 0.1; @gpib.ibclr @gpib.write("*CLS") @temp,@field,@pres,@status=0,0,0,0 read_data @temp_set,@temp_rate,@temp_cond=read_temp @field_set,@field_rate,@field_cond,@field_mode=read_field @level;read_level end attr_reader :temp attr_reader :field attr_reader :pres attr_reader :status attr_reader :temp_set attr_reader :temp_rate attr_reader :temp_cond attr_reader :field_set attr_reader :field_rate attr_reader :field_cond attr_reader :field_mode attr_reader :level #attr_accessor : # constants Status_temp=["unknown","normal stability","stable","","","tolerance","not valid","filling","","","standby","","","disable","incomplete","failure"] Status_field=["unknown","persistent","warming","cooling","stable","approach","charging","discharging","error","","","","","","","failure"] Status_chamber=["unknown","purge/seal","vent/seal","seal","under purge/seal","under vent/seal","","","pumping","flooding","","","","","","failure"] Cond_temp=["fast settle","no overshoot"] Cond_field=["linear","no overshoot","oscillate"] Mode_field=["persistent","driven"] Chamber_operation=["seal immediately","purge and seal","vent and seal","pump continuously","vent continuously"] # set environment def set_temp(tmp,rt=@temp_rate,cnd=@temp_cond) # K,K/min #Cond_temp=["fast settle","no overshoot"] @temp_set=tmp; @temp_rate=rt; @temp_cond=cnd @gpib.write(sprintf "TEMP %.2f %.1f %d",tmp,rt,cnd) end def set_field(fld,rt=@field_rate,cnd=@field_cond,md=@field_mode) # Oe,Oe/sec #Cond_field=["linear","no overshoot","oscillate"] #Mode_field=["persistent","driven"] @field_set=fld; @field_rate=rt; @field_cond=cnd; @field_mode=md @gpib.write(sprintf "FIELD %.2f %.1f %d %d",fld,rt,cnd,md) # persistent,driven end def shutdown() @gpib.write(sprintf "SHUTDOWN") end # read settings def read_temp @gpib.write("TEMP?") return @gpib.read(256).split(/\s*,\s*/).collect{|e| e.to_f}[0..2] end def read_field @gpib.write("FIELD?") return @gpib.read(256).split(/\s*,\s*/).collect{|e| e.to_f}[0..2] end def read_level @gpib.write("LEVEL?") @level=@gpib.read(256).to_f return @level end # read present conditions def read_data # 0:status,1:temp,2:field,19:pressure flg=2**0+2**1+2**2+2**19 @gpib.write("GETDAT? #{flg}") str=@gpib.read(256).split(/\s*,\s*/) num=str[2].to_i @temp=str[3].to_f @field=str[4].to_f @pres=str[5].to_f # @status="temp:"+Status_temp[num & 0xf]+",field:"+Status_field[num>>4 & 0xf]+",chamber:"+Status_chamber[num>>8 & 0xf] @status={ "temp"=>Status_temp[num & 0xf], "field"=>Status_field[num>>4 & 0xf], "chamber"=>Status_chamber[num>>8 & 0xf], } end # chamber operation def chamber(num) #Chamber_operation=["seal immediately","purge and seal","vent and seal","pump continuously","vent continuously"] @gpib.write("CHAMBER #{num}") end end # class