Beijer Electronics (formerly QSI Corporation)
http://www.qsiforums.com/

GetObjRef and type of the object
http://www.qsiforums.com/viewtopic.php?f=6&t=4786
Page 1 of 1

Author:  alzverev [ Tue May 20, 2014 12:35 pm ]
Post subject:  GetObjRef and type of the object

Hello,

I'm doing redevelopment of the K65 (one of old Qlarity HMI's) application into the G72 one. What am I doing is I parse VTP commands, receive object reference with GetObjRef call and then set property values with SetObjProp call.

But there are such commands as "bD" which should be interpreted and set differently depending on the type of the object it is pointing to. So, the question is how to check if the object received from GetObjRef call has the type of, for example, LabelV2 or ButtonV2?

Thanks in advance,
Alexey.

Author:  Jeremy [ Tue May 20, 2014 10:28 pm ]
Post subject:  Re: GetObjRef and type of the object

Alverev,

Can you send me an email or a PM with your email address? Use the buttons under my reply to try one of those options. I would like to talk a little more in depth about what you are trying to accomplish. I may have something that can get you a jump start on your project.

Author:  Jeremy [ Wed May 21, 2014 7:02 am ]
Post subject:  Re: GetObjRef and type of the object

Also, to directly answer the question -- if you are writing custom objects, or even deriving from the standard ones then there are some things you could do. For instance, you could create a new template MyButtonV2 that extends ButtonV2 and a template MyLabelV2 that extends LabelV2.

In each of these classes you could add a new property called Data with an appropriate validation function. Your generic VTP parser can then use SetObjProp to set the Data property on any template which supports that property (And throw an exception if the object doesn't have that property).

Code:
'In MyButtonV2
dim Data as string
func Data(newVal as string)
    Value = newVal
    Data := newVal
endfunc

'In the VTP parser
if command == "bD" then
    check error
        SetObjProp(CurrentObject, "Data", subParameter1)
    on error
        LogError("bD not supported on object " + str(CurrentObject))
    enderr
endif


Note that the code sample is a bit loose and would very much have to be adapted to whatever you are doing

Author:  Jeremy [ Wed May 21, 2014 7:12 am ]
Post subject:  Re: GetObjRef and type of the object

The other approach that you can use is to try and cast the variable to the right data type. This is going to be a bit cumbersome as you don't easily know off hand the right type. But at least the set of choices is fairly small.

Code:
dim btn as ButtonV2
dim lbl as LabelV2
dim name as string

name = str(selectedObject)
check error
    val(btn, name)
    btn.Value = parm1
    return
on error
    _ClearException()
enderr

check error
    val(lbl, name)
    lbl.Value = parm1
    return
on error
    _ClearException()
enderr

LogError(name + " is not of a supported type")


Author:  kpilquist [ Sat Aug 16, 2014 6:53 pm ]
Post subject:  Re: GetObjRef and type of the object

I am curious if you have had much luck with this. I am attempting to do the same thing.

Author:  Jeremy [ Tue Aug 19, 2014 11:52 am ]
Post subject:  Re: GetObjRef and type of the object

kpilquist

Which are you trying to do? Casting objects of different types or emulating the K65 on a G72?

Author:  kpilquist [ Wed Aug 27, 2014 11:43 am ]
Post subject:  Re: GetObjRef and type of the object

I am trying to emulate k65 on a g70. I have been playing around with parsing the VTP, but my programming skills aren't up to that level yet.

Author:  Jeremy [ Wed Aug 27, 2014 11:58 am ]
Post subject:  Re: GetObjRef and type of the object

Send me an email or a PM and I will get you more information

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/