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 whether you accept or reject these cookies being set.

Change "visdimopacity & visdim"
#1
Hi,

How to change the "visdimopacity and visdim" value dynamically

Code:
var Globals = {
config: {.......,"visdimopacity":"80", visdim":"3",.......... },
updateTime: '1502280884.48142',
};

Thanks

Jean-Marc.
Jean-Marc
Reply
#2
Code:
require('uci')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 3)
uci.commit('genohm-scada')
Reply
#3
Thumbs Up 
Hi Admin,

Admin, thank you, it's perfect.

Jean-Marc.
Jean-Marc
Reply
#4
A stupid question. What do the parameters "visdimopacity and visdim"?
Reply
#5
Visualization settings: "Dim inactive visualization after" is visdim, "Dimming level" is visdimopacity
Reply
#6
(10.08.2017, 05:56)admin Wrote:
Code:
require('uci')
uci.set('genohm-scada', 'core', 'visdimopacity', 80)
uci.set('genohm-scada', 'core', 'visdim', 3)
uci.commit('genohm-scada')

Hi Admin,

I understand what this it is supposed to do, and I want to allow the user to turn screen dimming on or off themselves. However, can you please explain how this is used in a working code example? This looks a bit like a fragment to me and I can't figure out what to do with it. I tried a few things with no joy.

Thanks!
Reply
#7
It is full script, Set 'visdim', 0 to turn it off
Reply
#8
(15.06.2020, 11:59)Daniel. Wrote: It is full script, Set 'visdim', 0  to turn it off
Thank you for your reply. It seems to me that the browser needs to be refreshed for this to take effect. Is that right? Can we make it immediate (not requiring a refresh)?

I have the following code:
Code:
-- Set screen dimming on/off

require('uci')

if (event.getvalue() == true) then
  log('Auto dimming on') 
  uci.set('genohm-scada', 'core', 'visdimopacity', 80)
  uci.set('genohm-scada', 'core', 'visdim', 1)
 
else
  log('Auto dimming off')
  uci.set('genohm-scada', 'core', 'visdimopacity', 80)
  uci.set('genohm-scada', 'core', 'visdim', 0)
 
end

uci.commit('genohm-scada') 

I trigger this script with a toggle button on a Visualisation screen. While it works, it does need a refresh, so my question above remains. Can we make it take effect immediately?

Thanks!
Reply
#9
Hi,

The changes are made server side and the client (browser) has no clue that that was done, so you always need to refresh..

Here is a custom JS to refresh to browser from server side (needs to be loaded so 1 refresh is needed after adding the JS)
Code:
$(function(){
  if (typeof grp != 'undefined') {
   grp.listen('1/1/1', function(object, state) {
     if (state == 'value') {
         location.reload();
     }
   }, true);
  }
});
Change 1/1/1 to the same address that triggers the uci update

BR,

Erwin
Reply
#10
Hi Erwin,

Thanks you for your quick response and explanation. I implemented this (changing the 1/1/1 to my script triggering address) and it all works as expected, with the observation that the page refreshes either 2 or 3 times, rather than just once. I can live with that, although it is curious.

Thanks!
Reply
#11
Hi,

Try removing “, true” on line 7

BR,

Erwin
Reply
#12
Perfect! Thanks.
Reply


Forum Jump: