navibar.cc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. sendNursing();
  118. // 把护理状态缓存起来
  119. StoragePreferences::putBool(STORE_NURSING_TYPE, true);
  120. }
  121. else {
  122. setNursingBg(setNursing);
  123. lightControl("DOORLED", "000F");
  124. setNursingEnd();
  125. if (blueCodeId != 0) {
  126. sendBlueCodeResponse(blueCodeTid, to_string(blueCodeId));
  127. blueCodeId = 0;
  128. blueCodeTid = "";
  129. }
  130. }
  131. }
  132. //void callBedButtonSetVisible() {
  133. // if (mnavibarPtr == NULL) {
  134. // return;
  135. // }
  136. //
  137. // int roomCallBed = StoragePreferences::getInt(STORE_ROOM_CALL_BED, 1);
  138. // if (!roomCallBed) {
  139. // // 如果roomCallBed是0的话,那就隐藏
  140. // mCallBedButtonPtr->setVisible(roomCallBed);
  141. // mCallBedPicPainterPtr->setVisible(roomCallBed);
  142. //
  143. // mHelpButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96));
  144. // mHelpPicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27));
  145. // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 482, 96, 96));
  146. // mCallNursePicPainterPtr->setPosition(LayoutPosition(45, 504, 29, 27));
  147. //
  148. // }
  149. // else {
  150. // // 如果roomCallBed是1的话,那就显示
  151. // mCallBedButtonPtr->setVisible(roomCallBed);
  152. // mCallBedPicPainterPtr->setVisible(roomCallBed);
  153. //
  154. // mHelpButtonPtr->setPosition(LayoutPosition(11, 265, 96, 96));
  155. // mHelpPicPainterPtr->setPosition(LayoutPosition(43, 287, 32, 26));
  156. // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96));
  157. // mCallNursePicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27));
  158. // }
  159. //}
  160. void setBlueCodeId(int id, string tid) {
  161. blueCodeId = id;
  162. blueCodeTid = tid;
  163. }
  164. void navibarNfcLogout() {
  165. hasClerk = false;
  166. clerkNfc = "";
  167. sendAuthLogout(to_string(getAuthItId()));
  168. mNfcLogoutButtonPtr->setVisible(false);
  169. }
  170. void navibarNfcLogin(std::string revStr) {
  171. if (hasClerk) {
  172. if (clerkNfc == revStr) {
  173. navibarNfcLogout();
  174. Intent* intent = new Intent();
  175. intent->putExtra(functionWindows, "success");
  176. intent->putExtra(functionText, LANGUAGEMANAGER->getValue("NfcLogoutSuccess"));
  177. EASYUICONTEXT->openActivity("functionActivity", intent);
  178. return;
  179. }
  180. navibarNfcLogout();
  181. }
  182. bool reslut = getClerkByPartIdAndPassNo(revStr);
  183. if (reslut) {
  184. hasClerk = true;
  185. clerkNfc = revStr;
  186. sendAuthLogin(clerkNfc);
  187. sendSignIn(clerkNfc);
  188. sendPostionStart(clerkNfc);
  189. mNfcLogoutButtonPtr->setVisible(true);
  190. Intent* intent = new Intent();
  191. intent->putExtra(functionWindows, "success");
  192. intent->putExtra(functionText, LANGUAGEMANAGER->getValue("NfcLoginSuccess"));
  193. EASYUICONTEXT->openActivity("functionActivity", intent);
  194. }
  195. else {
  196. Intent* intent = new Intent();
  197. intent->putExtra(functionWindows, "warn");
  198. intent->putExtra(warnText, LANGUAGEMANAGER->getValue("PassNoError"));
  199. EASYUICONTEXT->openActivity("functionActivity", intent);
  200. }
  201. }
  202. /**
  203. * 注册定时器
  204. * 填充数组用于注册定时器
  205. * 注意:id不能重复
  206. */
  207. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  208. //{0, 6000}, //定时器id=0, 时间间隔6秒
  209. //{1, 1000},
  210. };
  211. /**
  212. * 当界面构造时触发
  213. */
  214. static void onUI_init(){
  215. //Tips :添加 UI初始化的显示代码到这里,如:mText1->setText("123");
  216. // callBedButtonSetVisible();
  217. setNavibarTheme();
  218. setNursingBg(isNursing2);
  219. }
  220. /*
  221. * 当界面完全退出时触发
  222. */
  223. static void onUI_quit() {
  224. }
  225. /**
  226. * 串口数据回调接口
  227. */
  228. static void onProtocolDataUpdate(const SProtocolData &data) {
  229. //串口数据回调接口
  230. }
  231. /**
  232. * 定时器触发函数
  233. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  234. * 参数: id
  235. * 当前所触发定时器的id,与注册时的id相同
  236. * 返回值: true
  237. * 继续运行当前定时器
  238. * false
  239. * 停止运行当前定时器
  240. */
  241. static bool onUI_Timer(int id){
  242. switch (id) {
  243. default:
  244. break;
  245. }
  246. return true;
  247. }
  248. /**
  249. * 有新的触摸事件时触发
  250. * 参数:ev
  251. * 新的触摸事件
  252. * 返回值:true
  253. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  254. * false
  255. * 触摸事件将继续传递到控件上
  256. */
  257. static bool onnavibarActivityTouchEvent(const MotionEvent &ev) {
  258. switch (ev.mActionStatus) {
  259. case MotionEvent::E_ACTION_DOWN://触摸按下
  260. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  261. break;
  262. case MotionEvent::E_ACTION_MOVE://触摸滑动
  263. break;
  264. case MotionEvent::E_ACTION_UP: //触摸抬起
  265. break;
  266. default:
  267. break;
  268. }
  269. return false;
  270. }
  271. static bool onButtonClick_HomeButton(ZKButton *pButton) {
  272. LOGD(" ButtonClick HomeButton !!!\n");
  273. // if (getAuthItId() != 0) {
  274. // Intent* intent = new Intent();
  275. // intent->putExtra(functionWindows, "logoutMedicalCare");
  276. // intent->putExtra(goActivity, "home");
  277. // EASYUICONTEXT->openActivity("functionActivity", intent);
  278. // } else {
  279. // goHome();
  280. // }
  281. goHome();
  282. return false;
  283. }
  284. static bool onButtonClick_HealthCareButton(ZKButton *pButton) {
  285. LOGD(" ButtonClick HealthCareButton !!!\n");
  286. goCare();
  287. return false;
  288. }
  289. static bool onButtonClick_MoreButton(ZKButton *pButton) {
  290. LOGD(" ButtonClick MoreButton !!!\n");
  291. // if (getAuthItId() != 0) {
  292. // Intent* intent = new Intent();
  293. // intent->putExtra(functionWindows, "logoutMedicalCare");
  294. // intent->putExtra(goActivity, "more");
  295. // EASYUICONTEXT->openActivity("functionActivity", intent);
  296. // } else {
  297. // goMore();
  298. // }
  299. goMore();
  300. return false;
  301. }
  302. static bool onButtonClick_HelpButton(ZKButton *pButton) {
  303. LOGD(" ButtonClick HelpButton !!!\n");
  304. sendReinforceCall();
  305. Intent* intent = new Intent();
  306. intent->putExtra(functionWindows, "help");
  307. EASYUICONTEXT->openActivity("functionActivity", intent);
  308. return false;
  309. }
  310. static bool onButtonClick_CallNurseButton(ZKButton *pButton) {
  311. LOGD(" ButtonClick CallNurseButton !!!\n");
  312. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  313. int port = StoragePreferences::getInt(SIP_REG_PORT, SIP_REG_PORT_DEFAULT);
  314. std::string domain = StoragePreferences::getString(SIP_REG_DOMAIN, SIP_REG_DOMAIN_DEFAULT);
  315. std::string od_number = StoragePreferences::getString(SIP_REG_DOOR_ACCOUNT, SIP_REG_DOOR_ACCOUNT_DEFAULT);
  316. std::string od_number_uri = URI(od_number, domain, port);
  317. LOGD("od_number_uri: %s", od_number_uri.c_str());
  318. GetTelephone()->MakeCall(od_number_uri);
  319. } else {
  320. Intent* intent = new Intent();
  321. intent->putExtra(isOutgoing, "true");
  322. EASYUICONTEXT->openActivity("callActivity", intent);
  323. }
  324. return false;
  325. }
  326. static bool onButtonClick_CallCancelButton(ZKButton *pButton) {
  327. LOGD(" ButtonClick CallCancelButton !!!\n");
  328. sendCallByDoor();
  329. return false;
  330. }
  331. static bool onButtonClick_NursingButton(ZKButton *pButton) {
  332. LOGD(" ButtonClick NursingButton !!!\n");
  333. if (!isNursing2) {
  334. Intent* intent = new Intent();
  335. intent->putExtra(functionWindows, "nursing2");
  336. EASYUICONTEXT->openActivity("functionActivity", intent);
  337. }
  338. else {
  339. Intent* intent = new Intent();
  340. intent->putExtra(functionWindows, "nursingEnd2");
  341. EASYUICONTEXT->openActivity("functionActivity", intent);
  342. }
  343. return false;
  344. }
  345. static bool onButtonClick_BlueCodeButton(ZKButton *pButton) {
  346. LOGD(" ButtonClick BlueCodeButton !!!\n");
  347. sendBlueCodeCall();
  348. mBlueCodeButtonPtr->setInvalid(true);
  349. lightControl("DOORLED", "001F");
  350. Intent* intent = new Intent();
  351. intent->putExtra(functionWindows, "blueCode");
  352. EASYUICONTEXT->openActivity("functionActivity", intent);
  353. return false;
  354. }
  355. static bool onButtonClick_NfcLogoutButton(ZKButton *pButton) {
  356. LOGD(" ButtonClick NfcLogoutButton !!!\n");
  357. Intent* intent = new Intent();
  358. intent->putExtra(functionWindows, "navibarLogout");
  359. EASYUICONTEXT->openActivity("functionActivity", intent);
  360. return false;
  361. }