|
@@ -1,6 +1,5 @@
|
|
|
package com.sunzee.service;
|
|
|
|
|
|
-import android.annotation.SuppressLint;
|
|
|
import android.app.AlarmManager;
|
|
|
import android.app.Notification;
|
|
|
import android.app.NotificationManager;
|
|
@@ -16,8 +15,6 @@ import android.os.IBinder;
|
|
|
import android.os.SystemClock;
|
|
|
import android.support.annotation.Nullable;
|
|
|
import android.support.annotation.RequiresApi;
|
|
|
-import android.telephony.TelephonyManager;
|
|
|
-import android.telephony.gsm.GsmCellLocation;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.WindowManager;
|
|
@@ -33,11 +30,10 @@ import com.orhanobut.hawk.Hawk;
|
|
|
import com.sunzee.R;
|
|
|
import com.sunzee.base.BaseApplication;
|
|
|
import com.sunzee.db.WarringBeanDao;
|
|
|
+import com.sunzee.model.Global;
|
|
|
import com.sunzee.model.Heartbeat;
|
|
|
import com.sunzee.model.HoleInformation;
|
|
|
import com.sunzee.model.HttpResult;
|
|
|
-import com.sunzee.model.StateToilet;
|
|
|
-import com.sunzee.model.ToiletState;
|
|
|
import com.sunzee.model.domain.AddAlarmRecordBean;
|
|
|
import com.sunzee.model.domain.ErrorBean;
|
|
|
import com.sunzee.model.domain.GetAdBean;
|
|
@@ -60,6 +56,7 @@ import com.sunzee.utils.HexadecimalUtil;
|
|
|
import com.sunzee.utils.PreventSpeedClickUtil;
|
|
|
import com.sunzee.utils.SharedPreferencesUtils;
|
|
|
import com.sunzee.utils.TimeUtil;
|
|
|
+import com.sunzee.utils.TimerUtil;
|
|
|
import com.sunzee.utils.ToastUtil;
|
|
|
import com.sunzee.utils.UiUtil;
|
|
|
import com.wuxiaolong.androidutils.library.LogUtil;
|
|
@@ -75,7 +72,6 @@ import java.util.Arrays;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -96,15 +92,14 @@ public class MyService extends Service {
|
|
|
private boolean isRead = true;
|
|
|
private boolean isRegularCleaning = false;
|
|
|
private ThreadPoolAdvanceParameter mPoolAdvanceParameter = new ThreadPoolAdvanceParameter();
|
|
|
- private final static int TOTAL_SUM = 6;
|
|
|
+ public final static int TOTAL_SUM = 6;
|
|
|
|
|
|
//存储两个数据:是否上过厕所,一开始上厕所的时间是什么时候
|
|
|
//CopyOnWriteArrayList并不是完全意义上的线程安全,如果涉及到remove操作,一定要谨慎处理。
|
|
|
//写操作是加锁,读操作是不加锁的。多读少写时使用
|
|
|
- private static List<HoleInformation> sHoleInformationList = new LinkedList<>();
|
|
|
- private static LinkedList<Integer> sCleaningLocationList = new LinkedList<>();//存储要清洗的位置。
|
|
|
+ public static final List<HoleInformation> sHoleInformationList = new LinkedList<>();
|
|
|
+ public static final LinkedList<Integer> sCleaningLocationList = new LinkedList<>();//存储要清洗的位置。
|
|
|
|
|
|
- private static List<Integer> sToiletList = new CopyOnWriteArrayList<>();//存储是否上过厕所 0表示上过,1表示没有。2表示没有状态。
|
|
|
private static volatile boolean isCleanOK = false;
|
|
|
|
|
|
@Nullable
|
|
@@ -119,9 +114,12 @@ public class MyService extends Service {
|
|
|
Log.d(TAG, "MyServiceonCreate: ");
|
|
|
EventBus.getDefault().register(this);
|
|
|
for (int i = 0; i < TOTAL_SUM; i++) {
|
|
|
- sHoleInformationList.add(i, new HoleInformation(2, 0));//初始化
|
|
|
+ sHoleInformationList.add(new HoleInformation(2, 0));//初始化
|
|
|
+
|
|
|
+
|
|
|
// sToiletList.add(i, 1);//初始化,一开始都是没上过厕所的。
|
|
|
}
|
|
|
+ startRefreshime();
|
|
|
}
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
|
|
@@ -916,7 +914,9 @@ public class MyService extends Service {
|
|
|
getApplicationContext().startService(downloadApkIntent);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//------------------------------------------------------------------------广告 end---------------------------------
|
|
|
+ private boolean isAwait = true;
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void event(Message messageEvent) {
|
|
@@ -934,11 +934,13 @@ public class MyService extends Service {
|
|
|
mThreadPoolMyservice.stopWriteD120();
|
|
|
mThreadPoolMyservice.stopSetM8();
|
|
|
mThreadPoolMyservice.startSetM8();
|
|
|
+
|
|
|
} else if (messageEvent.getName().equals("DD120")) {
|
|
|
mThreadPoolMyservice.stopWriteDD120();
|
|
|
Log.d(TAG, "addCleanTime120event: 廁所位置寫入成功");
|
|
|
mThreadPoolMyservice.stopSetM8();
|
|
|
mThreadPoolMyservice.startSetM8();
|
|
|
+ Log.d(TAG, "cleanPositionNumX20: "+"D120执行了。");
|
|
|
} else if (messageEvent.getName().equals("M17")) {
|
|
|
mThreadPoolMyservice.stopSetM17();
|
|
|
if (isRegularCleaning) {
|
|
@@ -950,7 +952,13 @@ public class MyService extends Service {
|
|
|
isCleanOK = true;
|
|
|
mThreadPoolMyservice.stopSetM8();
|
|
|
Log.d(TAG, "addCleanTime120event: 開始清洗");
|
|
|
+ } else if (messageEvent.getName().equals("MM3")) {
|
|
|
+ mThreadPoolMyservice.stopWriteMM3();
|
|
|
+ cleanCount = 0;
|
|
|
+ Log.d(TAG, "addCleanTime120event: 開始复位");
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
mPoolAdvanceParameter.stopAll();
|
|
|
mPoolAdvanceParameter.startALLRead();
|
|
|
break;
|
|
@@ -996,31 +1004,95 @@ public class MyService extends Service {
|
|
|
List<String> lis = Arrays.asList(s1.split(""));//第0位会是空字符串
|
|
|
ArrayList<String> result = new ArrayList(lis);//
|
|
|
result.remove(0);
|
|
|
- if ("0".equals(result.get(0))) {
|
|
|
- //是否加入清洗
|
|
|
- synchronized (sCleaningLocationList) {//多线程操作需要加上同步锁
|
|
|
- isClean(0);
|
|
|
- }
|
|
|
- } else if ("1".equals(result.get(0))) {
|
|
|
- //记录
|
|
|
- synchronized (sCleaningLocationList) {//多线程操作需要加上同步锁
|
|
|
- addCleanTime(0);
|
|
|
- }
|
|
|
- }
|
|
|
+ Log.d(TAG, "result event: " + result.get(0) + result.get(1));
|
|
|
+
|
|
|
+ //todo 是否监听
|
|
|
+ //监控1号厕所
|
|
|
+ /* monitoring(result.get(0), 1);
|
|
|
+ //监控2号厕所
|
|
|
+ monitoring(result.get(1), 2);
|
|
|
+ //监控3号厕所
|
|
|
+ monitoring(result.get(2), 3);
|
|
|
+ //监控4号厕所
|
|
|
+ monitoring(result.get(3), 4);
|
|
|
+ //监控5号厕所
|
|
|
+ monitoring(result.get(4), 5);
|
|
|
+ //监控6号厕所
|
|
|
+ monitoring(result.get(5), 6);*/
|
|
|
} else if (name.equals("D2")) {
|
|
|
String data = String.valueOf(HexadecimalUtil.hex2dec(HexadecimalUtil.flipString(AsciiUtils.asciiByteArray2HexStr(responseFrame.getData())).get(0)));
|
|
|
- Log.d(TAG, "addCleanTimeD2event: "+data);
|
|
|
+ Log.d(TAG, "addCleanTimeD2event: " + data);
|
|
|
switch (data) {
|
|
|
- case "1": //清洗完毕----清洗過程中還是清洗完畢
|
|
|
- /*if (isCleanOK) {
|
|
|
- synchronized (sCleaningLocationList) {//多线程操作需要加上同步锁
|
|
|
+ case "0"://复位中
|
|
|
+ if (!isAwait) {
|
|
|
+ isAwait = true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "1": //第一次待机中
|
|
|
+ //复位了,那么就需要判断是否还需要清洗
|
|
|
+ //todo 这里的代码会一直执行,如果不等于0,那么这里会一直执行。
|
|
|
+ synchronized (sCleaningLocationList) {//多线程操作需要加上同步锁
|
|
|
+ if (isAwait) {
|
|
|
+ isAwait = false;
|
|
|
+ if (sCleaningLocationList.size() != 0) {
|
|
|
+ while (sCleaningLocationList.size() > 0) {
|
|
|
+ Integer first = sCleaningLocationList.getFirst();
|
|
|
+ Log.d(TAG, "first: "+first+",state:"+sHoleInformationList.get(first - 1).getState());
|
|
|
+ Log.d(TAG, "event: first"+(sHoleInformationList.get(first - 1).getState() != 0 && sHoleInformationList.get(first - 1).getState() != 2));
|
|
|
+
|
|
|
+ if (sHoleInformationList.get(first - 1).getState() != 0 && sHoleInformationList.get(first - 1).getState() != 2) {
|
|
|
+ sCleaningLocationList.removeFirst();
|
|
|
+ }else{
|
|
|
+ cleanPositionNumX20(first);
|
|
|
+ cleanCount++;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "3"://清洗完毕----清洗過程中還是清洗完畢
|
|
|
+ synchronized (sCleaningLocationList) {//多线程操作需要加上同步锁
|
|
|
+ Log.d(TAG, "为零event: " + isCleanOK);
|
|
|
+ if (isCleanOK) {
|
|
|
isCleanOK = false;
|
|
|
- sCleaningLocationList.removeFirst();
|
|
|
+ Log.d(TAG, "为零sCleaningLocationListevent: " + sCleaningLocationList.size());
|
|
|
if (sCleaningLocationList.size() != 0) {
|
|
|
- cleanPositionNumX20(sCleaningLocationList.getFirst());
|
|
|
+ Integer first = null;
|
|
|
+ Integer integer = sCleaningLocationList.removeFirst();
|
|
|
+ //如果集合大于0,那么我就取出第一个位置,进行判断是否正在上厕所,如果是,那么就需要移除,继续下一个,
|
|
|
+ while (sCleaningLocationList.size() > 0) {
|
|
|
+ first = sCleaningLocationList.getFirst();
|
|
|
+// if (sHoleInformationList.get(first-1).getState()==3) {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ for (Integer integer1 : sCleaningLocationList) {
|
|
|
+ sb.append(integer1);
|
|
|
+ }
|
|
|
+ Log.d(TAG, "first: "+first+",state:"+sHoleInformationList.get(first - 1).getState()+",sb:"+sb);
|
|
|
+ Log.d(TAG, "event: first"+(sHoleInformationList.get(first - 1).getState() != 0 && sHoleInformationList.get(first - 1).getState() != 2));
|
|
|
+
|
|
|
+ if (sHoleInformationList.get(first - 1).getState() != 0 && sHoleInformationList.get(first - 1).getState() != 2) {
|
|
|
+ sCleaningLocationList.removeFirst();
|
|
|
+ } else {
|
|
|
+ Log.d(TAG, "integer: "+integer+",first: "+first+",sb:"+sb);
|
|
|
+ if ((integer == 1 || integer == 2 || integer == 3) && (first == 4 || first == 5 || first == 6)) {
|
|
|
+ mThreadPoolMyservice.stopWriteMM3();
|
|
|
+ mThreadPoolMyservice.startWriteMM3("M3");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ cleanPositionNumX20(first);
|
|
|
+ cleanCount++;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- }*/
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -1037,6 +1109,21 @@ public class MyService extends Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void monitoring(String number, int position) {
|
|
|
+ Log.d(TAG, "monitoring: " + number + position);
|
|
|
+ synchronized (sCleaningLocationList) {//多线程操作需要加上同步锁
|
|
|
+ if ("0".equals(number)) {//
|
|
|
+ //是否加入清洗
|
|
|
+ isClean(position);
|
|
|
+ } else if ("1".equals(number)) {
|
|
|
+ //记录
|
|
|
+ addCleanTime(position);
|
|
|
+ }
|
|
|
+ }
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
private void addCleanTime(int number) {
|
|
|
Log.d(TAG, "厕所有人开始上厕所了。 ");
|
|
|
/**
|
|
@@ -1044,21 +1131,27 @@ public class MyService extends Service {
|
|
|
* 将标志位变为0.,如果我为0 就不执行了。避免时间一直更新。
|
|
|
* 存储当前的时间,到指定的集合中【标志位,0time】
|
|
|
*/
|
|
|
- HoleInformation holeInformation = sHoleInformationList.get(number);
|
|
|
- if (holeInformation.getState() != 1&&holeInformation.getState() != 3) {
|
|
|
+ Log.d(TAG, "addCleanTime: 为零isCleanaddCleanTime1");
|
|
|
+ HoleInformation holeInformation = sHoleInformationList.get(number - 1);
|
|
|
+ Log.d(TAG, "为零isCleanaddCleanTime11: " + sHoleInformationList.size() + holeInformation.getState());
|
|
|
+ Log.d(TAG, "为零isCleanaddCleanTime12: " + (number - 1));
|
|
|
+ if (holeInformation.getState() != 1 && holeInformation.getState() != 3) {
|
|
|
holeInformation.setState(1);//上厕所
|
|
|
holeInformation.setTimeDuration(System.currentTimeMillis());//存储他上厕所的时间
|
|
|
- }else if(holeInformation.getState() == 1){
|
|
|
- if (System.currentTimeMillis() - holeInformation.getTimeDuration() > 20000) {
|
|
|
+ } else if (holeInformation.getState() == 1) {
|
|
|
+ if (System.currentTimeMillis() - holeInformation.getTimeDuration() > 10000) {
|
|
|
//將其標誌位上過廁所。
|
|
|
holeInformation.setState(3);
|
|
|
Log.d(TAG, "addCleanTime: 上厕所超过20秒");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Log.d(TAG, "addCleanTime: 上厕所没超过20秒");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //记录清洗次数
|
|
|
+ private int cleanCount = 0;
|
|
|
+
|
|
|
private void isClean(int number) {
|
|
|
/**
|
|
|
* 0:
|
|
@@ -1072,51 +1165,74 @@ public class MyService extends Service {
|
|
|
* 如果标志位为1,表示一直没上厕所
|
|
|
* 什么都不做。
|
|
|
*/
|
|
|
- HoleInformation holeInformation = sHoleInformationList.get(number);
|
|
|
- Log.d(TAG, "x20event: " + holeInformation.toString());
|
|
|
+ HoleInformation holeInformation = sHoleInformationList.get(number - 1);
|
|
|
+ Log.d(TAG, "为零isCleanaddCleanTime23: " + sHoleInformationList.size() + holeInformation.getState());
|
|
|
+ Log.d(TAG, "为零isCleanaddCleanTime24: " + (number - 1));
|
|
|
int state = holeInformation.getState();
|
|
|
- // if (state != 0) {
|
|
|
- if (state == 3) {
|
|
|
- holeInformation.setState(4);
|
|
|
- holeInformation.setOutTimeDuration(System.currentTimeMillis());//存储他上厕所的时间
|
|
|
- }else if(holeInformation.getState()==4){
|
|
|
- Log.d(TAG, "厕所event: " + holeInformation.getTimeDuration());
|
|
|
- Log.d(TAG, "厕所event: " + System.currentTimeMillis());
|
|
|
- if (System.currentTimeMillis() - holeInformation.getTimeDuration() > 20000) {
|
|
|
- //上廁所超過20秒,那麼將狀態改為上廁所狀態。
|
|
|
- if (sCleaningLocationList.size() == 0) {
|
|
|
- //开始清洗厕所。[往尾部添加]
|
|
|
- if (!sCleaningLocationList.contains(number)) {
|
|
|
- sCleaningLocationList.addLast(number);//如果里面已经有了,那么就需要在加入,并且添加
|
|
|
- cleanPositionNumX20(number);
|
|
|
- Log.d(TAG, "addCleanTimeisClean: "+"開始清洗");
|
|
|
+ if (state == 3) {
|
|
|
+ holeInformation.setState(4);
|
|
|
+ holeInformation.setOutTimeDuration(System.currentTimeMillis());//存储他上厕所的时间
|
|
|
+ } else if (holeInformation.getState() == 4) {
|
|
|
+ if (System.currentTimeMillis() - holeInformation.getOutTimeDuration() > 5000) {
|
|
|
+ //上廁所超過20秒,那麼將狀態改為上廁所狀態。
|
|
|
+ Log.d(TAG, "为零isClean: " + sCleaningLocationList.size());
|
|
|
+ if (sCleaningLocationList.size() == 0) {
|
|
|
+ //如果不包含,那么就走这里
|
|
|
+ sCleaningLocationList.addLast(number);
|
|
|
+ Log.d(TAG, "为零isCleannumber4: " + number);
|
|
|
+ isCleanOK = true;
|
|
|
+ if (cleanCount >= 10) {
|
|
|
+ //如果为10,那么就需要复位,并且清零了。
|
|
|
+ mThreadPoolMyservice.stopWriteMM3();
|
|
|
+ mThreadPoolMyservice.startWriteMM3("M3");
|
|
|
+ cleanCount = 0;
|
|
|
+ Log.d(TAG, "厕所event复位1: " + cleanCount);
|
|
|
+ } else {
|
|
|
+ cleanCount++;//
|
|
|
+ cleanPositionNumX20(number);
|
|
|
+ Log.d(TAG, "isClean: " + number);
|
|
|
+ Log.d(TAG, "addCleanTimeisClean: " + "開始清洗");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //todo 这里存在一个问题,就是如果刚好,没有清洗,并且长度大于0呢?存在多线程安全问题
|
|
|
+ //那么我们就需要判断是否在清洗,通过一个标志位。清洗中,清洗完毕
|
|
|
+ int index = 100;
|
|
|
+ for (int i = 0; i < sCleaningLocationList.size(); i++) {
|
|
|
+ Log.d(TAG, "isClean111: " + (sCleaningLocationList.get(i) == (number)) + "" + sCleaningLocationList.get(i) + (number));
|
|
|
+ if (sCleaningLocationList.get(i) == (number)) {
|
|
|
+ index = i;
|
|
|
+ Log.d(TAG, "为零isCleannumber2: " + index);
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
+ if (index != 100) {
|
|
|
+ sCleaningLocationList.remove(index);//如果移除后等于0,集合大小等于0,那么开始清洗。
|
|
|
+ sCleaningLocationList.addLast(number);
|
|
|
+ isCleanOK = true;
|
|
|
} else {
|
|
|
- //todo 这里存在一个问题,就是如果刚好,没有清洗,并且长度大于0呢?存在多线程安全问题
|
|
|
- //那么我们就需要判断是否在清洗,通过一个标志位。清洗中,清洗完毕
|
|
|
sCleaningLocationList.addLast(number);
|
|
|
- Log.d(TAG, "addCleanTime: 清洗集合個數大於0:");
|
|
|
+ isCleanOK = true;
|
|
|
}
|
|
|
- holeInformation.setState(0);//改为2或者0都可以。
|
|
|
- Log.d(TAG, "addCleanTime: 出廁所使用超過5秒");
|
|
|
- } else {
|
|
|
- Log.d(TAG, "addCleanTime出厕所没有超过5秒: ");
|
|
|
- // holeInformation.setState(2);//为什么不是1,如果是1,那么
|
|
|
- }
|
|
|
- }else if (holeInformation.getState()==1){
|
|
|
- if (holeInformation.getState()!=2) {
|
|
|
- holeInformation.setState(2);
|
|
|
- Log.d(TAG, "addCleanTime重置狀態");
|
|
|
+ Log.d(TAG, "addCleanTime: 清洗集合個數大於0:");
|
|
|
}
|
|
|
+ holeInformation.setState(0);//改为2或者0都可以。
|
|
|
+ } else {
|
|
|
+ Log.d(TAG, "addCleanTime进厕所没超过20秒 ");
|
|
|
+ // holeInformation.setState(2);//为什么不是1,如果是1,那么
|
|
|
}
|
|
|
- /* }else{
|
|
|
- Log.d(TAG, "isClean: 不清洗廁所!");
|
|
|
- }*/
|
|
|
+ } else if (holeInformation.getState() == 1) {
|
|
|
+ if (holeInformation.getState() != 2) {
|
|
|
+ holeInformation.setState(2);
|
|
|
+ Log.d(TAG, "为零isCleanaddCleanTime1 addCleanTime重置狀態");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void cleanPositionNumX20(int data) {
|
|
|
mThreadPoolMyservice.stopWriteDD120();
|
|
|
mThreadPoolMyservice.startWriteDD120("D120", "000" + data);
|
|
|
+ Log.d(TAG, "cleanPositionNumX20: "+"000" + data);
|
|
|
}
|
|
|
|
|
|
private boolean isOpenReadWarring = true;
|
|
@@ -1310,55 +1426,41 @@ public class MyService extends Service {
|
|
|
|
|
|
//-----------------------------------------------------------------------报警 end---------------------------------
|
|
|
public void setAdvanced(String name, ArrayList<String> results, ThreadPoolAdvanceParameter threadGetParameter1) {
|
|
|
- if (name.equals("D426")) {
|
|
|
- if (!threadGetParameter1.isReceive1()) {
|
|
|
- threadGetParameter1.setReceive1(true);
|
|
|
- threadGetParameter1.stopReadD426();
|
|
|
- threadGetParameter1.getValues()[0] = String.valueOf(HexadecimalUtil.hex2dec(results.get(0)));
|
|
|
- }
|
|
|
- } else if (name.equals("D427")) {
|
|
|
+ if (name.equals("D418")) {
|
|
|
if (!threadGetParameter1.isReceive2()) {
|
|
|
threadGetParameter1.setReceive2(true);
|
|
|
- threadGetParameter1.stopReadD427();
|
|
|
- threadGetParameter1.getValues()[1] = String.valueOf(HexadecimalUtil.hex2dec(results.get(0)));
|
|
|
- }
|
|
|
-
|
|
|
- } else if (name.equals("D428")) {
|
|
|
- if (!threadGetParameter1.isReceive3()) {
|
|
|
- threadGetParameter1.setReceive3(true);
|
|
|
- threadGetParameter1.stopReadD428();
|
|
|
- threadGetParameter1.getValues()[2] = String.valueOf(HexadecimalUtil.hex2dec(results.get(0)));
|
|
|
+ threadGetParameter1.stopReadD418();
|
|
|
+ threadGetParameter1.getValues()[6] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(0))));
|
|
|
+ threadGetParameter1.getValues()[7] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(1))));
|
|
|
+ threadGetParameter1.getValues()[0] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(2))));
|
|
|
+ threadGetParameter1.getValues()[1] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(3))));
|
|
|
+ threadGetParameter1.getValues()[2] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(4))));
|
|
|
+ threadGetParameter1.getValues()[3] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(5))));
|
|
|
+ threadGetParameter1.getValues()[4] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(6))));
|
|
|
+ threadGetParameter1.getValues()[5] = String.valueOf(get177Data(HexadecimalUtil.hex2dec(results.get(7))));
|
|
|
+
|
|
|
+ Log.d(TAG, "D418setAdvanced: "+results.size());
|
|
|
}
|
|
|
-
|
|
|
- } else if (name.equals("D429")) {
|
|
|
- if (!threadGetParameter1.isReceive4()) {
|
|
|
- threadGetParameter1.setReceive4(true);
|
|
|
- //参数23 D278
|
|
|
- threadGetParameter1.stopReadD429();
|
|
|
- threadGetParameter1.getValues()[3] = String.valueOf(HexadecimalUtil.hex2dec(results.get(0)));
|
|
|
- }
|
|
|
- } else if (name.equals("D430")) {
|
|
|
- if (!threadGetParameter1.isReceive5()) {
|
|
|
- threadGetParameter1.setReceive5(true);
|
|
|
- threadGetParameter1.stopReadD430();
|
|
|
- threadGetParameter1.getValues()[4] = String.valueOf(HexadecimalUtil.hex2dec(results.get(0)));
|
|
|
- }
|
|
|
- } else if (name.equals("D431")) {
|
|
|
- if (!threadGetParameter1.isReceive6()) {
|
|
|
- threadGetParameter1.setReceive6(true);
|
|
|
- threadGetParameter1.stopReadD431();
|
|
|
- threadGetParameter1.getValues()[5] = String.valueOf(HexadecimalUtil.hex2dec(results.get(0)));
|
|
|
+ } else if (name.equals("D426")) {
|
|
|
+ if (!threadGetParameter1.isReceive1()) {
|
|
|
+ threadGetParameter1.setReceive1(true);
|
|
|
+ threadGetParameter1.stopReadD426();
|
|
|
+ threadGetParameter1.getValues()[7] = String.valueOf(HexadecimalUtil.hex2dec(results.get(0)));
|
|
|
+ threadGetParameter1.getValues()[8] = String.valueOf(HexadecimalUtil.hex2dec(results.get(1)));
|
|
|
+ threadGetParameter1.getValues()[9] = String.valueOf(HexadecimalUtil.hex2dec(results.get(2)));
|
|
|
+ threadGetParameter1.getValues()[10] = String.valueOf(HexadecimalUtil.hex2dec(results.get(3)));
|
|
|
+ threadGetParameter1.getValues()[11] = String.valueOf(HexadecimalUtil.hex2dec(results.get(4)));
|
|
|
+ threadGetParameter1.getValues()[12] = String.valueOf(HexadecimalUtil.hex2dec(results.get(5)));
|
|
|
+ threadGetParameter1.getValues()[13] = String.valueOf(HexadecimalUtil.hex2dec(results.get(6)));
|
|
|
+ threadGetParameter1.getValues()[14] = String.valueOf(HexadecimalUtil.hex2dec(results.get(7)));
|
|
|
+ threadGetParameter1.getValues()[15] = String.valueOf(HexadecimalUtil.hex2dec(results.get(8)));
|
|
|
+ Log.d(TAG, "D426setAdvanced: "+results.size());
|
|
|
}
|
|
|
}
|
|
|
- if (threadGetParameter1.isReceive1() && threadGetParameter1.isReceive2() && threadGetParameter1.isReceive3() && threadGetParameter1.isReceive4() && threadGetParameter1.isReceive5() && threadGetParameter1.isReceive6()) {
|
|
|
- getDataSuccess();
|
|
|
- threadGetParameter1.setReceive1(false);
|
|
|
- threadGetParameter1.setReceive2(false);
|
|
|
- threadGetParameter1.setReceive3(false);
|
|
|
- threadGetParameter1.setReceive4(false);
|
|
|
- threadGetParameter1.setReceive5(false);
|
|
|
- threadGetParameter1.setReceive6(false);
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String get177Data(long l) {
|
|
|
+ return String.valueOf(Math.round((l/ Global.num)*10));
|
|
|
}
|
|
|
|
|
|
public void getDataSuccess() {
|
|
@@ -1393,4 +1495,51 @@ public class MyService extends Service {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ private Timer timerGetTime;
|
|
|
+ private TimerTask timerTaskGetTime;
|
|
|
+ private int resetTime = 60;
|
|
|
+ private boolean isReset = false;
|
|
|
+
|
|
|
+ private void startRefreshime() {
|
|
|
+ timerGetTime = new Timer();
|
|
|
+ timerTaskGetTime = new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ synchronized (sCleaningLocationList) {//多线程操作需要加上同步锁
|
|
|
+ if (sCleaningLocationList.size() <= 0) {
|
|
|
+ //如果复位了,清洗一个后,移除了。那么就为小于等于0,那么就会有一个没有复位。
|
|
|
+ if (isReset) {//会导致不复位。
|
|
|
+ if (resetTime <= 0) {
|
|
|
+ //不能一直复位,因为如果一直厕所呢?所以我们复位后就需要停止继续执行这里面的内容,等到大于0的时候再进行里面的内容
|
|
|
+ //在集合移除最后一个的时候我们来一个标志位来解决这个问题。
|
|
|
+ isReset = false;
|
|
|
+ //等于0 的时候我们就需要进行复位 todo 复位
|
|
|
+ mThreadPoolMyservice.stopWriteMM3();
|
|
|
+ mThreadPoolMyservice.startWriteMM3("M3");
|
|
|
+ Log.d(TAG, "厕所event复位2: " + cleanCount);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ resetTime--;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //有清洗的时候就要走这里面。
|
|
|
+ resetTime = 60;
|
|
|
+ isReset = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ timerGetTime.schedule(timerTaskGetTime, 0, 1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void stopRefreshTime() {
|
|
|
+ TimerUtil.stopTimerAndTimerTask(timerGetTime, timerTaskGetTime);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+//todo 重启触摸屏后回出现问题:有的已经在清洗了,但是安卓屏幕不认。所以就会开始清洗。
|
|
|
+/**
|
|
|
+ * 如何优化呢?
|
|
|
+ * 1.就需要
|
|
|
+ */
|