vignesh
vignesh

Reputation: 97

OPC-DA AddGroup not working by using "TitaniumAS.Opc.Client" c# library

I'm getting a NULL reference error while adding the group. ie: in line -> opcDaGroup = server.AddGroup("Group"); Please help me out what's the issue and how to overcome the same. whether this is the DCOM access issue.

enter image description here

Code: public OpcDaGroup opcDaGroup;

private void StartConnection(string Cls_Id, string Machine_IpAddress)
{
    try
    {
        log.Debug("START - Starting the connection");
        Uri url = UrlBuilder.Build(Cls_Id, Machine_IpAddress);
        server = new OpcDaServer(url);
        server.Connect();
        log.Debug("END   - Starting the connection");
    }
    catch (Exception e)
    {
        log.Error("Could not connect to the OPC server for the IpAddress: {0}", e);
    }
}

public OpcDaAdapterThreadImpl(string Cls_Id, string Machine_IpAddress, string name, ICollection<TagConfigurationModel> tags)
{
    this.Cls_Id = Cls_Id;
    this.Machine_IpAddress = Machine_IpAddress;
    this.name = name;
    this.AdapterReady = true;
    Tags = tags;
    var group = tags.GroupBy(c => new { ItemName = c.TagName }).Select(c => c.Key).Distinct();
    grouptags = group.Select(c => new TagConfigurationModel { TagName = c.ItemName }).ToList();
    opcTagItems = grouptags.Select(c => new OpcDaItemDefinition { ItemId = c.TagName, IsActive = true }).ToList();
    // Connection Initializing
    StartConnection(Cls_Id, Machine_IpAddress);
    if (server.IsConnected)
    {
        // Add group to the server
        opcDaGroup = server.AddGroup("Group");
        opcDaGroup.IsActive = true;

        // Add Items to group
        opcDaGroup.AddItems(opcTagItems);
    }
}

Upvotes: 1

Views: 493

Answers (0)

Related Questions