From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-23-2015 08:05 AM
Hello,
I am trying to read some Tags in a Siemens S7-1200 PLC over NI OPC server. I can read them in NI-DSM (Distributed System Manager). However, I can not read or write them in Labview. I generated a shared variable event loop which will run when a variable changes. I get always Variant in Variant as Value which is not correct as I want to convert it to a data type. (See attached image)
How can I correct it?
Solved! Go to Solution.
07-23-2015 08:09 AM
Use 'variant to data' to convert it to the appropriate data type (it looks like a numeric?).
07-23-2015 08:24 AM
Did you see the image? Variant to data but which data? Data is also variant. I have to make variant->variant->UInt8 which seems not good and not correct. Tags are UInt8. Normally in probe windows I see <variant:254> for byte variables. But what does it mean <Variant:<Variant:233>> ?
07-23-2015 08:40 AM
07-23-2015 08:56 AM
O thanks, it works. But I wonder why are there 2 variants inside each other.
07-23-2015 09:03 AM - edited 07-23-2015 09:04 AM
It is quite common for a function/property/method to return a value as a variant if the data type is unknown at runtime (e.g. getting a control value for a generic control).
Is your shared variable a variant? If so - the event data converts that to a variant (even though it is already a variant) because you might have registered for events for different shared variables that might be of different data types so it returns as a variant so you can convert it to the correct type (based on the 'data type' event data item).