mainLogic.cc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include "net/NetManager.h"
  4. #include "storage/StoragePreferences.h"
  5. #include "net/net.h"
  6. #include <system/Thread.h>
  7. #include "restclient-cpp/restclient.h"
  8. #include "curl/curl.h"
  9. #include <algorithm>
  10. #include "service/BusinessConfig.h"
  11. #include "core/sip_config.h"
  12. #include "manager/LanguageManager.h"
  13. #include "base/strings.hpp"
  14. #include "base/http_client.h"
  15. #include "os/UpgradeMonitor.h"
  16. #include "core/jhws.h"
  17. #include "core/update_assistant.h"
  18. #include "utils/TimeHelper.h"
  19. #define ETHERNETMANAGER NETMANAGER->getEthernetManager()
  20. /*
  21. *此文件由GUI工具生成
  22. *文件功能:用于处理用户的逻辑相应代码
  23. *功能说明:
  24. *========================onButtonClick_XXXX
  25. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称,
  26. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  27. *========================onSlideWindowItemClick_XXXX(int index)
  28. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  29. 如slideWindow1;index 代表按下图标的偏移值
  30. *========================onSeekBarChange_XXXX(int progress)
  31. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  32. 如SeekBar1;progress 代表当前的进度值
  33. *========================ogetListItemCount_XXXX()
  34. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称,
  35. 如List1;返回值为当前列表的总条数
  36. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  37. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称,
  38. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  39. *========================常用接口===============
  40. *LOGD(...) 打印调试信息的接口
  41. *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字****
  42. *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  43. *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12
  44. *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  45. *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  46. *
  47. * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示
  48. */
  49. static bool dataInit = false; // false表示需要从数据库里获取数据,true表示从缓存里获取数据
  50. PartSetting partSetting;
  51. Json::Value customerData;
  52. Json::Value nurseConfigOption;
  53. Json::Value frameInfo; // 缓存房间名字等
  54. Json::Value rightTitleInfo; // 缓存分机右边医生和护士标题
  55. Json::Value eventList; // 按键事件的缓存
  56. Json::Value customerFeeList; // 费用的缓存
  57. Json::Value customerAdviceList; // 医嘱的缓存
  58. bool hasNurseConfigOption = false;
  59. static bool reinforce = false; // 判断设备是否处于增援状态
  60. static bool serverInfo = true; // 判断是否需要从服务器获取服务器信息,第一次要,后续不要
  61. static int nurseConfigNumber = 5; // 护理项的数量,用于左侧显示,最少为5个,最多不限
  62. TcpModel nursingTcpModel;
  63. static int customerFeePageNo = 1;
  64. static int customerFeePageSize = 3;
  65. static int customerFeeDataTotal = 0;
  66. static int customerAdvicePageNo = 1;
  67. static int customerAdvicePageSize = 2;
  68. static int customerAdviceDataTotal = 0;
  69. #define STORE_NURSING_TYPE "nursing_type" // 护理的状态,如果是true,那就在护理中,如果是false,那就不在护理中
  70. #define NURSING_TIME_HANDLE 6 // 护理的定时器id
  71. #define OXYGEN_TIME_HANDLE 7 // 吸氧倒计时
  72. #define EVENT_TIME_HANDLE 8 // 事件定时器
  73. //======================================= udp 请示服务器信息
  74. static net::Conn* udpConn;
  75. class UdpThread: public Thread {
  76. public:
  77. static void getServerInfo(){
  78. string url = getHttpGateway() + "/ncs_url/server_info";
  79. LOGD("请求服务器信息. url = %s", url.c_str());
  80. //发起HTTP GET请求
  81. RestClient::Response r = RestClient::get(url);
  82. //解析json
  83. Json::Reader reader;
  84. Json::Value root;
  85. if (reader.parse(r.body, root, false)){
  86. // http
  87. StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
  88. StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
  89. // tcp
  90. StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
  91. StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
  92. // sip
  93. StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
  94. StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
  95. serverInfo = false; // 只有请求成功了,才不需要重复请求
  96. }
  97. }
  98. static void getDeviceInfo(){
  99. if (dataInit){
  100. getCustomerInfo(StoragePreferences::getString(STORE_CUSTOMER_ID, ""));
  101. getFrameInfo();
  102. getRightTitle();
  103. //getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
  104. reinforceDispaly();
  105. return;
  106. }
  107. string url = getHttpGateway()+"/deviceBed/getBedDeviceInfoByEthMac/"+ETHERNETMANAGER->getMacAddr();
  108. LOGD("请求设备信息. url = %s", url.c_str());
  109. //发起HTTP GET请求
  110. RestClient::Response r = RestClient::get(url);
  111. LOGD("获得设备信息. result = %s", r.body.c_str());
  112. //解析json
  113. Json::Reader reader;
  114. Json::Value root;
  115. if (reader.parse(r.body, root, false)){
  116. string partName = root["part_display"].asString();
  117. StoragePreferences::putString(STORE_PARTNAME,partName);
  118. NavibarSetPartName(partName);
  119. //设备
  120. StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
  121. StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
  122. //SIP存储
  123. // StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString()); // 应该去找配置文件里的sip-ip
  124. StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
  125. StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
  126. if (root["customer_id"] != NULL && root["customer_id"].asString() != "") {
  127. string customerId = root["customer_id"].asString();
  128. StoragePreferences::putString(STORE_CUSTOMER_ID, customerId);
  129. //获取病患信息
  130. getCustomerInfo(customerId);
  131. }
  132. //获取科室设置
  133. string partId = root["part_id"].asString();
  134. StoragePreferences::putString(STORE_PARTID, partId);
  135. getPartSetting(partId);
  136. getVersion();
  137. setFrameInfo(root);
  138. }
  139. }
  140. // 将空间相关的数据缓存起来
  141. static void setFrameInfo(Json::Value deviceInfo) {
  142. frameInfo["frame_id"] = deviceInfo["frame_id"].asInt();
  143. frameInfo["full_name"] = deviceInfo["full_name"].asString();
  144. frameInfo["part_id"] = deviceInfo["part_id"].asInt();
  145. getFrameInfo();
  146. }
  147. // 读取空间缓存的数据
  148. static void getFrameInfo() {
  149. mRoomNamePtr->setText(frameInfo["full_name"].asString());
  150. }
  151. // 通过https获取用户的数据,并且放进缓存里
  152. static void getCustomerInfo(string customerId){
  153. if (dataInit){
  154. settingCustomer(customerData);
  155. return;
  156. }
  157. string url = getHttpGateway()+"/deviceBed/getCustomerInfo/" + customerId;
  158. LOGD("请求用户信息. url = %s", url.c_str());
  159. //发起HTTP GET请求
  160. RestClient::Response r = RestClient::get(url);
  161. LOGD("获得用户信息. result = %s", r.body.c_str());
  162. //解析json
  163. Json::Reader reader;
  164. Json::Value root;
  165. if (reader.parse(r.body, root, false)){
  166. customerData = root;
  167. settingCustomer(root);
  168. }
  169. }
  170. // 读取用户的缓存数据
  171. static void settingCustomer(Json::Value root){
  172. // mUserNamePtr->setText(root["named"].asString());
  173. // string sex = root["sex"].asInt()==0?"女":"男";
  174. // mSexAgePtr->setText(sex+" "+root["age"].asString()+root["age_unit"].asString());
  175. string inDate = root["in_date"].asString();
  176. time_t timet = stoi(inDate);
  177. struct tm *t = gmtime(&timet);
  178. char pDate[25];
  179. sprintf(pDate,"%d-%02d-%02d",
  180. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday);
  181. // if (root["illness_desc"].asString()==""){
  182. // mAdvicePtr->setTextTr("Null");
  183. // } else {
  184. // mAdvicePtr->setText(root["illness_desc"].asString());
  185. // }
  186. //护理项
  187. if (root["list"].isArray() && root["list"].size()>0){
  188. hasNurseConfigOption = true;
  189. nurseConfigOption = root["list"];
  190. nurseConfigNumber = root["list"].size();
  191. }
  192. }
  193. static void getPartSetting(string partId){
  194. string url = getHttpGateway()+"/deviceBed/getPartSetting/"+partId;
  195. LOGD("请求科室信息. url = %s", url.c_str());
  196. //发起HTTP GET请求
  197. RestClient::Response r = RestClient::get(url);
  198. LOGD("获得科室信息. result = %s", r.body.c_str());
  199. //解析json
  200. Json::Reader reader;
  201. Json::Value root;
  202. if (reader.parse(r.body, root, false)){
  203. partSetting.partId = root["part_id"].asInt();
  204. partSetting.dayStart = root["day_start"].asString();
  205. partSetting.dayLight = root["day_light"].asInt();
  206. partSetting.dayVol = root["day_vol"].asInt();
  207. partSetting.dayRingVol = root["day_ring_vol"].asInt();
  208. partSetting.dayRingTimes = root["day_ring_times"].asInt();
  209. partSetting.dayNurseLed = root["day_nurse_led"].asInt();
  210. partSetting.dayDoorVol = root["day_door_vol"].asInt();
  211. partSetting.dayBedVol = root["day_bed_vol"].asInt();
  212. partSetting.dayTransferBoxVol = root["day_transfer_box_vol"].asInt();
  213. partSetting.dayTransferBoxSystemVol = root["day_transfer_box_system_vol"].asInt();
  214. partSetting.nightStart = root["night_start"].asString();
  215. partSetting.nightLight = root["night_light"].asInt();
  216. partSetting.nightVol = root["night_vol"].asInt();
  217. partSetting.nightRingVol = root["night_ring_vol"].asInt();
  218. partSetting.nightRingTimes = root["night_ring_times"].asInt();
  219. partSetting.nightNurseLed = root["night_nurse_led"].asInt();
  220. partSetting.nightDoorVol = root["night_door_vol"].asInt();
  221. partSetting.nightBedVol = root["night_bed_vol"].asInt();
  222. partSetting.nightTransferBoxVol = root["night_transfer_box_vol"].asInt();
  223. partSetting.nightTransferBoxSystemVol = root["night_transfer_box_system_vol"].asInt();
  224. partSetting.sleepSecondsNurse = root["sleep_seconds_nurse"].asInt();
  225. partSetting.sleepSecondsDoor = root["sleep_seconds_door"].asInt();
  226. partSetting.sleepSecondsBed = root["sleep_seconds_bed"].asInt();
  227. partSetting.sipOvertime = root["sip_overtime"].asInt();
  228. partSetting.transferDuration = root["transfer_duration"].asInt();
  229. partSetting.transferDurationLeader = root["transfer_duration_leader"].asInt();
  230. partSetting.communicationModeBed = root["communication_mode_bed"].asInt();
  231. partSetting.communicationModeNurse = root["communication_mode_nurse"].asInt();
  232. partSetting.communicationModeMobile = root["communication_model_mobile"].asInt();
  233. partSetting.customizeRoleCallFirst = root["customize_role_call_first"].asInt();
  234. partSetting.customizeRoleCallSecond = root["customize_role_call_second"].asInt();
  235. partSetting.customizeRoleCallThird = root["customize_role_call_third"].asInt();
  236. partSetting.customizeRoleCallFourth = root["customize_role_call_fourth"].asInt();
  237. partSetting.customizeRoleCallFifth = root["customize_role_call_fifth"].asInt();
  238. partSetting.customizeHospitalCallFirst = root["customize_hospital_call_first"].asInt();
  239. partSetting.customizeHospitalCallFirstName = root["customize_hospital_call_first_name"].asString();
  240. partSetting.customizeHospitalCallSecond = root["customize_hospital_call_second"].asInt();
  241. partSetting.customizeHospitalCallSecondName = root["customize_hospital_second_name"].asString();
  242. partSetting.customizeHospitalCallThird = root["customize_hospital_call_third"].asInt();
  243. partSetting.customizeHospitalCallThirdName = root["customize_hospital_call_third_name"].asString();
  244. partSetting.doctorTitle = root["doctor_title"].asString();
  245. partSetting.doctorValid = root["doctor_valid"].asInt();
  246. partSetting.nurseTitle = root["nurse_title"].asString();
  247. partSetting.nurseValid = root["nurse_valid"].asInt();
  248. partSetting.doorNurseTitle = root["door_nurse_title"].asString();
  249. partSetting.doorNurseValid = root["door_nurse_valid"].asInt();
  250. partSetting.doorNursingTitle = root["door_nursing_title"].asString();
  251. partSetting.doorNursingValid = root["door_nursing_valid"].asInt();
  252. partSetting.upSeconds = root["up_seconds"].asInt();
  253. partSetting.autoAccept = root["auto_accept"].asInt();
  254. partSetting.eventForward = root["event_forward"].asInt();
  255. partSetting.nursingColorRgb = root["nursing_color_rgb"].asString();
  256. partSetting.twoColorDoorLightValid = root["two_color_door_light_valid"].asInt();
  257. partSetting.qrUrl = root["qr_url"].asString();
  258. StoragePreferences::putString(STORE_DAY_START, partSetting.dayStart);
  259. StoragePreferences::putInt(STORE_DAY_LIGHT,partSetting.dayLight);
  260. StoragePreferences::putInt(STORE_DAY_VOL,partSetting.dayBedVol);
  261. StoragePreferences::putInt(STORE_DAY_RING_TIMES,partSetting.dayRingTimes);
  262. StoragePreferences::putString(STORE_NIGHT_START, partSetting.nightStart);
  263. StoragePreferences::putInt(STORE_NIGHT_LIGHT,partSetting.nightLight);
  264. StoragePreferences::putInt(STORE_NIGHT_VOL,partSetting.nightBedVol);
  265. StoragePreferences::putInt(STORE_NIGHT_RING_TIMES,partSetting.nightRingTimes);
  266. StoragePreferences::putInt(STORE_SLEEP_TIME, partSetting.sleepSecondsBed);
  267. StoragePreferences::putString(STORE_DOCTOR_TITLE, partSetting.doctorTitle);
  268. StoragePreferences::putBool(STORE_DOCTOR_VISIBLE, partSetting.doctorValid==1);
  269. StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
  270. StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
  271. StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
  272. setRightTitle(root);
  273. dataInit = true;
  274. }
  275. }
  276. // 将医生和护士别称缓存起来
  277. static void setRightTitle(Json::Value partSetting) {
  278. rightTitleInfo["doctor_title"] = partSetting["doctor_title"].asString();
  279. rightTitleInfo["doctor_valid"] = partSetting["doctor_valid"].asInt();
  280. rightTitleInfo["nurse_title"] = partSetting["nurse_title"].asString();
  281. rightTitleInfo["nurse_valid"] = partSetting["nurse_valid"].asInt();
  282. getRightTitle();
  283. }
  284. static void getRightTitle() {
  285. }
  286. static void getVersion() {
  287. std::string url = getHttpGateway() + "/deviceBed/getAppVersion?device_type=304&part_id=" + StoragePreferences::getString(STORE_PARTID, "");
  288. std::string content_type = std::string("application/json");
  289. LOGD("请求版本信息. url = %s", url.c_str());
  290. //发起HTTP POST请求
  291. RestClient::Response r = RestClient::post(url, content_type, "");
  292. if (r.code != 200) {
  293. LOGD("请求版本信息-> 错误代码: %d", r.code);
  294. return;
  295. }
  296. LOGD("获得版本信息. result = %s", r.body.c_str());
  297. //解析json
  298. Json::Reader reader;
  299. Json::Value root;
  300. if(reader.parse(r.body, root, false)) {
  301. int currentVersionNo = getVersionNo();
  302. int responseVersionNo = root["version_no"].asInt();
  303. std::string responseVersion = root["version_code"].asString();
  304. LOGD("服务器版本 : %s %d, 当前设备版本: %d", responseVersion.c_str(), responseVersionNo, currentVersionNo);
  305. if (currentVersionNo < responseVersionNo) {
  306. Intent* intent = new Intent();
  307. intent->putExtra(appUpdate, "true");
  308. EASYUICONTEXT->openActivity("DeviceUpdateActivity", intent);
  309. }
  310. }
  311. }
  312. // 判断是否处于增援状态,处于增援状态,就要显示蓝色
  313. static void reinforceDispaly() {
  314. if (reinforce) {
  315. SetPainterInfo(0xFF2F9DF1,"增援已发出");
  316. }
  317. }
  318. /**
  319. * 线程创建成功后会调用该函数,可以在该函数中做一些初始化操作
  320. * return true 继续线程
  321. * false 退出线程
  322. */
  323. virtual bool readyToRun() {
  324. LOGD("Thread 已经创建完成");
  325. return true;
  326. }
  327. /**
  328. * 线程循环函数
  329. *
  330. * return true 继续线程循环
  331. * false 推出线程
  332. */
  333. virtual bool threadLoop() {
  334. LOGD("线程循环函数");
  335. //检查是否有退出线程的请求,如果有,则返回false,立即退出线程
  336. if (exitPending()) {
  337. return false;
  338. }
  339. udpConn = net::Dial("udp", "192.168.1.255:10010");
  340. if (udpConn) {
  341. byte buf[1024] = {0};
  342. const char* req = "search_server";
  343. //发送
  344. udpConn->Write((byte*)req, strlen(req));
  345. while (true && !exitPending()) {
  346. //读取,超时10*1000毫秒
  347. int n = udpConn->Read(buf, sizeof(buf) - 1, 10*1000);
  348. if (n > 0) {
  349. buf[n] = 0;
  350. char serverStr[1024];
  351. sprintf(serverStr,"%s",buf);
  352. LOGD("读取 %d字节: %s", n, serverStr);
  353. //解析json
  354. Json::Reader reader;
  355. Json::Value root;
  356. if (reader.parse(serverStr, root, false)){
  357. if (root.isMember("success") && root["success"].asBool()){
  358. serverIP = root["data"]["third_server"].asString();
  359. serverHttpPort = root["data"]["third_server_port"].asInt();
  360. StoragePreferences::putString(STORE_GATEWAY, serverIP);
  361. StoragePreferences::putInt(STORE_HTTP_PORT, serverHttpPort);
  362. //先获取服务器信息
  363. //getServerInfo();
  364. //就当在获取服务器信息完成后获取用户信息,这里测试用
  365. //getCustomerInfo();
  366. //退出UDP线程
  367. pthread_exit(NULL);
  368. break;
  369. }
  370. }
  371. } else if (n == 0) {
  372. LOGD("连接正常断开");
  373. break;
  374. } else if (n == net::E_TIMEOUT) {
  375. udpConn->Write((byte*)req, strlen(req));
  376. LOGD("读取超时");
  377. } else {
  378. LOGD("出错");
  379. break;
  380. }
  381. }
  382. //关闭连接
  383. udpConn->Close();
  384. //释放内存
  385. delete udpConn;
  386. udpConn = NULL;
  387. }
  388. //返回真,继续下次线程循环
  389. return true;
  390. }
  391. };
  392. static UdpThread udp_thread;
  393. void setReinforce(bool result) {
  394. reinforce = result;
  395. }
  396. //标识方法
  397. void SetPainterInfo(uint32_t bgColor, const std::string& msg){
  398. mPainterInfoPtr->setBackgroundColor(bgColor);
  399. mTextInfoPtr->setText(msg);
  400. if (bgColor == 0xFFFFFFFF){
  401. mRoomNamePtr->setTextColor(0x00AAF4);
  402. } else {
  403. mRoomNamePtr->setTextColor(0xFFFFFF);
  404. }
  405. }
  406. // 收到tcp的时候,刷新数据
  407. void dataRefresh() {
  408. LOGD("DATA-REFRESH, 数据刷新");
  409. dataInit = false;
  410. udp_thread.getDeviceInfo();
  411. }
  412. void getPartSetting() {
  413. udp_thread.getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
  414. }
  415. // 处理护理的tcpModel
  416. void setNursingTcpModel(TcpModel tcpModel) {
  417. LOGD("缓存Nursing的tcpModel !!!");
  418. nursingTcpModel = tcpModel;
  419. }
  420. /**
  421. * 注册定时器
  422. * 填充数组用于注册定时器
  423. * 注意:id不能重复
  424. */
  425. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  426. //{0, 6000}, //定时器id=0, 时间间隔6秒
  427. //{1, 1000},
  428. };
  429. /**
  430. * 当界面构造时触发
  431. */
  432. static void onUI_init(){
  433. //udp_thread.run("this is thread name");
  434. //测试用
  435. LOGD("进入mainLogic页面, 触发 onUI_init");
  436. if(serverInfo) { // 如果是false,就是不需要
  437. udp_thread.getServerInfo();
  438. }
  439. udp_thread.getDeviceInfo();
  440. }
  441. /**
  442. * 当切换到该界面时触发
  443. */
  444. static void onUI_intent(const Intent *intentPtr) {
  445. if (intentPtr != NULL) {
  446. }
  447. }
  448. /*
  449. * 当界面显示时触发
  450. */
  451. static void onUI_show() {
  452. }
  453. /*
  454. * 当界面隐藏时触发
  455. */
  456. static void onUI_hide() {
  457. }
  458. /*
  459. * 当界面完全退出时触发
  460. */
  461. static void onUI_quit() {
  462. //pthread_exit(NULL);
  463. }
  464. /**
  465. * 串口数据回调接口
  466. */
  467. static void onProtocolDataUpdate(const SProtocolData &data) {
  468. }
  469. /**
  470. * 定时器触发函数
  471. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  472. * 参数: id
  473. * 当前所触发定时器的id,与注册时的id相同
  474. * 返回值: true
  475. * 继续运行当前定时器
  476. * false
  477. * 停止运行当前定时器
  478. */
  479. static bool onUI_Timer(int id){
  480. switch (id) {
  481. default:
  482. break;
  483. }
  484. return true;
  485. }
  486. /**
  487. * 有新的触摸事件时触发
  488. * 参数:ev
  489. * 新的触摸事件
  490. * 返回值:true
  491. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  492. * false
  493. * 触摸事件将继续传递到控件上
  494. */
  495. static bool onmainActivityTouchEvent(const MotionEvent &ev) {
  496. switch (ev.mActionStatus) {
  497. case MotionEvent::E_ACTION_DOWN://触摸按下
  498. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  499. break;
  500. case MotionEvent::E_ACTION_MOVE://触摸滑动
  501. break;
  502. case MotionEvent::E_ACTION_UP: //触摸抬起
  503. break;
  504. default:
  505. break;
  506. }
  507. return false;
  508. }
  509. static int getListItemCount_BedListView(const ZKListView *pListView) {
  510. //LOGD("getListItemCount_BedListView !\n");
  511. return 3;
  512. }
  513. static void obtainListItemData_BedListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  514. //LOGD(" obtainListItemData_ BedListView !!!\n");
  515. }
  516. static void onListItemClick_BedListView(ZKListView *pListView, int index, int id) {
  517. //LOGD(" onListItemClick_ BedListView !!!\n");
  518. }
  519. static bool onButtonClick_CallBedButton(ZKButton *pButton) {
  520. LOGD(" ButtonClick CallBedButton !!!\n");
  521. return false;
  522. }
  523. static bool onButtonClick_CallNurseButton(ZKButton *pButton) {
  524. LOGD(" ButtonClick CallNurseButton !!!\n");
  525. return false;
  526. }
  527. static bool onButtonClick_HelpButton(ZKButton *pButton) {
  528. LOGD(" ButtonClick HelpButton !!!\n");
  529. return false;
  530. }
  531. static bool onButtonClick_CallCencelButton(ZKButton *pButton) {
  532. LOGD(" ButtonClick CallCencelButton !!!\n");
  533. return false;
  534. }
  535. static bool onButtonClick_NursingButton(ZKButton *pButton) {
  536. LOGD(" ButtonClick NursingButton !!!\n");
  537. EASYUICONTEXT->openActivity("ui3Activity");
  538. return false;
  539. }
  540. static bool onButtonClick_MoreButton(ZKButton *pButton) {
  541. LOGD(" ButtonClick MoreButton !!!\n");
  542. EASYUICONTEXT->openActivity("ui3Activity");
  543. return false;
  544. }