Skip to content

Commit

Permalink
Pass the pin states in getContinuousChanges mode to a callback function.
Browse files Browse the repository at this point in the history
  • Loading branch information
docbacardi committed Mar 29, 2022
1 parent c93efbb commit c9a67e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions iomatrix/templates/io_matrix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ function IoMatrix:bget()
end


function IoMatrix:getContinuousChanges()
self.netx:getContinuousChanges()
function IoMatrix:getContinuousChanges(fnCallback, pvUser)
self.netx:getContinuousChanges(fnCallback, pvUser)
end


Expand Down
4 changes: 2 additions & 2 deletions iomatrix/templates/io_matrix/netx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ end



function IoMatrix_netx:getContinuousChanges()
function IoMatrix_netx:getContinuousChanges(fnCallback, pvUser)
for _, tDev in pairs(self.atDevices) do
tDev:getContinuousChanges()
tDev:getContinuousChanges(fnCallback, pvUser)
end
end

Expand Down
14 changes: 12 additions & 2 deletions iomatrix/templates/io_matrix/netx_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ end



function IoMatrix_netx_base:getContinuousChanges()
function IoMatrix_netx_base:getContinuousChanges(fnCallback, pvUser)
local tResult

-- Collect the parameter.
Expand All @@ -635,9 +635,19 @@ function IoMatrix_netx_base:getContinuousChanges()
self.hPinDescription -- Pin description handle.
}

local fnDefaultCallback = self.fnCallbackMessage
local function fnMessageSplitter(strData, tParamB)
local strMatch = string.match(strData, "^([01]+)%c+$")
if strMatch~=nil then
return fnCallback(pvUser, strMatch)
else
return fnDefaultCallback(strData, tParamB)
end
end

-- Call the netX program.
self.tLog.debug('__/Output/____________________________________________________________________')
self.tPlugin:call(self.ulExecutionAddress, self.ulParameterStartAddress, self.fnCallbackMessage, 0)
self.tPlugin:call(self.ulExecutionAddress, self.ulParameterStartAddress, fnMessageSplitter, 0)
self.tLog.debug('______________________________________________________________________________')

-- Get the result.
Expand Down

0 comments on commit c9a67e9

Please sign in to comment.