public bool GetEventAttributes(
int categoryId,
out int[] attributeIds,
out string[] descriptions,
out short[] datatypes)
{
string methodName = "IOPCEventServer.QueryEventAttributes";
int count = 0;
IntPtr pAttributeIds = IntPtr.Zero;
IntPtr pDescriptions = IntPtr.Zero;
IntPtr pDataTypes = IntPtr.Zero;
try
{
IOPCEventServer server = BeginComCall<IOPCEventServer>(methodName, true);
server.QueryEventAttributes(
categoryId,
out count,
out pAttributeIds,
out pDescriptions,
out pDataTypes);
}
catch (Exception e)
{
ComCallError(methodName, e);
}
finally
{
EndComCall(methodName);
}
// unmarshal results.
attributeIds = ComUtils.GetInt32s(ref pAttributeIds, count, true);
descriptions = ComUtils.GetUnicodeStrings(ref pDescriptions, count, true);
datatypes = ComUtils.GetInt16s(ref pDataTypes, count, true);
// remove the AREAS attribute which is never exposed.
for (int ii = 0; ii < count; ii++)
{
if (String.Compare(descriptions[ii], "AREAS", StringComparison.OrdinalIgnoreCase) == 0)
{
int[] attributeIds2 = new int[count-1];
string[] descriptions2 = new string[count-1];
short[] datatypes2 = new short[count-1];
if (ii > 0)
{
Array.Copy(attributeIds, attributeIds2, ii);
Array.Copy(descriptions, descriptions2, ii);
Array.Copy(datatypes, datatypes2, ii);
}
if (ii < count-1)
{
Array.Copy(attributeIds, ii+1, attributeIds2, ii, count-ii-1);
Array.Copy(descriptions, ii+1, descriptions2, ii, count-ii-1);
Array.Copy(datatypes, ii+1, datatypes2, ii, count-ii-1);
}
attributeIds = attributeIds2;
descriptions = descriptions2;
datatypes = datatypes2;
break;
}
}
return count > 0;
}
#endregion