12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274 |
- #pragma once
- #include "uart/ProtocolSender.h"
- #include "net/NetManager.h"
- #include "storage/StoragePreferences.h"
- #include "net/net.h"
- #include <system/Thread.h>
- #include <sys/reboot.h>
- #include "restclient-cpp/restclient.h"
- #include "curl/curl.h"
- #include <algorithm>
- #include "service/BusinessConfig.h"
- #include "core/sip_config.h"
- #include "manager/LanguageManager.h"
- #include "core/utilities.h"
- #include <string>
- #include "zkaudio.h"
- #include "base/strings.hpp"
- #include "base/http_client.h"
- #include "os/UpgradeMonitor.h"
- #include "core/jhws.h"
- #include "core/update_assistant.h"
- #include "utils/TimeHelper.h"
- #define ETHERNETMANAGER NETMANAGER->getEthernetManager()
- #define WIFIMANAGER NETMANAGER->getWifiManager()
- /*
- *此文件由GUI工具生成
- *文件功能:用于处理用户的逻辑相应代码
- *功能说明:
- *========================onButtonClick_XXXX
- 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称,
- 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
- *========================onSlideWindowItemClick_XXXX(int index)
- 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
- 如slideWindow1;index 代表按下图标的偏移值
- *========================onSeekBarChange_XXXX(int progress)
- 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
- 如SeekBar1;progress 代表当前的进度值
- *========================ogetListItemCount_XXXX()
- 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称,
- 如List1;返回值为当前列表的总条数
- *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
- 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称,
- 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
- *========================常用接口===============
- *LOGD(...) 打印调试信息的接口
- *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字****
- *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
- *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12
- *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
- *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
- *
- * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示
- */
- TcpModel nursingTcpModel;
- static bool dataInit = false; // false表示需要从数据库里获取数据,true表示从缓存里获取数据
- PartSetting partSetting;
- Json::Value frameRoom;
- Json::Value frameBedList;
- Json::Value frameInfo; // 缓存房间名字等
- Json::Value rightTitleInfo; // 缓存分机右边医生和护士标题
- Json::Value painterInfo;
- Json::Value painterInfoList;
- static bool reinforce = false; // 判断设备是否处于增援状态
- static bool serverInfo = true; // 判断是否需要从服务器获取服务器信息,第一次要,后续不要
- static bool isHelpTimerRegistered = false;
- static std::string cencalByDoorTid = "";
- #define HELP_TIMER_HANDLE 3 // 增援的定时器id
- #define EVENT_TIME_HANDLE 8 // 事件定时器
- #define SLEEP_STRAT_TIME_HANDLE 9 // 息屏
- static bool deviceRequest = false;
- static bool frameRequest = false;
- #define REQUEST_TIME_HANDLE 200 // 重新请求
- static void requestTimeHandle() {
- if (deviceRequest != frameRequest) {
- LOGD("启动定时任务,重新请求数据");
- mActivityPtr->registerUserTimer(REQUEST_TIME_HANDLE, 10 * 60 * 1000);
- }
- }
- static void getServerInfo(){
- string url = getHttpGateway() + "/ncs_url/server_info";
- LOGD("请求服务器信息. url = %s", url.c_str());
- //发起HTTP GET请求
- RestClient::Response r = RestClient::get(url);
- LOGD("请求服务器信息. result = %s", r.body.c_str());
- if (r.code != 200) {
- LOGD("请求服务器信息错误. 错误代码 = %d", r.code);
- string serverIP = StoragePreferences::getString(STORE_GATEWAY, "172.28.100.100");
- int serverPort = StoragePreferences::getInt(STORE_HTTP_PORT, 8006);
- LOGD("serverIP ===> %s", serverIP.c_str());
- LOGD("serverPort ===> %d", serverPort);
- if (!checkAddr(serverIP) || serverPort == 0) {
- // http
- StoragePreferences::putString(STORE_GATEWAY, "172.28.100.100");
- StoragePreferences::putInt(STORE_HTTP_PORT, 8006);
- //重启
- sync();
- reboot(RB_AUTOBOOT);
- }
- return;
- }
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- // http
- StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
- StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
- // tcp
- StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
- StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
- // sip
- StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
- StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
- serverInfo = false; // 只有请求成功了,才不需要重复请求
- }
- }
- // 读取空间缓存的数据
- static void getFrameInfo() {
- mRoomNamePtr->setText(frameInfo["full_name"].asString());
- }
- static void getFrameRoom(int frame_id) {
- string url = getHttpGateway() + "/deviceRoom/get_frame_room/" + to_string(frame_id);
- LOGD("请求房间信息. url = %s", url.c_str());
- RestClient::Response r = RestClient::get(url);
- //发起HTTP GET请求
- if (r.code != 200) {
- LOGD("请求房间信息错误. 错误代码 = %d", r.code);
- if (!frameRequest) {
- frameRequest = true;
- requestTimeHandle();
- }
- return;
- }
- LOGD("获得房间信息. result = %s", r.body.c_str());
- frameRequest = false;
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- frameRoom = root;
- frameBedList = root["frame_bed_list"];
- if (mBedListViewPtr != NULL) {
- mBedListViewPtr->refreshListView();
- }
- }
- }
- static void callBedButtonSetVisible() {
- int roomCallBed = StoragePreferences::getInt(STORE_ROOM_CALL_BED, 1);
- if (!roomCallBed) {
- // 如果roomCallBed是0的话,那就隐藏
- mCallBedButtonPtr->setVisible(roomCallBed);
- mCallNurseButtonPtr->setPosition(LayoutPosition(869, 160, 140, 55));
- mCallCencelButtonPtr->setPosition(LayoutPosition(869, 241, 140, 55));
- mHelpButtonPtr->setPosition(LayoutPosition(869, 323, 140, 55));
- mNursingButtonPtr->setPosition(LayoutPosition(869, 404, 140, 55));
- mMoreButtonPtr->setPosition(LayoutPosition(869, 485, 140, 55));
- }
- else {
- // 如果roomCallBed是1的话,那就显示
- mCallBedButtonPtr->setVisible(roomCallBed);
- mCallNurseButtonPtr->setPosition(LayoutPosition(869, 185, 140, 55));
- mCallCencelButtonPtr->setPosition(LayoutPosition(869, 260, 140, 55));
- mHelpButtonPtr->setPosition(LayoutPosition(869, 335, 140, 55));
- mNursingButtonPtr->setPosition(LayoutPosition(869, 410, 140, 55));
- mMoreButtonPtr->setPosition(LayoutPosition(869, 485, 140, 55));
- }
- }
- // 将医生和护士别称缓存起来
- static void setRightTitle(Json::Value partSetting) {
- rightTitleInfo["doctor_title"] = partSetting["doctor_title"].asString();
- rightTitleInfo["doctor_valid"] = partSetting["doctor_valid"].asInt();
- rightTitleInfo["nurse_title"] = partSetting["nurse_title"].asString();
- rightTitleInfo["nurse_valid"] = partSetting["nurse_valid"].asInt();
- }
- static void setDirectorAndHeadNurse() {
- mDirectorTextViewPtr->setText(partSetting.partDirector);
- mHeadNurseTextViewPtr->setText(partSetting.partNurseHead);
- }
- static void getVersion() {
- std::string url = getHttpGateway() + "/deviceRoom/get_app_version?device_type=303&part_id=" + StoragePreferences::getString(STORE_PARTID, "");
- std::string content_type = std::string("application/json");
- LOGD("请求版本信息. url = %s", url.c_str());
- //发起HTTP POST请求
- RestClient::Response r = RestClient::post(url, content_type, "");
- if (r.code != 200) {
- LOGD("请求版本信息-> 错误代码: %d", r.code);
- return;
- }
- LOGD("获得版本信息. result = %s", r.body.c_str());
- //解析json
- Json::Reader reader;
- Json::Value root;
- if(reader.parse(r.body, root, false)) {
- int currentVersionNo = getVersionNo();
- int responseVersionNo = root["version_no"].asInt();
- std::string responseVersion = root["version_code"].asString();
- LOGD("服务器版本 : %s %d, 当前设备版本: %d", responseVersion.c_str(), responseVersionNo, currentVersionNo);
- if (currentVersionNo < responseVersionNo) {
- Intent* intent = new Intent();
- intent->putExtra(appUpdate, "true");
- EASYUICONTEXT->openActivity("DeviceUpdateActivity", intent);
- }
- }
- }
- // 判断是否处于增援状态,处于增援状态,就要显示蓝色
- static void reinforceDispaly() {
- if (reinforce) {
- // SetPainterInfo(0xFF2F9DF1, "增援已发出");
- // setHelpButton("/button/button_help3.png" ,false);
- setPainterInfo(StoragePreferences::getInt(STORE_DEVICE_ID,0), 0xFF2F9DF1, LANGUAGEMANAGER->getValue("HelpInfo"), "REINFORCE", "ADD", 60);
- }
- }
- static void getTemplate() {
- int templateInt = StoragePreferences::getInt(STORE_TEMPLATE, 1);
- LOGD("templateInt =====> %d", templateInt);
- if (templateInt == 1) {
- mDirectorTextViewPtr->setVisible(false);
- mDirectorTitleTextViewPtr->setVisible(false);
- mHeadNurseTextViewPtr->setVisible(false);
- mHeadNurseTitleTextViewPtr->setVisible(false);
- mBedListViewPtr->setPosition(LayoutPosition(6, 90, 855, 465));
- }
- else if (templateInt == 2) {
- mDirectorTextViewPtr->setVisible(true);
- mDirectorTitleTextViewPtr->setVisible(true);
- mHeadNurseTextViewPtr->setVisible(true);
- mHeadNurseTitleTextViewPtr->setVisible(true);
- mBedListViewPtr->setPosition(LayoutPosition(6, 90, 855, 395));
- }
- else if (templateInt == 3) {
- mDirectorTextViewPtr->setVisible(false);
- mDirectorTitleTextViewPtr->setVisible(false);
- mHeadNurseTextViewPtr->setVisible(false);
- mHeadNurseTitleTextViewPtr->setVisible(false);
- mBedListViewPtr->setPosition(LayoutPosition(6, 90, 855, 465));
- }
- }
- void getTheme() {
- int themeInt = StoragePreferences::getInt(STORE_THEME, 1);
- LOGD("themeInt =====> %d", themeInt);
- if (themeInt == 1) {
- mMainBgPainterPtr->setBackgroundColor(color);
- }
- else if (themeInt == 2) {
- mMainBgPainterPtr->setBackgroundColor(color);
- }
- }
- static void getPartSetting(string partId){
- string url = getHttpGateway() + "/deviceBed/getPartSetting/" + partId;
- LOGD("请求科室信息. url = %s", url.c_str());
- //发起HTTP GET请求
- RestClient::Response r = RestClient::get(url);
- LOGD("获得科室信息. result = %s", r.body.c_str());
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- partSetting.partId = root["part_id"].asInt();
- partSetting.dayStart = root["day_start"].asString();
- partSetting.dayLight = root["day_light"].asInt();
- partSetting.dayVol = root["day_vol"].asInt();
- partSetting.dayRingVol = root["day_ring_vol"].asInt();
- partSetting.dayRingTimes = root["day_ring_times"].asInt();
- partSetting.dayNurseLed = root["day_nurse_led"].asInt();
- partSetting.dayDoorVol = root["day_door_vol"].asInt();
- partSetting.dayBedVol = root["day_bed_vol"].asInt();
- partSetting.dayTransferBoxVol = root["day_transfer_box_vol"].asInt();
- partSetting.dayTransferBoxSystemVol = root["day_transfer_box_system_vol"].asInt();
- partSetting.nightStart = root["night_start"].asString();
- partSetting.nightLight = root["night_light"].asInt();
- partSetting.nightVol = root["night_vol"].asInt();
- partSetting.nightRingVol = root["night_ring_vol"].asInt();
- partSetting.nightRingTimes = root["night_ring_times"].asInt();
- partSetting.nightNurseLed = root["night_nurse_led"].asInt();
- partSetting.nightDoorVol = root["night_door_vol"].asInt();
- partSetting.nightBedVol = root["night_bed_vol"].asInt();
- partSetting.nightTransferBoxVol = root["night_transfer_box_vol"].asInt();
- partSetting.nightTransferBoxSystemVol = root["night_transfer_box_system_vol"].asInt();
- partSetting.sleepSecondsNurse = root["sleep_seconds_nurse"].asInt();
- partSetting.sleepSecondsDoor = root["sleep_seconds_door"].asInt();
- partSetting.sleepSecondsBed = root["sleep_seconds_bed"].asInt();
- partSetting.sipOvertime = root["sip_overtime"].asInt();
- partSetting.transferDuration = root["transfer_duration"].asInt();
- partSetting.transferDurationLeader = root["transfer_duration_leader"].asInt();
- partSetting.communicationModeBed = root["communication_mode_bed"].asInt();
- partSetting.communicationModeNurse = root["communication_mode_nurse"].asInt();
- partSetting.communicationModeMobile = root["communication_model_mobile"].asInt();
- partSetting.customizeRoleCallFirst = root["customize_role_call_first"].asInt();
- partSetting.customizeRoleCallSecond = root["customize_role_call_second"].asInt();
- partSetting.customizeRoleCallThird = root["customize_role_call_third"].asInt();
- partSetting.customizeRoleCallFourth = root["customize_role_call_fourth"].asInt();
- partSetting.customizeRoleCallFifth = root["customize_role_call_fifth"].asInt();
- partSetting.customizeHospitalCallFirst = root["customize_hospital_call_first"].asInt();
- partSetting.customizeHospitalCallFirstName = root["customize_hospital_call_first_name"].asString();
- partSetting.customizeHospitalCallSecond = root["customize_hospital_call_second"].asInt();
- partSetting.customizeHospitalCallSecondName = root["customize_hospital_second_name"].asString();
- partSetting.customizeHospitalCallThird = root["customize_hospital_call_third"].asInt();
- partSetting.customizeHospitalCallThirdName = root["customize_hospital_call_third_name"].asString();
- partSetting.doctorTitle = root["doctor_title"].asString();
- partSetting.doctorValid = root["doctor_valid"].asInt();
- partSetting.nurseTitle = root["nurse_title"].asString();
- partSetting.nurseValid = root["nurse_valid"].asInt();
- partSetting.partDirector = root["part_director"].asString();
- partSetting.partNurseHead = root["part_nurse_head"].asString();
- partSetting.doorNurseTitle = root["door_nurse_title"].asString();
- partSetting.doorNurseValid = root["door_nurse_valid"].asInt();
- partSetting.doorNursingTitle = root["door_nursing_title"].asString();
- partSetting.doorNursingValid = root["door_nursing_valid"].asInt();
- partSetting.upSeconds = root["up_seconds"].asInt();
- partSetting.autoAccept = root["auto_accept"].asInt();
- partSetting.eventForward = root["event_forward"].asInt();
- partSetting.nursingColorRgb = root["nursing_color_rgb"].asString();
- partSetting.twoColorDoorLightValid = root["two_color_door_light_valid"].asInt();
- partSetting.qrUrl = root["qr_url"].asString();
- partSetting.screenLight = root["screen_light"].asInt();
- partSetting.roomCallBed = root["room_call_bed"].asInt();
- partSetting.customerAgeHiddenOnDoor = root["customer_age_hidden_on_door"].asInt();
- if (root["linux_door_volume_native"].size() != 0) {
- partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
- partSetting.linuxDoorGainSize = root["linux_door_gain_size"].asInt();
- zk_audio_input_set_volume_native(0, 0);
- zk_audio_input_set_volume_native(1, partSetting.linuxDoorVolumeNative);
- GetTelephone()->SetInputPcmGainSize(partSetting.linuxDoorGainSize);
- StoragePreferences::putInt(STORE_VOLUME_NATIVE, partSetting.linuxDoorVolumeNative);
- StoragePreferences::putInt(STORE_GAIN_SIZE, partSetting.linuxDoorGainSize);
- }
- StoragePreferences::putString(STORE_DAY_START, partSetting.dayStart);
- StoragePreferences::putInt(STORE_DAY_LIGHT,partSetting.dayLight);
- StoragePreferences::putInt(STORE_DAY_VOL,partSetting.dayBedVol);
- StoragePreferences::putInt(STORE_DAY_RING_TIMES,partSetting.dayRingTimes);
- StoragePreferences::putString(STORE_NIGHT_START, partSetting.nightStart);
- StoragePreferences::putInt(STORE_NIGHT_LIGHT,partSetting.nightLight);
- StoragePreferences::putInt(STORE_NIGHT_VOL,partSetting.nightBedVol);
- StoragePreferences::putInt(STORE_NIGHT_RING_TIMES,partSetting.nightRingTimes);
- StoragePreferences::putInt(STORE_SLEEP_TIME, partSetting.sleepSecondsDoor);
- StoragePreferences::putString(STORE_DOCTOR_TITLE, partSetting.doctorTitle);
- StoragePreferences::putBool(STORE_DOCTOR_VISIBLE, partSetting.doctorValid==1);
- StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
- StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
- StoragePreferences::putString(STORE_NURSING_COLOR_RGB, partSetting.nursingColorRgb);
- StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
- StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
- StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
- setRightTitle(root);
- callBedButtonSetVisible();
- setDirectorAndHeadNurse();
- getFrameRoom(frameInfo["frame_id"].asInt());
- dataInit = true;
- }
- }
- static void getDeviceInfo(){
- if (dataInit){
- getFrameInfo();
- //getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
- reinforceDispaly();
- setDirectorAndHeadNurse();
- getTemplate();
- return;
- }
- string url = getHttpGateway() + "/deviceRoom/get_device_by_eth_mac/" + StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0");
- LOGD("请求设备信息. url = %s", url.c_str());
- //发起HTTP GET请求
- RestClient::Response r = RestClient::get(url);
- if (r.code != 200) {
- LOGD("请求设备信息错误. 错误代码 = %d", r.code);
- if (!deviceRequest) {
- deviceRequest = true;
- requestTimeHandle();
- }
- return;
- }
- LOGD("获得设备信息. result = %s", r.body.c_str());
- deviceRequest = false;
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- string partName = root["part_display"].asString();
- StoragePreferences::putString(STORE_PARTNAME,partName);
- NavibarSetPartName(partName);
- //设备
- StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
- StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
- //SIP存储
- // StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString()); // 应该去找配置文件里的sip-ip
- StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
- StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
- frameInfo["frame_id"] = root["frame_id"].asInt();
- frameInfo["full_name"] = root["full_name"].asString();
- frameInfo["part_id"] = root["part_id"].asInt();
- getFrameInfo();
- //获取科室设置
- string partId = root["part_id"].asString();
- StoragePreferences::putString(STORE_PARTID, partId);
- getPartSetting(partId);
- getVersion();
- }
- }
- void setReinforce(bool result) {
- reinforce = result;
- }
- void setHelpButton(const char *pPicPath, bool isTouchable){
- mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, pPicPath);
- mHelpButtonPtr->setTouchable(isTouchable);
- }
- void cancelAutoBtnHelpTimer(){
- if (isHelpTimerRegistered) {
- mActivityPtr->unregisterUserTimer(HELP_TIMER_HANDLE);
- isHelpTimerRegistered = false;
- }
- }
- std::string getCencalByDoorTid() {
- return cencalByDoorTid;
- }
- int getNowTime() {
- struct tm *t = TimeHelper::getDateTime();
- char timeStr[50];
- string formatStr = "%02d:%02d:%02d";
- sprintf(timeStr, formatStr.c_str(), t->tm_hour,t->tm_min,t->tm_sec);
- int hour, minute, second;// 定义时间的各个int临时变量。
- sscanf(timeStr, "%d:%d:%d", &hour, &minute, &second);
- int time = hour * 60 * 60 + minute * 60 + second;
- return time;
- }
- Json::Value getPainterInfoList() {
- return painterInfoList;
- }
- void addPainterInfo(int deviceId, uint32_t bgColor, const std::string& msg, const std::string type, int endTime) {
- // 将设备id,颜色,展示的信息,时间存放起来
- painterInfo["deviceId"] = deviceId;
- // painterInfo["bgColor"] = bgColor + "";
- painterInfo["bgColor"] = bgColor;
- painterInfo["msg"] = msg;
- painterInfo["type"] = type;
- painterInfo["endTime"] = getNowTime() + endTime;
- painterInfoList.append(painterInfo);
- }
- bool removePainterInfo(int deviceId, const std::string type) {
- // 获取painterInfoList的长度
- int size = painterInfoList.size();
- if (size == 0) { // 如果为空了,那就代表painterInfoList没有值,直接返回
- return false;
- }
- // 如果painterInfoList里有对应的deviceId,那就需要先删除原本的,然后再从头添加新的
- int removeIndex = -1;
- for (int i = 0; i < painterInfoList.size(); i++) {
- LOGD("deviceId == %d", deviceId);
- LOGD("painterInfoList.deviceId == %d", painterInfoList[i]["deviceId"].asInt());
- LOGD("type == %s", type.c_str());
- LOGD("painterInfoList.type == %s", painterInfoList[i]["type"].asCString());
- if (painterInfoList[i]["deviceId"].asInt() == deviceId && painterInfoList[i]["type"].asString() == type) {
- removeIndex = i;
- }
- }
- if (removeIndex != -1) {
- painterInfoList.removeIndex(removeIndex, &painterInfo);
- }
- return true;
- }
- //标识方法
- void setPainterInfo(int deviceId, uint32_t bgColor, const std::string& msg, const std::string type, const std::string handle, int endTime) {
- if (handle == "ADD") { // 进行添加,如果painterInfoList为空时,添加需要启动定时器
- int size = painterInfoList.size();
- removePainterInfo(deviceId, type);
- addPainterInfo(deviceId, bgColor, msg, type, endTime);
- if (size == 0) {
- mActivityPtr->registerUserTimer(HELP_TIMER_HANDLE, 1000); // 每秒检测一次
- }
- if (type == "REINFORCE") { // 增援添加的时候,需要禁用增援按钮
- setReinforce(true); // 设置增援状态为true
- setHelpButton("/button/button_help3.png", false);
- }
- }
- else if (handle == "UPDATE") { // 进行修改时,需要把原本的删除掉,再进行添加
- bool result = removePainterInfo(deviceId, type);
- addPainterInfo(deviceId, bgColor, msg, type, endTime);
- if (!result) {
- mActivityPtr->registerUserTimer(HELP_TIMER_HANDLE, 1000); // 每秒检测一次
- }
- }
- else if (handle == "DELETE") { // 进行删除
- removePainterInfo(deviceId, type);
- if (type == "REINFORCE") { // 增援删除的时候,需要还原增援按钮的图片
- setReinforce(false);
- setHelpButton("/button/button_help2.png", true);
- }
- }
- LOGD("painterInfoList.size() == %d", painterInfoList.size());
- mPainterInfoPtr->setBackgroundColor(bgColor);
- mTextInfoPtr->setText(msg);
- if (bgColor == 0xFFFFFFFF){
- mRoomNamePtr->setTextColor(0x00AAF4);
- } else {
- mRoomNamePtr->setTextColor(0xFFFFFF);
- }
- }
- // 收到tcp的时候,刷新数据
- void dataRefresh() {
- LOGD("DATA-REFRESH, 数据刷新");
- if (mActivityPtr == NULL) {
- return;
- }
- if (serverInfo) {
- getServerInfo();
- }
- dataInit = false;
- getDeviceInfo();
- mBedListViewPtr->refreshListView();
- }
- void getPartSetting() {
- getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
- }
- // 处理护理的tcpModel
- void setNursingTcpModel(TcpModel tcpModel) {
- LOGD("缓存Nursing的tcpModel !!!");
- nursingTcpModel = tcpModel;
- }
- void sendNursingEnd() {
- StoragePreferences::putBool(STORE_NURSING_TYPE, false);
- // std::string heartStr = "DOORLED,000F";
- // const char* sendMsg = heartStr.c_str();
- // sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
- lightControl("DOORLED", "000F");
- if (StoragePreferences::getString(STORE_NURSING_INTERACTION_ID, "") != "") { // 对比一下,json里面不为空的时候
- // 发送tcp, tcp_type = SIDE, tcp_action = NURSING_END
- TcpModel tcpModel;
- tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
- tcpModel.type = TcpType::SIDE;
- tcpModel.action = SideAction::NURSING_END;
- tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
- tcpModel.data = StoragePreferences::getString(STORE_NURSING_INTERACTION_ID, ""); // 获取nursingTcpModel里,id字段的数据
- std::string req = getTcpModelString(tcpModel);
- LOGD("TCP NURSING_END : %s",req.c_str());
- // TcpClient::instance()->sendMsg(req.c_str());
- //回调注册
- TcpCallback callback;
- callback.tid = tcpModel.tid;
- callback.jsonStr = req;
- callback.onSuccess = [](Json::Value json){
- LOGD("event callback success");
- return 0;
- };
- callback.onFalied = [](Json::Value json){
- LOGD("event callback failed");
- return 0;
- };
- TcpClient::instance()->sendMsgWithCb(req.c_str(), callback);
- TcpModel newTcpModel;
- // 需要把护理的interactionId清空
- StoragePreferences::putString(STORE_NURSING_INTERACTION_ID, "");
- }
- }
- void setTemplate() {
- getTemplate();
- mBedListViewPtr->refreshListView();
- }
- void setTheme() {
- getTheme();
- }
- /**
- * 注册定时器
- * 填充数组用于注册定时器
- * 注意:id不能重复
- */
- static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
- //{0, 6000}, //定时器id=0, 时间间隔6秒
- //{1, 1000},
- };
- /**
- * 当界面构造时触发
- */
- static void onUI_init(){
- //udp_thread.run("this is thread name");
- //测试用
- LOGD("进入mainLogic页面, 触发 onUI_init");
- if (ETHERNETMANAGER->isConnected() || WIFIMANAGER->isConnected()) {
- if(serverInfo) { // 如果是false,就是不需要
- getServerInfo();
- }
- getDeviceInfo();
- }
- if (StoragePreferences::getBool(STORE_NURSING_TYPE, false)) { // 如果处于护理状态
- mFunctionWinPtr->showWnd();
- mFunctionTextViewPtr->setText(LANGUAGEMANAGER->getValue("InNursing"));
- mFunctionButtonPtr->setText(LANGUAGEMANAGER->getValue("NursingEnd"));
- mFunctionBackPtr->setVisible(false);
- } else {
- mFunctionWinPtr->hideWnd();
- }
- setTemplate();
- }
- /**
- * 当切换到该界面时触发
- */
- static void onUI_intent(const Intent *intentPtr) {
- if (intentPtr != NULL) {
- }
- }
- /*
- * 当界面显示时触发
- */
- static void onUI_show() {
- }
- /*
- * 当界面隐藏时触发
- */
- static void onUI_hide() {
- }
- /*
- * 当界面完全退出时触发
- */
- static void onUI_quit() {
- //pthread_exit(NULL);
- }
- /**
- * 串口数据回调接口
- */
- static void onProtocolDataUpdate(const SProtocolData &data) {
- }
- /**
- * 定时器触发函数
- * 不建议在此函数中写耗时操作,否则将影响UI刷新
- * 参数: id
- * 当前所触发定时器的id,与注册时的id相同
- * 返回值: true
- * 继续运行当前定时器
- * false
- * 停止运行当前定时器
- */
- static bool onUI_Timer(int id){
- switch (id) {
- case HELP_TIMER_HANDLE: // 不能在线程里面关掉线程
- {
- // SetPainterInfo(0xFFFFFFFF, "");
- // setReinforce(false);
- // setHelpButton("/button/button_help2.png", true);
- // return false;
- if (painterInfoList.size() > 0) { // painterInfoList代表里面存在内容
- // 取出排列最后的一项,判断列表是否超时,没有超时就将内容填充到里面
- Json::Value _painterInfo;
- _painterInfo = painterInfoList.get(painterInfoList.size() - 1, &painterInfo);
- int nowTime = getNowTime();
- if (nowTime >= _painterInfo["endTime"].asInt()) {
- if (_painterInfo["type"] == "REINFORCE") {
- setReinforce(false);
- setHelpButton("/button/button_help2.png", true);
- }
- painterInfoList.removeIndex(painterInfoList.size() - 1, &painterInfo);
- } else {
- mPainterInfoPtr->setBackgroundColor( _painterInfo["bgColor"].asUInt());
- mTextInfoPtr->setText(_painterInfo["msg"].asCString());
- if (_painterInfo["bgColor"] == 0xFFFFFFFF){
- mRoomNamePtr->setTextColor(0x00AAF4);
- } else {
- mRoomNamePtr->setTextColor(0xFFFFFF);
- }
- }
- } else {
- mPainterInfoPtr->setBackgroundColor(0xFFFFFFFF);
- mTextInfoPtr->setText("");
- mRoomNamePtr->setTextColor(0x00AAF4);
- setReinforce(false);
- setHelpButton("/button/button_help2.png", true);
- return false;
- }
- }
- break;
- case REQUEST_TIME_HANDLE:
- {
- if (deviceRequest) {
- getDeviceInfo();
- }
- if (frameRequest) {
- getFrameRoom(frameInfo["frame_id"].asInt());
- }
- if (!deviceRequest && !frameRequest) {
- return false;
- }
- }
- break;
- default:
- break;
- }
- return true;
- }
- /**
- * 有新的触摸事件时触发
- * 参数:ev
- * 新的触摸事件
- * 返回值:true
- * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
- * false
- * 触摸事件将继续传递到控件上
- */
- static bool onmainActivityTouchEvent(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 int getListItemCount_BedListView(const ZKListView *pListView) {
- //LOGD("getListItemCount_BedListView !\n");
- // if (frameBedList.size() > 3) {
- // return frameBedList.size();
- // }
- return frameBedList.size();
- }
- static void obtainListItemData_BedListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
- //LOGD(" obtainListItemData_ BedListView !!!\n");
- int templateInt = StoragePreferences::getInt(STORE_TEMPLATE, 1);
- if (templateInt == 3) {
- pListItem->findSubItemByID(ID_MAIN_CustomerPortrait)->setPosition(LayoutPosition(50, 120, 48, 50));
- pListItem->findSubItemByID(ID_MAIN_CustomerName)->setPosition(LayoutPosition(5, 180, 270, 50));
- pListItem->findSubItemByID(ID_MAIN_CustomerSex)->setPosition(LayoutPosition(130, 130, 30, 30));
- pListItem->findSubItemByID(ID_MAIN_CustomerAge)->setPosition(LayoutPosition(170, 130, 90, 30));
- pListItem->findSubItemByID(ID_MAIN_DoctoreBg)->setPosition(LayoutPosition(5, 365, 135, 90));
- pListItem->findSubItemByID(ID_MAIN_DoctorText)->setPosition(LayoutPosition(5, 370, 130, 30));
- pListItem->findSubItemByID(ID_MAIN_DoctorName)->setPosition(LayoutPosition(5, 410, 130, 35));
- pListItem->findSubItemByID(ID_MAIN_NurseBg)->setPosition(LayoutPosition(140, 365, 135, 90));
- pListItem->findSubItemByID(ID_MAIN_NurseText)->setPosition(LayoutPosition(145, 370, 130, 30));
- pListItem->findSubItemByID(ID_MAIN_NurseName)->setPosition(LayoutPosition(145, 410, 130, 35));
- pListItem->findSubItemByID(ID_MAIN_NurseConfigBg)->setVisible(true);
- pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setVisible(true);
- pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setVisible(true);
- pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setVisible(true);
- pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setVisible(true);
- pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setVisible(true);
- pListItem->findSubItemByID(ID_MAIN_NurseOption6)->setVisible(true);
- }
- else {
- pListItem->findSubItemByID(ID_MAIN_NurseConfigBg)->setVisible(false);
- pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setVisible(false);
- pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setVisible(false);
- pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setVisible(false);
- pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setVisible(false);
- pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setVisible(false);
- pListItem->findSubItemByID(ID_MAIN_NurseOption6)->setVisible(false);
- if (templateInt == 1) {
- pListItem->findSubItemByID(ID_MAIN_CustomerPortrait)->setPosition(LayoutPosition(120, 145, 48, 50));
- pListItem->findSubItemByID(ID_MAIN_CustomerName)->setPosition(LayoutPosition(5, 220, 270, 50));
- pListItem->findSubItemByID(ID_MAIN_CustomerSex)->setPosition(LayoutPosition(80, 285, 30, 30));
- pListItem->findSubItemByID(ID_MAIN_CustomerAge)->setPosition(LayoutPosition(135, 280, 90, 40));
- pListItem->findSubItemByID(ID_MAIN_DoctoreBg)->setPosition(LayoutPosition(5, 345, 135, 110));
- pListItem->findSubItemByID(ID_MAIN_DoctorText)->setPosition(LayoutPosition(5, 350, 130, 30));
- pListItem->findSubItemByID(ID_MAIN_DoctorName)->setPosition(LayoutPosition(5, 390, 130, 40));
- pListItem->findSubItemByID(ID_MAIN_NurseBg)->setPosition(LayoutPosition(140, 345, 135, 110));
- pListItem->findSubItemByID(ID_MAIN_NurseText)->setPosition(LayoutPosition(145, 350, 130, 30));
- pListItem->findSubItemByID(ID_MAIN_NurseName)->setPosition(LayoutPosition(145, 390, 130, 40));
- }
- else if (templateInt == 2) {
- pListItem->findSubItemByID(ID_MAIN_CustomerPortrait)->setPosition(LayoutPosition(120, 120, 48, 50));
- pListItem->findSubItemByID(ID_MAIN_CustomerName)->setPosition(LayoutPosition(5, 180, 270, 50));
- pListItem->findSubItemByID(ID_MAIN_CustomerSex)->setPosition(LayoutPosition(80, 245, 30, 30));
- pListItem->findSubItemByID(ID_MAIN_CustomerAge)->setPosition(LayoutPosition(135, 240, 90, 40));
- pListItem->findSubItemByID(ID_MAIN_DoctoreBg)->setPosition(LayoutPosition(5, 300, 135, 90));
- pListItem->findSubItemByID(ID_MAIN_DoctorText)->setPosition(LayoutPosition(5, 305, 130, 30));
- pListItem->findSubItemByID(ID_MAIN_DoctorName)->setPosition(LayoutPosition(5, 345, 130, 35));
- pListItem->findSubItemByID(ID_MAIN_NurseBg)->setPosition(LayoutPosition(140, 300, 135, 90));
- pListItem->findSubItemByID(ID_MAIN_NurseText)->setPosition(LayoutPosition(145, 305, 130, 30));
- pListItem->findSubItemByID(ID_MAIN_NurseName)->setPosition(LayoutPosition(145, 345, 130, 35));
- }
- }
- if (frameBedList.size() > 0) {
- string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
- if (frameBedName == "") {
- pListItem->findSubItemByID(ID_MAIN_BedFrameTextView)->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
- } else {
- int nPos = frameBedName.find("-");
- if (nPos != -1) {
- frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
- }
- pListItem->findSubItemByID(ID_MAIN_BedFrameTextView)->setText(frameBedName);
- }
- // 用户相关
- string customerName = frameBedList[index]["customer_name"].asString();
- if (customerName == "") {
- pListItem->findSubItemByID(ID_MAIN_CustomerName)->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
- } else {
- pListItem->findSubItemByID(ID_MAIN_CustomerName)->setText(customerName);
- }
- if (partSetting.customerAgeHiddenOnDoor != 0) {
- if (frameBedList[index]["customer_age"].asString() == "") {
- pListItem->findSubItemByID(ID_MAIN_CustomerAge)->setText("");
- } else {
- pListItem->findSubItemByID(ID_MAIN_CustomerAge)->setText("*" + frameBedList[index]["customer_age_unit"].asString());
- }
- }
- else {
- pListItem->findSubItemByID(ID_MAIN_CustomerAge)->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
- }
- string customerSex = frameBedList[index]["customer_sex"].asString();
- if (customerSex == "0") { // 如果性别为女性,则替换成女性头像,和女性的图标
- pListItem->findSubItemByID(ID_MAIN_CustomerPortrait)->setBackgroundPic("ic_custom_female.png");
- pListItem->findSubItemByID(ID_MAIN_CustomerSex)->setBackgroundPic("ic_gender_female.png");
- }
- else if (customerSex == "1") {
- pListItem->findSubItemByID(ID_MAIN_CustomerPortrait)->setBackgroundPic("ic_custom_male.png");
- pListItem->findSubItemByID(ID_MAIN_CustomerSex)->setBackgroundPic("ic_gender_male.png");
- }
- else {
- pListItem->findSubItemByID(ID_MAIN_CustomerPortrait)->setBackgroundPic("ic_custom_empty.png");
- pListItem->findSubItemByID(ID_MAIN_CustomerSex)->setBackgroundPic("");
- }
- // 医生护士相关
- if (rightTitleInfo["doctor_valid"] != 1){
- pListItem->findSubItemByID(ID_MAIN_DoctorText)->setVisible(false);
- } else {
- pListItem->findSubItemByID(ID_MAIN_DoctorText)->setText(rightTitleInfo["doctor_title"].asString());
- }
- if (rightTitleInfo["nurse_valid"] != 1){
- pListItem->findSubItemByID(ID_MAIN_NurseText)->setVisible(false);
- } else {
- pListItem->findSubItemByID(ID_MAIN_NurseText)->setText(rightTitleInfo["nurse_title"].asString());
- }
- pListItem->findSubItemByID(ID_MAIN_DoctorName)->setText(frameBedList[index]["doctor_name"].asString());
- pListItem->findSubItemByID(ID_MAIN_NurseName)->setText(frameBedList[index]["nurse_name"].asString());
- // 护理项相关
- Json::Value nurseConfigList = frameBedList[index]["nurse_config_dtos"];
- for (int i = 0; i < 6; i++) {
- int nurseOptionNumber = ID_MAIN_NurseOption1 + i * 2;
- if (i == 5) {
- nurseOptionNumber = ID_MAIN_NurseOption6;
- }
- if (StoragePreferences::getInt(STORE_TEMPLATE, 1) == 3) {
- pListItem->findSubItemByID(nurseOptionNumber)->setVisible(true);
- if (nurseConfigList.size() > 0 && nurseConfigList.size() >= i && nurseConfigList[i]["nurse_option_name"].asString() != "") {
- //颜色
- string nurseConfigColot = nurseConfigList[i]["nurse_color_rbg"].asString();
- uint32_t bgColor = 0xFFF5F8FF;
- if (nurseConfigColot != "") {
- string rgbStr = "FF" + nurseConfigColot;
- transform(rgbStr.begin(), rgbStr.end(), rgbStr.begin(), ::toupper);
- bgColor = strtoul(("0x" + rgbStr).c_str(), NULL,16);
- }
- string nurseOptionName = nurseConfigList[i]["nurse_option_name"].asString();
- pListItem->findSubItemByID(nurseOptionNumber)->setBackgroundColor(bgColor);
- pListItem->findSubItemByID(nurseOptionNumber)->setText(nurseOptionName);
- }
- else {
- pListItem->findSubItemByID(nurseOptionNumber)->setBackgroundColor(0xFFF5F8FF);
- pListItem->findSubItemByID(nurseOptionNumber)->setText(LANGUAGEMANAGER->getValue("None"));
- }
- }
- else {
- pListItem->findSubItemByID(nurseOptionNumber)->setVisible(false);
- }
- }
- // Json::Value nurseConfigList = frameBedList[index]["nurse_config_dtos"];
- // if (nurseConfigList.size() > 0) {
- // for (int i = 0; i < 5; i++) {
- // int nurseConfigColorNumber = ID_MAIN_NurseConfigColor1 + i;
- // int nurseConfigNumber = ID_MAIN_NurseConfig1 + i * 2;
- // int nurseOptionNumber = ID_MAIN_NurseOption1 + i * 2;
- // if (nurseConfigList.size() >= i) {
- // //颜色
- // string nurseConfigColot = nurseConfigList[i]["nurse_color_rbg"].asString();
- // uint32_t bgColor = 0xFFC0C0C0;
- // if (nurseConfigColot != "") {
- // string rgbStr = "FF" + nurseConfigColot;
- // transform(rgbStr.begin(), rgbStr.end(), rgbStr.begin(), ::toupper);
- // bgColor = strtoul(("0x" + rgbStr).c_str(), NULL,16);
- // }
- // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(bgColor);
- // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
- // string nurseOptionName = nurseConfigList[i]["nurse_option_name"].asString();
- // if (nurseOptionName == "") {
- // nurseOptionName = LANGUAGEMANAGER->getValue("None");
- // }
- // pListItem->findSubItemByID(nurseOptionNumber)->setText(nurseOptionName);
- //
- // } else {
- // //颜色
- // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
- // pListItem->findSubItemByID(nurseOptionNumber)->setText(LANGUAGEMANAGER->getValue("None"));
- // }
- // }
- // }
- // else {
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor1)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor2)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor3)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor4)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor5)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig1)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig2)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig3)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig4)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig5)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setText(LANGUAGEMANAGER->getValue("None"));
- // }
- }
- }
- static void onListItemClick_BedListView(ZKListView *pListView, int index, int id) {
- //LOGD(" onListItemClick_ BedListView !!!\n");
- }
- static bool onButtonClick_CallBedButton(ZKButton *pButton) {
- LOGD(" ButtonClick CallBedButton !!!\n");
- if (frameBedList.size() > 0) {
- mCallBebWinPtr->showWnd();
- } else {
- Intent* intent = new Intent();
- intent->putExtra(warnText, LANGUAGEMANAGER->getValue("NoBedList"));
- EASYUICONTEXT->openActivity("warnActivity", 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");
- intent->putExtra(audioOnly, "true");
- EASYUICONTEXT->openActivity("callActivity", intent);
- }
- return false;
- }
- static bool onButtonClick_HelpButton(ZKButton *pButton) {
- LOGD(" ButtonClick HelpButton !!!\n");
- TcpModel tcpModel;
- tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
- tcpModel.type = TcpType::REINFORCE;
- tcpModel.action = ReinforceAction::CALL;
- tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
- tcpModel.to_id = 0;
- std::string req = getTcpModelString(tcpModel);
- LOGD("REINFORCE CALL : %s",req.c_str());
- // TcpClient::instance()->sendMsg(req.c_str());
- //回调注册
- TcpCallback callback;
- callback.tid = tcpModel.tid;
- callback.jsonStr = req;
- callback.onSuccess = [](Json::Value json){
- LOGD("callback success");
- return 0;
- };
- callback.onFalied = [](Json::Value json){
- LOGD("callback failed");
- return 0;
- };
- TcpClient::instance()->sendMsgWithCb(req.c_str(), callback);
- // setHelpButton("/button/button_help3.png" ,false);
- // SetPainterInfo(0xFF2F9DF1, "增援已发出");
- // setReinforce(true); // 设置增援状态为true
- // //1分钟后无响应还原颜色
- // if (!isHelpTimerRegistered){
- // mActivityPtr->registerUserTimer(HELP_TIMER_HANDLE, 60000);
- // }
- setPainterInfo(StoragePreferences::getInt(STORE_DEVICE_ID,0), 0xFF2F9DF1, LANGUAGEMANAGER->getValue("HelpInfo"), "REINFORCE", "ADD", 60);
- return false;
- }
- static bool onButtonClick_CallCencelButton(ZKButton *pButton) {
- LOGD(" ButtonClick CallCencelButton !!!\n");
- // 发送tcp, tcp_type = VOICE, tcp_action = CANCEL_BY_DOOR
- TcpModel tcpModel;
- tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
- tcpModel.type = TcpType::VOICE;
- tcpModel.action = VoiceAction::CANCEL_BY_DOOR;
- tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
- tcpModel.to_id = NULL;
- std::string req = getTcpModelString(tcpModel);
- LOGD("TCP VOICE : %s",req.c_str());
- cencalByDoorTid = tcpModel.tid;
- //回调注册
- TcpCallback callback;
- callback.tid = tcpModel.tid;
- callback.jsonStr = req;
- callback.onSuccess = [](Json::Value json){
- LOGD("side callback success");
- return 0;
- };
- callback.onFalied = [](Json::Value json){
- LOGD("side callback failed");
- return 0;
- };
- TcpClient::instance()->sendMsgWithCb(req.c_str(), callback);
- return false;
- }
- static bool onButtonClick_NursingButton(ZKButton *pButton) {
- LOGD(" ButtonClick NursingButton !!!\n");
- // std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
- // std::string heartStr;
- // if (color != "" && color.size() == 3) {
- // heartStr = "DOORLED," + color + "F";
- // } else {
- // heartStr = "DOORLED,010F";
- // }
- // const char* sendMsg = heartStr.c_str();
- // sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
- std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
- if (color != "" && color.size() == 3) {
- color = color + "F";
- } else {
- color = "010F";
- }
- lightControl("DOORLED", color);
- mFunctionWinPtr->showWnd();
- mFunctionTextViewPtr->setText(LANGUAGEMANAGER->getValue("InNursing"));
- mFunctionButtonPtr->setText(LANGUAGEMANAGER->getValue("NursingEnd"));
- mFunctionBackPtr->setVisible(false);
- // 发送tcp, tcp_type = SIDE, tcp_action = NURSING
- TcpModel tcpModel;
- tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
- tcpModel.type = TcpType::SIDE;
- tcpModel.action = SideAction::NURSING;
- tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
- tcpModel.to_id = NULL;
- std::string req = getTcpModelString(tcpModel);
- LOGD("TCP SIDE : %s",req.c_str());
- //回调注册
- TcpCallback callback;
- callback.tid = tcpModel.tid;
- callback.jsonStr = req;
- callback.onSuccess = [](Json::Value json){
- LOGD("side callback success");
- return 0;
- };
- callback.onFalied = [](Json::Value json){
- LOGD("side callback failed");
- return 0;
- };
- TcpClient::instance()->sendMsgWithCb(req.c_str(), callback);
- // 把护理状态缓存起来
- StoragePreferences::putBool(STORE_NURSING_TYPE, true);
- return false;
- }
- static bool onButtonClick_MoreButton(ZKButton *pButton) {
- LOGD(" ButtonClick MoreButton !!!\n");
- EASYUICONTEXT->openActivity("ui3Activity");
- return false;
- }
- static bool onButtonClick_FunctionButton(ZKButton *pButton) {
- LOGD(" ButtonClick FunctionButton !!!\n");
- mFunctionWinPtr->hideWnd();
- sendNursingEnd();
- return false;
- }
- static bool onButtonClick_FunctionBack(ZKButton *pButton) {
- LOGD(" ButtonClick FunctionBack !!!\n");
- return false;
- }
- static int getListItemCount_CallBedListView(const ZKListView *pListView) {
- //LOGD("getListItemCount_CallBedListView !\n");
- return frameBedList.size();
- }
- static void obtainListItemData_CallBedListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
- //LOGD(" obtainListItemData_ CallBedListView !!!\n");
- pListItem->setText(frameBedList[index]["frame_bed"]["full_name"].asString());
- pListItem->findSubItemByID(ID_MAIN_CallBedName)->setText(frameBedList[index]["customer_name"].asString());
- }
- static void onListItemClick_CallBedListView(ZKListView *pListView, int index, int id) {
- // LOGD(" onListItemClick_ CallBedListView !!!\n");
- string customerName = frameBedList[index]["customer_name"].asString();
- string toId = frameBedList[index]["bed_device_id"].asString();
- if (customerName == "") {
- Intent* intent = new Intent();
- intent->putExtra(warnText, LANGUAGEMANAGER->getValue("NoCustomer"));
- EASYUICONTEXT->openActivity("warnActivity", intent);
- }
- else if (toId == "") {
- Intent* intent = new Intent();
- intent->putExtra(warnText, LANGUAGEMANAGER->getValue("NoBedDevice"));
- EASYUICONTEXT->openActivity("warnActivity", intent);
- }
- else {
- mCallBebWinPtr->hideWnd();
- Intent* intent = new Intent();
- intent->putExtra(isOutgoing, "true");
- intent->putExtra(audioOnly, "true");
- intent->putExtra(toIdStr, toId);
- intent->putExtra(callName, frameBedList[index]["frame_bed"]["full_name"].asString() + " " + customerName);
- EASYUICONTEXT->openActivity("callActivity", intent);
- }
- }
- static bool onButtonClick_CallBedCancel(ZKButton *pButton) {
- LOGD(" ButtonClick CallBedCancel !!!\n");
- mCallBebWinPtr->hideWnd();
- return false;
- }
|