navibar.cc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include <sys/reboot.h>
  4. #include "app/Activity.h"
  5. #include "service/BusinessConfig.h"
  6. #include "net/NetManager.h"
  7. #include "core/sip_config.h"
  8. #include "core/utilities.h"
  9. /*
  10. *此文件由GUI工具生成
  11. *文件功能:用于处理用户的逻辑相应代码
  12. *功能说明:
  13. *========================onButtonClick_XXXX
  14. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[标识]名称,
  15. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  16. *========================onSlideWindowItemClick_XXXX(int index)
  17. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[标识]名称,
  18. 如slideWindow1;index 代表按下图标的偏移值
  19. *========================onSeekBarChange_XXXX(int progress)
  20. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[标识]名称,
  21. 如SeekBar1;progress 代表当前的进度值
  22. *========================ogetListItemCount_XXXX()
  23. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[标识]名称,
  24. 如List1;返回值为当前列表的总条数
  25. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  26. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[标识]名称,
  27. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  28. *========================常用接口===============
  29. *LOGD(...) 打印调试信息的接口
  30. *mTextXXX->setText("****") 在控件TextXXX上显示文字****
  31. *mButton1->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  32. *mSeekBar->setProgress(12) 在控件mSeekBar上将进度调整到12
  33. *mListView1->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  34. *mDashbroadView1->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  35. */
  36. static uint32_t navibarButtonColor = buleDeepColour;
  37. static bool isNursing2 = false;
  38. static bool hasClerk = false;
  39. static int blueCodeId = 0;
  40. static string blueCodeTid = "";
  41. static string clerkNfc = "";
  42. void setNavibarTheme() {
  43. int themeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt);
  44. if (themeInt == 1) {
  45. mBgPainterPtr->setBackgroundPic("/navibar/bg.png");
  46. mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/square_bule.png");
  47. navibarButtonColor = buleDeepColour;
  48. mHomeButtonPtr->setTextColor(navibarButtonColor);
  49. }
  50. else if (themeInt == 2) {
  51. mBgPainterPtr->setBackgroundPic("/navibar/bg-pink.png");
  52. mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/square_pink.png");
  53. navibarButtonColor = redDeepColour;
  54. mHomeButtonPtr->setTextColor(navibarButtonColor);
  55. }
  56. }
  57. void goHome() {
  58. mHomeButtonPtr->setBackgroundPic("button/elliptic_white.png");
  59. mHomeButtonPtr->setTextColor(navibarButtonColor);
  60. mHealthCareButtonPtr->setBackgroundPic("");
  61. mHealthCareButtonPtr->setTextColor(whiteColour);
  62. mMoreButtonPtr->setBackgroundPic("");
  63. mMoreButtonPtr->setTextColor(whiteColour);
  64. EASYUICONTEXT->openActivity("mainActivity");
  65. EASYUICONTEXT->closeActivity("moreActivity");
  66. EASYUICONTEXT->closeActivity("medicalCareActivity");
  67. }
  68. void goMore() {
  69. mHomeButtonPtr->setBackgroundPic("");
  70. mHomeButtonPtr->setTextColor(whiteColour);
  71. mHealthCareButtonPtr->setBackgroundPic("");
  72. mHealthCareButtonPtr->setTextColor(whiteColour);
  73. mMoreButtonPtr->setBackgroundPic("button/elliptic_white.png");
  74. mMoreButtonPtr->setTextColor(navibarButtonColor);
  75. EASYUICONTEXT->openActivity("moreActivity");
  76. // EASYUICONTEXT->closeActivity("mainActivity");
  77. EASYUICONTEXT->closeActivity("medicalCareActivity");
  78. }
  79. void goCare() {
  80. mHomeButtonPtr->setBackgroundPic("");
  81. mHomeButtonPtr->setTextColor(whiteColour);
  82. mHealthCareButtonPtr->setBackgroundPic("button/elliptic_white.png");
  83. mHealthCareButtonPtr->setTextColor(navibarButtonColor);
  84. mMoreButtonPtr->setBackgroundPic("");
  85. mMoreButtonPtr->setTextColor(whiteColour);
  86. EASYUICONTEXT->openActivity("medicalCareActivity");
  87. // EASYUICONTEXT->closeActivity("mainActivity");
  88. EASYUICONTEXT->closeActivity("moreActivity");
  89. }
  90. void setNursingBg(bool setNursing) {
  91. isNursing2 = setNursing;
  92. if (mnavibarPtr == NULL) {
  93. return;
  94. }
  95. if (setNursing) {
  96. mBgPainterPtr->setBackgroundPic("navibar/bg-pink.png");
  97. mNursingButtonPtr->setText(LANGUAGEMANAGER->getValue("NursingEnd"));
  98. mBlueCodeButtonPtr->setInvalid(false);
  99. }
  100. else {
  101. mBgPainterPtr->setBackgroundPic("navibar/bg.png");
  102. mNursingButtonPtr->setText(LANGUAGEMANAGER->getValue("Nursing"));
  103. mBlueCodeButtonPtr->setInvalid(true);
  104. }
  105. }
  106. void setNursing2(bool setNursing) {
  107. if (setNursing) {
  108. setNursingBg(setNursing);
  109. // 门灯控制
  110. std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
  111. if (color != "" && color.size() == 3) {
  112. color = color + "F";
  113. } else {
  114. color = "010F";
  115. }
  116. lightControl("DOORLED", color);
  117. statusLight();
  118. sendNursing();
  119. // 把护理状态缓存起来
  120. StoragePreferences::putBool(STORE_NURSING_TYPE, true);
  121. std::list<string> _sosData = getSosDataList();
  122. if (_sosData.empty()) {
  123. return;
  124. }
  125. std::list<string>::iterator it = _sosData.begin();
  126. while (it != _sosData.end()) {
  127. string sosDataStr = *it;
  128. sendSosCancel(sosDataStr);
  129. it++;
  130. }
  131. cleanSosDataList();
  132. }
  133. else {
  134. setNursingBg(setNursing);
  135. lightControl("DOORLED", "000F");
  136. setNursingEnd();
  137. if (blueCodeId != 0) {
  138. sendBlueCodeResponse(blueCodeTid, to_string(blueCodeId));
  139. blueCodeId = 0;
  140. blueCodeTid = "";
  141. }
  142. }
  143. }
  144. void setBlueCode(bool isInvalid) {
  145. if (isInvalid) {
  146. if (mBlueCodeButtonPtr->isInvalid()) {
  147. return;
  148. }
  149. }
  150. sendBlueCodeCall();
  151. mBlueCodeButtonPtr->setInvalid(true);
  152. std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
  153. if (color == "010") {
  154. lightControl("DOORLED", "002F");
  155. }
  156. else {
  157. lightControl("DOORLED", "020F");
  158. }
  159. Intent* intent = new Intent();
  160. intent->putExtra(functionWindows, "blueCode");
  161. EASYUICONTEXT->openActivity("functionActivity", intent);
  162. }
  163. void setBlueCode() {
  164. setBlueCode(false);
  165. }
  166. //void callBedButtonSetVisible() {
  167. // if (mnavibarPtr == NULL) {
  168. // return;
  169. // }
  170. //
  171. // int roomCallBed = StoragePreferences::getInt(STORE_ROOM_CALL_BED, 1);
  172. // if (!roomCallBed) {
  173. // // 如果roomCallBed是0的话,那就隐藏
  174. // mCallBedButtonPtr->setVisible(roomCallBed);
  175. // mCallBedPicPainterPtr->setVisible(roomCallBed);
  176. //
  177. // mHelpButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96));
  178. // mHelpPicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27));
  179. // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 482, 96, 96));
  180. // mCallNursePicPainterPtr->setPosition(LayoutPosition(45, 504, 29, 27));
  181. //
  182. // }
  183. // else {
  184. // // 如果roomCallBed是1的话,那就显示
  185. // mCallBedButtonPtr->setVisible(roomCallBed);
  186. // mCallBedPicPainterPtr->setVisible(roomCallBed);
  187. //
  188. // mHelpButtonPtr->setPosition(LayoutPosition(11, 265, 96, 96));
  189. // mHelpPicPainterPtr->setPosition(LayoutPosition(43, 287, 32, 26));
  190. // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96));
  191. // mCallNursePicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27));
  192. // }
  193. //}
  194. void setBlueCodeId(int id, string tid) {
  195. blueCodeId = id;
  196. blueCodeTid = tid;
  197. }
  198. void navibarNfcLogout() {
  199. hasClerk = false;
  200. clerkNfc = "";
  201. sendAuthLogout(to_string(getAuthItId()));
  202. mNfcLogoutButtonPtr->setVisible(false);
  203. }
  204. void navibarNfcLogin(std::string revStr) {
  205. if (hasClerk) {
  206. if (clerkNfc == revStr) {
  207. navibarNfcLogout();
  208. Intent* intent = new Intent();
  209. intent->putExtra(functionWindows, "success");
  210. intent->putExtra(functionText, LANGUAGEMANAGER->getValue("NfcLogoutSuccess"));
  211. EASYUICONTEXT->openActivity("functionActivity", intent);
  212. return;
  213. }
  214. navibarNfcLogout();
  215. }
  216. bool reslut = getClerkByPartIdAndPassNo(revStr);
  217. if (reslut) {
  218. hasClerk = true;
  219. clerkNfc = revStr;
  220. sendAuthLogin(clerkNfc);
  221. sendSignIn(clerkNfc);
  222. sendPostionStart(clerkNfc);
  223. mNfcLogoutButtonPtr->setVisible(true);
  224. Intent* intent = new Intent();
  225. intent->putExtra(functionWindows, "success");
  226. intent->putExtra(functionText, LANGUAGEMANAGER->getValue("NfcLoginSuccess"));
  227. EASYUICONTEXT->openActivity("functionActivity", intent);
  228. }
  229. else {
  230. Intent* intent = new Intent();
  231. intent->putExtra(functionWindows, "warn");
  232. intent->putExtra(warnText, LANGUAGEMANAGER->getValue("PassNoError"));
  233. EASYUICONTEXT->openActivity("functionActivity", intent);
  234. }
  235. }
  236. /**
  237. * 注册定时器
  238. * 填充数组用于注册定时器
  239. * 注意:id不能重复
  240. */
  241. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  242. //{0, 6000}, //定时器id=0, 时间间隔6秒
  243. //{1, 1000},
  244. };
  245. /**
  246. * 当界面构造时触发
  247. */
  248. static void onUI_init(){
  249. //Tips :添加 UI初始化的显示代码到这里,如:mText1->setText("123");
  250. // callBedButtonSetVisible();
  251. setNavibarTheme();
  252. setNursingBg(isNursing2);
  253. }
  254. /*
  255. * 当界面完全退出时触发
  256. */
  257. static void onUI_quit() {
  258. }
  259. /**
  260. * 串口数据回调接口
  261. */
  262. static void onProtocolDataUpdate(const SProtocolData &data) {
  263. //串口数据回调接口
  264. }
  265. /**
  266. * 定时器触发函数
  267. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  268. * 参数: id
  269. * 当前所触发定时器的id,与注册时的id相同
  270. * 返回值: true
  271. * 继续运行当前定时器
  272. * false
  273. * 停止运行当前定时器
  274. */
  275. static bool onUI_Timer(int id){
  276. switch (id) {
  277. default:
  278. break;
  279. }
  280. return true;
  281. }
  282. /**
  283. * 有新的触摸事件时触发
  284. * 参数:ev
  285. * 新的触摸事件
  286. * 返回值:true
  287. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  288. * false
  289. * 触摸事件将继续传递到控件上
  290. */
  291. static bool onnavibarActivityTouchEvent(const MotionEvent &ev) {
  292. switch (ev.mActionStatus) {
  293. case MotionEvent::E_ACTION_DOWN://触摸按下
  294. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  295. break;
  296. case MotionEvent::E_ACTION_MOVE://触摸滑动
  297. break;
  298. case MotionEvent::E_ACTION_UP: //触摸抬起
  299. break;
  300. default:
  301. break;
  302. }
  303. return false;
  304. }
  305. static bool onButtonClick_HomeButton(ZKButton *pButton) {
  306. LOGD(" ButtonClick HomeButton !!!\n");
  307. // if (getAuthItId() != 0) {
  308. // Intent* intent = new Intent();
  309. // intent->putExtra(functionWindows, "logoutMedicalCare");
  310. // intent->putExtra(goActivity, "home");
  311. // EASYUICONTEXT->openActivity("functionActivity", intent);
  312. // } else {
  313. // goHome();
  314. // }
  315. goHome();
  316. return false;
  317. }
  318. static bool onButtonClick_HealthCareButton(ZKButton *pButton) {
  319. LOGD(" ButtonClick HealthCareButton !!!\n");
  320. goCare();
  321. return false;
  322. }
  323. static bool onButtonClick_MoreButton(ZKButton *pButton) {
  324. LOGD(" ButtonClick MoreButton !!!\n");
  325. // if (getAuthItId() != 0) {
  326. // Intent* intent = new Intent();
  327. // intent->putExtra(functionWindows, "logoutMedicalCare");
  328. // intent->putExtra(goActivity, "more");
  329. // EASYUICONTEXT->openActivity("functionActivity", intent);
  330. // } else {
  331. // goMore();
  332. // }
  333. goMore();
  334. return false;
  335. }
  336. static bool onButtonClick_HelpButton(ZKButton *pButton) {
  337. LOGD(" ButtonClick HelpButton !!!\n");
  338. sendReinforceCall();
  339. Intent* intent = new Intent();
  340. intent->putExtra(functionWindows, "help");
  341. EASYUICONTEXT->openActivity("functionActivity", intent);
  342. return false;
  343. }
  344. static bool onButtonClick_CallNurseButton(ZKButton *pButton) {
  345. LOGD(" ButtonClick CallNurseButton !!!\n");
  346. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  347. int port = StoragePreferences::getInt(SIP_REG_PORT, SIP_REG_PORT_DEFAULT);
  348. std::string domain = StoragePreferences::getString(SIP_REG_DOMAIN, SIP_REG_DOMAIN_DEFAULT);
  349. std::string od_number = StoragePreferences::getString(SIP_REG_DOOR_ACCOUNT, SIP_REG_DOOR_ACCOUNT_DEFAULT);
  350. std::string od_number_uri = URI(od_number, domain, port);
  351. LOGD("od_number_uri: %s", od_number_uri.c_str());
  352. GetTelephone()->MakeCall(od_number_uri);
  353. } else {
  354. Intent* intent = new Intent();
  355. intent->putExtra(callActivityType, "fromCall");
  356. // intent->putExtra(callRoleType, "NURSE");
  357. EASYUICONTEXT->openActivity("callActivity", intent);
  358. }
  359. return false;
  360. }
  361. static bool onButtonClick_CallCancelButton(ZKButton *pButton) {
  362. LOGD(" ButtonClick CallCancelButton !!!\n");
  363. sendCallByDoor();
  364. return false;
  365. }
  366. static bool onButtonClick_NursingButton(ZKButton *pButton) {
  367. LOGD(" ButtonClick NursingButton !!!\n");
  368. if (!isNursing2) {
  369. Intent* intent = new Intent();
  370. intent->putExtra(functionWindows, "nursing2");
  371. EASYUICONTEXT->openActivity("functionActivity", intent);
  372. }
  373. else {
  374. Intent* intent = new Intent();
  375. intent->putExtra(functionWindows, "nursingEnd2");
  376. EASYUICONTEXT->openActivity("functionActivity", intent);
  377. }
  378. return false;
  379. }
  380. static bool onButtonClick_BlueCodeButton(ZKButton *pButton) {
  381. LOGD(" ButtonClick BlueCodeButton !!!\n");
  382. sendBlueCodeCall();
  383. mBlueCodeButtonPtr->setInvalid(true);
  384. std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
  385. if (color == "010") {
  386. lightControl("DOORLED", "002F");
  387. }
  388. else {
  389. lightControl("DOORLED", "020F");
  390. }
  391. Intent* intent = new Intent();
  392. intent->putExtra(functionWindows, "blueCode");
  393. EASYUICONTEXT->openActivity("functionActivity", intent);
  394. return false;
  395. }
  396. static bool onButtonClick_NfcLogoutButton(ZKButton *pButton) {
  397. LOGD(" ButtonClick NfcLogoutButton !!!\n");
  398. Intent* intent = new Intent();
  399. intent->putExtra(functionWindows, "navibarLogout");
  400. EASYUICONTEXT->openActivity("functionActivity", intent);
  401. return false;
  402. }