def test_AnalogInputNode_displayToHal(): node = AnalogInputNode() cal = [['hal_value', 'gui_value'], [0.0, 0.0], [10.0, 500.0]] node.calibrationTableData = cal node.setData(col.HAL_VALUE, 1.75) assert node.data(col.HAL_VALUE) == 1.75 assert node.displayToHal(node.value()) == 1.75
def test_AnalogInputNode_value(): node = AnalogInputNode() cal = [['hal_value', 'gui_value'], [0.0, 0.0], [10.0, 500.0]] node.calibrationTableData = cal node.setData(col.HAL_VALUE, 1.0) assert node.value() == 50 assert node.data(col.VALUE) == 50 node.setData(col.HAL_VALUE, 1.5) assert node.value() == 75 assert node.data(col.VALUE) == 75
def test_AnalogInputNode_calibrationTableData(): node = AnalogInputNode() good_cal = [['hal_value', 'gui_value'], [0.0, 0.0], [1.0, 12.4], [2, 24.8]] bad_cal = [['hal_value', 'gui_value'], [0.0, 0.0], [-1.0, 12.4], [2, 24.8]] node.calibrationTableData = good_cal assert node.calibrationTableData == good_cal node.calibrationTableData = bad_cal assert node.calibrationTableData == good_cal node.setData(col.HAL_VALUE, .12) assert node.value() == 1.488 assert node.data(col.VALUE) == 1.488
def test_AnalogInputNode_setData(): node = AnalogInputNode() cal = [['hal_value', 'gui_value'], [0.0, 0.0], [10.0, 500.0]] node.calibrationTableData = cal node.setData(col.HAL_VALUE, 1.5) node.setData(col.VALUE, "can't set this") node.setData(col.UNITS, 'mTorr') node.setData(col.DISPLAY_DIGITS, 5) node.setData(col.DISPLAY_SCIENTIFIC, True) node.setData(col.CALIBRATION_TABLE_MODEL, "can't set this") assert node.data(col.HAL_VALUE) == 1.5 assert node.data(col.VALUE) == 75 assert node.data(col.UNITS) == 'mTorr' assert node.data(col.DISPLAY_DIGITS) == 5 assert node.data(col.DISPLAY_SCIENTIFIC) == True assert type(node.data(col.CALIBRATION_TABLE_MODEL)) == type( CalibrationTableModel())