2020-06-24 1.修改添加场景方法,需要指定回路号
添加场景:回路号 这里的回路号需要注意,相同子网号和设备号下的场景需要累加不重复,逻辑模块为例:1区有3个表,2区有2个表 总共5个场景,所以(2区表1 回路号为4、2区表2 回路号为5)
| | |
| | | private String parentRemarks; |
| | | private ArrayList<String> parentRemarksList = new ArrayList(); |
| | | |
| | | private EditText et_subnetID, et_deviceID, et_bitType, et_littleType, et_remarks, et_remarks_mk, et_mChannelNum,et_scene,et_mPort; |
| | | private EditText et_subnetID, et_deviceID, et_bitType, et_littleType, et_remarks, et_remarks_mk, et_mChannelNum,et_scene,et_mPort,et_scene2; |
| | | private Button btn_add,btn_scene,btn_addAll; |
| | | |
| | | @Override |
| | |
| | | et_mPort = findViewById(R.id.et_mPort); |
| | | |
| | | et_scene = findViewById(R.id.et_scene); |
| | | et_scene2 = findViewById(R.id.et_scene2); |
| | | |
| | | btn_add = findViewById(R.id.btn_add); |
| | | btn_scene = findViewById(R.id.btn_scene); |
| | |
| | | return; |
| | | } |
| | | String mChannelNumStr = et_mChannelNum.getText().toString(); |
| | | if (TextUtils.isEmpty(littleTypeStr)) { |
| | | if (TextUtils.isEmpty(mChannelNumStr)) { |
| | | showToast("回路号不能为空"); |
| | | return; |
| | | } |
| | |
| | | * |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mChannelNum 回路号 这里的回路号需要注意,相同子网号和设备号下的场景需要累加不重复,逻辑模块为例:1区有3个表,2区有2个表 总共5个场景,所以(2区表1 回路号为4、2区表2 回路号为5) |
| | | * @param mAreaNum //场景 区域号 |
| | | * @param mAreaSceneNum //场景 当前区域场景号 |
| | | * @param mChannelRemark 读取场景的备注名称 例如: 入住、起床模式、阅读模式 |
| | |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | */ |
| | | private void AddScenesDevices(int mSubnetID, int mDeviceID, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | private void AddScenesDevices(int mSubnetID, int mDeviceID, int mChannelNum, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | //添加场景 |
| | | DevicesData mScenesData = DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, mAreaNum, mAreaSceneNum, mChannelRemark, parentRemarks,true); |
| | | DevicesData mScenesData = DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, mChannelNum, mAreaNum, mAreaSceneNum, mChannelRemark, parentRemarks,true); |
| | | } |
| | | |
| | | |
| | |
| | | showToast("端口号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String mChannelNumStr = et_mChannelNum.getText().toString(); |
| | | if (TextUtils.isEmpty(mChannelNumStr)) { |
| | | showToast("回路号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | // String bitTypeStr = et_bitType.getText().toString(); |
| | | // if (TextUtils.isEmpty(bitTypeStr)) { |
| | |
| | | return; |
| | | } |
| | | |
| | | String et_sceneString = et_scene.getText().toString(); |
| | | if (TextUtils.isEmpty(et_sceneString)) { |
| | | showToast("场景ID不能为空"); |
| | | String et_AreaNumString = et_scene.getText().toString(); |
| | | if (TextUtils.isEmpty(et_AreaNumString)) { |
| | | showToast("场景:区号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String et_scene2String = et_scene2.getText().toString(); |
| | | if (TextUtils.isEmpty(et_scene2String)) { |
| | | showToast("场景:场景号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | mSubnetID = Integer.parseInt(subnetIDStr); |
| | |
| | | port = Integer.parseInt(mPortStr); |
| | | // bigType = Integer.parseInt(bitTypeStr); |
| | | // littleType = Integer.parseInt(littleTypeStr); |
| | | // mChannelNum = Integer.parseInt(mChannelNumStr); |
| | | mChannelNum = Integer.parseInt(mChannelNumStr); |
| | | parentRemarks = remarksMkString; |
| | | int sceneID = Integer.parseInt(et_sceneString); |
| | | int areaID = Integer.parseInt(et_AreaNumString); |
| | | int sceneID = Integer.parseInt(et_scene2String); |
| | | |
| | | DevicesData mScenesData = DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, sceneID, sceneID, remarksString, parentRemarks,true); |
| | | DevicesData mScenesData = DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, mChannelNum, areaID, sceneID, remarksString, parentRemarks,true); |
| | | if (mScenesData != null) { |
| | | showToast("添加成功"); |
| | | } else { |
| | |
| | | // DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, 5, 5, "会客模式", parentRemarks,true); |
| | | |
| | | |
| | | //添加一个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); |
| | | // //添加一个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路窗帘 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 2, 111, 8, 1, "窗帘", "2路窗帘",false); |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 2, 111, 8, 2, "纱窗", "2路窗帘",false); |
| | | // //添加一个开合帘 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 1, 111, 92, 1, "开合帘", "开合帘",false); |
| | | // |
| | | // //添加一个空调 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.AIR_BIG_TYPE, 0, 111, 9, 1, "房间空调", "HVAC空调模块",false); |
| | | |
| | | //添加一个干节点传感器 |
| | | DeviceParser.addDevicesListWithoutSearching(port, Configuration.SENSOR_BIG_TYPE, 0, 111, 99, 1, "干节点", "干节点",false); |
| | | /** |
| | | * 场景这里的回路号需要注意: 相同子网号和设备号下的场景需要累加不重复,逻辑模块为例:1区有3个表,2区有2个表 总共5个场景,所以(2区表1 回路号为4、2区表2 回路号为5) |
| | | * 不然如果回路号不对简易编程搜索备注的话会出错 |
| | | */ |
| | | //添加一个场景 |
| | | DeviceParser.addLogicScenesDevicesListWithoutSearching(port, 1, 16, 4, 2, 1, "卧室开灯", "逻辑模块",false); |
| | | |
| | | |
| | | //添加一个2路窗帘 |
| | | DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 2, 111, 8, 1, "窗帘", "2路窗帘",false); |
| | | DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 2, 111, 8, 2, "纱窗", "2路窗帘",false); |
| | | //添加一个开合帘 |
| | | DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 1, 111, 92, 1, "开合帘", "开合帘",false); |
| | | |
| | | //添加一个空调 |
| | | DeviceParser.addDevicesListWithoutSearching(port, Configuration.AIR_BIG_TYPE, 0, 111, 9, 1, "房间空调", "HVAC空调模块",false); |
| | | //添加一个场景 最后一个bSaveAndCallBack 设置为true |
| | | DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, 5, 5, "会客模式", parentRemarks,true); |
| | | DeviceParser.addLogicScenesDevicesListWithoutSearching(port, 1, 16, 5,2, 2, "卧室关灯", "逻辑模块",true); |
| | | |
| | | |
| | | |
| | |
| | | // 获取所有设备的状态。deviceStateBeanList为所有设备的状态列表 |
| | | List<DeviceStateBean> deviceStateBeanList = HDLCommand.getAllDevicesState(); |
| | | // 第三方可根据自己的需求刷新设备页。以下为示例代码。 |
| | | for (DeviceStateBean deviceStateBean : deviceStateBeanList) { |
| | | //注意!第三方应该将设备集合全部在这里遍历一遍以下操作,并更新状态值。这里仅作为Demo演示,只判断一个。 |
| | | if(deviceStateBeanList != null) { |
| | | for (DeviceStateBean deviceStateBean : deviceStateBeanList) { |
| | | //注意!第三方应该将设备集合全部在这里遍历一遍以下操作,并更新状态值。这里仅作为Demo演示,只判断一个。 |
| | | |
| | | //先判断此模块是否为当前设备的模块 |
| | | if (deviceStateBean.getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && deviceStateBean.getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()) { |
| | | //先判断此模块是否为当前设备的模块 |
| | | if (deviceStateBean.getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && deviceStateBean.getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()) { |
| | | // 再判断是什么类型的设备。 |
| | | switch (deviceStateBean.getDeviceType()) { |
| | | case HDLApConfig.TYPE_LIGHT_DIMMER: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_LIGHT_RELAY: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_LIGHT_MIX_DIMMER: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_LIGHT_MIX_RELAY: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_CURTAIN_GLYSTRO: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_CURTAIN_ROLLER: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_CURTAIN_MODULE: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_AC_HVAC: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setArrCurState(deviceStateBean.getArrCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_AC_PANEL: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setArrCurState(deviceStateBean.getArrCurState()); |
| | | } |
| | | break; |
| | | switch (deviceStateBean.getDeviceType()) { |
| | | case HDLApConfig.TYPE_LIGHT_DIMMER: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_LIGHT_RELAY: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_LIGHT_MIX_DIMMER: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_LIGHT_MIX_RELAY: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_CURTAIN_GLYSTRO: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_CURTAIN_ROLLER: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_CURTAIN_MODULE: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setCurState(deviceStateBean.getCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_AC_HVAC: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setArrCurState(deviceStateBean.getArrCurState()); |
| | | } |
| | | break; |
| | | case HDLApConfig.TYPE_AC_PANEL: |
| | | //判断是哪个回路的设备 |
| | | if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) { |
| | | appliancesInfo.setArrCurState(deviceStateBean.getArrCurState()); |
| | | } |
| | | break; |
| | | |
| | | |
| | | default: |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLSDK; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HandleSearch; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.BgmInfoEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DevicesInfoEvent; |
| | |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_main); |
| | | NetWorkUtil.setIsGetWifiBroadCast(true); |
| | | // HDLSDK.init(this); |
| | | // HDLSDK.startHomeMode(this); |
| | | HDLSDK.init(this); |
| | | //控制BUS设备模式 |
| | | HDLSDK.startHomeMode(this); |
| | | |
| | | HDLCommand.init(this); |
| | | HDLCommand.startHomeMode(this); |
| | | // //控制RCU设备模式 |
| | | // HDLSDK.startRcuMode(this,"192.168.10.111"); |
| | | |
| | | // |
| | | // HDLCommand.init(this); |
| | | // HDLCommand.startHomeMode(this); |
| | | |
| | | // /**配置是否开启SDK打印日志,默认为打开*/ |
| | | // HDLCommand.setHDLLogOpen(false);// |
| | |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="12sp" |
| | | android:text="回路备注:"></TextView> |
| | | android:text="回路或场景的备注:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_remarks" |
| | |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="场景号:"></TextView> |
| | | android:text="区号:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_scene" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:hint="区号和场景号" /> |
| | | android:hint="区号和场景号" |
| | | android:text="2" |
| | | android:inputType="number" |
| | | android:maxLength="3"/> |
| | | </LinearLayout> |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="80dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="场景号:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_scene2" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:text="2" |
| | | android:inputType="number" |
| | | android:maxLength="3" |
| | | android:hint="场景号" /> |
| | | </LinearLayout> |
| | | |
| | | <Button |
| | |
| | | android:id="@+id/btn_addAll" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginBottom="20dp" |
| | | android:layout_marginBottom="40dp" |
| | | android:text="添加测试" /> |
| | | |
| | | |
| | |
| | | <resources> |
| | | <string name="app_name">HDL_SDK</string> |
| | | <string name="app_version">hdl_lib_v1.7.0.20200601_beta</string> |
| | | <string name="app_version">hdl_lib_v1.7.1.20200624_beta</string> |
| | | <string name="btn_save">保存</string> |
| | | <string name="et_subnetid_hint">子网号(范围0 - 254)</string> |
| | | <string name="et_deviceid_hint">设备号号(范围0 - 254)</string> |
| | |
| | | defaultConfig { |
| | | minSdkVersion 17 |
| | | targetSdkVersion 28 |
| | | versionCode 10 |
| | | versionName "1.7.0" |
| | | versionCode 11 |
| | | versionName "1.7.1" |
| | | |
| | | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
| | | |
| | |
| | | //package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; |
| | | // |
| | | //import android.content.Context; |
| | | // |
| | | //import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; |
| | | //import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; |
| | | // |
| | | ///** |
| | | // * Created by jlchen on 2020-06-23. |
| | | // */ |
| | | //public class HDLSDK { |
| | | // |
| | | // /** |
| | | // * 初始化 SDK |
| | | // * |
| | | // * @param context |
| | | // */ |
| | | // public static void init(Context context) { |
| | | // HDLDeviceManager.init(context); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 开启bus模式 |
| | | // * 启用6000端口 |
| | | // * @param context |
| | | // */ |
| | | // public static void startHomeMode(Context context) { |
| | | // SPUtils.setParam(context, SPUtils.KEY_RCU_IP_, ""); |
| | | // HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; |
| | | // HandleSearch.rcuIp = ""; |
| | | // HDLUdpCore.closeSocket6008(); |
| | | // HDLUdpCore.init6000(); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 开启RCU模式 |
| | | // * 启用6008端口 |
| | | // * @param context |
| | | // * @param newRcuIp RCU的IP地址 |
| | | // */ |
| | | // public static void startRcuMode(Context context, String newRcuIp) { |
| | | // HandleSearch.curSearchMode = HandleSearch.GET_RCU_DEVICES; |
| | | // HandleSearch.rcuIp = newRcuIp; |
| | | // SPUtils.setParam(context, SPUtils.KEY_RCU_IP_, newRcuIp); |
| | | // HDLUdpCore.closeSocket6000(); |
| | | // HDLUdpCore.init6008(); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 是否开启SDK日志打印 |
| | | // * |
| | | // * @param bOpen |
| | | // */ |
| | | // public static void setHDLLogOpen(boolean bOpen) { |
| | | // HDLLog.setHDLLogOpen(bOpen); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 释放资源 关闭串口 |
| | | // */ |
| | | // public static void release() { |
| | | // HDLDeviceManager.release(); |
| | | // } |
| | | //} |
| | | package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; |
| | | import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; |
| | | |
| | | /** |
| | | * Created by jlchen on 2020-06-23. |
| | | */ |
| | | public class HDLSDK { |
| | | |
| | | /** |
| | | * 初始化 SDK |
| | | * |
| | | * @param context |
| | | */ |
| | | public static void init(Context context) { |
| | | HDLDeviceManager.init(context); |
| | | } |
| | | |
| | | /** |
| | | * 开启bus模式 |
| | | * 启用6000端口 |
| | | * @param context |
| | | */ |
| | | public static void startHomeMode(Context context) { |
| | | SPUtils.setParam(context, SPUtils.KEY_RCU_IP_, ""); |
| | | HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; |
| | | HandleSearch.rcuIp = ""; |
| | | HDLUdpCore.closeSocket6008(); |
| | | HDLUdpCore.init6000(); |
| | | } |
| | | |
| | | /** |
| | | * 开启RCU模式 |
| | | * 启用6008端口 |
| | | * @param context |
| | | * @param newRcuIp RCU的IP地址 |
| | | */ |
| | | public static void startRcuMode(Context context, String newRcuIp) { |
| | | HandleSearch.curSearchMode = HandleSearch.GET_RCU_DEVICES; |
| | | HandleSearch.rcuIp = newRcuIp; |
| | | SPUtils.setParam(context, SPUtils.KEY_RCU_IP_, newRcuIp); |
| | | HDLUdpCore.closeSocket6000(); |
| | | HDLUdpCore.init6008(); |
| | | } |
| | | |
| | | /** |
| | | * 是否开启SDK日志打印 |
| | | * |
| | | * @param bOpen |
| | | */ |
| | | public static void setHDLLogOpen(boolean bOpen) { |
| | | HDLLog.setHDLLogOpen(bOpen); |
| | | } |
| | | |
| | | /** |
| | | * 释放资源 关闭串口 |
| | | */ |
| | | public static void release() { |
| | | HDLDeviceManager.release(); |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加场景设备回路 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mChannelNum 回路号 |
| | | * @param mAreaNum //场景 区域号 |
| | | * @param mAreaSceneNum //场景 当前区域场景号 |
| | | * @param mChannelRemark |
| | | * @param parentRemarks |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | * |
| | | * 场景这里的回路号需要注意: 相同子网号和设备号下的场景需要累加不重复,逻辑模块为例:1区有3个表,2区有2个表 总共5个场景,所以(2区表1 回路号为4、2区表2 回路号为5) |
| | | * 不然如果回路号不对简易编程搜索备注的话会出错 |
| | | */ |
| | | public static DevicesData addScenesDevicesListWithoutSearching(int port, int mSubnetID, int mDeviceID, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | public static DevicesData addScenesDevicesListWithoutSearching(int port, int mSubnetID, int mDeviceID, int mChannelNum, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | // boolean bWantData = false; |
| | | |
| | | int bigType = Configuration.GLOBAL_LOGIC_BIG_TYPE; |
| | |
| | | |
| | | |
| | | if (isFindDevicesData) { |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mAreaNum, port, parentRemarks, mChannelRemark); |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mChannelNum, port, parentRemarks, mChannelRemark); |
| | | LogicMode mLogicMode = new LogicMode(); |
| | | mLogicMode.setAreaNum(mAreaNum); |
| | | mLogicMode.setAreaSceneNum(mAreaSceneNum); |
| | |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | } else { |
| | | List<AppliancesInfo> appliancesInfoList = new ArrayList<>(); |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mAreaNum, port, parentRemarks, mChannelRemark); |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mChannelNum, port, parentRemarks, mChannelRemark); |
| | | LogicMode mLogicMode = new LogicMode(); |
| | | mLogicMode.setAreaNum(mAreaNum); |
| | | mLogicMode.setAreaSceneNum(mAreaSceneNum); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加逻辑模块的场景设备回路 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mChannelNum 回路号 |
| | | * @param mAreaNum //场景 区域号 |
| | | * @param mAreaSceneNum //场景 当前区域场景号 |
| | | * @param mChannelRemark |
| | | * @param parentRemarks |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | */ |
| | | public static DevicesData addLogicScenesDevicesListWithoutSearching(int port, int mSubnetID, int mDeviceID, int mChannelNum, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | // boolean bWantData = false; |
| | | |
| | | int bigType = Configuration.LOGIC_BIG_TYPE; |
| | | int littleType = 0; |
| | | if (isWantData(bigType, littleType)) { |
| | | DevicesData devicesData = new DevicesData(); |
| | | devicesData.setSourceSubnetID(mSubnetID); |
| | | devicesData.setSourceDeviceID(mDeviceID); |
| | | devicesData.setRemark(parentRemarks); |
| | | |
| | | Boolean isFindDevicesData = false; |
| | | int index = 0; |
| | | for (int i = 0; i < devicesDataList.size(); i++) { |
| | | if (devicesDataList.get(i).getSourceSubnetID() == mSubnetID && devicesDataList.get(i).getSourceDeviceID() == mDeviceID) { |
| | | index = i; |
| | | isFindDevicesData = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (isFindDevicesData) { |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mChannelNum, port, parentRemarks, mChannelRemark); |
| | | LogicMode mLogicMode = new LogicMode(); |
| | | mLogicMode.setAreaNum(mAreaNum); |
| | | mLogicMode.setAreaSceneNum(mAreaSceneNum); |
| | | mAppliancesInfo.setLogicMode(mLogicMode); |
| | | devicesDataList.get(index).getAppliancesInfoList().add(mAppliancesInfo); |
| | | devicesData = devicesDataList.get(index); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | } else { |
| | | List<AppliancesInfo> appliancesInfoList = new ArrayList<>(); |
| | | AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mChannelNum, port, parentRemarks, mChannelRemark); |
| | | LogicMode mLogicMode = new LogicMode(); |
| | | mLogicMode.setAreaNum(mAreaNum); |
| | | mLogicMode.setAreaSceneNum(mAreaSceneNum); |
| | | mAppliancesInfo.setLogicMode(mLogicMode); |
| | | appliancesInfoList.add(mAppliancesInfo); |
| | | devicesData.setAppliancesInfoList(appliancesInfoList); |
| | | devicesDataList.add(devicesData); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | } |
| | | |
| | | |
| | | return devicesData; |
| | | |
| | | } else { |
| | | return null; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |