#pragma once #include "uart/ProtocolSender.h" #include #include "app/Activity.h" #include "service/BusinessConfig.h" #include "net/NetManager.h" #include "core/sip_config.h" #include "core/utilities.h" /* *此文件由GUI工具生成 *文件功能:用于处理用户的逻辑相应代码 *功能说明: *========================onButtonClick_XXXX 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[标识]名称, 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK. *========================onSlideWindowItemClick_XXXX(int index) 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[标识]名称, 如slideWindow1;index 代表按下图标的偏移值 *========================onSeekBarChange_XXXX(int progress) 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[标识]名称, 如SeekBar1;progress 代表当前的进度值 *========================ogetListItemCount_XXXX() 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[标识]名称, 如List1;返回值为当前列表的总条数 *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index) 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[标识]名称, 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明 *========================常用接口=============== *LOGD(...) 打印调试信息的接口 *mTextXXX->setText("****") 在控件TextXXX上显示文字**** *mButton1->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色 *mSeekBar->setProgress(12) 在控件mSeekBar上将进度调整到12 *mListView1->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用 *mDashbroadView1->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度 */ static uint32_t navibarButtonColor = buleDeepColour; static bool isNursing2 = false; static bool hasClerk = false; static int blueCodeId = 0; static string blueCodeTid = ""; static string clerkNfc = ""; void setNavibarTheme() { int themeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt); if (themeInt == 1) { mBgPainterPtr->setBackgroundPic("/navibar/bg.png"); mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/square_bule.png"); navibarButtonColor = buleDeepColour; mHomeButtonPtr->setTextColor(navibarButtonColor); } else if (themeInt == 2) { mBgPainterPtr->setBackgroundPic("/navibar/bg-pink.png"); mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/square_pink.png"); navibarButtonColor = redDeepColour; mHomeButtonPtr->setTextColor(navibarButtonColor); } } void goHome() { mHomeButtonPtr->setBackgroundPic("button/elliptic_white.png"); mHomeButtonPtr->setTextColor(navibarButtonColor); mHealthCareButtonPtr->setBackgroundPic(""); mHealthCareButtonPtr->setTextColor(whiteColour); mMoreButtonPtr->setBackgroundPic(""); mMoreButtonPtr->setTextColor(whiteColour); EASYUICONTEXT->openActivity("mainActivity"); EASYUICONTEXT->closeActivity("moreActivity"); EASYUICONTEXT->closeActivity("medicalCareActivity"); } void goMore() { mHomeButtonPtr->setBackgroundPic(""); mHomeButtonPtr->setTextColor(whiteColour); mHealthCareButtonPtr->setBackgroundPic(""); mHealthCareButtonPtr->setTextColor(whiteColour); mMoreButtonPtr->setBackgroundPic("button/elliptic_white.png"); mMoreButtonPtr->setTextColor(navibarButtonColor); EASYUICONTEXT->openActivity("moreActivity"); // EASYUICONTEXT->closeActivity("mainActivity"); EASYUICONTEXT->closeActivity("medicalCareActivity"); } void goCare() { mHomeButtonPtr->setBackgroundPic(""); mHomeButtonPtr->setTextColor(whiteColour); mHealthCareButtonPtr->setBackgroundPic("button/elliptic_white.png"); mHealthCareButtonPtr->setTextColor(navibarButtonColor); mMoreButtonPtr->setBackgroundPic(""); mMoreButtonPtr->setTextColor(whiteColour); EASYUICONTEXT->openActivity("medicalCareActivity"); // EASYUICONTEXT->closeActivity("mainActivity"); EASYUICONTEXT->closeActivity("moreActivity"); } void setNursingBg(bool setNursing) { isNursing2 = setNursing; if (mnavibarPtr == NULL) { return; } if (setNursing) { mBgPainterPtr->setBackgroundPic("navibar/bg-pink.png"); mNursingButtonPtr->setText(LANGUAGEMANAGER->getValue("NursingEnd")); mBlueCodeButtonPtr->setInvalid(false); } else { mBgPainterPtr->setBackgroundPic("navibar/bg.png"); mNursingButtonPtr->setText(LANGUAGEMANAGER->getValue("Nursing")); mBlueCodeButtonPtr->setInvalid(true); } } void setNursing2(bool setNursing) { if (setNursing) { setNursingBg(setNursing); // 门灯控制 std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010"); if (color != "" && color.size() == 3) { color = color + "F"; } else { color = "010F"; } lightControl("DOORLED", color); sendNursing(); // 把护理状态缓存起来 StoragePreferences::putBool(STORE_NURSING_TYPE, true); } else { setNursingBg(setNursing); lightControl("DOORLED", "000F"); setNursingEnd(); if (blueCodeId != 0) { sendBlueCodeResponse(blueCodeTid, to_string(blueCodeId)); blueCodeId = 0; blueCodeTid = ""; } } } //void callBedButtonSetVisible() { // if (mnavibarPtr == NULL) { // return; // } // // int roomCallBed = StoragePreferences::getInt(STORE_ROOM_CALL_BED, 1); // if (!roomCallBed) { // // 如果roomCallBed是0的话,那就隐藏 // mCallBedButtonPtr->setVisible(roomCallBed); // mCallBedPicPainterPtr->setVisible(roomCallBed); // // mHelpButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96)); // mHelpPicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27)); // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 482, 96, 96)); // mCallNursePicPainterPtr->setPosition(LayoutPosition(45, 504, 29, 27)); // // } // else { // // 如果roomCallBed是1的话,那就显示 // mCallBedButtonPtr->setVisible(roomCallBed); // mCallBedPicPainterPtr->setVisible(roomCallBed); // // mHelpButtonPtr->setPosition(LayoutPosition(11, 265, 96, 96)); // mHelpPicPainterPtr->setPosition(LayoutPosition(43, 287, 32, 26)); // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96)); // mCallNursePicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27)); // } //} void setBlueCodeId(int id, string tid) { blueCodeId = id; blueCodeTid = tid; } void navibarNfcLogout() { hasClerk = false; clerkNfc = ""; sendAuthLogout(to_string(getAuthItId())); mNfcLogoutButtonPtr->setVisible(false); } void navibarNfcLogin(std::string revStr) { if (hasClerk) { if (clerkNfc == revStr) { navibarNfcLogout(); Intent* intent = new Intent(); intent->putExtra(functionWindows, "success"); intent->putExtra(functionText, LANGUAGEMANAGER->getValue("NfcLogoutSuccess")); EASYUICONTEXT->openActivity("functionActivity", intent); return; } navibarNfcLogout(); } bool reslut = getClerkByPartIdAndPassNo(revStr); if (reslut) { hasClerk = true; clerkNfc = revStr; sendAuthLogin(clerkNfc); sendSignIn(clerkNfc); sendPostionStart(clerkNfc); mNfcLogoutButtonPtr->setVisible(true); Intent* intent = new Intent(); intent->putExtra(functionWindows, "success"); intent->putExtra(functionText, LANGUAGEMANAGER->getValue("NfcLoginSuccess")); EASYUICONTEXT->openActivity("functionActivity", intent); } else { Intent* intent = new Intent(); intent->putExtra(functionWindows, "warn"); intent->putExtra(warnText, LANGUAGEMANAGER->getValue("PassNoError")); EASYUICONTEXT->openActivity("functionActivity", intent); } } /** * 注册定时器 * 填充数组用于注册定时器 * 注意:id不能重复 */ static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = { //{0, 6000}, //定时器id=0, 时间间隔6秒 //{1, 1000}, }; /** * 当界面构造时触发 */ static void onUI_init(){ //Tips :添加 UI初始化的显示代码到这里,如:mText1->setText("123"); // callBedButtonSetVisible(); setNavibarTheme(); setNursingBg(isNursing2); } /* * 当界面完全退出时触发 */ static void onUI_quit() { } /** * 串口数据回调接口 */ static void onProtocolDataUpdate(const SProtocolData &data) { //串口数据回调接口 } /** * 定时器触发函数 * 不建议在此函数中写耗时操作,否则将影响UI刷新 * 参数: id * 当前所触发定时器的id,与注册时的id相同 * 返回值: true * 继续运行当前定时器 * false * 停止运行当前定时器 */ static bool onUI_Timer(int id){ switch (id) { default: break; } return true; } /** * 有新的触摸事件时触发 * 参数:ev * 新的触摸事件 * 返回值:true * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上 * false * 触摸事件将继续传递到控件上 */ static bool onnavibarActivityTouchEvent(const MotionEvent &ev) { switch (ev.mActionStatus) { case MotionEvent::E_ACTION_DOWN://触摸按下 //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY); break; case MotionEvent::E_ACTION_MOVE://触摸滑动 break; case MotionEvent::E_ACTION_UP: //触摸抬起 break; default: break; } return false; } static bool onButtonClick_HomeButton(ZKButton *pButton) { LOGD(" ButtonClick HomeButton !!!\n"); // if (getAuthItId() != 0) { // Intent* intent = new Intent(); // intent->putExtra(functionWindows, "logoutMedicalCare"); // intent->putExtra(goActivity, "home"); // EASYUICONTEXT->openActivity("functionActivity", intent); // } else { // goHome(); // } goHome(); return false; } static bool onButtonClick_HealthCareButton(ZKButton *pButton) { LOGD(" ButtonClick HealthCareButton !!!\n"); goCare(); return false; } static bool onButtonClick_MoreButton(ZKButton *pButton) { LOGD(" ButtonClick MoreButton !!!\n"); // if (getAuthItId() != 0) { // Intent* intent = new Intent(); // intent->putExtra(functionWindows, "logoutMedicalCare"); // intent->putExtra(goActivity, "more"); // EASYUICONTEXT->openActivity("functionActivity", intent); // } else { // goMore(); // } goMore(); return false; } static bool onButtonClick_HelpButton(ZKButton *pButton) { LOGD(" ButtonClick HelpButton !!!\n"); sendReinforceCall(); Intent* intent = new Intent(); intent->putExtra(functionWindows, "help"); EASYUICONTEXT->openActivity("functionActivity", intent); return false; } static bool onButtonClick_CallNurseButton(ZKButton *pButton) { LOGD(" ButtonClick CallNurseButton !!!\n"); if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){ int port = StoragePreferences::getInt(SIP_REG_PORT, SIP_REG_PORT_DEFAULT); std::string domain = StoragePreferences::getString(SIP_REG_DOMAIN, SIP_REG_DOMAIN_DEFAULT); std::string od_number = StoragePreferences::getString(SIP_REG_DOOR_ACCOUNT, SIP_REG_DOOR_ACCOUNT_DEFAULT); std::string od_number_uri = URI(od_number, domain, port); LOGD("od_number_uri: %s", od_number_uri.c_str()); GetTelephone()->MakeCall(od_number_uri); } else { Intent* intent = new Intent(); intent->putExtra(isOutgoing, "true"); EASYUICONTEXT->openActivity("callActivity", intent); } return false; } static bool onButtonClick_CallCancelButton(ZKButton *pButton) { LOGD(" ButtonClick CallCancelButton !!!\n"); sendCallByDoor(); return false; } static bool onButtonClick_NursingButton(ZKButton *pButton) { LOGD(" ButtonClick NursingButton !!!\n"); if (!isNursing2) { Intent* intent = new Intent(); intent->putExtra(functionWindows, "nursing2"); EASYUICONTEXT->openActivity("functionActivity", intent); } else { Intent* intent = new Intent(); intent->putExtra(functionWindows, "nursingEnd2"); EASYUICONTEXT->openActivity("functionActivity", intent); } return false; } static bool onButtonClick_BlueCodeButton(ZKButton *pButton) { LOGD(" ButtonClick BlueCodeButton !!!\n"); sendBlueCodeCall(); mBlueCodeButtonPtr->setInvalid(true); lightControl("DOORLED", "001F"); Intent* intent = new Intent(); intent->putExtra(functionWindows, "blueCode"); EASYUICONTEXT->openActivity("functionActivity", intent); return false; } static bool onButtonClick_NfcLogoutButton(ZKButton *pButton) { LOGD(" ButtonClick NfcLogoutButton !!!\n"); Intent* intent = new Intent(); intent->putExtra(functionWindows, "navibarLogout"); EASYUICONTEXT->openActivity("functionActivity", intent); return false; }