@@ -165,6 +165,9 @@ Script.serveEvent('CSK_MultiIOLinkSMI.OnNewReadMessageEventName', 'M
165165Script .serveEvent (' CSK_MultiIOLinkSMI.OnNewWriteMessageFunctionName' , ' MultiIOLinkSMI_OnNewWriteMessageFunctionName' )
166166Script .serveEvent (' CSK_MultiIOLinkSMI.OnNewWriteMessageEventName' , ' MultiIOLinkSMI_OnNewWriteMessageEventName' )
167167
168+ Script .serveEvent (' CSK_MultiIOLinkSMI.OnNewWriteMessagePrefix' , ' MultiIOLinkSMI_OnNewWriteMessagePrefix' )
169+ Script .serveEvent (' CSK_MultiIOLinkSMI.OnNewWriteMessagePostfix' , ' MultiIOLinkSMI_OnNewWriteMessagePostfix' )
170+
168171Script .serveEvent (' CSK_MultiIOLinkSMI.OnNewReadJSONTemplate' , ' MultiIOLinkSMI_OnNewReadJSONTemplate' )
169172Script .serveEvent (' CSK_MultiIOLinkSMI.OnNewWriteJSONTemplate' , ' MultiIOLinkSMI_OnNewWriteJSONTemplate' )
170173Script .serveEvent (' CSK_MultiIOLinkSMI.OnNewReadDataMessage' , ' MultiIOLinkSMI_OnNewReadDataMessage' )
@@ -382,7 +385,7 @@ local function handleOnExpiredTmrMultiIOLinkSMI()
382385 end
383386
384387 Script .notifyEvent (' MultiIOLinkSMI_OnNewStatusCSKIODDInterpreterAvailable' , (CSK_IODDInterpreter ~= nil ))
385- Script .notifyEvent (' MultiIOLinkSMI_OnNewStatusIODDMatchFound' , (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddInfo ~= nil ))
388+ Script .notifyEvent (' MultiIOLinkSMI_OnNewStatusIODDMatchFound' , (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddInfo ~= nil and multiIOLinkSMI_Instances [ selectedInstance ]. status ~= ' PORT_NOT_ACTIVE ' and multiIOLinkSMI_Instances [ selectedInstance ]. status ~= ' DEACTIVATED ' ))
386389 if CSK_IODDInterpreter then
387390 CSK_IODDInterpreter .pageCalledInstances ()
388391 end
@@ -458,6 +461,9 @@ local function handleOnExpiredTmrMultiIOLinkSMI()
458461 multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages [selectedIODDWriteMessage ].jsonTemplate )
459462 )
460463 Script .notifyEvent (' MultiIOLinkSMI_OnNewTestWriteIODDMessage' , testIODDMessageToWrite )
464+ Script .notifyEvent (' MultiIOLinkSMI_OnNewWriteMessagePrefix' , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages [selectedIODDWriteMessage ].prefix )
465+ Script .notifyEvent (' MultiIOLinkSMI_OnNewWriteMessagePostfix' , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages [selectedIODDWriteMessage ].postfix )
466+
461467 local processDataTableContent , parameterTableContent = CSK_IODDInterpreter .getWriteDataTableContents (' writeIOLink_' )
462468 Script .notifyEvent (' MultiIOLinkSMI_OnNewProcessDataOutTableContentCSKIODDInterpreter' , processDataTableContent )
463469 Script .notifyEvent (' MultiIOLinkSMI_OnNewWriteParametersTableContentCSKIODDInterpreter' , parameterTableContent )
@@ -662,8 +668,8 @@ local function handleOnNewPortEvent(port, eventType, eventCode)
662668 ioddName ,
663669 jsonNewIdentification
664670 )
665- handleOnExpiredTmrMultiIOLinkSMI ()
666671 end
672+ handleOnExpiredTmrMultiIOLinkSMI ()
667673end
668674Script .serveFunction (' CSK_MultiIOLinkSMI.handleOnNewPortEvent' , handleOnNewPortEvent )
669675
@@ -1080,12 +1086,12 @@ local function triggerProcessDataTestViaUI()
10801086 Script .notifyEvent (' MultiIOLinkSMI_OnNewStatusProcessDataTestResult' , ' Payload = ' .. tostring (data ))
10811087
10821088 if data and multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin ~= ' ' then
1083- local findString = string.find (data , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin , 0 )
1089+ local findString = string.find (data , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin , 0 , true )
10841090 if findString then
10851091 if multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchEnd == ' ' then
10861092 data = string.sub (data , findString + # multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin )
10871093 else
1088- local findString2 = string.find (data , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchEnd , findString + # multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin )
1094+ local findString2 = string.find (data , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchEnd , findString + # multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin , true )
10891095 if findString2 then
10901096 data = string.sub (data , findString + # multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin , findString2 - 1 )
10911097 else
@@ -1284,12 +1290,33 @@ local function handleOnNewListIODD(jsonIODDList)
12841290end
12851291Script .register (' CSK_IODDInterpreter.OnNewListIODD' , handleOnNewListIODD )
12861292
1293+ local function parseRowInformation (selection , pattern )
1294+ if selection ~= " " then
1295+ local _ , pos = string.find (selection , pattern )
1296+ if pos ~= nil then
1297+ pos = tonumber (pos )
1298+ local endPos = string.find (selection , ' "' , pos + 1 )
1299+ local newSelection = string.sub (selection , pos + 1 , endPos - 1 )
1300+ if (newSelection ~= nil and newSelection ~= " " ) then
1301+ return newSelection
1302+ end
1303+ end
1304+ end
1305+ end
1306+
12871307local function processDataInRowSelectedCSKIODDInterpreter (rowData )
12881308 if CSK_IODDInterpreter then
12891309 local jsonTemplate , jsonDataInfo = CSK_IODDInterpreter .processDataInRowSelected (rowData , ' readIOLink_' )
12901310 handleOnNewReadDataJsonTemplateAndInfo (jsonTemplate , jsonDataInfo )
12911311 local processDataTableContent = CSK_IODDInterpreter .getReadDataTableContents (' readIOLink_' )
12921312 Script .notifyEvent (' MultiIOLinkSMI_OnNewProcessDataInTableContentCSKIODDInterpreter' , processDataTableContent )
1313+ local searchPattern = parseRowInformation (rowData , ' "readIOLink_colPD2":"' )
1314+ if searchPattern ~= nil then
1315+ setSearchBegin (searchPattern .. ' ":{"value":' )
1316+ setSearchEnd (' }' )
1317+ Script .notifyEvent (' MultiIOLinkSMI_OnNewSearchBegin' , tostring (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin ))
1318+ Script .notifyEvent (' MultiIOLinkSMI_OnNewSearchEnd' , tostring (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchEnd ))
1319+ end
12931320 else
12941321 _G .logger :info (nameOfModule .. " : CSK_IODDInterpreter not available." )
12951322 end
@@ -1302,15 +1329,50 @@ local function readParameterRowSelectedCSKIODDInterpreter(rowData)
13021329 handleOnNewReadDataJsonTemplateAndInfo (jsonTemplate , jsonDataInfo )
13031330 local _ , parameterTableContent = CSK_IODDInterpreter .getReadDataTableContents (' readIOLink_' )
13041331 Script .notifyEvent (' MultiIOLinkSMI_OnNewReadParametersTableContentCSKIODDInterpreter' , parameterTableContent )
1332+ local searchPattern = parseRowInformation (rowData , ' "readIOLink_colSD4":"' )
1333+ if searchPattern ~= nil then
1334+ setSearchBegin (searchPattern .. ' ":{"value":' )
1335+ setSearchEnd (' }' )
1336+ Script .notifyEvent (' MultiIOLinkSMI_OnNewSearchBegin' , tostring (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchBegin ))
1337+ Script .notifyEvent (' MultiIOLinkSMI_OnNewSearchEnd' , tostring (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddReadMessages [selectedIODDReadMessage ].searchEnd ))
1338+ end
13051339 else
13061340 _G .logger :info (nameOfModule .. " : CSK_IODDInterpreter not available." )
13071341 end
13081342end
13091343Script .serveFunction (' CSK_MultiIOLinkSMI.readParameterRowSelectedCSKIODDInterpreter' , readParameterRowSelectedCSKIODDInterpreter )
13101344
1345+ local function checkForWriteMessagePrefixPostfix (content )
1346+ -- Check to set automatically prefix and postfix for write message
1347+ local prefix = ' '
1348+ local postfix = ' '
1349+
1350+ local _ , amountOfValues = string.gsub (content , ' "value":' ,' ' )
1351+ if amountOfValues == 1 then
1352+ local tempPrefix = string.find (content , ' "value":' )
1353+ if tempPrefix then
1354+ prefix = string.sub (content , 1 , tempPrefix + 7 )
1355+ local _ , amountPostfix = string.gsub (content , ' {' ,' ' )
1356+ postfix = ' '
1357+ for i = 1 , amountPostfix do
1358+ postfix = postfix .. ' }'
1359+ end
1360+ end
1361+ end
1362+
1363+ if prefix ~= ' ' and postfix ~= ' ' then
1364+ CSK_MultiIOLinkSMI .setWriteMessagePrefix (prefix )
1365+ CSK_MultiIOLinkSMI .setWriteMessagePostfix (postfix )
1366+ else
1367+ CSK_MultiIOLinkSMI .setWriteMessagePrefix (' ' )
1368+ CSK_MultiIOLinkSMI .setWriteMessagePostfix (' ' )
1369+ end
1370+ end
1371+
13111372local function processDataOutRowSelectedCSKIODDInterpreter (rowData )
13121373 if CSK_IODDInterpreter then
13131374 local jsonTemplate , jsonDataInfo = CSK_IODDInterpreter .processDataOutRowSelected (rowData , ' writeIOLink_' )
1375+ checkForWriteMessagePrefixPostfix (jsonTemplate )
13141376 handleOnNewWriteDataJsonTemplateAndInfo (jsonTemplate , jsonDataInfo )
13151377 local processDataTableContent = CSK_IODDInterpreter .getWriteDataTableContents (' writeIOLink_' )
13161378 Script .notifyEvent (' MultiIOLinkSMI_OnNewProcessDataOutTableContentCSKIODDInterpreter' , processDataTableContent )
@@ -1320,6 +1382,20 @@ local function processDataOutRowSelectedCSKIODDInterpreter(rowData)
13201382end
13211383Script .serveFunction (' CSK_MultiIOLinkSMI.processDataOutRowSelectedCSKIODDInterpreter' , processDataOutRowSelectedCSKIODDInterpreter )
13221384
1385+ local function setWriteMessagePrefix (prefix )
1386+ multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages [selectedIODDWriteMessage ].prefix = prefix
1387+ Script .notifyEvent (' MultiIOLinkSMI_OnNewWriteMessagePrefix' , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages [selectedIODDWriteMessage ].prefix )
1388+ Script .notifyEvent (' MultiIOLinkSMI_OnNewProcessingParameter' , selectedInstance , ' writeMessage' , json .encode (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages ))
1389+ end
1390+ Script .serveFunction (' CSK_MultiIOLinkSMI.setWriteMessagePrefix' , setWriteMessagePrefix )
1391+
1392+ local function setWriteMessagePostfix (postfix )
1393+ multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages [selectedIODDWriteMessage ].postfix = postfix
1394+ Script .notifyEvent (' MultiIOLinkSMI_OnNewWriteMessagePostfix' , multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages [selectedIODDWriteMessage ].postfix )
1395+ Script .notifyEvent (' MultiIOLinkSMI_OnNewProcessingParameter' , selectedInstance , ' writeMessage' , json .encode (multiIOLinkSMI_Instances [selectedInstance ].parameters .ioddWriteMessages ))
1396+ end
1397+ Script .serveFunction (' CSK_MultiIOLinkSMI.setWriteMessagePostfix' , setWriteMessagePostfix )
1398+
13231399local function writeParameterRowSelectedCSKIODDInterpreter (rowData )
13241400 if CSK_IODDInterpreter then
13251401 local jsonTemplate , jsonDataInfo = CSK_IODDInterpreter .writeParameterRowSelected (rowData , ' writeIOLink_' )
0 commit comments