瀏覽代碼

主界面状态显示修改

一拖四炒菜机
pry 3 月之前
父節點
當前提交
e9f005e945
共有 2 個文件被更改,包括 67 次插入4 次删除
  1. +19
    -4
      app/src/main/java/com/bonait/bnframework/business/ControlBase.java
  2. +48
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/TTrig.java

+ 19
- 4
app/src/main/java/com/bonait/bnframework/business/ControlBase.java 查看文件

@@ -6,6 +6,7 @@ import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.TTrig;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.IOperateResult;
import com.bonait.bnframework.common.modbus.ModbusMaster;
@@ -279,6 +280,8 @@ public abstract class ControlBase {

public IStatusNotify statusNotify;

boolean[] First = new boolean[4];

/**
* 设备心跳监听
*/
@@ -291,13 +294,25 @@ public abstract class ControlBase {

for (int i=0;i<4;i++){

if (!MbSlave.ReadBoolean(GetAddress(i+1,AddressData.Heartbeat))){
StartTime[i]=System.currentTimeMillis();
if(StartTime[i]==0&&!First[i]){
MbSlave.WriteBoolean(GetAddress(i+1,AddressData.Heartbeat),true);
First[i]=true;
}
if((System.currentTimeMillis()-StartTime[i])>=2000)

if(TTrig.get("心跳检测"+String.valueOf(i)).Start(MbSlave.ReadBoolean(GetAddress(i+1,AddressData.Heartbeat)))){
StartTime[i]=System.currentTimeMillis();
MbSlave.WriteBoolean(GetAddress(i+1,AddressData.Heartbeat),true);
}

HeartbeatStatus[i]=StartTime[i]>0&&(System.currentTimeMillis()-StartTime[i])<=TimeOut;

HeartbeatStatus[i]=(System.currentTimeMillis()-StartTime[i])<=TimeOut;
// if (!MbSlave.ReadBoolean(GetAddress(i+1,AddressData.Heartbeat))){
// StartTime[i]=System.currentTimeMillis();
// }
// if((System.currentTimeMillis()-StartTime[i])>=2000)
// MbSlave.WriteBoolean(GetAddress(i+1,AddressData.Heartbeat),true);
//
// HeartbeatStatus[i]=(System.currentTimeMillis()-StartTime[i])<=TimeOut;

if ( HeartbeatStatus[i]&&MbSlave.ReadBoolean(GetAddress(i+1,AddressData.FryingPanHide))){
status[i]="空闲中";


+ 48
- 0
app/src/main/java/com/bonait/bnframework/common/helper/TTrig.java 查看文件

@@ -0,0 +1,48 @@
package com.bonait.bnframework.common.helper;

import com.bonait.bnframework.common.helper.I.IRun;

import java.util.concurrent.ConcurrentHashMap;

/**
* 上升沿操作
*/
public class TTrig {
private static volatile ConcurrentHashMap<String, TTrig> _Instance;

public static TTrig get(String name) {
if (_Instance == null)
_Instance = new ConcurrentHashMap<String, TTrig>();
if (!_Instance.containsKey(name))
_Instance.put(name, new TTrig());
return _Instance.get(name);
}

private TTrig() {
}

private boolean flag=false;
private boolean Q=false;

public boolean getQ() {
return Q;
}

private void setIN(boolean falag) {
Q = falag && !flag;
flag = falag;
}

public void Start(boolean IN, IRun callback) {
setIN(IN);
if (Q)
callback.Run();

}

public boolean Start(boolean IN) {
setIN(IN);
return Q;
}

}

Loading…
取消
儲存