nicsensor/tool/test/check_threhold.sh
leimingsheng 88f871c880 feat(master) update to 1.10 base dev 2
1.[新增功能]解耦脚本参数配置功能, 脚本配置全部放到project.config中
2.[新增功能]增加对pmbus set命令的支持
3.[新增功能]增加setup.sh, 用于一键部署脚本
4.[功能优化]代码结构目录重新归档
2026-04-17 17:09:43 +08:00

45 lines
1.1 KiB
Bash

#!/bin/sh
# 20250627
# A tool script to test a value greater or less than threhold
data=$1
direction=$2
threhold=$3
param_num=$#
print_usage(){
echo " Script Usage"
echo " ./check_threhold.sh <value> <direction> <threhold>"
echo " @Param direction : greater , >"
echo " less , <"
echo " equal , ="
echo ""
echo " E.G. ./check_threhold.sh 500 > 1000"
echo " +--> Result : 0"
echo ""
echo " About Result: 1 means true, 0 means fault"
echo ""
}
main(){
if [ ${param_num} -ne 3 ];then
print_usage
exit 0
fi
if [ "${direction}" = "great" ] || [ "${direction}" = ">" ];then
res= `echo " $data > $threhold" | bc -l`
elif [ "${direction}" = "less" ] || [ "${direction}" = "<" ];then
res= `echo " $data < $threhold" | bc -l`
elif [ "${direction}" = "equal" ] || [ "${direction}" = "=" ];then
res= `echo " $data = $threhold" | bc -l`
else
echo "Invalid direction"
print_usage
fi
echo $res
}
main