2020-06-24 1.增加干节点指令处理。                (干节点0 移动传感器1 煤气传感器10 烟雾传感器11 水浸25 门磁窗磁26 紧急按钮27)

2020-06-24
1.增加干节点指令处理。
(干节点0 移动传感器1 煤气传感器10 烟雾传感器11 水浸25 门磁窗磁26 紧急按钮27)
2个文件已添加
9个文件已修改
722 ■■■■■ 已修改文件
app/src/main/AndroidManifest.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AddDevicesActivity.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/SensorActivity.java 507 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_add_devices.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DryContactSensorBackEvent.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/AndroidManifest.xml
@@ -35,6 +35,7 @@
        <activity android:name=".activity.GeothermalActivity" />
        <activity android:name=".activity.CtrlCommonSwitchActivity" />
        <activity android:name=".activity.CtrlSecurityActivity" />
        <activity android:name=".activity.SensorActivity" />
        <receiver android:name=".activity.BootComplete">
            <intent-filter>
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AddDevicesActivity.java
@@ -17,27 +17,30 @@
import java.util.ArrayList;
/** SDK目前支持的大类:小类
 * 灯光类:调光回路、开关回路、混合调光类、混合开关类
 * 窗帘类:开合帘电机、卷帘电机、窗帘模块
 * 空调功能:HVAC 模块、通用空调面板
 * 背景音乐功能:背景音乐模块 2018新背景音乐模块小类3
 * 传感器:干结点0 到 功率24
 * 逻辑功能:逻辑模块
 * 全局场景:
 * 地热功能:地热模块
 * 新风:新风系统
/** SDK目前支持手动添加的大类:小类
 * 灯光类(大类1):调光回路(0)、开关回路(1)、混合调光类(9)、混合开关类(10)
 * 窗帘类(大类2):开合帘电机(0)、卷帘电机(1)、窗帘模块(2)
 * 空调功能(大类7):HVAC 模块(0)、通用空调面板(3)
 * 背景音乐功能(大类9):背景音乐模块 2018新背景音乐模块小类3
 * 传感器(大类5):干结点0 到 功率24
 * 逻辑功能(大类12):逻辑模块(0)
 * 全局场景(大类17):全局场景(0)
 * 地热功能:地热模块(0)
 * 新风(大类19):新风系统(0)
 * 通用开关(大类100):通用开关(0)
 * 灯光类1:0 ,1,9,10
 * 窗帘类2:0,1,2
 * 传感器5:0~24
 * 空调类7:0,3
 * 地热模块8:0
 * 背景音乐功能9:0
 * 逻辑功能12:0
 * 全局场景17:0
 * 新风模块19:0
 * 通用开关100:0
 * 格式 支持的模块名字 大类ID:小类ID
 *
 * 灯光类 1:0 ,1,9,10
 * 窗帘类 2:0,1,2
 * 传感器 5:0~24
 * 空调类 7:0,3
 * 地热模块 8:0
 * 背景音乐功能 9:0
 * 逻辑功能 12:0
 * 全局场景 17:0
 * 新风模块 19:0
 * 通用开关 100:0
 *
 * 该方法应用于提供项目交付前的提取批量数据生成好数据。
 * 模拟生成设备回路数据,在项目不支持简易编程搜索情况下,可以通过该方法,先快捷生成目标数据 得到 List<DevicesData> 格式的设备列表数据
@@ -378,13 +381,8 @@
        DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, 111, 3, 3, "电视灯", "4路继电器",false);
        DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, 111, 3, 4, "廊灯", "4路继电器",false);
        //添加一个4路继电器
        DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, 111, 3, 1, "吧台灯", "4路继电器",false);
        DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, 111, 3, 2, "休闲灯", "4路继电器",false);
        DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, 111, 3, 3, "电视灯", "4路继电器",false);
        DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, 111, 3, 4, "廊灯", "4路继电器",false);
        //添加一个干节点传感器
        DeviceParser.addDevicesListWithoutSearching(port, Configuration.SENSOR_BIG_TYPE, 0, 111, 99, 1, "干节点", "干节点",false);
        //添加一个2路窗帘
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java
@@ -63,6 +63,9 @@
                }else  if (appliancesInfos.get(position).getBigType() == Configuration.SECURITY_BIG_TYPE) {
                    //大类是安防模块则跳转到CtrlSecurityActivity
                    intent.setClass(AppliancesActivity.this, CtrlSecurityActivity.class);
                }else  if (appliancesInfos.get(position).getBigType() == Configuration.SENSOR_BIG_TYPE) {
                    //大类是传感器 则跳转到SensorActivity 干节点指令类型
                    intent.setClass(AppliancesActivity.this, SensorActivity.class);
                }
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/SensorActivity.java
New file
@@ -0,0 +1,507 @@
package com.hdl.sdk.hdl_sdk.activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig;
import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo;
import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DryContactSensorBackEvent;
import com.hdl.sdk.hdl_sdk.R;
import com.hdl.sdk.hdl_sdk.base.BaseActivity;
import com.hdl.sdk.hdl_sdk.utlis.HDLLog;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/**
 * 传感器 干节点指令类型的传感器模块
 * 干节点 移动传感器 水浸 门磁窗磁 紧急按钮
 *
 * 一般配合4合1干节点模块使用
 */
public class SensorActivity extends BaseActivity {
    /**
     * Topbar
     */
//    private RelativeLayout topBarBack;
//    private TextView topBarTitle;
    private Button sensorbtn;
    private TextView sensorText;
    private AppliancesInfo appliancesInfo;
    /**
     * 复写isRegisterEventBus()  要注册使用EventBus,这里要设置返回true
     *
     * @return true
     */
    @Override
    protected boolean isRegisterEventBus() {
        return true;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sensor);
        initToolbar();
        initcurState();
        initView();
        initOnClick();
        displayStateView();
        //从网络上查询刷新一次设备状态,待调试
        HDLCommand.getDryContactSensorStateFromNetwork(appliancesInfo);
    }
    /**
     * 初始化Toolbar
     */
    private void initToolbar() {
//        topBarBack = findViewById(R.id.ll_top_b_left);
//        setViewVisible(topBarBack);
//        topBarTitle = findViewById(R.id.tv_top_b_header_title);
//        topBarBack.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                finish();
//            }
//        });
    }
    private void initcurState() {
        appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
//        String titleStr = appliancesInfo.getRemarks();
//        topBarTitle.setText(titleStr);
    }
    private void initView() {
        sensorbtn = findViewById(R.id.sensorbtn);
        sensorText = findViewById(R.id.sensorText);
    }
    private void initOnClick() {
        sensorbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //从网络上查询刷新一次设备状态,待调试
                HDLCommand.getDryContactSensorStateFromNetwork(appliancesInfo);
            }
        });
    }
    private void displayStateView() {
        switch (appliancesInfo.getDeviceType()) {
//            case HDLApConfig.TYPE_SENSOR_TEMP:////2019-07-03 屏蔽
//            case HDLApConfig.TYPE_SENSOR_HUMIDITY:
//            case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
//            case HDLApConfig.TYPE_SENSOR_VOC:
//            case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
//            case HDLApConfig.TYPE_SENSOR_C02:
//            case HDLApConfig.TYPE_SENSOR_LPG:
//            case HDLApConfig.TYPE_SENSOR_CO_H2:
//            case HDLApConfig.TYPE_SENSOR_CH4:
//            case HDLApConfig.TYPE_SENSOR_SMOG:
//            case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
//            case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
//            case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
//            case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
//            case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
//            case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
//            case HDLApConfig.TYPE_SENSOR_WEIGHT:
//            case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
//            case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
//            case HDLApConfig.TYPE_SENSOR_SHAKE:
//            case HDLApConfig.TYPE_SENSOR_VOLTAGE:
//            case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
//            case HDLApConfig.TYPE_SENSOR_POWER:
//            case HDLApConfig.TYPE_SENSOR_FLOODING:
//            case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
//            case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
            case HDLApConfig.TYPE_SENSOR_DRY_CONTACT: //干节点
            case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: //红外感应传感器
            case HDLApConfig.TYPE_SENSOR_CO_H2:         //煤气传感器
            case HDLApConfig.TYPE_SENSOR_SMOG:          //烟雾传感器
            case HDLApConfig.TYPE_SENSOR_FLOODING:       //水浸传感器
            case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:   //门磁传感器
            case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON://紧急按钮
                break;
            default:
                finish();//设备类型不对结束页面
                break;
        }
        /**根据需求是否发送一次获取刷新状态请求*/
    }
    /**
     * 传感器状态回调 Event
     * 干节点状态主动广播 和 被动查询状态反馈
     *
     * @param event
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onDryContactSensorBackEventMain(DryContactSensorBackEvent event) {
        if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
                && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
                && event.getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
        ) {
            //传感器 干接点 。只有开关状态
            if (!event.isSuccess()) {
                showToast("获取传感器状态失败,请重新再试");
                return;
            }
            String mData = "";
            if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR) {
                mData = event.getState() == 0 ? "无动静" : "有动静";
            } else {
                mData = event.getState() == 0 ? "闭合" : "断开";
            }
            sensorText.setText("传感器---干接点状态:" + mData);
//            showToast("传感器---干接点状态:" + mData);
            HDLLog.I("传感器---干接点状态:" + mData);
        }
    }
//    /**
//     * 传感器状态回调 Event
//     *
//     * @param event
//     */
//    @Subscribe(threadMode = ThreadMode.MAIN)
//    public void onSensorStateBackInfoMain(SensorStateBackInfo event) {
//        if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
//                && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
//                && event.getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
//        ) {
//            //这个返回的信息是当前状态的
//            switch (event.getAppliancesInfo().getDeviceType()) {
//                case HDLApConfig.TYPE_SENSOR_DRY_CONTACT://2019-07-03 屏蔽
//                    //传感器 干接点 。只有开关状态
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---干接点状态失败,请重新再试");
//                        return;
//                    }
//                    float dryContactValue = (float) event.getAppliancesInfo().getCurState();
//                    String dryContactUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---干接点状态:" + dryContactValue + dryContactUnit);
//                    HDLLog.Log("传感器---干接点状态:" + dryContactValue + dryContactUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
//                    //传感器 移动探测 。灵敏度
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---移动探测灵敏度状态失败,请重新再试");
//                        return;
//                    }
//                    float mdValue = (float) event.getAppliancesInfo().getCurState();
//                    String mdValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---移动探测灵敏度:" + mdValue + mdValueUnit);
//                    HDLLog.Log("传感器---移动探测灵敏度:" + mdValue + mdValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_TEMP:
//                    //传感器 温度
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---温度状态失败,请重新再试");
//                        return;
//                    }
//                    float tempValue = (float) event.getAppliancesInfo().getCurState();
//                    String tempValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---温度:" + tempValue + tempValueUnit);
//                    HDLLog.Log("传感器---温度:" + tempValue + tempValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_HUMIDITY:
//                    //传感器 湿度
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---湿度状态失败,请重新再试");
//                        return;
//                    }
//                    float humidityValue = (float) event.getAppliancesInfo().getCurState();
//                    String humidityValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---湿度:" + humidityValue + humidityValueUnit);
//                    HDLLog.Log("传感器---湿度:" + humidityValue + humidityValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
//                    //传感器 照度
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---照度状态失败,请重新再试");
//                        return;
//                    }
//                    float illuminaceValue = (float) event.getAppliancesInfo().getCurState();
//                    String illuminaceValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---照度:" + illuminaceValue + illuminaceValueUnit);
//                    HDLLog.Log("传感器---照度:" + illuminaceValue + illuminaceValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_VOC:
//                    //传感器 当前空气质量等级
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---当前空气质量等级状态失败,请重新再试");
//                        return;
//                    }
//                    float vocValue = (float) event.getAppliancesInfo().getCurState();
//                    String vocValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---当前空气质量等级:" + vocValue + vocValueUnit);
//                    HDLLog.Log("传感器---当前空气质量等级:" + vocValue + vocValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
//                    //传感器 pm2.5
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---pm2.5状态失败,请重新再试");
//                        return;
//                    }
//                    float pm2_5Value = (float) event.getAppliancesInfo().getCurState();
//                    String pm2_5ValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---pm2.5:" + pm2_5Value + pm2_5ValueUnit);
//                    HDLLog.Log("传感器---pm2.5:" + pm2_5Value + pm2_5ValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_C02:
//                    //传感器 二氧化碳
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---二氧化碳状态失败,请重新再试");
//                        return;
//                    }
//                    float co2Value = (float) event.getAppliancesInfo().getCurState();
//                    String co2ValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---二氧化碳:" + co2Value + co2ValueUnit);
//                    HDLLog.Log("传感器---二氧化碳:" + co2Value + co2ValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_LPG:
//                    //传感器 液化石油气
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---液化石油气状态失败,请重新再试");
//                        return;
//                    }
//                    float lpgValue = (float) event.getAppliancesInfo().getCurState();
//                    String lpgValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---液化石油气:" + lpgValue + lpgValueUnit);
//                    HDLLog.Log("传感器---液化石油气:" + lpgValue + lpgValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_CO_H2:
//                    //传感器 人工煤气
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---人工煤气状态失败,请重新再试");
//                        return;
//                    }
//                    float coh2Value = (float) event.getAppliancesInfo().getCurState();
//                    String coh2ValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---人工煤气:" + coh2Value + coh2ValueUnit);
//                    HDLLog.Log("传感器---人工煤气:" + coh2Value + coh2ValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_CH4:
//                    //传感器 天然气
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---天然气状态失败,请重新再试");
//                        return;
//                    }
//                    float ch4Value = (float) event.getAppliancesInfo().getCurState();
//                    String ch4ValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---天然气:" + ch4Value + ch4ValueUnit);
//                    HDLLog.Log("传感器---天然气:" + ch4Value + ch4ValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_SMOG:
//                    //传感器 烟雾
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---烟雾状态失败,请重新再试");
//                        return;
//                    }
//                    float smogValue = (float) event.getAppliancesInfo().getCurState();
//                    String smogValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---烟雾:" + smogValue + smogValueUnit);
//                    HDLLog.Log("传感器---烟雾:" + smogValue + smogValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
//                    //传感器 风速
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---风速状态失败,请重新再试");
//                        return;
//                    }
//                    float windSpeedValue = (float) event.getAppliancesInfo().getCurState();
//                    String windSpeedValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---风速:" + windSpeedValue + windSpeedValueUnit);
//                    HDLLog.Log("传感器---风速:" + windSpeedValue + windSpeedValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
//                    //传感器 风压
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---风压状态失败,请重新再试");
//                        return;
//                    }
//                    float windPressureValue = (float) event.getAppliancesInfo().getCurState();
//                    String windPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---风压:" + windPressureValue + windPressureValueUnit);
//                    HDLLog.Log("传感器---风压:" + windPressureValue + windPressureValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
//                    //传感器 液体流量
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---液体流量状态失败,请重新再试");
//                        return;
//                    }
//                    float liquidFlowValue = (float) event.getAppliancesInfo().getCurState();
//                    String liquidFlowValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit);
//                    HDLLog.Log("传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
//                    //传感器 液体压力
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---液体压力状态失败,请重新再试");
//                        return;
//                    }
//                    float liquidPressureValue = (float) event.getAppliancesInfo().getCurState();
//                    String liquidPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit);
//                    HDLLog.Log("传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
//                    //传感器 液体深度
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---液体深度状态失败,请重新再试");
//                        return;
//                    }
//                    float liquidDepthValue = (float) event.getAppliancesInfo().getCurState();
//                    String liquidDepthValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit);
//                    HDLLog.Log("传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
//                    //传感器 雨量
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---雨量状态失败,请重新再试");
//                        return;
//                    }
//                    float rainFallValue = (float) event.getAppliancesInfo().getCurState();
//                    String rainFallValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---雨量:" + rainFallValue + rainFallValueUnit);
//                    HDLLog.Log("传感器---雨量:" + rainFallValue + rainFallValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_WEIGHT:
//                    //传感器 重量
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---重量状态失败,请重新再试");
//                        return;
//                    }
//                    float weightValue = (float) event.getAppliancesInfo().getCurState();
//                    String weightValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---重量:" + weightValue + weightValueUnit);
//                    HDLLog.Log("传感器---重量:" + weightValue + weightValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
//                    //传感器 重量
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---重量状态失败,请重新再试");
//                        return;
//                    }
//                    float height_lengthValue = (float) event.getAppliancesInfo().getCurState();
//                    String height_lengthValueUnit = ((SensorStateBackInfo) event).getUnite();
//                    showToast("传感器---重量:" + height_lengthValue + height_lengthValueUnit);
//                    HDLLog.Log("传感器---重量:" + height_lengthValue + height_lengthValueUnit);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
//                    //传感器 物体速度
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---物体速度状态失败,请重新再试");
//                        return;
//                    }
//                    float objectSpeedValue = (float) event.getAppliancesInfo().getCurState();
//                    String objectSpeedUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---物体速度:" + objectSpeedValue + objectSpeedUnite);
//                    HDLLog.Log("传感器---物体速度:" + objectSpeedValue + objectSpeedUnite);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_SHAKE:
//                    //传感器 震动
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---震动状态失败,请重新再试");
//                        return;
//                    }
//                    float shakeValue = (float) event.getAppliancesInfo().getCurState();
//                    String shakeValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---震动:" + shakeValue + shakeValueUnite);
//                    HDLLog.Log("传感器---震动:" + shakeValue + shakeValueUnite);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_VOLTAGE:
//                    //传感器 电压
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---电压状态失败,请重新再试");
//                        return;
//                    }
//                    float voltageValue = (float) event.getAppliancesInfo().getCurState();
//                    String voltageValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---电压:" + voltageValue + voltageValueUnite);
//                    HDLLog.Log("传感器---电压:" + voltageValue + voltageValueUnite);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
//                    //传感器 电流
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---电流状态失败,请重新再试");
//                        return;
//                    }
//                    float electricityValue = (float) event.getAppliancesInfo().getCurState();
//                    String electricityValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---电流:" + electricityValue + electricityValueUnite);
//                    HDLLog.Log("传感器---电流:" + electricityValue + electricityValueUnite);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_POWER:
//                    //传感器 功率
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---功率状态失败,请重新再试");
//                        return;
//                    }
//                    float powerValue = (float) event.getAppliancesInfo().getCurState();
//                    String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---功率:" + powerValue + powerValueUnite);
//                    HDLLog.Log("传感器---功率:" + powerValue + powerValueUnite);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_FLOODING:
//                    //传感器 水浸
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---水浸状态失败,请重新再试");
//                        return;
//                    }
//                    float floodingValue = (float) event.getAppliancesInfo().getCurState();
//                    String floodingValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---水浸:" + floodingValue + floodingValueUnite);
//                    HDLLog.Log("传感器---水浸:" + floodingValue + floodingValueUnite);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
//                    //传感器 门磁窗磁
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---门磁窗磁状态失败,请重新再试");
//                        return;
//                    }
//                    float doorMagnetValue = (float) event.getAppliancesInfo().getCurState();
//                    String doorMagnetValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---门磁窗磁:" + doorMagnetValue + doorMagnetValueUnite);
//                    HDLLog.Log("传感器---门磁窗磁:" + doorMagnetValue + doorMagnetValueUnite);
//                    break;
//                case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
//                    //传感器 紧急按钮
//                    if (!event.isSuccess()) {
//                        showToast("获取传感器---紧急按钮状态失败,请重新再试");
//                        return;
//                    }
//                    float emergencyButtonValue = (float) event.getAppliancesInfo().getCurState();
//                    String emergencyButtonUnite = ((SensorStateBackInfo) event).getUnite();//数值单位
//                    showToast("传感器---紧急按钮:" + emergencyButtonValue + emergencyButtonUnite);
//                    HDLLog.Log("传感器---紧急按钮:" + emergencyButtonValue + emergencyButtonUnite);
//                    break;
//
//
//            }
//        }
//    }
}
app/src/main/res/layout/activity_add_devices.xml
@@ -10,7 +10,7 @@
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="20dp"
            android:layout_marginRight="10dp"
@@ -264,7 +264,7 @@
                android:id="@+id/btn_addAll"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="20dp"
                android:text="添加测试" />
hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java
@@ -170,7 +170,13 @@
    public static final int COMMON_SWITCH_CTRL_BACK_COMMAND = 0xE01D;//通用开关控制反馈
    public static final int COMMON_SWITCH_STATE_COMMAND = 0xE018;//读通用开关状态
    public static final int COMMON_SWITCH_STATE_BACK_COMMAND = 0xE019;//读通用开关状态反馈
    /**
     * 2020-06-23 干接点 水浸、门磁、煤气、烟雾
     */
    public static final int DRY_CONTACT_STATE_COMMAND = 0x15CE;//读取干节点状态
    public static final int DRY_CONTACT_STATE_BACK_COMMAND = 0x15CF;// 干节点状态回复
    public static final int DRY_CONTACT_BROADCAST_STATE_COMMAND = 0x15D0;//干节点状态主动广播反馈
    /**
     * RCU 配置数据
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java
@@ -1228,4 +1228,57 @@
//        }
//    }
    /**
     * 获取干接点传感器模块状态
     * @param info
     */
    public static void getDryContactSensorStateFromNetwork(final AppliancesInfo info) {
        if (info == null) {
            return;
        }
        HDLDeviceManager.isGetDeviceStateSuccess = false;
        switch (info.getDeviceType()) {
            case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
            case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
            case HDLApConfig.TYPE_SENSOR_TEMP:
            case HDLApConfig.TYPE_SENSOR_HUMIDITY:
            case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
            case HDLApConfig.TYPE_SENSOR_VOC:
            case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
            case HDLApConfig.TYPE_SENSOR_C02:
            case HDLApConfig.TYPE_SENSOR_LPG:
            case HDLApConfig.TYPE_SENSOR_CO_H2:
            case HDLApConfig.TYPE_SENSOR_CH4:
            case HDLApConfig.TYPE_SENSOR_SMOG:
            case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
            case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
            case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
            case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
            case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
            case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
            case HDLApConfig.TYPE_SENSOR_WEIGHT:
            case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
            case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
            case HDLApConfig.TYPE_SENSOR_SHAKE:
            case HDLApConfig.TYPE_SENSOR_VOLTAGE:
            case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
            case HDLApConfig.TYPE_SENSOR_POWER:
            case HDLApConfig.TYPE_SENSOR_FLOODING:
            case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
            case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
                //发送获传感器模块状态数据
                byte[] sendDatabyte = new byte[]{
                        (byte) 1,
                        (byte) info.getChannelNum()
                };
                addSendData(info, sendDatabyte, Configuration.STATE);
                break;
            default:
                HDLLog.info("不是传感器模块");
                break;
        }
    }
}
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -34,6 +34,7 @@
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchStateBackEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DryContactSensorBackEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent;
@@ -189,6 +190,11 @@
                break;
            case Configuration.COMMON_SWITCH_STATE_BACK_COMMAND:
                handleCommonSwitchStateData(getDatas);
                break;
            /***2020-06-23 新增干节点指令**/
            case Configuration.DRY_CONTACT_STATE_BACK_COMMAND:
            case Configuration.DRY_CONTACT_BROADCAST_STATE_COMMAND:
                handleDryContactBroadcastStateData(getDatas);
                break;
            case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729新增
            case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://报警设置反馈
@@ -2833,4 +2839,42 @@
    }
    /**
     * 干接点广播状态反馈反馈
     * 2020-06-24 新增
     *
     * @param getDatas
     */
    private static void handleDryContactBroadcastStateData(UdpDataBean getDatas) {
        outter:
        for (int i = 0, len = devicesDataList.size(); i < len; i++) {
            if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
                    && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
            ) {
                List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
                for (int j = 0, len2 = infos.size(); j < len2; j++) {
                    if (infos.get(j).getBigType() == Configuration.SENSOR_BIG_TYPE
                            && infos.get(j).getChannelNum() == (getDatas.addBytes[1] & 0xFF)) {//2019-07-29
                        if (getDatas.addBytes.length >= 3) {
                            isGetDeviceStateSuccess = true;
                            int state = getDatas.addBytes[2] & 0xFF;
                            devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(state);
//                            devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
                            EventBus.getDefault().post(new DryContactSensorBackEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true, state));
                        } else {
                            isGetDeviceStateSuccess = true;
                            EventBus.getDefault().post(new DryContactSensorBackEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), false));
                            HDLLog.info("DryContac 返回addBytes数据异常");
                        }
                        break outter;
                    } else {
//                        HDLLog.I("DryContac 没有找到匹配类型");
                    }
                }
                break outter;
            }
        }
    }
}
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java
@@ -438,6 +438,8 @@
            case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729安防模块 布防设置反馈
            case Configuration.SECURITY_STATE_BACK_COMMAND://20190729 读取安防设置反馈
            case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://20190729 报警设置反馈
            case Configuration.DRY_CONTACT_STATE_BACK_COMMAND:
            case Configuration.DRY_CONTACT_BROADCAST_STATE_COMMAND://2020-06-23 增加干接点状态回复
            case Configuration.CURTAIN_STATE_BACK_COMMAND:
            case Configuration.AIR_STATE_BACK_COMMAND:
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DryContactSensorBackEvent.java
New file
@@ -0,0 +1,22 @@
package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo;
public class DryContactSensorBackEvent extends DeviceStateEvent {
    private int mState;
    public DryContactSensorBackEvent(AppliancesInfo appliancesInfo, boolean isSuccess) {
        super(appliancesInfo, isSuccess);
    }
    public DryContactSensorBackEvent(AppliancesInfo appliancesInfo, boolean isSuccess, int mState) {
        super(appliancesInfo, isSuccess);
        this.mState = mState;
    }
    public int getState() {
        return mState;
    }
}
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java
@@ -599,7 +599,18 @@
                appliancesInfo.setDeviceName("传感器 功率");
                appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_POWER);
                break;
            case 25:
                appliancesInfo.setDeviceName("传感器 水浸");
                appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_FLOODING);
                break;
            case 26:
                appliancesInfo.setDeviceName("传感器 门磁窗磁");
                appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_DOOR_MAGNET);
                break;
            case 27:
                appliancesInfo.setDeviceName("传感器 紧急按钮");
                appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON);
                break;
            default:
                appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
@@ -611,8 +622,9 @@
            appliancesInfo.setLittleType(littleType);
//            appliancesInfo.setCtrlCommand(Configuration.LOGIC_CTRL_COMMAND);
//            appliancesInfo.setCtrlBackCommand(Configuration.LOGIC_CTRL_BACK_COMMAND);
            appliancesInfo.setStateCommand(Configuration.SENSOR_STATE_COMMAND);
            appliancesInfo.setStateBackCommand(Configuration.SENSOR_STATE_BACK_COMMAND);
//            appliancesInfo.setStateCommand(Configuration.SENSOR_STATE_COMMAND);
//            appliancesInfo.setStateBackCommand(Configuration.SENSOR_STATE_BACK_COMMAND);
            appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
            appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
            appliancesInfo.setParentRemarks(parentRemarks);
@@ -620,6 +632,16 @@
            appliancesInfo.setIpAddress(ipAddress);
            if (littleType == 0 || littleType == 1 || littleType == 10 ||  littleType == 11 || littleType == 25 || littleType == 26 || littleType == 27) {
                //干节点0 移动传感器1 煤气传感器10 烟雾传感器11 水浸25 门磁窗磁26 紧急按钮27
                appliancesInfo.setStateCommand(Configuration.DRY_CONTACT_STATE_COMMAND);
                appliancesInfo.setStateBackCommand(Configuration.DRY_CONTACT_STATE_BACK_COMMAND);
            } else {
                appliancesInfo.setStateCommand(Configuration.SENSOR_STATE_COMMAND);
                appliancesInfo.setStateBackCommand(Configuration.SENSOR_STATE_BACK_COMMAND);
            }
        }