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.

convert eventargs in delphi

More
08 Feb 2018 06:44 - 08 Feb 2018 06:44 #5996 by support
Replied by support on topic convert eventargs in delphi
Yes, the event args are big, and it is usually enough to transfer just parts of it. In fact, all its parts are serializable/deserializable in the same way as described for the whole event args, if you wanted to use that way.

Yes, properties like HasGoodStatus, HasBadStatus, HasValue are read-only. This is because they are just conditions made on top of other parts UAAttributeData - specifically, the StatusCode. I suggest that instead of trying to transfer there, you simply transfer the StatusCode. It is read/write, so you can restore it afterwards, and at the same time, the HasGoodStatus etc. properties will be restored automatically.

The StatusCode itself is of UAStatusCode type, but that's just a convenience wrapper over a 32-bit unsigned integer. So what you actually end up transferring would be the StatusCode.InternalValue.

One final gotcha: The InternalValue mentioned above is actually declared as 64-bit signed integer. This is because some languages (such as VB, VB.NET) cannot handle 32-bit unsigned integers. Therefore the property is declared wider, but it never contains a value outside of 32-bit unsigned integer range, and you can safely transfer just the low 32 bits and/or convert it to unsigned 32-bit integer.
Last edit: 08 Feb 2018 06:44 by support.

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

More
07 Feb 2018 21:13 #5990 by alr1976
Replied by alr1976 on topic convert eventargs in delphi
Hi!

I sent to remote computer few data so sent all eventargs take bytes that don t need(I m using very slow connection and pay to use satellite upload/download.
I have found a way but my problem is :
1)I sent data to remotecomputer (only value,hasgood/hasbad).
2) in remote pc I create eventargs and insert value succeed and servertimestamp
my problem is when create
attribute := coUAAttributeData.Create;
hasgood,hasbad,hasvalue are readonly and I can t insert my data
is not possible change these data also if I have readonly?

Thanks Alessandro

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

More
07 Feb 2018 19:21 - 07 Feb 2018 19:24 #5987 by support
Replied by support on topic convert eventargs in delphi
If this was in .NET, the answer would be relatively easy: Most our objects, including EasyUADataChangeNotificationEventArgs, support [Serializable]/ISerializable, and can therefore be easily stored into a binary stream or retrieved from it.

It was not really our design goal to also support serialization for COM languages and tools, but (depending on the language), it might be possible to achieve that (but we have never tried so far, I admit).

The general steps for serialization should roughly be:
  1. Create an instance of .NET MemoryStream, using CoMemoryStream.Create.
  2. Create an instance of .NET BinaryFormatter, using CoBinaryFormatter.Create.
  3. Call binaryFormatter.Serialize, passing it the memoryStream, and the easyUADataChangeNotificationEventArgs.
  4. Call memoryStream.GetBuffer or memoryStream.Read to obtain the array of bytes.

The general steps for deserialization should roughly be:
  1. Create an instance of .NET MemoryStream, using CoMemoryStream.Create.
  2. Call memoryStream.Write with the array of bytes.
  3. Create an instance of .NET BinaryFormatter, using CoBinaryFormatter.Create.
  4. Call binaryFormatter.Deserialize, passing it the memoryStream.
  5. Cast the resulting value to _EasyUADataChangeNotificationEventArgs

Let me know if you run into problems with this.

Regards
Last edit: 07 Feb 2018 19:24 by support.

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

More
07 Feb 2018 16:48 #5982 by alr1976
Hi!

I need to send eventargs from procedure TClientEventChangeData.OnDataChangeNotification to other computer so I will ask you if it possible:

1)Convert eventargs in Tbytes so I can send it and after recreate in remote computer. but how can I convert eventargs in Tbytes?
2)Send data to remote computer (for example value,hasgoodvalue,etc) and after create eventargs in remotecomputer. How create _EasyUADataChangeNotificationEventArgs and insert new value?

I need eventargs because all my functions use it in input value for all functions.

Br,Alessandro

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

Moderators: support
Time to create page: 0.048 seconds