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.

Alert Manager
#81
You can check the structure of the Alerts manager data using the Storage viewer app. But if you modify this data via a script the client won't see these changes unless a reload is performed.
Reply
#82
It's only possible when the alert manager is loaded into an frame in the visu by using this custom JS:
Code:
$(function(){
   $(document).ready(function() {
      var f= $('iframe');
      f.load(function(){
         if (typeof grp != 'undefined') {
            grp.listen('1/1/1', function(object, state) {
               if (state == 'value' && object.value == true ){
                  f.contents().find('#AcknowledgeButton').click();
               }
            }, true);
          }
      });
   });
});
Reply
#83
Hi, I have used this app in the past but I have noticed that I have no more access to this alert manager in Schneider Spacelynk.

Where could I find the latest version of this app ?

Thank you
Reply
#84
https://forum.logicmachine.net/showthrea...3#pid22783
------------------------------
Ctrl+F5
Reply
#85
I have written this script for surveillance of alarms. It will only generate one alarm if an Object is not updated within a range of time. You can use it as Resident or Scheduled Script. It takes every object with the tag "Alarm". Change the "controlltime" to your desire.

Code:
--This script is for Object surveillance passivley with the updatetime property
--Alarms will be updated on change!

alarms = grp.tag('Alarm') --add the Tag or Tags of the Object that need surveillance

controlltime = 30 --Allowed Time between recieved Telegramms in Seconds

--initializing Tables for Alarming
currentstate = {}
previousstate = storage.get("previousstate") or {}


now = os.time()

--Iteration throgh the alarms Table to get the update time of every Object

for index, alarm in ipairs(alarms) do
    lastrecieved = alarm.updatetime

    local online
    --calculating the Timedelta and comparing it with our Variable
    if (now - lastrecieved) > controlltime then
        online = false
    else
        online = true
    end

    -- Store the current status in the currentstatus table
    currentstate[alarm.id] = {id = alarm.id, comment = alarm.comment, online = online}

    -- Compare the current status with the previous status
    if previousstate[alarm.id] == nil or currentstate[alarm.id].online ~= previousstate[alarm.id].online then
        if not currentstate[alarm.id].online then
            alert("Alarm " .. currentstate[alarm.id].comment .. " nicht verfügbar")
          else
                  alert("Alarm " ..currentstate[alarm.id].comment .. " verfügbar")
        end
    end

end

-- Log the current status
-- log(currentstate)

-- Save the current status to persistent storage as previous status
storage.set("previousstate", currentstate)




And this script that will actively send a read request to check if alarms are still available. It will take every objekt with the tag "Alarm". This is designed to be used as resedent or scheduled script.

Code:
-- Variables as Tag
alarms = grp.tag('Alarm')


currentstatus = {}
previousstate = storage.get("previousstate") or {}

-- Iterate over all alarms
for index, alarm in ipairs(alarms) do
    value, responding = grp.readvalue(alarm.address, readtimeout)
    local online

    if responding == "timeout" then
        online = false
    else
        online = true
    end

    -- Store the current status in the currentstatus table
    currentstatus[alarm.id] = {id = alarm.id, name = alarm.name, online = online}

    -- Compare the current status with the previous status
    if previousstate[alarm.id] == nil or currentstatus[alarm.id].online ~= previousstate[alarm.id].online then
        if not currentstatus[alarm.id].online then
            alert("Alarm " .. currentstatus[alarm.id].name .. " nicht verfügbar")
        end
    end
end

-- Log the current status
--log(currentstatus)

-- Save the current status to persistent storage as previous status
storage.set("previousstate", currentstatus)
Reply


Forum Jump: