Logic Machine Forum
To Use Read only just for false condition of status object - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: To Use Read only just for false condition of status object (/showthread.php?tid=5320)



To Use Read only just for false condition of status object - savaskorkmaz - 21.03.2024

Hi,

I have an 1 bit object on visualation. We are sending fixed value as "1". This object also have a status group address. 

We want that, if the status object is 0, command object will act like read only. It will not send any command.

How we can do it ?

Regards,


RE: To Use Read only just for false condition of status object - Fahd - 22.03.2024

(21.03.2024, 18:15)savaskorkmaz Wrote: Hi,

I have an 1 bit object on visualation. We are sending fixed value as "1". This object also have a status group address. 

We want that, if the status object is 0, command object will act like read only. It will not send any command.

How we can do it ?

Regards,

$(function() {
  $('.hidden-by-value').each(function(_, el) {
    var addr = $(el).data('object');
    if (addr) {
      grp.listen(addr, function(obj) {
        var value = obj.value;
        if (value) {
          $(el).addClass('item-read-only').removeClass('hidden-by-value');
        } else {
          $(el).removeClass('item-read-only').addClass('hidden-by-value');
        }
      });
    }
  });
});


RE: To Use Read only just for false condition of status object - savaskorkmaz - 22.03.2024

Hi Fahd ,
Nice to hear you again Smile

Is it javascript ?


RE: To Use Read only just for false condition of status object - Fahd - 22.03.2024

(22.03.2024, 11:47)savaskorkmaz Wrote: Hi Fahd ,
Nice to hear you again Smile
Is it javascript ?


Hi Savas,
Yes, just add hidden-by-value to the additional classes for the objects that you want to apply that function to.


RE: To Use Read only just for false condition of status object - savaskorkmaz - 25.03.2024

Hı Fahd, it didn't worked.
I think i explained with lack of information. Let me explain with example.
I have one object in visualation with 1/1/1 for command and 1/1/2 for status.
I want that,
when 1/1/2 ( the status ) is false then 1/1/1 will be read only.
When 1/1/2 ( the status ) is true then 1/1/1 will be writable.

Thanks


RE: To Use Read only just for false condition of status object - admin - 25.03.2024

Add to Custom JS and use read-only-by-value Additional class.
Code:
$(function() {
  $('.read-only-by-value').each(function(_, el) {
    var addr = $(el).data('status-object');

    if (addr) {
      grp.listen(addr, function(obj) {
        $(el).toggleClass('item-read-only', !obj.value);
      });
    }
  });
});



RE: To Use Read only just for false condition of status object - savaskorkmaz - 25.03.2024

Thanks a lot, it worked

(25.03.2024, 11:36)admin Wrote: Add to Custom JS and use read-only-by-value Additional class.
Code:
$(function() {
  $('.read-only-by-value').each(function(_, el) {
    var addr = $(el).data('status-object');

    if (addr) {
      grp.listen(addr, function(obj) {
        $(el).toggleClass('item-read-only', !obj.value);
      });
    }
  });
});