MEGA Search
20.3 Million


Sign Up
From: darnis  
Subject: How can I import a IDL file to DELPHI Project?
NewsGroup: borland.public.delphi.oleautomation
Date Posted: 14-Jun-2005 at 10:55:9 PST
Hi, all

    I have a problem how can I import the third provide IDL file? For
example, the OPC Server's IDL file from www.opcfoundation.org , how can I
import it to my project?


   OPC.IDL is download from opcfoundation. It's attached following.

Thanks.

Darnis

-----------------------------OPC.IDL---------------------------------
// OPC.IDL
// REVISION:  8/28 8:00 pm

import "oaidl.idl" ;

typedef enum { OPC_DS_CACHE = 1, OPC_DS_DEVICE } OPCDATASOURCE ;

typedef enum { OPC_BRANCH = 1, OPC_LEAF, OPC_FLAT} OPCBROWSETYPE;

typedef enum { OPC_NS_HIERARCHIAL = 1, OPC_NS_FLAT} OPCNAMESPACETYPE;

typedef enum { OPC_BROWSE_UP = 1, OPC_BROWSE_DOWN} OPCBROWSEDIRECTION;

typedef enum { OPC_READABLE = 1, OPC_WRITEABLE } OPCACCESSRIGHTS;

typedef enum { OPC_NOENUM = 0, OPC_ANALOG, OPC_ENUMERATED } OPCEUTYPE;

typedef enum { OPC_STATUS_RUNNING = 1,
               OPC_STATUS_FAILED,
               OPC_STATUS_NOCONFIG,
               OPC_STATUS_SUSPENDED,
               OPC_STATUS_TEST } OPCSERVERSTATE;

typedef enum { OPC_ENUM_PRIVATE_CONNECTIONS = 1,
               OPC_ENUM_PUBLIC_CONNECTIONS,
               OPC_ENUM_ALL_CONNECTIONS,
               OPC_ENUM_PRIVATE,
               OPC_ENUM_PUBLIC,
               OPC_ENUM_ALL } OPCENUMSCOPE;

typedef DWORD OPCHANDLE;

typedef struct {
    DWORD       dwSize;
    DWORD       dwItemCount;
    OPCHANDLE   hClientGroup;
    DWORD       dwTransactionID;
    HRESULT     hrStatus;
} OPCGROUPHEADER;

typedef struct {
    OPCHANDLE   hClient;
    DWORD       dwValueOffset;
    WORD        wQuality;
    WORD        wReserved;
    FILETIME    ftTimeStampItem;
} OPCITEMHEADER1;

typedef struct {
    OPCHANDLE   hClient;
    DWORD       dwValueOffset;
    WORD        wQuality;
    WORD        wReserved;
} OPCITEMHEADER2;

typedef struct {
    DWORD       dwItemCount;
    OPCHANDLE   hClientGroup;
    DWORD       dwTransactionID;
    HRESULT     hrStatus;
} OPCGROUPHEADERWRITE;

typedef struct {
    OPCHANDLE   hClient;
    HRESULT     dwError;
} OPCITEMHEADERWRITE;

typedef struct {
    OPCHANDLE   hClient;
    FILETIME    ftTimeStamp;
    WORD        wQuality;
    WORD        wReserved;
    VARIANT     vDataValue;
} OPCITEMSTATE;

typedef struct {
           FILETIME       ftStartTime;
           FILETIME       ftCurrentTime;
           FILETIME       ftLastUpdateTime;
           OPCSERVERSTATE dwServerState;
           DWORD          dwGroupCount;
           DWORD          dwBandWidth;
           WORD           wMajorVersion;
           WORD           wMinorVersion;
           WORD           wBuildNumber;
           WORD           wReserved;
  [string] LPWSTR         szVendorInfo;
} OPCSERVERSTATUS;

typedef struct {
  [string]              LPWSTR     szAccessPath;
  [string]              LPWSTR     szItemID;
                        BOOL       bActive ;
                        OPCHANDLE  hClient;
                        DWORD      dwBlobSize;
  [size_is(dwBlobSize)] BYTE     * pBlob;
                        VARTYPE    vtRequestedDataType;
                        WORD       wReserved;
} OPCITEMDEF;

typedef struct {
  [string]              LPWSTR     szAccessPath;
  [string]              LPWSTR     szItemID;
                        BOOL       bActive;
                        OPCHANDLE  hClient;
                        OPCHANDLE  hServer;
                        DWORD      dwAccessRights;
                        DWORD      dwBlobSize;
  [size_is(dwBlobSize)] BYTE     * pBlob;
                        VARTYPE    vtRequestedDataType;
                        VARTYPE    vtCanonicalDataType;
                        OPCEUTYPE  dwEUType;
                        VARIANT    vEUInfo;
} OPCITEMATTRIBUTES;

typedef struct {
                        OPCHANDLE  hServer;
                        VARTYPE    vtCanonicalDataType;
                        WORD       wReserved;
                        DWORD      dwAccessRights;
                        DWORD      dwBlobSize;
  [size_is(
dwBlobSize)] BYTE     * pBlob;
} OPCITEMRESULT;


[
  object,
  uuid(39c13a4d-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCServer : IUnknown
{
  HRESULT AddGroup(
    [in, string]        LPCWSTR     szName,
    [in]                BOOL        bActive,
    [in]                DWORD       dwRequestedUpdateRate,
    [in]                OPCHANDLE   hClientGroup,
    [unique, in]        LONG      * pTimeBias,
    [unique, in]        float     * pPercentDeadband,
    [in]                DWORD       dwLCID,
    [out]               OPCHANDLE * phServerGroup,
    [out]               DWORD     * pRevisedUpdateRate,
    [in]                REFIID      riid,
    [out, iid_is(riid)] LPUNKNOWN * ppUnk
    );

  HRESULT GetErrorString(
    [in]          HRESULT  dwError,
    [in]          LCID     dwLocale,
    [out, string] LPWSTR * ppString
    );

  HRESULT GetGroupByName(
    [in, string]        LPCWSTR szName,
    [in]                REFIID riid,
    [out, iid_is(riid)] LPUNKNOWN * ppUnk
    );

  HRESULT GetStatus(
    [out] OPCSERVERSTATUS ** ppServerStatus
    );

  HRESULT RemoveGroup(
    [in] OPCHANDLE hServerGroup,
    [in] BOOL      bForce
    );

  HRESULT CreateGroupEnumerator(
    [in] OPCENUMSCOPE dwScope,
    [in] REFIID       riid,
    [out, iid_is(riid)] LPUNKNOWN* ppUnk
    );

}

[
  object,
  uuid(39c13a4e-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCServerPublicGroups : IUnknown
{
  HRESULT GetPublicGroupByName(
    [in, string]        LPCWSTR     szName,
    [in]                REFIID      riid,
    [out, iid_is(riid)] LPUNKNOWN * ppUnk
    );

  HRESULT RemovePublicGroup(
    [in] OPCHANDLE hServerGroup,
    [in] BOOL      bForce
    );
}


[
  object,
  uuid(39c13a4f-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCBrowseServerAddressSpace: IUnknown
{
  HRESULT QueryOrganization(
    [out] OPCNAMESPACETYPE  * pNameSpaceType
    );

  HRESULT ChangeBrowsePosition(
    [in]         OPCBROWSEDIRECTION dwBrowseDirection,
    [in, string] LPCWSTR            szString
    );

  HRESULT BrowseOPCItemIDs(
    [in]         OPCBROWSETYPE   dwBrowseFilterType,
    [in, string] LPCWSTR         szFilterCriteria,
    [in]         VARTYPE         vtDataTypeFilter,
    [in]         DWORD           dwAccessRightsFilter,
    [out]        LPENUMSTRING  * ppIEnumString
    );

  HRESULT GetItemID(
    [in]          LPWSTR   szItemDataID,
    [out, string] LPWSTR * szItemID
    );

  HRESULT BrowseAccessPaths(
    [in, string] LPCWSTR        szItemID,
    [out]        LPENUMSTRING * ppIEnumString
    );
}



[
  object,
  uuid(39c13a50-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCGroupStateMgt : IUnknown
{
  HRESULT GetState(
    [out]         DWORD     * pUpdateRate,
    [out]         BOOL      * pActive,
    [out, string] LPWSTR    * ppName,
    [out]         LONG      * pTimeBias,
    [out]         float     * pPercentDeadband,
    [out]         DWORD     * pLCID,
    [out]         OPCHANDLE * phClientGroup,
    [out]         OPCHANDLE * phServerGroup
    );

  HRESULT SetState(
    [unique, in]  DWORD     * pRequestedUpdateRate,
    [out]         DWORD     * pRevisedUpdateRate,
    [unique, in]  BOOL      * pActive,
    [unique, in]  LONG      * pTimeBias,
    [unique, in]  float     * pPercentDeadband,
    [unique, in]  DWORD     * pLCID,
    [unique, in]  OPCHANDLE * phClientGroup
    );

  HRESULT SetName(
    [in, string] LPCWSTR szName
    );

  HRESULT CloneGroup(
    [in, string]        LPCWSTR     szName,
    [in]                REFIID      riid,
    [out, iid_is(riid)] LPUNKNOWN * ppUnk
    );
}



[
  object,
  uuid(39c13a51-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCPublicGroupStateMgt : IUnknown
{
  HRESULT GetState(
    [out] BOOL * pPublic
    );

  HRESULT MoveToPublic(
    void
    );
}



[
  object,
  uuid(39c
13a52-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCSyncIO : IUnknown
{
  HRESULT Read(
    [in]                        OPCDATASOURCE   dwSource,
    [in]                        DWORD           dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE     * phServer,
    [out, size_is(,dwNumItems)] OPCITEMSTATE ** ppItemValues,
    [out, size_is(,dwNumItems)] HRESULT      ** ppErrors
    );

  HRESULT Write(
    [in]                        DWORD        dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE  * phServer,
    [in, size_is(dwNumItems)]   VARIANT    * pItemValues,
    [out, size_is(,dwNumItems)] HRESULT   ** ppErrors
    );
}

[
  object,
  uuid(39c13a53-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCAsyncIO : IUnknown
{
  HRESULT Read(
    [in]                        DWORD           dwConnection,
    [in]                        OPCDATASOURCE   dwSource,
    [in]                        DWORD           dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE     * phServer,
    [out]                       DWORD         * pTransactionID,
    [out, size_is(,dwNumItems)] HRESULT      ** ppErrors
    );

  HRESULT Write(
    [in]                        DWORD       dwConnection,
    [in]                        DWORD       dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE * phServer,
    [in, size_is(dwNumItems)]   VARIANT   * pItemValues,
    [out]                       DWORD     * pTransactionID,
    [out, size_is(,dwNumItems)] HRESULT ** ppErrors
    );

  HRESULT Refresh(
    [in]  DWORD           dwConnection,
    [in]  OPCDATASOURCE   dwSource,
    [out] DWORD         * pTransactionID
    );

  HRESULT Cancel(
    [in] DWORD dwTransactionID
    );

}


[
  object,
  uuid(39c13a54-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IOPCItemMgt: IUnknown
{
  HRESULT AddItems(
    [in]                        DWORD            dwNumItems,
    [in, size_is(dwNumItems)]   OPCITEMDEF     * pItemArray,
    [out, size_is(,dwNumItems)] OPCITEMRESULT ** ppAddResults,
    [out, size_is(,dwNumItems)] HRESULT       ** ppErrors
    );

  HRESULT ValidateItems(
    [in]                        DWORD             dwNumItems,
    [in, size_is(dwNumItems)]   OPCITEMDEF      * pItemArray,
    [in]                        BOOL              bBlobUpdate,
    [out, size_is(,dwNumItems)] OPCITEMRESULT  ** ppValidationResults,
    [out, size_is(,dwNumItems)] HRESULT        ** ppErrors
    );

  HRESULT RemoveItems(
    [in]                        DWORD        dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE  * phServer,
    [out, size_is(,dwNumItems)] HRESULT   ** ppErrors
    );

  HRESULT SetActiveState(
    [in]                        DWORD        dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE  * phServer,
    [in]                        BOOL         bActive,
    [out, size_is(,dwNumItems)] HRESULT   ** ppErrors
    );

  HRESULT SetClientHandles(
    [in]                        DWORD        dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE  * phServer,
    [in, size_is(dwNumItems)]   OPCHANDLE  * phClient,
    [out, size_is(,dwNumItems)] HRESULT   ** ppErrors
    );

  HRESULT SetDatatypes(
    [in]                        DWORD        dwNumItems,
    [in, size_is(dwNumItems)]   OPCHANDLE  * phServer,
    [in, size_is(dwNumItems)]   VARTYPE    * pRequestedDatatypes,
    [out, size_is(,dwNumItems)] HRESULT   ** ppErrors
    );

  HRESULT CreateEnumerator(
    [in]                REFIID      riid,
    [out, iid_is(riid)] LPUNKNOWN * ppUnk
    );
}


[
  object,
  uuid(39c13a55-011e-11d0-9675-0020afd8adb3),
  pointer_default(unique)
]
interface IEnumOPCItemAttributes : IUnknown
{
  HRESULT Next(
    [in]  ULONG celt,
    [out, size_is(,*pceltFetched)] OPCITEMATTRIBUTES ** ppItemArray,
    [out] ULONG * pceltFetched
    );

  HRESULT Skip(
    [in] ULONG celt
    );

  HRESULT Reset(
    void
    );

  HRESULT Clone(
    [out] IEnumOPCItemAttributes ** ppEnumItemAttributes
    );
}



From: darnis  
Subject: Re: How can I import a IDL file to DELPHI Project?
NewsGroup: borland.public.delphi.oleautomation
Date Posted: 15-Jun-2005 at 9:54:32 PST
> I had a go at this too, and at using midl, but there are some
> problems, as this IDL is not in the correct format.
>
> I have used the OPC client interfaces, and they are all automation
> compatible.  What puzzles me most about this one - given that OPC
> stands for "OLE for Process Control" - is that these are not
> automation compatible types in this IDL.
>
> At the very least, it needs to be wrapped in something like:
>
> [
>   uuid(F2F13D0C-0A82-420A-8F45-F1E63BAC30AC),
>   version(1.0),
>   helpstring("OPC Server Type library")
> ]
> library OPCServer
> {
>
>     ... // all the IDL // ...
>
> };

I want to plan the OPC Server use delphi.
In Delphi7, I do this

> [
>   uuid(F2F13D0C-0A82-420A-8F45-F1E63BAC30AC),
>   version(1.0),
>   helpstring("OPC Server Type library")
> ]
> library OPCServer
> {
>
>     ... // all the IDL // ...
>
> };

there is a error "Unexpected identifier" when i save the type library.
And it seems that any change in tab "Text" bring on this error.
Why ? How about to wrap the IDL?


thanks,
darnis



From: darnis  
Subject: Re: How can I import a IDL file to DELPHI Project?
NewsGroup: borland.public.delphi.oleautomation
Date Posted: 15-Jun-2005 at 9:53:57 PST
> the Type Library Viewer (make a new Type Library or ActiveX server project
> to enable it [it's located at Project menu I think]) has "Text" tab and an
> option to not be
> "read only" so that you can edit the IDL text
>
> at Delphi environment options there's also a Type Library tab with option
to
> use IDL or Pascal, set it to use IDL there
>
> cheers,
> George
>

Thank a lot.

The problem is same to John Carlyle-Clarke.



From: John Carlyle-Clarke  
Subject: Re: How can I import a IDL file to DELPHI Project?
NewsGroup: borland.public.delphi.oleautomation
Date Posted: 14-Jun-2005 at 16:1:33 PST
"George Birbilis"  wrote in
news:42aee7bc@newsgroups.borland.com: 

>>    I have a problem how can I import the third provide IDL file?
>>    For 
>> example, the OPC Server's IDL file from www.opcfoundation.org ,
>> how can I import it to my project?
>>
>>
>>   OPC.IDL is download from opcfoundation. It's attached
>>   following. 
>>
> 
> the Type Library Viewer (make a new Type Library or ActiveX server
> project to enable it [it's located at Project menu I think]) has
> "Text" tab and an option to not be
> "read only" so that you can edit the IDL text
> 
> at Delphi environment options there's also a Type Library tab with
> option to use IDL or Pascal, set it to use IDL there

I had a go at this too, and at using midl, but there are some 
problems, as this IDL is not in the correct format.

I have used the OPC client interfaces, and they are all automation 
compatible.  What puzzles me most about this one - given that OPC 
stands for "OLE for Process Control" - is that these are not 
automation compatible types in this IDL.

At the very least, it needs to be wrapped in something like:

[
  uuid(F2F13D0C-0A82-420A-8F45-F1E63BAC30AC), 
  version(1.0), 
  helpstring("OPC Server Type library")
]
library OPCServer
{

    	... // all the IDL // ...

};


From: George Birbilis  
Subject: Re: How can I import a IDL file to DELPHI Project?
NewsGroup: borland.public.delphi.oleautomation
Date Posted: 14-Jun-2005 at 17:20:38 PST
>    I have a problem how can I import the third provide IDL file? For
> example, the OPC Server's IDL file from www.opcfoundation.org , how can I
> import it to my project?
>
>
>   OPC.IDL is download from opcfoundation. It's attached following.
>

the Type Library Viewer (make a new Type Library or ActiveX server project 
to enable it [it's located at Project menu I think]) has "Text" tab and an 
option to not be
"read only" so that you can edit the IDL text

at Delphi environment options there's also a Type Library tab with option to 
use IDL or Pascal, set it to use IDL there

cheers,
George

-----
George Birbilis (birbilis@kagi.com)
Microsoft Most Valuable Professional
MVP J# for 2004 & 2005
http://www.kagi.com/birbilis
QuickTime, Delphi, ActiveX, .NET, IPC
http://www.mech.upatras.gr/~robgroup
Robotics