class Tc def initialize(type="K",rtmp=0) text=open("tc%s.dat"%(type.downcase)){|f| f.read} @tv=text.split(/\n/).collect{|l| l.split(/\s*,\s*/).collect{|t| t.to_f}} @tv.shift @rt=rtmp @rv=0 room() end def room(deg=@rt) @rt=deg @rv=volt(@rt) end def temp(vlt) vlt=(vlt+@rv)*1000 for i in 0...@tv.size break if @tv[i][1]>=vlt end i=1 if i==0 bv=@tv[i-1][1] av=@tv[i][1] bt=@tv[i-1][0] at=@tv[i][0] t=bt+(at-bt)*(vlt-bv)/(av-bv) return t end def volt(tmp) for i in 0...@tv.size break if @tv[i][0]>=tmp end i=1 if i==0 bv=@tv[i-1][1] av=@tv[i][1] bt=@tv[i-1][0] at=@tv[i][0] v=bv+(av-bv)*(tmp-bt)/(at-bt) return v/1000-@rv end end #class