|
@@ -20,6 +20,7 @@ import com.google.gson.Gson
|
|
import com.wdkl.app.ncs.callingdoor.BuildConfig
|
|
import com.wdkl.app.ncs.callingdoor.BuildConfig
|
|
import com.wdkl.app.ncs.callingdoor.R
|
|
import com.wdkl.app.ncs.callingdoor.R
|
|
import com.wdkl.app.ncs.callingdoor.agreement.CallingdoorAgreement
|
|
import com.wdkl.app.ncs.callingdoor.agreement.CallingdoorAgreement
|
|
|
|
+import com.wdkl.app.ncs.callingdoor.bean.CallingItem
|
|
import com.wdkl.app.ncs.callingdoor.bean.Trans433Data
|
|
import com.wdkl.app.ncs.callingdoor.bean.Trans433Data
|
|
import com.wdkl.app.ncs.callingdoor.databinding.CallingdoorMainLayBinding
|
|
import com.wdkl.app.ncs.callingdoor.databinding.CallingdoorMainLayBinding
|
|
import com.wdkl.app.ncs.callingdoor.fragment.*
|
|
import com.wdkl.app.ncs.callingdoor.fragment.*
|
|
@@ -45,6 +46,7 @@ import com.wdkl.ncs.android.middleware.model.vo.DeviceRoomInfoVO
|
|
import com.wdkl.ncs.android.middleware.model.vo.FrameBedVO
|
|
import com.wdkl.ncs.android.middleware.model.vo.FrameBedVO
|
|
import com.wdkl.ncs.android.middleware.model.vo.InteractionVO
|
|
import com.wdkl.ncs.android.middleware.model.vo.InteractionVO
|
|
import com.wdkl.ncs.android.middleware.tcp.TcpClient
|
|
import com.wdkl.ncs.android.middleware.tcp.TcpClient
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.channel.DeviceChannel
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.OtherUtil
|
|
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.channel.VoiceUtil
|
|
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
|
|
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
|
|
@@ -80,6 +82,7 @@ import serialporttest.utils.StringUtils
|
|
import java.io.*
|
|
import java.io.*
|
|
import java.lang.Process
|
|
import java.lang.Process
|
|
import java.util.*
|
|
import java.util.*
|
|
|
|
+import java.util.concurrent.Executors
|
|
import java.util.concurrent.TimeUnit
|
|
import java.util.concurrent.TimeUnit
|
|
import kotlin.collections.ArrayList
|
|
import kotlin.collections.ArrayList
|
|
|
|
|
|
@@ -127,7 +130,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
|
|
|
private val handler by lazy { Handler(Looper.getMainLooper()) }
|
|
private val handler by lazy { Handler(Looper.getMainLooper()) }
|
|
|
|
|
|
- private var bedCalls = ArrayList<String>()
|
|
|
|
|
|
+ private var bedCalls = ArrayList<CallingItem>()
|
|
|
|
|
|
private var trans433Data: Trans433Data? = null
|
|
private var trans433Data: Trans433Data? = null
|
|
|
|
|
|
@@ -246,6 +249,8 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
//3288 15.6寸竖屏:width=1080, height=1920
|
|
//3288 15.6寸竖屏:width=1080, height=1920
|
|
//3288 10.1寸竖屏:width=800, height=1280
|
|
//3288 10.1寸竖屏:width=800, height=1280
|
|
Log.d(TAG, "device orientation: ${Constant.DEVICE_ORIENTATION}, width: ${dm.widthPixels}, height: ${dm.heightPixels}")
|
|
Log.d(TAG, "device orientation: ${Constant.DEVICE_ORIENTATION}, width: ${dm.widthPixels}, height: ${dm.heightPixels}")
|
|
|
|
+
|
|
|
|
+ startScheduledExecutor()
|
|
}
|
|
}
|
|
|
|
|
|
//检查launch版本
|
|
//检查launch版本
|
|
@@ -396,6 +401,17 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun startScheduledExecutor() {
|
|
|
|
+ val timerTask: TimerTask = object : TimerTask() {
|
|
|
|
+ override fun run() {
|
|
|
|
+ checkCalls()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val executor = Executors.newSingleThreadScheduledExecutor()
|
|
|
|
+ executor!!.scheduleAtFixedRate(timerTask, 100, 30, TimeUnit.SECONDS)
|
|
|
|
+ }
|
|
|
|
+
|
|
private fun showMsgMain(msg: String) {
|
|
private fun showMsgMain(msg: String) {
|
|
runOnUiThread {
|
|
runOnUiThread {
|
|
showMessage(msg)
|
|
showMessage(msg)
|
|
@@ -1228,6 +1244,8 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
nursingInteId = interactionVO.id
|
|
nursingInteId = interactionVO.id
|
|
SettingConfig.setNursingId(activity, nursingInteId)
|
|
SettingConfig.setNursingId(activity, nursingInteId)
|
|
|
|
+ } else if (tcpModel.action == TcpAction.SideAction.SHOW || tcpModel.action == TcpAction.SideAction.CLEAR) {
|
|
|
|
+ updateCallInfo(tcpModel)
|
|
} else {
|
|
} else {
|
|
/*if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
|
|
/*if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
|
|
DoorLightHelper.handleDoorLight(tcpModel)
|
|
DoorLightHelper.handleDoorLight(tcpModel)
|
|
@@ -1295,14 +1313,14 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
if (tcpModel.action == TcpAction.SideAction.CALL) {
|
|
if (tcpModel.action == TcpAction.SideAction.CALL) {
|
|
SerialPortHelper.setDoorLight(1, "200")
|
|
SerialPortHelper.setDoorLight(1, "200")
|
|
//显示分机呼叫信息
|
|
//显示分机呼叫信息
|
|
- val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
- updateBedCall(interactionVO, true)
|
|
|
|
|
|
+ //val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
+ //updateBedCall(interactionVO, true)
|
|
} else if (tcpModel.action == TcpAction.SideAction.SOS_CALL) {
|
|
} else if (tcpModel.action == TcpAction.SideAction.SOS_CALL) {
|
|
SerialPortHelper.setDoorLight(1, "200")
|
|
SerialPortHelper.setDoorLight(1, "200")
|
|
Constant.sosOn = true
|
|
Constant.sosOn = true
|
|
} else if (tcpModel.action == TcpAction.SideAction.ACCEPT || tcpModel.action == TcpAction.SideAction.CANCEL) {
|
|
} else if (tcpModel.action == TcpAction.SideAction.ACCEPT || tcpModel.action == TcpAction.SideAction.CANCEL) {
|
|
- val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
- updateBedCall(interactionVO, false)
|
|
|
|
|
|
+ //val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
+ //updateBedCall(interactionVO, false)
|
|
|
|
|
|
//如果当前还有其他床位呼叫或者是紧急呼叫则不重置门灯
|
|
//如果当前还有其他床位呼叫或者是紧急呼叫则不重置门灯
|
|
if (bedCalls.size == 0 && !Constant.sosOn) {
|
|
if (bedCalls.size == 0 && !Constant.sosOn) {
|
|
@@ -1319,54 +1337,116 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun updateCallInfo(tcpModel: TcpModel) {
|
|
|
|
+ val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
+ if (tcpModel.action == TcpAction.SideAction.SHOW) {
|
|
|
|
+ //显示呼叫信息
|
|
|
|
+ updateBedCall(interactionVO, true)
|
|
|
|
+ } else if (tcpModel.action == TcpAction.SideAction.CLEAR) {
|
|
|
|
+ //清除呼叫信息
|
|
|
|
+ updateBedCall(interactionVO, false)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//更新呼叫信息显示
|
|
//更新呼叫信息显示
|
|
private fun updateBedCall(interactionVO: InteractionVO, add: Boolean) {
|
|
private fun updateBedCall(interactionVO: InteractionVO, add: Boolean) {
|
|
- val language = LocaleMangerUtils.getApplicationLocale().language
|
|
|
|
- val name = CommonUtils.subStringAfter(interactionVO.fromFrameFullName, "-")
|
|
|
|
- val frameName: String
|
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
|
- frameName = Util.appendSpace(interactionVO.fromFrameFullName.replace("-", ","))
|
|
|
|
- } else {
|
|
|
|
- frameName = interactionVO.fromFrameFullName.replace("-", "")
|
|
|
|
- }
|
|
|
|
- val text = getString(R.string.voice_call_speech, frameName)
|
|
|
|
- if (add) {
|
|
|
|
- bedCalls.add(name)
|
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
|
- if (Constant.TTS_STATUS == 2) {
|
|
|
|
- SpeechUtil.getInstance().addSpeech(text, false)
|
|
|
|
|
|
+ try {
|
|
|
|
+ val language = LocaleMangerUtils.getApplicationLocale().language
|
|
|
|
+ val bedName = CommonUtils.subStringAfter(interactionVO.fromFrameFullName, "-")
|
|
|
|
+ val roomName = CommonUtils.subStringBefore(interactionVO.fromFrameFullName, "-")
|
|
|
|
+ var showText = getString(R.string.voice_call_speech, bedName)
|
|
|
|
+ if (interactionVO.actionType == TcpType.SOS.name) {
|
|
|
|
+ //紧急呼叫
|
|
|
|
+ if (!TextUtils.isEmpty(interactionVO.data)) {
|
|
|
|
+ showText = interactionVO.data
|
|
|
|
+ } else {
|
|
|
|
+ showText = getString(R.string.sos_call_speech, roomName)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- bedCalls.remove(name)
|
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
|
- if (Constant.TTS_STATUS == 2) {
|
|
|
|
- SpeechUtil.getInstance().removeSpeak(text)
|
|
|
|
|
|
+
|
|
|
|
+ val speechText: String
|
|
|
|
+ if (Locale.CHINESE.language.equals(language)) {
|
|
|
|
+ speechText = Util.appendSpace(showText.replace("-", ","))
|
|
|
|
+ } else {
|
|
|
|
+ speechText = showText.replace("-", " ")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (add) {
|
|
|
|
+ val item = CallingItem(System.currentTimeMillis(), showText)
|
|
|
|
+ bedCalls.add(item)
|
|
|
|
+ /*if (Locale.CHINESE.language.equals(language)) {
|
|
|
|
+ if (Constant.TTS_STATUS == 2) {
|
|
|
|
+ SpeechUtil.getInstance().addSpeech(speechText, false)
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+ } else {
|
|
|
|
+ if (bedCalls.size > 0) {
|
|
|
|
+ val iterator = bedCalls.iterator()
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ val it = iterator.next()
|
|
|
|
+ if (it.text == showText) {
|
|
|
|
+ iterator.remove()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ /*if (Locale.CHINESE.language.equals(language)) {
|
|
|
|
+ if (Constant.TTS_STATUS == 2) {
|
|
|
|
+ SpeechUtil.getInstance().removeSpeak(speechText)
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ showCalls()
|
|
|
|
+ } catch (ex: Exception) {
|
|
|
|
+ ex.printStackTrace()
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- if (bedCalls.size > 0) {
|
|
|
|
- view_flipper.removeAllViews()
|
|
|
|
- for ((index, e) in bedCalls.withIndex()) {
|
|
|
|
- val textView = TextView(activity)
|
|
|
|
- textView.text = e + " " + StringUtil.getResString(R.string.str_call)
|
|
|
|
- textView.setSingleLine(true)
|
|
|
|
- textView.setEllipsize(TextUtils.TruncateAt.END);
|
|
|
|
- textView.setTextColor(Color.RED)
|
|
|
|
- if ("rk3288".equals(Build.MODEL)) {
|
|
|
|
- textView.textSize = 48f
|
|
|
|
- } else {
|
|
|
|
- textView.textSize = 32f
|
|
|
|
|
|
+ private fun showCalls() {
|
|
|
|
+ synchronized(Unit) {
|
|
|
|
+ if (bedCalls.size > 0) {
|
|
|
|
+ view_flipper.removeAllViews()
|
|
|
|
+ for ((index, e) in bedCalls.withIndex()) {
|
|
|
|
+ val textView = TextView(activity)
|
|
|
|
+ textView.text = e.text
|
|
|
|
+ textView.setSingleLine(true)
|
|
|
|
+ textView.setEllipsize(TextUtils.TruncateAt.END)
|
|
|
|
+ textView.setTextColor(Color.RED)
|
|
|
|
+ if ("rk3288".equals(Build.MODEL)) {
|
|
|
|
+ textView.textSize = 48f
|
|
|
|
+ } else {
|
|
|
|
+ textView.textSize = 32f
|
|
|
|
+ }
|
|
|
|
+ textView.gravity = (Gravity.END or Gravity.CENTER)
|
|
|
|
+ //textView.getPaint().setFlags(mFlags);//字体划线
|
|
|
|
+ //textView.setTypeface(null, mTypeface);//字体样式
|
|
|
|
+
|
|
|
|
+ view_flipper.addView(textView, index)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ view_flipper.removeAllViews()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun checkCalls() {
|
|
|
|
+ //5分钟无人处理自动清除
|
|
|
|
+ try {
|
|
|
|
+ if (bedCalls.size > 0) {
|
|
|
|
+ val iterator = bedCalls.iterator()
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ val it = iterator.next()
|
|
|
|
+ if (System.currentTimeMillis() - it.time >= 5 * 60 * 1000) {
|
|
|
|
+ iterator.remove()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- textView.gravity = (Gravity.END or Gravity.CENTER)
|
|
|
|
- //textView.getPaint().setFlags(mFlags);//字体划线
|
|
|
|
- //textView.setTypeface(null, mTypeface);//字体样式
|
|
|
|
|
|
|
|
- view_flipper.addView(textView, index)
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ showCalls()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- view_flipper.removeAllViews()
|
|
|
|
|
|
+ } catch (ex: Exception) {
|
|
|
|
+ ex.printStackTrace()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1495,9 +1575,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
|
|
|
inner class TimeReceiver: BroadcastReceiver() {
|
|
inner class TimeReceiver: BroadcastReceiver() {
|
|
override fun onReceive(context: Context, intent: Intent) {
|
|
override fun onReceive(context: Context, intent: Intent) {
|
|
- if (intent.action == Intent.ACTION_TIME_TICK
|
|
|
|
- || intent.action == Intent.ACTION_TIME_CHANGED
|
|
|
|
- || intent.action == Intent.ACTION_TIMEZONE_CHANGED) {
|
|
|
|
|
|
+ if (intent.action == Intent.ACTION_TIME_TICK) {
|
|
updateNetState()
|
|
updateNetState()
|
|
if (initialized) {
|
|
if (initialized) {
|
|
updateSettings(false)
|
|
updateSettings(false)
|