Update con ordinamento lista allarmi in LUA
This commit is contained in:
@@ -26,11 +26,11 @@ valueChanged = false
|
||||
-- se non è da NLua inizializzo variabili accessorie
|
||||
local function checkInit()
|
||||
if(callMode ~= 'NLua') then
|
||||
alarmList = {"##Allarme01", "Allarme02", "AllarmeSilenziato03", "##Allarme04", "Allarme05", "Allarme06", "Allarme07", "##Allarme08"}
|
||||
alarmList = {"##Allarme01", "Allarme02", "Allarme03", "##Allarme04", "Allarme05", "Allarme06", "Allarme07", "##Allarme08"}
|
||||
numAlarm = #alarmList
|
||||
-- valori status da testare
|
||||
lastVal = 0
|
||||
currVal = 3
|
||||
currVal = 255
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,9 +60,10 @@ end
|
||||
local function setupBitMask()
|
||||
for i = 1, numAlarm,1 do
|
||||
if(string.sub(alarmListTable[i],0,2)~='##') then
|
||||
bitMask = math.floor(bitMask + 2^(i-1))
|
||||
bitMask = bitMask + 2^(i-1)
|
||||
end
|
||||
end
|
||||
bitMask = math.tointeger(bitMask)
|
||||
end
|
||||
|
||||
-- confronto lastVal e currVal
|
||||
@@ -82,17 +83,23 @@ end
|
||||
|
||||
|
||||
local function checkActiveAlarms()
|
||||
local hasAlarms = 0
|
||||
for i = 1, numAlarm do
|
||||
bTest = testBit(valMask(currVal),i)
|
||||
if(bTest) then
|
||||
alarmListActive[i]=alarmListTable[i]
|
||||
alarmListActive[#alarmListActive+1]=string.format("%03d",i) ..' - '.. alarmListTable[i]
|
||||
hasAlarms = 1
|
||||
end
|
||||
end
|
||||
-- ordino allarmi...
|
||||
if(hasAlarms==1) then
|
||||
table.sort(alarmListActive)
|
||||
end
|
||||
end
|
||||
|
||||
local function calcStatusVar()
|
||||
for k, v in pairs(alarmListActive) do
|
||||
alarmStatus = alarmStatus .. k .. ' - ' .. v .. ' | '
|
||||
alarmStatus = alarmStatus .. v .. ' | '
|
||||
end
|
||||
|
||||
if(#alarmStatus == 0) then
|
||||
|
||||
Reference in New Issue
Block a user