Skip to content

Commit 16829bb

Browse files
Merge pull request #5 from golluroSICKAG/main
# Release 2.1.0
2 parents 17293bc + 63eb0bf commit 16829bb

8 files changed

Lines changed: 114 additions & 119 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## Release 2.1.0
5+
6+
### New features
7+
- User can select a subindex to read (even if subindex access is not supported)
8+
49
## Release 2.0.0
510
Major internal code edits!
611

CSK_Module_IODDInterpreter/project.mf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Module can provide chunks of IODD file in JSON format to describe some datapoint
475475
</serves>
476476
</crown>
477477
<meta key="author">SICK AG</meta>
478-
<meta key="version">2.0.0</meta>
478+
<meta key="version">2.1.0</meta>
479479
<meta key="priority">low</meta>
480480
<meta key="copy-protected">false</meta>
481481
<meta key="read-protected">false</meta>

CSK_Module_IODDInterpreter/scripts/Sensors/IODDInterpreter/IODDInterpreter_Controller.lua

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,7 @@ local function updateSelectedProcessDataTable(selectedRow, selectedProcessDataTa
311311
if state == false and selectedProcessDataTable["0"] == true then
312312
selectedProcessDataTable["0"] = false
313313
end
314-
if selectedProcessDataTable.subindexAccessSupported == true then
315-
selectedProcessDataTable[subindex] = state
316-
else
317-
for tempSubndex, _ in pairs(selectedProcessDataTable) do
318-
if tempSubndex ~= "subindexAccessSupported" then
319-
selectedProcessDataTable[tempSubndex] = state
320-
end
321-
end
322-
end
314+
selectedProcessDataTable[subindex] = state
323315
else
324316
for tempSubndex, _ in pairs(selectedProcessDataTable) do
325317
if tempSubndex ~= "subindexAccessSupported" then
@@ -340,15 +332,7 @@ local function updateSelectedParametersTable(selectedRow, selectedParametersTabl
340332
if state == false and selectedParametersTable[index]["0"] == true then
341333
selectedParametersTable[index]["0"] = false
342334
end
343-
if selectedParametersTable[index].subindexAccessSupported == true then
344-
selectedParametersTable[index][subindex] = state
345-
else
346-
for subindex1, _ in pairs(selectedParametersTable[index]) do
347-
if subindex1 ~= "subindexAccessSupported" then
348-
selectedParametersTable[index][subindex1] = state
349-
end
350-
end
351-
end
335+
selectedParametersTable[index][subindex] = state
352336
else
353337
for subindex1, _ in pairs(selectedParametersTable[index]) do
354338
if subindex1 ~= "subindexAccessSupported" then
@@ -970,7 +954,7 @@ local function loadInstancesListParameters(parameterName)
970954
parameterSet = nil
971955
data = nil
972956
else
973-
_G.logger:warning(nameOfModule .. ' instance ' .. instanceId .. ": Loading parameters from CSK_PersistentData module did not work.")
957+
_G.logger:info(nameOfModule .. ": Loading parameters from CSK_PersistentData module did not work.")
974958
end
975959
else
976960
_G.logger:warning(nameOfModule .. ": CSK_PersistentData Module not available.")

CSK_Module_IODDInterpreter/scripts/Sensors/IODDInterpreter/helper/IODDInterpreter.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ end
4747

4848
function IODDInterpreter:getSubIndexParameter(index, subindex)
4949
if self.ParamIndexMap[index] and self.ParamIndexSubindexMap[index][subindex] then
50-
local tempTable = copy(self.Variable[self.ParamIndexMap[index]].Datatype.RecordItem[self.ParamIndexSubindexMap[index][subindex]])
51-
changeTextIDtoText(tempTable, self.languages[self.currentLanguage])
52-
return tempTable
50+
if self.Variable[self.ParamIndexMap[index]].Datatype['xsi:type'] == "ArrayT" then
51+
local tempTable = copy(self.Variable[self.ParamIndexMap[index]].Datatype.SimpleDatatype)
52+
changeTextIDtoText(tempTable, self.languages[self.currentLanguage])
53+
return tempTable
54+
else
55+
local tempTable = copy(self.Variable[self.ParamIndexMap[index]].Datatype.RecordItem[self.ParamIndexSubindexMap[index][subindex]])
56+
changeTextIDtoText(tempTable, self.languages[self.currentLanguage])
57+
return tempTable
58+
end
5359
else
5460
return false
5561
end

CSK_Module_IODDInterpreter/scripts/Sensors/IODDInterpreter/helper/funcs.lua

Lines changed: 87 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ local function getDatatypeBitlength(datatypeInfo)
203203
elseif datatypeInfo.type == "StringT" or datatypeInfo.type == "OctetStringT" then
204204
return tonumber(datatypeInfo.fixedLength)
205205
elseif datatypeInfo.type == "ArrayT" then
206-
return tonumber(datatypeInfo.count)*getDatatypeBitlength(datatypeInfo.Datatype)
206+
return tonumber(datatypeInfo.count)*getDatatypeBitlength(datatypeInfo.SimpleDatatype)
207207
end
208208
end
209209

@@ -218,122 +218,121 @@ local defaultValueForSimpleType = {
218218

219219
local function makeExpectedPayload(compiledTable)
220220
local expectedTable = {}
221-
for _, dataPointInfo in pairs(compiledTable) do
222-
dataPointInfo = renameDatatype(dataPointInfo)
223-
if dataPointInfo.Datatype.type == 'ArrayT' then
224-
expectedTable[dataPointInfo.Name] = {}
225-
for i = 1, dataPointInfo.Datatype.count do
226-
expectedTable[dataPointInfo.Name]["element_" .. tostring(i)] = {}
227-
expectedTable[dataPointInfo.Name]["element_" .. tostring(i)].value = defaultValueForSimpleType[dataPointInfo.Datatype.Datatype.type]
228-
end
229-
elseif dataPointInfo.Datatype.type =='RecordT' then
230-
expectedTable[dataPointInfo.Name] = {}
231-
local repeatedNames = {}
232-
for _, recordInfo in ipairs(dataPointInfo.Datatype.RecordItem) do
233-
local recordName = recordInfo.Name
234-
if expectedTable[dataPointInfo.Name][recordInfo.Name] then
235-
table.insert(repeatedNames, recordInfo.Name)
236-
expectedTable[dataPointInfo.Name][recordInfo.Name..'_1'] = copy(expectedTable[dataPointInfo.Name][recordInfo.Name])
237-
local repeatedIndex = 2
238-
recordName = recordInfo.Name .. '_' .. tostring(repeatedIndex)
239-
while expectedTable[dataPointInfo.Name][recordName] do
240-
recordName = recordInfo.Name .. '_' .. tostring(repeatedIndex)
241-
repeatedIndex = repeatedIndex + 1
242-
end
243-
end
244-
expectedTable[dataPointInfo.Name][recordName] = {}
245-
expectedTable[dataPointInfo.Name][recordName].value = defaultValueForSimpleType[recordInfo.Datatype.type]
246-
end
247-
for i, recordName in ipairs(repeatedNames) do
248-
expectedTable[dataPointInfo.Name][recordName] = nil
221+
for dataPointId, dataPointInfo in pairs(compiledTable) do
222+
if dataPointInfo.subindeces then
223+
expectedTable[dataPointId] = {}
224+
for subindexId, subindexInfo in pairs(dataPointInfo.subindeces) do
225+
expectedTable[dataPointId][subindexId] = {
226+
value = defaultValueForSimpleType[subindexInfo.info.type]
227+
}
249228
end
250229
else
251-
expectedTable[dataPointInfo.Name] = {}
252-
if dataPointInfo.Datatype then
253-
expectedTable[dataPointInfo.Name].value = defaultValueForSimpleType[dataPointInfo.Datatype.type]
254-
elseif dataPointInfo.Datatype then
255-
expectedTable[dataPointInfo.Name].value = defaultValueForSimpleType[dataPointInfo.Datatype.type]
256-
end
230+
expectedTable[dataPointId] = {
231+
value = defaultValueForSimpleType[dataPointInfo.info.type]
232+
}
257233
end
258234
end
259235
return expectedTable
260236
end
261237
funcs.makeExpectedPayload = makeExpectedPayload
262238

263-
local function compileProcessDataTable(processDataInfo, selectedTable)
239+
local function getSingleInfoTable(rawInfoTable)
240+
local info = copy(rawInfoTable)
241+
if rawInfoTable.Datatype then
242+
for key, value in pairs(rawInfoTable.Datatype) do
243+
info[key] = value
244+
end
245+
end
246+
if rawInfoTable.SimpleDatatype then
247+
for key, value in pairs(rawInfoTable.SimpleDatatype) do
248+
info[key] = value
249+
end
250+
end
251+
info.type = info["xsi:type"]
252+
info["xsi:type"] = nil
253+
info.RecordItem = nil
254+
info.Datatype = nil
255+
info.SimpleDatatype = nil
256+
return info
257+
end
258+
259+
local function compileDataPointTable(dataInfo, selectedTable)
260+
if not dataInfo then
261+
return nil
262+
end
264263
local compiledTable = {}
265-
if selectedTable["0"] == true then
266-
local singleProcessData = copy(processDataInfo)
267-
singleProcessData.bitOffset = 0
268-
singleProcessData.Frequency = 0
269-
singleProcessData.requested = false
270-
compiledTable[singleProcessData.Name] = singleProcessData
271-
--table.insert(compiledTable, singleProcessData)
272-
elseif selectedTable["1"] ~= nil then
264+
if dataInfo.Datatype["xsi:type"] == "ArrayT" or dataInfo.Datatype["xsi:type"] == "RecordT" then
273265
for subindex, selected in pairs(selectedTable) do
274266
if selected == true and subindex ~= "0" and subindex ~= "subindexAccessSupported" then
275-
if processDataInfo.Datatype["xsi:type"] == "ArrayT" then
276-
local singleProcessData = copy(processDataInfo.Datatype)
277-
singleProcessData.subindex = subindex
278-
singleProcessData.bitOffset = tonumber(subindex) * getDatatypeBitlength(singleProcessData.SimpleDatatype)
279-
singleProcessData.Frequency = 0
280-
singleProcessData.requested = false
281-
singleProcessData.Name = processDataInfo.Name.. '_element' .. tostring(subindex)
282-
compiledTable[singleProcessData.Name] = singleProcessData
283-
--table.insert(compiledTable, singleProcessData)
284-
elseif processDataInfo.Datatype["xsi:type"] == "RecordT" then
267+
if not compiledTable[dataInfo.Name] then
268+
local info = copy(dataInfo)
269+
for key, value in pairs(dataInfo.Datatype) do
270+
info[key] = value
271+
end
272+
info.type = info["xsi:type"]
273+
info["xsi:type"] = nil
274+
if dataInfo.Datatype["xsi:type"] == "ArrayT" then
275+
info.SimpleDatatype.type = info.SimpleDatatype["xsi:type"]
276+
end
277+
info.BitLength = getDatatypeBitlength(info)
278+
info.RecordItem = nil
279+
info.SimpleDatatype = nil
280+
compiledTable[dataInfo.Name] = {
281+
info = info,
282+
subindeces = {}
283+
}
284+
end
285+
if dataInfo.Datatype["xsi:type"] == "ArrayT" then
286+
local singleProcessDatatype = copy(dataInfo.Datatype.SimpleDatatype)
287+
singleProcessDatatype.subindex = subindex
288+
singleProcessDatatype.type = singleProcessDatatype["xsi:type"]
289+
singleProcessDatatype.bitOffset = (tonumber(subindex)-1) * getDatatypeBitlength(singleProcessDatatype)
290+
singleProcessDatatype.Name = dataInfo.Name.. '_element' .. tostring(subindex)
291+
compiledTable[dataInfo.Name].subindeces[singleProcessDatatype.Name] = {
292+
info = singleProcessDatatype
293+
}
294+
295+
elseif dataInfo.Datatype["xsi:type"] == "RecordT" then
285296
local subindexMap = {}
286-
for i, subindexInfo in ipairs(processDataInfo.Datatype.RecordItem) do
297+
for i, subindexInfo in ipairs(dataInfo.Datatype.RecordItem) do
287298
subindexMap[subindexInfo.subindex] = i
288299
end
289-
local singleProcessData = copy(processDataInfo.Datatype.RecordItem[subindexMap[subindex]])
290-
singleProcessData.Frequency = 0
291-
singleProcessData.requested = false
292-
compiledTable[singleProcessData.Name] = singleProcessData
293-
--table.insert(compiledTable, singleProcessData)
300+
local singleProcessDatatype = copy(dataInfo.Datatype.RecordItem[subindexMap[subindex]])
301+
singleProcessDatatype.subindex = subindex
302+
if not singleProcessDatatype.Name then
303+
singleProcessDatatype.Name = "Null parameter"
304+
end
305+
compiledTable[dataInfo.Name].subindeces[singleProcessDatatype.Name] = {
306+
info = getSingleInfoTable(singleProcessDatatype)
307+
}
294308
end
295309
end
296310
end
311+
elseif selectedTable["0"] == true then
312+
compiledTable[dataInfo.Name] = {
313+
info = getSingleInfoTable(dataInfo)
314+
}
297315
end
298316
if getTableSize(compiledTable) == 0 then
299317
return nil
300318
end
301319
return compiledTable
302320
end
303-
funcs.compileProcessDataTable = compileProcessDataTable
321+
funcs.compileProcessDataTable = compileDataPointTable
304322

305323
local function compileParametersTable(iodd, selectedTable)
306324
local compiledTable = {}
307325
for index, subindeces in pairs(selectedTable) do
308-
if subindeces["0"] == true then
309-
local ioddIndexdata = iodd:getParameterInfoFromIndex(index)
310-
ioddIndexdata.subindex = "0"
311-
ioddIndexdata.Frequency = 0
312-
ioddIndexdata.requested = false
313-
compiledTable[ioddIndexdata.Name] = ioddIndexdata
314-
--table.insert(compiledTable, ioddIndexdata)
315-
elseif subindeces["1"] ~= nil then
316-
for subindex, selected in pairs(subindeces) do
317-
if selected == true and subindex ~= "0" and subindex ~= "subindexAccessSupported" then
318-
local ioddIndexdata = iodd:getParameterInfoFromIndex(index)
319-
if ioddIndexdata.Datatype["xsi:type"] == "ArrayT" then
320-
local ioddSubIndexdata = ioddIndexdata.Datatype
321-
ioddSubIndexdata.index = index
322-
ioddSubIndexdata.subindex = subindex
323-
ioddSubIndexdata.Frequency = 0
324-
ioddSubIndexdata.requested = false
325-
ioddSubIndexdata.Name = ioddIndexdata.Name.. '_element' .. tostring(subindex)
326-
--table.insert(compiledTable, ioddSubIndexdata)
327-
compiledTable[ioddIndexdata.Name] = ioddSubIndexdata
328-
elseif ioddIndexdata.Datatype["xsi:type"] == "RecordT" then
329-
local ioddSubIndexdata = iodd:getSubIndexParameter(index, subindex)
330-
ioddSubIndexdata.index = index
331-
ioddSubIndexdata.Frequency = 0
332-
ioddSubIndexdata.requested = false
333-
--table.insert(compiledTable, ioddSubIndexdata)
334-
compiledTable[ioddSubIndexdata.Name] = ioddSubIndexdata
326+
for subindex, selected in pairs(subindeces) do
327+
if selected == true then
328+
local ioddIndexdata = iodd:getParameterInfoFromIndex(index)
329+
local compiledDataPointTable = compileDataPointTable(ioddIndexdata, subindeces)
330+
if compiledDataPointTable then
331+
for key, value in pairs(compiledDataPointTable) do
332+
compiledTable[key] = value
335333
end
336334
end
335+
break
337336
end
338337
end
339338
end

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Tested on
4343
|Device|Firmware version|Module version|
4444
|--|--|--|
4545
|SICK AppEngine|V1.7.0|V1.1.0|
46+
|SIM1012|V2.4.2|V2.1.0|
4647
|SIM1012|V2.4.2|V1.1.0|
4748
|SIM1012|v2.3.0|v1.0.1|
4849
|SIM1012|v2.3.0|v1.0.0|

docu/CSK_Module_IODDInterpreter.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta name="generator" content="Asciidoctor 2.0.12">
88
<meta name="author" content="SICK AG">
9-
<title>Documentation - CSK_Module_IODDInterpreter 2.0.0</title>
9+
<title>Documentation - CSK_Module_IODDInterpreter 2.1.0</title>
1010
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
1111
<style>
1212
/* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
@@ -615,11 +615,11 @@
615615
</head>
616616
<body class="article toc2 toc-left">
617617
<div id="header">
618-
<h1>Documentation - CSK_Module_IODDInterpreter 2.0.0</h1>
618+
<h1>Documentation - CSK_Module_IODDInterpreter 2.1.0</h1>
619619
<div class="details">
620620
<span id="author" class="author">SICK AG</span><br>
621-
<span id="revnumber">version 2.0.0,</span>
622-
<span id="revdate">2024-10-21</span>
621+
<span id="revnumber">version 2.1.0,</span>
622+
<span id="revdate">2025-01-22</span>
623623
</div>
624624
<div id="toc" class="toc2">
625625
<div id="toctitle">Table of Contents</div>
@@ -755,11 +755,11 @@ <h2 id="_document_metadata">Document metadata</h2>
755755
</tr>
756756
<tr>
757757
<th class="tableblock halign-left valign-top"><p class="tableblock">Version</p></th>
758-
<td class="tableblock halign-left valign-top"><p class="tableblock">2.0.0</p></td>
758+
<td class="tableblock halign-left valign-top"><p class="tableblock">2.1.0</p></td>
759759
</tr>
760760
<tr>
761761
<th class="tableblock halign-left valign-top"><p class="tableblock">Date</p></th>
762-
<td class="tableblock halign-left valign-top"><p class="tableblock">2024-10-21</p></td>
762+
<td class="tableblock halign-left valign-top"><p class="tableblock">2025-01-22</p></td>
763763
</tr>
764764
<tr>
765765
<th class="tableblock halign-left valign-top"><p class="tableblock">Author</p></th>
@@ -5534,8 +5534,8 @@ <h4 id="_short_description_89">Short description</h4>
55345534
</div>
55355535
<div id="footer">
55365536
<div id="footer-text">
5537-
Version 2.0.0<br>
5538-
Last updated 2024-10-21 14:45:31 +0200
5537+
Version 2.1.0<br>
5538+
Last updated 2025-01-22 11:40:09 +0100
55395539
</div>
55405540
</div>
55415541
<script type="text/javascript">

docu/media/mainPage.png

4.55 KB
Loading

0 commit comments

Comments
 (0)