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.

Setting a trend back to nil
#1
I have a trend that I only want to plot some of the time.  This is for an A/C's set point, which I only want to plot when the A/C is actually turned on.   I'd rather not plot it as zero when it's off because that affects the Y-axis scaling.  To achieve this I'm trying to clear or nil the object's value, similar to when it's first created.

Note, this is for a C-Bus Automation Controller.  The SetCBusMeasurement function doesn't accept a nil value, but can this be achieved through the standard LM libraries?

Here is my (non-working) code. The grp.find call successfully retrieves an object, but I cannot get it to clear the value:


Code:
1234567891011
    if ( ac["SystemOn"] == true ) then         SetCBusMeasurement(0, CBUS_MEASUREMENT_DEVICE, CBUS_MEASUREMENT_CHANNEL_SETPOINTACTIVE, ac["Setpoint"], CBUS_MEASUREMENT_UNIT_CELSIUS)      else       log("Setpoint Active : trying to set set to nil so it doesn't plot on trend")       local obj = grp.find("0/"..CBUS_MEASUREMENT_APP.."/"..CBUS_MEASUREMENT_DEVICE.."/"..CBUS_MEASUREMENT_CHANNEL_SETPOINTACTIVE)       if ( obj ~= nil ) then         obj.value = nil                 obj.data = nil            obj.datahex = ""       end     end
Reply
#2
You can try using float32 data type and writing NaN value to your object. Note that it will still show as 0 in the web interface.
Code:
1
nan = 0/0 -- zero divided by zero produces NaN
Reply
#3
(06.02.2018, 10:35)admin Wrote: You can try using float32 data type and writing NaN value to your object. Note that it will still show as 0 in the web interface.

Thank you!  I also realised I was attempting to manipulate grp.find results which of course does nothing.  This is what works:

Code:
123456
local function clearObject(name)   local obj = grp.find(name)   if ( obj ~= nil ) then     grp.write(name,0/0)   end end

Trend now stops plotting as desired. 

   

Thanks again Smile
Reply


Forum Jump: