Commit 2124bb0f59f9a910366bf022182caf6b1540ec42

Authored by jinyan.yi
1 parent 794ca6f6

.

@@ -46,6 +46,8 @@ import java.io.OutputStream; @@ -46,6 +46,8 @@ import java.io.OutputStream;
46 import java.lang.ref.WeakReference; 46 import java.lang.ref.WeakReference;
47 import java.net.Socket; 47 import java.net.Socket;
48 import java.util.Arrays; 48 import java.util.Arrays;
  49 +import java.util.Timer;
  50 +import java.util.TimerTask;
49 51
50 //import static com.qnbar.smc.service.SocketService.JUST_OPEN_DOOR; 52 //import static com.qnbar.smc.service.SocketService.JUST_OPEN_DOOR;
51 //import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR; 53 //import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR;
@@ -441,7 +443,7 @@ public class SocketService1 extends BaseService { @@ -441,7 +443,7 @@ public class SocketService1 extends BaseService {
441 //获取serverId 443 //获取serverId
442 ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class); 444 ReportEquStatus rps = gson.fromJson(socketResponse.getData(), ReportEquStatus.class);
443 // String serverId = rps.getServerId(); 445 // String serverId = rps.getServerId();
444 - reportEquStatus(rps.getServerId()); 446 + reportEquStatus(rps.getServerId(),0);
445 break; 447 break;
446 448
447 case SET_EQU_STATUS://设置声音,灯光,播放暂停 449 case SET_EQU_STATUS://设置声音,灯光,播放暂停
@@ -487,7 +489,7 @@ public class SocketService1 extends BaseService { @@ -487,7 +489,7 @@ public class SocketService1 extends BaseService {
487 } 489 }
488 } 490 }
489 491
490 - private void reportEquStatus(String serverId) { 492 + private void reportEquStatus(String serverId,int lightSet) {
491 //填充返回数据 493 //填充返回数据
492 int volume = getAudioVolume() / 6 + 1; 494 int volume = getAudioVolume() / 6 + 1;
493 int lightStatus = 2; 495 int lightStatus = 2;
@@ -499,10 +501,18 @@ public class SocketService1 extends BaseService { @@ -499,10 +501,18 @@ public class SocketService1 extends BaseService {
499 } catch (RemoteException e) { 501 } catch (RemoteException e) {
500 e.printStackTrace(); 502 e.printStackTrace();
501 } 503 }
502 - if (Lights.getInstance().getByMeshAddress(  
503 - ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status  
504 - == ConnectionStatus.ON) {  
505 - lightStatus = 1; 504 +
  505 + if (lightSet == 1 || lightSet == 2) {
  506 + lightStatus = lightSet;
  507 + } else {
  508 + ConnectionStatus stu = Lights.getInstance().getByMeshAddress(((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status;
  509 + if( Lights.getInstance().getByMeshAddress(
  510 + ((FangTangApplication) getApplication()).getConnectDevice().meshAddress).status == ConnectionStatus.ON ) {
  511 + Log.d("ReportInfo","lightStatus==1");
  512 + lightStatus = 1;
  513 + } else {
  514 + Log.d("ReportInfo", "lightStatus:"+stu);
  515 + }
506 } 516 }
507 517
508 EquipmentStatus equStatus = new EquipmentStatus(); 518 EquipmentStatus equStatus = new EquipmentStatus();
@@ -524,11 +534,26 @@ public class SocketService1 extends BaseService { @@ -524,11 +534,26 @@ public class SocketService1 extends BaseService {
524 if (op == 1) {//打开灯光 534 if (op == 1) {//打开灯光
525 Log.d("setEqu", "打开灯光"); 535 Log.d("setEqu", "打开灯光");
526 LightOperationUtils.open(); 536 LightOperationUtils.open();
527 - LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));  
528 - } else if (op == 2) {//关闭灯光  
529 - Log.d("setEqu", "关闭灯光");  
530 LightOperationUtils.setLightValue(5); 537 LightOperationUtils.setLightValue(5);
531 - LightOperationUtils.close(); 538 +
  539 + //延时增亮
  540 + Timer timer=new Timer();//实例化Timer类
  541 + timer.schedule(new TimerTask(){
  542 + public void run(){
  543 + LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
  544 + this.cancel();}},2000);//毫秒
  545 + }
  546 + else if(op == 2)//关闭灯光
  547 + {
  548 + Log.d("setEqu","关闭灯光");
  549 + LightOperationUtils.setLightValue(5);
  550 +
  551 + //延时关闭
  552 + Timer timer=new Timer();//实例化Timer类
  553 + timer.schedule(new TimerTask(){
  554 + public void run(){
  555 + LightOperationUtils.close();
  556 + this.cancel();}},2000);//毫秒
532 } 557 }
533 } 558 }
534 559
@@ -556,8 +581,13 @@ public class SocketService1 extends BaseService { @@ -556,8 +581,13 @@ public class SocketService1 extends BaseService {
556 581
557 setAudioVolume(equc.getAudioCtl()); 582 setAudioVolume(equc.getAudioCtl());
558 583
559 - reportEquStatus(equc.getServerId()); 584 + try {
  585 + Thread.sleep(500);
  586 + } catch (InterruptedException e) {
  587 + e.printStackTrace();
  588 + }
560 589
  590 + reportEquStatus(equc.getServerId(),equc.getLightCtl());
561 } 591 }
562 592
563 /*--命令处理-end-----------------------------------*/ 593 /*--命令处理-end-----------------------------------*/
Please register or login to post a comment