Skip to content

Commit 6da728e

Browse files
V1.0.0 (#1)
- Initial version
1 parent bcec978 commit 6da728e

13 files changed

Lines changed: 2088 additions & 552 deletions

File tree

CHANGELOG.md

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

4-
## Release 0.1.0
5-
- Initial commit
6-
7-
### New features
8-
- ...
9-
10-
### Improvements
11-
- ...
12-
13-
### Bugfix
14-
- ...
4+
## Release 1.0.0
5+
- Initial commit

CSK_Module_MultiDataLogger/pages/pages/CSK_Module_MultiDataLogger/CSK_Module_MultiDataLogger.html

Lines changed: 355 additions & 96 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
document.addEventListener('sopasjs-ready', () => {
2+
setTimeout(() => {
3+
document.title = 'CSK_Module_MultiDataLogger'
4+
}, 500);
5+
})

CSK_Module_MultiDataLogger/project.mf.xml

Lines changed: 116 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,34 @@
66
</crown>
77
<crown name="CSK_MultiDataLogger">
88
<trait>released</trait>
9-
<desc>Please fill in information regarding: What is the idea of this module and its features? +
10-
How to use this module in general.... like: +
11-
{empty} +
12-
Typically the features of this module are used like this (check also main script of this module): +
13-
{empty} +
9+
<desc>Module to store / log data like files or images. +
10+
{empty} +
11+
Typically, the feature of this module is used like this (check also main script of this module): +
12+
{empty} +
1413
**1) Setup** +
15-
ToDo +
16-
{empty} +
17-
**2) Something else....** +
18-
</desc>
14+
- Set instance to configure via 'setSelectedInstance' +
15+
- Set data mode and storage path via 'setDataMode' and 'setPath'. +
16+
- Set type of data or image via 'setDataType' or 'setImageType'. +
17+
- If it should store data in a CSV-formatted file, you should set the CSV filename via 'setCSVFilename', the CSV labels via 'setCSVLabels'. Additionally, choose mode for 'setSaveOnlyChanges' and 'setSaveDataDirectly'. +
18+
- Set an event to receive the data / image to store via 'setRegisterEvent'. This event should provide as first parameter the data to store and as second parameter an optional filename (2nd parameter not needed, if data type is 'csv'). Otherwise, it will use the timestamp as filename. +</desc>
19+
<enum name="DataMode" trait="released">
20+
<desc>Mode of data to store.</desc>
21+
<item desc="Store files" name="file">file</item>
22+
<item desc="Store images" name="image">image</item>
23+
</enum>
24+
<enum name="DataType" trait="released">
25+
<desc>Data type</desc>
26+
<item desc="JSON" name="json">json</item>
27+
<item desc="CSV" name="csv">csv</item>
28+
</enum>
29+
<enum name="ImageFormat" trait="released">
30+
<desc>Image format</desc>
31+
<item desc="BMP" name="bmp">bmp</item>
32+
<item desc="PNG" name="png">png</item>
33+
<item desc="JPEG" name="jpg">jpg</item>
34+
<item desc="JSON" name="json">json</item>
35+
<item desc="MSGPACK" name="msgpack">msgpack</item>
36+
</enum>
1937
<serves>
2038
<event name="OnNewStatusLoadParameterOnReboot">
2139
<desc>Notify status if parameters should be loaded on app/device boot up.</desc>
@@ -31,10 +49,10 @@ ToDo +
3149
</event>
3250
<event name="OnNewProcessingParameter">
3351
<desc>Event to share processing parameters to the instances.</desc>
34-
<param desc="Number of the instance to receive the parameter." multiplicity="1" name="objectNo" type="int"/>
52+
<param desc="Numeric identifier of the instance to receive the parameter." multiplicity="1" name="objectNo" type="int"/>
3553
<param desc="Name of the parameter." multiplicity="1" name="parameter" type="string"/>
3654
<param desc="Value of the parameter." multiplicity="1" name="value" type="auto"/>
37-
<param desc="If parameter is for specifici internal used object, its number." multiplicity="?" name="internalObjectNo" type="int"/>
55+
<param desc="Numeric identifier, if parameter is for specific internal used object." multiplicity="?" name="internalObjectNo" type="int"/>
3856
</event>
3957
<event name="OnNewSelectedInstance">
4058
<desc>Notify if new instance is selected.</desc>
@@ -43,12 +61,6 @@ ToDo +
4361
<event name="OnDataLoadedOnReboot">
4462
<desc>Event to call if module tried to load parameters and should be ready.</desc>
4563
</event>
46-
<event name="OnNewResultNUM">
47-
<desc>Example of dynamically created event to provide result of instance. +
48-
NUM will be replaced by the number of instance (e.g. "OnNewResult1"). +
49-
INFO: Other modules can check via "Script.isServedAsEvent" if event of sepecific instance exists.</desc>
50-
<param desc="Result" multiplicity="1" name="result" type="bool"/>
51-
</event>
5264
<event name="OnNewParameterName">
5365
<desc>Notify name of persistent data parameter.</desc>
5466
<param desc="Parameter name" multiplicity="1" name="name" type="string"/>
@@ -70,16 +82,16 @@ INFO: Other modules can check via "Script.isServedAsEvent" if event of sepecific
7082
<param desc="Status" multiplicity="1" name="status" type="bool"/>
7183
</event>
7284
<event name="OnNewValueUpdateNUM">
73-
<desc>Example of dynamically created event to sync paramters between instance threads and Controller part of module. +
74-
NUM will be replaced by the number of instance (e.g. "OnNewResult1"). +</desc>
85+
<desc>Example of dynamically created event to sync parameters between instance threads and Controller part of module. +
86+
NUM will be replaced by the number of instance (e.g. "OnNewValueUpdate1"). +</desc>
7587
<param desc="Instance new value is coming from." multiplicity="1" name="instance" type="int"/>
76-
<param desc="Name of the paramter to update/sync." multiplicity="1" name="parameter" type="string"/>
88+
<param desc="Name of the parameter to update/sync." multiplicity="1" name="parameter" type="string"/>
7789
<param desc="Value to update." multiplicity="1" name="value" type="auto"/>
7890
<param desc="Optionally if internal parameter should be used for internal objects." multiplicity="?" name="selectedObject" type="int"/>
7991
</event>
8092
<event name="OnNewValueToForwardNUM">
8193
<desc>Example of dynamically created event to forward data from instance thread to Controller part of module, e.g. to forward values to UI. +
82-
NUM will be replaced by the number of instance (e.g. "OnNewResult1"). +</desc>
94+
NUM will be replaced by the number of instance (e.g. "OnNewValueToForward1"). +</desc>
8395
<param desc="Eventname to use to forward value." multiplicity="1" name="eventname" type="string"/>
8496
<param desc="Value to forward." multiplicity="1" name="value" type="auto"/>
8597
</event>
@@ -91,6 +103,46 @@ NUM will be replaced by the number of instance (e.g. "OnNewResult1"). +</desc>
91103
<desc>Notify event instance is registered to receive data to process.</desc>
92104
<param desc="Name of event." multiplicity="1" name="eventname" type="string"/>
93105
</event>
106+
<event name="OnNewStatusStoragePath">
107+
<desc>Notify path to store incoming data</desc>
108+
<param desc="Storage path." multiplicity="1" name="path" type="string"/>
109+
</event>
110+
<event name="OnNewStatusDataMode">
111+
<desc>Notify mode of data storage</desc>
112+
<param desc="Data mode." multiplicity="1" name="mode" type="string"/>
113+
</event>
114+
<event name="OnNewStatusDataType">
115+
<desc>Notfiy data type.</desc>
116+
<param desc="Data type" multiplicity="1" name="type" type="string"/>
117+
</event>
118+
<event name="OnNewStatusImageType">
119+
<desc>Notify image type.</desc>
120+
<param desc="Type of image" multiplicity="1" name="imageType" type="string"/>
121+
</event>
122+
<event name="OnNewStatusImageCompressionValue">
123+
<desc>Notify value of image compression.</desc>
124+
<param desc="Image compression value." multiplicity="1" name="imgCompression" type="int"/>
125+
</event>
126+
<event name="OnNewStatusCSVLables">
127+
<desc>Notify CSV labels.</desc>
128+
<param desc="CSV labels." multiplicity="1" name="labels" type="string"/>
129+
</event>
130+
<event name="OnNewStatusSaveOnlyChanges">
131+
<desc>Notify status if log file should log received data only if it differs from previous data.</desc>
132+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
133+
</event>
134+
<event name="OnNewStatusSaveDataDirectly">
135+
<desc>Notify status if log file should be saved automatically as soon as it receives a new data entry.</desc>
136+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
137+
</event>
138+
<event name="OnNewStatusCSVFilename">
139+
<desc>Notify name of CSV file to store data.</desc>
140+
<param desc="Name of file." multiplicity="1" name="name" type="string"/>
141+
</event>
142+
<event name="OnNewStatusAvailableEvents">
143+
<desc>Notify available events.</desc>
144+
<param desc="JSON list" multiplicity="1" name="listOfEvents" type="string"/>
145+
</event>
94146
<function name="setParameterName">
95147
<desc>Function to set the name of the parameters if saved/loaded via the CSK_PersistentData module.</desc>
96148
<param desc="Name of the parameter" multiplicity="1" name="name" type="string"/>
@@ -102,7 +154,7 @@ NUM will be replaced by the number of instance (e.g. "OnNewResult1"). +</desc>
102154
<desc>Load parameters for this module from the CSK_PersistentData module if possible and use them.</desc>
103155
</function>
104156
<function name="setLoadOnReboot">
105-
<desc>Configure if this module should load its saved parameters at app/ device boot up.</desc>
157+
<desc>Configure if this module should load its saved parameters at app / device boot up.</desc>
106158
<param desc="Set status" multiplicity="1" name="status" type="bool"/>
107159
</function>
108160
<function name="pageCalled">
@@ -122,30 +174,62 @@ NUM will be replaced by the number of instance (e.g. "OnNewResult1"). +</desc>
122174
(Will be set to currently active instance, see "setSelectedObject")</desc>
123175
<param desc="(external) Event name to listen to." multiplicity="1" name="event" type="string"/>
124176
</function>
125-
<function name="processInstanceNUM">
126-
<desc>Example of dynamically served function to process internally coded function. +
127-
NUM will be replaced by the number of instance (e.g. "processInstance1"). +
128-
INFO: Other modules can check via "Script.isServedAsFunction" if function of sepecific instance exists. +
129-
Needs then to be called via "Script.callFunction".</desc>
130-
<param alias="Alias" desc="Transferred object (optional)" multiplicity="?" name="object" type="object"/>
131-
<return desc="Processing result (optional)." multiplicity="?" name="result" type="bool"/>
132-
</function>
133177
<function name="addInstance">
134178
<desc>Function to add an additional instance.</desc>
135179
</function>
136180
<function name="resetInstances">
137181
<desc>Function to reset instances to one single instance. +
138182
IMPORTANT: As instances start their own threads, the module needs to be restarted if new instances are needed... (see AppEngine docu for "Script.startScript").</desc>
139183
</function>
184+
<function name="setPath">
185+
<desc>Function to set storage path.</desc>
186+
<param desc="Storage path for incoming data." multiplicity="1" name="path" type="string"/>
187+
</function>
188+
<function name="setDataMode">
189+
<desc>Function to set data mode.</desc>
190+
<param desc="Data mode." multiplicity="1" name="mode" ref="CSK_MultiDataLogger.DataMode" type="enum"/>
191+
</function>
192+
<function name="setDataType">
193+
<desc>Function to set data type.</desc>
194+
<param desc="Data type." multiplicity="1" name="dataType" type="enum"/>
195+
</function>
196+
<function name="setImageType">
197+
<desc>Function to set image type.</desc>
198+
<param desc="Image type" multiplicity="1" name="imgType" type="string"/>
199+
</function>
200+
<function name="setCompressionValue">
201+
<desc>Function to set image compression value</desc>
202+
<param desc="Image compression value." multiplicity="1" name="value" type="int"/>
203+
</function>
204+
<function name="setCSVLabels">
205+
<desc>Function to set CSV labels.</desc>
206+
<param desc="CSV labels seperated by comma." multiplicity="1" name="labels" type="string"/>
207+
</function>
208+
<function name="setSaveOnlyChanges">
209+
<desc>Set to TRUE if data should be logged only if value changed. +</desc>
210+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
211+
</function>
212+
<function name="setSaveDataDirectly">
213+
<desc>Set if data should be saved persistently with every new received data. +
214+
If FALSE it is needed to call 'saveLog' manually to store log data.</desc>
215+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
216+
</function>
217+
<function name="setCSVFilename">
218+
<desc>Function to set CSV filename.</desc>
219+
<param desc="Filename" multiplicity="1" name="name" type="string"/>
220+
</function>
221+
<function name="saveCSVFile">
222+
<desc>Function to manually save CSV file.</desc>
223+
</function>
140224
</serves>
141225
</crown>
142226
<meta key="author">SICK AG</meta>
143-
<meta key="version">0.1.0</meta>
227+
<meta key="version">1.0.0</meta>
144228
<meta key="priority">low</meta>
145229
<meta key="copy-protected">false</meta>
146230
<meta key="read-protected">false</meta>
147231
<meta key="crown2-flow-engine">false</meta>
148-
<meta key="LuaLoadAllEngineAPI">true</meta>
232+
<meta key="LuaLoadAllEngineAPI">false</meta>
149233
<entry default="CSK_Module_MultiDataLogger.lua" path="scripts"/>
150234
</application>
151235
</manifest>

CSK_Module_MultiDataLogger/scripts/CSK_Module_MultiDataLogger.lua

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
-- If app property "LuaLoadAllEngineAPI" is FALSE, use this to load and check for required APIs
3232
-- This can improve performance of garbage collection
3333

34-
-- _G.availableAPIs = require('Data/MultiDataLogger/helper/checkAPIs') -- can be used to adjust function scope of the module related on available APIs of the device
34+
_G.availableAPIs = require('Data/MultiDataLogger/helper/checkAPIs') -- can be used to adjust function scope of the module related on available APIs of the device
3535
-----------------------------------------------------------
3636
-- Logger
3737
_G.logger = Log.SharedLogger.create('ModuleLogger')
@@ -60,31 +60,6 @@ multiDataLoggerController.setMultiDataLogger_Instances_Handle(multiDataLogger_In
6060
--**********************Start Function Scope *******************************
6161
--**************************************************************************
6262

63-
--[[
64-
--- Function to show how this module could be used
65-
local function startProcessing()
66-
67-
CSK_MultiDataLogger.setSelectedInstance(1) --> select instance of module
68-
CSK_MultiDataLogger.doSomething() --> preparation
69-
70-
-- Option A --> prepare an event to trigger processing via this one
71-
--Script.serveEvent("CSK_MultiDataLogger.OnNewTestEvent", "MultiDataLogger_OnNewTestEvent") --> Create event to listen to and process forwarded object
72-
--CSK_MultiDataLogger.setRegisterEvent('CSK_MultiDataLogger.OnNewTestEvent') --> Register processing to the event
73-
74-
--Script.notifyEvent('OnNewTestEvent', data)
75-
76-
-- Option B --> trigger processing via function call
77-
local result = CSK_MultiDataLogger.processSomething(data)
78-
79-
end
80-
end
81-
82-
-- Call processing function after persistent data was loaded
83-
--Script.register("CSK_MultiDataLogger.OnDataLoadedOnReboot", startProcessing)
84-
]]
85-
86-
--OR
87-
8863
--- Function to react on startup event of the app
8964
local function main()
9065

@@ -97,9 +72,37 @@ local function main()
9772
-- If so, the app will trigger the "OnDataLoadedOnReboot" event if ready after loading parameters
9873
--
9974
-- Can be used e.g. like this
75+
76+
--[[
77+
-- File
78+
CSK_MultiDataLogger.setSelectedInstance(1)
79+
CSK_MultiDataLogger.setPath('/public/MetaData/')
80+
CSK_MultiDataLogger.setDataMode('file')
81+
CSK_MultiDataLogger.setDataType('json')
82+
CSK_MultiDataLogger.setRegisterEvent('CSK_OtherModule.OnNewLogData')
83+
84+
-- Image
85+
CSK_MultiDataLogger.addInstance()
86+
CSK_MultiDataLogger.setSelectedInstance(2)
87+
CSK_MultiDataLogger.setPath('/public/ImageData/')
88+
CSK_MultiDataLogger.setDataMode('image')
89+
CSK_MultiDataLogger.setImageType('bmp')
90+
CSK_MultiDataLogger.setRegisterEvent('CSK_OtherModule.OnNewImage')
91+
92+
-- CSV data
93+
CSK_MultiDataLogger.addInstance()
94+
CSK_MultiDataLogger.setSelectedInstance(3)
95+
CSK_MultiDataLogger.setPath('/public/Data/')
96+
CSK_MultiDataLogger.setDataMode('file')
97+
CSK_MultiDataLogger.setImageType('csv')
98+
CSK_MultiDataLogger.setCSVFilename('csvDataFile')
99+
CSK_MultiDataLogger.setCSVLabels('DateTime, ValueA, ValueB')
100+
CSK_MultiDataLogger.setSaveOnlyChanges(true)
101+
CSK_MultiDataLogger.setSaveDataDirectly(false)
102+
CSK_MultiDataLogger.setRegisterEvent('CSK_OtherModule.OnNewImage')
103+
]]
100104
----------------------------------------------------------------------------------------
101105

102-
--startProcessing() --> see above
103106
CSK_MultiDataLogger.pageCalled() -- Update UI
104107

105108
end

0 commit comments

Comments
 (0)