~aleteoryx/muditaos

ref: 7424b4be5859bf6528fcb64f6b3d128abb65f89d muditaos/module-services/service-time/AlarmServiceAPI.cpp -rw-r--r-- 1.8 KiB
7424b4be — Alek Rudnik [EGD-7433] Remove legacy fileindexer database 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Constants.hpp"

#include <service-time/AlarmMessage.hpp>
#include <service-time/AlarmServiceAPI.hpp>

#include <module-db/Interface/AlarmEventRecord.hpp>

namespace alarms
{

    namespace AlarmServiceAPI
    {
        template <class requestType, typename... Types> bool sendRequest(sys::Service *serv, Types... messageArgs)
        {
            auto msg = std::make_shared<requestType>(messageArgs...);
            return serv->bus.sendUnicast(msg, service::name::service_time);
        }

        bool requestGetAlarm(sys::Service *serv, unsigned int id)
        {
            return sendRequest<AlarmGetRequestMessage>(serv, id);
        }

        bool requestAddAlarm(sys::Service *serv, const AlarmEventRecord &alarmEvent)
        {
            return sendRequest<AlarmAddRequestMessage>(serv, alarmEvent);
        }

        bool requestUpdateAlarm(sys::Service *serv, const AlarmEventRecord &alarmEvent)
        {
            return sendRequest<AlarmUpdateRequestMessage>(serv, alarmEvent);
        }

        bool requestRemoveAlarm(sys::Service *serv, unsigned int id)
        {
            return sendRequest<AlarmRemoveRequestMessage>(serv, id);
        }

        bool requestGetAlarmsInRange(
            sys::Service *serv, TimePoint start, TimePoint end, unsigned int offset, unsigned int limit)
        {
            return sendRequest<AlarmsGetInRangeRequestMessage>(serv, start, end, offset, limit);
        }

        bool requestGetNextSingleEvents(sys::Service *serv)
        {
            return sendRequest<AlarmGetNextSingleEventsRequestMessage>(serv);
        }

    }; // namespace AlarmServiceAPI

} // namespace alarms