# humidity chamber pressure reading (4-20 mA with taskit RS232 ADC)

namespace eval presshch {} {
}

proc stdConfig::presshch {} {
  controller std "\r" 5

  obj PressHumidityChamber rd
  prop readcmd ":0400000003.."
  prop update presshch::update
  
  kids Pressure {
    node calib_min par 848
    node calib_max par 1153
  }
}

proc presshch::update {} {
  if {[scan [sct result] ":0406%4x%4x%4x" a0 a1 a2] == 3} {
    get_values [sct] calib_min calib_max
    sct update [expr (($a2-$a0) * 25 / 65536. - 4) / 16. * ($calib_max - $calib_min) + $calib_min]
  } else {
    error "bad result: [sct result]"
  }
  return idle
}

