using ArchestrA.MxAccess;

namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Host.Backend.MxAccess;

/// <summary>
///     Delegate matching <c>LMXProxyServer.OnDataChange</c> COM event signature. Allows
///     <see cref="MxAccessClient"/> to subscribe via the abstracted <see cref="IMxProxy"/>
///     instead of the COM object directly (so the test mock works without MXAccess registered).
/// </summary>
public delegate void MxDataChangeHandler(
    int hLMXServerHandle,
    int phItemHandle,
    object pvItemValue,
    int pwItemQuality,
    object pftItemTimeStamp,
    ref MXSTATUS_PROXY[] ItemStatus);

public delegate void MxWriteCompleteHandler(
    int hLMXServerHandle,
    int phItemHandle,
    ref MXSTATUS_PROXY[] ItemStatus);

/// <summary>
///     Abstraction over <c>LMXProxyServer</c> — port of v1 <c>IMxProxy</c>. Same surface area
///     so the lifted client behaves identically; only the namespace + apartment-marshalling
///     entry-point change.
/// </summary>
public interface IMxProxy
{
    int Register(string clientName);
    void Unregister(int handle);

    int AddItem(int handle, string address);
    void RemoveItem(int handle, int itemHandle);

    void AdviseSupervisory(int handle, int itemHandle);
    void UnAdviseSupervisory(int handle, int itemHandle);

    void Write(int handle, int itemHandle, object value, int securityClassification);

    event MxDataChangeHandler? OnDataChange;
    event MxWriteCompleteHandler? OnWriteComplete;
}
