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.

Window Service and OPC Subscription

More
04 Apr 2017 08:46 #5067 by support
Version 2016.2 can be installed alongside 5.23 and they should not conflict.

Regards

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

More
04 Apr 2017 08:22 #5066 by LuisGar
Can I have both versions installed in my development computer?

Since I already said, those objects are used by another applications which we are also developing and already installing in some production machines.

Those same objects are being used by this service to monitor some others variables collected by the PLC, so changing the version of OPC right is complicated.

The objects mentioned worked without any problem in the Application, but I am having problems to get the events in the service.

Regards

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

More
03 Apr 2017 08:08 #5061 by support
Can you make just a simple application with the current version, to see if it behaves differently? This way, you would know whether the upgrade is worth it.

Note that the newer version do not have the "MultipleItemsChanged" event; there is just an "ItemChanged" event, delivering each change separately. So you will not have to loop over the array. This event has been removed because it was left-over from earlier COM interfaces/versions, but was actually no longer bringing any performance benefit, for which it was originally introduced.

Also, just to be absolutely sure, have you checked that by some kind of simple bug, it's not the line below that is throwing away all the notifications when run on the test machine?
if (DesignHelpers.IsDesignTime) return;

Regards

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

More
30 Mar 2017 09:44 #5055 by LuisGar
QuickOPC 5.23 Build 1371.1

We had a problem with this version some months ago, you recommend me to move to a newer version, which implies to Update our version of Visual Studio, since we have VS10, and it does not support newer .NET Framework, at the moment we are working with .NET Framework 4,

We were planning to get a newer version of VS, but we need to check which are the changes in the application that we have to do.

www.opclabs.com/forum/browsing/1437-opcbrowsedialog-bug

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

More
30 Mar 2017 09:34 #5054 by support
Before we go into further details - which version of QuickOPC are you using? It looks like that it is something fairly old.

Regards

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

More
30 Mar 2017 09:16 #5053 by LuisGar
By the way, I use exactly the same objects in an application, not a service, and they work without any problem

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

More
30 Mar 2017 09:15 - 30 Mar 2017 09:21 #5052 by LuisGar
This is basically the code which perform the task,

In the event I launch, I save the status of my alarms in a database, I got the status from the first read in the database, but the events which come afterwards I just dont get any data.
private static void SubscribeItems()
        {
           DateTime now = DateTime.Now;
 
            ExceptionHandler.LogException(new Exception("Start Subscribe Alarms OPC " + DateTime.Now.ToString()));
 
            List<DAReadItemArguments> ListReadItemsArguments = new List<DAReadItemArguments>();
 
            //subscribe all the alarms to the OPC server
            foreach (Alarm AlarmItem in ListOfAlarms)
            {
                ListReadItemsArguments.Add(new DAReadItemArguments(AlarmItem.OPCDescriptor.MachineName,
                                                                   AlarmItem.OPCDescriptor.ServerName,
                                                                   AlarmItem.OPCDescriptor.OPCItem, 0));
 
 
            }
 
            DAVtqResult[] _DAVtq;
 
            _DAVtq = new DAVtqResult[ListReadItemsArguments.Count];
 
            _DAVtq = OPCClient.ReadMultipleItems(ListReadItemsArguments.ToArray());
			//This Read works correctly /////////////////////
 
            ExceptionHandler.LogException(new Exception("Read Alarms OPC " + (DateTime.Now - now).ToString()));
 
            int i = 0;
 
            foreach (Alarm AlarmItem in ListOfAlarms)
            {
                if (_DAVtq[i] != null && _DAVtq[i].Succeeded && _DAVtq[i].Vtq != null)
                {
                    if (_DAVtq[i].Vtq.Value != null)
                    {
                        AlarmItem.State = (Alarm.AlarmState)(Convert.ToInt16(_DAVtq[i].Vtq.Value));
                    }
                    else
                    {
                        AlarmItem.State = Alarm.AlarmState.Inactive;
                    }
                }
                i++;
            }
 
            ExceptionHandler.LogException(new Exception("fire Alarms OPC event 1st time " + (DateTime.Now - now).ToString()));
 
            // raise the AlarmEvent:
            OnGlobalAlarmsEvent(null, new AlarmSignalEventArgs(ListOfAlarms));
 
            OPCClient.UnsubscribeAllItems();
 
            ExceptionHandler.LogException(new Exception("Subscribe OPC Alarms " + (DateTime.Now - now).ToString()));
 
            //subscribe all the alarms to the OPC server
            foreach (Alarm AlarmItem in ListOfAlarms)
            {
                int SubscriptionID = OPCClient.SubscribeItem(AlarmItem.OPCDescriptor.MachineName, AlarmItem.OPCDescriptor.ServerName, AlarmItem.OPCDescriptor.OPCItem, 50, null);
                //copy the subscription ID, to know later which alarm fired the OPC event
                AlarmItem.OPCDescriptor.SubscriptionID = SubscriptionID;
            }
 
            OPCClient.MultipleItemsChanged += new EventHandler<EasyDAMultipleItemsChangedEventArgs>(OPCClient_MultipleItemsChanged);
 
            ExceptionHandler.LogException(new Exception("END OPC Alarms " + ( DateTime.Now - now ).ToString()));
        }
    }
 
 
	    /// <summary>
        /// Handles the event that occurs if at least one OPC Alarm variable changed its state (from true to false or vice versa)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OPCClient_MultipleItemsChanged(object sender, EasyDAMultipleItemsChangedEventArgs e)
        {
            if (DesignHelpers.IsDesignTime) return;
 
            lock (ListOfAlarms)
            {
 
                foreach (Alarm AlarmItem in ListOfAlarms)
                {
                    //bool changed = false;
 
                    //Search for all the arguments given in the opc event, which are actives and look for the alarm that fired that event
                    foreach (EasyDAItemChangedEventArgs TempEventArg in e.ArgsArray)
                    {
                        // if the Subscription ID was found, and the Argument is value then set the status of the alarm
                        if ((AlarmItem.OPCDescriptor.SubscriptionID == TempEventArg.Handle) && (TempEventArg.Vtq != null))
                        {
                            Alarm.AlarmState TempValue = (Alarm.AlarmState)(Convert.ToInt16(TempEventArg.Vtq.Value));
 
                        }
 
                    }
                }
            }
 
            // raise the AlarmEvent:
            OnGlobalAlarmsEvent(null, new AlarmSignalEventArgs(ListOfAlarms));
 
			////////This event is not fired
        }

Best Regards.
Last edit: 30 Mar 2017 09:21 by support.

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

More
29 Mar 2017 11:38 #5046 by support
Hello.

Can you post a code of your event handler code here, or at least its "skeleton" where the logic can be seen?

What I want to verify is whether the error checking is done right.

You are supposed to get SOME event notification even in case of problems/failures. In case of configuration issues (and thus also security-related errors), you should still get an event which carries the necessary error information. So I find it the described behavior unusual.

Thank you

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

More
28 Mar 2017 09:59 #5042 by LuisGar
Hi

I am developing a new Windows service to monitor some OPC variables periodically. The service seems to work correctly in the computer where I am developing, It reads the OPC items at the start, and later on, it makes a subscription to those items to check any status change of those same items. So far everything seems ok, but at the moment when I install the service in my test environment, the service does not work as desired, It performs the initial read, which is performed by OPCClient.ReadMultipleItems(ListReadItemsArguments.ToArray());

but the events from the OPC are not fired, I have logged every time when the event is fired, In the development machine it works ok, but in the test machine it does not log anything.

I think it should be a problem with the settings between the user used in developing computer and the user used in the test computer, but even installing the service and logging with the administration account, does I have the same problem

Do you have any recommendation that I should follow...

Thanks in advance

Luis Garcia.

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

Moderators: support
Time to create page: 0.071 seconds