-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTurbineSimulator.mc2
More file actions
597 lines (471 loc) · 21.1 KB
/
TurbineSimulator.mc2
File metadata and controls
597 lines (471 loc) · 21.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
// @endpoint https://resverianaliz.aydemyenilenebilir.com.tr:8889/api/v0/exec
// @theme dark-blue
{
//'type' 'flex'
'title' 'Turbine Simulator'
'cellHeight' 80
'options' {
'scheme' 'CHARTANA'
'timeZone' 'AUTO'
'showLoader' true
'eventHandler' 'type=popup,tag=popup'
}
'vars' {
'plant' 'Yalova'
'SimManufacturer' 'Sinovel'
'TurbineId' [ 1 ]
'SimModel' 'SN1500'
'real' 0
'sim' 0
'curve' '0'
'startDate' [ NOW 7 d - ISO8601 'T' SPLIT 0 GET '21:00:00Z' ] 'T' JOIN TOTIMESTAMP //NOW 7 d - // 1658308294000000 // NOW
'endDate' NOW //1658913094000000 //604800000000
'myreadtoken' '4vM.a2aMxhl2qCB88Gutar8jXe4R4cqp.QaYYHtumjJg9DCHgXXY1_qIoBhzeh6PIdfX9KLtgeK1O0YHXcr0qA2ZPQrLAurl_PbQAkNjvy3WNq4fNEv434rOXWMsGq55X4qYtTOCtx53bqFwUXsRr6.B3sKF1YE1At8iEE2RyxC9RYOnS7UT4F'
}
'tiles' [
{
'title' 'Plant'
'x' 0 'y' 0 'w' 1 'h' 1
'type' 'input:list'
'macro' <%
[ $myreadtoken '~.*' { 'type' 'Wind' } ] FINDSETS STACKTOLIST 1 GET 'plant' GET LSORT 'listOfPlants' STORE
{
'data' $listOfPlants
'globalParams' { 'input' { 'value' $plant } } // the initial selected value coming from global vars
'events' [ { 'type' 'variable' 'tags' [ 'plant' 'TurbineId' ] 'selector' 'plant' } ] // Event definition
}
%>
}
{
'title' 'Turbine'
'x' 0 'y' 1 'w' 1 'h' 7
'type' 'input:multi-cb'
'options' { 'eventHandler' 'type=(variable),tag=(plant)'
'input' { 'showButton' true 'showFilter' true }
}
'macro' <%
[ $myreadtoken '~.*' { 'plant' $plant } ] FINDSETS STACKTOLIST 1 GET 'TurbineId' GET <% TOLONG %> SORTBY 'listOfTurbines' STORE
{
'data' $listOfTurbines
'globalParams' { 'input' { 'value' '1' } } // the initial selected value coming from global vars
'events' [ { 'type' 'variable' 'tags' [ 'TurbineId' 'plant' ] 'selector' 'TurbineId' } ] // Event definition
}
%>
}
{
'title' 'Start Date'
'x' 1 'y' 0 'w' 2 'h' 1
'type' 'input:date'
'macro' <%
{
'data' [ NOW 8 d - ISO8601 'T' SPLIT 0 GET '21:00:00Z' ] 'T' JOIN TOTIMESTAMP
'events' [
{ 'type' 'variable' 'tags' [ 'startDate' 'plant' 'TurbineId' ] 'selector' 'startDate' }
]
}
%>
}
{
'title' 'End Date'
'x' 3 'y' 0 'w' 2 'h' 1
'type' 'input:date'
'macro' <%
{
'data' [ NOW ISO8601 'T' SPLIT 0 GET '20:59:59Z' ] 'T' JOIN TOTIMESTAMP
'events' [
{ 'type' 'variable' 'tags' [ 'endDate' 'plant' 'TurbineId' ] 'selector' 'endDate' }
]
}
%>
}
{
'title' 'Manufacturer'
'x' 5 'y' 0 'w' 2 'h' 1
'type' 'input:list'
'macro' <%
// [ $myreadtoken '~.*' {} ] FINDSETS STACKTOLIST 1 GET 'plant' GET LSORT 'listOfPlants' STORE
[ $myreadtoken '~curve.*' {} ] FINDSETS STACKTOLIST 1 GET 'Manufacturer' GET LSORT 'listOfMans' STORE
//[ 'Select' 'Goldwind' 'Sinovel' 'Vestas' ] 'listOfMans' STORE
{
'data' $listOfMans
'globalParams' { 'input' { 'value' $SimManufacturer } } // the initial selected value coming from global vars
'events' [ { 'type' 'variable' 'tags' [ 'SimManufacturer' ] 'selector' 'SimManufacturer' } ] // Event definition
}
%>
}
{
'title' 'Simulated Turbine'
'options' { 'eventHandler' 'type=(variable),tag=(SimManufacturer)'
} //subscribe to SimManufacturer event
'x' 7 'y' 0 'w' 2 'h' 1
'type' 'input:list'
'macro' <%
/* <% $SimManufacturer 'Goldwind' == %> <% [ 'Select' 'GW165-6MW' ] 'listOfTurbines' STORE %>
<% $SimManufacturer 'Sinovel' == %> <% [ 'Select' 'SN1500' ] 'listOfTurbines' STORE %>
<% $SimManufacturer 'Vestas' == %> <% [ 'Select' 'V112' ] 'listOfTurbines' STORE %>
<% %> 3 SWITCH
*/
[ $myreadtoken '~curve.*' { 'Manufacturer' $SimManufacturer } ] FINDSETS STACKTOLIST 1 GET 'Model' GET LSORT 'listOfModels' STORE
{
'data' $listOfModels
'globalParams' { 'input' { 'value' $SimModel 'showButton' true } } // the initial selected value coming from global vars
'events' [ { 'type' 'variable' 'tags' [ 'SimModel' 'SimManufacturer' ] 'selector' 'SimModel' } ] // Event definition
}
%>
}
/// add new turbines to db
{
'type' 'button'
'title' 'Add New Turbine'
'options' {
'button' { 'label' 'Add New' }
}
'w' 3 'h' 1 'x' 9 'y' 0
'macro' <% { 'data' <%
{ 'data' ''
'events' [
{ 'tags' [ 'popup' ] 'type' 'popup'
'value'
{ 'title' 'Enter Turbine Data'
'cellHeight' 80
'vars' {
'winds' '0 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 1650 1700 1750 1800 1850 1900 1950 2000 2050 2100 2150 2200 2250 2300 2350 2400 2450 2500'
'powers' '0.0 4.0498878 23.628781 58.493583 112.55065 179.99284 253.35229 354.7410 458.4080 574.8670 716.3690 865.4690 1049.0700 1249.6800 1368.4700 1437.6800 1475.1500 1493.6000 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0'
'manufacturer' 'Manufacturer'
'model' 'Model'
'writetoken' 'VLMWo2sl_0j0ml.KHLpaa7lr14wLn_fAffcp.pGvv989p7MFOcyR9yF.nOrDqB2jgNR1iN93WCYav0lawYiRt0zuNWvDJhBeaVEzlGwVNBeIlRkhkv1OpUYymIiUZYMR'
}
'tiles' [ ///dashboard tile start
{
'type' 'input:text'
'title' 'Manufacturer'
'w' 6 'h' 1 'x' 0 'y' 0
'macro' <% { 'data' $manufacturer 'events' [ { 'tags' [ 'manufacturer' ] 'type' 'variable' 'selector' 'manufacturer' } ] } %>
}
{
'type' 'input:text'
'title' 'Model'
'w' 6 'h' 1 'x' 6 'y' 0
'macro' <% { 'data' $model 'events' [ { 'tags' [ 'model' ] 'type' 'variable' 'selector' 'model' } ] } %>
}
{
'type' 'input:text'
'title' 'Wind List'
'w' 12 'h' 1 'x' 0 'y' 1
'macro' <% { 'data' $winds 'events' [ { 'tags' [ 'winds' ] 'type' 'variable' 'selector' 'winds' } ] } %>
}
{
'type' 'input:text'
'title' 'Power List'
'w' 12 'h' 1 'x' 0 'y' 2
'macro' <% { 'data' $powers 'events' [ { 'tags' [ 'powers' ] 'type' 'variable' 'selector' 'powers' } ] } %>
}
{
'type' 'scatter'
'title' 'Curve Check'
'w' 12 'h' 3 'x' 0 'y' 3
'macro' <%
[ $winds ' ' SPLIT <% TOLONG %> FOREACH ] //winds as ticklist
[] [] [] //empty latlongelev
[ $powers ' ' SPLIT <% TODOUBLE %> FOREACH ] //powers as curve
MAKEGTS 'curve' STORE
{ 'data' [ $curve ] 'params' [ { 'type' 'scatter' } ]
'globalParams' { 'timeMode' 'timestamp' 'showControls' true } }
%>
'options' { 'eventHandler' 'type=(variable),tag=(curvevalues|winds|powers)' }
}
{
'type' 'button'
'title' 'Save'
'options' {
'button' { 'label' 'Save to DB' }
'eventHandler' 'type=variable,tag=(winds|powers|manufacturer|model)'
}
'w' 2 'h' 1 'x' 5 'y' 6
'macro' <%
{
'data' <%
[ $winds ' ' SPLIT <% TOLONG %> FOREACH ] //winds as ticklist
[] [] [] //empty latlongelev
[ $powers ' ' SPLIT <% TODOUBLE %> FOREACH ] //powers as curve
MAKEGTS { 'Manufacturer' $manufacturer 'Model' $model } RELABEL 'curve' RENAME 'curve' STORE
$curve $writetoken UPDATE
{ 'data' $curve
'events' [ { 'type' 'variable' 'tags' [ 'model' ] 'value' $model } ]
}
%>
}
%>
}
] } /// dashboard tile end
}
]
}
%> } %>
}
///// end of popup //////////////////////////////77
{
'title' 'Real Production'
'options' {
'eventHandler' 'type=(variable|zoom|focus),tag=(chart1|TurbineId|plant|startDate|endDate)'
'showLegend' true
'showRangeSelector' true
}
'x' 1 'y' 1 'w' 5 'h' 4
'type' 'line' 'macro' <%
// '~(1|2)'
"~(" $TurbineId '|' JOIN + ")" + 'turbineselector' STORE
{ 'token' $myreadtoken
'class' '~WIND_SPEED.*'
'labels' { 'TurbineId' $turbineselector 'plant' $plant }
'start' $startDate TOSTRING
'end' $endDate TOSTRING
//'timespan' MAXLONG d
//'sample' 0.5
'timestep' 10 m
} FETCH 'data1' STORE
// [ $myreadtoken '~WIND_SPEED.*' { 'TurbineId' $turbineselector 'plant' $plant }
// $startDate TOSTRING
// $endDate TOSTRING
// ] FETCH 'data1' STORE
$data1 { '.app' '' '.uuid' '' 'type' '' } RELABEL 'data1' STORE //relabel the atributes
{ 'token' $myreadtoken
'class' '~ACTIVE_POWER.*'
'labels' { 'TurbineId' $turbineselector 'plant' $plant }
'start' $startDate TOSTRING
'end' $endDate TOSTRING
//'timespan' MAXLONG d
//'sample' 0.5
'timestep' 10 m
}
// [ $myreadtoken '~ACTIVE_POWER.*' { 'TurbineId' $turbineselector 'plant' $plant }
// $startDate TOSTRING
//$endDate TOSTRING
// ]
FETCH 'data2' STORE
$data2 { '.app' '' '.uuid' '' 'type' '' } RELABEL 'data2' STORE //relabel the atributes
//align timeseries
$endDate "lastBucket" STORE
$startDate 'start' STORE
10 m "bucketSpan" STORE // 1 minute
//$data FIRSTTICK "start" STORE // count = ((end - start) / bucketspan) + 1
//$startDate TOTIMESTAMP 'start' STORE
$lastBucket $start - $bucketSpan / TOLONG 1 + "bucketCount" STORE
[ $data1 bucketizer.last $lastBucket $bucketSpan $bucketCount ] BUCKETIZE FILLPREVIOUS FILLNEXT SORT 'data1' STORE
[ $data2 bucketizer.last $lastBucket $bucketSpan $bucketCount ] BUCKETIZE FILLPREVIOUS FILLNEXT SORT 'data2' STORE
[ $data2 bucketizer.sum 0 0 1 ] BUCKETIZE 'realpow' STORE
{ 'data' [ $data2 ] //'params' [ { 'yAxis' 0 } { 'yAxis' 1 } ]
'events' [
{ 'type' 'variable' 'tags' [ 'realpow' ] 'value' { 'real' $realpow } }
{ 'tags' [ 'chart2' ] 'type' 'zoom' } // send zoom event on channel "chart2"
{ 'tags' [ 'chart2' ] 'type' 'focus' } // send focus event on channel "chart2"
]
}
%>
}
{
'title' 'Simulated Production'
'options' {
'eventHandler' 'type=(variable|zoom|focus),tag=(chart2|TurbineId|plant|SimManufacturer|SimModel|startDate|endDate)'
'showLegend' true
'showRangeSelector' true
}
'x' 6 'y' 1 'w' 6 'h' 4
'type' 'line' 'macro' <%
"~(" $TurbineId '|' JOIN + ")" + 'turbineselector' STORE
{ 'token' $myreadtoken
'class' '~WIND_SPEED.*'
'labels' { 'TurbineId' $turbineselector 'plant' $plant }
'start' $startDate TOSTRING
'end' $endDate TOSTRING
//'timespan' MAXLONG d
//'sample' 0.5
'timestep' 10 m
}
//[ $myreadtoken '~WIND_SPEED.*' { 'TurbineId' $turbineselector 'plant' $plant }
// $startDate TOSTRING
// $endDate TOSTRING
// ]
FETCH 'data1' STORE
$data1 { '.app' '' '.uuid' '' 'type' '' } RELABEL 'data1' STORE //relabel the atributes
//align timeseries
$endDate "lastBucket" STORE
$startDate 'start' STORE
10 m "bucketSpan" STORE // 1 minute
//$data FIRSTTICK "start" STORE // count = ((end - start) / bucketspan) + 1
//$startDate TOTIMESTAMP 'start' STORE
$lastBucket $start - $bucketSpan / TOLONG 1 + "bucketCount" STORE
[ $data1 bucketizer.last $lastBucket $bucketSpan $bucketCount ] BUCKETIZE FILLPREVIOUS FILLNEXT SORT 'data1' STORE
//$data1 <% 100 * %> FOREACH 'wind' STORE
[] 'wind' STORE
0 $data1 SIZE 1 - <% 'i' STORE $wind [ $data1 $i GET 100 * ] APPEND 'wind' STORE %> FOR
//'curve' STORE
[ $myreadtoken '~curve.*' { 'Manufacturer' $SimManufacturer 'Model' $SimModel } NOW MAXLONG ] FETCH 'simTurbine' STORE
[ $simTurbine bucketizer.mean 0 1 0 ] BUCKETIZE INTERPOLATE SORT 'curve' STORE // interpolate the empty points
// create empty list for simulated powers
[] 'simulatedpwrs' STORE
0 $wind SIZE 1 - <% 'i' STORE
//calculate expected power with theoretical curve between selected dates
[] 'values' STORE
$wind $i GET SIZE 1 - 'len' STORE
0 $len <% 'j' STORE
$curve $wind $i GET VALUES $j GET ATTICK 0 GET -1 GET 'value' STORE //change to theoretical if you like
<% $value NULL == %> <% 0 'value' STORE %>
<% $value 'value' STORE %> 1 SWITCH
$values [ $value ] APPEND 'values' STORE
%> FOR
$wind $i GET TICKLIST
[] [] []
$values
MAKEGTS $wind $i GET LABELS 'TurbineId' GET RENAME 'simpowr' STORE
$simulatedpwrs [ $simpowr ] APPEND 'simulatedpwrs' STORE
%> FOR
[ $simulatedpwrs bucketizer.sum 0 0 1 ] BUCKETIZE 'simpow' STORE
{ 'data' [ $simulatedpwrs ] 'params' [ ]
'events' [
{ 'tags' [ 'simpow' ] 'type' 'variable' 'value' { 'sim' $simpow } }
// { 'type' 'variable' 'tags' [ 'chart' ] 'value' { 'data' $data2 WRAP } }
{ 'tags' [ 'chart1' ] 'type' 'zoom' } // send zoom event on channel "chart1"
{ 'tags' [ 'chart1' ] 'type' 'focus' } // send focus event on channel "chart1"
]
}
%>
}
{
'title' 'Power Curve Comparison'
'options' {
'eventHandler' 'type=variable,tag=(TurbineId|plant|SimManufacturer|SimModel|startDate|endDate)' //TurbineId,plant,startDate,endDate,VariableId
'showLegend' true
}
'x' 1 'y' 5 'w' 5 'h' 4
'type' 'spline'
'macro' <%
"~(" $TurbineId '|' JOIN + ")" + 'turbineselector' STORE
//[ $myreadtoken '~ACTIVE_POWER.*' { 'TurbineId' $turbineselector 'plant' $plant }
// $startDate TOSTRING
// $endDate TOSTRING
// ]
{ 'token' $myreadtoken
'class' '~ACTIVE_POWER.*'
'labels' { 'TurbineId' $turbineselector 'plant' $plant }
'start' $startDate TOSTRING
'end' $endDate TOSTRING
//'timespan' MAXLONG d
//'sample' 0.5
'timestep' 10 m
} FETCH 'pow' STORE
//[ $myreadtoken '~WIND_SPEED.*' { 'TurbineId' $turbineselector 'plant' $plant }
// $startDate TOSTRING
//$endDate TOSTRING
// ]
{ 'token' $myreadtoken
'class' '~WIND_SPEED.*'
'labels' { 'TurbineId' $turbineselector 'plant' $plant }
'start' $startDate TOSTRING
'end' $endDate TOSTRING
//'timespan' MAXLONG d
//'sample' 0.5
'timestep' 10 m
} FETCH 'wind' STORE
//align timeseries
$endDate "lastBucket" STORE
$startDate 'start' STORE
10 m "bucketSpan" STORE // 1 minute
//$data FIRSTTICK "start" STORE // count = ((end - start) / bucketspan) + 1
//$startDate TOTIMESTAMP 'start' STORE
$lastBucket $start - $bucketSpan / TOLONG 1 + "bucketCount" STORE
[ $pow bucketizer.last $lastBucket $bucketSpan $bucketCount ] BUCKETIZE FILLPREVIOUS FILLNEXT SORT 'pow' STORE
[ $wind bucketizer.last $lastBucket $bucketSpan $bucketCount ] BUCKETIZE FILLPREVIOUS FILLNEXT SORT 'wind' STORE
[] 'winds' STORE
0 $wind SIZE 1 - <% 'i' STORE $winds [ $wind $i GET 100 * ] APPEND 'winds' STORE %> FOR
//$plant TOSTRING '-' + $TurbineId TOSTRING + 'turbine_name1' STORE
[] 'curves' STORE
0 $winds SIZE 1 - <% 'i' STORE
$winds $i GET VALUES FLATTEN // ticks
[] [] [] // latitudes, longitudes and elevations
$pow $i GET VALUES FLATTEN // values
MAKEGTS $winds $i GET LABELS 'TurbineId' GET RENAME 'data_merge' STORE
[ $data_merge bucketizer.mean 0 50 0 ] BUCKETIZE INTERPOLATE SORT 'mean_spline' STORE
$curves [ $mean_spline ] APPEND 'curves' STORE
%> FOR
[ $myreadtoken '~curve.*' { 'Manufacturer' $SimManufacturer 'Model' $SimModel } NOW MAXLONG ] FETCH { '.app' '' } RELABEL 'simTurbine' STORE
[ $simTurbine bucketizer.mean 0 50 0 ] BUCKETIZE INTERPOLATE SORT 'curve' STORE // interpolate the empty points
'SN1500' TOSTRING 'turbine_name2' STORE
//$wind <% 100 * %> FOREACH 'wind' STORE
{ 'data' [ $curves $curve ]
'params' [ ]
'globalParams' { 'timeMode' 'timestamp' }
}
%>
}
// All variables comparison table (mean, tbd)
{
'type' 'tabular' 'x' 6 'y' 5 'w' 6 'h' 3
'title' 'Real vs Simulated'
'options' { 'eventHandler' 'type=variable,tag=(TurbineId|SimModel|plant|realpow|simpow)'
// suscribe to events
'tabular' { 'fixedWidth' true }
}
'macro' <%
[] 'rows' STORE
0 $real SIZE 1 - <% 'i' STORE
$real $i GET 'l' GET 'TurbineId' GET 'turbin' STORE
$real $i GET 'v' GET 0 GET 3 GET 6 / 100 * RINT 100 / 'realpwr' STORE
$sim $i GET 'v' GET 0 GET 1 GET 6 / 100 * RINT 100 / 'simpwr' STORE
$rows [ [ $turbin $realpwr $simpwr ] ] APPEND 'rows' STORE
%> FOR
{
'columns' [ 'Turbine' 'Real(kWh)' 'Simulated(kWh)' ]
'rows' $rows
}
'values' STORE
{ 'data' $values
'events' [ { 'type' 'variable' 'tags' [ 'simtable' ] 'value' $values } ]
'globalParams' {
'tabular' {
'fixedWidth' true
'sortable' true
//'filterable' true
}
}
} // data can also be a gts or a list thereof
%>
}
{
'title' 'Download Simulation Table'
'type' 'display'
'cellHeight' 50
'options' { 'eventHandler' 'type=variable,tag=simtable' }
'x' 6 'y' 8 'w' 6 'h' 1
'macro' <%
<'
fileName = "SimTable.csv";
let csvContent = "data:text/csv;charset=utf-8,";
csvContent += {{{jsonHeader}}}.join(";") + "\r\n";
{{{jsonRow}}}.forEach(function(rowArray) {
let row = rowArray.join(";");
csvContent += row + "\r\n";
});
var dataUri = encodeURI(csvContent);
const a = document.createElement('a');
a.href = dataUri;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
'>
{
"jsonRow" $rows ->JSON
"jsonHeader" $columns ->JSON
} TEMPLATE
'download_script_js' STORE
<'
<button style='background-color: DodgerBlue;' onclick='{{download_script_js}}' >Download</button>
'>
{
'download_script_js' $download_script_js
} TEMPLATE
%>
}
]
}