Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions 12 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog
All notable changes to this project will be documented in this file.

## 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)
- Sort preconfigured requests within UI in alphabetic order

### Bugfix
- Adds multiple 'http://' to endpoint

## Release 2.0.0

### New features
Expand Down
9 changes: 8 additions & 1 deletion 9 CSK_Module_MultiHTTPClient/project.mf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ The module will dynamically create events to provide the incoming response of th
<item name="TRACE">TRACE</item>
<item name="OPTIONS">OPTIONS</item>
</enum>
<enum name="Protocol" trait="released">
<desc>Protocol to use for requests.</desc>
<item desc="HTTP" name="HTTP">HTTP</item>
<item desc="HTTPS" name="HTTPS">HTTPS</item>
</enum>
<serves>
<event name="OnNewStatusLoadParameterOnReboot">
<desc>Notify status if parameters should be loaded on app/device boot up.</desc>
Expand Down Expand Up @@ -404,6 +409,7 @@ IMPORTANT: As instances start their own threads, the module needs to be restarte
<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"/>
<param desc="Status of request is periodic." multiplicity="1" name="periodic" type="bool"/>
<param desc="Optional time of request period in ms." multiplicity="?" name="period" type="int"/>
<param desc="Optional protocol of request." multiplicity="?" name="protocol" ref="CSK_MultiHTTPClient.Protocol" type="enum"/>
</function>
<function name="sendRequestViaUI">
<desc>Function to trigger preconfigured request via UI.</desc>
Expand Down Expand Up @@ -508,6 +514,7 @@ IMPORTANT: As instances start their own threads, the module needs to be restarte
<param constraint="1-99" desc="Numeric identifier of processing instance." multiplicity="1" name="Instance" type="int"/>
<param desc="Name of request." multiplicity="1" name="RequestName" type="string"/>
<param desc="Mode of request." multiplicity="1" name="Mode" ref="CSK_MultiHTTPClient.RequestMode" type="enum"/>
<param desc="Protocol of request." multiplicity="1" name="Protocol" ref="CSK_MultiHTTPClient.Protocol" type="enum"/>
<param desc="Endpoint for request WITHOUT leading 'http://'" multiplicity="1" name="Endpoint" type="string"/>
<param desc="Port for request." multiplicity="1" name="Port" type="int"/>
<return desc="Handle to internally used FlowConfig instance." multiplicity="1" name="handle" type="handle"/>
Expand All @@ -523,7 +530,7 @@ IMPORTANT: As instances start their own threads, the module needs to be restarte
</crown>
</crown>
<meta key="author">SICK AG</meta>
<meta key="version">2.0.0</meta>
<meta key="version">2.1.0</meta>
<meta key="priority">low</meta>
<meta key="copy-protected">false</meta>
<meta key="read-protected">false</meta>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local function sendRequest(handle, source)
local instance = Container.get(handle, 'Instance')
local requestName = Container.get(handle, 'RequestName')
local mode = Container.get(handle, 'Mode')
local protocol = Container.get(handle, 'Protocol')
local endpoint = Container.get(handle, 'Endpoint')
local port = Container.get(handle, 'Port')

Expand All @@ -25,7 +26,7 @@ local function sendRequest(handle, source)
else
CSK_MultiHTTPClient.setSelectedInstance(instance)

CSK_MultiHTTPClient.addRequest(requestName, mode, endpoint, port, source, false)
CSK_MultiHTTPClient.addRequest(requestName, mode, endpoint, port, source, false, nil, protocol)
break
end
end
Expand All @@ -37,7 +38,7 @@ Script.serveFunction(BLOCK_NAMESPACE .. '.sendRequest', sendRequest)
--*************************************************************
--*************************************************************

local function create(instance, requestName, mode, endpoint, port)
local function create(instance, requestName, mode, protocol, endpoint, port)

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

Expand All @@ -52,6 +53,7 @@ local function create(instance, requestName, mode, endpoint, port)
Container.add(handle, 'Instance', instance)
Container.add(handle, 'RequestName', requestName)
Container.add(handle, 'Mode', mode)
Container.add(handle, 'Protocol', protocol)
Container.add(handle, 'Endpoint', endpoint)
Container.add(handle, 'Port', port)
return handle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,15 @@ local function getRequestsTableContent()
}
table.insert(tableContent, tableRow)
else
local orderedTable = {}
for n in pairs(multiHTTPClient_Instances[selectedInstance].parameters.requests) do
table.insert(orderedTable, n)
end
table.sort(orderedTable)

local id = 1
for reqName, requestDescription in pairs(multiHTTPClient_Instances[selectedInstance].parameters.requests) do
for _, value in ipairs(orderedTable) do
local requestDescription = multiHTTPClient_Instances[selectedInstance].parameters.requests[value]
local tableRow = {
RequestNo = tostring(id),
Name = requestDescription.requestName,
Expand All @@ -171,7 +178,7 @@ local function getRequestsTableContent()
Event = requestDescription.registeredEvent,
Periodic = requestDescription.requestPeriodic,
Period = requestDescription.requestPeriod,
selected = (multiHTTPClient_Instances[selectedInstance].selectedRequest == reqName)
selected = (multiHTTPClient_Instances[selectedInstance].selectedRequest == requestDescription.requestName)
}
table.insert(tableContent, tableRow)
id = id + 1
Expand Down Expand Up @@ -739,17 +746,27 @@ local function createRequestParameters()
return requestParameters
end

local function addRequest(name, mode, endpoint, port, event, periodic, period)
local function addRequest(name, mode, endpoint, port, event, periodic, period, protocol)

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

local httpIncluded = string.find(endpoint, 'http') or string.find(endpoint, 'https')

multiHTTPClient_Instances[selectedInstance].requestName = name
multiHTTPClient_Instances[selectedInstance].requestMode = mode
multiHTTPClient_Instances[selectedInstance].requestEndpoint = 'http://' .. endpoint
if httpIncluded then
multiHTTPClient_Instances[selectedInstance].requestEndpoint = endpoint
else
if protocol == 'HTTPS' then
multiHTTPClient_Instances[selectedInstance].requestEndpoint = 'https://' .. endpoint
else
multiHTTPClient_Instances[selectedInstance].requestEndpoint = 'http://' .. endpoint
end
end
multiHTTPClient_Instances[selectedInstance].requestPort = port
multiHTTPClient_Instances[selectedInstance].registeredEvent = event or ''
multiHTTPClient_Instances[selectedInstance].requestPeriodic = periodic
Expand All @@ -761,8 +778,10 @@ local function addRequest(name, mode, endpoint, port, event, periodic, period)
local requestData = helperFuncs.convertTable2Container(multiHTTPClient_Instances[selectedInstance].parameters.requests[multiHTTPClient_Instances[selectedInstance].requestName])
Script.notifyEvent("MultiHTTPClient_OnNewProcessingParameter", selectedInstance, 'addRequest', requestData)

multiHTTPClient_Instances[selectedInstance].selectedRequest = multiHTTPClient_Instances[selectedInstance].requestName
Script.notifyEvent("MultiHTTPClient_OnNewProcessingParameter", selectedInstance, 'selectedRequest', multiHTTPClient_Instances[selectedInstance].selectedRequest)
multiHTTPClient_Instances[selectedInstance].requestName = ''
Script.notifyEvent('MultiHTTPClient_OnNewRequestName', multiHTTPClient_Instances[selectedInstance].requestName)
Script.notifyEvent('MultiHTTPClient_OnNewRequestsTable', getRequestsTableContent())

--announceExternalEventsAndFunctions() -- future usage
end
else
Expand Down
1 change: 1 addition & 0 deletions 1 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Tested on

|Device|Firmware|Module version|
|--|--|--|
|SIM1012|V2.4.2|V2.1.0|
|SICK AppEngine|V1.7.0|V2.0.0|
|SIM1012|V2.4.2|V2.0.0|
|SIM1012|V2.3.0|V1.0.0|
Expand Down
71 changes: 61 additions & 10 deletions 71 docu/CSK_Module_MultiHTTPClient.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.12">
<meta name="author" content="SICK AG">
<title>Documentation - CSK_Module_MultiHTTPClient 2.0.0</title>
<title>Documentation - CSK_Module_MultiHTTPClient 2.1.0</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
/* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
Expand Down Expand Up @@ -615,11 +615,11 @@
</head>
<body class="article toc2 toc-left">
<div id="header">
<h1>Documentation - CSK_Module_MultiHTTPClient 2.0.0</h1>
<h1>Documentation - CSK_Module_MultiHTTPClient 2.1.0</h1>
<div class="details">
<span id="author" class="author">SICK AG</span><br>
<span id="revnumber">version 2.0.0,</span>
<span id="revdate">2024-10-11</span>
<span id="revnumber">version 2.1.0,</span>
<span id="revdate">2025-02-05</span>
</div>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
Expand Down Expand Up @@ -776,6 +776,7 @@ <h1>Documentation - CSK_Module_MultiHTTPClient 2.0.0</h1>
</li>
<li><a href="#_enumerations">Enumerations</a>
<ul class="sectlevel2">
<li><a href="#API:Enum:CSK_MultiHTTPClient.Protocol"><span class="api-enum">CSK_MultiHTTPClient.Protocol</span></a></li>
<li><a href="#API:Enum:CSK_MultiHTTPClient.RequestMode"><span class="api-enum">CSK_MultiHTTPClient.RequestMode</span></a></li>
</ul>
</li>
Expand All @@ -798,11 +799,11 @@ <h2 id="_document_metadata">Document metadata</h2>
</tr>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock">Version</p></th>
<td class="tableblock halign-left valign-top"><p class="tableblock">2.0.0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2.1.0</p></td>
</tr>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock">Date</p></th>
<td class="tableblock halign-left valign-top"><p class="tableblock">2024-10-11</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2025-02-05</p></td>
</tr>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock">Author</p></th>
Expand Down Expand Up @@ -1345,14 +1346,21 @@ <h6 id="_parameters">Parameters</h6>
<td class="tableblock halign-left valign-top"><p class="tableblock">?</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional time of request period in ms.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">protocol</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ENUM<br>
<a href="#API:Enum:CSK_MultiHTTPClient.Protocol">CSK_MultiHTTPClient.Protocol</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">?</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional protocol of request.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect5">
<h6 id="_sample_auto_generated_4">Sample (auto-generated)</h6>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="lua">CSK_MultiHTTPClient.addRequest(name, mode, endpoint, port, event, periodic, period)</code></pre>
<pre class="CodeRay highlight"><code data-lang="lua">CSK_MultiHTTPClient.addRequest(name, mode, endpoint, port, event, periodic, period, protocol)</code></pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -6075,6 +6083,13 @@ <h6 id="_parameters_43">Parameters</h6>
<td class="tableblock halign-left valign-top"><p class="tableblock">Mode of request.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Protocol</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ENUM<br>
<a href="#API:Enum:CSK_MultiHTTPClient.Protocol">CSK_MultiHTTPClient.Protocol</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Protocol of request.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Endpoint</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">STRING</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1</p></td>
Expand Down Expand Up @@ -6120,7 +6135,7 @@ <h6 id="_return_values_6">Return values</h6>
<h6 id="_sample_auto_generated_108">Sample (auto-generated)</h6>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="lua">handle = MultiHTTPClient_FC.SendRequest.create(Instance, RequestName, Mode, Endpoint, Port)</code></pre>
<pre class="CodeRay highlight"><code data-lang="lua">handle = MultiHTTPClient_FC.SendRequest.create(Instance, RequestName, Mode, Protocol, Endpoint, Port)</code></pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -6220,6 +6235,9 @@ <h2 id="_enumerations">Enumerations</h2>
<div class="ulist">
<ul>
<li>
<p><a href="#API:Enum:CSK_MultiHTTPClient.Protocol">CSK_MultiHTTPClient.Protocol</a></p>
</li>
<li>
<p><a href="#API:Enum:CSK_MultiHTTPClient.RequestMode">CSK_MultiHTTPClient.RequestMode</a></p>
</li>
</ul>
Expand All @@ -6228,6 +6246,39 @@ <h2 id="_enumerations">Enumerations</h2>
</dl>
</div>
<div class="sect2">
<h3 id="API:Enum:CSK_MultiHTTPClient.Protocol"><span class="api-enum">CSK_MultiHTTPClient.Protocol</span></h3>
<div class="paragraph">
<p>Protocol to use for requests.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Items</caption>
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Value</th>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="literal"><pre>HTTP</pre></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTP</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTP</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="literal"><pre>HTTPS</pre></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTPS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTPS</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="API:Enum:CSK_MultiHTTPClient.RequestMode"><span class="api-enum">CSK_MultiHTTPClient.RequestMode</span></h3>
<div class="paragraph">
<p>Mode of HTTP request.</p>
Expand Down Expand Up @@ -6295,8 +6346,8 @@ <h3 id="API:Enum:CSK_MultiHTTPClient.RequestMode"><span class="api-enum">CSK_Mul
</div>
<div id="footer">
<div id="footer-text">
Version 2.0.0<br>
Last updated 2024-10-11 11:33:25 +0200
Version 2.1.0<br>
Last updated 2025-02-05 17:24:29 +0100
</div>
</div>
<script type="text/javascript">
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.