Commit 5e4b9687 authored by 杨熙's avatar 杨熙

1.0.5.3更改当前发现的bug,对程序启动部分进行处理,

parent 2e5a7b62
......@@ -25,7 +25,7 @@
#include "KK_HwDevManager.h"
#define CENTRALAC_INDOORUNIT_NUM_MAX 64
#define MQ_VERSION "1.0.5.2"
#define MQ_VERSION "1.0.5.3"
using namespace std;
......
......@@ -640,7 +640,7 @@ int kk_handleDeviceInfo::onSetDevService(map<string,kk_handleDeviceInfo::HwSubDe
string nodeid = "*";
string arg = "*";
string dev_model_id = subDevIt->second->dev_model_id;
EH::Json::Value cmd_1 = cmd[0u]; //0容易出错,原因: 这里的value的参数同时包含string和int,识别不出来,改成cmd[0u]就能解决了!
// EH::Json::Value cmd_1 = cmd[0u]; //0容易出错,原因: 这里的value的参数同时包含string和int,识别不出来,改成cmd[0u]就能解决了!
// EH::Json::Value::Members members(cmd.getMemberNames());
// for (EH::Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it) {
......@@ -651,25 +651,29 @@ int kk_handleDeviceInfo::onSetDevService(map<string,kk_handleDeviceInfo::HwSubDe
if(dev_model_id == ZeroFire1ChanChopinSwitch_PID|| dev_model_id == ZeroFire2ChanModularSwitch_PID){ //一路灯控 /灯控模块
KKChannelDev* chanDev = subDevIt->second->channelDevs["1"];
bool on = true;
on = cmd_1["value"].asBool() == true;
on = cmd[0u]["value"].asBool() == true;
if(chanDev!=NULL){
opcode = "SWITCH";
nodeid = chanDev->nodeId;
arg = on?"ON":"OFF";
}
on_Send_Service(opcode,nodeid,arg,dev_model_id);
}else if(dev_model_id == ZeroFire2ChanChopinSwitch_PID||dev_model_id == ZeroFire3ChanChopinSwitch_PID){ //多路灯控 /灯控模块
for(int i = 0; i < cmd.size(); i++) {
vector<string> chanMac;
Split(cmd_1["name"].asString(),"_",chanMac);
Split(cmd[i]["name"].asString(),"_",chanMac);
string sn = Replace(chanMac[0],":","");
string channel = chanMac[1];
KKChannelDev* chanDev = subDevIt->second->channelDevs[channel];
bool on = true;
on = cmd_1["value"].asBool() == true;
on = cmd[i]["value"].asBool() == true;
if(chanDev!=NULL){
opcode = "SWITCH";
nodeid = chanDev->nodeId;
arg = on?"ON":"OFF";
}
on_Send_Service(opcode,nodeid,arg,dev_model_id);
}
}
// else if (dev_model_id == Chopin1CurtainSwitch_PID|| dev_model_id == Chopin2CurtainSwitch_PID) { //肖邦一路二路窗帘面板
// KKChannelDev* chanDev = subDevIt->second->channelDevs[channel];
......@@ -1169,7 +1173,12 @@ int kk_handleDeviceInfo::onSetDevService(map<string,kk_handleDeviceInfo::HwSubDe
} catch (exception &e) {
LOGW("%s.\n", e.what());
}
return 0;
}
//下发解析好的命令
//供:onSetDevService()调用
int kk_handleDeviceInfo::on_Send_Service(string opcode,string nodeid,string arg,string dev_model_id){
if(opcode!=""){
EH::Json::Value json;
json["opcode"] = opcode;
......@@ -1187,12 +1196,12 @@ int kk_handleDeviceInfo::onSetDevService(map<string,kk_handleDeviceInfo::HwSubDe
LOGW("Send msg to IotHandler failed.msg is %s\n",wholeMsg.c_str());
}
}else{
LOGW("dev:%s not support set property. \n",sn.c_str());
LOGW("nodeid:%s not support set property. \n",nodeid.c_str());
return -1;
}
return 0;
}
}
EH::Json::Value kk_handleDeviceInfo::centralACStatusToSet(string fanSpeed,bool on,int runModel,int settingTemperature) {
LOGI("centralACStatusToSet , fanSpeed:%s runModel:%d \n",fanSpeed.c_str(),runModel);
EH::Json::Value contronlSet;
......@@ -1976,7 +1985,7 @@ int kk_handleDeviceInfo::onGetDevService(map<string,kk_handleDeviceInfo::HwSubDe
int error;
EH::Json::Value payload,payload1;
EH::Json::Value Panel2;
EH::Json::Value jsonObject;
EH::Json::Value jsonObject_0;
string respTopic1 = pushTopic+"/devices";//1. 子设备列表
string respTopic2 = pushTopic+"/device/sync";//全部设备信息
map<string,HwSubDev*>::iterator it = hwSubDevs.begin();
......@@ -1986,42 +1995,45 @@ int kk_handleDeviceInfo::onGetDevService(map<string,kk_handleDeviceInfo::HwSubDe
//1. 子设备列表
for (it = hwSubDevs.begin(); it != hwSubDevs.end(); it++) {
jsonObject["mac"] = it->second->sn;
jsonObject["product_id"] = it->second->dev_model_id;
jsonObject["state"] = it->second->online = true ? 1:3;
Panel2.append(jsonObject);
jsonObject_0["mac"] = it->second->sn;
jsonObject_0["product_id"] = it->second->dev_model_id;
jsonObject_0["state"] = it->second->online = true ? 1:3;
Panel2.append(jsonObject_0);
}
payload1["devices"] = Panel2;
MQ_CCU_Adapter::GetInstance()->sendtoRoma(payload1,respTopic1);
//5. 子设备状态改变 ,要上传每个设备的状态信息。
for (it = hwSubDevs.begin(); it != hwSubDevs.end(); it++) {
EH::Json::Value jsonObject_1;
EH::Json::Value Panel;
jsonObject["mac"] = it->second->sn;
jsonObject["product_id"] = it->second->dev_model_id;
jsonObject["state"] = it->second->online = true ? 1:3;
string dev_model_id = it->second->dev_model_id;
EH::Json::Value fieldinfo;
jsonObject_1["mac"] = it->second->sn;
jsonObject_1["product_id"] = it->second->dev_model_id;
jsonObject_1["state"] = it->second->online = true ? 1:3;
string dev_model_id = it->second->dev_model_id;
if(dev_model_id == ZeroFire1ChanChopinSwitch_PID || dev_model_id == ZeroFire2ChanModularSwitch_PID){ //单路灯控 /灯控模块
for (map<string,KKChannelDev*>::iterator subIt = it->second->channelDevs.begin();subIt!= it->second->channelDevs.end(); subIt++){
HwSwitch* chanDev = (HwSwitch* )it->second->channelDevs[IntToString(StringToInt(subIt->second->channel,error))];
fieldinfo["name"] = "PowerSwitch" + IntToString(StringToInt(subIt->second->channel,error));
fieldinfo["name"] = "PowerSwitch";
fieldinfo["value"] = chanDev->on ? true:false;
}
EH::Json::Value Panel3;
jsonObject["datapoints"] = Panel3.append(jsonObject);;
Panel.append(jsonObject);
jsonObject_1["datapoints"] = Panel3.append(fieldinfo);
Panel.append(jsonObject_1);
payload["devices"] = Panel;
MQ_CCU_Adapter::GetInstance()->sendtoRoma(payload,respTopic2); //推送新设备到Roma
}else if(dev_model_id == ZeroFire2ChanChopinSwitch_PID || dev_model_id == ZeroFire3ChanChopinSwitch_PID){ //多路灯控 /灯控模块
EH::Json::Value Panel3;
for (map<string,KKChannelDev*>::iterator subIt = it->second->channelDevs.begin();subIt!= it->second->channelDevs.end(); subIt++){
HwSwitch* chanDev = (HwSwitch* )it->second->channelDevs[IntToString(StringToInt(subIt->second->channel,error))];
fieldinfo["name"] = "PowerSwitch_" + IntToString(StringToInt(subIt->second->channel,error));
fieldinfo["value"] = chanDev->on ? true:false;
Panel3.append(fieldinfo);
}
EH::Json::Value Panel3;
jsonObject["datapoints"] = Panel3.append(jsonObject);;
Panel.append(jsonObject);
jsonObject_1["datapoints"] = Panel3;
Panel.append(jsonObject_1);
payload["devices"] = Panel;
MQ_CCU_Adapter::GetInstance()->sendtoRoma(payload,respTopic2); //推送新设备到Roma
}
......
......@@ -169,6 +169,9 @@ public:
int onGetDevService(map<string,kk_handleDeviceInfo::HwSubDev*>&hwSubDevs,map<string,vector<string> >& controllerModel,string pushTopic);
//控制设备
int onSetDevService(map<string,kk_handleDeviceInfo::HwSubDev*>&hwSubDevs,string sn,EH::Json::Value cmd);
//下发解析好的命令
//供:onSetDevService()调用
int on_Send_Service(string opcode,string nodeid,string arg,string dev_model_id);
//建立通道设备模型
kk_handleDeviceInfo::KKChannelDev* buildChannelDevice(string operateId,string nodeId,string channel,EH::Json::Value status,string devroomid,string devname);
......
#!/bin/sh
while :
do
stillRunning=$(ps -e |grep Konkexinghai)
if [ "$stillRunning" ] ; then
echo "Konkexinghai is running."
else
echo "try to start Konkexinghai"
killall Konkexinghai
sleep 1
mv /tmp/Roma/bin/Konkexinghai /home/hj/Roma/bin/
mv /tmp/Roma/config/hj_hwprofile.json /home/hj/Roma/config/
sh /home/hj/Roma/bin/start.sh &
fi
sleep 60
done
#!/bin/bash
#1:system config
#2:Roma config
mkdir /home/hj/Roma/
mv bin/ /home/hj/Roma/
mv config/ /home/hj/Roma/
#3:ccu config
mv check_Konkexinghai.sh /usr/local/bin/hj/
mv on_boot.sh /usr/local/bin/hj/
echo "install Konkexinghai ok,sys will reboot in 1s."
reboot
#!/bin/sh
/xlink-gw/xsepproject -c /xlink-gw/xsep.conf &
/xlink-gw/xlink-gw-core-cpp > /dev/null 2>&1 &
#!/bin/bash
cd /home/hj/Roma/bin/
nohup /home/hj/Roma/bin/Konkexinghai >> /dev/null 2>&1 &
cd /home/hj/konkeyunzhiyi/bin/
nohup /home/hj/konkeyunzhiyi/bin/konkeyunzhiyi >> /dev/null 2>&1 &
#nohup ./Konkexinghai 2>&1|logger -i -t "Konkexinghai" &
#!/bin/sh
while :
do
stillRunning_2=$(ps -e |grep xlink-gw-core-cpp |grep -v "grep")
if [ "$stillRunning_2" ] ; then
echo "xlink-gw-core-cpp is running."
else
echo "try to start xlink-gw-core-cpp"
killall xlink-gw-core-cpp
sleep 1
sh /home/hj/konkeyunzhiyi/xlink-gw/start.sh &
fi
stillRunning_1=$(ps -e |grep xsepproject |grep -v "grep")
if [ "$stillRunning_1" ] ; then
echo "xsepproject is running."
else
echo "try to start xsepproject"
killall xsepproject
sleep 1
sh /home/hj/konkeyunzhiyi/xlink-gw/start.sh &
fi
sleep 10
stillRunning_0=$(ps -e |grep konkeyunzhiyi |grep -v "grep" |grep -v "check_konkeyunzhiyi")
if [ "$stillRunning_0" ] ; then
echo "konkeyunzhiyi is running."
else
echo "try to start konkeyunzhiyi"
killall konkeyunzhiyi
sleep 1
sh /home/hj/konkeyunzhiyi/bin/start.sh &
fi
sleep 50
done
#!/bin/bash
#1:system config
#2:konkeyunzhiyi config
mkdir /home/hj/konkeyunzhiyi/
mv bin/ /home/hj/konkeyunzhiyi/
mv config/ /home/hj/konkeyunzhiyi/
mv xlink-gw/ /home/hj/konkeyunzhiyi/
#3:ccu config
mv check_konkeyunzhiyi.sh /usr/local/bin/hj/
mv on_boot.sh /usr/local/bin/hj/
echo "install konkeyunzhiyi ok,sys will reboot in 1s."
reboot
......@@ -25,9 +25,8 @@ fi
/usr/local/bin/hj/HJ_Firmware monitor upgrade.cloud.hijaytech.com upgrade.cloud.hijaytech.com >/dev/null 2>&1 &
sh /usr/local/bin/hj/check_Konkexinghai.sh &
sleep 1
sh /usr/local/bin/hj/check_konkeyunzhiyi.sh &
#enable crontab
sed -i 's%\(^##*\)\(.*/home/hj/smarthome/script/monitor.sh\)%\2%' $CRON_FILE;
......
#!/bin/bash
#1:system config
#2:konkeyunzhiyi config
mv bin/konkeyunzhiyi /home/hj/konkeyunzhiyi/bin/
mv xlink-gw/xsepproject /home/hj/konkeyunzhiyi/xlink-gw/
mv xlink-gw/xlink-gw-core-cpp /home/hj/konkeyunzhiyi/xlink-gw/
#3:重启程序
killall konkeyunzhiyi
killall xsepproject
killall xlink-gw-core-cpp
echo "update konkeyunzhiyi ok"
......@@ -29,7 +29,7 @@ APIHost=https://api2.xlink.cn
; CertificationID=5f16c339553dfa69fafe7b6f
; CertificationKey=56395fde-3b1c-46dc-a3a6-f3b1aa62be3b
#IOT
#IOT
ProductID=1603bcc0b2ca03e91603bcc0b2cab201
ProductKey=219e6b59c46282a67cea36050111e779
CertificationID=605980cd6fb0bd27b23545fa
......
#!/bin/sh
nohup /home/hj/konkeyunzhiyi/xlink-gw/xlink-gw-core-cpp > /home/hj/konkeyunzhiyi/xlink-gw/1.txt 2>&1 &
nohup /home/hj/konkeyunzhiyi/xlink-gw/xsepproject -c xsep.conf > /home/hj/konkeyunzhiyi/xlink-gw/1.txt 2>&1 &
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment