This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Searching for User Parameters
#1
Hi All,

I'm trying to find a user parameter via a keywork (tag) search rather than the parameter name much like I can do it with other types.  I've looked at running a sql query in a function to do it however I can't seem to associate a keyword with the parameter name.

I can use: 

SetUserParam('Local Network', 'w_obs_wind_dirtext', value) 

however I want to set the value based on the keywork like

SetCBusByKW({'irrigation_current_runtype'}, 'or', {target = 1, ramprate = 0})


I have some db helper functions like the below, so not opposed to doing something in a query.


function db_GetObjectByTag(tag)

    -- Return a table of object parameters based on the id
    local query = string.format('SELECT * FROM objecttags WHERE tag = "%s"', tag)
    liste = db:getall(query)

    if (table.maxn(liste) ~= 0) then
        return liste
    else
        return false
    end
   
end





Cheers,
Paul
Reply
#2
Why don't you use build in function?
myobjects = grp.tag('tag')
------------------------------
Ctrl+F5
Reply
#3
(12.02.2020, 13:20)Daniel. Wrote: Why don't you use build in function?
myobjects = grp.tag('tag')

I don't have that function on the SCAC available for user parameters. The logic machine is very similar, but with some mods. A lot of the info on this forum is applicable, particularly around the lua scripting options.
Reply
#4
User parameter is standard LM object so grp.tag should work. Have you actually tried it?
Reply
#5
I tried it on NAC and it works
------------------------------
Ctrl+F5
Reply
#6
Yep. tried it and it works for a read, is it possible to write using a similar methos via tag?

Paul
Reply
#7
It depend what you want to write.
------------------------------
Ctrl+F5
Reply
#8
Pretty much anything that can be written to a user param, string, integer, float.
Reply
#9
Writing is done like this:
Code:
value = 123
objects = grp.tag('tag')
objects:write(value)
Reply
#10
Awesome, thats what I need, thanks. Is there documentation available on this type of thing, the CBus documentation is pretty basic.

Cheers,
Paul
Reply
#11
Hi,

See: https://openrb.com/docs/lua.htm

BR,

Erwin
Reply


Forum Jump: