Hello
In my net framework 4.7.2 project with OPCLabs V5.71 I can browse servers, browse nodes and also read items of remote OPC DA servers. Browsing servers is done relative quickly (1-2 seconds). But the problem is, that browsing nodes and reading items takes extremly long. With the code below, browsing nodes takes more then 30 seconds, reading items takes more then 40 seconds. For testing I have tried directly reading items without browsing servers and nodes (because I know server name and node name I have written these directly in the item definition). But the result was the same: I got the item values after more then 40 seconds.
I can definitly say that there is no network speed problem, and it should be also not machine specific problem because I have tried on many different machines.
But when OPC items are read cyclic, there is no problem in reading for example 1 second cycle. What takes so long during the first connection or initialising?
Its like, all the tags are browsed, even if I read directly items (without browsing servers and nodes
Is there a way to shorten this time? Or is this waiting while first connection unavoidable?
internal class Program
{
static void Main(string[] args)
{
Program program = new Program();
ComManagement.Instance.Configuration.InstantiationParameters.OverrideDefaultSecurity = false;
ComManagement.Instance.Configuration.SecurityParameters.UseCustomSecurity = true;
ComManagement.Instance.Configuration.SecurityParameters.TurnOffCallSecurity = true;
program.Browse_Servers(); // takes 1-2 seconds
program.Browse_nodes(); // takes more then 30 seconds
program.Read_single_item(); // takes more then 40 seconds
}
public void Browse_Servers()
{
var client = new EasyDAClient();
ServerElementCollection serverElements;
try
{
Console.WriteLine("Browsing servers");
serverElements = client.BrowseServers("10.92.120.174");
}
catch (OpcException opcException)
{
//fault handling
}
foreach (ServerElement serverElement in serverElements)
{
Console.WriteLine($"ServerElements(\"{serverElement.ClsidString}\").ProgId: {serverElement.ProgId}");
}
}
void Browse_nodes()
{
Console.WriteLine("Browsing nodes");
var client = new EasyDAClient();
DANodeElementCollection branchElements;
try
{
branchElements = client.BrowseBranches("10.92.120.174", "OPC.IwSCP.1", "");
Console.WriteLine(branchElements);
}
catch (OpcException opcException)
{
//fault handling
return;
}
foreach (DANodeElement branchElement in branchElements)
{
Console.WriteLine($"BranchElements(\"{branchElement.Name}\").HasChildren: {branchElement.HasChildren}");
}
}
void Read_single_item()
{
Console.WriteLine("Read items");
var client = new EasyDAClient();
DAVtqResult[] vtqResults = client.ReadMultipleItems("opcda://" + "10.92.120.174" + "/OPC.IwSCP.1", new DAItemDescriptor[]
{
//System Info
"!BSTR,"+OPC_device_name+",System.HardwareDescription",
"!BSTR,"+OPC_device_name+",Plc.FirmwareVersion",
"!BSTR,"+OPC_device_name+",Firmware.DeviceFirmware{0,0}",
});
for (int i = 0; i < vtqResults.Length; i++)
{
Debug.Assert(vtqResults[i] != null);
if (vtqResults[i].Succeeded)
{
Console.WriteLine("vtqResults[{0}].Vtq: {1}", i, vtqResults[i].Vtq);
}
else
{
//fault handling
}
}
Console.ReadLine();
}
}