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.

widget template
#1
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.



I attach an example image

Tank's
Reply
#2
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.
Reply
#3
(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

some idea ?
Reply
#4
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:
value = tonumber(event.datahex, 16)

up = bit.band(value, 8) == 8
stop = bit.band(value, 7) == 0

if stop then
  grp.write('32/1/3', true)
elseif up then
  grp.write('32/1/4', true)
else
  grp.write('32/1/5', true)
end
Reply
#5
(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:
value = tonumber(event.datahex, 16)

up = bit.band(value, 8) == 8
stop = bit.band(value, 7) == 0

if stop then
  grp.write('32/1/3', true)
elseif up then
  grp.write('32/1/4', true)
else
  grp.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.

Thank's
Reply
#6
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.
Code:
planID = 8  --plan number shown after # in quisk visu preview http://URL/scada-vis/#6
visObjectType = 1  --all binary objects are type 0 and all numeric objects are type 1

--All Manin objects will be shifted by selected addres.
controlObjectMain = 0
controlObjectSub = 0
controlObjectAddress = 0

--Select shift for status object. If status object is not used in object visu it will be ignored.
statusObjectMain = 0
statusObjectSub = 0
statusObjectAddress = 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 _, tableData in ipairs(dbobjects) do
  oldControlAddress = tableData.object
  oldStatusAddress = tableData.statusobject
  currentRow = tableData.id
  newControlAddress = 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 used
  db:update('visobjects', { statusobject = newControlAddress }, { id = currentRow })
    else
  db:update('visobjects', { statusobject = newStatusAddress }, { id = currentRow })
    end

 
end 
log('update finished')
script.disable(_SCRIPTNAME)

Always make a backup before using any of this scripts.

BR
------------------------------
Ctrl+F5
Reply


Forum Jump: