Skip to content

Commit 2681f34

Browse files
committed
Report table rendering & tweaks
1 parent bf38329 commit 2681f34

File tree

9 files changed

+309
-136
lines changed

9 files changed

+309
-136
lines changed

source/TS.NET.Sequencer/HtmlReportGenerator.cs

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ public void Render(Sequence sequence, string outputFilePath)
3333
sb.AppendLine($" <div>{sequence.Name}</div>");
3434
sb.AppendLine($" <div>{sequence.StartTimestamp.ToString("yyyy-MM-dd HH:mm:ss")} ({sequence.TzId})</div>");
3535
sb.AppendLine($" <div>{HumanDuration(sequence.Duration)}</div>");
36-
sb.AppendLine($" <div>TS00007</div>");
36+
sb.AppendLine($" <div>TS0019</div>");
3737
sb.AppendLine(" </div>");
3838
sb.AppendLine(" </div>");
3939

4040
sb.AppendLine(" <table class=\"min-w-full bg-white\">");
4141
sb.AppendLine(" <thead class=\"bg-gray-200 text-black text-sm leading-normal\">");
4242
sb.AppendLine(" <tr>");
43-
sb.AppendLine(" <th class=\"p-1 pl-2 text-left\">#</th>");
44-
sb.AppendLine(" <th class=\"p-1 text-left\">Step name</th>");
45-
sb.AppendLine(" <th class=\"p-1 text-left\">Duration</th>");
46-
sb.AppendLine(" <th class=\"p-1 text-left\">Summary</th>");
47-
sb.AppendLine(" <th class=\"p-1 pr-2 text-left\">Status</th>");
43+
sb.AppendLine(" <th class=\"p-1 pl-2 text-left font-normal\">#</th>");
44+
sb.AppendLine(" <th class=\"p-1 text-left font-normal\">Step name</th>");
45+
sb.AppendLine(" <th class=\"p-1 text-left font-normal\">Duration</th>");
46+
sb.AppendLine(" <th class=\"p-1 text-left font-normal\">Summary</th>");
47+
sb.AppendLine(" <th class=\"p-1 pr-2 text-left font-normal\">Status</th>");
4848
sb.AppendLine(" </tr>");
4949
sb.AppendLine(" </thead>");
5050
sb.AppendLine(" <tbody class=\"text-black text-sm \">");
@@ -54,7 +54,10 @@ public void Render(Sequence sequence, string outputFilePath)
5454
foreach (var step in sequence.Steps)
5555
{
5656
var status = step.Result?.Status ?? Status.Skipped;
57-
sb.AppendLine($" <tr class=\"even:bg-gray-100 odd:bg-white\">");
57+
if (step.Result?.Exception != null || (step.Result?.Metadata != null && step.Result.Metadata.Length > 0))
58+
sb.AppendLine($" <tr class=\"\">");
59+
else
60+
sb.AppendLine($" <tr class=\"border-b border-gray-300\">");
5861
sb.AppendLine($" <td class=\"p-1 pl-2 text-left whitespace-nowrap\">{step.Index}</td>");
5962
sb.AppendLine($" <td class=\"p-1 text-left\">{step.Name}</td>");
6063
sb.AppendLine($" <td class=\"p-1 text-left\">{HumanDuration(step.Result?.Duration)}</td>");
@@ -64,8 +67,9 @@ public void Render(Sequence sequence, string outputFilePath)
6467

6568
if (step.Result?.Exception != null || (step.Result?.Metadata != null && step.Result.Metadata.Length > 0))
6669
{
67-
sb.AppendLine(" <tr class=\"bg-gray-50\">");
68-
sb.AppendLine(" <td colspan=\"5\" class=\"p-1\">");
70+
sb.AppendLine(" <tr class=\"border-b border-gray-300\">");
71+
sb.AppendLine(" <td class=\"p-2 bg-gray-200\">");
72+
sb.AppendLine(" <td colspan=\"4\" class=\"p-2\">");
6973
sb.AppendLine(" <div class=\"text-sm\">");
7074

7175
if (step.Result.Exception != null)
@@ -76,10 +80,52 @@ public void Render(Sequence sequence, string outputFilePath)
7680

7781
if (step.Result.Metadata != null)
7882
{
83+
bool firstMetadataItem = true;
7984
foreach (var meta in step.Result.Metadata)
8085
{
8186
switch (meta)
8287
{
88+
case ResultMetadataTable table:
89+
if (!table.ShowInReport)
90+
break; // Skip rendering if flagged off
91+
if (firstMetadataItem)
92+
{
93+
sb.AppendLine($"<div class=\"pb-2 text-xs underline\">{table.Name}</div>");
94+
firstMetadataItem = false;
95+
}
96+
else
97+
sb.AppendLine($"<div class=\"py-2 text-xs underline\">{table.Name}</div>");
98+
sb.AppendLine("<table class=\"text-xs border border-gray-400\">");
99+
if (table.Headers != null && table.Headers.Length > 0)
100+
{
101+
sb.AppendLine("<thead>");
102+
sb.AppendLine("<tr>");
103+
foreach (var h in table.Headers)
104+
{
105+
sb.AppendLine($"<th class=\"px-2 py-1 border-b border-gray-400 text-left font-normal\">{h}</th>");
106+
}
107+
sb.AppendLine("</tr>");
108+
sb.AppendLine("</thead>");
109+
}
110+
if (table.Rows != null && table.Rows.Length > 0)
111+
{
112+
sb.AppendLine("<tbody>");
113+
foreach (var row in table.Rows)
114+
{
115+
sb.AppendLine("<tr>");
116+
if (row != null)
117+
{
118+
foreach (var cell in row)
119+
{
120+
sb.AppendLine($"<td class=\"px-2 py-1 border-b border-gray-300\">{cell}</td>");
121+
}
122+
}
123+
sb.AppendLine("</tr>");
124+
}
125+
sb.AppendLine("</tbody>");
126+
}
127+
sb.AppendLine("</table>");
128+
break;
83129
//case StepResultChart chart:
84130
// sb.AppendLine(" <em class=\"text-gray-500\">Chart metadata not yet implemented in report.</em>");
85131
// break;
@@ -120,7 +166,7 @@ private static string HumanDuration(TimeSpan? duration)
120166

121167
private static string StatusTextColour(Status? status)
122168
{
123-
switch(status)
169+
switch (status)
124170
{
125171
case Status.Running:
126172
case Status.Cancelled:
@@ -136,7 +182,7 @@ private static string StatusTextColour(Status? status)
136182
return "text-black";
137183
default:
138184
throw new NotImplementedException();
139-
}
185+
}
140186
}
141187

142188
private static string GetStyles(Sequence sequence)
@@ -152,7 +198,7 @@ private static string GetStyles(Sequence sequence)
152198
{
153199
var content = reader.ReadToEnd();
154200
content = content.Replace("[@top-center content]", sequence.Name);
155-
content = content.Replace("[@top-right content]", "Device: TS00007");
201+
content = content.Replace("[@top-right content]", "Device: TS0019");
156202
content = content.Replace("[@bottom-left content]", sequence.StartTimestamp.ToString("yyyy-MM-dd HH:mm:ss"));
157203
sb.Append(content);
158204
}

source/TS.NET.Sequencer/Result/ResultMetadataTable.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
public class ResultMetadataTable : ResultMetadata
44
{
5-
public string TableProperty { get; set; }
5+
public string[] Headers { get; set; }
6+
public string[][] Rows { get; set; }
67
}
78
}

source/TS.NET.Sequencer/report-tailwind.css

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@
1313
--color-red-700: oklch(50.5% 0.213 27.518);
1414
--color-yellow-600: oklch(68.1% 0.162 75.834);
1515
--color-green-600: oklch(62.7% 0.194 149.214);
16-
--color-gray-50: oklch(98.5% 0.002 247.839);
1716
--color-gray-100: oklch(96.7% 0.003 264.542);
1817
--color-gray-200: oklch(92.8% 0.006 264.531);
18+
--color-gray-300: oklch(87.2% 0.01 258.338);
19+
--color-gray-400: oklch(70.7% 0.022 261.325);
1920
--color-gray-500: oklch(55.1% 0.027 264.364);
2021
--color-gray-900: oklch(21% 0.034 264.665);
2122
--color-black: #000;
2223
--color-white: #fff;
2324
--spacing: 0.25rem;
2425
--container-4xl: 56rem;
26+
--text-xs: 0.75rem;
27+
--text-xs--line-height: calc(1 / 0.75);
2528
--text-sm: 0.875rem;
2629
--text-sm--line-height: calc(1.25 / 0.875);
2730
--text-4xl: 2.25rem;
2831
--text-4xl--line-height: calc(2.5 / 2.25);
32+
--font-weight-normal: 400;
2933
--leading-normal: 1.5;
3034
--default-font-family: var(--font-sans);
3135
--default-mono-font-family: var(--font-mono);
@@ -200,6 +204,9 @@
200204
.flex {
201205
display: flex;
202206
}
207+
.table {
208+
display: table;
209+
}
203210
.max-w-4xl {
204211
max-width: var(--container-4xl);
205212
}
@@ -218,16 +225,27 @@
218225
.gap-2 {
219226
gap: calc(var(--spacing) * 2);
220227
}
228+
.border {
229+
border-style: var(--tw-border-style);
230+
border-width: 1px;
231+
}
221232
.border-2 {
222233
border-style: var(--tw-border-style);
223234
border-width: 2px;
224235
}
236+
.border-b {
237+
border-bottom-style: var(--tw-border-style);
238+
border-bottom-width: 1px;
239+
}
240+
.border-gray-300 {
241+
border-color: var(--color-gray-300);
242+
}
243+
.border-gray-400 {
244+
border-color: var(--color-gray-400);
245+
}
225246
.border-gray-900 {
226247
border-color: var(--color-gray-900);
227248
}
228-
.bg-gray-50 {
229-
background-color: var(--color-gray-50);
230-
}
231249
.bg-gray-200 {
232250
background-color: var(--color-gray-200);
233251
}
@@ -243,9 +261,18 @@
243261
.p-2 {
244262
padding: calc(var(--spacing) * 2);
245263
}
264+
.px-2 {
265+
padding-inline: calc(var(--spacing) * 2);
266+
}
246267
.px-10 {
247268
padding-inline: calc(var(--spacing) * 10);
248269
}
270+
.py-1 {
271+
padding-block: calc(var(--spacing) * 1);
272+
}
273+
.py-2 {
274+
padding-block: calc(var(--spacing) * 2);
275+
}
249276
.py-4 {
250277
padding-block: calc(var(--spacing) * 4);
251278
}
@@ -255,6 +282,9 @@
255282
.pr-2 {
256283
padding-right: calc(var(--spacing) * 2);
257284
}
285+
.pb-2 {
286+
padding-bottom: calc(var(--spacing) * 2);
287+
}
258288
.pl-2 {
259289
padding-left: calc(var(--spacing) * 2);
260290
}
@@ -272,10 +302,18 @@
272302
font-size: var(--text-sm);
273303
line-height: var(--tw-leading, var(--text-sm--line-height));
274304
}
305+
.text-xs {
306+
font-size: var(--text-xs);
307+
line-height: var(--tw-leading, var(--text-xs--line-height));
308+
}
275309
.leading-normal {
276310
--tw-leading: var(--leading-normal);
277311
line-height: var(--leading-normal);
278312
}
313+
.font-normal {
314+
--tw-font-weight: var(--font-weight-normal);
315+
font-weight: var(--font-weight-normal);
316+
}
279317
.whitespace-nowrap {
280318
white-space: nowrap;
281319
}
@@ -303,15 +341,8 @@
303341
.text-yellow-600 {
304342
color: var(--color-yellow-600);
305343
}
306-
.odd\:bg-white {
307-
&:nth-child(odd) {
308-
background-color: var(--color-white);
309-
}
310-
}
311-
.even\:bg-gray-100 {
312-
&:nth-child(even) {
313-
background-color: var(--color-gray-100);
314-
}
344+
.underline {
345+
text-decoration-line: underline;
315346
}
316347
.print\:bg-white {
317348
@media print {
@@ -333,11 +364,16 @@
333364
syntax: "*";
334365
inherits: false;
335366
}
367+
@property --tw-font-weight {
368+
syntax: "*";
369+
inherits: false;
370+
}
336371
@layer properties {
337372
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
338373
*, ::before, ::after, ::backdrop {
339374
--tw-border-style: solid;
340375
--tw-leading: initial;
376+
--tw-font-weight: initial;
341377
}
342378
}
343379
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using TS.NET.Photino;
2+
using TS.NET.Sequencer;
3+
4+
namespace TS.NET.Sequences;
5+
6+
public class AdcFineGainAnalysisSequence : Sequence
7+
{
8+
public BenchCalibrationVariables Variables { get; private set; }
9+
10+
public AdcFineGainAnalysisSequence(Func<Dialog, DialogResult> uiDialog, BenchCalibrationVariables variables)
11+
{
12+
Name = "ADC fine gain analysis";
13+
Variables = variables;
14+
variables.WarmupTimeSec = 30;
15+
AddSteps(uiDialog);
16+
SetStepIndices();
17+
}
18+
19+
private void AddSteps(Func<Dialog, DialogResult> uiDialog)
20+
{
21+
Steps =
22+
[
23+
new InitialiseDeviceStep("Initialise device", Variables),
24+
new InitialiseSigGensStep("Initialise instruments", Variables),
25+
new LoadUserCalFromDeviceFallbackToFileStep("Load calibration from device/file", Variables),
26+
new WarmupStep("Warmup device", Variables) { Skip = false, AllowSkip = true },
27+
28+
new Step("Connect SDG2042X - Channel 1"){ Action = (CancellationToken cancellationToken) => {
29+
Instruments.Instance.SetSdgChannel(0);
30+
cancellationToken.WaitHandle.WaitOne(2000);
31+
return Sequencer.Status.Done;
32+
}},
33+
34+
new AdcBranchGainsStep("ADC branch gains - Channel 1 - 1 GSPS", 0, 1_000_000_000, Variables),
35+
new AdcBranchGainsStep("ADC branch gains - Channel 1 - 660 MSPS", 0, 660_000_000, Variables),
36+
new AdcBranchGainsStep("ADC branch gains - Channel 1 - 500 MSPS", 0, 500_000_000, Variables),
37+
new AdcBranchGainsStep("ADC branch gains - Channel 1 - 330 MSPS", 0, 330_000_000, Variables),
38+
new AdcBranchGainsStep("ADC branch gains - Channel 1 - 250 MSPS", 0, 250_000_000, Variables),
39+
new AdcBranchGainsStep("ADC branch gains - Channel 1 - 165 MSPS", 0, 165_000_000, Variables),
40+
new AdcBranchGainsStep("ADC branch gains - Channel 1 - 100 MSPS", 0, 100_000_000, Variables),
41+
42+
new Step("Connect SDG2042X - Channel 3"){ Action = (CancellationToken cancellationToken) => {
43+
Instruments.Instance.SetSdgChannel(2);
44+
cancellationToken.WaitHandle.WaitOne(2000);
45+
return Sequencer.Status.Done;
46+
}},
47+
48+
new AdcBranchGainsStep("ADC branch gains - Channel 3 - 1 GSPS", 2, 1_000_000_000, Variables),
49+
new AdcBranchGainsStep("ADC branch gains - Channel 3 - 660 MSPS", 2, 660_000_000, Variables),
50+
new AdcBranchGainsStep("ADC branch gains - Channel 3 - 500 MSPS", 2, 500_000_000, Variables),
51+
new AdcBranchGainsStep("ADC branch gains - Channel 3 - 330 MSPS", 2, 330_000_000, Variables),
52+
new AdcBranchGainsStep("ADC branch gains - Channel 3 - 250 MSPS", 2, 250_000_000, Variables),
53+
new AdcBranchGainsStep("ADC branch gains - Channel 3 - 165 MSPS", 2, 165_000_000, Variables),
54+
new AdcBranchGainsStep("ADC branch gains - Channel 3 - 100 MSPS", 2, 100_000_000, Variables),
55+
56+
new Step("Disconnect SDG2042X"){ Action = (CancellationToken cancellationToken) => { Instruments.Instance.SetSdgChannel(-1); return Sequencer.Status.Done; }},
57+
58+
new Step("Cleanup"){ Action = (CancellationToken cancellationToken) => {
59+
Instruments.Instance.Close();
60+
return Sequencer.Status.Done;
61+
}},
62+
];
63+
}
64+
}

source/TS.NET.Sequences/Sequences/BenchCalibrationSequence.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private void AddSteps(Func<Dialog, DialogResult> uiDialog)
8484
return Sequencer.Status.Done;
8585
}},
8686

87-
new AdcFineGainStep("Measure & set ADC fine gain", Variables),
87+
new AdcBranchGainsStep("Measure & set ADC fine gain", 0, 1_000_000_000, Variables),
8888

8989
new BufferInputVppStep("Channel 1 - measure buffer input Vpp - HG L0", 0, 0, Variables) { IgnoreError = true, Timeout = TimeSpan.FromSeconds(30), MaxRetries = 3 },
9090
new BufferInputVppStep("Channel 1 - measure buffer input Vpp - HG L1", 0, 1, Variables) { IgnoreError = true, Timeout = TimeSpan.FromSeconds(30), MaxRetries = 3 },

0 commit comments

Comments
 (0)