2020-06-24 1.增加手动添加生成设备接口方法。 2.增加通用开关和安防模块支持。
| | |
| | | android:roundIcon="@mipmap/ic_launcher_round" |
| | | android:supportsRtl="true" |
| | | android:theme="@style/AppTheme"> |
| | | <activity android:name=".activity.SettingActivity"></activity> |
| | | <activity android:name=".activity.AddDevicesActivity"></activity> |
| | | <activity android:name=".activity.SettingActivity" /> |
| | | <activity android:name=".activity.AddDevicesManuallyActivity" /> |
| | | <activity android:name=".activity.MainActivity"> |
| | | <intent-filter> |
| | |
| | | <activity android:name=".activity.AudioActivity" /> |
| | | <activity android:name=".activity.FreshAirActivity" /> |
| | | <activity android:name=".activity.GeothermalActivity" /> |
| | | <activity android:name=".activity.CtrlCommonSwitchActivity" /> |
| | | <activity android:name=".activity.CtrlSecurityActivity" /> |
| | | |
| | | <receiver android:name=".activity.BootComplete"> |
| | | <intent-filter> |
New file |
| | |
| | | package com.hdl.sdk.hdl_sdk.activity; |
| | | |
| | | import android.app.Activity; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | import android.widget.Button; |
| | | import android.widget.EditText; |
| | | import android.widget.Toast; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.Config.Configuration; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Parser.DeviceParser; |
| | | import com.hdl.sdk.hdl_sdk.R; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | |
| | | /** SDK目前支持的大类:小类 |
| | | * 灯光类:调光回路、开关回路、混合调光类、混合开关类 |
| | | * 窗帘类:开合帘电机、卷帘电机、窗帘模块 |
| | | * 空调功能:HVAC 模块、通用空调面板 |
| | | * 背景音乐功能:背景音乐模块 2018新背景音乐模块小类3 |
| | | * 传感器:干结点0 到 功率24 |
| | | * 逻辑功能:逻辑模块 |
| | | * 全局场景: |
| | | * 地热功能:地热模块 |
| | | * 新风:新风系统 |
| | | |
| | | * 灯光类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> 格式的设备列表数据 |
| | | * |
| | | * 上层做本地保存或者云端备份,App启动时读取恢复 |
| | | * 每次启动时先加载生成好的设备列表数据,然后在 SDK 初始化后,赋值给 HDLDeviceManager.devicesDataList |
| | | */ |
| | | public class AddDevicesActivity extends Activity { |
| | | |
| | | private int bigType; |
| | | private int littleType; |
| | | private int mSubnetID; |
| | | private int mDeviceID; |
| | | private int mChannelNum; |
| | | private int port = 6000; |
| | | 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 Button btn_add,btn_scene,btn_addAll; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_add_devices); |
| | | |
| | | et_subnetID = findViewById(R.id.et_subnetID); |
| | | et_deviceID = findViewById(R.id.et_deviceID); |
| | | et_bitType = findViewById(R.id.et_bitType); |
| | | et_littleType = findViewById(R.id.et_littleType); |
| | | et_remarks = findViewById(R.id.et_remarks); |
| | | // et_port = findViewById(R.id.et_port); |
| | | et_remarks_mk = findViewById(R.id.et_remarks_mk); |
| | | et_mChannelNum = findViewById(R.id.et_mChannelNum); |
| | | et_mPort = findViewById(R.id.et_mPort); |
| | | |
| | | et_scene = findViewById(R.id.et_scene); |
| | | |
| | | btn_add = findViewById(R.id.btn_add); |
| | | btn_scene = findViewById(R.id.btn_scene); |
| | | btn_addAll= findViewById(R.id.btn_addAll); |
| | | |
| | | |
| | | btn_add.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | addDevicesManuallyWithoutSearchingAll(); |
| | | |
| | | } |
| | | }); |
| | | |
| | | btn_scene.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | addScene(); |
| | | |
| | | } |
| | | }); |
| | | |
| | | btn_addAll.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | addMultipleDevices(); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | private void addDevicesManuallyWithoutSearchingAll() { |
| | | // parentRemarksList.clear(); |
| | | |
| | | |
| | | String subnetIDStr = et_subnetID.getText().toString(); |
| | | if (TextUtils.isEmpty(subnetIDStr)) { |
| | | showToast("子网号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String deviceIDStr = et_deviceID.getText().toString(); |
| | | if (TextUtils.isEmpty(deviceIDStr)) { |
| | | showToast("设备号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String bitTypeStr = et_bitType.getText().toString(); |
| | | if (TextUtils.isEmpty(bitTypeStr)) { |
| | | showToast("大类不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String littleTypeStr = et_littleType.getText().toString(); |
| | | if (TextUtils.isEmpty(littleTypeStr)) { |
| | | showToast("小类不能为空"); |
| | | return; |
| | | } |
| | | String mChannelNumStr = et_mChannelNum.getText().toString(); |
| | | if (TextUtils.isEmpty(littleTypeStr)) { |
| | | showToast("回路号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String mPortStr = et_mPort.getText().toString(); |
| | | if (TextUtils.isEmpty(mPortStr)) { |
| | | showToast("端口号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | String remarksMkString = et_remarks_mk.getText().toString(); |
| | | if (TextUtils.isEmpty(remarksMkString)) { |
| | | showToast("模块备注不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | String remarksString = et_remarks.getText().toString(); |
| | | if (TextUtils.isEmpty(remarksString)) { |
| | | showToast("备注不能为空"); |
| | | return; |
| | | } |
| | | |
| | | // String et_portString = et_port.getText().toString(); |
| | | // if (TextUtils.isEmpty(et_portString)) { |
| | | // showToast("端口不能为空"); |
| | | // return; |
| | | // } |
| | | |
| | | |
| | | mSubnetID = Integer.parseInt(subnetIDStr); |
| | | mDeviceID = Integer.parseInt(deviceIDStr); |
| | | |
| | | bigType = Integer.parseInt(bitTypeStr); |
| | | littleType = Integer.parseInt(littleTypeStr); |
| | | mChannelNum = Integer.parseInt(mChannelNumStr); |
| | | parentRemarks = remarksMkString; |
| | | port = Integer.parseInt(mPortStr); |
| | | |
| | | |
| | | /** |
| | | * 添加设备回路 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * @param bigType 回路大类 |
| | | * @param littleType 回路小类 |
| | | * @param mSubnetID 回路子网ID |
| | | * @param mDeviceID 回路设备ID |
| | | * @param mChannelNum 回路号 |
| | | * @param mChannelRemark 回路备注 例如:窗帘、吊灯、厕所灯、电视 |
| | | * @param parentRemarks 当前回路模块的备注 例如: 酒店RCU模块 |
| | | * @return |
| | | */ |
| | | //如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | DevicesData mDevicesData = DeviceParser.addDevicesListWithoutSearching(port, bigType, littleType, mSubnetID, mDeviceID, mChannelNum, remarksString, parentRemarks,true); |
| | | if (mDevicesData != null) { |
| | | showToast("添加成功"); |
| | | } else { |
| | | showToast("添加失败"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 添加场景设备回路 需指定 场景区号 和 场景号 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mAreaNum //场景 区域号 |
| | | * @param mAreaSceneNum //场景 当前区域场景号 |
| | | * @param mChannelRemark 读取场景的备注名称 例如: 入住、起床模式、阅读模式 |
| | | * @param parentRemarks 当前回路模块的备注 例如: 酒店RCU模块 |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | */ |
| | | private void AddScenesDevices(int mSubnetID, int mDeviceID, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | //添加场景 |
| | | DevicesData mScenesData = DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, mAreaNum, mAreaSceneNum, mChannelRemark, parentRemarks,true); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加场景回路 |
| | | */ |
| | | private void addScene(){ |
| | | |
| | | String subnetIDStr = et_subnetID.getText().toString(); |
| | | if (TextUtils.isEmpty(subnetIDStr)) { |
| | | showToast("子网号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String deviceIDStr = et_deviceID.getText().toString(); |
| | | if (TextUtils.isEmpty(deviceIDStr)) { |
| | | showToast("设备号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | String mPortStr = et_mPort.getText().toString(); |
| | | if (TextUtils.isEmpty(mPortStr)) { |
| | | showToast("端口号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | // String bitTypeStr = et_bitType.getText().toString(); |
| | | // if (TextUtils.isEmpty(bitTypeStr)) { |
| | | // showToast("大类不能为空"); |
| | | // return; |
| | | // } |
| | | // |
| | | // String littleTypeStr = et_littleType.getText().toString(); |
| | | // if (TextUtils.isEmpty(littleTypeStr)) { |
| | | // showToast("小类不能为空"); |
| | | // return; |
| | | // } |
| | | // String mChannelNumStr = et_mChannelNum.getText().toString(); |
| | | // if (TextUtils.isEmpty(littleTypeStr)) { |
| | | // showToast("回路号不能为空"); |
| | | // return; |
| | | // } |
| | | |
| | | |
| | | String remarksMkString = et_remarks_mk.getText().toString(); |
| | | if (TextUtils.isEmpty(remarksMkString)) { |
| | | showToast("模块备注不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | String remarksString = et_remarks.getText().toString(); |
| | | if (TextUtils.isEmpty(remarksString)) { |
| | | showToast("备注不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String et_sceneString = et_scene.getText().toString(); |
| | | if (TextUtils.isEmpty(et_sceneString)) { |
| | | showToast("场景ID不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | mSubnetID = Integer.parseInt(subnetIDStr); |
| | | mDeviceID = Integer.parseInt(deviceIDStr); |
| | | port = Integer.parseInt(mPortStr); |
| | | // bigType = Integer.parseInt(bitTypeStr); |
| | | // littleType = Integer.parseInt(littleTypeStr); |
| | | // mChannelNum = Integer.parseInt(mChannelNumStr); |
| | | parentRemarks = remarksMkString; |
| | | int sceneID = Integer.parseInt(et_sceneString); |
| | | |
| | | DevicesData mScenesData = DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, sceneID, sceneID, remarksString, parentRemarks,true); |
| | | if (mScenesData != null) { |
| | | showToast("添加成功"); |
| | | } else { |
| | | showToast("添加失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 批量添加 |
| | | * 仅做演示用 |
| | | */ |
| | | private void addMultipleDevices(){ |
| | | |
| | | String subnetIDStr = et_subnetID.getText().toString(); |
| | | if (TextUtils.isEmpty(subnetIDStr)) { |
| | | showToast("子网号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String deviceIDStr = et_deviceID.getText().toString(); |
| | | if (TextUtils.isEmpty(deviceIDStr)) { |
| | | showToast("设备号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | String remarksMkString = et_remarks_mk.getText().toString(); |
| | | if (TextUtils.isEmpty(remarksMkString)) { |
| | | showToast("模块备注不能为空"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | mSubnetID = Integer.parseInt(subnetIDStr); |
| | | mDeviceID = Integer.parseInt(deviceIDStr); |
| | | parentRemarks = remarksMkString; |
| | | |
| | | // //添加一个灯 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, mSubnetID, mDeviceID, 1, "吧台灯", parentRemarks,false); |
| | | // //添加一个灯 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, mSubnetID, mDeviceID, 2, "休闲灯", parentRemarks,false); |
| | | // //添加一个灯 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, mSubnetID, mDeviceID, 3, "电视灯", parentRemarks,false); |
| | | // //添加一个灯 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.LIGTH_BIG_TYPE, 0, mSubnetID, mDeviceID, 6, "廊灯", parentRemarks,false); |
| | | // |
| | | // //添加一个窗帘 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 2, mSubnetID, mDeviceID, 1, "窗帘", parentRemarks,false); |
| | | // //添加一个窗帘 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.CURTAIN_BIG_TYPE, 2, mSubnetID, mDeviceID, 2, "纱窗", parentRemarks,false); |
| | | // |
| | | // //添加一个空调 |
| | | // DeviceParser.addDevicesListWithoutSearching(port, Configuration.AIR_BIG_TYPE, 0, mSubnetID, mDeviceID, 1, "房间空调", parentRemarks,false); |
| | | // |
| | | //// //添加通用开关 清理 |
| | | //// DeviceParser.addDevicesListWithoutSearching(port, Configuration.COMMON_SWITCH_BIG_TYPE, 0, mSubnetID, mDeviceID, 15, "清理", parentRemarks,false); |
| | | //// //添加通用开关 入住 |
| | | //// DeviceParser.addDevicesListWithoutSearching(port, Configuration.COMMON_SWITCH_BIG_TYPE, 0, mSubnetID, mDeviceID, 16, "入住", parentRemarks,false); |
| | | //// //添加通用开关 稍后 |
| | | //// DeviceParser.addDevicesListWithoutSearching(port, Configuration.COMMON_SWITCH_BIG_TYPE, 0, mSubnetID, mDeviceID, 13, "稍后", parentRemarks,false); |
| | | //// //添加通用开关 勿扰 |
| | | //// DeviceParser.addDevicesListWithoutSearching(port, Configuration.COMMON_SWITCH_BIG_TYPE, 0, mSubnetID, mDeviceID, 14, "勿扰", parentRemarks,false); |
| | | //// //添加一个安防模块 |
| | | //// DeviceParser.addDevicesListWithoutSearching(port, Configuration.SECURITY_BIG_TYPE, 0, 12, 1, 1, "安防模块", "安防模块",false); |
| | | // |
| | | // //添加一个场景 这里场景号和区号 默认一样 |
| | | // DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, 2, 2, "空置无卡", parentRemarks,false); |
| | | // //添加一个场景 |
| | | // DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, 3, 3, "插卡场景", parentRemarks,false); |
| | | // //添加一个场景 |
| | | // DeviceParser.addScenesDevicesListWithoutSearching(port, mSubnetID, mDeviceID, 4, 4, "房灯", parentRemarks,false); |
| | | // //添加一个场景 最后一个bSaveAndCallBack 设置为true |
| | | // 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); |
| | | |
| | | |
| | | //添加一个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); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private void showToast(String text) { |
| | | Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | }else if (appliancesInfos.get(position).getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { |
| | | //大类是地热模块则跳转到GeothermalActivity |
| | | intent.setClass(AppliancesActivity.this, GeothermalActivity.class); |
| | | }else { |
| | | }else if (appliancesInfos.get(position).getBigType() == Configuration.COMMON_SWITCH_BIG_TYPE) { |
| | | //大类是通用开关则跳转到CtrlCommonSwitchActivity |
| | | intent.setClass(AppliancesActivity.this, CtrlCommonSwitchActivity.class); |
| | | }else if (appliancesInfos.get(position).getBigType() == Configuration.SECURITY_BIG_TYPE) { |
| | | //大类是安防模块则跳转到CtrlSecurityActivity |
| | | intent.setClass(AppliancesActivity.this, CtrlSecurityActivity.class); |
| | | } |
| | | |
| | | |
| | | else { |
| | | intent.setClass(AppliancesActivity.this, CtrlActivity.class); |
| | | } |
| | | Bundle bundle = new Bundle(); |
New file |
| | |
| | | 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.CommonSwitchCtrlBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchStateBackEvent; |
| | | import com.hdl.sdk.hdl_sdk.R; |
| | | import com.hdl.sdk.hdl_sdk.base.BaseActivity; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | /** |
| | | * 通用开关设备演示 |
| | | */ |
| | | public class CtrlCommonSwitchActivity extends BaseActivity { |
| | | |
| | | /**Topbar*/ |
| | | private RelativeLayout topBarBack; |
| | | private TextView topBarTitle; |
| | | private Button btnOpen,btnClose; |
| | | private TextView switchText; |
| | | private AppliancesInfo appliancesInfo; |
| | | private int switchState = 0; |
| | | |
| | | |
| | | /** |
| | | * 复写isRegisterEventBus() 要注册使用EventBus,这里要设置返回true |
| | | * |
| | | * @return true |
| | | */ |
| | | @Override |
| | | protected boolean isRegisterEventBus() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_ctrl_common_switch); |
| | | initToolbar(); |
| | | initcurState(); |
| | | initView(); |
| | | initOnClick(); |
| | | displayStateView(); |
| | | |
| | | //从网络上查询刷新一次设备状态,待调试 |
| | | // HDLCommand.getCommonSwitchStateFromNetwork(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() { |
| | | btnOpen = findViewById(R.id.btnOpen); |
| | | |
| | | btnClose = findViewById(R.id.btnClose); |
| | | switchText = findViewById(R.id.switchText); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | private void initOnClick() { |
| | | |
| | | btnOpen.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | //0=关 255=开 |
| | | HDLCommand.commonSwitchCtrl(appliancesInfo, 255); |
| | | } |
| | | }); |
| | | |
| | | btnClose.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | HDLCommand.commonSwitchCtrl(appliancesInfo,0); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void displayStateView(){ |
| | | |
| | | switch (appliancesInfo.getDeviceType()) { |
| | | case HDLApConfig.TYPE_COMMON_SWITCH: |
| | | break; |
| | | default: |
| | | finish();//设备类型不对结束页面 |
| | | break; |
| | | } |
| | | /**根据需求是否发送一次获取刷新状态请求*/ |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通用开关控制回调Event |
| | | * |
| | | * @param event |
| | | */ |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onCommonSwitchCtrlEventMain(CommonSwitchCtrlBackEvent event) { |
| | | if (event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() |
| | | && event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && event.getCommonSwitchBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() |
| | | ) { |
| | | if (!event.isSuccess()) { |
| | | showToast("通用开关控制超时,请重新再试"); |
| | | return; |
| | | } |
| | | |
| | | showToast("通用开关控制成功"); |
| | | |
| | | switchState = event.getCommonSwitchBackInfo().getSwitchState(); |
| | | if(switchState>0){ |
| | | switchText.setText("当前状态:开"); |
| | | }else{ |
| | | switchText.setText("当前状态:关"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 通用开关 回调Event |
| | | * |
| | | * @param event |
| | | */ |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onCommonSwitchStateEventMain(CommonSwitchStateBackEvent event) { |
| | | if (event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() |
| | | && event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && event.getCommonSwitchBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() |
| | | ) { |
| | | if (!event.isSuccess()) { |
| | | showToast("通用开关读取状态超时,请重新再试"); |
| | | return; |
| | | } |
| | | |
| | | // showToast("通用开关控制成功"); |
| | | |
| | | switchState = event.getCommonSwitchBackInfo().getSwitchState(); |
| | | if(switchState>0){ |
| | | switchText.setText("当前状态:开"); |
| | | }else{ |
| | | switchText.setText("当前状态:关"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 读取指定RCU房间门铃状态 |
| | | // HDLCommand.getHotelRoomDoorbellStatus(100,100); |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.hdl.sdk.hdl_sdk.activity; |
| | | |
| | | |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | import android.widget.AdapterView; |
| | | import android.widget.ArrayAdapter; |
| | | import android.widget.Button; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.Spinner; |
| | | import android.widget.TextView; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.Parser.SecurityParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.SecurityArmingStateBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.SecurityStateBean; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityAlarmFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; |
| | | 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; |
| | | |
| | | /** |
| | | * 安防模块控制页面 |
| | | */ |
| | | public class CtrlSecurityActivity extends BaseActivity { |
| | | /** |
| | | * Topbar |
| | | */ |
| | | // private RelativeLayout topBarBack; |
| | | // private TextView topBarTitle; |
| | | private AppliancesInfo appliancesInfo; |
| | | private Button btn_read_config, btn_set_arming, btn_send_alarm; |
| | | private Spinner spinner_arming; |
| | | // private TextView tv_alarmFire, tv_alarmGas, tv_alarmSudden, tv_alarmEmergency, tv_alarmCurrent, tv_alarmSilent, tv_alarmPower, tv_alarmTemperature; |
| | | private TextView tv_mes; |
| | | private static final String[] armingTypeItems = {"假期布防", "离开布防", "夜间布防", "晚上有客布防", "白天布防", "撤防"}; |
| | | private int armingState;//布防状态 6 = 撤防 5 = 白天布防 4 = 晚上有客布防 3 = 夜间布防 2 = 离开布防 1 = 假期布防 |
| | | private SecurityStateBean mSecurityStateBean; |
| | | |
| | | private int alarmSendState;//发送测试报警 |
| | | |
| | | /** |
| | | * 复写isRegisterEventBus() 要注册使用EventBus,这里要设置返回true |
| | | * |
| | | * @return true |
| | | */ |
| | | @Override |
| | | protected boolean isRegisterEventBus() { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_ctrl_security); |
| | | |
| | | initToolbar(); |
| | | initView(); |
| | | initOnClick(); |
| | | initcurState(); |
| | | //读布防状态 |
| | | HDLCommand.getSecurityStateFromNetwork(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(); |
| | | // } |
| | | // }); |
| | | // topBarTitle.setText("安防模块演示"); |
| | | } |
| | | |
| | | /** |
| | | * initView |
| | | */ |
| | | private void initView() { |
| | | btn_read_config = findViewById(R.id.btn_read_config); |
| | | btn_set_arming = findViewById(R.id.btn_set_arming); |
| | | btn_send_alarm = findViewById(R.id.btn_send_alarm); |
| | | spinner_arming = findViewById(R.id.spinner_arming); |
| | | |
| | | // tv_alarmFire = findViewById(R.id.tv_alarmFire); |
| | | // tv_alarmGas = findViewById(R.id.tv_alarmGas); |
| | | // tv_alarmSudden = findViewById(R.id.tv_alarmSudden); |
| | | // |
| | | // tv_alarmEmergency = findViewById(R.id.tv_alarmEmergency); |
| | | // tv_alarmCurrent = findViewById(R.id.tv_alarmCurrent); |
| | | // tv_alarmSilent = findViewById(R.id.tv_alarmSilent); |
| | | // tv_alarmPower = findViewById(R.id.tv_alarmPower); |
| | | // tv_alarmTemperature = findViewById(R.id.tv_alarmTemperature); |
| | | tv_mes = findViewById(R.id.tv_mes); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * initOnClick |
| | | */ |
| | | private void initOnClick() { |
| | | /** |
| | | * 读布防状态 |
| | | */ |
| | | btn_read_config.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | HDLCommand.getSecurityStateFromNetwork(appliancesInfo); |
| | | } |
| | | }); |
| | | |
| | | /** |
| | | * 布防 |
| | | */ |
| | | btn_set_arming.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | /** |
| | | * 要先撤防后布防 |
| | | */ |
| | | HDLCommand.securityArmingCtrl(appliancesInfo, armingState); |
| | | } |
| | | }); |
| | | |
| | | // btn_send_alarm.setOnClickListener(new View.OnClickListener() { |
| | | // @Override |
| | | // public void onClick(View view) { |
| | | // alarmSendState++; |
| | | // if (alarmSendState > 7) { |
| | | // alarmSendState = 0; |
| | | // } |
| | | // HDLCommand.securitySendAlarm(appliancesInfo, alarmSendState); |
| | | // } |
| | | // }); |
| | | |
| | | ArrayAdapter<String> sp_CheckBitAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, armingTypeItems); |
| | | sp_CheckBitAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
| | | spinner_arming.setAdapter(sp_CheckBitAdapter); |
| | | spinner_arming.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { |
| | | public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { |
| | | armingState = arg2 + 1; |
| | | } |
| | | |
| | | public void onNothingSelected(AdapterView<?> arg0) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * initcurState |
| | | */ |
| | | private void initcurState() { |
| | | appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); |
| | | |
| | | // String titleStr = ""; |
| | | // try { |
| | | // titleStr = appliancesInfo.getRemarks(); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // if (titleStr != null) { |
| | | // topBarTitle.setText(titleStr); |
| | | // } |
| | | |
| | | mSecurityStateBean = new SecurityStateBean(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 布防设置回调Event |
| | | * |
| | | * @param event |
| | | */ |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onSecurityArmingFeedBackEventMain(SecurityArmingFeedBackEvent event) { |
| | | if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() |
| | | && event.getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() |
| | | ) { |
| | | //先判断是否超时 |
| | | if (!event.isSuccess()) { |
| | | tv_mesSetText("布防设置超时,请重新再试"); |
| | | return; |
| | | } |
| | | |
| | | int armingStateGet = event.getArmingState(); |
| | | if (armingStateGet >= 1 && armingStateGet <= 6) { |
| | | armingState = armingStateGet; |
| | | spinner_arming.setSelection(armingState - 1, true); |
| | | tv_mesSetText("布防成功,当前状态:" + armingTypeItems[armingState - 1]); |
| | | } else if (armingState == SecurityParser.ARMING_FAIL) { |
| | | tv_mesSetText("布防失败"); |
| | | } else { |
| | | tv_mesSetText("未知布防状态"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询布防状态 回调Event |
| | | * |
| | | * @param event |
| | | */ |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onDeviceStateEventMain(DeviceStateEvent event) { |
| | | |
| | | if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() |
| | | ) { |
| | | //这个返回的信息是当前状态的 |
| | | switch (event.getAppliancesInfo().getDeviceType()) { |
| | | case HDLApConfig.TYPE_SECURITY_MODULE: |
| | | if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) { |
| | | if (!event.isSuccess()) { |
| | | tv_mesSetText("获取布防状态失败,请重新再试"); |
| | | return; |
| | | } |
| | | |
| | | SecurityArmingStateBackInfo mSecurityArmingStateBackInfo = new SecurityArmingStateBackInfo(event.getAppliancesInfo().getArrCurState()); |
| | | if (mSecurityArmingStateBackInfo == null) { |
| | | tv_mesSetText("获取布防状态失败,请重新再试"); |
| | | return; |
| | | } |
| | | |
| | | int armingStateBack = mSecurityArmingStateBackInfo.getArmingState(); |
| | | if (armingStateBack == 0) { //读取返回0为撤防 |
| | | armingState = SecurityParser.ARMING_DISARMING; |
| | | spinner_arming.setSelection(armingState - 1, true); |
| | | tv_mesSetText("获取成功,当前状态:" + armingTypeItems[armingState - 1]); |
| | | } else if (armingStateBack >= 1 && armingStateBack <= 6) { |
| | | armingState = armingStateBack;//更新状态值 |
| | | spinner_arming.setSelection(armingState - 1, true); |
| | | tv_mesSetText("获取成功,当前状态:" + armingTypeItems[armingState - 1]); |
| | | } else { |
| | | tv_mesSetText("获取成功,未知布防状态"); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 报警回调Event |
| | | * |
| | | * @param event |
| | | */ |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onSecurityAlarmFeedBackEventMain(SecurityAlarmFeedBackEvent event) { |
| | | if (event.getSecurityBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && event.getSecurityBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() |
| | | && event.getSecurityBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() |
| | | ) { |
| | | // //先判断是否超时 |
| | | // if (!event.isSuccess()) { |
| | | // tv_mesSetText("报警设置超时,请重新再试"); |
| | | // return; |
| | | // } |
| | | |
| | | mSecurityStateBean = event.getSecurityBackInfo().getSecurityStateBean(); |
| | | if (mSecurityStateBean != null) { |
| | | setAllAlarmStateTextView(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * TextView 显示信息并且showToast提示 |
| | | * |
| | | * @param mes |
| | | */ |
| | | private void tv_mesSetText(String mes) { |
| | | tv_mes.setText(mes); |
| | | showToast(mes); |
| | | } |
| | | |
| | | private String getAlarmStateString(int state, String alarmName) { |
| | | if (state == 0) { |
| | | return "正常"; |
| | | } else { |
| | | HDLLog.I(alarmName + ", 报警状态!"); |
| | | return "警告,报警状态!"; |
| | | } |
| | | } |
| | | |
| | | |
| | | private void setAllAlarmStateTextView() { |
| | | // tv_alarmFire.setText(getAlarmStateString(mSecurityStateBean.getAlarmFire(), "火警")); |
| | | // tv_alarmGas.setText(getAlarmStateString(mSecurityStateBean.getAlarmGas(), "煤气报警")); |
| | | // tv_alarmSudden.setText(getAlarmStateString(mSecurityStateBean.getAlarmSudden(), "突发报警")); |
| | | // tv_alarmEmergency.setText(getAlarmStateString(mSecurityStateBean.getAlarmEmergency(), "紧急报警")); |
| | | // tv_alarmCurrent.setText(getAlarmStateString(mSecurityStateBean.getAlarmCurrent(), "电流报警")); |
| | | // tv_alarmSilent.setText(getAlarmStateString(mSecurityStateBean.getAlarmSilent(), "无声报警")); |
| | | // tv_alarmPower.setText(getAlarmStateString(mSecurityStateBean.getAlarmPower(), "功率报警")); |
| | | // tv_alarmTemperature.setText(getAlarmStateString(mSecurityStateBean.getAlarmTemperature(), "温度报警")); |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_main); |
| | | NetWorkUtil.setIsGetWifiBroadCast(true); |
| | | // HDLSDK.init(this); |
| | | // HDLSDK.startHomeMode(this); |
| | | |
| | | HDLCommand.init(this); |
| | | HDLCommand.startHomeMode(this); |
| | | |
| | | // /**配置是否开启SDK打印日志,默认为打开*/ |
| | | // HDLCommand.setHDLLogOpen(false);// |
| | | |
| | |
| | | btn_getlocal_add.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | startActivity(AddDevicesManuallyActivity.class); |
| | | startActivity(AddDevicesActivity.class); |
| | | |
| | | } |
| | | }); |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:id="@+id/activity_main" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <ScrollView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="10dp" |
| | | android:layout_marginTop="20dp" |
| | | android:layout_marginRight="10dp" |
| | | android:orientation="vertical"> |
| | | |
| | | |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:text="手动添加" |
| | | android:textColor="@android:color/black" |
| | | android:textSize="24sp" /> |
| | | |
| | | |
| | | <TextView |
| | | android:layout_width="100dp" |
| | | android:layout_height="match_parent" |
| | | android:gravity="center|left" |
| | | android:text="设备参数" |
| | | android:textColor="@android:color/black" |
| | | android:textSize="18sp" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="子网号:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_subnetID" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:hint="子网号(范围0 - 254)" |
| | | android:inputType="number" |
| | | android:maxLength="3" |
| | | android:gravity="center|left" |
| | | android:text="100" /> |
| | | </LinearLayout> |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="设备号:"></TextView> |
| | | |
| | | |
| | | <EditText |
| | | android:id="@+id/et_deviceID" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:hint="设备号(范围0 - 254)" |
| | | android:gravity="center|left" |
| | | android:inputType="number" |
| | | android:maxLength="3" |
| | | android:text="100" /> |
| | | |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="大类:"></TextView> |
| | | |
| | | |
| | | <EditText |
| | | android:id="@+id/et_bitType" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:hint="大类" |
| | | android:inputType="number" |
| | | android:maxLength="3" |
| | | android:gravity="center|left" |
| | | android:text="1" /> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="小类:"></TextView> |
| | | |
| | | |
| | | <EditText |
| | | android:id="@+id/et_littleType" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:hint="小类" |
| | | android:inputType="number" |
| | | android:maxLength="3" |
| | | android:text="0" |
| | | |
| | | /> |
| | | </LinearLayout> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="回路号:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_mChannelNum" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:hint="回路号" |
| | | android:inputType="number" |
| | | android:maxLength="3" |
| | | android:gravity="center|left" |
| | | android:text="1" |
| | | |
| | | /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="端口号:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_mPort" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:hint="请输入端口号" |
| | | android:inputType="number" |
| | | android:maxLength="4" |
| | | android:gravity="center|left" |
| | | android:text="6000" |
| | | |
| | | /> |
| | | </LinearLayout> |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="12sp" |
| | | android:text="模块备注:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_remarks_mk" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:hint="请输入模块备注" |
| | | android:text="酒店RCU" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="70dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="12sp" |
| | | android:text="回路备注:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_remarks" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:hint="请输入回路备注" /> |
| | | </LinearLayout> |
| | | |
| | | |
| | | |
| | | <Button |
| | | android:id="@+id/btn_add" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp" |
| | | android:text="添加" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="80dp" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:textSize="16sp" |
| | | android:text="场景号:"></TextView> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_scene" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:gravity="center|left" |
| | | android:hint="区号和场景号" /> |
| | | </LinearLayout> |
| | | |
| | | <Button |
| | | android:id="@+id/btn_scene" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp" |
| | | android:text="添加场景" /> |
| | | |
| | | <Button |
| | | android:id="@+id/btn_addAll" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="10dp" |
| | | android:text="添加测试" /> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | </ScrollView> |
| | | </RelativeLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:id="@+id/activity_ctrl" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | <!-- <include--> |
| | | <!-- android:id="@+id/hdl_top_bar_layout"--> |
| | | <!-- layout="@layout/hdl_toolbar_top_view_b"/>--> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_marginRight="20dp" |
| | | android:layout_marginLeft="20dp" |
| | | android:orientation="vertical"> |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="40dp" |
| | | android:text="通用开关设备" |
| | | android:gravity="center|left" |
| | | android:textSize="@dimen/ts_24" |
| | | |
| | | /> |
| | | |
| | | <TextView |
| | | android:id="@+id/switchText" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="10dp" |
| | | android:textSize="@dimen/ts_20" |
| | | android:text="这个按钮做通用开关设备的演示" /> |
| | | |
| | | <Button |
| | | android:id="@+id/btnOpen" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="开" /> |
| | | |
| | | |
| | | <Button |
| | | android:id="@+id/btnClose" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="关" /> |
| | | </LinearLayout> |
| | | |
| | | </RelativeLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:id="@+id/activity_ctrl" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginRight="20dp" |
| | | android:orientation="vertical"> |
| | | |
| | | <!--<TextView--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="40dp"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="MCU 协议调试"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_24" />--> |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="40dp" |
| | | android:gravity="center|left" |
| | | android:text="安防模块" |
| | | android:textSize="@dimen/ts_20" /> |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="30dp" |
| | | android:gravity="center|left" |
| | | android:text="布防前,要先撤防后布防" |
| | | android:textSize="@dimen/ts_18" /> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/air" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | |
| | | |
| | | |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="火警状态:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmFire"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="煤气报警:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmGas"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="突发报警:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmSudden"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="紧急报警:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmEmergency"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="电流报警:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmCurrent"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="无声报警:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmSilent"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="功率报警:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmPower"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | |
| | | <!--<LinearLayout--> |
| | | <!--android:layout_width="match_parent"--> |
| | | <!--android:layout_height="30dp">--> |
| | | <!--<TextView--> |
| | | <!--android:layout_width="100dp"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center"--> |
| | | <!--android:textColor="@color/black"--> |
| | | <!--android:textSize="@dimen/ts_18"--> |
| | | <!--android:text="温度报警:" />--> |
| | | <!--<TextView--> |
| | | <!--android:id="@+id/tv_alarmTemperature"--> |
| | | <!--android:layout_width="wrap_content"--> |
| | | <!--android:layout_height="match_parent"--> |
| | | <!--android:gravity="center|left"--> |
| | | <!--android:text="正常" />--> |
| | | <!--</LinearLayout>--> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="40dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="100dp" |
| | | android:layout_height="match_parent" |
| | | android:gravity="center" |
| | | android:textSize="@dimen/ts_18" |
| | | android:text="布防状态:" /> |
| | | |
| | | <Spinner |
| | | android:id="@+id/spinner_arming" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="match_parent" |
| | | android:minWidth="120dp"></Spinner> |
| | | </LinearLayout> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="40dp"> |
| | | |
| | | <Button |
| | | android:id="@+id/btn_read_config" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="40dp" |
| | | android:textSize="@dimen/ts_18" |
| | | android:text="读取安防设置 " /> |
| | | |
| | | <Button |
| | | android:id="@+id/btn_set_arming" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="40dp" |
| | | android:textSize="@dimen/ts_18" |
| | | android:text="修改布防状态" /> |
| | | |
| | | |
| | | |
| | | </LinearLayout> |
| | | <Button |
| | | android:id="@+id/btn_send_alarm" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="40dp" |
| | | android:textSize="@dimen/ts_18" |
| | | android:visibility="gone" |
| | | android:text="发送报警指令" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_mes" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="5dp" |
| | | android:text="安防模块布防演示" |
| | | android:textSize="@dimen/ts_20" /> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | </LinearLayout> |
| | | </LinearLayout> |
| | | |
| | | </RelativeLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:id="@+id/activity_ctrl" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <!--<include--> |
| | | <!-- android:id="@+id/hdl_top_bar_layout"--> |
| | | <!-- layout="@layout/hdl_toolbar_top_view_b" />--> |
| | | |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginRight="20dp" |
| | | android:layout_marginTop="20dp" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:id="@+id/sensorText" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="这个按钮做传感器演示" /> |
| | | |
| | | <Button |
| | | android:id="@+id/sensorbtn" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="获取传感器状态" /> |
| | | </LinearLayout> |
| | | |
| | | </RelativeLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources> |
| | | |
| | | |
| | | <!-- 默认字体大小 --> |
| | | <dimen name="textSize_title">20sp</dimen> |
| | | <dimen name="ts_44">44sp</dimen> |
| | | <dimen name="ts_40">40sp</dimen> |
| | | <dimen name="ts_32">32sp</dimen> |
| | | <dimen name="ts_24">24sp</dimen> |
| | | <dimen name="ts_22">22sp</dimen> |
| | | <dimen name="ts_20">20sp</dimen> |
| | | <dimen name="ts_18">18sp</dimen> |
| | | <dimen name="ts_16">16sp</dimen> |
| | | <dimen name="ts_15">15sp</dimen> |
| | | <dimen name="ts_14">14sp</dimen> |
| | | <dimen name="ts_13">13sp</dimen> |
| | | <dimen name="ts_12">12sp</dimen> |
| | | <dimen name="ts_11">11sp</dimen> |
| | | <dimen name="ts_10">10sp</dimen> |
| | | |
| | | <dimen name="toolbar_height">56dp</dimen> |
| | | </resources> |
| | |
| | | public static final int GEOTHERMAL_BIG_TYPE = 8; |
| | | public static final int AIR_BIG_TYPE = 7; |
| | | public static final int AUDIO_BIG_TYPE = 9; |
| | | /**安防功能*/ |
| | | public static final int SECURITY_BIG_TYPE = 10; |
| | | public static final int LOGIC_BIG_TYPE = 12; |
| | | public static final int GLOBAL_LOGIC_BIG_TYPE = 17; |
| | | /** |
| | |
| | | //支持的小类 |
| | | public static final int FRESH_AIR_LITTLE_TYPE_0 = 0; |
| | | public static final int GEOTHERMAL_LITTLE_TYPE_0 = 0; |
| | | |
| | | /**通用开关*/ |
| | | public static final int COMMON_SWITCH_BIG_TYPE = 100; |
| | | |
| | | |
| | | //小类 先不做分类 |
| | |
| | | public static final int FRESH_AIR_STATE_COMMAND = 0x144C; |
| | | public static final int FRESH_AIR_STATE_BACK_COMMAND = 0x144D; |
| | | |
| | | /** |
| | | * 2020-06-23 安防功能模块操作码、状态读取码 ARMING布防 ALARM报警 |
| | | */ |
| | | public static final int SECURITY_ARMING_CTRL_COMMAND = 0x0104;//布防设置 |
| | | public static final int SECURITY_ARMING_CTRL_BACK_COMMAND = 0x0105;//布防设置反馈 |
| | | public static final int SECURITY_STATE_COMMAND = 0x011E;//读取安防设置 |
| | | public static final int SECURITY_STATE_BACK_COMMAND = 0x011F;//读取安防设置反馈 |
| | | public static final int SECURITY_ALARM_CTRL_COMMAND = 0x010C;//报警设置 |
| | | public static final int SECURITY_ALARM_CTRL_BACK_COMMAND = 0x010D;//报警设置反馈 |
| | | |
| | | /** |
| | | * 2020-06-23 通用开关 |
| | | */ |
| | | public static final int COMMON_SWITCH_CTRL_COMMAND = 0xE01C;//通用开关控制 |
| | | 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;//读通用开关状态反馈 |
| | | |
| | | |
| | | /** |
| | | * RCU 配置数据 |
| | |
| | | public static final int TYPE_SENSOR_ELECTRICITY = 624; |
| | | public static final int TYPE_SENSOR_POWER = 625; |
| | | |
| | | |
| | | public static final int TYPE_SENSOR_FLOODING = 626; //水浸//2019-11-4 新增 |
| | | public static final int TYPE_SENSOR_DOOR_MAGNET= 627; //门磁、窗磁 |
| | | public static final int TYPE_SENSOR_EMERGENCY_BUTTON = 628; //紧急按钮 |
| | | |
| | | //2019-07 |
| | | public static final int TYPE_GEOTHERMAL_MODULE = 801; //地热模块(0) 回路号,备注,地热状态 |
| | | // public static final int TYPE_GEOTHERMAL_MODULE_PANEL = 802; //常规地热面板(1) 面板号,备注,服务器模式,地热状态 |
| | | // public static final int TYPE_GEOTHERMAL_MODULE_PI = 803; //带PI运算的地热面板(2) 面板号,备注,地热状态 |
| | | |
| | | //安防功能模块 |
| | | public static final int TYPE_SECURITY_MODULE = 1001; |
| | | |
| | | public static final int TYPE_FRESH_AIR = 1901; //新风系统 |
| | | |
| | | |
| | | public static final int TYPE_COMMON_SWITCH = 10001;//通用开关 |
| | | |
| | | |
| | | |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | |
| | | /** |
| | | * Created by jlchen on 2020-04-01. |
| | | */ |
| | | public class CommonSwitchBackInfo { |
| | | |
| | | private AppliancesInfo appliancesInfo; |
| | | private int switchNum; //回路号 |
| | | private int switchState; //开关状态 |
| | | |
| | | public AppliancesInfo getAppliancesInfo() { |
| | | return appliancesInfo; |
| | | } |
| | | |
| | | public void setAppliancesInfo(AppliancesInfo appliancesInfo) { |
| | | this.appliancesInfo = appliancesInfo; |
| | | } |
| | | |
| | | |
| | | public int getSwitchNum() { |
| | | return switchNum; |
| | | } |
| | | |
| | | public void setSwitchNum(int switchNum) { |
| | | this.switchNum = switchNum; |
| | | } |
| | | |
| | | public int getSwitchState() { |
| | | return switchState; |
| | | } |
| | | |
| | | public void setSwitchState(int switchState) { |
| | | this.switchState = switchState; |
| | | } |
| | | } |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.Parser; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | |
| | | /** |
| | | * Created by JLChen on 2019/7/29 |
| | | */ |
| | | public class SecurityParser { |
| | | |
| | | public static final int fail = 0; |
| | | /** |
| | | * 布防设置 |
| | | */ |
| | | //布防类型 6 =撤防 5 = 白天布防 4 = 晚上有客布防 3 = 夜间布防 2 = 离开布防 1 = 假期布防 |
| | | public static final int ARMING_HOLIDAY = 1; |
| | | public static final int ARMING_LEAVE = 2; |
| | | public static final int ARMING_AT_NIGHT = 3; |
| | | public static final int ARMING_AT_NIGHT_WITH_GUEST = 4; |
| | | public static final int ARMING_DURING_THE_DAY = 5; |
| | | public static final int ARMING_DISARMING = 6; |
| | | |
| | | public static final int ARMING_FAIL = 7;//布防失败 |
| | | // public static final int ARMING_UNKNOWM = -1;//未知状态 |
| | | |
| | | //获取布防 bytes数据 |
| | | public static byte[] getArmingByte(AppliancesInfo appliancesInfo, int state) { |
| | | try { |
| | | if (state < 0 || state > 6) {//参数错误默认撤防 |
| | | state = 6; |
| | | } |
| | | byte[] addBytes = new byte[2]; |
| | | addBytes[0] = (byte) appliancesInfo.getChannelNum(); |
| | | addBytes[1] = (byte) state; |
| | | return addBytes; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return new byte[]{fail}; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | // Bit 4 0 = 正常状态 , 1 = 电流报警 |
| | | // Bit 3 0 =正常状态, 1 = 紧急报警 |
| | | // Bit 2 0 =正常状态, 1 = 突发报警 |
| | | // Bit 1 0 =正常状态, 1 =煤气报警 |
| | | // Bit 0 0 =正常状态, 1 = 火警 3 |
| | | // |
| | | // Encode Bit Value |
| | | // Bit 7 0 =正常状态, 1 = 温度报警 |
| | | // Bit 6 0 =正常状态, 1 = 功率报警 |
| | | // Bit 5 0 =正常状态, 1 = 无声报警 |
| | | //private int CurrentAlarm; //电流报警 |
| | | // private int EmergencyAlarm; //紧急报警 |
| | | // private int SuddenAlarm; //突发报警 |
| | | // private int FireAlarm; //火警 3 |
| | | // |
| | | // private int TemperatureAlarm;//温度报警 |
| | | // private int PowerAlarm; //功率报警 |
| | | // private int SilentAlarm; //无声报警 |
| | | /** |
| | | * 报警设置 ALARM |
| | | */ |
| | | public static final int ALARM_CURRENT = 4; //电流报警 |
| | | public static final int ALARM_EMERGENCY = 3; //紧急报警 |
| | | public static final int ALARM_SUDDEN = 2; //突发报警 |
| | | public static final int ALARM_GAS = 1; //煤气报警 |
| | | public static final int ALARM_FIRE = 0; //火警 3 |
| | | public static final int ALARM_TEMPERATURE = 7; //温度报警 |
| | | public static final int ALARM_POWER = 6; //功率报警 |
| | | public static final int ALARM_SILENT = 5; //无声报警 |
| | | |
| | | //获取报警设置 bytes数据 只报警一种情况 |
| | | public static byte[] getAlarmByte(AppliancesInfo appliancesInfo, int state) { |
| | | try { |
| | | byte[] addBytes = new byte[3]; |
| | | addBytes[0] = (byte) appliancesInfo.getChannelNum(); |
| | | switch (state) { |
| | | case ALARM_FIRE: |
| | | addBytes[1] = 0x01; |
| | | break; |
| | | case ALARM_GAS: |
| | | addBytes[1] = (byte) (1 << 1); |
| | | break; |
| | | case ALARM_SUDDEN: |
| | | addBytes[1] = (byte) (1 << 2); |
| | | break; |
| | | case ALARM_EMERGENCY: |
| | | addBytes[1] = (byte) (1 << 3); |
| | | break; |
| | | case ALARM_CURRENT: |
| | | addBytes[1] = (byte) (1 << 4); |
| | | break; |
| | | |
| | | case ALARM_SILENT: |
| | | addBytes[2] = (byte) (1 << 5); |
| | | break; |
| | | case ALARM_POWER: |
| | | addBytes[2] = (byte) (1 << 6); |
| | | break; |
| | | case ALARM_TEMPERATURE: |
| | | addBytes[2] = (byte) (1 << 7); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | return addBytes; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return new byte[]{fail}; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity; |
| | | |
| | | /** |
| | | * Created by JLChen on 2019/8/9 |
| | | */ |
| | | public class SecurityArmingStateBackInfo { |
| | | private int armingState; //布防状态 6 = 撤防 5 = 白天布防 4 = 晚上有客布防 3 = 夜间布防 2 = 离开布防 1 = 假期布防 |
| | | |
| | | public SecurityArmingStateBackInfo(byte[] curState) { |
| | | armingState = -1; |
| | | if (curState == null) return; |
| | | if (curState.length >= 2) { |
| | | armingState = curState[1] & 0xFF; |
| | | } |
| | | } |
| | | |
| | | public int getArmingState() { |
| | | return armingState; |
| | | } |
| | | |
| | | public void setArmingState(int armingState) { |
| | | this.armingState = armingState; |
| | | } |
| | | } |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.Parser.SecurityParser; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.SecurityStateBean; |
| | | |
| | | /** |
| | | * Created by JLChen on 2019/7/29 |
| | | * 安防模块 |
| | | */ |
| | | public class SecurityBackInfo { |
| | | |
| | | private AppliancesInfo appliancesInfo; |
| | | private String remarks; |
| | | private int channelNum; //回路号 |
| | | private SecurityStateBean mSecurityStateBean; |
| | | |
| | | private byte[] curState; //返回信息 |
| | | |
| | | public SecurityBackInfo() { |
| | | |
| | | } |
| | | |
| | | public SecurityBackInfo(AppliancesInfo mAppliancesInfo) { |
| | | this.appliancesInfo = mAppliancesInfo; |
| | | this.remarks = mAppliancesInfo.getRemarks(); |
| | | this.curState = mAppliancesInfo.getArrCurState(); |
| | | this.mSecurityStateBean = new SecurityStateBean(); |
| | | |
| | | if (this.curState == null) return; |
| | | |
| | | if (this.curState.length >= 3) { |
| | | this.channelNum = this.curState[0] & 0xFF; |
| | | this.mSecurityStateBean.alarmCurrent = this.curState[1] & 0x10; |
| | | this.mSecurityStateBean.alarmEmergency = this.curState[1] & 0x08; |
| | | this.mSecurityStateBean.alarmSudden = this.curState[1] & 0x04; |
| | | this.mSecurityStateBean.alarmGas = this.curState[1] & 0x02; |
| | | this.mSecurityStateBean.alarmFire = this.curState[1] & 0x01; |
| | | this.mSecurityStateBean.alarmTemperature = this.curState[2] & 0x80; |
| | | this.mSecurityStateBean.alarmPower = this.curState[2] & 0x40; |
| | | this.mSecurityStateBean.alarmSilent = this.curState[2] & 0x20; |
| | | int mCurState = this.curState[2] & 0x1F; |
| | | |
| | | switch (mCurState) { |
| | | case 0: |
| | | this.mSecurityStateBean.armingState = SecurityParser.ARMING_DISARMING;//撤防状态 |
| | | break; |
| | | case 1: |
| | | this.mSecurityStateBean.armingState = SecurityParser.ARMING_HOLIDAY;//假期布防 |
| | | break; |
| | | case 2: |
| | | this.mSecurityStateBean.armingState = SecurityParser.ARMING_LEAVE;//离开布防 |
| | | break; |
| | | case 4: |
| | | this.mSecurityStateBean.armingState = SecurityParser.ARMING_AT_NIGHT;//夜间布防 |
| | | break; |
| | | case 8: |
| | | this.mSecurityStateBean.armingState = SecurityParser.ARMING_AT_NIGHT_WITH_GUEST;//晚上有客布防 |
| | | break; |
| | | case 10: |
| | | this.mSecurityStateBean.armingState = SecurityParser.ARMING_DURING_THE_DAY;//白天布防 |
| | | break; |
| | | default: |
| | | // this.armingState = SecurityParser.ARMING_DISARMING;//撤防状态 |
| | | this.mSecurityStateBean.armingState = -1; //未知状态 |
| | | break; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public AppliancesInfo getAppliancesInfo() { |
| | | return appliancesInfo; |
| | | } |
| | | |
| | | public void setAppliancesInfo(AppliancesInfo appliancesInfo) { |
| | | this.appliancesInfo = appliancesInfo; |
| | | } |
| | | |
| | | public String getRemarks() { |
| | | return remarks; |
| | | } |
| | | |
| | | public void setRemarks(String remarks) { |
| | | this.remarks = remarks; |
| | | } |
| | | |
| | | public int getChannelNum() { |
| | | return channelNum; |
| | | } |
| | | |
| | | public void setChannelNum(int channelNum) { |
| | | this.channelNum = channelNum; |
| | | } |
| | | |
| | | public SecurityStateBean getSecurityStateBean() { |
| | | return mSecurityStateBean; |
| | | } |
| | | |
| | | public void setSecurityStateBean(SecurityStateBean securityStateBean) { |
| | | mSecurityStateBean = securityStateBean; |
| | | } |
| | | |
| | | public byte[] getCurState() { |
| | | return curState; |
| | | } |
| | | |
| | | public void setCurState(byte[] curState) { |
| | | this.curState = curState; |
| | | } |
| | | } |
| | | |
| | | |
| | | // Bit 4 0 = 正常状态 , 1 = 电流报警 |
| | | // Bit 3 0 =正常状态, 1 = 紧急报警 |
| | | // Bit 2 0 =正常状态, 1 = 突发报警 |
| | | // Bit 1 0 =正常状态, 1 = 煤气报警 |
| | | // Bit 0 0 =正常状态, 1 = 火警 3 |
| | | // |
| | | // Encode Bit Value |
| | | // Bit 7 0 =正常状态, 1 = 温度报警 |
| | | // Bit 6 0 =正常状态, 1 = 功率报警 |
| | | // Bit 5 0 =正常状态, 1 = 无声报警 |
| | | // Bit 4 0 =正常状态, 1 = 白天布防状态 |
| | | // Bit 3 0 =正常状态, 1 = 晚上有客布防 |
| | | // Bit 2 0 =正常状态, 1 = 夜间布防 |
| | | // Bit 1 0 =正常状态, 1 = 离开布防 |
| | | // Bit 0 0 =正常状态, 1 = 假期布防 |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean; |
| | | |
| | | /** |
| | | * Created by JLChen on 2019/7/29 |
| | | */ |
| | | public class SecurityStateBean { |
| | | public int alarmCurrent; //电流报警 |
| | | public int alarmEmergency; //紧急报警 |
| | | public int alarmSudden; //突发报警 |
| | | public int alarmGas; //煤气报警 |
| | | public int alarmFire; //火警 3 |
| | | |
| | | public int alarmTemperature;//温度报警 |
| | | public int alarmPower; //功率报警 |
| | | public int alarmSilent; //无声报警 |
| | | |
| | | public int armingState; //布防状态 6 = 撤防 5 = 白天布防 4 = 晚上有客布防 3 = 夜间布防 2 = 离开布防 1 = 假期布防 |
| | | |
| | | public int getAlarmCurrent() { |
| | | return alarmCurrent; |
| | | } |
| | | |
| | | public void setAlarmCurrent(int alarmCurrent) { |
| | | this.alarmCurrent = alarmCurrent; |
| | | } |
| | | |
| | | public int getAlarmEmergency() { |
| | | return alarmEmergency; |
| | | } |
| | | |
| | | public void setAlarmEmergency(int alarmEmergency) { |
| | | this.alarmEmergency = alarmEmergency; |
| | | } |
| | | |
| | | public int getAlarmSudden() { |
| | | return alarmSudden; |
| | | } |
| | | |
| | | public void setAlarmSudden(int alarmSudden) { |
| | | this.alarmSudden = alarmSudden; |
| | | } |
| | | |
| | | public int getAlarmGas() { |
| | | return alarmGas; |
| | | } |
| | | |
| | | public void setAlarmGas(int alarmGas) { |
| | | this.alarmGas = alarmGas; |
| | | } |
| | | |
| | | public int getAlarmFire() { |
| | | return alarmFire; |
| | | } |
| | | |
| | | public void setAlarmFire(int alarmFire) { |
| | | this.alarmFire = alarmFire; |
| | | } |
| | | |
| | | public int getAlarmTemperature() { |
| | | return alarmTemperature; |
| | | } |
| | | |
| | | public void setAlarmTemperature(int alarmTemperature) { |
| | | this.alarmTemperature = alarmTemperature; |
| | | } |
| | | |
| | | public int getAlarmPower() { |
| | | return alarmPower; |
| | | } |
| | | |
| | | public void setAlarmPower(int alarmPower) { |
| | | this.alarmPower = alarmPower; |
| | | } |
| | | |
| | | public int getAlarmSilent() { |
| | | return alarmSilent; |
| | | } |
| | | |
| | | public void setAlarmSilent(int alarmSilent) { |
| | | this.alarmSilent = alarmSilent; |
| | | } |
| | | |
| | | public int getArmingState() { |
| | | return armingState; |
| | | } |
| | | |
| | | public void setArmingState(int armingState) { |
| | | this.armingState = armingState; |
| | | } |
| | | } |
| | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; |
| | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.Parser.SecurityParser; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DeviceStateBean; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent; |
| | | 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.EventCode; |
| | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; |
| | | import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; |
| | | import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; |
| | |
| | | */ |
| | | |
| | | public class HDLCommand { |
| | | |
| | | public static int mRequestTimeout = 5000;//默认请求超时时间 |
| | | private static Timer getStateFailTimer = null;//获取设备状态失败Timer |
| | | |
| | | private static Timer lightCtrlFailTimer = null;//控制灯光失败Timer |
| | |
| | | private static Timer freshAirCtrlFailTimer = null;//控制新风失败Timer 2019-07-09 |
| | | private static Timer geothermalCtrlFailTimer = null;//控制地热失败Timer 2019-07-10 |
| | | |
| | | private static Timer securityCtrlFailTimer = null;//安防模块操作失败Timer |
| | | private static Timer commonSwitchCtrlFailTimer = null;//通用开关失败Timer |
| | | |
| | | /** |
| | | * 初始化 |
| | |
| | | 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(); |
| | | } |
| | | |
| | | // /** |
| | | // * 获取本地广播IP |
| | |
| | | } |
| | | |
| | | |
| | | /**************************************2020-06-23新增***************************************/ |
| | | /** |
| | | * 控制通用开关 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void commonSwitchCtrl(final AppliancesInfo info, int state) { |
| | | |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (info.getBigType() == Configuration.COMMON_SWITCH_BIG_TYPE) { |
| | | |
| | | if (commonSwitchCtrlFailTimer != null) { |
| | | commonSwitchCtrlFailTimer.cancel(); |
| | | commonSwitchCtrlFailTimer = null; |
| | | } |
| | | |
| | | byte[] bytes = new byte[]{(byte) info.getChannelNum(), (byte) state}; |
| | | |
| | | addSendData(info, bytes, Configuration.CONTROL); |
| | | |
| | | commonSwitchCtrlFailTimer = new Timer(); |
| | | commonSwitchCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | HDLLog.info("通用开关控制失败"); |
| | | CommonSwitchBackInfo mCommonSwitchBackInfo = new CommonSwitchBackInfo(); |
| | | mCommonSwitchBackInfo.setAppliancesInfo(info); |
| | | EventBus.getDefault().post(new CommonSwitchCtrlBackEvent(mCommonSwitchBackInfo, false)); |
| | | } |
| | | } |
| | | }, mRequestTimeout); |
| | | } else { |
| | | HDLLog.info("djlCtrl: 通用开关设备控制不在范围内" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取通用开关状态 |
| | | * @param info |
| | | */ |
| | | public static void getCommonSwitchStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_COMMON_SWITCH: |
| | | addSendData(info, new byte[0], Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.info("不是通用开关设备"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取安防模块状态 |
| | | * @param info |
| | | */ |
| | | public static void getSecurityStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_SECURITY_MODULE: |
| | | //发送获安防模块状态数据 |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.info("不是安防模块"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 安防模块 布防设置 |
| | | * 2020-06-23 |
| | | * @param info |
| | | */ |
| | | public static void securityArmingCtrl(final AppliancesInfo info, int state) { |
| | | // HDLDeviceManager.isSecurityCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (securityCtrlFailTimer != null) { |
| | | securityCtrlFailTimer.cancel(); |
| | | securityCtrlFailTimer = null; |
| | | } |
| | | if (info.getBigType() == Configuration.SECURITY_BIG_TYPE) { |
| | | byte[] sendbytes = SecurityParser.getArmingByte(info, state); |
| | | addSendData(info, sendbytes, Configuration.CONTROL); |
| | | securityCtrlFailTimer = new Timer(); |
| | | securityCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info,0, false)); |
| | | } |
| | | } |
| | | }, 5000); |
| | | |
| | | } else { |
| | | HDLLog.info("安防模块不在范围内" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 安防模块 报警设置 |
| | | // * 2019-7-29 |
| | | // * @param info |
| | | // * @param state 发送的报警内容,只报警一种 |
| | | // */ |
| | | // public static void securitySendAlarm(final AppliancesInfo info, int state) { |
| | | // if (info.getBigType() == Configuration.SECURITY_BIG_TYPE) { |
| | | // byte[] sendbytes = SecurityParser.getAlarmByte(info, state); |
| | | // cusSendCommand(Configuration.SECURITY_ALARM_CTRL_COMMAND, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendbytes); |
| | | // } else { |
| | | // HDLLog.info("不是安防模块" |
| | | // + " LittleType = " + info.getLittleType() |
| | | // + " BigType = " + info.getBigType() |
| | | // ); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; |
| | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicMode; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.SecurityBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSensor.SensorStateBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLWarning.WarningType; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.RcuLight; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.UdpDataBean; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent; |
| | | 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.EventCode; |
| | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityAlarmFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Parser.DeviceParser; |
| | | import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; |
| | |
| | | case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709新增 |
| | | handleGeothermalCtrlData(getDatas); |
| | | break; |
| | | |
| | | /***2020-06-23 新增通用开关**/ |
| | | case Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND: |
| | | handleCommonSwitchCtrlData(getDatas); |
| | | break; |
| | | case Configuration.COMMON_SWITCH_STATE_BACK_COMMAND: |
| | | handleCommonSwitchStateData(getDatas); |
| | | break; |
| | | case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729新增 |
| | | case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://报警设置反馈 |
| | | handleSecurityCtrlData(getDatas); |
| | | break; |
| | | case Configuration.SECURITY_STATE_BACK_COMMAND: |
| | | handleSecurityStateData(getDatas); |
| | | break; |
| | | // 获取设备备注 |
| | | case Configuration.DEVICES_READ_BACK_COMMAND: |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通用开关控制反馈 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleCommonSwitchCtrlData(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.COMMON_SWITCH_BIG_TYPE |
| | | && infos.get(j).getDeviceType() == HDLApConfig.TYPE_COMMON_SWITCH) { |
| | | |
| | | if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | //大类、小类、回路号都匹配 |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF); |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF); |
| | | AppliancesInfo mSwitchInfo = infos.get(j); |
| | | CommonSwitchBackInfo info = new CommonSwitchBackInfo(); |
| | | info.setAppliancesInfo(mSwitchInfo); |
| | | info.setSwitchNum(getDatas.addBytes[0] & 0xFF); |
| | | info.setSwitchState(getDatas.addBytes[1] & 0xFF); |
| | | setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); |
| | | EventBus.getDefault().post(new CommonSwitchCtrlBackEvent(info, true)); |
| | | break outter;//跳出循环 |
| | | } |
| | | } |
| | | } |
| | | |
| | | break outter;//跳出循环 |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /**************************************2020-06-23新增***************************************/ |
| | | /** |
| | | * 通用开关读状态反馈反馈 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleCommonSwitchStateData(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.COMMON_SWITCH_BIG_TYPE |
| | | && infos.get(j).getDeviceType() == HDLApConfig.TYPE_COMMON_SWITCH) { |
| | | |
| | | if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | //大类、小类、回路号都匹配 |
| | | if (getDatas.addBytes.length >= 2) { |
| | | isGetDeviceStateSuccess = true; |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF); |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF); |
| | | AppliancesInfo mSwitchInfo = infos.get(j); |
| | | CommonSwitchBackInfo info = new CommonSwitchBackInfo(); |
| | | info.setAppliancesInfo(mSwitchInfo); |
| | | info.setSwitchNum(getDatas.addBytes[0] & 0xFF); |
| | | info.setSwitchState(getDatas.addBytes[1] & 0xFF); |
| | | EventBus.getDefault().post(new CommonSwitchStateBackEvent(info, true)); |
| | | } |
| | | break outter;//跳出循环 |
| | | } |
| | | } |
| | | } |
| | | |
| | | break outter;//跳出循环 |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 读取安防设置反馈 |
| | | * 2020-06-23 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleSecurityStateData(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.SECURITY_BIG_TYPE |
| | | && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE |
| | | && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-29 |
| | | if (getDatas.addBytes.length >= 2) { |
| | | isGetDeviceStateSuccess = true; |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); |
| | | EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); |
| | | } else { |
| | | isGetDeviceStateSuccess = true; |
| | | EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), false)); |
| | | HDLLog.info("handleSecurityStateData 返回addBytes数据异常"); |
| | | } |
| | | break outter; |
| | | } else { |
| | | HDLLog.info("handleSecurityStateData 没有找到匹配类型"); |
| | | } |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理安防设备 |
| | | * 2020-06-23 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleSecurityCtrlData(UdpDataBean getDatas) { |
| | | switch (getDatas.command) { |
| | | //Arming 布防设置反馈 |
| | | case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND: |
| | | 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 (getDatas.addBytes.length > 0) { |
| | | if (infos.get(j).getBigType() == Configuration.SECURITY_BIG_TYPE |
| | | && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE |
| | | && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | if (getDatas.addBytes.length >= 2) { |
| | | AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | // isSecurityCtrlSuccess = true; |
| | | setDeviceCtrlSuccessStateWithInfo(mInfo, true); |
| | | EventBus.getDefault().post(new SecurityArmingFeedBackEvent(mInfo, getDatas.addBytes[1] & 0xFF, true)); |
| | | } else { |
| | | HDLLog.E("布防设置 反馈数据异常"); |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | |
| | | //ALARM 报警设置反馈 |
| | | case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND: |
| | | 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 (getDatas.addBytes.length > 0) { |
| | | if (infos.get(j).getBigType() == Configuration.SECURITY_BIG_TYPE |
| | | && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE |
| | | && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | if (getDatas.addBytes.length >= 3) { |
| | | //byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState(); |
| | | |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); |
| | | AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | |
| | | SecurityBackInfo info = new SecurityBackInfo(mInfo); |
| | | // isSecurityCtrlSuccess = true; |
| | | setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); |
| | | EventBus.getDefault().post(new SecurityAlarmFeedBackEvent(info, true)); |
| | | } else { |
| | | HDLLog.E("报警设置反馈 反馈数据异常"); |
| | | } |
| | | |
| | | break outter; |
| | | } |
| | | } |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | //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(); |
| | | // } |
| | | //} |
| | |
| | | case Configuration.FRESH_AIR_STATE_BACK_COMMAND://20190709新增 |
| | | case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709新增 地热模块 |
| | | case Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND://20190709新增 |
| | | case Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND: //2020-06-23 通用开关 |
| | | case Configuration.COMMON_SWITCH_STATE_BACK_COMMAND: //2020-06-23 通用开关 |
| | | 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.CURTAIN_STATE_BACK_COMMAND: |
| | | case Configuration.AIR_STATE_BACK_COMMAND: |
| | | |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; |
| | | |
| | | /** |
| | | * Created by jlchen on 2020-04-01. |
| | | */ |
| | | public class CommonSwitchCtrlBackEvent { |
| | | CommonSwitchBackInfo mCommonSwitchBackInfo; |
| | | boolean isSuccess; |
| | | |
| | | public CommonSwitchCtrlBackEvent(CommonSwitchBackInfo commonSwitchBackInfo, boolean isSuccess){ |
| | | this.isSuccess = isSuccess; |
| | | this.mCommonSwitchBackInfo = commonSwitchBackInfo; |
| | | } |
| | | |
| | | public CommonSwitchBackInfo getCommonSwitchBackInfo() { |
| | | return mCommonSwitchBackInfo; |
| | | } |
| | | |
| | | public boolean isSuccess() { |
| | | return isSuccess; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; |
| | | |
| | | /** |
| | | * Created by jlchen on 2020-04-01. |
| | | */ |
| | | public class CommonSwitchStateBackEvent { |
| | | CommonSwitchBackInfo mCommonSwitchBackInfo; |
| | | boolean isSuccess; |
| | | |
| | | public CommonSwitchStateBackEvent(CommonSwitchBackInfo commonSwitchBackInfo, boolean isSuccess){ |
| | | this.isSuccess = isSuccess; |
| | | this.mCommonSwitchBackInfo = commonSwitchBackInfo; |
| | | } |
| | | |
| | | public CommonSwitchBackInfo getCommonSwitchBackInfo() { |
| | | return mCommonSwitchBackInfo; |
| | | } |
| | | |
| | | public boolean isSuccess() { |
| | | return isSuccess; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.SecurityBackInfo; |
| | | |
| | | /** |
| | | * Created by JLChen on 2019/7/29 |
| | | */ |
| | | public class SecurityAlarmFeedBackEvent { |
| | | SecurityBackInfo mSecurityBackInfo; |
| | | boolean isSuccess; |
| | | |
| | | public SecurityAlarmFeedBackEvent(SecurityBackInfo securityBackInfo, boolean isSuccess){ |
| | | this.mSecurityBackInfo = securityBackInfo; |
| | | this.isSuccess = isSuccess; |
| | | } |
| | | |
| | | public SecurityBackInfo getSecurityBackInfo() { |
| | | return mSecurityBackInfo; |
| | | } |
| | | |
| | | public boolean isSuccess() { |
| | | return isSuccess; |
| | | } |
| | | } |
New file |
| | |
| | | package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | |
| | | /** |
| | | * Created by JLChen on 2019/7/29 |
| | | */ |
| | | public class SecurityArmingFeedBackEvent { |
| | | AppliancesInfo appliancesInfo; |
| | | int armingState; |
| | | boolean isSuccess; |
| | | |
| | | public SecurityArmingFeedBackEvent(boolean isSuccess){ |
| | | this.isSuccess = isSuccess; |
| | | } |
| | | |
| | | public SecurityArmingFeedBackEvent(AppliancesInfo mAppliancesInfo, int armingState, boolean isSuccess){ |
| | | this.appliancesInfo = mAppliancesInfo; |
| | | this.armingState = armingState; |
| | | this.isSuccess = isSuccess; |
| | | } |
| | | |
| | | public int getArmingState() { |
| | | return armingState; |
| | | } |
| | | |
| | | public boolean isSuccess() { |
| | | return isSuccess; |
| | | } |
| | | |
| | | public AppliancesInfo getAppliancesInfo() { |
| | | return appliancesInfo; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.hdl.sdk.hdl_core.Config.Configuration; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicMode; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import static com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager.devicesDataList; |
| | | |
| | | /** |
| | | * Created by djl on 2017/3/29. |
| | |
| | | case Configuration.FRESH_AIR_LITTLE_TYPE_0: |
| | | isWant = true; |
| | | break; |
| | | default: |
| | | isWant = false; |
| | | break; |
| | | } |
| | | break; |
| | | case Configuration.COMMON_SWITCH_BIG_TYPE://2020-06-23 通用开关设备 |
| | | switch (littleType) { |
| | | case 0: |
| | | isWant = true; |
| | | break; |
| | | default: |
| | | isWant = false; |
| | | break; |
| | | } |
| | | break; |
| | | case Configuration.SECURITY_BIG_TYPE: |
| | | switch (littleType) { |
| | | case 0: |
| | | isWant = true; |
| | | break; |
| | | // case 2: |
| | | // isWant = true; |
| | | // break; |
| | | default: |
| | | isWant = false; |
| | | break; |
| | |
| | | |
| | | if (bWantData) { |
| | | devicesData.setAppliancesInfoList(appliancesInfoList); |
| | | HDLDeviceManager.devicesDataList.add(devicesData); |
| | | devicesDataList.add(devicesData); |
| | | |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | | }else { |
| | |
| | | case Configuration.FRESH_AIR_BIG_TYPE: |
| | | parseFreshAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); |
| | | break; |
| | | case Configuration.COMMON_SWITCH_BIG_TYPE://2020-06-23 通用开关 |
| | | parseCommonSwitchData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, ""); |
| | | break; |
| | | case Configuration.SECURITY_BIG_TYPE://2020-06-23 新增 |
| | | parseSecurityData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, ""); |
| | | break; |
| | | default: |
| | | // appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); |
| | | break; |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 2020-06-23 |
| | | * 新增通用开关 |
| | | * @param littleType |
| | | * @param appliancesInfo |
| | | * @param devicesData |
| | | * @param parentRemarks |
| | | * @param channelNum |
| | | * @param port |
| | | * @param ipAddress |
| | | */ |
| | | private static void parseCommonSwitchData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) { |
| | | switch (littleType) { |
| | | case 0: |
| | | appliancesInfo.setDeviceName("通用开关"); |
| | | appliancesInfo.setDeviceType(HDLApConfig.TYPE_COMMON_SWITCH); |
| | | break; |
| | | default: |
| | | appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); |
| | | break; |
| | | |
| | | } |
| | | if (devicesData != null) { |
| | | appliancesInfo.setChannelNum(channelNum); |
| | | appliancesInfo.setBigType(Configuration.COMMON_SWITCH_BIG_TYPE); |
| | | appliancesInfo.setLittleType(littleType); |
| | | appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID()); |
| | | appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID()); |
| | | appliancesInfo.setParentRemarks(parentRemarks); |
| | | |
| | | appliancesInfo.setCtrlCommand(Configuration.COMMON_SWITCH_CTRL_COMMAND);// |
| | | appliancesInfo.setCtrlBackCommand(Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND);// |
| | | appliancesInfo.setStateCommand(Configuration.COMMON_SWITCH_STATE_COMMAND);// |
| | | appliancesInfo.setStateBackCommand(Configuration.COMMON_SWITCH_STATE_BACK_COMMAND);// |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 2020-06-23 新增 |
| | | * |
| | | * @param littleType |
| | | * @param appliancesInfo |
| | | * @param devicesData |
| | | * @param parentRemarks |
| | | * @param channelNum |
| | | * @param port |
| | | * @param ipAddress |
| | | */ |
| | | private static void parseSecurityData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) { |
| | | switch (littleType) { |
| | | case 0: |
| | | appliancesInfo.setDeviceName("安防模块"); |
| | | appliancesInfo.setDeviceType(HDLApConfig.TYPE_SECURITY_MODULE); |
| | | break; |
| | | // case 2: |
| | | // appliancesInfo.setDeviceName("安防控制面板"); |
| | | // appliancesInfo.setDeviceType(HDLApConfig.SECURITY_CONTROL_PANEL); |
| | | // break; |
| | | default: |
| | | appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); |
| | | break; |
| | | |
| | | } |
| | | if (devicesData != null) { |
| | | appliancesInfo.setChannelNum(channelNum); |
| | | appliancesInfo.setBigType(Configuration.SECURITY_BIG_TYPE); |
| | | appliancesInfo.setLittleType(littleType); |
| | | appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID()); |
| | | appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID()); |
| | | appliancesInfo.setParentRemarks(parentRemarks); |
| | | // appliancesInfo.setPort(port); |
| | | // appliancesInfo.setIpAddress(ipAddress); |
| | | appliancesInfo.setCtrlCommand(Configuration.SECURITY_ARMING_CTRL_COMMAND);//布防 |
| | | appliancesInfo.setCtrlBackCommand(Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND);//布防设置反馈 |
| | | appliancesInfo.setStateCommand(Configuration.SECURITY_STATE_COMMAND);//读取安防设置 |
| | | appliancesInfo.setStateBackCommand(Configuration.SECURITY_STATE_BACK_COMMAND);//读取安防设置反馈 |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加设备回路 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * @param port 发送UDP包 端口号 |
| | | * @param bigType |
| | | * @param littleType |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mChannelNum |
| | | * @param mChannelRemark |
| | | * @param parentRemarks |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | */ |
| | | public static DevicesData addDevicesListWithoutSearching(int port, int bigType, int littleType, int mSubnetID, int mDeviceID, int mChannelNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | // boolean bWantData = false; |
| | | 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); |
| | | devicesDataList.get(index).getAppliancesInfoList().add(mAppliancesInfo); |
| | | devicesData = devicesDataList.get(index); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | } else { |
| | | List<AppliancesInfo> appliancesInfoList = new ArrayList<>(); |
| | | appliancesInfoList.add(getDevicesInfo(devicesData, bigType, littleType, mChannelNum, port, parentRemarks, mChannelRemark)); |
| | | devicesData.setAppliancesInfoList(appliancesInfoList); |
| | | devicesDataList.add(devicesData); |
| | | if(bSaveAndCallBack){ |
| | | HandleSearch.OnDeviceListGetSuccessCallBack();} |
| | | |
| | | } |
| | | |
| | | |
| | | return devicesData; |
| | | |
| | | } else { |
| | | return null; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加场景设备回路 |
| | | * 如果存在相同子网号 设备号,则当成混合模块添加到该回路下,不存在则新添加模块 |
| | | * @param mSubnetID |
| | | * @param mDeviceID |
| | | * @param mAreaNum //场景 区域号 |
| | | * @param mAreaSceneNum //场景 当前区域场景号 |
| | | * @param mChannelRemark |
| | | * @param parentRemarks |
| | | * @param bSaveAndCallBack 是否马上保存本地并且推送DevicesInfoEvent 事件 |
| | | * @return |
| | | */ |
| | | public static DevicesData addScenesDevicesListWithoutSearching(int port, int mSubnetID, int mDeviceID, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { |
| | | // boolean bWantData = false; |
| | | |
| | | int bigType = Configuration.GLOBAL_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, mAreaNum, 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, mAreaNum, 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; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |