diff --git a/CHANGELOG.md b/CHANGELOG.md index cd42d41..cbdbc82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,24 @@ # Changelog All notable changes to this project will be documented in this file. +## Release 2.2.0 + +### New features +- Provide version of module via 'OnNewStatusModuleVersion' +- Function 'getParameters' to provide PersistentData parameters +- Check if features of module can be used on device and provide this via 'OnNewStatusModuleIsActive' event / 'getStatusModuleActive' function + +### Improvements +- New UI design available (e.g. selectable via CSK_Module_PersistentData v4.1.0 or higher), see 'OnNewStatusCSKStyle' +- Show timestamp info after ping +- Check interface selection within UI table +- 'loadParameters' returns its success +- 'sendParameters' can control if sent data should be saved directly by CSK_Module_PersistentData +- Added browser tab information +- Minor UI changes + +### Bugfix +- Error while trying to set nameserver if running on emulator or SAE ## Release 2.1.0 diff --git a/CSK_Module_DeviceNetworkConfig/pages/assets/CSK_Module_DeviceNetworkConfig/UI_sample.png b/CSK_Module_DeviceNetworkConfig/pages/assets/CSK_Module_DeviceNetworkConfig/UI_sample.png new file mode 100644 index 0000000..08022d5 Binary files /dev/null and b/CSK_Module_DeviceNetworkConfig/pages/assets/CSK_Module_DeviceNetworkConfig/UI_sample.png differ diff --git a/CSK_Module_DeviceNetworkConfig/pages/assets/legacy/settings.json b/CSK_Module_DeviceNetworkConfig/pages/assets/legacy/settings.json index 939ec2a..a845df1 100644 --- a/CSK_Module_DeviceNetworkConfig/pages/assets/legacy/settings.json +++ b/CSK_Module_DeviceNetworkConfig/pages/assets/legacy/settings.json @@ -1,3 +1,9 @@ { -"showLoginButton": false + "canChangeLanguage": true, + "showLoginButton": false, + "defaultLanguage": "en", + "disableEditMode": true, + "showPageHistory": true, + "compactMode": false, + "canChangeCompactMode": false } \ No newline at end of file diff --git a/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.css b/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.css index eadc5e2..d2060d1 100644 --- a/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.css +++ b/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.css @@ -1,10 +1,56 @@ +.myCustomMinWidth_CSK_Module_DeviceNetworkConfig { + min-width: 60px; +} + +.myCustomSpacerVert10_CSK_Module_DeviceNetworkConfig { + min-height: 10px; +} + +.myCustomSpacerVert20_CSK_Module_DeviceNetworkConfig { + min-height: 20px; +} + +.myCustomFrameNoColor_CSK_Module_DeviceNetworkConfig { + margin: 6px; + border-radius: 10px; + border-style: solid; + border-width: 0px; + border-color: 007CC1; + background-color: white; +} + .myCustomFrame_CSK_Module_DeviceNetworkConfig { + margin: 6px; + border-radius: 10px; border-style: solid; border-width: 1px; - border-color: grey; - margin: 6px; + border-color: #007CC1; + background-color: white; } -.myCustomMinWidth_CSK_Module_DeviceNetworkConfig { - min-width: 60px; +.myCustomLabel_CSK_Module_DeviceNetworkConfig { + font-size:30px; + color: grey; + margin-top: 10px; +} + +.myCustomFrameLabel_CSK_Module_DeviceNetworkConfig { + background: white; + position:relative; + top: calc(-1.2rem); + left: calc(1rem); + font-size: medium; +} + +.myCustomBorderBottom_CSK_Module_DeviceNetworkConfig { + border-bottom: 1px solid lightgray; + margin-inline: calc(1rem); +} + +.myCustomBackground_CSK_Module_DeviceNetworkConfig { +} + +.myCustomButton_CSK_Module_DeviceNetworkConfig { + border-radius: 30px; + padding-right: 0px; } diff --git a/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.html b/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.html index 871f7a7..b5bf2dc 100644 --- a/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.html +++ b/CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.html @@ -1,288 +1,388 @@ - - - - - - - - - - Applied network configuration will be saved persistently. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Applied network configuration will be saved persistently. + + + + + + ... Currently processing ... + + + + + + + New config accepted + + + + + New config NOT accepted + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To delete a nameserver, please select a DNS entry from the list and press 'Remove'. +
+ A maximum of three nameserves can be added. Nameservers that are added automatically via DHCP cannot be deleted. +
+ Please note that the DNS entries can only be persistent, if the app 'CSK_Module_PersistentData' is loaded. +
+
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + + Please login with at least user level 'Maintenance' or higher to see this page. - -
- - - - ... Currently processing ... - - - - - - - New config accepted - - - - - New config NOT accepted - - - - - - Refresh - - - -

Interface settings

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Apply new network configuration - - - - - -

DNS settings

-

To delete a nameserver, please select a DNS entry from the list and press "Remove".
- A maximum of three nameserves can be added.
- Nameservers that are added automatically via DHCP cannot be deleted.

- Please note that the DNS entries can only be persisted, if the app "CSK_Module_PersistentData" is loaded.

- - - - - - - - - - - - - - Add - - - - - - - - - - - - - - - - - - - Remove - - - - - - - - - -

Tools

- - - - - - - PING - - - - - - - - - - - - - -
-
-
- - - - - Please login with at least user level 'Maintenance' or higher to see this page. - - - - - - -
- - - - -
- -
+ + + + + + + + + + + + Module is not supported on this device... + + UI sample + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSK_Module_DeviceNetworkConfig/pages/pages/navigation.json b/CSK_Module_DeviceNetworkConfig/pages/pages/navigation.json index 7f2c3a0..3f3a226 100644 --- a/CSK_Module_DeviceNetworkConfig/pages/pages/navigation.json +++ b/CSK_Module_DeviceNetworkConfig/pages/pages/navigation.json @@ -1,14 +1,4 @@ { - "version": "1.0", - "pages": [ - { - "category": "CSK Module Device Network Config", - "pages": [ - { - "path": "CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.html", - "name": "Network Configuration" - } - ] - } - ] + "version": "1.0", + "pages": [] } \ No newline at end of file diff --git a/CSK_Module_DeviceNetworkConfig/pages/src/converter.ts b/CSK_Module_DeviceNetworkConfig/pages/src/converter.ts index 51af689..14b9619 100644 --- a/CSK_Module_DeviceNetworkConfig/pages/src/converter.ts +++ b/CSK_Module_DeviceNetworkConfig/pages/src/converter.ts @@ -15,4 +15,65 @@ export function InvalidUpstreamIPv4Display(inState) { } return null +} + +export function changeStyle(theme) { + const style: HTMLStyleElement = document.createElement('style'); + style.id ='blub' + if (theme == 'CSK_Style'){ + var headerToolbar = `.sopasjs-ui-header-toolbar-wrapper { background-color: #FFFFFF; }` + var uiHeader = `.sopasjs-ui-header>.app-logo { margin-right:0px; }` + var appLogo = `.app-logo { background-color:#FFFFFF; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAAtCAIAAACmg/d8AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAArZSURBVHhe7Zp7bFtXHccH6+i6AauYBu1AQgzGYLAJCQSiQMVLPIQE2garxiRAG0IM/iggjWpTmzZNX3k1aV5O4rycd7O8mrZJmjRJ7fgRO+80dhzHTvyIHdt52I7jt3PL17mue+z41ZJKm+Ovfn9Y9/zO8fX5nHN+v9+9fuROUgmtJOAEVxJwgisJOMGVBJzgSgJOcCUBJ7iSgBNcScAJriTgBFcScILrQwTYuOEe01nrJ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bIPMyceOeKDEE37NuC1H4leRtlI0v+BkJqs/PotTnSDdY8vbyrsq1ogAOyubwoWsIa/XZhu7A4Vu3ugKGmijKtWBAYR7ZsF2osPJWZvWDGB6nRFmlwCBUaeRv0vwBChJ2K6oh0gyGI4Ov8HrtAcQFO6qOrJOAEVxJwgisJOMGVBJzgSgJOcCUBJ7iSgBNcScAJrTt3/gfzR65/IHLpiAAAAABJRU5ErkJggg==) }` + var uiNavbar =`.sopasjs-ui-navbar-wrapper { background-color: #737F85; }` + var navbarMenuLiActive = `.sopasjs-navbar-menu>li.active { background-color: #283c45; }` + var navbarMenuLiActiveA = `.sopasjs-navbar-menu>li.active>a { background-color: #283c45; }` + var navbarMeluLi = `.sopasjs-navbar-menu>li { color: #FFFFFF; }` + var navbarMeluLiA = `.sopasjs-navbar-menu>li>a { color: #FFFFFF; }` + var headerToolbarButtonHighlight = `.sopasjs-ui-header-toolbar-button.sopasjs-ui-navigation-navbutton>a.highlight { background-color: #737F85; }` + var toolbarButton = `.sopasjs-ui-header-toolbar-button>a { color: #283c45; }` + + var customBackground = `.CSK_Module_DeviceNetworkConfig .myCustomBackground_CSK_Module_DeviceNetworkConfig { background-color: #737F8522; }` // font-family: "Open Sans"; }` + + style.innerHTML = headerToolbar; + style.innerHTML += uiHeader; + style.innerHTML += appLogo; + style.innerHTML += uiNavbar; + style.innerHTML += navbarMenuLiActive; + style.innerHTML += navbarMenuLiActiveA; + style.innerHTML += navbarMeluLi; + style.innerHTML += navbarMeluLiA; + style.innerHTML += headerToolbarButtonHighlight; + style.innerHTML += toolbarButton; + + style.innerHTML += customBackground; + } + else if (theme == 'None'){ + var headerToolbar = `.sopasjs-ui-header-toolbar-wrapper { background-color: #007fc3; }` + var uiHeader = `.sopasjs-ui-header>.app-logo { margin-right:10px; }` + var appLogo = `.app-logo { background-color:#007fc3; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAABICAYAAAAUNQy9AAAAAXNSR0IArs4c6QAAAARnQ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14DrkhQx0AtG4v4UGzr8C7+kaD2l2rVWHQMWMMHg9U2zGTR6QLoK1zJuRCo/Y60bixiI18PLcIbpdYvNWvZWPQsWDM3qG2YyGID/MGdBfyHWL+aUIVfEcl3KH5Izy/Fx+mjsUa4KJD36XhTtjS8G176faStG2tdsMb1DKUs9oDfZcBpl5WNOH/GL6lI76hb8d2lixpXgtMvXIHBqRiujODSoG+A+Qn4GfBV4AJBfoms+h4vC3XsOTVuOvy8ZcFlT2q8iSyGaq7Tx5xEFkPwksUQvGQxBC9ZDMFLFkPwksUQvGQxBC9ZDMFLFkPwksUQvGQxBC9ZDMFLFkPwksUQvGQxBC9ZDMFnata/dLDegR+YrlcAAAAASUVORK5CYII=') }` + var uiNavbar =`.sopasjs-ui-navbar-wrapper { background-color: #f6f8f9; }` + var navbarMenuLiActive = `.sopasjs-navbar-menu>li.active { background-color: #007fc3; }` + var navbarMenuLiActiveA = `.sopasjs-navbar-menu>li.active>a { background-color: #007fc3; }` + var navbarMeluLi = `.sopasjs-navbar-menu>li { color: #697987; }` + var navbarMeluLiA = `.sopasjs-navbar-menu>li>a { color: #505f6b; }` + var headerToolbarButtonHighlight = `.sopasjs-ui-header-toolbar-button.sopasjs-ui-navigation-navbutton>a.highlight { background-color: #006093; }` + var toolbarButton = `.sopasjs-ui-header-toolbar-button>a { color: #cce5f3; }` + + var customBackground = `.CSK_Module_DeviceNetworkConfig .myCustomBackground_CSK_Module_DeviceNetworkConfig { background-color: #fff; }` // font-family: "sans-serif"; }` + + style.innerHTML = headerToolbar; + style.innerHTML += uiHeader; + style.innerHTML += appLogo; + style.innerHTML += uiNavbar; + style.innerHTML += navbarMenuLiActive; + style.innerHTML += navbarMenuLiActiveA; + style.innerHTML += navbarMeluLi; + style.innerHTML += navbarMeluLiA; + style.innerHTML += headerToolbarButtonHighlight; + style.innerHTML += toolbarButton; + + style.innerHTML += customBackground; + } + document.head.append(style); + return theme } \ No newline at end of file diff --git a/CSK_Module_DeviceNetworkConfig/pages/src/index.ts b/CSK_Module_DeviceNetworkConfig/pages/src/index.ts index 9f71c59..5ec9d21 100644 --- a/CSK_Module_DeviceNetworkConfig/pages/src/index.ts +++ b/CSK_Module_DeviceNetworkConfig/pages/src/index.ts @@ -1,12 +1,17 @@ -/** - * Customize icons for navigation tree - * - * List of available icons ("Font Awesome" collection) - * - */ document.addEventListener('sopasjs-ready', () => { - // "Configuration" page const page_1 = document.querySelector('div.sopasjs-ui-navbar-wrapper > div > ul > li:nth-child(3) > a > i'); page_1.classList.remove('fa-file'); page_1.classList.add('fa-wrench'); + + const page_FirstLabel = document.querySelector('div.sopasjs-ui-navbar-wrapper > div > ul > li:nth-child(2)'); + const page_App = document.querySelector('div.sopasjs-ui-navbar-wrapper > div > ul > li:nth-child(4)'); + const page_Setup = document.querySelector('div.sopasjs-ui-navbar-wrapper > div > ul > li:nth-child(5) > a'); + + page_FirstLabel.remove(); + page_App.remove(); + page_Setup.remove(); + + setTimeout(() => { + document.title = 'CSK_Module_DeviceNetworkConfig' + }, 500); }) \ No newline at end of file diff --git a/CSK_Module_DeviceNetworkConfig/project.mf.xml b/CSK_Module_DeviceNetworkConfig/project.mf.xml index 6b0040e..47d3d31 100644 --- a/CSK_Module_DeviceNetworkConfig/project.mf.xml +++ b/CSK_Module_DeviceNetworkConfig/project.mf.xml @@ -120,6 +120,18 @@ See following descriptions of events/functions regarding further information. Highlights the DNS 'IP' in UI if format of IP is not correct. + + Notify UI style to use for CSK modules. + + + + Notify version of module. + + + + Notify if module can be used on device. + + Function to register "OnResume" of the module UI (only as helper function). @@ -191,25 +203,36 @@ See following descriptions of events/functions regarding further information. Function to set the name of the parameters if saved/loaded via the CSK_PersistentData module. - - Send parameters to CSK_PersistentData module if possible to save them. + + Configure if this module should load its saved parameters at app/device boot up. + Load parameters for this module from the CSK_PersistentData module if possible and use them. + - - Configure if this module should load its saved parameters at app/device boot up. - + + released + Function to get all parameters of the client in JSON format. + + + + Send parameters to CSK_PersistentData module if possible to save them. + + + + Function to get status if module is active. + SICK AG - 2.1.0 + 2.2.0 low false false false - true + false diff --git a/CSK_Module_DeviceNetworkConfig/scripts/CSK_Module_DeviceNetworkConfig.lua b/CSK_Module_DeviceNetworkConfig/scripts/CSK_Module_DeviceNetworkConfig.lua index 4fff678..6d2ac51 100644 --- a/CSK_Module_DeviceNetworkConfig/scripts/CSK_Module_DeviceNetworkConfig.lua +++ b/CSK_Module_DeviceNetworkConfig/scripts/CSK_Module_DeviceNetworkConfig.lua @@ -26,6 +26,12 @@ --**********************Start Global Scope ********************************* --************************************************************************** ----------------------------------------------------------- +-- If app property "LuaLoadAllEngineAPI" is FALSE, use this to load and check for required APIs +-- This can improve performance of garbage collection +_G.availableAPIs = require('Configuration.DeviceNetworkConfig.helper.checkAPIs') -- can be used to adjust function scope of the module related on available APIs of the device +----------------------------------------------------------- +--************************************************************************** +----------------------------------------------------------- -- Logger _G.logger = Log.SharedLogger.create('ModuleLogger') _G.logHandle = Log.Handler.create() @@ -39,12 +45,17 @@ _G.logHandle:applyConfig() -- Check this script regarding DeviceNetworkConfig_Model parameters and functions _G.deviceNetworkConfig_Model = require('Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Model') +if _G.availableAPIs.default == false or _G.availableAPIs.specific == false then + _G.logger:warning("CSK_DeviceNetworkConfig: Relevant CROWN(s) not available on device. Module is not supported...") +else + _G.deviceNetworkConfig_Model.refreshInterfaces() +end + --************************************************************************** --**********************End Global Scope *********************************** --************************************************************************** --**********************Start Function Scope ******************************* --************************************************************************** -_G.deviceNetworkConfig_Model.refreshInterfaces() --- Function to react on startup event of the app local function main() diff --git a/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Controller.lua b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Controller.lua index c2e49a5..7ba2932 100644 --- a/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Controller.lua +++ b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Controller.lua @@ -8,7 +8,7 @@ --************************************************************************** --************************ Start Global Scope ****************************** --************************************************************************** -local NAME_OF_MODULE = 'CSK_DeviceNetworkConfig' +local nameOfModule = 'CSK_DeviceNetworkConfig' -- Timer to update UI via events after page was loaded local tmrDeviceNetworkConfig = Timer.create() @@ -31,6 +31,11 @@ local jsonInterfaceListContent -- available interfaces as JSON local deviceNetworkConfig_Model -- ************************ UI Events Start ******************************** + +Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusModuleVersion', 'DeviceNetworkConfig_OnNewStatusModuleVersion') +Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusCSKStyle', 'DeviceNetworkConfig_OnNewStatusCSKStyle') +Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusModuleIsActive', 'DeviceNetworkConfig_OnNewStatusModuleIsActive') + Script.serveEvent("CSK_DeviceNetworkConfig.OnNewStatusLoadParameterOnReboot", "DeviceNetworkConfig_OnNewStatusLoadParameterOnReboot") Script.serveEvent("CSK_DeviceNetworkConfig.OnPersistentDataModuleAvailable", "DeviceNetworkConfig_OnPersistentDataModuleAvailable") Script.serveEvent("CSK_DeviceNetworkConfig.OnNewParameterName", "DeviceNetworkConfig_OnNewParameterName") @@ -98,7 +103,8 @@ end --- Function to check what options should be adjustable in UI local function checkWhatToDisable() - if currentDHCP == true or (deviceNetworkConfig_Model.helperFuncs.checkIP(currentIP) and deviceNetworkConfig_Model.helperFuncs.checkIP(currentSubnet) and (deviceNetworkConfig_Model.helperFuncs.checkIP(currentGateway) or currentGateway == '')) then + + if currentDHCP == true or (deviceNetworkConfig_Model.helperFuncs.checkIP(currentIP) and deviceNetworkConfig_Model.helperFuncs.checkIP(currentSubnet) and (deviceNetworkConfig_Model.helperFuncs.checkIP(currentGateway) or currentGateway == '')) and currentInterfaceName ~= '-'then Script.notifyEvent("DeviceNetworkConfig_OnApplyButtonDisabled", false) else Script.notifyEvent("DeviceNetworkConfig_OnApplyButtonDisabled", true) @@ -146,7 +152,7 @@ end local function refresh() interfacesTable = deviceNetworkConfig_Model.refreshInterfaces() - jsonInterfaceListContent = deviceNetworkConfig_Model.helperFuncs.createJsonList(interfacesTable) + jsonInterfaceListContent = deviceNetworkConfig_Model.helperFuncs.createJsonList(interfacesTable, selectedInterfaceName) Script.notifyEvent("DeviceNetworkConfig_OnNewInterfaceTable", jsonInterfaceListContent) checkWhatToDisable() end @@ -169,19 +175,25 @@ end -- Get a list of all configured nameservers local function getNameserverList() local retValue = {} - for _,v in pairs(Ethernet.DNS.getNameservers()) do - -- To enable the display in the dynamic table using the keyword "dns" - ---@diagnostic disable-next-line: param-type-mismatch - table.insert(retValue, {dns= v}) + if _G.availableAPIs.specific == true then + for _,v in pairs(Ethernet.DNS.getNameservers()) do + -- To enable the display in the dynamic table using the keyword "dns" + ---@diagnostic disable-next-line: param-type-mismatch + table.insert(retValue, {dns= v}) + end end - -- If only 127.0.0.1 is use, hide it + -- If only 127.0.0.1 is used, hide it if #retValue == 1 then if retValue[1].dns == "127.0.0.1" then retValue = {} end end + if #retValue == 0 then + table.insert(retValue, {dns= '-'}) + end + return retValue end @@ -240,7 +252,7 @@ local function updateNameservers(nameserverList) for _,ip in pairs(l_cleanedList) do l_statusOutput = l_statusOutput .. ip .. " " end - _G.logger:info(NAME_OF_MODULE .. ": Added nameservers (" .. l_statusOutput ..")") + _G.logger:fine(nameOfModule .. ": Added nameservers (" .. l_statusOutput ..")") -- Store nameserver entries permanently CSK_DeviceNetworkConfig.sendParameters() @@ -312,9 +324,17 @@ Script.serveFunction('CSK_DeviceNetworkConfig.selectDNSViaUI', selectDNSViaUI) --- Function to send all relevant values to UI on resume local function handleOnExpiredTmrDeviceNetworkConfig() + + Script.notifyEvent("DeviceNetworkConfig_OnNewStatusModuleVersion", 'v' .. deviceNetworkConfig_Model.version) + Script.notifyEvent("DeviceNetworkConfig_OnNewStatusCSKStyle", deviceNetworkConfig_Model.styleForUI) + Script.notifyEvent("DeviceNetworkConfig_OnNewStatusModuleIsActive", _G.availableAPIs.default and _G.availableAPIs.specific) + updateUserLevel() - refresh() + if _G.availableAPIs.default and _G.availableAPIs.specific then + selectedInterfaceName = '' + refresh() + end currentInterfaceName = '-' currentIP = '-' currentSubnet = '-' @@ -345,25 +365,72 @@ local function pageCalled() end Script.serveFunction("CSK_DeviceNetworkConfig.pageCalled", pageCalled) +--- Function to check if selection in UIs DynamicTable can find related pattern +---@param selection string Full text of selection +---@param pattern string Pattern to search for +---@param findEnd bool Find end after pattern +---@return string? Success if pattern was found or even postfix after pattern till next quotation marks if findEnd was set to TRUE +local function checkSelection(selection, pattern, findEnd) + if selection ~= "" then + local _, pos = string.find(selection, pattern) + if pos == nil then + return nil + else + if findEnd then + pos = tonumber(pos) + local endPos = string.find(selection, '"', pos+1) + if endPos then + local tempSelection = string.sub(selection, pos+1, endPos-1) + if tempSelection ~= nil and tempSelection ~= '-' then + return tempSelection + end + else + return nil + end + else + return 'true' + end + end + end + return nil +end + local function selectInterface(row_selected) Script.notifyEvent("DeviceNetworkConfig_OnNewEthernetConfigStatus", 'empty') Script.notifyEvent("DeviceNetworkConfig_OnIPError", false) Script.notifyEvent("DeviceNetworkConfig_OnSubnetError", false) Script.notifyEvent("DeviceNetworkConfig_OnGatewayError", false) - local _, pos1 = string.find(row_selected, '"Interface":"') - local pos2, _ = string.find(row_selected, '"', pos1+1) - local selectedInterfaceName = string.sub(row_selected, pos1+1, pos2-1) + + local tempSelection = checkSelection(row_selected, '"Interface":"', true) + if tempSelection then + local isSelected = checkSelection(row_selected, '"selected":true', false) + if isSelected then + selectedInterfaceName = tempSelection + else + selectedInterfaceName = '-' + end + else + selectedInterfaceName = '-' + end + + currentInterfaceName = selectedInterfaceName + if selectedInterfaceName ~= '-' and selectedInterfaceName ~= '' then currentIP = interfacesTable[selectedInterfaceName].ipAddress currentSubnet = interfacesTable[selectedInterfaceName].subnetMask currentGateway = interfacesTable[selectedInterfaceName].defaultGateway currentDHCP = interfacesTable[selectedInterfaceName].dhcp - currentInterfaceName = selectedInterfaceName Script.notifyEvent("DeviceNetworkConfig_OnNewIP", currentIP) Script.notifyEvent("DeviceNetworkConfig_OnNewSubnetMask", currentSubnet) Script.notifyEvent("DeviceNetworkConfig_OnNewDefaultGateway", currentGateway) Script.notifyEvent("DeviceNetworkConfig_OnNewDHCPStatus", currentDHCP) Script.notifyEvent("DeviceNetworkConfig_OnNewInterfaceChoice",currentInterfaceName) + else + Script.notifyEvent("DeviceNetworkConfig_OnNewIP", '-') + Script.notifyEvent("DeviceNetworkConfig_OnNewSubnetMask", '-') + Script.notifyEvent("DeviceNetworkConfig_OnNewDefaultGateway", '-') + Script.notifyEvent("DeviceNetworkConfig_OnNewDHCPStatus", false) + Script.notifyEvent("DeviceNetworkConfig_OnNewInterfaceChoice", '-') end if currentDHCP == true then Script.notifyEvent("DeviceNetworkConfig_OnIPDisabled", true) @@ -371,6 +438,7 @@ local function selectInterface(row_selected) Script.notifyEvent("DeviceNetworkConfig_OnGatewayDisabled", true) end Script.sleep(100) + jsonInterfaceListContent = deviceNetworkConfig_Model.helperFuncs.createJsonList(interfacesTable, selectedInterfaceName) Script.notifyEvent("DeviceNetworkConfig_OnNewInterfaceTable", jsonInterfaceListContent) checkWhatToDisable() end @@ -432,7 +500,12 @@ local function ping() local succes, time = Ethernet.ping(deviceNetworkConfig_Model.ping_ip_adress) Script.notifyEvent("DeviceNetworkConfig_OnNewPingResult", succes) if (time) then - Script.notifyEvent("DeviceNetworkConfig_OnNewPingDetails", tostring(time).." ms") + if availableAPIs.dateTime then + local currentTime = tostring(DateTime.getTimestamp()) + Script.notifyEvent("DeviceNetworkConfig_OnNewPingDetails", tostring(time).." ms (at timestamp " .. currentTime .. ")") + else + Script.notifyEvent("DeviceNetworkConfig_OnNewPingDetails", tostring(time).." ms") + end else Script.notifyEvent("DeviceNetworkConfig_OnNewPingDetails", "No Connection") end @@ -443,10 +516,10 @@ local function applyConfig() if deviceNetworkConfig_Model.helperFuncs.checkIP(currentIP) and deviceNetworkConfig_Model.helperFuncs.checkIP(currentSubnet) and deviceNetworkConfig_Model.helperFuncs.checkIP(currentGateway) or currentGateway == '' then Script.notifyEvent("DeviceNetworkConfig_OnNewEthernetConfigStatus", 'processing') if currentDHCP == true then - _G.logger:info(NAME_OF_MODULE .. ": Applying device's Ethernet config: \n Interface " .. currentInterfaceName .. " \n DHCP: " .. tostring(currentDHCP)) + _G.logger:info(nameOfModule .. ": Applying device's Ethernet config: \n Interface " .. currentInterfaceName .. " \n DHCP: " .. tostring(currentDHCP)) deviceNetworkConfig_Model.applyEthernetConfig(currentInterfaceName, currentDHCP, nil, nil, nil) else - _G.logger:info(NAME_OF_MODULE .. ": Applying device's Ethernet config: \n Interface " .. currentInterfaceName .. " \n DHCP: " .. tostring(currentDHCP) .. " \n IP: " .. currentIP.. " \n Subnet: " .. currentSubnet .. " \n Gateway: " .. currentGateway) + _G.logger:info(nameOfModule .. ": Applying device's Ethernet config: \n Interface " .. currentInterfaceName .. " \n DHCP: " .. tostring(currentDHCP) .. " \n IP: " .. currentIP.. " \n Subnet: " .. currentSubnet .. " \n Gateway: " .. currentGateway) deviceNetworkConfig_Model.applyEthernetConfig(currentInterfaceName, currentDHCP, currentIP, currentSubnet, currentGateway) end refresh() @@ -454,35 +527,47 @@ local function applyConfig() else Script.notifyEvent("DeviceNetworkConfig_OnNewEthernetConfigStatus", 'error') end - _G.logger:info(NAME_OF_MODULE .. ": Applying device's Ethernet config finished") + _G.logger:info(nameOfModule .. ": Applying device's Ethernet config finished") end Script.serveFunction("CSK_DeviceNetworkConfig.applyConfig", applyConfig) --- Function to react 'Ethernet.Interface.OnLinkActiveChanged' event local function handleOnLinkActiveChanged(ifName, linkActive) refresh() - _G.logger:info(NAME_OF_MODULE .. ': New link status = ' .. tostring(linkActive) .. ' on interface ' .. ifName) + _G.logger:fine(nameOfModule .. ': New link status = ' .. tostring(linkActive) .. ' on interface ' .. ifName) end Script.register("Ethernet.Interface.OnLinkActiveChanged", handleOnLinkActiveChanged) +local function getParameters() + return deviceNetworkConfig_Model.helperFuncs.json.encode(deviceNetworkConfig_Model.parameters) +end +Script.serveFunction('CSK_DeviceNetworkConfig.getParameters', getParameters) + +local function getStatusModuleActive() + return _G.availableAPIs.default and _G.availableAPIs.specific +end +Script.serveFunction('CSK_DeviceNetworkConfig.getStatusModuleActive', getStatusModuleActive) + -- ********************************************************************************** -- Following function can be adapted for CSK_PersistentData module usage -- ********************************************************************************** local function setParameterName(name) - _G.logger:info(NAME_OF_MODULE .. ": Set parameter name: " .. tostring(name)) + _G.logger:fine(nameOfModule .. ": Set parameter name: " .. tostring(name)) deviceNetworkConfig_Model.parametersName = tostring(name) end Script.serveFunction("CSK_DeviceNetworkConfig.setParameterName", setParameterName) -local function sendParameters() +local function sendParameters(noDataSave) if deviceNetworkConfig_Model.persistentModuleAvailable then CSK_PersistentData.addParameter(deviceNetworkConfig_Model.helperFuncs.convertTable2Container(deviceNetworkConfig_Model.parameters), deviceNetworkConfig_Model.parametersName) - CSK_PersistentData.setModuleParameterName(NAME_OF_MODULE, deviceNetworkConfig_Model.parametersName, deviceNetworkConfig_Model.parameterLoadOnReboot) - _G.logger:info(NAME_OF_MODULE .. ": Send DeviceNetworkConfig parameters with name '" .. deviceNetworkConfig_Model.parametersName .. "' to CSK_PersistentData module.") - CSK_PersistentData.saveData() + CSK_PersistentData.setModuleParameterName(nameOfModule, deviceNetworkConfig_Model.parametersName, deviceNetworkConfig_Model.parameterLoadOnReboot) + _G.logger:fine(nameOfModule .. ": Send DeviceNetworkConfig parameters with name '" .. deviceNetworkConfig_Model.parametersName .. "' to CSK_PersistentData module.") + if not noDataSave then + CSK_PersistentData.saveData() + end else - _G.logger:warning(NAME_OF_MODULE .. ": CSK_PersistentData Module not available.") + _G.logger:warning(nameOfModule .. ": CSK_PersistentData Module not available.") end end Script.serveFunction("CSK_DeviceNetworkConfig.sendParameters", sendParameters) @@ -491,49 +576,57 @@ local function loadParameters() if deviceNetworkConfig_Model.persistentModuleAvailable then local data = CSK_PersistentData.getParameter(deviceNetworkConfig_Model.parametersName) if data then - _G.logger:info(NAME_OF_MODULE .. ": Loaded parameters from CSK_PersistentData module.") + _G.logger:info(nameOfModule .. ": Loaded parameters from CSK_PersistentData module.") deviceNetworkConfig_Model.parameters = deviceNetworkConfig_Model.helperFuncs.convertContainer2Table(data) -- Load nameservers - updateNameservers(deviceNetworkConfig_Model.parameters.nameservers) + if deviceNetworkConfig_Model.deviceType ~= 'AppEngine' then + updateNameservers(deviceNetworkConfig_Model.parameters.nameservers) + end CSK_DeviceNetworkConfig.pageCalled() + return true else - _G.logger:warning(NAME_OF_MODULE .. ": Loading parameters from CSK_PersistentData module did not work.") + _G.logger:warning(nameOfModule .. ": Loading parameters from CSK_PersistentData module did not work.") + return false end else - _G.logger:warning(NAME_OF_MODULE .. ": CSK_PersistentData Module not available.") + _G.logger:warning(nameOfModule .. ": CSK_PersistentData Module not available.") + return false end end Script.serveFunction("CSK_DeviceNetworkConfig.loadParameters", loadParameters) local function setLoadOnReboot(status) deviceNetworkConfig_Model.parameterLoadOnReboot = status - _G.logger:info(NAME_OF_MODULE .. ": Set new status to load setting on reboot: " .. tostring(status)) + _G.logger:fine(nameOfModule .. ": Set new status to load setting on reboot: " .. tostring(status)) end Script.serveFunction("CSK_DeviceNetworkConfig.setLoadOnReboot", setLoadOnReboot) --- Function to react on initial load of persistent parameters local function handleOnInitialDataLoaded() - if string.sub(CSK_PersistentData.getVersion(), 1, 1) == '1' then + if _G.availableAPIs.default and _G.availableAPIs.specific then + _G.logger:fine(nameOfModule .. ': Try to initially load parameter from CSK_PersistentData module.') + if string.sub(CSK_PersistentData.getVersion(), 1, 1) == '1' then - _G.logger:warning(NAME_OF_MODULE .. ': CSK_PersistentData module is too old and will not work. Please update CSK_PersistentData module.') + _G.logger:warning(nameOfModule .. ': CSK_PersistentData module is too old and will not work. Please update CSK_PersistentData module.') - deviceNetworkConfig_Model.persistentModuleAvailable = false - else + deviceNetworkConfig_Model.persistentModuleAvailable = false + else - local parameterName, loadOnReboot = CSK_PersistentData.getModuleParameterName(NAME_OF_MODULE) + local parameterName, loadOnReboot = CSK_PersistentData.getModuleParameterName(nameOfModule) - if parameterName then - deviceNetworkConfig_Model.parametersName = parameterName - deviceNetworkConfig_Model.parameterLoadOnReboot = loadOnReboot - end + if parameterName then + deviceNetworkConfig_Model.parametersName = parameterName + deviceNetworkConfig_Model.parameterLoadOnReboot = loadOnReboot + end - if deviceNetworkConfig_Model.parameterLoadOnReboot then - loadParameters() + if deviceNetworkConfig_Model.parameterLoadOnReboot then + loadParameters() + end + Script.notifyEvent('DeviceNetworkConfig_OnDataLoadedOnReboot') end - Script.notifyEvent('DeviceNetworkConfig_OnDataLoadedOnReboot') end end Script.register("CSK_PersistentData.OnInitialDataLoaded", handleOnInitialDataLoaded) diff --git a/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Model.lua b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Model.lua index c2378af..a5452c9 100644 --- a/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Model.lua +++ b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Model.lua @@ -29,13 +29,24 @@ deviceNetworkConfig_Model.helperFuncs = require('Configuration/DeviceNetworkConf deviceNetworkConfig_Model.interfacesTable = {} -- table to hold setup of available ethernet interfaces deviceNetworkConfig_Model.ping_ip_adress = "" -- IP address to check for ping +deviceNetworkConfig_Model.styleForUI = 'None' -- Optional parameter to set UI style +deviceNetworkConfig_Model.version = Engine.getCurrentAppVersion() -- Version of module + +-- Get device type +local typeName = Engine.getTypeName() +if typeName == 'AppStudioEmulator' or typeName == 'SICK AppEngine' then + deviceNetworkConfig_Model.deviceType = 'AppEngine' +else + deviceNetworkConfig_Model.deviceType = string.sub(typeName, 1, 7) +end + deviceNetworkConfig_Model.parameters = {} deviceNetworkConfig_Model.parameters.nameservers = {}; -- Name servers (DNS) -- Default values for persistent data -- If available, following values will be updated from data of CSK_PersistentData module (check CSK_PersistentData module for this) deviceNetworkConfig_Model.parametersName = 'CSK_DeviceNetworkConfig_Parameter' -- name of parameter dataset to be used for this module -deviceNetworkConfig_Model.parameterLoadOnReboot = true -- Status if parameter dataset should be loaded on app/device reboot +deviceNetworkConfig_Model.parameterLoadOnReboot = false -- Status if parameter dataset should be loaded on app/device reboot --************************************************************************** --********************** End Global Scope ********************************** @@ -43,6 +54,13 @@ deviceNetworkConfig_Model.parameterLoadOnReboot = true -- Status if parameter da --**********************Start Function Scope ******************************* --************************************************************************** +--- Function to react on UI style change +local function handleOnStyleChanged(theme) + deviceNetworkConfig_Model.styleForUI = theme + Script.notifyEvent("DeviceNetworkConfig_OnNewStatusCSKStyle", deviceNetworkConfig_Model.styleForUI) +end +Script.register('CSK_PersistentData.OnNewStatusCSKStyle', handleOnStyleChanged) + ---Function to get current setting of ethernet interfaces local function refreshInterfaces() deviceNetworkConfig_Model.interfacesTable = {} diff --git a/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/helper/checkAPIs.lua b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/helper/checkAPIs.lua new file mode 100644 index 0000000..343b001 --- /dev/null +++ b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/helper/checkAPIs.lua @@ -0,0 +1,54 @@ +---@diagnostic disable: undefined-global, redundant-parameter, missing-parameter + +-- Load all relevant APIs for this module +--************************************************************************** + +local availableAPIs = {} + +-- Function to load all default APIs +local function loadAPIs() + CSK_DeviceNetworkConfig = require 'API.CSK_DeviceNetworkConfig' + + Log = require 'API.Log' + Log.Handler = require 'API.Log.Handler' + Log.SharedLogger = require 'API.Log.SharedLogger' + + Container = require 'API.Container' + + Engine = require 'API.Engine' + File = require 'API.File' + Object = require 'API.Object' + Parameters = require 'API.Parameters' + Timer = require 'API.Timer' + + -- Check if related CSK modules are available to be used + local appList = Engine.listApps() + for i = 1, #appList do + if appList[i] == 'CSK_Module_PersistentData' then + CSK_PersistentData = require 'API.CSK_PersistentData' + elseif appList[i] == 'CSK_Module_UserManagement' then + CSK_UserManagement = require 'API.CSK_UserManagement' + end + end +end + +-- Function to load specific APIs +local function loadSpecificAPIs() + -- If you want to check for specific APIs/functions supported on the device the module is running, place relevant APIs here + Ethernet = require 'API.Ethernet' + Ethernet.DNS = require 'API.Ethernet.DNS' + Ethernet.Interface = require 'API.Ethernet.Interface' +end + +-- Function to load DateTime APIs +local function loadDateTimeAPIs() + -- If you want to check for specific APIs/functions supported on the device the module is running, place relevant APIs here + DateTime = require 'API.DateTime' +end + +availableAPIs.default = xpcall(loadAPIs, debug.traceback) -- TRUE if all default APIs were loaded correctly +availableAPIs.specific = xpcall(loadSpecificAPIs, debug.traceback) -- TRUE if all specific APIs were loaded correctly +availableAPIs.dateTime = xpcall(loadDateTimeAPIs, debug.traceback) -- TRUE if DateTime API was loaded correctly + +return availableAPIs +--************************************************************************** \ No newline at end of file diff --git a/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/helper/funcs.lua b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/helper/funcs.lua index a29d25c..294144a 100644 --- a/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/helper/funcs.lua +++ b/CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/helper/funcs.lua @@ -50,8 +50,12 @@ end --- Function to create a json string out of a table content ---@param content string[] Content to use +---@param selection int? Currently selected parameter ---@return string jsonstring Json list of entries -local function createJsonList(content) +local function createJsonList(content, selection) + if selection == nil then + selection = 0 + end local contentList = {} if content == nil then contentList = { @@ -68,6 +72,10 @@ local function createJsonList(content) else local sortedTableKeys = getSortedTableKeys(content) for _, tableKey in ipairs(sortedTableKeys) do + local isSelected = false + if tableKey == selection then + isSelected = true + end table.insert(contentList, { Interface = content[tableKey].interfaceName, @@ -76,7 +84,8 @@ local function createJsonList(content) DefaultGateway = content[tableKey].defaultGateway, DHCP = content[tableKey].dhcp, MACAddress = content[tableKey].macAddress, - Connected = content[tableKey].isLinkActive + Connected = content[tableKey].isLinkActive, + selected = isSelected } ) end diff --git a/README.md b/README.md index 4255839..979f832 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,15 @@ For further information check out the [documentation](https://raw.githack.com/SI ## Information -Tested on: -1. SIM1012 - Firmware 2.3.0 -2. SIM1000fx - Firmware 1.7.2 +Tested on: +|Device|Firmware|Module version| +|--|--|--| +|SICK AppEngine|V1.7.0|V2.2.0| +|SIM1012|V2.4.2|V2.2.0| +|SIM1000FX|V1.7.2|**Please note** -> This application / module is part of the SICK AppSpace Coding Starter Kit developing approach. +This module is part of the SICK AppSpace Coding Starter Kit developing approach. It is programmed in an object oriented way. Some of the modules use kind of "classes" in Lua to make it possible to reuse code / classes in other projects. In general it is not neccessary to code this way, but the architecture of this app can serve as a sample to be used especially for bigger projects and to make it easier to share code. Please check the [documentation](https://github.com/SICKAppSpaceCodingStarterKit/.github/blob/main/docu/SICKAppSpaceCodingStarterKit_Documentation.md) of CSK for further information. @@ -23,7 +26,7 @@ Please check the [documentation](https://github.com/SICKAppSpaceCodingStarterKit |Module|Version|Remark |--|--|--| -|CSK_Module_PersistentData|[V4.0.0](https://github.com/SICKAppSpaceCodingStarterKit/CSK_Module_PersistentData/releases/tag/v4.0.0)|Necessary to persist the DNS settings +|CSK_Module_PersistentData|[>=V4.0.0](https://github.com/SICKAppSpaceCodingStarterKit/CSK_Module_PersistentData)|Necessary to persist the DNS settings ## Topics Coding Starter Kit, CSK, Module, SICK-AppSpace, Ethernet, Interface, Config, Device, DNS, DHCP, IP, PING diff --git a/docu/CSK_Module_DeviceNetworkConfig.html b/docu/CSK_Module_DeviceNetworkConfig.html index 06125ac..97361e9 100644 --- a/docu/CSK_Module_DeviceNetworkConfig.html +++ b/docu/CSK_Module_DeviceNetworkConfig.html @@ -6,7 +6,7 @@ -Documentation - CSK_Module_DeviceNetworkConfig 2.1.0 +Documentation - CSK_Module_DeviceNetworkConfig 2.2.0