-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensorLifeTimeTest2
More file actions
executable file
·116 lines (109 loc) · 2.29 KB
/
Copy pathsensorLifeTimeTest2
File metadata and controls
executable file
·116 lines (109 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
echo Sensor Life Time Test Record Tool. @2022 DUKECAT DESIGN.
if [ ! `which dialog` ]; then
echo NO dialog installed!
exit 1
fi
if [ "$1" = "-c" ]
then
echo Create database!
sqlite3 irLifeTimeTest.db "create table testdata(obj, sn, value, date);"
echo Done.
exit 0
elif [ "$1" = "-l" ]
then
if [ -z $2 ]
then
sqlite3 irLifeTimeTest.db "select * from testdata;"
else
sqlite3 irLifeTimeTest.db "select * from testdata where obj = \"$2\";"
fi
exit 0
elif [ "$1" = "-d" ]
then
echo -n ARE YOU SURE?\(yEs\):
read AYS
if [ "$AYS" = "yEs" ]
then
rm irLifeTimeTest.db
fi
exit 0
elif [ "$1" = "-h" ]
then
echo This script is for DEVELOPMENT ONLY.
echo No Garantee for anything. sqlite3 is requirement.
echo $0 [option] [obj]
echo -c To Create database.
echo -d Delete database
echo -l Show all the data or obj data.
exit 0
elif [ -z $1 ]
then
echo Operate in Normal Mode.
dialog --title "DUKECAT Sensor Life Time Test" --msgbox "It's for dev records, please make sure all data are currect.\n-h for help." 0 0
else
echo $1 ??, -h for help!
exit 0
fi
if [ -f "irLifeTimeTest.db" ]
then
echo Database is exist.
else
echo Database is not exist, please create first.
exit 0
fi
#echo -n Enter Object Name :
#read OBJ
dialog --title "DUKECAT Sensor Life Time Test" --inputbox "Enter OBJECT NAME" 8 50 2>dialogTemp
result=$?
OBJ=$(cat dialogTemp)
if [ $result -eq 1 ]
then
echo cancel!
exit 0
fi
if [ -z "$OBJ" ]
then
echo OBJ is null.
echo See you!
exit 0
fi
SN=0
while :
do
#echo -n Enter Series Number :
#read SN
SN=`expr $SN + 1`
dialog --title "DUKECAT Sensor Life Time Test" --inputbox "Enter Serial Number" 8 50 $SN 2>dialogTemp
result=$?
SN=$(cat dialogTemp)
if [ $result -eq 1 ]
then
echo cancel!
exit 0
fi
if [ -z "$SN" ]
then
echo SN is null.
echo Bye Bye!
exit 0
fi
testDate=`date "+%Y-%m-%d"`
#echo -n Enter the Value :
dialog --title "DUKECAT Sensor Life Time Test" --inputbox "Enter Value" 8 50 2>dialogTemp
result=$?
VALUE=$(cat dialogTemp)
if [ $result -eq 1 ]
then
echo cancel!
exit 0
fi
if [ -z "$VALUE" ]
then
echo VALUE is null.
echo SN = $SN will not save.
exit 0
fi
echo "OBJECT: $OBJ\tSN: $SN\tVALUE:$VALUE\tDATE:$testDate"
sqlite3 irLifeTimeTest.db "insert into testdata values(\"$OBJ\", $SN, $VALUE, \"$testDate\");"
done