06-16-2011 05:05 PM
I want to send the value of an indicator on my custom LV Operator Interface to the Process Model to include in the xml report when running a sequence. I tried using the PropertyObject Class but was unsucessful. I seem to be missing something.
In the OI I created a property object with the method "NewPropertyObject" from a Engine reference. The type is set to a PropValType_String. I then give the Object a name with the property node "PropertyObject.Name" and called the method "PropertyObject.SetValString" passing it the value of the indicator.
In the Process model, I did essentially the same thing with ActiveX Adapter steps. Called the method "NewPropertyObject" with a type of "PropValType_String" and stored the reference to it. I used that reference on a PropertyObject class to "Set Property" to the same name as above. I then called the method "GetValString" to retrieve the value of the indicator.
Obviously this won't work because I'm actually creating a new object with the same name instead of referencing the current one. What I need is a method "GetPropertyObject" from the Engine class. Why does such a method not exist? Since both the OI and the Process Model are running under the same instance of the Engine shouldn't they be able to share values with PropertyObjects?
Looking for a solution, I've noticed that the answer is probably to use UIMessaging. I will try that, but is there a reason my 'simple' method could not work?
06-17-2011 12:45 AM
UIMessaging is fine for passing information from a SequenceFile such as the Process Model to the UI but not the other way.
The simplest way is just store it in the StationGlobals.
06-17-2011 02:03 AM
Ray,
i am sorry to contradict you. StationGlobals are a possible way, maybe even the simplest from a certain point of view, but i wouldn't recommend it.
I recommend using UIMessages as already considered.
You are correct that UIMessages are comming from the sequence' execution and are sent to the UI, not the other way round.
But if i want to know something, i do the same what the OP did: ASK.
So the UIMessage would present the question, and the UI has to have to answer it. Passing data will be done by using the ThisContext as parameter for the UIMessage.
The advantage: You will keep your StationGlobals clean, use suggested communication channels and retrieve only data necessary at a certain point of execution. Additionally, you are not bound to any settings (if you do not use "InsertIfMissing" for instance), so you can run your model/sequence on any machine/UI. It will probably not work as desired, but it will not create errors because of trying to access invalid data.
hope this helps,
Norbert
06-17-2011 04:52 AM
Norbert,
Dont be sorry.
Thinking about your process, I would probably just pass the reference to the property I want the data to be stored in by the UI rather than the whole Context.
06-17-2011 06:00 AM
Ray,
that is personal preference. I prefer to have the same procedure for each UIMessage Code using the default "Set/Get Property Value" (it is written for getting a sequence context as parameter) instead of having some cases working with property nodes and others with the set/get prop vals....
thanks,
Norbert
06-17-2011 11:47 AM
Thanks for info. I found the exact solution here:
http://zone.ni.com/devzone/cda/epd/p/id/2606.
Still curious about my first approach directly using Engine Properties. What is the problem with this?