Hi I'm trying to use widgets, and I find it particularly reductive to have to create a widget for each shutter, since the connection to the object is given in the widget, there is a way to pass the parameters not inside the widget but to its use.
(10.07.2020, 06:44)admin Wrote: Does your shutter actuator support 4-bit objects? If so you can just use 4-bit control which has +/- buttons for control via press and hold.
My problem I have 3 different bit up/down/stop
and 1 bit for status open/close
You can create a script to convert 4-bit to 1-bit. In visualization object select 4-bit as Main object and 1-bit as Status object. This way the icon will show the status.
Script to determine 4-bit action (stop/up/down). Change 1-bit addresses and values as needed.
Code:
123456789101112
value = tonumber(event.datahex, 16)
up = bit.band(value, 8) == 8stop = bit.band(value, 7) == 0ifstopthengrp.write('32/1/3', true)
elseifupthengrp.write('32/1/4', true)
elsegrp.write('32/1/5', true)
end
(10.07.2020, 08:35)admin Wrote: You can create a script to convert 4-bit to 1-bit. In visualization object select 4-bit as Main object and 1-bit as Status object. This way the icon will show the status.
Script to determine 4-bit action (stop/up/down). Change 1-bit addresses and values as needed.
Code:
123456789101112
value = tonumber(event.datahex, 16)
up = bit.band(value, 8) == 8stop = bit.band(value, 7) == 0ifstopthengrp.write('32/1/3', true)
elseifupthengrp.write('32/1/4', true)
elsegrp.write('32/1/5', true)
end
Hi but in this way need to create more script , i have more shutter and more windows , best solution is a tempplate widget , where is possible to connecto directly at the right address .
If it's possible I prefer not write more script.
Hi
There is no such thing what you are looking for. Some users created a scripts with direct database write where they shifted groups of a template page. This will work only if you have certain pattern of object creation.
Here is an example https://forum.logicmachine.net/showthrea...50#pid7450
Not sure what for but I wrote some script to shift visu objects based on selected shift. It may be useful to you.
planID = 8--plan number shown after # in quisk visu preview http://URL/scada-vis/#6visObjectType = 1--all binary objects are type 0 and all numeric objects are type 1--All Manin objects will be shifted by selected addres. controlObjectMain = 0controlObjectSub = 0controlObjectAddress = 0--Select shift for status object. If status object is not used in object visu it will be ignored. statusObjectMain = 0statusObjectSub = 0statusObjectAddress = 0------------------------------------------ End Parameters ------------------------------------------------------------------------ DON'T CHANGE ANYTHING UNDER THIS LINE -------------------------------dbobjects = db:getall('SELECT id, object, statusobject FROM visobjects WHERE floor = ' .. planID .. ' AND type = ' .. visObjectType .. '')
--log(dbobjects)for_, tableDatainipairs(dbobjects) dooldControlAddress = tableData.objectoldStatusAddress = tableData.statusobjectcurrentRow = tableData.idnewControlAddress = oldControlAddress + ((controlObjectMain * 2048) + (controlObjectSub * 256) + controlObjectAddress)
newStatusAddress = oldStatusAddress + ((statusObjectMain * 2048) + (statusObjectSub * 256) + statusObjectAddress)
log('oldControlAddress= '..tostring(oldControlAddress)..', currentRow= '..tostring(currentRow)..', newControlAddress= ' ..tostring(newControlAddress)..', newStatusAddress= ' ..tostring(newStatusAddress) )
db:update('visobjects', { object = newControlAddress }, { id = currentRow })
if (oldControlAddress == oldStatusAddress) then--if no status object selected main object must be useddb:update('visobjects', { statusobject = newControlAddress }, { id = currentRow })
elsedb:update('visobjects', { statusobject = newStatusAddress }, { id = currentRow })
endendlog('update finished')
script.disable(_SCRIPTNAME)
Always make a backup before using any of this scripts.