bool CHarmonyHub::WriteToHardware(const char *pdata, const unsigned char length) { const tRBUF *pCmd = reinterpret_cast<const tRBUF*>(pdata); if(this->m_bIsChangingActivity) { _log.Log(LOG_ERROR,"Harmony Hub: Command cannot be sent. Hub is changing activity"); return false; } //activities can be switched on if ((pCmd->LIGHTING2.packettype == pTypeLighting2) && (pCmd->LIGHTING2.cmnd==1)) { int lookUpId = (int)(pCmd->LIGHTING2.id1 << 24) | (int)(pCmd->LIGHTING2.id2 << 16) | (int)(pCmd->LIGHTING2.id3 << 8) | (int)(pCmd->LIGHTING2.id4) ; std::stringstream sstr; sstr << lookUpId; //get the activity id from the db and send to h/w if (!SubmitCommand(START_ACTIVITY_COMMAND, sstr.str(), "")) { _log.Log(LOG_ERROR,"Harmony Hub: Error sending the switch command"); return false; } } else if((pCmd->LIGHTING2.packettype == pTypeLighting2) && (pCmd->LIGHTING2.cmnd==0)) { if(!SubmitCommand(START_ACTIVITY_COMMAND, "PowerOff","")) { _log.Log(LOG_ERROR,"Harmony Hub: Error sending the power-off command"); return false; } } return true; }
bool CHarmonyHub::UpdateActivities() { if(SubmitCommand(m_commandcsocket, m_szAuthorizationToken, GET_CONFIG_COMMAND, "", "") == 1) { _log.Log(LOG_ERROR,"Harmony Hub: Get activities failed"); return false; } std::map< std::string, std::string> mapActivities; std::vector< Device > vecDevices; if(ParseConfiguration(m_szResultString, mapActivities, vecDevices) == 1) { _log.Log(LOG_ERROR,"Harmony Hub: Parse activities and devices failed"); return false; } std::map< std::string, std::string>::iterator it = mapActivities.begin(); std::map< std::string, std::string>::iterator ite = mapActivities.end(); int cnt=0; for(; it != ite; ++it) { UpdateSwitch(cnt++, it->first.c_str(), strcmp(m_szCurActivityID.c_str(), it->first.c_str())==0, it->second); /*m_szResultString.append(it->first); m_szResultString.append(" - "); m_szResultString.append(it->second); m_szResultString.append("\n");*/ } return true; }
void SSessionConsoleCommandBar::HandleInputTextCommitted( const FText& InText, ETextCommit::Type CommitInfo ) { if (CommitInfo == ETextCommit::OnEnter) { SubmitCommand(InText.ToString()); } }
bool CHarmonyHub::WriteToHardware(const char *pdata, const unsigned char length) { tRBUF *pCmd=(tRBUF*) pdata; BYTE idx=0; if(this->m_bIsChangingActivity) { _log.Log(LOG_ERROR,"Harmony Hub: Command cannot be sent. Hub is changing activity"); return false; } //activities can be switched on if ((pCmd->LIGHTING2.packettype == pTypeLighting2) && (pCmd->LIGHTING2.cmnd==1)) { //char szIdx[10]; //sprintf(szIdx, "%X%02X%02X%02X", 0, 0, 0, pCmd->LIGHTING2.id4); int lookUpId = (int)(pCmd->LIGHTING2.id1 << 24) | (int)(pCmd->LIGHTING2.id2 << 16) | (int)(pCmd->LIGHTING2.id3 << 8) | (int)(pCmd->LIGHTING2.id4) ; std::stringstream sstr; sstr << lookUpId; //get the activity id from the db and send to h/w std::stringstream szQuery; std::vector<std::vector<std::string> > result; //szQuery << "SELECT StrParam1 FROM DeviceStatus WHERE (HardwareID==" << m_HwdID << ") AND (DeviceID=='" << szIdx << "')"; //result = m_sql.query(szQuery.str()); //if (result.size() > 0) //should be there since it is switched on //{ if (SubmitCommand(m_commandcsocket, m_szAuthorizationToken, START_ACTIVITY_COMMAND, sstr.str(), "") == 1) { _log.Log(LOG_ERROR,"Harmony Hub: Error sending the switch command"); return false; } /*} else _log.Log(LOG_ERROR,"Harmony Hub: Device not found" );*/ } else if((pCmd->LIGHTING2.packettype == pTypeLighting2) && (pCmd->LIGHTING2.cmnd==0)) { if(SubmitCommand(m_commandcsocket, m_szAuthorizationToken, START_ACTIVITY_COMMAND, "PowerOff","") == 1) { _log.Log(LOG_ERROR,"Harmony Hub: Error sending the poweroff command"); return false; } } return true; }
bool CHarmonyHub::UpdateActivities() { if(!SubmitCommand(GET_CONFIG_COMMAND_RAW, "", "")) { _log.Log(LOG_ERROR,"Harmony Hub: Get activities failed"); return false; } std::map< std::string, std::string> mapActivities; Json::Reader jReader; Json::Value root; bool ret = jReader.parse(m_szResultString, root); if (!ret) { _log.Log(LOG_ERROR, "Harmony Hub: Invalid data received! (Update Activities)"); return false; } if (root["activity"].empty()) { _log.Log(LOG_ERROR, "Harmony Hub: Invalid data received! (Update Activities)"); return false; } int totActivities = (int)root["activity"].size(); for (int ii = 0; ii < totActivities; ii++) { std::string aID = root["activity"][ii]["id"].asString(); std::string aLabel = root["activity"][ii]["label"].asString(); mapActivities[aID] = aLabel; } std::map< std::string, std::string>::const_iterator itt; int cnt = 0; for (itt = mapActivities.begin(); itt != mapActivities.end(); ++itt) { UpdateSwitch(cnt++, itt->first.c_str(), (m_szCurActivityID == itt->first), itt->second); } return true; }
bool CHarmonyHub::UpdateCurrentActivity() { if(SubmitCommand(m_commandcsocket, m_szAuthorizationToken, GET_CURRENT_ACTIVITY_COMMAND, "", "") == 1) { //_log.Log(LOG_ERROR,"Harmony Hub: Get current activity failed"); return false; } //check if changed if(!strcmp(m_szCurActivityID.c_str(), m_szResultString.c_str())==0) { if(!m_szCurActivityID.empty()) { //need to set the old activity to off CheckSetActivity(m_szCurActivityID,false ); } CheckSetActivity(m_szResultString,true); m_szCurActivityID = m_szResultString; } return true; }
bool CHarmonyHub::UpdateCurrentActivity() { if(!SubmitCommand(GET_CURRENT_ACTIVITY_COMMAND_RAW, "", "")) { //_log.Log(LOG_ERROR,"Harmony Hub: Get current activity failed"); return false; } //check if changed if(m_szCurActivityID!=m_szResultString) { if(!m_szCurActivityID.empty()) { //need to set the old activity to off CheckSetActivity(m_szCurActivityID,false ); } CheckSetActivity(m_szResultString,true); m_szCurActivityID = m_szResultString; } return true; }
FReply SSessionConsoleCommandBar::HandleSendButtonClicked( ) { SubmitCommand(InputTextBox->GetText().ToString()); return FReply::Handled(); }