Jump to content
C4 Forums | Control4

how to run initialization code in c4i


zyroad

Recommended Posts

Posted

I have a lua function need to be called when the driver is loaded. Where should I put its into?

---------------------In the c4i-----------------

<script><![CDATA[

blobs = {}

function blobs.Initialize()

blobs.num = 0

print("InitBlobs")

blobs[blobs.num+1]=C4:GetBlobByName(string.format("B%04d",blobs.num))

while blobs[blobs.num+1] do

blobs.num = blobs.num+1

blobs[blobs.num+1]=C4:GetBlobByName(string.format("B%04d",blobs.num))

end

end

-------------

function SZL.Initialize(nProfileID, tValidClusterIDs, nGroupID, nSourceEndpoint, nDestEndpoint, nDestEndpoint2)

SZL.ResetSequenceNumber()

-- Fill in for your device...

SZL.gMyProfileID = nProfileID

SZL.gMyValidClusterIDs = {}

for k,v in pairs(tValidClusterIDs) do

SZL.gMyValidClusterIDs[v] = k

end

SZL.Endpoints = {}

SZL.gMyGroupID = nGroupID

-- Endpoints are usually by cluster, but these are the default if not set...

SZL.gMySE = nSourceEndpoint

SZL.gMyDE = nDestEndpoint

SZL.gMyDE2 = nDestEndpoint2

blobs.Initialize() ----can't work when called here, this is strange.

end

---------------------------

function OnPropertyChanged(strProperty)

blobs.Initialize() ----can work when called here, but I need to change some property first.

print(blobs.num) ----use this to monitor if the blobs.Initialize() is called

print(SZL.gMySE) ----use this to monitor if the SZL.Initialize() is called

end

--------------------------

SZL.Initialize(0x104, {

SZL.ClusterID.Basic,

SZL.ClusterID.Identify,

SZL.ClusterID.Groups,

SZL.ClusterID.Scenes,

SZL.ClusterID.OnOff,

SZL.ClusterID.LevelControl,

SZL.ClusterID.Time

}, 0, 10, 11, 12) -----can work, but nested blobs.Initialize() function is not called, it's very strange

blobs.Initialize() ----can't work when call here

]]></script>


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.