Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Subscribe items from windows services

More
31 Jul 2014 15:35 #2116 by support
I do not see anything wrong with your code, assuming that RaiseItemRead != null, and that InfoBaseClass.ShowInfo(...) would somehow indicate that there is a problem.

I know you mentioned DCOM configured, so are you connecting to a remote server?

If not, have you tried the same locally?

Have you tried the different settings for:
  1. EasyDAClient.ClientParameters.UseCustomSecurity
  2. EasyDAClient.ClientParameters.TurnOffActivationSecurity
  3. EasyDAClient.ClientParameters.TurnOffCallSecurity

Best regards

Please Log in or Create an account to join the conversation.

More
30 Jul 2014 22:18 - 31 Jul 2014 15:22 #2112 by barbieri
The same code is in a DLL that is used both by the Windows form application and by the service.
Both start a separated thread that subscribe the item so, theoretically there is no difference from the code side.

An example of the code:

in the subscribe thread, for each item into my DB:
...
ret = TheOPC.SubscribeItem(tag.Machine, tag.Server, tag.TAG, tag.UpdateRate, ITAG);
...
 
 
public static int SubscribeItem(string MachineName, string ServerClass, string ItemID, int UpdateRate, object state)
{
    return MyEasyDAClient.SubscribeItem(MachineName, ServerClass, ItemID, UpdateRate, state);
}
 
....
 
MyEasyDAClient.ItemChanged += new EventHandler<EasyDAItemChangedEventArgs (MyEasyDAClient_ItemChanged);
 
...
 
private static void MyEasyDAClient_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
{
 if (RaiseItemRead != null && e != null)
 {
   if (e.Vtq != null)
    {
      RaiseItemRead(e.Vtq.Value, e.State);
     }
     else if (e.Exception != null)
     {
       InfoBaseClass.ShowInfo(e.Exception.Message);
     }
  }
}
 
 
...

The RaiseItemRead function write the value inside the DB.

THe parameters of the OPC Client are below but I've tested also with different values:
  public class OPCParameters 
    {
        public int MachineReconnectDelay = 1000;
 
        public bool AllowAsynchronousMethod = true;
        public bool AllowSynchronousMethod = false; //TASK_625
        public bool Isolated = true;
        public int ItemDetach = 5000;
        public int ServerDetach = 30000; // ERA 30000
        public int TopicRead = 5000; // ERA 120000
        public int TopicWrite = 5000; // ERA 120000
 
        internal DAReadWriteMethod IDesiredMethod = DAReadWriteMethod.Synchronous; //TASK_625
        public int BrowseAccessPaths = 10000;
        public int BrowseNodes = 25000;
        public int BrowseProperties = 20000;
        public int BrowseServers = 20000;
        public int GetProperty = 3000;
        public int ReadItem = 3000; // TASK_OPC
        public int WriteItem = 10000;
        public int ReadAutomatic = -1;
        public int WriteAutomatic = -1;
 
        public int DesiredMethod
        {
            get
            {
                return (int)IDesiredMethod;
            }
            set
            {
                IDesiredMethod = (DAReadWriteMethod) value;
            }
        }
    }
Last edit: 31 Jul 2014 15:22 by support. Reason: code formatting

Please Log in or Create an account to join the conversation.

More
30 Jul 2014 16:30 #2108 by support
It looks like that we are not receiving the callback from the server. If the server thinks it is sending it to us, it may also be "lost" somewhere in the DCOM infrastructure, although in that case I would expect that the callback will return an error code to the server. But not all servers will report it as a problem.

Just to be sure, can you post a piece of code that handles the event, or relevant parts of it?

And, can you can confirm that the SAME code does work well from the Windows Forms app?

Please Log in or Create an account to join the conversation.

More
25 Jul 2014 19:46 #2102 by barbieri
Tomorrow I will try with different settings.
I've checked the logs of the server and seems that the tag has been correctly subscribed, the callback is sanded on value change but the data_change event is not raised.

Please Log in or Create an account to join the conversation.

More
25 Jul 2014 18:31 #2101 by support
Can you please try different settings of QuickOPC security parameters, as described at the bottom of this thread:http://www.opclabs.com/forum/connections-reconnections-com-dcom/1244-connecting-to-remote-machines-via-code-quickopc-dcom

Note: It is unlikely that the event is not fired at all. Isn't it coming, but with a non-null Exception property in the event argumens?

Please Log in or Create an account to join the conversation.

More
24 Jul 2014 22:32 - 25 Jul 2014 06:35 #2099 by barbieri
Hello all,
I want to subscribe a TAG value from opc server with a subscribe operation.

e.g.
EasyDAClient.SubscribeItem(MachineName, ServerClass, ItemID, UpdateRate, state);

I am able to do it through a windows form client without any issue.


But when I am trying to do the same from windows service, the change event is not fired.

I've already modified the DCOM configuration according to: xlreporter.net/download/OPC_and_DCOM.pdf but the issue is still there.
I've modified the user who run the service from system to local admin to domain admin... nothing change.

I'm working with EasyOPC v5.23 on a windows server 2008.
I'm trying to connect to a Keepware OPC server and to a Simatic OPC server.

The read-write operation without subscription works well.

Can you help me?
Last edit: 25 Jul 2014 06:35 by barbieri.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.056 seconds