|
|
|
@ -13,8 +13,10 @@ import com.yinuo.safetywatcher.watcher.base.NoOptionsActivity
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.GasCache
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.GasPortUtils
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.ParseHelper
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.UNIT_LEL
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.UNIT_MGM3
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.UNIT_PPM
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.UNIT_VOL
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CH4_H2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.O2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.VOCS
|
|
|
|
@ -48,32 +50,38 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
gasName = intent.getStringExtra("GasType")!!
|
|
|
|
|
sensorIndex = intent.getIntExtra("index", -1)
|
|
|
|
|
val localGasUnit = getLocalGasUnit(gasName)
|
|
|
|
|
// 氧气单位固定
|
|
|
|
|
if (gasName == O2) {
|
|
|
|
|
mBinding.rgUnit.visibility = View.GONE
|
|
|
|
|
mBinding.rbLel.visibility = View.GONE
|
|
|
|
|
mBinding.rbVol.visibility = View.VISIBLE
|
|
|
|
|
// // 氧气单位固定
|
|
|
|
|
// if (gasName == O2) {
|
|
|
|
|
// mBinding.rgUnit.visibility = View.GONE
|
|
|
|
|
// mBinding.rbLel.visibility = View.GONE
|
|
|
|
|
// mBinding.rbVol.visibility = View.VISIBLE
|
|
|
|
|
// showRbView = mBinding.rbVol
|
|
|
|
|
// } else if (gasName == CH4_H2) {
|
|
|
|
|
// mBinding.rgUnit.visibility = View.GONE
|
|
|
|
|
// mBinding.rbVol.visibility = View.GONE
|
|
|
|
|
// mBinding.rbLel.visibility = View.VISIBLE
|
|
|
|
|
// showRbView = mBinding.rbLel
|
|
|
|
|
// } else {
|
|
|
|
|
mBinding.rgUnit.visibility = View.VISIBLE
|
|
|
|
|
// mBinding.rbVol.visibility = View.GONE
|
|
|
|
|
// mBinding.rbLel.visibility = View.GONE
|
|
|
|
|
// if (gasName == VOCS) {
|
|
|
|
|
// mBinding.rbMgm3.visibility = View.GONE
|
|
|
|
|
// }
|
|
|
|
|
if (localGasUnit == UNIT_PPM) {
|
|
|
|
|
mBinding.rbPpm.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbPpm
|
|
|
|
|
} else if (localGasUnit == UNIT_VOL) {
|
|
|
|
|
mBinding.rbVol.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbVol
|
|
|
|
|
} else if (gasName == CH4_H2) {
|
|
|
|
|
mBinding.rgUnit.visibility = View.GONE
|
|
|
|
|
mBinding.rbVol.visibility = View.GONE
|
|
|
|
|
mBinding.rbLel.visibility = View.VISIBLE
|
|
|
|
|
} else if (localGasUnit == UNIT_LEL) {
|
|
|
|
|
mBinding.rbLel.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbLel
|
|
|
|
|
} else {
|
|
|
|
|
mBinding.rgUnit.visibility = View.VISIBLE
|
|
|
|
|
mBinding.rbVol.visibility = View.GONE
|
|
|
|
|
mBinding.rbLel.visibility = View.GONE
|
|
|
|
|
if (gasName == VOCS) {
|
|
|
|
|
mBinding.rbMgm3.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
if (localGasUnit == UNIT_PPM) {
|
|
|
|
|
mBinding.rbPpm.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbPpm
|
|
|
|
|
} else {
|
|
|
|
|
mBinding.rbMgm3.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbMgm3
|
|
|
|
|
}
|
|
|
|
|
mBinding.rbMgm3.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbMgm3
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 昵称和量程
|
|
|
|
|
lifecycleScope.launch(Dispatchers.IO) {
|
|
|
|
@ -88,7 +96,7 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
}
|
|
|
|
|
val gasRange = ParseHelper.getGasRangeMax(gasName)
|
|
|
|
|
// mBinding.etStep.text = getString(R.string.sensor_step_txt).plus(": $gasRange")
|
|
|
|
|
mBinding.etStep.hint = "最大量程:$gasRange $localGasUnit"
|
|
|
|
|
mBinding.etStep.hint = "量程:$gasRange $localGasUnit"
|
|
|
|
|
mBinding.etGasName.hint = "气体名称:$gasNickName"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -257,18 +265,23 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
if (rangeStr.isNotEmpty()) {
|
|
|
|
|
val toInt = rangeStr.toInt()
|
|
|
|
|
if (toInt <= 0) {
|
|
|
|
|
showToast("最大量程必须大于0!")
|
|
|
|
|
showToast("量程必须大于0!")
|
|
|
|
|
} else {
|
|
|
|
|
GasPortUtils.setSensorMaxRange(sensorIndex, toInt)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (gasName != O2 && gasName != CH4_H2) {
|
|
|
|
|
val checkedRadioButtonId = mBinding.rgUnit.checkedRadioButtonId
|
|
|
|
|
var selectedUnit = UNIT_PPM
|
|
|
|
|
if (checkedRadioButtonId == R.id.rb_mgm3) {
|
|
|
|
|
selectedUnit = UNIT_MGM3
|
|
|
|
|
} else if (checkedRadioButtonId == R.id.rb_vol) {
|
|
|
|
|
selectedUnit = UNIT_VOL
|
|
|
|
|
} else if (checkedRadioButtonId == R.id.rb_lel) {
|
|
|
|
|
selectedUnit = UNIT_LEL
|
|
|
|
|
}
|
|
|
|
|
saveGasUnit(gasName, selectedUnit)
|
|
|
|
|
// }
|
|
|
|
|
showToast("保存成功")
|
|
|
|
|
}
|
|
|
|
|
}
|