| | |
| | | |
| | | |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.widget.Button; |
| | | import android.widget.RelativeLayout; |
| | |
| | | import com.hdl.sdk.ttl_sdk.R; |
| | | import com.hdl.sdk.ttl_sdk.base.BaseActivity; |
| | | import com.hdl.sdk.ttl_sdk.utlis.HDLLog; |
| | | import com.hdl.sdk.ttl_sdk.utlis.HDLUtlis; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | |
| | | */ |
| | | private RelativeLayout topBarBack; |
| | | private TextView topBarTitle; |
| | | private Button sensorbtn; |
| | | private TextView sensorText; |
| | | private AppliancesInfo appliancesInfo; |
| | | |
| | |
| | | initToolbar(); |
| | | initcurState(); |
| | | initView(); |
| | | initOnClick(); |
| | | displayStateView(); |
| | | //从网络上查询刷新一次设备状态,待调试 |
| | | HDLCommand.getDryContactSensorStateFromNetwork(appliancesInfo); |
| | | |
| | | Log.d("panlili", "SensorActivity.java:appliancesInfo-----> " + appliancesInfo.toString()); |
| | | //传感器无状态获取,只能触发事件上报 |
| | | } |
| | | |
| | | /** |
| | |
| | | private void initcurState() { |
| | | appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); |
| | | String titleStr = appliancesInfo.getRemarks(); |
| | | topBarTitle.setText(titleStr); |
| | | if (TextUtils.isEmpty(titleStr) || titleStr.equals(HDLUtlis.REMAEK_NULL)) { |
| | | if (TextUtils.isEmpty(appliancesInfo.getDeviceName())) { |
| | | titleStr = "备注为空"; |
| | | } else { |
| | | titleStr = appliancesInfo.getDeviceName(); |
| | | } |
| | | } |
| | | topBarTitle.setText(titleStr + appliancesInfo.getDeviceType()); |
| | | |
| | | } |
| | | |
| | | private void initView() { |
| | | sensorbtn = findViewById(R.id.sensorbtn); |
| | | sensorText = findViewById(R.id.sensorText); |
| | | |
| | | |
| | | } |
| | | |
| | | private void initOnClick() { |
| | | |
| | | sensorbtn.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | //从网络上查询刷新一次设备状态,待调试 |
| | | HDLCommand.getDryContactSensorStateFromNetwork(appliancesInfo); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void displayStateView() { |
| | | |
| | | switch (appliancesInfo.getDeviceType()) { |
| | | // case HDLApConfig.TYPE_SENSOR_DRY_CONTACT://2019-07-03 屏蔽 |
| | | // case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: |
| | | // case HDLApConfig.TYPE_SENSOR_TEMP: |
| | | // case HDLApConfig.TYPE_SENSOR_HUMIDITY: |
| | | // case HDLApConfig.TYPE_SENSOR_ILLUMINACE: |
| | | // case HDLApConfig.TYPE_SENSOR_VOC: |
| | | // case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5: |
| | | // case HDLApConfig.TYPE_SENSOR_C02: |
| | | // case HDLApConfig.TYPE_SENSOR_LPG: |
| | | // case HDLApConfig.TYPE_SENSOR_CO_H2: |
| | | // case HDLApConfig.TYPE_SENSOR_CH4: |
| | | // case HDLApConfig.TYPE_SENSOR_SMOG: |
| | | // case HDLApConfig.TYPE_SENSOR_WIND_SPEED: |
| | | // case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE: |
| | | // case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW: |
| | | // case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE: |
| | | // case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH: |
| | | // case HDLApConfig.TYPE_SENSOR_RAIN_FALL: |
| | | // case HDLApConfig.TYPE_SENSOR_WEIGHT: |
| | | // case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH: |
| | | // case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED: |
| | | // case HDLApConfig.TYPE_SENSOR_SHAKE: |
| | | // case HDLApConfig.TYPE_SENSOR_VOLTAGE: |
| | | // case HDLApConfig.TYPE_SENSOR_ELECTRICITY: |
| | | // case HDLApConfig.TYPE_SENSOR_POWER: |
| | | // case HDLApConfig.TYPE_SENSOR_FLOODING: |
| | | // case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET: |
| | | // case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON: |
| | | |
| | | |
| | | case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: //红外感应传感器 |
| | | case HDLApConfig.TYPE_SENSOR_CO_H2: //煤气传感器 |
| | | case HDLApConfig.TYPE_SENSOR_SMOG: //烟雾传感器 |
| | |
| | | |
| | | /** |
| | | * 传感器状态回调 Event |
| | | * 干节点状态主动广播 和 被动查询状态反馈 |
| | | * 干节点状态主动广播--->15D0 |
| | | * |
| | | * @param event |
| | | */ |
| | |
| | | && event.getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() |
| | | ) { |
| | | |
| | | //传感器 干接点 。只有开关状态 |
| | | if (!event.isSuccess()) { |
| | | showToast("获取传感器状态失败,请重新再试"); |
| | | showToast("传感器状态上报失败,请重新再试"); |
| | | return; |
| | | } |
| | | String mData = ""; |
| | | if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR) { |
| | | mData = event.getState() == 0 ? "无动静" : "有动静"; |
| | | if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR) {//红外感应传感器 |
| | | mData = event.getState() == 0 ? "无人" : "有人"; |
| | | } else if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_SENSOR_FLOODING) {//水浸传感器 |
| | | mData = event.getState() == 0 ? "正常" : "漏水"; |
| | | } else if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_SENSOR_DOOR_MAGNET) {//门磁传感器 |
| | | mData = event.getState() == 0 ? "闭合" : "打开"; |
| | | } else { |
| | | mData = event.getState() == 0 ? "闭合" : "断开"; |
| | | mData = event.getState() == 0 ? "正常" : "报警"; |
| | | } |
| | | |
| | | sensorText.setText("传感器---干接点状态:" + mData); |
| | | // showToast("传感器---干接点状态:" + mData); |
| | | HDLLog.Log("传感器---干接点状态:" + mData); |
| | | sensorText.setText("传感器状态:" + mData); |
| | | HDLLog.Log("传感器状态:" + mData); |
| | | } |
| | | } |
| | | |