namespace eval cryocon_sniffer {} {
}

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

  pollperiod 0.001 0.001

  obj CryoconSniffer rd
  prop read cryocon_sniffer::read
  prop rdcmd "INPUT A:SENPR?"
  prop path ""

  kids "cryocon" {
#    node tb upd
#    prop rdcmd "INPUT B:SENPR?"
    node l1 upd
    prop rdcmd "LOOP 1:OUTPWR?"
    node l2 upd
    prop rdcmd "LOOP 2:OUTPWR?"
  }
}

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

proc cryocon_sniffer::update {} {
  if {[sct result] eq [sct rdcmd]} {
    sct path [sct]
    return idle
  }  
  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]
    sct path ""
  }
  return idle
}
