This repository was archived by the owner on May 4, 2024. It is now read-only.
forked from mtconnect/cppagent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyles.xsl
More file actions
590 lines (538 loc) · 22.5 KB
/
Copy pathstyles.xsl
File metadata and controls
590 lines (538 loc) · 22.5 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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:m="urn:mtconnect.org:MTConnectDevices:2.0"
xmlns:s="urn:mtconnect.org:MTConnectStreams:2.0"
xmlns:e="urn:mtconnect.org:MTConnectError:2.0"
xmlns:js="urn:custom-javascript"
exclude-result-prefixes="msxsl js"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<!-- Root template -->
<xsl:template match="/">
<head>
<meta charset="utf-8"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>MTConnect Agent</title>
<link href="/styles/bootstrap.min.css" rel="stylesheet"></link>
<link href="/styles/styles.css" rel="stylesheet"></link>
</head>
<body>
<!-- Header with logo, navigation, form and buttons -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" style="padding: 5px 10px;" href="https://mtconnect.org" target="_blank" rel="noopener noreferrer">
<img alt="Brand" src="/styles/MTConnect_Logo.png" />
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li id="tab-probe">
<a href="../probe">Probe</a>
</li>
<li id="tab-current">
<a href="../current">Current</a>
</li>
<li id="tab-sample">
<a href="../sample">Sample</a>
</li>
</ul>
<form class="navbar-form navbar-left" onsubmit="return false;">
<div class="form-group">
<input id="path" type="text" class="form-control" style="width: 18em; margin-right: 6px;" placeholder="Path" />
<input id="from" type="text" class="form-control" style="width: 6em; margin-right: 6px;" placeholder="From" />
<input id="count" type="text" class="form-control" style="width: 6em; margin-right: 6px;" placeholder="Count" />
<button type="submit" onclick="fetchData()" class="btn" style="margin-right: 6px;">Fetch</button>
<button id="autorefresh" type="button" class="btn" style="margin-right: 6px;">Autorefresh</button>
<button id="xml" onclick="showXml()" type="button" class="btn" style="margin-right: 6px;">XML</button>
<button type="button" class="btn" data-toggle="modal" data-target="#myModal" style="margin-right: 6px;">?</button>
</div>
</form>
</div>
</div>
</nav>
<!-- Main contents -->
<div class="container-fluid page-container">
<xsl:apply-templates />
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">x</span>
</button>
<h3 class="modal-title" id="myModalLabel">MTConnect Agent</h3>
</div>
<div class="modal-body">
<p>The MTConnect Agent receives data from one or more devices and makes it available as XML, then transforms that into HTML.</p>
<h4>Probe</h4>
<p>The Probe tab shows the structure of the available devices and their data items.</p>
<h4>Current</h4>
<p>The Current tab shows the latest values for each data item, along with a timestamp.</p>
<h4>Sample</h4>
<p>The Sample tab shows a sequence of values and their timestamps.</p>
<h4>Path</h4>
<p>
You can search the available data using a simple query language called
<a href="https://en.wikipedia.org/wiki/XPath">XPath</a>
, e.g.
</p>
<p>Note: these will give an error if the given path cannot be found in the document.</p>
<ul>
<li>
Availability of all devices:
<a href='../current?path=//DataItem[@type="AVAILABILITY"]'>//DataItem[@type="AVAILABILITY"]</a>
</li>
<li>
All condition statuses:
<a href='../current?path=//DataItems/DataItem[@category="CONDITION"]'>//DataItems/DataItem[@category="CONDITION"]</a>
</li>
<li>
All controller data items:
<a href='../current?path=//Controller/*'>//Controller/*</a>
</li>
<li>
All linear axis data items:
<a href='../current?path=//Axes/Components/Linear/DataItems'>//Axes/Components/Linear/DataItems</a>
</li>
<li>
X-axis data items:
<a href='../current?path=//Axes/Components/Linear[@id="x"]'>//Axes/Components/Linear[@id="x"]</a>
</li>
<li>
Door status:
<a href='../current?path=//Door'>//Door</a>
</li>
</ul>
<h4>From/Count</h4>
<p>
The MTConnect Agent stores a certain number of observations, called sequences. You can specify which ones and how many to view with the
<b>From</b>
and
<b>Count</b>
fields.
</p>
<h4>Fetch</h4>
<p>Click Fetch to retrieve Current or Sample data - if From or Count values are supplied, the relevant Sample data will be shown.</p>
<h4>Autorefresh</h4>
<p>Toggles autorefresh of page every 2 seconds.</p>
<h4>XML</h4>
<p>Click the XML button to open the underlying raw XML in a new tab.</p>
<h4>Note</h4>
<p>Conditions are transformed from Normal, Warning, Fault elements to Condition elements with value of NORMAL, WARNING, FAULT.</p>
<h4>About</h4>
<p>
For more information on MTConnect, see
<a href="https://mtconnect.org">MTConnect.org</a>
.
</p>
<p>
This UI was developed by
<a href="https://mriiot.com">MRIIOT</a>
, your agile digital transformation partner.
</p>
<p>License: MIT</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<button onclick="gotoTop()" id="gotoTop" title="Go to top">
<img src="/styles/icon-up.webp" />
</button>
<!-- note: jquery is needed for bootstrap modal -->
<script src="/styles/jquery-1.12.4.min.js"></script>
<script src="/styles/bootstrap.min.js"></script>
<script src="/styles/script.js"></script>
</body>
</xsl:template>
<!-- include other templates -->
<!-- Windows can't handle these include statements - see readme -->
<!-- <xsl:include href="styles-probe.xsl" /> -->
<!-- <xsl:include href="styles-streams.xsl" /> -->
<!-- <xsl:include href="styles-error.xsl"/> -->
<!-- probe -->
<xsl:template match="m:MTConnectDevices">
<div id="main-container" class="table-responsive stickytable-container">
<table class="table table-hover">
<thead>
<th>Element</th>
<th>Id</th>
<th>Name</th>
<th>Category</th>
<th>Type</th>
<th>SubType</th>
<th>Value</th>
<th>Units</th>
</thead>
<tbody>
<xsl:for-each select="//*">
<xsl:variable name="indent" select="count(ancestor::*)" />
<xsl:variable name="element" select="local-name()" />
<xsl:variable name="rowStyle">
<xsl:choose>
<xsl:when test="$element='Header' or $element='Agent' or $element='Device'">
font-weight:bold;
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- get value -->
<xsl:variable name="value">
<xsl:choose>
<xsl:when test="local-name()='Unavailable'">UNAVAILABLE</xsl:when>
<xsl:otherwise>
<xsl:value-of select="text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr style="{$rowStyle}">
<td>
<div class="truncate">
<!-- indent according to depth and show type, eg Device, DataItem -->
<span style="color:transparent">
<xsl:value-of select="substring('xxxxxxxxxxxx',1,$indent)" />
</span>
<!-- add +/- if item has any child elements -->
<xsl:choose>
<xsl:when test="*">
<img style="width:12px;" src="/styles/icon-minus.webp" />
</xsl:when>
<xsl:otherwise>
 
</xsl:otherwise>
</xsl:choose>
<!--   -->
<!-- narrow space - see https://stackoverflow.com/questions/8515365/are-there-other-whitespace-codes-like-nbsp-for-half-spaces-em-spaces-en-space -->
 
<xsl:value-of select="$element" />
</div>
</td>
<td>
<xsl:value-of select="@id" />
</td>
<td>
<xsl:value-of select="@name" />
</td>
<td>
<xsl:value-of select="@category" />
</td>
<td>
<xsl:value-of select="@type" />
</td>
<td>
<xsl:value-of select="@subType" />
</td>
<td>
<xsl:value-of select="$value" />
</td>
<td>
<xsl:value-of select="@units" />
</td>
</tr>
<!-- Header subtable -->
<xsl:choose>
<xsl:when test="$element='Header'">
<tr>
<td colspan="7">
<table class="subtable">
<thead>
<xsl:for-each select="@*">
<th>
<xsl:value-of select="name()" />
</th>
</xsl:for-each>
</thead>
<tbody>
<tr>
<xsl:for-each select="@*">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
</tr>
</tbody>
</table>
</td>
</tr>
</xsl:when>
</xsl:choose>
<!-- Agent subtable -->
<xsl:choose>
<xsl:when test="$element='Agent'">
<tr>
<td colspan="3">
<table class="subtable">
<thead>
<th>uuid</th>
<th>mtconnectVersion</th>
</thead>
<tbody>
<tr>
<td>
<xsl:value-of select="@uuid" />
</td>
<td>
<xsl:value-of select="@mtconnectVersion" />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</xsl:when>
</xsl:choose>
<!-- Device subtable -->
<xsl:choose>
<xsl:when test="$element='Device'">
<tr>
<td colspan="3">
<table class="subtable">
<thead>
<th>uuid</th>
<th>sampleInterval</th>
</thead>
<tbody>
<tr>
<td>
<xsl:value-of select="@uuid" />
</td>
<td>
<xsl:value-of select="@sampleInterval" />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</xsl:when>
</xsl:choose>
<!-- Description subtable -->
<xsl:choose>
<xsl:when test="$element='Description'">
<tr>
<td colspan="7">
<table class="subtable">
<thead>
<xsl:for-each select="@*">
<th>
<xsl:value-of select="name()" />
</th>
</xsl:for-each>
<th>value</th>
</thead>
<tbody>
<tr>
<xsl:for-each select="@*">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
<td>
<xsl:value-of select="text()" />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:template>
<!-- streams -->
<xsl:template match="s:MTConnectStreams">
<div id="main-container" class="table-responsive stickytable-container">
<table class="table table-hover">
<thead>
<th>Element</th>
<th>Id</th>
<th>Name</th>
<th>Timestamp</th>
<th>Sequence</th>
<th>Value</th>
</thead>
<tbody>
<xsl:for-each select="//*">
<xsl:variable name="indent" select="count(ancestor::*)" />
<!-- get element name -->
<xsl:variable name="element">
<xsl:choose>
<xsl:when test="local-name()='Condition'">Conditions</xsl:when>
<xsl:when test="local-name()='Normal'">Condition</xsl:when>
<xsl:when test="local-name()='Warning'">Condition</xsl:when>
<xsl:when test="local-name()='Fault'">Condition</xsl:when>
<xsl:when test="local-name()='Unavailable'">Condition</xsl:when>
<xsl:when test="local-name()='Entry'"></xsl:when>
<xsl:otherwise>
<xsl:value-of select="local-name()" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- get style for the row -->
<xsl:variable name="rowStyle">
<xsl:choose>
<xsl:when test="$element='Header' or $element='DeviceStream' or $element='Samples' or $element='Events' or $element='Conditions'">
font-weight:bold;
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- get value -->
<xsl:variable name="value">
<xsl:choose>
<xsl:when test="local-name()='Normal'">NORMAL</xsl:when>
<xsl:when test="local-name()='Warning'">WARNING</xsl:when>
<xsl:when test="local-name()='Fault'">FAULT</xsl:when>
<xsl:when test="local-name()='Unavailable'">UNAVAILABLE</xsl:when>
<xsl:otherwise>
<xsl:value-of select="text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- get sequence (or entry key) -->
<xsl:variable name="sequence">
<xsl:choose>
<xsl:when test="local-name()='Entry'">
<xsl:value-of select="@key" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@sequence" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- get value style -->
<!-- . or assign a class and define colors in stylesheet -->
<xsl:variable name="valueStyle">
<xsl:choose>
<xsl:when test="$value='NORMAL'">background: #9fe473</xsl:when>
<xsl:when test="$value='WARNING'">background: #ffe989</xsl:when>
<xsl:when test="$value='FAULT'">background: #ff4c41</xsl:when>
<xsl:when test="$value='AVAILABLE'">background: #e7f38b</xsl:when>
<xsl:when test="$value='UNAVAILABLE'">color: #aaa</xsl:when>
<xsl:when test="$value='ACTIVE'">background: #9fe473</xsl:when>
<xsl:when test="$value='INACTIVE'">background: #f0f0f0</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- get sequence style -->
<xsl:variable name="sequenceStyle">
<xsl:choose>
<xsl:when test="local-name()='Entry'">text-align:right;</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr style="{$rowStyle}">
<td>
<!-- indent according to depth and show type, eg Device, DataItem -->
<span style="color:transparent">
<xsl:value-of select="substring('xxxxxxxxxxxx',1,$indent)" />
</span>
<!-- add +/- if item has any child elements -->
<xsl:choose>
<xsl:when test="*">
<img style="width:12px;" src="/styles/icon-minus.webp" />
</xsl:when>
<xsl:otherwise>
 
</xsl:otherwise>
</xsl:choose>
<!--   -->
<!-- narrow space - see https://stackoverflow.com/questions/8515365/are-there-other-whitespace-codes-like-nbsp-for-half-spaces-em-spaces-en-space -->
 
<xsl:value-of select="$element" />
</td>
<!-- . and truncate with ellipsis -->
<!-- <td style="max-width:12em;"> -->
<td>
<xsl:value-of select="@dataItemId" />
</td>
<td>
<xsl:value-of select="@name" />
</td>
<td>
<!-- <xsl:value-of select="@timestamp"/> -->
<!-- <xsl:value-of select="translate(@timestamp,'T',' ')"/> -->
<!-- <xsl:value-of select="substring(@timestamp,12)"/> -->
<!-- <xsl:value-of select="substring(@timestamp,12,10)"/> -->
<span title="{@timestamp}">
<xsl:value-of select="substring(@timestamp,12,10)" />
</span>
</td>
<td style="{$sequenceStyle};">
<!-- <xsl:value-of select="@sequence"/> -->
<xsl:value-of select="$sequence" />
</td>
<td style="{$valueStyle};">
<xsl:value-of select="$value" />
</td>
</tr>
<!-- Header subtable -->
<xsl:choose>
<xsl:when test="$element='Header'">
<tr>
<td colspan="6">
<table class="subtable">
<thead>
<xsl:for-each select="@*">
<th>
<xsl:value-of select="name()" />
</th>
</xsl:for-each>
</thead>
<tbody>
<tr>
<xsl:for-each select="@*">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
</tr>
</tbody>
</table>
</td>
</tr>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:template>
<!-- <xsl:template match="s:VariableDataSet">
<table>
<thead>
<xsl:for-each select="@*">
<th>
<xsl:value-of select="name()"/>
</th>
</xsl:for-each>
</thead>
<tbody>
<tr>
<xsl:for-each select="@*">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</tbody>
</table>
</xsl:template> -->
</xsl:stylesheet>