From 94f92e97f29d98edfa2852478911c85f3154e075 Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 13 Sep 2023 11:28:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0PLC=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/bpa/MainActivity.java | 6 ++++-- .../main/java/com/example/bpa/app/ICSApp.java | 1 + .../com/example/bpa/helper/NetworkUtils.java | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/bpa/MainActivity.java b/app/src/main/java/com/example/bpa/MainActivity.java index eaa31be..ea4dbb8 100644 --- a/app/src/main/java/com/example/bpa/MainActivity.java +++ b/app/src/main/java/com/example/bpa/MainActivity.java @@ -44,6 +44,7 @@ import com.example.bpa.helper.MQTT; import com.example.bpa.helper.MessageLog; import com.example.bpa.helper.ModbusTcpHelper; import com.example.bpa.helper.ModbusTcpServer; +import com.example.bpa.helper.NetworkUtils; import com.example.bpa.helper.Speech; import com.example.bpa.helper.T; import com.example.bpa.helper.ThreadManager; @@ -175,6 +176,9 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen * 初始化业务 */ private void initBusiness() { + //1.同步时间 + NetworkUtils.SynchronizationTime(); + Main.getInstance().ToggleEnvironment(); //PLC数据监控 ReconnectModbus(); @@ -183,8 +187,6 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen OrderServer.Get().MqttInit(); //消息中心 RegisterMessage(); - - } /** diff --git a/app/src/main/java/com/example/bpa/app/ICSApp.java b/app/src/main/java/com/example/bpa/app/ICSApp.java index f90f322..7e2631f 100644 --- a/app/src/main/java/com/example/bpa/app/ICSApp.java +++ b/app/src/main/java/com/example/bpa/app/ICSApp.java @@ -39,6 +39,7 @@ public class ICSApp extends Application { public void onCreate() { super.onCreate(); NetworkUtils.exec3("ip rule add from all lookup main pref 9999"); + NetworkUtils.SynchronizationTime();//同步时间 ConfigName.getInstance().dishesCon = this; ConfigName.getInstance().app = this; } diff --git a/app/src/main/java/com/example/bpa/helper/NetworkUtils.java b/app/src/main/java/com/example/bpa/helper/NetworkUtils.java index 47f0cd0..00441cf 100644 --- a/app/src/main/java/com/example/bpa/helper/NetworkUtils.java +++ b/app/src/main/java/com/example/bpa/helper/NetworkUtils.java @@ -173,6 +173,25 @@ public class NetworkUtils { } + /** + * 同步时间 + */ + public static void SynchronizationTime() + { + new Thread(new Runnable() { + @Override + public void run() { + try { + exec3("settings put global auto_time 0"); + Thread.sleep(500); + exec3("settings put global auto_time 1"); + } catch (InterruptedException e) { + + } + } + }).start(); + } + /** * 发送 * @param cmds