-- Multiplies a single input value by a multiplier -- @param Obji: Table containing input values with keys "1" (multiplier) and "2" (input value) -- @return table: Table with key "1" containing the result as string function SingleTagMultiplier(Obji) local Objo = {} local multiplier = tonumber(Obji["1"]) local inputValue = tonumber(Obji["2"]) if not multiplier or not inputValue then Objo["1"] = "0" else Objo["1"] = tostring(multiplier * inputValue) end return Objo end -- Multiplies multiple input values by a single multiplier -- @param Obji: Table containing input values with keys: -- "1" = multiplier, "2" to "9" = input values to be multiplied -- @return table: Table with keys "1" to "8" containing the multiplied results as strings function MultipleTagMultiplier(Obji) local Objo = {} local multiplier = tonumber(Obji["1"]) if not multiplier then -- If multiplier is invalid, set all outputs to "0" for i = 1, 8 do Objo[tostring(i)] = "0" end else -- Multiply each input by the multiplier for i = 2, 9 do local inputValue = tonumber(Obji[tostring(i)]) or 0 Objo[tostring(i-1)] = tostring(multiplier * inputValue) end end return Objo end -- Maps numeric input tags to values (0 or 64) -- @param Obji: Table containing up to 25 numeric input values with keys "1" to "25" -- @return table: Table with keys "1" to "25" containing "64" for "1.00", "0" otherwise function IEC104DirectNTFlagMapping(Obji) local Objo = {} for i = 1, 25 do -- Get input as string local raw = Obji[tostring(i)] or "0" -- Convert to number (float) local num = tonumber(raw) or 0 -- Check if numeric value equals 1 if num == 1 then Objo[tostring(i)] = "0" else Objo[tostring(i)] = "64" end end return Objo end