View Issue Details

IDProjectCategoryView StatusLast Update
0000019.NET APIImplementation Bugpublic2007-02-10 03:48
ReporterRandy Armstrong Assigned ToRandy Armstrong  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0000019: Flat Address Space Browsing does not work
Description

I tested my app which browses DA Servers (and also the sample DA client) against a known "flat" server (Honeywell PHD OPC Server)
Your DA client and my application both return the same error upon DAServer.Browse: E_UNKNOWN_ITEM_NAME
Both programs worked before the latest .Net API update.

Additional Information

Randy,

I made the changes you suggested.
One problem still...

  // check that root is browsed for flat address spaces.

  if (itemID.ItemName != null && itemID.ItemName.Length > 0)

  {

        throw new ResultIDException(ResultID.Da.E_UNKNOWN_ITEM_NAME);

  }

At the "if" above, itemID is null and an exception is thrown attempting to access itemID.ItemName
I changed the code as follows and all is well:
if (itemID != null && (itemID.ItemName != null && itemID.ItemName.Length > 0) )

-Dane


From: Randy Armstrong [mailto:randy.armstrong@opcfoundation.org]
Sent: Tuesday, November 29, 2005 3:51 PM
To: dane@exele.com
Subject: RE: More info...

Hi Dane,

The checks for flat address space were moved up one level in the function stack. Unfortunately, I omitted a check when I moved the code. The following changes should fix the problem:

private BrowseElement[] GetElements(

  int                            elementsFound,

  ItemIdentifier                 itemID, 

  BrowseFilters                  filters, 

  bool                           branches, 

  ref OpcCom.Da20.BrowsePosition position)

...

// return an empty list if requesting branches for a flat address space.

if (namespaceType == OPCNAMESPACETYPE.OPC_NS_FLAT)

{

  if (branches)

  {

        return new BrowseElement[0];

  }

  // check that root is browsed for flat address spaces.

  if (itemID.ItemName != null && itemID.ItemName.Length > 0)

  {

        throw new ResultIDException(ResultID.Da.E_UNKNOWN_ITEM_NAME);

  }

}

// get the enumerator.

enumerator = GetEnumerator((itemID != null)?itemID.ItemName:null, filters, branches, namespaceType == OPCNAMESPACETYPE.OPC_NS_FLAT);

...

private EnumString GetEnumerator(string itemID, BrowseFilters filters, bool branches, bool flat)

{

  IOPCBrowseServerAddressSpace browser = (IOPCBrowseServerAddressSpace)m_server;

  if (!flat)

  {

        // move to the specified branch for hierarchial address spaces.

        try

        {

              browser.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_TO, (itemID != null)?itemID:"");

        }

        catch

        {

              // attempt to browse down if browse to fails (needed to support some non-compliant servers). 

              try

              {

                    browser.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_DOWN, (itemID != null)?itemID:"");

              }

              catch

              {

                    throw new ResultIDException(ResultID.Da.E_UNKNOWN_ITEM_NAME);

              }

        }

  }

  ...

}


From: Dane Overfield [mailto:dane@exele.com]

Sent: November 29, 2005 12:01 PM

To: 'Randy Armstrong'

Subject: More info...

Randy,

Here is some more detail on the flat server problem.

I ran the older .Net API 1.3 code vs. the new to see the difference.

The problem is in

private EnumString GetEnumerator(string itemID, BrowseFilters filters, bool branches)

OLD 1.3 Code:

checks the organization (browser.queryorganization)

If hierarchical, performs a browser.ChangeBrowsePosition

NEW 1.3 Code:

Does not check organization (browser.queryorganization)

Performs a browser.ChangeBrowsePosition against a Flat space which causes the error

Here are the routines: you can see that the first few lines are not the same

Old Code:

private EnumString GetEnumerator(string itemID, BrowseFilters filters, bool branches)

{

IOPCBrowseServerAddressSpace browser = (IOPCBrowseServerAddressSpace)m_server;

// check the server address space type.

OPCNAMESPACETYPE namespaceType = OPCNAMESPACETYPE.OPC_NS_HIERARCHIAL;

try

{

browser.QueryOrganization(out namespaceType);

}

catch (Exception e)

{

throw OpcCom.Interop.CreateException("IOPCBrowseServerAddressSpace.QueryOrganization", e);

}

// move to the specified branch for hierarchial address spaces.

if (namespaceType == OPCNAMESPACETYPE.OPC_NS_HIERARCHIAL)

{

try

{

 browser.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_TO, (itemID != null)?itemID:"");

}

catch

{

 // attempt to browse down if browse to fails (needed to support some non-compliant servers). 

 try

 {

  browser.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_DOWN, (itemID != null)?itemID:"");

 }

 catch

 {

  throw new ResultIDException(ResultID.Da.E_UNKNOWN_ITEM_NAME);

 }

}

}

// generate error for any value other that the 'root' item for flat address spaces.

else

{

if (itemID != null && itemID != "")

{

 throw new ExternalException("Invalid item id for branch.", OpcCom.Da.ResultIDs.E_FAIL);

}

}

try

{

// create the enumerator.

OpcRcw.Da.IEnumString enumerator = null;

browser.BrowseOPCItemIDs(

 (branches)?OPCBROWSETYPE.OPC_BRANCH:OPCBROWSETYPE.OPC_LEAF,

 (filters.ElementNameFilter != null)?filters.ElementNameFilter:"",

 (short)VarEnum.VT_EMPTY,

 0,

 out enumerator);

// return the enumerator.

return new EnumString(enumerator);

}

catch

{

throw new ResultIDException(ResultID.Da.E_UNKNOWN_ITEM_NAME);

}

}

New Code

private EnumString GetEnumerator(string itemID, BrowseFilters filters, bool branches)

{

IOPCBrowseServerAddressSpace browser = (IOPCBrowseServerAddressSpace)m_server;

// move to the specified branch for hierarchial address spaces.

try

{

browser.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_TO, (itemID != null)?itemID:"");

}

catch

{

// attempt to browse down if browse to fails (needed to support some non-compliant servers). 

try

{

 browser.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_DOWN, (itemID != null)?itemID:"");

}

catch

{

 throw new ResultIDException(ResultID.Da.E_UNKNOWN_ITEM_NAME);

}

}

try

{

// create the enumerator.

OpcRcw.Da.IEnumString enumerator = null;

browser.BrowseOPCItemIDs(

 (branches)?OPCBROWSETYPE.OPC_BRANCH:OPCBROWSETYPE.OPC_LEAF,

 (filters.ElementNameFilter != null)?filters.ElementNameFilter:"",

 (short)VarEnum.VT_EMPTY,

 0,

 out enumerator);

// return the enumerator.

return new EnumString(enumerator);

}

catch

{

throw new ResultIDException(ResultID.Da.E_UNKNOWN_ITEM_NAME);

}

}

TagsNo tags attached.

Activities

Randy Armstrong

2007-02-10 03:48

administrator   ~0000154

Fixed in release 2.00.1.00.

Issue History

Date Modified Username Field Change
2005-12-12 23:34 Randy Armstrong New Issue
2005-12-12 23:35 Randy Armstrong Status new => assigned
2005-12-12 23:35 Randy Armstrong Assigned To => Randy Armstrong
2007-02-10 03:48 Randy Armstrong Status assigned => resolved
2007-02-10 03:48 Randy Armstrong Resolution open => fixed
2007-02-10 03:48 Randy Armstrong Note Added: 0000154