map/das-dn/third_party/AdsLib/AdsNotification.h

66 lines
2.8 KiB
C
Raw Normal View History

2024-12-03 10:36:06 +08:00
// SPDX-License-Identifier: MIT
/**
2024-12-09 09:41:04 +08:00
Copyright (c) 2020 - 2022 Beckhoff Automation GmbH & Co. KG
2024-12-03 10:36:06 +08:00
*/
#pragma once
2024-12-09 09:41:04 +08:00
#include "AdsDevice.h"
namespace Beckhoff
{
namespace Ads
{
typedef void (* PAdsNotificationFuncExConst)(const AmsAddr* pAddr, const AdsNotificationHeader* pNotification, uint32_t hUser);
typedef void (* PAdsNotificationFuncExLegacy)(AmsAddr* pAddr, AdsNotificationHeader* pNotification, uint32_t hUser);
struct AdsNotification {
AdsNotification(const AdsDevice& route,
const std::string& symbolName,
const AdsNotificationAttrib& notificationAttributes,
PAdsNotificationFuncExConst callback,
uint32_t hUser)
: m_Symbol(route.GetHandle(symbolName)),
m_Notification(route.GetHandle(ADSIGRP_SYM_VALBYHND, *m_Symbol, notificationAttributes,
reinterpret_cast<PAdsNotificationFuncEx>(callback), hUser))
{}
AdsNotification(const AdsDevice& route,
const std::string& symbolName,
const AdsNotificationAttrib& notificationAttributes,
PAdsNotificationFuncExLegacy callback,
uint32_t hUser)
: m_Symbol(route.GetHandle(symbolName)),
m_Notification(route.GetHandle(ADSIGRP_SYM_VALBYHND, *m_Symbol, notificationAttributes,
reinterpret_cast<PAdsNotificationFuncEx>(callback), hUser))
{}
AdsNotification(const AdsDevice& route,
uint32_t indexGroup,
uint32_t indexOffset,
const AdsNotificationAttrib& notificationAttributes,
PAdsNotificationFuncExConst callback,
uint32_t hUser)
: m_Symbol{route.GetHandle(indexOffset)},
m_Notification(route.GetHandle(indexGroup, indexOffset, notificationAttributes,
reinterpret_cast<PAdsNotificationFuncEx>(callback), hUser))
{}
AdsNotification(const AdsDevice& route,
uint32_t indexGroup,
uint32_t indexOffset,
const AdsNotificationAttrib& notificationAttributes,
PAdsNotificationFuncExLegacy callback,
uint32_t hUser)
: m_Symbol{route.GetHandle(indexOffset)},
m_Notification(route.GetHandle(indexGroup, indexOffset, notificationAttributes,
reinterpret_cast<PAdsNotificationFuncEx>(callback), hUser))
{}
2024-12-03 10:36:06 +08:00
private:
2024-12-09 09:41:04 +08:00
AdsHandle m_Symbol;
AdsHandle m_Notification;
2024-12-03 10:36:06 +08:00
};
2024-12-09 09:41:04 +08:00
}
}