75 lines
1.8 KiB
C++
Executable File
75 lines
1.8 KiB
C++
Executable File
// std
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <chrono>
|
|
#include <thread>
|
|
|
|
// tmsif
|
|
#include <tmsif/api/Alert.hpp>
|
|
|
|
// ddkit
|
|
#include <ddkit/actors/Session.hpp>
|
|
|
|
|
|
// callback-implementations - messages from clients
|
|
class AlertService : public M_Alert::IService
|
|
{
|
|
public:
|
|
void CmdRaiseAlarm(M_Alert::AlarmConditionInfoType const& Condition) override
|
|
{
|
|
fprintf(stderr, "CmdRaiseAlarm !!\n");
|
|
}
|
|
};
|
|
|
|
|
|
class AlertClient : public M_Alert::IClient
|
|
{
|
|
public:
|
|
|
|
void setAlertClient(M_Alert::Client *uglyPointer)
|
|
{m_client = uglyPointer;}
|
|
|
|
M_Alert::Client *m_client;
|
|
|
|
void ReportAlarmLog(M_Alert::AlertIdType const& KeyAlarmId, M_Alert::AlarmLogType const& Alarm, bool IsRemoved)
|
|
{
|
|
fprintf(stderr, "ReportAlarmLog !!\n");
|
|
(*m_client)->CmdRaiseAlarm(M_Alert::AlarmConditionInfoType("a", "b", "c", "d", "e"));
|
|
}
|
|
};
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
std::cout << "App started ..." << std::endl;
|
|
|
|
int domain = 5;
|
|
ddkit::actors::Session session(domain);
|
|
|
|
// constructing callbacks
|
|
AlertService callbacksFromClients;
|
|
|
|
// starting Service
|
|
const std::string serviceName = "AlertService123";
|
|
auto service = M_Alert::Service::create(session, serviceName, callbacksFromClients);
|
|
|
|
// client
|
|
AlertClient callbacksFromServices;
|
|
auto client = M_Alert::Client::create(session, serviceName, callbacksFromServices);
|
|
callbacksFromServices.setAlertClient(&client);
|
|
|
|
// messages
|
|
auto msg = M_Alert::AlarmLogType(M_Alert::AlarmStatusKind::Active, false, false,
|
|
false, {}, M_Alert::AlarmCategoryKind::Type::Warning, M_Common::TimeType(4000, 0), {});
|
|
|
|
uint64_t i = 1;
|
|
while(true) {
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
|
|
// send data cyclic for example
|
|
service->ReportAlarmLog("test123", msg, false);
|
|
}
|
|
|
|
return 0;
|
|
}
|