Thay ten tu ID box-> id engine
This commit is contained in:
parent
7ea6e38122
commit
ce8de60c80
Binary file not shown.
|
@ -281,10 +281,14 @@ func CheckTime(time_run string) int {
|
||||||
|
|
||||||
t_start, t_end := ReadTimeRun(time_run)
|
t_start, t_end := ReadTimeRun(time_run)
|
||||||
var time_now = time.Now().Hour()
|
var time_now = time.Now().Hour()
|
||||||
|
var millis = time.Now().Minute()
|
||||||
if Debug == 1 {
|
if Debug == 1 {
|
||||||
//fmt.Printf("Kieu time : %T\n", time)
|
//fmt.Printf("Kieu time : %T\n", time)
|
||||||
fmt.Printf("time = %v\n", time_now)
|
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 {
|
if time_now >= t_start && time_now <= t_end {
|
||||||
time_sts = 1
|
time_sts = 1
|
||||||
//Status_engine()
|
//Status_engine()
|
||||||
|
|
Binary file not shown.
|
@ -568,10 +568,12 @@ func UpdateModule(id_engine int) {
|
||||||
file.Write_log("---------------------------------------", box.Path_log_luncher)
|
file.Write_log("---------------------------------------", box.Path_log_luncher)
|
||||||
}
|
}
|
||||||
func UpdateEngine() {
|
func UpdateEngine() {
|
||||||
|
// log.Println("--- Begin Update Engine")
|
||||||
SttUpdate = true
|
SttUpdate = true
|
||||||
box.Stop_check_engine()
|
box.Stop_check_engine()
|
||||||
box.Stop_engine()
|
box.Stop_engine()
|
||||||
box.RequestUpdate(box.Url)
|
box.RequestUpdate(box.Url)
|
||||||
|
// log.Println("--- End Update Engine")
|
||||||
SttUpdate = false
|
SttUpdate = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
S905X_BI/root@192.168.3.238
Normal file
BIN
S905X_BI/root@192.168.3.238
Normal file
Binary file not shown.
27
box/box.go
27
box/box.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
//"github.com/eclipse/paho.mqtt.golang"
|
//"github.com/eclipse/paho.mqtt.golang"
|
||||||
"io"
|
"io"
|
||||||
|
@ -288,7 +289,7 @@ func SetUp() bool {
|
||||||
UpdateConfig(Path_engine_config) // Cap nhat thong tin name engine cho engine.json
|
UpdateConfig(Path_engine_config) // Cap nhat thong tin name engine cho engine.json
|
||||||
file.Println("Dowload_engine done")
|
file.Println("Dowload_engine done")
|
||||||
file.Println("Replace_id 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)
|
RenameBox(namebox)
|
||||||
//Set_autorun() // Thiet lap engine auto run sau khi reset(Set up thong so Url, do phan giai, )
|
//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)
|
file.Write_log("AIBOX Reset\n", Path_log_luncher)
|
||||||
|
@ -324,6 +325,7 @@ func GetIndex(message Message, value string) int {
|
||||||
return k
|
return k
|
||||||
}
|
}
|
||||||
func DowloadEngineUpdate(name string, link string, version string, id int) {
|
func DowloadEngineUpdate(name string, link string, version string, id int) {
|
||||||
|
log.Println("Download engine update")
|
||||||
file.Println("Name: " + name)
|
file.Println("Name: " + name)
|
||||||
file.Println("Version: " + version)
|
file.Println("Version: " + version)
|
||||||
file.Println("Link: " + link)
|
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].Name)
|
||||||
file.Println(message.Data.Engines[index].Path)
|
file.Println(message.Data.Engines[index].Path)
|
||||||
var id_val = strconv.Itoa(message.Data.Engines[index].Id)
|
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("ID new: ", id_val)
|
||||||
fmt.Println("Path config:", path_val)
|
fmt.Println("Path config:", path_val)
|
||||||
threshold := fmt.Sprintf("%.2f", message.Data.Engines[index].Threshold)
|
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
|
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)
|
fmt.Println("Path save license:", path)
|
||||||
SaveLicense(message.Data.License, path)
|
SaveLicense(message.Data.License, path)
|
||||||
// Do cap nhat chua biet port dang nao la bao nhieu len ko set dc
|
// 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("---------------------------------------------------")
|
fmt.Println("---------------------------------------------------")
|
||||||
file.Println("---------------------------------------------------")
|
file.Println("---------------------------------------------------")
|
||||||
}
|
}
|
||||||
|
log.Println("Done download engine update")
|
||||||
} // End for array engine
|
} // End for array engine
|
||||||
|
|
||||||
func Dowload_engine() {
|
func Dowload_engine() {
|
||||||
|
@ -461,7 +464,7 @@ func Dowload_engine() {
|
||||||
file.Println(message.Data.Engines[i].Name)
|
file.Println(message.Data.Engines[i].Name)
|
||||||
file.Println(message.Data.Engines[i].Path)
|
file.Println(message.Data.Engines[i].Path)
|
||||||
var id_val = strconv.Itoa(message.Data.Engines[i].Id)
|
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("ID new: ", id_val)
|
||||||
fmt.Println("Path config:", path_val)
|
fmt.Println("Path config:", path_val)
|
||||||
threshold := fmt.Sprintf("%.2f", message.Data.Engines[i].Threshold)
|
threshold := fmt.Sprintf("%.2f", message.Data.Engines[i].Threshold)
|
||||||
|
@ -532,6 +535,7 @@ func FormRequest(Url string) string {
|
||||||
return respon_msg
|
return respon_msg
|
||||||
}
|
}
|
||||||
func RequestUpdate(Url string) {
|
func RequestUpdate(Url string) {
|
||||||
|
log.Println("---------- Start RequestUpdate ")
|
||||||
var respon_msg = FormRequest(Url)
|
var respon_msg = FormRequest(Url)
|
||||||
file.Println(respon_msg)
|
file.Println(respon_msg)
|
||||||
json.Unmarshal([]byte(respon_msg), &messageUpdate)
|
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].Name == messageUpdate.Data.Engines[i].Name+"_"+strconv.Itoa(messageUpdate.Data.Engines[i].Id) {
|
||||||
if message.Data.Engines[j].Version != messageUpdate.Data.Engines[i].Version {
|
if message.Data.Engines[j].Version != messageUpdate.Data.Engines[i].Version {
|
||||||
// Backup file config.txt vao thu muc backup
|
// 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
|
// Delete foder engine old
|
||||||
file.DeleteForder(message.Data.Engines[j].Path)
|
file.DeleteForder(message.Data.Engines[j].Path)
|
||||||
message.Data.Engines[j] = messageUpdate.Data.Engines[i]
|
message.Data.Engines[j] = messageUpdate.Data.Engines[i]
|
||||||
|
@ -565,7 +569,7 @@ func RequestUpdate(Url string) {
|
||||||
arrcompare[j] = 1 + arrcompare[j]
|
arrcompare[j] = 1 + arrcompare[j]
|
||||||
}
|
}
|
||||||
if message.Data.Engines[j].Threshold != messageUpdate.Data.Engines[i].Threshold {
|
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_old := fmt.Sprintf("%.2f", message.Data.Engines[j].Threshold)
|
||||||
th_new := fmt.Sprintf("%.2f", messageUpdate.Data.Engines[i].Threshold)
|
th_new := fmt.Sprintf("%.2f", messageUpdate.Data.Engines[i].Threshold)
|
||||||
|
|
||||||
|
@ -614,6 +618,7 @@ func RequestUpdate(Url string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateConfig(Path_engine_config)
|
UpdateConfig(Path_engine_config)
|
||||||
|
log.Println("---------- End RequestUpdate ")
|
||||||
|
|
||||||
}
|
}
|
||||||
func RemoveIndex(s []Engine, index int) []Engine {
|
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 {
|
if i > -1 {
|
||||||
|
|
||||||
// Replace
|
// 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)
|
newConfig = strings.Replace(newConfig, "[QRCODE]", message.Data.QrCode, -1)
|
||||||
//Replace trường accuracy_face_recognition()
|
//Replace trường accuracy_face_recognition()
|
||||||
file.Write_log(" --- > Replace accuracy_face_recognition < ---", Path_log_luncher)
|
file.Write_log(" --- > Replace accuracy_face_recognition < ---", Path_log_luncher)
|
||||||
|
@ -1231,15 +1236,15 @@ func Stop_engine() {
|
||||||
} else {
|
} else {
|
||||||
file.Println("Engine kill")
|
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 {
|
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 {
|
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)
|
//log.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
file.Println("loop_run kill")
|
file.Println("node kill")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user