Невозможно запустить программу — «Ваше первое приложение Kaa» с помощью учебника по Kaa в Windows 10

Ссылка на учебник:
http://kaaproject.github.io/kaa/docs/v0.10.0/Programming-guide/Your-first-Kaa-application/

Я на шаге «Запустить приложение». Я использую C ++ SDK.

Я пытаюсь создать программу в руководстве, но не могу запустить программу. Инструкции для Linux и требуют от меня выполнения некоторых команд. Поскольку я не могу этого сделать, я подумал, что если я открою его в Visual Studio, это сработает.

Открыв Visual Studio, я обнаружил, что кнопка «Пуск» была заменена на кнопку «Присоединить …». Я никогда не видел этого раньше.

Может кто-нибудь помочь мне разобраться, как запустить программу?

Благодарю.

Код:

#include <boost/asio.hpp>
#include <kaa/Kaa.hpp>
#include <kaa/IKaaClient.hpp>
#include <kaa/configuration/manager/IConfigurationReceiver.hpp>
#include <kaa/configuration/storage/FileConfigurationStorage.hpp>
#include <kaa/log/strategies/RecordCountLogUploadStrategy.hpp>
#include <memory>
#include <string>
#include <cstdint>

class ConfigurationCollection : public kaa::IConfigurationReceiver {
public:
ConfigurationCollection()
: kaaClient_(kaa::Kaa::newClient())
, samplePeriod_(0)
, interval_(samplePeriod_)
, timer_(service_, interval_)
{
// Set a custom strategy for uploading logs.
kaaClient_->setLogUploadStrategy(
std::make_shared<kaa::RecordCountLogUploadStrategy>(1, kaaClient_->getKaaClientContext()));
// Set up a configuration subsystem.
kaa::IConfigurationStoragePtr storage(
std::make_shared<kaa::FileConfigurationStorage>(std::string(savedConfig_)));
kaaClient_->setConfigurationStorage(storage);
kaaClient_->addConfigurationListener(*this);
auto handlerUpdate = [this](const boost::system::error_code& err)
{
this->update();
};
timer_.async_wait(handlerUpdate);
}

~ConfigurationCollection()
{
// Stop the Kaa endpoint.
kaaClient_->stop();
std::cout << "Simple client demo stopped" << std::endl;
}

void run()
{
// Run the Kaa endpoint.
kaaClient_->start();
// Read default sample period
samplePeriod_ = kaaClient_->getConfiguration().samplePeriod;
std::cout << "Default sample period: " << samplePeriod_<< std::endl;
// Default sample period
timer_.expires_from_now(boost::posix_time::seconds(samplePeriod_));
service_.run();
}

private:
static constexpr auto savedConfig_ = "saved_config.cfg";
std::shared_ptr<kaa::IKaaClient> kaaClient_;
int32_t samplePeriod_;
boost::asio::io_service service_;
boost::posix_time::seconds interval_;
boost::asio::deadline_timer timer_;

int32_t getTemperature()
{
// For sake of example random data is used
return rand() % 10 + 25;
}

void update()
{
kaa::KaaUserLogRecord logRecord;
logRecord.temperature = getTemperature();
// Send value of temperature
kaaClient_->addLogRecord(logRecord);
// Show log
std::cout << "Sampled temperature: " << logRecord.temperature << std::endl;
// Set a new  period of the send data
timer_.expires_at(timer_.expires_at() + boost::posix_time::seconds(samplePeriod_));
// Posts the timer event
auto handlerUpdate = [this](const boost::system::error_code& err)
{
this->update();
};
timer_.async_wait(handlerUpdate);
}

void updateConfiguration(const kaa::KaaRootConfiguration &configuration)
{
std::cout << "Received configuration data. New sample period: "<< configuration.samplePeriod << " seconds" << std::endl;
samplePeriod_ = configuration.samplePeriod;
}

void onConfigurationUpdated(const kaa::KaaRootConfiguration &configuration)
{
updateConfiguration(configuration);
}
};
int main()
{
ConfigurationCollection configurationCollection;

try {
// It does control of the transmit and receive data
configurationCollection.run();
} catch (std::exception& e) {
std::cout << "Exception: " << e.what();
}
return 0;
}

0

Решение

Страница Windows http://kaaproject.github.io/kaa/docs/v0.10.0/Programming-guide/Using-Kaa-endpoint-SDKs/C++/SDK-Windows/ объясняет процесс компиляции C ++ SDK и приложений для платформы Windows.

0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]