Skip to content

Commit c869946

Browse files
Release 2.1.0 (#5)
# Release 2.1.0 ## New features - Protocol (HTTP, HTTPS) selectable within FlowConfig block ## Improvements - Do not automatically select new added request within UI table (might confuse user) ## Bugfix - Adds multiple 'http://' to endpoint
1 parent bba0b76 commit c869946

6 files changed

Lines changed: 111 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
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+
- Protocol (HTTP, HTTPS) selectable within FlowConfig block
8+
9+
### Improvements
10+
- Do not automatically select new added request within UI table (might confuse user)
11+
- Sort preconfigured requests within UI in alphabetic order
12+
13+
### Bugfix
14+
- Adds multiple 'http://' to endpoint
15+
416
## Release 2.0.0
517

618
### New features

CSK_Module_MultiHTTPClient/project.mf.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ The module will dynamically create events to provide the incoming response of th
4747
<item name="TRACE">TRACE</item>
4848
<item name="OPTIONS">OPTIONS</item>
4949
</enum>
50+
<enum name="Protocol" trait="released">
51+
<desc>Protocol to use for requests.</desc>
52+
<item desc="HTTP" name="HTTP">HTTP</item>
53+
<item desc="HTTPS" name="HTTPS">HTTPS</item>
54+
</enum>
5055
<serves>
5156
<event name="OnNewStatusLoadParameterOnReboot">
5257
<desc>Notify status if parameters should be loaded on app/device boot up.</desc>
@@ -404,6 +409,7 @@ IMPORTANT: As instances start their own threads, the module needs to be restarte
404409
<param desc="Name of event to get data to send via HTTP request.&#10;If not used, fill with ''." multiplicity="1" name="event" type="string"/>
405410
<param desc="Status of request is periodic." multiplicity="1" name="periodic" type="bool"/>
406411
<param desc="Optional time of request period in ms." multiplicity="?" name="period" type="int"/>
412+
<param desc="Optional protocol of request." multiplicity="?" name="protocol" ref="CSK_MultiHTTPClient.Protocol" type="enum"/>
407413
</function>
408414
<function name="sendRequestViaUI">
409415
<desc>Function to trigger preconfigured request via UI.</desc>
@@ -508,6 +514,7 @@ IMPORTANT: As instances start their own threads, the module needs to be restarte
508514
<param constraint="1-99" desc="Numeric identifier of processing instance." multiplicity="1" name="Instance" type="int"/>
509515
<param desc="Name of request." multiplicity="1" name="RequestName" type="string"/>
510516
<param desc="Mode of request." multiplicity="1" name="Mode" ref="CSK_MultiHTTPClient.RequestMode" type="enum"/>
517+
<param desc="Protocol of request." multiplicity="1" name="Protocol" ref="CSK_MultiHTTPClient.Protocol" type="enum"/>
511518
<param desc="Endpoint for request WITHOUT leading 'http://'" multiplicity="1" name="Endpoint" type="string"/>
512519
<param desc="Port for request." multiplicity="1" name="Port" type="int"/>
513520
<return desc="Handle to internally used FlowConfig instance." multiplicity="1" name="handle" type="handle"/>
@@ -523,7 +530,7 @@ IMPORTANT: As instances start their own threads, the module needs to be restarte
523530
</crown>
524531
</crown>
525532
<meta key="author">SICK AG</meta>
526-
<meta key="version">2.0.0</meta>
533+
<meta key="version">2.1.0</meta>
527534
<meta key="priority">low</meta>
528535
<meta key="copy-protected">false</meta>
529536
<meta key="read-protected">false</meta>

CSK_Module_MultiHTTPClient/scripts/Communication/MultiHTTPClient/FlowConfig/MultiHTTPClient_SendRequest.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local function sendRequest(handle, source)
1313
local instance = Container.get(handle, 'Instance')
1414
local requestName = Container.get(handle, 'RequestName')
1515
local mode = Container.get(handle, 'Mode')
16+
local protocol = Container.get(handle, 'Protocol')
1617
local endpoint = Container.get(handle, 'Endpoint')
1718
local port = Container.get(handle, 'Port')
1819

@@ -25,7 +26,7 @@ local function sendRequest(handle, source)
2526
else
2627
CSK_MultiHTTPClient.setSelectedInstance(instance)
2728

28-
CSK_MultiHTTPClient.addRequest(requestName, mode, endpoint, port, source, false)
29+
CSK_MultiHTTPClient.addRequest(requestName, mode, endpoint, port, source, false, nil, protocol)
2930
break
3031
end
3132
end
@@ -37,7 +38,7 @@ Script.serveFunction(BLOCK_NAMESPACE .. '.sendRequest', sendRequest)
3738
--*************************************************************
3839
--*************************************************************
3940

40-
local function create(instance, requestName, mode, endpoint, port)
41+
local function create(instance, requestName, mode, protocol, endpoint, port)
4142

4243
local fullInstanceName = tostring(instance) .. tostring(requestName)
4344

@@ -52,6 +53,7 @@ local function create(instance, requestName, mode, endpoint, port)
5253
Container.add(handle, 'Instance', instance)
5354
Container.add(handle, 'RequestName', requestName)
5455
Container.add(handle, 'Mode', mode)
56+
Container.add(handle, 'Protocol', protocol)
5557
Container.add(handle, 'Endpoint', endpoint)
5658
Container.add(handle, 'Port', port)
5759
return handle

CSK_Module_MultiHTTPClient/scripts/Communication/MultiHTTPClient/MultiHTTPClient_Controller.lua

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,15 @@ local function getRequestsTableContent()
160160
}
161161
table.insert(tableContent, tableRow)
162162
else
163+
local orderedTable = {}
164+
for n in pairs(multiHTTPClient_Instances[selectedInstance].parameters.requests) do
165+
table.insert(orderedTable, n)
166+
end
167+
table.sort(orderedTable)
168+
163169
local id = 1
164-
for reqName, requestDescription in pairs(multiHTTPClient_Instances[selectedInstance].parameters.requests) do
170+
for _, value in ipairs(orderedTable) do
171+
local requestDescription = multiHTTPClient_Instances[selectedInstance].parameters.requests[value]
165172
local tableRow = {
166173
RequestNo = tostring(id),
167174
Name = requestDescription.requestName,
@@ -171,7 +178,7 @@ local function getRequestsTableContent()
171178
Event = requestDescription.registeredEvent,
172179
Periodic = requestDescription.requestPeriodic,
173180
Period = requestDescription.requestPeriod,
174-
selected = (multiHTTPClient_Instances[selectedInstance].selectedRequest == reqName)
181+
selected = (multiHTTPClient_Instances[selectedInstance].selectedRequest == requestDescription.requestName)
175182
}
176183
table.insert(tableContent, tableRow)
177184
id = id + 1
@@ -739,17 +746,27 @@ local function createRequestParameters()
739746
return requestParameters
740747
end
741748

742-
local function addRequest(name, mode, endpoint, port, event, periodic, period)
749+
local function addRequest(name, mode, endpoint, port, event, periodic, period, protocol)
743750

744751
if name ~= '' then
745752
if multiHTTPClient_Instances[selectedInstance].parameters.requests[name] then
746753
_G.logger:fine(nameOfModule .. ": Request with this name already exists.")
747754
else
748755
_G.logger:fine(nameOfModule .. ": Add request to instance" .. tostring(selectedInstance))
749756

757+
local httpIncluded = string.find(endpoint, 'http') or string.find(endpoint, 'https')
758+
750759
multiHTTPClient_Instances[selectedInstance].requestName = name
751760
multiHTTPClient_Instances[selectedInstance].requestMode = mode
752-
multiHTTPClient_Instances[selectedInstance].requestEndpoint = 'http://' .. endpoint
761+
if httpIncluded then
762+
multiHTTPClient_Instances[selectedInstance].requestEndpoint = endpoint
763+
else
764+
if protocol == 'HTTPS' then
765+
multiHTTPClient_Instances[selectedInstance].requestEndpoint = 'https://' .. endpoint
766+
else
767+
multiHTTPClient_Instances[selectedInstance].requestEndpoint = 'http://' .. endpoint
768+
end
769+
end
753770
multiHTTPClient_Instances[selectedInstance].requestPort = port
754771
multiHTTPClient_Instances[selectedInstance].registeredEvent = event or ''
755772
multiHTTPClient_Instances[selectedInstance].requestPeriodic = periodic
@@ -761,8 +778,10 @@ local function addRequest(name, mode, endpoint, port, event, periodic, period)
761778
local requestData = helperFuncs.convertTable2Container(multiHTTPClient_Instances[selectedInstance].parameters.requests[multiHTTPClient_Instances[selectedInstance].requestName])
762779
Script.notifyEvent("MultiHTTPClient_OnNewProcessingParameter", selectedInstance, 'addRequest', requestData)
763780

764-
multiHTTPClient_Instances[selectedInstance].selectedRequest = multiHTTPClient_Instances[selectedInstance].requestName
765-
Script.notifyEvent("MultiHTTPClient_OnNewProcessingParameter", selectedInstance, 'selectedRequest', multiHTTPClient_Instances[selectedInstance].selectedRequest)
781+
multiHTTPClient_Instances[selectedInstance].requestName = ''
782+
Script.notifyEvent('MultiHTTPClient_OnNewRequestName', multiHTTPClient_Instances[selectedInstance].requestName)
783+
Script.notifyEvent('MultiHTTPClient_OnNewRequestsTable', getRequestsTableContent())
784+
766785
--announceExternalEventsAndFunctions() -- future usage
767786
end
768787
else

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Tested on
1717

1818
|Device|Firmware|Module version|
1919
|--|--|--|
20+
|SIM1012|V2.4.2|V2.1.0|
2021
|SICK AppEngine|V1.7.0|V2.0.0|
2122
|SIM1012|V2.4.2|V2.0.0|
2223
|SIM1012|V2.3.0|V1.0.0|

docu/CSK_Module_MultiHTTPClient.html

Lines changed: 61 additions & 10 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_MultiHTTPClient 2.0.0</title>
9+
<title>Documentation - CSK_Module_MultiHTTPClient 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_MultiHTTPClient 2.0.0</h1>
618+
<h1>Documentation - CSK_Module_MultiHTTPClient 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-11</span>
621+
<span id="revnumber">version 2.1.0,</span>
622+
<span id="revdate">2025-02-05</span>
623623
</div>
624624
<div id="toc" class="toc2">
625625
<div id="toctitle">Table of Contents</div>
@@ -776,6 +776,7 @@ <h1>Documentation - CSK_Module_MultiHTTPClient 2.0.0</h1>
776776
</li>
777777
<li><a href="#_enumerations">Enumerations</a>
778778
<ul class="sectlevel2">
779+
<li><a href="#API:Enum:CSK_MultiHTTPClient.Protocol"><span class="api-enum">CSK_MultiHTTPClient.Protocol</span></a></li>
779780
<li><a href="#API:Enum:CSK_MultiHTTPClient.RequestMode"><span class="api-enum">CSK_MultiHTTPClient.RequestMode</span></a></li>
780781
</ul>
781782
</li>
@@ -798,11 +799,11 @@ <h2 id="_document_metadata">Document metadata</h2>
798799
</tr>
799800
<tr>
800801
<th class="tableblock halign-left valign-top"><p class="tableblock">Version</p></th>
801-
<td class="tableblock halign-left valign-top"><p class="tableblock">2.0.0</p></td>
802+
<td class="tableblock halign-left valign-top"><p class="tableblock">2.1.0</p></td>
802803
</tr>
803804
<tr>
804805
<th class="tableblock halign-left valign-top"><p class="tableblock">Date</p></th>
805-
<td class="tableblock halign-left valign-top"><p class="tableblock">2024-10-11</p></td>
806+
<td class="tableblock halign-left valign-top"><p class="tableblock">2025-02-05</p></td>
806807
</tr>
807808
<tr>
808809
<th class="tableblock halign-left valign-top"><p class="tableblock">Author</p></th>
@@ -1345,14 +1346,21 @@ <h6 id="_parameters">Parameters</h6>
13451346
<td class="tableblock halign-left valign-top"><p class="tableblock">?</p></td>
13461347
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional time of request period in ms.</p></td>
13471348
</tr>
1349+
<tr>
1350+
<td class="tableblock halign-left valign-top"><p class="tableblock">protocol</p></td>
1351+
<td class="tableblock halign-left valign-top"><p class="tableblock">ENUM<br>
1352+
<a href="#API:Enum:CSK_MultiHTTPClient.Protocol">CSK_MultiHTTPClient.Protocol</a></p></td>
1353+
<td class="tableblock halign-left valign-top"><p class="tableblock">?</p></td>
1354+
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional protocol of request.</p></td>
1355+
</tr>
13481356
</tbody>
13491357
</table>
13501358
</div>
13511359
<div class="sect5">
13521360
<h6 id="_sample_auto_generated_4">Sample (auto-generated)</h6>
13531361
<div class="listingblock">
13541362
<div class="content">
1355-
<pre class="CodeRay highlight"><code data-lang="lua">CSK_MultiHTTPClient.addRequest(name, mode, endpoint, port, event, periodic, period)</code></pre>
1363+
<pre class="CodeRay highlight"><code data-lang="lua">CSK_MultiHTTPClient.addRequest(name, mode, endpoint, port, event, periodic, period, protocol)</code></pre>
13561364
</div>
13571365
</div>
13581366
</div>
@@ -6075,6 +6083,13 @@ <h6 id="_parameters_43">Parameters</h6>
60756083
<td class="tableblock halign-left valign-top"><p class="tableblock">Mode of request.</p></td>
60766084
</tr>
60776085
<tr>
6086+
<td class="tableblock halign-left valign-top"><p class="tableblock">Protocol</p></td>
6087+
<td class="tableblock halign-left valign-top"><p class="tableblock">ENUM<br>
6088+
<a href="#API:Enum:CSK_MultiHTTPClient.Protocol">CSK_MultiHTTPClient.Protocol</a></p></td>
6089+
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
6090+
<td class="tableblock halign-left valign-top"><p class="tableblock">Protocol of request.</p></td>
6091+
</tr>
6092+
<tr>
60786093
<td class="tableblock halign-left valign-top"><p class="tableblock">Endpoint</p></td>
60796094
<td class="tableblock halign-left valign-top"><p class="tableblock">STRING</p></td>
60806095
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
@@ -6120,7 +6135,7 @@ <h6 id="_return_values_6">Return values</h6>
61206135
<h6 id="_sample_auto_generated_108">Sample (auto-generated)</h6>
61216136
<div class="listingblock">
61226137
<div class="content">
6123-
<pre class="CodeRay highlight"><code data-lang="lua">handle = MultiHTTPClient_FC.SendRequest.create(Instance, RequestName, Mode, Endpoint, Port)</code></pre>
6138+
<pre class="CodeRay highlight"><code data-lang="lua">handle = MultiHTTPClient_FC.SendRequest.create(Instance, RequestName, Mode, Protocol, Endpoint, Port)</code></pre>
61246139
</div>
61256140
</div>
61266141
</div>
@@ -6220,6 +6235,9 @@ <h2 id="_enumerations">Enumerations</h2>
62206235
<div class="ulist">
62216236
<ul>
62226237
<li>
6238+
<p><a href="#API:Enum:CSK_MultiHTTPClient.Protocol">CSK_MultiHTTPClient.Protocol</a></p>
6239+
</li>
6240+
<li>
62236241
<p><a href="#API:Enum:CSK_MultiHTTPClient.RequestMode">CSK_MultiHTTPClient.RequestMode</a></p>
62246242
</li>
62256243
</ul>
@@ -6228,6 +6246,39 @@ <h2 id="_enumerations">Enumerations</h2>
62286246
</dl>
62296247
</div>
62306248
<div class="sect2">
6249+
<h3 id="API:Enum:CSK_MultiHTTPClient.Protocol"><span class="api-enum">CSK_MultiHTTPClient.Protocol</span></h3>
6250+
<div class="paragraph">
6251+
<p>Protocol to use for requests.</p>
6252+
</div>
6253+
<table class="tableblock frame-all grid-all stretch">
6254+
<caption class="title">Items</caption>
6255+
<colgroup>
6256+
<col style="width: 33.3333%;">
6257+
<col style="width: 33.3333%;">
6258+
<col style="width: 33.3334%;">
6259+
</colgroup>
6260+
<thead>
6261+
<tr>
6262+
<th class="tableblock halign-left valign-top">Value</th>
6263+
<th class="tableblock halign-left valign-top">Name</th>
6264+
<th class="tableblock halign-left valign-top">Description</th>
6265+
</tr>
6266+
</thead>
6267+
<tbody>
6268+
<tr>
6269+
<td class="tableblock halign-left valign-top"><div class="literal"><pre>HTTP</pre></div></td>
6270+
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTP</p></td>
6271+
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTP</p></td>
6272+
</tr>
6273+
<tr>
6274+
<td class="tableblock halign-left valign-top"><div class="literal"><pre>HTTPS</pre></div></td>
6275+
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTPS</p></td>
6276+
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTPS</p></td>
6277+
</tr>
6278+
</tbody>
6279+
</table>
6280+
</div>
6281+
<div class="sect2">
62316282
<h3 id="API:Enum:CSK_MultiHTTPClient.RequestMode"><span class="api-enum">CSK_MultiHTTPClient.RequestMode</span></h3>
62326283
<div class="paragraph">
62336284
<p>Mode of HTTP request.</p>
@@ -6295,8 +6346,8 @@ <h3 id="API:Enum:CSK_MultiHTTPClient.RequestMode"><span class="api-enum">CSK_Mul
62956346
</div>
62966347
<div id="footer">
62976348
<div id="footer-text">
6298-
Version 2.0.0<br>
6299-
Last updated 2024-10-11 11:33:25 +0200
6349+
Version 2.1.0<br>
6350+
Last updated 2025-02-05 17:24:29 +0100
63006351
</div>
63016352
</div>
63026353
<script type="text/javascript">

0 commit comments

Comments
 (0)