From 8324f872ef3a4d0c978a9b1d062800c6a1701c12 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 01 十二月 2023 09:58:17 +0800
Subject: [PATCH] fix

---
 conf/config.go |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/conf/config.go b/conf/config.go
index 4307f1f..53632ae 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -4,8 +4,11 @@
 	"apsClient/pkg/convertx"
 	"apsClient/pkg/logx"
 	"apsClient/pkg/sqlitex"
+	"apsClient/pkg/timex"
+	"apsClient/utils"
 	"github.com/spf13/viper"
 	"log"
+	"time"
 )
 
 var (
@@ -73,6 +76,12 @@
 		ModbusIntType            string
 		SlaveId                  int
 		Package                  string
+		StandbyTime              int64
+	}
+
+	Prompt struct {
+		SafeProduce     string `json:"safeProduce,omitempty"`
+		PlcNotConnected string `json:"plcNotConnected,omitempty"`
 	}
 
 	config struct {
@@ -93,6 +102,16 @@
 
 		//PLC
 		PLC plc
+
+		Prompt Prompt
+
+		CurrentDeviceID string //璁剧疆褰撳墠闈㈡澘鎺у埗鐨勮澶�
+
+		SerfClusterStatus string //闆嗙兢鐘舵��
+
+		ClusterNodeQuantity int //闆嗙兢鑺傜偣鏁伴噺
+
+		SystemDeviceRunSince int64 //绯荤粺寮�濮嬭繍琛屾椂闂存埑
 	}
 )
 
@@ -115,6 +134,22 @@
 	if err := Viper.Unmarshal(&Conf); err != nil {
 		log.Fatalf("Unmarshal err:%v", err)
 	}
+	if Conf.PLC.StandbyTime == 0 {
+		Conf.PLC.StandbyTime = 300 //5鍒嗛挓
+	}
+
+	uptimeStr, err := utils.Exec("uptime -s")
+	if err == nil {
+		t, err := timex.StringToTime(uptimeStr)
+		if err == nil {
+			Conf.SystemDeviceRunSince = t.Unix()
+		}
+	} else {
+		Conf.SystemDeviceRunSince = time.Now().Unix()
+	}
+
+	SetUpTime()
+
 	ShowConfig()
 }
 
@@ -135,3 +170,15 @@
 	log.Printf("   services :                  %+v", Conf.Services)
 	log.Println("......................................................")
 }
+
+func SetUpTime() {
+	uptimeStr, err := utils.Exec("uptime -s")
+	if err == nil {
+		t, err := timex.StringToTime(uptimeStr)
+		if err == nil {
+			Conf.SystemDeviceRunSince = t.Unix()
+		}
+	} else {
+		Conf.SystemDeviceRunSince = time.Now().Unix()
+	}
+}

--
Gitblit v1.8.0