Logic Machine Forum
FB Editor - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Application Store (https://forum.logicmachine.net/forumdisplay.php?fid=11)
+--- Thread: FB Editor (/showthread.php?tid=3100)



FB Editor - KoBra - 12.01.2021

I found in the latest release 20201210 FB Editor 2.0 the function to calculate a sliding setpoint with or without offset.

I tried it but there seems a bug in the one with offset:

[Image: PU3dB0E.png]
Does somebody also know why the settings are only available as value and not object?
For installers i normally make the X and Y value programmable. For end user normally only the Offset on Y is a settingĀ (but this is also only available as value).


RE: FB Editor - Daniel - 12.01.2021

This is defined in the function which defines this block. Here are all the function https://forum.logicmachine.net/showthread.php?tid=818&pid=4849#pid4849. You can import them to user libraries and modify. This is quite old one and not sure if this is same like in the current FB.


RE: FB Editor - KoBra - 12.01.2021

Nope i checked and tested this one has the bug in both. So it seems the curve with 2 points function is updated sometime ago.

with the data above the outcome for both is now -10




RE: FB Editor - Daniel - 12.01.2021

I will try to get updated libs but it was done buy external dev so it might take some time.


RE: FB Editor - KoBra - 13.01.2021

I reverse engineered it and used some excel to test the calculations and the one below works.

--- [Function] fbe_curve_2pt
--- Curve function with 2 points
--- [Comment]
--- Depending on a straight line defined by 2 points, this module supplies a y-value for an x-value.
--- The first point of the straight line is defined by x1 and y1.
--- The second point of the straight line is defined by x2 and y2.
--- If x is less than x1, then y=y1.
--- If x is greater than x2, then y=y2.
--- Only strictly monotone rising or falling functions can be realised. This means x1 < x2.
--- [Input]
--- Input [value, object, storage]
--- X1 [value, object, storage]
--- Y1 [value, object, storage]
--- X2 [value, object, storage]
--- Y2 [value, object, storage]
--- [Output]
--- out - Output [object, storage]
function fbe_curve_2pt(input, x1, y1, x2, y2)
if input <= x1 then
return y1
elseif input >= x2 then
return y2
end
local n1, n2 = y2 - y1, x1 - x2
if n1 < 0 then
n1 = n1 * -1
n2 = n2 * -1
end
local c = n1 / n2
return y2 + (x2 - input) * c
end

--- [Function] fbe_curve_2pt_offset
--- Curve function with 2 points and offset
--- [Comment]
--- Depending on straight lines defined by 2 points, this module supplies an x-value for a y-value.
--- The first point of the straight line is defined by x1 and y1.
--- The second point of the straight line is defined by x2 and y2.
--- The x and the y-axis can be shifted by the respective offset.
--- If x is less than (x1 offset x), then y=y1.
--- If x is greater than (x2 offset x), then y=y2.
--- [Input]
--- Input [object, storage]
--- X1 [value, object, storage]
--- Y1 [value, object, storage]
--- X2 [value, object, storage]
--- Y2 [value, object, storage]
--- Offset X [value, object, storage]
--- Offset Y [value, object, storage]
--- [Output]
--- out - Output [object, storage]
function fbe_curve_2pt_offset(input, x1, y1, x2, y2, offsetX, offsetY)
if input <= (x1 + offsetX) then
return (y1 + offsetY)
elseif input >= (x2 + offsetX) then
return (y2+ offsetY)
end
local n1, n2 = y2 - y1, x1 - x2
if n1 < 0 then
n1 = n1 * -1
n2 = n2 * -1
end
local c = n1 / n2
return (y2 + offsetY) + ((x2 + offsetX) - input) * c
end


RE: FB Editor - Daniel - 14.01.2021

Libraries from latest FB


RE: FB Editor - KoBra - 14.01.2021

(14.01.2021, 10:46)Daniel. Wrote: Libraries from latest FB
I found the problem, without the offset the X is the input and the Y the output. In the one with offset the Y is the input and the X the output...




RE: FB Editor - KoBra - 14.01.2021

The adapted script, where in both versions the X is input (outdoor air temperature for example) and the calculated Y is output.

--- [Function] fbe_curve_2pt
--- Curve function with 2 points
--- [Comment]
--- Depending on a straight line defined by 2 points, this module supplies a y-value for an x-value.
--- The first point of the straight line is defined by x1 and y1.
--- The second point of the straight line is defined by x2 and y2.
--- If x is less than x1, then y=y1.
--- If x is greater than x2, then y=y2.
--- Only strictly monotone rising or falling functions can be realised. This means x1 < x2.
--- [Input]
--- Input [value, object, storage]
--- X1 [value, object, storage]
--- Y1 [value, object, storage]
--- X2 [value, object, storage]
--- Y2 [value, object, storage]
--- [Output]
--- out - Output [object, storage]
function fbe_curve_2pt(input, x1, y1, x2, y2)
if input <= x1 then
return y1
elseif input >= x2 then
return y2
end
local n1, n2 = y2 - y1, x1 - x2
if n1 < 0 then
n1 = n1 * -1
n2 = n2 * -1
end
local c = -n1 * x1 - n2 * y1
return (-n1 * input - c) / n2
end

--- [Function] fbe_curve_2pt_offset
--- Curve function with 2 points and offset
--- [Comment]
--- Depending on straight lines defined by 2 points, this module supplies an x-value for a y-value.
--- The first point of the straight line is defined by x1 and y1.
--- The second point of the straight line is defined by x2 and y2.
--- The x and the y-axis can be shifted by the respective offset.
--- If x is less than (x1 offset x), then y=y1.
--- If x is greater than (x2 offset x), then y=y2.
--- [Input]
--- Input [object, storage]
--- X1 [value, object, storage]
--- Y1 [value, object, storage]
--- X2 [value, object, storage]
--- Y2 [value, object, storage]
--- Offset X [value, object, storage]
--- Offset Y [value, object, storage]
--- [Output]
--- out - Output [object, storage]
function fbe_curve_2pt_offset(input, x1, y1, x2, y2, offsetX, offsetY)
if input <= (x1 + offsetX) then
return y1
elseif input >= (x2 + offsetX) then
return y2
end
local n1, n2 = y2 - y1, x1 - x2
if n1 < 0 then
n1 = n1 * -1
n2 = n2 * -1
end
local c = -n1 * (x1 + offsetX) - n2 * (y1 + offsetY)
return (-n1 * input - c) / n2
end