|
@@ -45,6 +45,7 @@ import com.wdkl.ncs.android.middleware.tcp.TcpClient
|
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.OtherUtil
|
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.VoiceUtil
|
|
|
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.DeviceTypeEnum
|
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
|
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
|
|
|
import com.wdkl.ncs.android.middleware.utils.AppUtil
|
|
@@ -59,8 +60,6 @@ import kotlinx.android.synthetic.main.view_title_layout.*
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
-import rs485.ByteUtil
|
|
|
-import rs485.Rs485Calling
|
|
|
import serialporttest.utils.SerialPort485Util
|
|
|
import serialporttest.utils.SerialPortUtil
|
|
|
import java.util.*
|
|
@@ -651,6 +650,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
if (Constant.CALL_STATE == Constant.CALL_STANDBY) {
|
|
|
Constant.CALL_STATE = Constant.CALL_OUTGOING
|
|
|
}
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -669,6 +669,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
if (resetCall) {
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
}
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -695,6 +696,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
if (frameDevice.device != null && uart.equals(frameDevice.device.ethMac, true)) {
|
|
|
updateCallText("紧急呼叫-->$uart, ${frameDevice.device.id}")
|
|
|
OtherUtil.sendSosCall(frameDevice.device.id)
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -754,16 +756,17 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
//首先找到分机所在床位层级,然后通过该bed frame的父级id(即房间层级)找到对应room frame,获得门灯设备信息
|
|
|
if (!TextUtils.isEmpty(bedAddr) && FrameHelper.frameDeviceList.size > 0) {
|
|
|
var roomId = -1
|
|
|
- for (frameDevice in FrameHelper.frameDeviceList) {
|
|
|
- if (frameDevice.device != null && bedAddr.equals(frameDevice.device.ethMac, true)) {
|
|
|
- roomId = frameDevice.frame.parentId
|
|
|
+ for (bedFrameDevice in FrameHelper.frameDeviceList) {
|
|
|
+ if (bedFrameDevice.device != null && bedAddr.equals(bedFrameDevice.device.ethMac, true)) {
|
|
|
+ roomId = bedFrameDevice.frame.parentId
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (roomId != -1) {
|
|
|
for (frameDevice in FrameHelper.frameDeviceList) {
|
|
|
if (frameDevice.frame != null && frameDevice.frame.id == roomId) {
|
|
|
- if (frameDevice.device != null && frameDevice.device.deviceType == 14) {
|
|
|
+ if (frameDevice.device != null && frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_DOOR_LIGHT.value()) {
|
|
|
//找到对应门灯设备
|
|
|
return frameDevice.device.ethMac
|
|
|
}
|
|
@@ -781,16 +784,17 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
//首先找到分机所在床位层级,然后通过该bed frame的父级id(即房间层级)找到对应room frame,获得门灯设备信息
|
|
|
if (!TextUtils.isEmpty(sosAddr) && FrameHelper.frameDeviceList.size > 0) {
|
|
|
var roomId = -1
|
|
|
- for (frameDevice in FrameHelper.frameDeviceList) {
|
|
|
- if (frameDevice.device != null && sosAddr.equals(frameDevice.device.ethMac, true)) {
|
|
|
- roomId = frameDevice.frame.id
|
|
|
+ for (roomFrameDevice in FrameHelper.frameDeviceList) {
|
|
|
+ if (roomFrameDevice.device != null && sosAddr.equals(roomFrameDevice.device.ethMac, true)) {
|
|
|
+ roomId = roomFrameDevice.frame.id
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (roomId != -1) {
|
|
|
for (frameDevice in FrameHelper.frameDeviceList) {
|
|
|
if (frameDevice.frame != null && frameDevice.frame.id == roomId) {
|
|
|
- if (frameDevice.device != null && frameDevice.device.deviceType == 14) {
|
|
|
+ if (frameDevice.device != null && frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_DOOR_LIGHT.value()) {
|
|
|
//找到对应门灯设备
|
|
|
return frameDevice.device.ethMac
|
|
|
}
|
|
@@ -803,6 +807,62 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
return null
|
|
|
}
|
|
|
|
|
|
+ //豪华分机呼叫同时需要控制对应房间模拟门灯
|
|
|
+ private fun controlDoorLight(tcpModel: TcpModel) {
|
|
|
+ val sideInteractionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
+ Log.e(TAG, "bed frameId: " + sideInteractionVO.fromDeviceFrameId + ", from parent frameId: " + sideInteractionVO.fromFrameParentId
|
|
|
+ + ", to parent frameId: " + sideInteractionVO.toFrameParentId)
|
|
|
+ if (FrameHelper.frameDeviceList.size > 0) {
|
|
|
+ if (TcpAction.SideAction.CALL == tcpModel.action
|
|
|
+ || TcpAction.SideAction.SOS_CALL == tcpModel.action
|
|
|
+ ) {
|
|
|
+ //分机呼叫或紧急呼叫
|
|
|
+ if (sideInteractionVO.fromFrameParentId != null) {
|
|
|
+ for (frameDevice in FrameHelper.frameDeviceList) {
|
|
|
+ if (frameDevice.frame != null && frameDevice.frame.id == sideInteractionVO.fromFrameParentId.toInt()) {
|
|
|
+ if (frameDevice.device != null && frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_DOOR_LIGHT.value()) {
|
|
|
+ //找到对应门灯设备
|
|
|
+ Log.e(TAG, "turn on door light: " + frameDevice.device.ethMac)
|
|
|
+ SerialPortHelper.openDoorLight(frameDevice.device.ethMac)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (TcpAction.SideAction.ACCEPT == tcpModel.action
|
|
|
+ || TcpAction.SideAction.CANCEL == tcpModel.action
|
|
|
+ || TcpAction.SideAction.SOS_CANCEL == tcpModel.action
|
|
|
+ ) {
|
|
|
+ //主机呼叫分机或分机取消或主机接听
|
|
|
+ if (sideInteractionVO.fromFrameParentId != null) {
|
|
|
+ for (frameDevice in FrameHelper.frameDeviceList) {
|
|
|
+ if (frameDevice.frame != null && frameDevice.frame.id == sideInteractionVO.fromFrameParentId.toInt()) {
|
|
|
+ if (frameDevice.device != null && frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_DOOR_LIGHT.value()) {
|
|
|
+ //找到对应门灯设备
|
|
|
+ Log.e(TAG, "turn off door light: " + frameDevice.device.ethMac)
|
|
|
+ SerialPortHelper.closeDoorLight(frameDevice.device.ethMac)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sideInteractionVO.toFrameParentId != null) {
|
|
|
+ for (frameDevice in FrameHelper.frameDeviceList) {
|
|
|
+ if (frameDevice.frame != null && frameDevice.frame.id == sideInteractionVO.toFrameParentId.toInt()) {
|
|
|
+ if (frameDevice.device != null && frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_DOOR_LIGHT.value()) {
|
|
|
+ //找到对应门灯设备
|
|
|
+ Log.e(TAG, "turn off door light: " + frameDevice.device.ethMac)
|
|
|
+ SerialPortHelper.closeDoorLight(frameDevice.device.ethMac)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private fun updateCallText(str: String) {
|
|
|
runOnUiThread {
|
|
|
tv_call_state.setText("呼叫状态: " + str)
|
|
@@ -1085,6 +1145,9 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
Constant.LATER_RESTART = true
|
|
|
}
|
|
|
}
|
|
|
+ } else if (tcpModel.type == TcpType.SIDE) {
|
|
|
+ //门灯控制
|
|
|
+ controlDoorLight(tcpModel)
|
|
|
} else if (tcpModel.action == TcpAction.DataAction.REFRESH) {
|
|
|
//重新加载数据,比如出院,入院等
|
|
|
initDevice()
|