namespace eval ihelium3_cryocon {} {
}

proc stdConfig::ihelium3_cryocon {} {
  controller std "\n" 5

  pollperiod 0.001 0.001

  obj CryoconSniffer rd
  prop read ihelium3_cryocon::read
  prop path ""

  kids "cryocon" {
#    node tb upd
#    prop rdcmd "INPUT B:SENPR?"
    node ra upd
    prop rdcmd "INPUT A:SENPR?"
    prop sensno 054
    
    node l1 upd
    prop rdcmd "LOOP 1:OUTPWR?"
    node l2 upd
    prop rdcmd "LOOP 2:OUTPWR?"
    
    node bref par 0
    
  }
}

proc ihelium3_cryocon::read {} {
  sct send "@@NOSEND@@"
  return ihelium3_cryocon::update
}

proc ihelium3_cryocon::update {} {
  foreach var [hlist [sct]] {
    if {[sct result] eq [silent "" hgetpropval [sct]/$var rdcmd]} {
      sct path [sct]/$var
      return idle
    }
  }
  if {[sct path] ne ""} {
    updateval [sct path] [sct result]
    set sensno [silent "" hgetpropval [sct path] sensno]
    sct path ""
    if {$sensno ne ""} {
      if {![silent 0 sct $sensno]} {
        ihelium3_calib $sensno
        sct $sensno 1
      }
      set tk [ihelium3_res2temp $sensno [hvali [sct]/bref] [sct result]]
      sct update $tk
    }
  }
  return idle
}
