Logger:Info("-- init_knxstack_6.lua start --")

-- defines
local KimParameterInterfaceObjectId = 40960


--[[
	old KIM devices structure:
	ONE interface object 40960
	Some properties for CO, Dpt, Ip, Number etc. - all stored as arrays
	
	array of up to 4065 elements of type 32 bit unsigned, DPT coded as Major.Minor = 16bit.16bit
	array of up to 4065 elements of type 32 bit unsigned
	array of up to 64 elements of type 32 bit unsigned
	array of up to 200 elements of type 32 bit signed
	array of 10 bytes [ SpeedText, TextWrapping, AppType,
				   TimeServerActive, SendTimeDelay, SendDateDelay,
				   DataLoggerActive, DataLoggingFormat, DataloggerType, DataloggerStatusType]
	array of 64 elements of type char
	array of 1 element of type 16 bit unsigned
]]--

local loadState = 1

function OnWriteLoadState(property, value)
  local request = value:GetAsUInt8()
  if request == 4 then
	loadState = 0
  elseif request == 1 then
	loadState = 2
  elseif request == 2 then
	loadState = 1
  end
  Logger:Info(" init_knxstack_6.lua: OnWriteLoadProcedure: got " .. request .. " response " .. loadState)
end

function OnReadLoadState(property, value)
  value:SetUInt8(loadState)
  Logger:Info(" init_knxstack_6.lua: OnReadLoadProcedure: response " .. loadState)
end

local kimInterfaceObject = PropertyService:CreateInterfaceObject(KimParameterInterfaceObjectId)

local loadProcedurePropertyData = kimInterfaceObject:RegisterSimpleProperty(5, 0x0, OnWriteLoadState, OnReadLoadState)
local coDptPropertyData = kimInterfaceObject:RegisterArrayProperty(64, 0x09, 4095):SetPersistence(true)
local ipAddressParameterPropertyData = kimInterfaceObject:RegisterArrayProperty(68, 0x09, 100):SetPersistence(true)
local numberParameterPropertyData = kimInterfaceObject:RegisterArrayProperty(69, 0x08, 64):SetPersistence(true)
local dptFlagPropertyData = kimInterfaceObject:RegisterArrayProperty(66, 0x09, 4095):SetPersistence(true)
local pid71PropertyData = kimInterfaceObject:RegisterArrayProperty(71, 0x02, 10):SetPersistence(true)
local pid72PropertyData = kimInterfaceObject:RegisterArrayProperty(72, 0x01, 64):SetPersistence(true)
local pid73TimeZoneId = kimInterfaceObject:RegisterSimpleProperty(73, 0x04):SetPersistence(true)  

Logger:Info("-- init_knxstack_6.lua done --")
