Announcement

Collapse
No announcement yet.

Events mit OLE-Automation Interface

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Events mit OLE-Automation Interface

    Ich möchte via Automation-Interface mit C++Builder4 einen OPC(Ole for Process Control) Client entwickeln.
    Hierfür habe ich die entsprechende TypeLibrary importiert. Dabei wurden einige Klassen und Methoden zur Eventbehandlung bereitgestellt(Auszug,siehe unten). Wie muß ich diese Klassen bzw. Methoden anwenden, um Events behandeln zu können.

    Code Auszug der importieren TypeLibrary(Group Events):

    // ************************************************** *******************//
    // Schnittstelle: DIOPCGroupEvent
    // Flags: (4224) NonExtensible Dispatchable
    // GUID: {28E68F97-8D75-11D1-8DC3-3C302A000000}
    // ************************************************** *******************//
    interface DIOPCGroupEvent : public TDispWrapper<IDispatch>
    {
    void __fastcall DataChange(long TransactionID/*[in]*/, long NumItems/*[in]*/,
    LPSAFEARRAY* ClientHandles/*[in]*/, LPSAFEARRAY* ItemValues/*[in]*/,
    LPSAFEARRAY* Qualities/*[in]*/, LPSAFEARRAY* TimeStamps/*[in]*/)
    {
    _TDispID _dispid(/* DataChange */ DISPID(1));
    TAutoArgs<6> _args;
    _args[1] = TransactionID /*[VT_I4:0]*/;
    _args[2] = NumItems /*[VT_I4:0]*/;
    _args[3] = ClientHandles /*[VT_SAFEARRAY:1]*/;
    _args[4] = ItemValues /*[VT_SAFEARRAY:1]*/;
    _args[5] = Qualities /*[VT_SAFEARRAY:1]*/;
    _args[6] = TimeStamps /*[VT_SAFEARRAY:1]*/;
    OleProcedure(_dispid, _args);
    }

    void __fastcall AsyncReadComplete(long TransactionID/*[in]*/, long NumItems/*[in]*/,
    LPSAFEARRAY* ClientHandles/*[in]*/,
    LPSAFEARRAY* ItemValues/*[in]*/, LPSAFEARRAY* Qualities/*[in]*/
    , LPSAFEARRAY* TimeStamps/*[in]*/, LPSAFEARRAY* Errors/*[in]*/)
    {
    _TDispID _dispid(/* AsyncReadComplete */ DISPID(2));
    TAutoArgs<7> _args;
    _args[1] = TransactionID /*[VT_I4:0]*/;
    _args[2] = NumItems /*[VT_I4:0]*/;
    _args[3] = ClientHandles /*[VT_SAFEARRAY:1]*/;
    _args[4] = ItemValues /*[VT_SAFEARRAY:1]*/;
    _args[5] = Qualities /*[VT_SAFEARRAY:1]*/;
    _args[6] = TimeStamps /*[VT_SAFEARRAY:1]*/;
    _args[7] = Errors /*[VT_SAFEARRAY:1]*/;
    OleProcedure(_dispid, _args);
    }

    // and so on....
    };

    // ************************************************** *******************//
    // DispIntf: DIOPCGroupEvent
    // Flags: (4224) NonExtensible Dispatchable
    // GUID: {28E68F97-8D75-11D1-8DC3-3C302A000000}
    // ************************************************** *******************//
    template <class T>
    class DIOPCGroupEventDispT : public TAutoDriver<DIOPCGroupEvent>
    {
    public:
    DIOPCGroupEventDispT(){}

    void Attach(LPUNKNOWN punk)
    { m_Dispatch = static_cast<T*>(punk); }

    void __fastcall DataChange(long TransactionID/*[in]*/, long NumItems/*[in]*/,
    LPSAFEARRAY* ClientHandles/*[in]*/,
    LPSAFEARRAY* ItemValues/*[in]*/,
    LPSAFEARRAY* Qualities/*[in]*/,
    LPSAFEARRAY* TimeStamps/*[in]*/);
    void __fastcall AsyncReadComplete(long TransactionID/*[in]*/, long NumItems/*[in]*/,
    LPSAFEARRAY* ClientHandles/*[in]*/,
    LPSAFEARRAY* ItemValues/*[in]*/,
    LPSAFEARRAY* Qualities/*[in]*/,
    LPSAFEARRAY* TimeStamps/*[in]*/,
    LPSAFEARRAY* Errors/*[in]*/);
    void __fastcall AsyncWriteComplete(long TransactionID/*[in]*/, long NumItems/*[in]*/,
    LPSAFEARRAY* ClientHandles/*[in]*/,
    LPSAFEARRAY* Errors/*[in]*/);
    void __fastcall AsyncCancelComplete(lo
Working...
X