diff --git a/Check_engine/Check_engine b/Check_engine/Check_engine index 8313aa0..a498095 100644 Binary files a/Check_engine/Check_engine and b/Check_engine/Check_engine differ diff --git a/Check_engine/Check_engine.go b/Check_engine/Check_engine.go index d4b3f40..f56efc5 100644 --- a/Check_engine/Check_engine.go +++ b/Check_engine/Check_engine.go @@ -281,10 +281,14 @@ func CheckTime(time_run string) int { t_start, t_end := ReadTimeRun(time_run) var time_now = time.Now().Hour() + var millis = time.Now().Minute() if Debug == 1 { //fmt.Printf("Kieu time : %T\n", time) fmt.Printf("time = %v\n", time_now) } + if int(time_now) == 9 && int(millis) == 5 { + RebootBox() + } if time_now >= t_start && time_now <= t_end { time_sts = 1 //Status_engine() diff --git a/S905X_BI/S905X_BI b/S905X_BI/S905X_BI index dbca8a6..d1090d9 100644 Binary files a/S905X_BI/S905X_BI and b/S905X_BI/S905X_BI differ diff --git a/S905X_BI/S905X_BI.go b/S905X_BI/S905X_BI.go index 942ef21..4fbda04 100644 --- a/S905X_BI/S905X_BI.go +++ b/S905X_BI/S905X_BI.go @@ -568,10 +568,12 @@ func UpdateModule(id_engine int) { file.Write_log("---------------------------------------", box.Path_log_luncher) } func UpdateEngine() { + // log.Println("--- Begin Update Engine") SttUpdate = true box.Stop_check_engine() box.Stop_engine() box.RequestUpdate(box.Url) + // log.Println("--- End Update Engine") SttUpdate = false } diff --git a/S905X_BI/root@192.168.3.238 b/S905X_BI/root@192.168.3.238 new file mode 100644 index 0000000..9dfdaa9 Binary files /dev/null and b/S905X_BI/root@192.168.3.238 differ diff --git a/box/box.go b/box/box.go index 2fb940e..6a2bce7 100644 --- a/box/box.go +++ b/box/box.go @@ -7,6 +7,7 @@ import ( "encoding/json" "errors" "fmt" + "log" //"github.com/eclipse/paho.mqtt.golang" "io" @@ -288,7 +289,7 @@ func SetUp() bool { UpdateConfig(Path_engine_config) // Cap nhat thong tin name engine cho engine.json file.Println("Dowload_engine done") file.Println("Replace_id done") - namebox := "BITABLE_" + strconv.Itoa(message.Data.Box_id) + namebox := "BITABLE_" + strconv.Itoa(message.Data.Engines[0].Id) RenameBox(namebox) //Set_autorun() // Thiet lap engine auto run sau khi reset(Set up thong so Url, do phan giai, ) file.Write_log("AIBOX Reset\n", Path_log_luncher) @@ -324,6 +325,7 @@ func GetIndex(message Message, value string) int { return k } func DowloadEngineUpdate(name string, link string, version string, id int) { + log.Println("Download engine update") file.Println("Name: " + name) file.Println("Version: " + version) file.Println("Link: " + link) @@ -385,12 +387,12 @@ func DowloadEngineUpdate(name string, link string, version string, id int) { file.Println(message.Data.Engines[index].Name) file.Println(message.Data.Engines[index].Path) var id_val = strconv.Itoa(message.Data.Engines[index].Id) - var path_val = message.Data.Engines[index].Path + "/data/Config.txt" + var path_val = message.Data.Engines[index].Path + "/data/config.json" fmt.Println("ID new: ", id_val) fmt.Println("Path config:", path_val) threshold := fmt.Sprintf("%.2f", message.Data.Engines[index].Threshold) Replace_id(path_val, id_val, threshold, message.Data.Engines[index].Url) // Cap nhap ID BOX cho file config.txt trong engine - path := message.Data.Engines[index].Path + "/data/license.bin" + path := message.Data.Engines[index].Path + "/data/.bin" fmt.Println("Path save license:", path) SaveLicense(message.Data.License, path) // Do cap nhat chua biet port dang nao la bao nhieu len ko set dc @@ -398,6 +400,7 @@ func DowloadEngineUpdate(name string, link string, version string, id int) { fmt.Println("---------------------------------------------------") file.Println("---------------------------------------------------") } + log.Println("Done download engine update") } // End for array engine func Dowload_engine() { @@ -461,7 +464,7 @@ func Dowload_engine() { file.Println(message.Data.Engines[i].Name) file.Println(message.Data.Engines[i].Path) var id_val = strconv.Itoa(message.Data.Engines[i].Id) - var path_val = message.Data.Engines[i].Path + "/data/Config.txt" + var path_val = message.Data.Engines[i].Path + "/data/config.json" fmt.Println("ID new: ", id_val) fmt.Println("Path config:", path_val) threshold := fmt.Sprintf("%.2f", message.Data.Engines[i].Threshold) @@ -532,6 +535,7 @@ func FormRequest(Url string) string { return respon_msg } func RequestUpdate(Url string) { + log.Println("---------- Start RequestUpdate ") var respon_msg = FormRequest(Url) file.Println(respon_msg) json.Unmarshal([]byte(respon_msg), &messageUpdate) @@ -553,7 +557,7 @@ func RequestUpdate(Url string) { if message.Data.Engines[j].Name == messageUpdate.Data.Engines[i].Name+"_"+strconv.Itoa(messageUpdate.Data.Engines[i].Id) { if message.Data.Engines[j].Version != messageUpdate.Data.Engines[i].Version { // Backup file config.txt vao thu muc backup - file.CoppyFile(message.Data.Engines[j].Path+"/data/Config.txt", message.Data.Engines[j].Id) + file.CoppyFile(message.Data.Engines[j].Path+"/data/config.json", message.Data.Engines[j].Id) // Delete foder engine old file.DeleteForder(message.Data.Engines[j].Path) message.Data.Engines[j] = messageUpdate.Data.Engines[i] @@ -565,7 +569,7 @@ func RequestUpdate(Url string) { arrcompare[j] = 1 + arrcompare[j] } if message.Data.Engines[j].Threshold != messageUpdate.Data.Engines[i].Threshold { - var path_val = message.Data.Engines[j].Path + "/data/Config.txt" + var path_val = message.Data.Engines[j].Path + "/data/config.json" th_old := fmt.Sprintf("%.2f", message.Data.Engines[j].Threshold) th_new := fmt.Sprintf("%.2f", messageUpdate.Data.Engines[i].Threshold) @@ -614,6 +618,7 @@ func RequestUpdate(Url string) { } } UpdateConfig(Path_engine_config) + log.Println("---------- End RequestUpdate ") } func RemoveIndex(s []Engine, index int) []Engine { @@ -995,7 +1000,7 @@ func Replace_id(path string, id_box string, th string, api_url string) { if i > -1 { // Replace - newConfig := strings.Replace(msg, "[NAME]", "BITABLE_"+strconv.Itoa(message.Data.Box_id), -1) + newConfig := strings.Replace(msg, "[NAME]", "BITABLE_"+strconv.Itoa(message.Data.Engines[0].Id), -1) newConfig = strings.Replace(newConfig, "[QRCODE]", message.Data.QrCode, -1) //Replace trường accuracy_face_recognition() file.Write_log(" --- > Replace accuracy_face_recognition < ---", Path_log_luncher) @@ -1231,15 +1236,15 @@ func Stop_engine() { } else { file.Println("Engine kill") } - out1, _ := exec.Command("sh", "-c", "ps -A | grep loop_run").Output() + out1, _ := exec.Command("sh", "-c", "ps -A | grep node").Output() if len(out1) != 0 { - _, err := exec.Command("sh", "-c", " sudo kill $(pgrep loop_run)").Output() + _, err := exec.Command("sh", "-c", " sudo kill $(pgrep node)").Output() if err != nil { - file.Write_log("sudo kill $(pgrep loop_run) of Check Stop engine() \n", Path_log_luncher) + file.Write_log("sudo kill $(pgrep node) of Check Stop engine() \n", Path_log_luncher) } //log.Fatal(err) } else { - file.Println("loop_run kill") + file.Println("node kill") } } }