-
Notifications
You must be signed in to change notification settings - Fork 0
/
Client.html
2746 lines (2314 loc) · 111 KB
/
Client.html
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
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<style>
body {
background-color: #EBECF0;
margin-top: 20px;
margin-left: 10px;
font-family: Verdana;
-webkit-tap-highlight-color: transparent;
text-shadow: 1px 1px white;
color: #676767;
}
.checkbox{
display: block;
background: white;
width: 10px;
height: 10px;
border: 1px inset;
border-radius: 3px;
}
.checkmark{
font-size: 10px;
position: relative;
top: -2px;
left: 2px;
visibility: hidden;
}
.timeInput {
box-shadow: inset 2px 2px 5px #babecc, inset -5px -5px 10px #fff;
border-radius: 30px;
border: 0;
height: 30px;
padding-left: 16px;
padding-right: 16px;
margin-right: 5px;
outline: 0;
background-color: #EBECF0;
transition: all 0.2s ease-in-out;
}
.timeInput:focus-within {
box-shadow: inset 1px 1px 2px #babecc, inset -1px -1px 2px #fff
}
.timeInput > input {
border: none;
outline: none;
box-shadow: none;
padding: 0;
margin: 0;
background: transparent;
width: 16px;
color: #676767;
font-family: Verdana;
text-align: center;
}
.timeInput > input:focus{
box-shadow: none;
}
#phaseContainer {
display: flex;
flex-direction: row;
width: 1430px;
margin-left: 80px;
margin-top: 20px;
justify-content: space-evenly;
font-size: 13px;
}
#phaseContainer > div{
display: flex;
flex-direction: column;
}
#offlineText {
position: relative;
top: -150px;
height: 0;
font-size: 20px;
width: 100%;
text-align: center;
}
#thermalCamTooltip{
visibility: hidden;
background: rgba(255 255 255 / 53%);
margin-left: 15px;
z-index: 999999;
position:absolute;
padding: 5px;
border-radius: 10px;
}
.lineChartHover {
visibility: hidden;
z-index: 999999;
position: absolute;
margin-left: 15px;
display: flex;
}
.lineChartHoverText {
background: rgba(255 255 255 / 53%);
padding: 5px;
border-radius: 10px;
}
#lineChartVerticalIndicator {
visibility: hidden;
z-index: 999999;
position: absolute;
margin-left: -5px;
display: block;
background: #bebebe;
height: 720px;
width: 2px;
top: 70px;
}
#lineChartHorizontalIndicator {
visibility: hidden;
z-index: 999999;
position: absolute;
margin-top: -5px;
display: block;
background: #bebebe;
height: 2px;
width: 1302px;
left: 164px;
}
#beanTemperatureProjection {
z-index: 99999;
position: absolute;
display: block;
height: 500px;
width: 2px;
background: repeating-linear-gradient( 0deg, transparent, transparent 10px, #ccc 10px, #ccc 20px );
visibility: hidden;
}
.propertySectionTitle {
width: 100%;
display: block;
margin-bottom: 3px;
margin-top: 10px;
text-align: center;
color: #9397a4;
font-weight: bold;
}
#propertiesInputForm{
display: flex;
flex-direction: column;
}
#propertiesInputForm > div{
display: flex;
flex-direction: row;
justify-content: space-between;
}
.filePickerInput {
background-image: url('img/file.png');
background-repeat: no-repeat;
background-size: 20px;
padding-left: 40px;
background-position: 16px 5px;
cursor: pointer;
}
input {
margin: 5px;
width: 220px;
box-shadow: inset 2px 2px 5px #babecc, inset -5px -5px 10px #fff;
border-radius: 30px;
border: 0;
height: 30px;
padding-left: 16px;
outline: 0;
background-color: #EBECF0;
transition: all 0.2s ease-in-out;
}
input:focus {
box-shadow: inset 1px 1px 2px #babecc, inset -1px -1px 2px #fff
}
input:disabled {
box-shadow: none;
border: 1px solid #bebebe;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
#actions{
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
margin-right: 10px;
}
.actionButton{
text-align: center;
width: 50px;
height: 50px;
display: flex;
flex-direction: column;
justify-content: center;
font-size: 13px;
}
#backgroundBlur {
position: fixed;
backdrop-filter: blur(5px);
/*backdrop-filter: brightness(40%);*/
z-index: 999;
width: 100%;
height: 100%;
left: 0;
top: 0;
visibility: hidden;
}
.textBox {
width: 97%;
height: 100px;
overflow-x: hidden;
overflow-y: scroll;
box-shadow: inset 2px 2px 5px #babecc, inset -5px -5px 10px #fff;
border-radius: 10px;
border: 0;
padding-left: 15px;
outline: 0;
background-color: #ececec;
padding-top: 10px;
font-size: 13px;
margin-left: 5px;
padding-bottom: 10px;
text-shadow: 1px 1px white;
color: #676767;
font-family: Verdana;
}
.textBox::-webkit-scrollbar {
width: 20px;
}
.textBox::-webkit-scrollbar-track {
}
.textBox::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #babecc;
border: 1px solid #9b9b9b;
}
.textBox::-webkit-scrollbar-thumb:hover {
background: #a9adbb;
}
.textBox::-webkit-scrollbar-thumb:active {
background: #989caa;
}
textarea {
resize: none;
}
textarea:focus{
outline: none;
}
#propertiesIcon {
opacity: 0.5;
cursor: pointer;
transition: transform 0.5s;
padding: 5px;
}
#propertiesIcon:hover {
transform: rotate(90deg);
}
#propertiesIcon:active{
opacity: 0.75;
}
#propertiesDialog {
position: fixed;
left: 0;
right: 0;
top: 0;
margin: 2% auto;
width: 700px;
padding: 20px;
border-radius: 20px;
box-shadow: -5px -5px 20px #b0b0b0, 5px 5px 20px black;
background-color: #EBECF0;
visibility: hidden;
z-index: 99999;
}
#propertiesTitle {
width: 100%;
display: block;
text-align: center;
margin-bottom: 10px;
color: #9397a4;
font-weight: bold;
font-size: 1.5em;
}
.button {
border: 0;
outline: 0;
border-radius: 20px;
background-color: #ebecf0;
box-shadow: -5px -5px 10px #fff, 5px 5px 10px #babecc;
transition: all 0.2s ease-in-out;
padding: 5px 8px 5px 8px;
text-decoration: none;
cursor: pointer;
font-weight: bold;
user-select: none;
}
.button:hover {
box-shadow: -2px -2px 5px #fff, 2px 2px 5px #babecc;
}
.button:active {
box-shadow: inset 1px 1px 2px #babecc, inset -1px -1px 2px #fff;
}
.disabledStyle, .disabledElement {
box-shadow: none !important;
border: 1px solid #bebebe !important;
transition: all 0.35s ease-in-out 0.01s;
}
.disabledElement {
pointer-events: none !important;
}
.closeButton {
position: absolute;
right: 15px;
top: 12px;
}
.lineChart {
margin: 0px 10px 0px 10px;
padding: 10px;
border-radius: 20px;
background-color: #ebecf0;
box-shadow: -5px -5px 10px #fff, 5px 5px 10px #babecc;
}
.thermalCam {
width: 320px;
height: 240px;
background-color: grey;
vertical-align: top;
margin: 0px 10px 20px 10px;
border-radius: 20px;
background-color: #ebecf0;
box-shadow: -5px -5px 10px #fff, 5px 5px 10px #babecc;
background-image: url(img/noise.png);
}
.controller {
box-shadow: -5px -5px 10px #fff, 5px 5px 10px #babecc;
border-radius: 20px;
background-color: #d1d4e0;
width: 60px;
height: 320px;
display: flex;
margin: 10px;
user-select: none;
transition: all 0.2s ease-in-out;
}
.controller:hover {
box-shadow: -2px -2px 5px #fff, 2px 2px 5px #babecc;
cursor: pointer;
}
.controller > span {
width: inherit;
background-color: #ebecf0;
background-size: 100% 100%;
display: block;
border-radius: 20px;
align-self: flex-end;
}
.controller > span > span {
display: flex;
height: 100%;
color: #555;
flex-direction: column;
justify-content: flex-end;
align-items: center;
position: relative;
bottom: 15px;
}
#fanImage {
opacity: 0.75;
animation: spin 1.35s linear infinite;
}
@keyframes spin
{
100%
{
transform: rotate(360deg);
}
}
</style>
</head>
<body oncontextmenu="return false;">
<div id="propertiesDialog">
<span class="closeButton button" onclick="hideRoastProperties();">X</span>
<span id="propertiesTitle">Roast Properties</span>
<div id="propertiesInputForm">
<div>
<input type="text" id="roastName" placeholder="Roast Name" title="Roast Name" onchange="roastProfile.setName(event.target.value)" />
<input type="date" readonly="readonly" disabled id="roastDate" title="Roast Date (auto filled)" />
<input type="time" readonly="readonly" disabled id="roastTime" title="Roast Time (auto filled)" />
</div>
<div>
<input type="number" readonly="readonly" disabled placeholder="Temperature (°C)" title="Temperature (°C)" id="ambientTemperature" />
<input type="number" readonly="readonly" disabled placeholder="Humidity (%)" title="Humidity (%)" id="ambientHumidity" />
<input type="number" readonly="readonly" disabled placeholder="Pressure (atm)" title="Pressure (atm)" id="ambientPressure" />
</div>
<span class="propertySectionTitle">Pre Roast Bean Data</span>
<div>
<input type="text" id="beanType" placeholder="Bean Type" title="Bean Type" onchange="roastProfile.setBeanType(event.target.value)" />
<input type="number" id="moistureContent" placeholder="Moisture Content (%)" title="Moisture Content (%)" onchange="roastProfile.setMoistureContent(event.target.value)" />
<input type="number" id="beanScreenSize" placeholder='Bean Screen Size (1/64")' title='Bean Screen Size (1/64")' onchange="roastProfile.setBeanScreenSize(event.target.value)" />
</div>
<div>
<input type="number" id="beanWeight" placeholder="Bean Weight (g)" title="Bean Weight (g)" onchange="roastProfile.setWeight(event.target.value)" />
<input type="number" id="beanVolume" placeholder="Bean Volume (mL)" title="Bean Volume (mL)" onchange="roastProfile.setVolume(event.target.value)" />
<input type="number" id="beanDensity" placeholder="Density (g/mL)" title="Density (g/mL)" onchange="roastProfile.setDensity(event.target.value)" />
</div>
<span class="propertySectionTitle">Post Roast Bean Data</span>
<div>
<input type="number" id="endBeanWeight" placeholder="End Weight (g)" title="End Weight (g)" onchange="roastProfile.setEndWeight(event.target.value)" />
<input type="number" id="endBeanVolume" placeholder="End Volume (mL)" title="End Volume (mL)" onchange="roastProfile.setEndVolume(event.target.value)" />
<input type="number" id="endBeanDensity" placeholder="End Density (g/mL)" title="End Density (g/mL)" onchange="roastProfile.setEndDensity(event.target.value)" />
</div>
<div>
<input type="number" readonly="readonly" disabled id="weightLossPercentage" placeholder="Weight loss (%)" title="Weight loss (%)" />
<input type="number" readonly="readonly" disabled id="volumeGainPercentage" placeholder="Volume gain (%)" title="Volume gain (%)" />
<input type="number" id="groundsColourIndex" placeholder="Grounds Colour Index" title="Grounds Colour Index" onchange="roastProfile.setColourIndex(event.target.value)" />
</div>
</div>
<span class="propertySectionTitle">Roasting Notes</span>
<textarea id="roastingNotes" class="textBox" style="width:99%;" placeholder="Roasting and cupping notes" onchange="roastProfile.setRoastingNotes(event.target.value)"></textarea>
<span class="propertySectionTitle">Event timing</span>
<div style="display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-evenly;">
<div style="display:flex; flex-direction: column; align-items:center;">
<span style="margin-bottom: 3px;">CHG</span>
<div class="timeInput">
<input type="number" id="chgMin" onchange="roastProfile.setEventTimeMin(event.target.value, 'CHG')" placeholder="m" maxlength="2" />:<input type="number" id="chgSec" onchange="roastProfile.setEventTimeSec(event.target.value, 'CHG')" placeholder="s" maxlength="2" />
</div>
</div>
<div style="display:flex; flex-direction: column; align-items:center;">
<span style="margin-bottom: 3px;">DE</span>
<div class="timeInput">
<input type="number" id="deMin" onchange="roastProfile.setEventTimeMin(event.target.value, 'DE')" placeholder="m" maxlength="2" />:<input type="number" id="deSec" onchange="roastProfile.setEventTimeSec(event.target.value, 'DE')" placeholder="s" maxlength="2" />
</div>
</div>
<div style="display:flex; flex-direction: column; align-items:center;">
<span style="margin-bottom: 3px;">FCS</span>
<div class="timeInput">
<input type="number" id="fcsMin" onchange="roastProfile.setEventTimeMin(event.target.value, 'FCS')" placeholder="m" maxlength="2" />:<input type="number" id="fcsSec" onchange="roastProfile.setEventTimeSec(event.target.value, 'FCS')" placeholder="s" maxlength="2" />
</div>
</div>
<div style="display:flex; flex-direction: column; align-items:center;">
<span style="margin-bottom: 3px;">FCE</span>
<div class="timeInput">
<input type="number" id="fceMin" onchange="roastProfile.setEventTimeMin(event.target.value, 'FCE')" placeholder="m" maxlength="2" />:<input type="number" id="fceSec" onchange="roastProfile.setEventTimeSec(event.target.value, 'FCE')" placeholder="s" maxlength="2" />
</div>
</div>
<div style="display:flex; flex-direction: column; align-items:center;">
<span style="margin-bottom: 3px;">SCS</span>
<div class="timeInput">
<input type="number" id="scsMin" onchange="roastProfile.setEventTimeMin(event.target.value, 'SCS')" placeholder="m" maxlength="2" />:<input type="number" id="scsSec" onchange="roastProfile.setEventTimeSec(event.target.value, 'SCS')" placeholder="s" maxlength="2" />
</div>
</div>
<div style="display:flex; flex-direction: column; align-items:center;">
<span style="margin-bottom: 3px;">SCE</span>
<div class="timeInput">
<input type="number" id="sceMin" onchange="roastProfile.setEventTimeMin(event.target.value, 'SCE')" placeholder="m" maxlength="2" />:<input type="number" id="sceSec" onchange="roastProfile.setEventTimeSec(event.target.value, 'SCE')" placeholder="s" maxlength="2" />
</div>
</div>
<div style="display:flex; flex-direction: column; align-items:center;">
<span style="margin-bottom: 3px;">COOL</span>
<div class="timeInput">
<input type="number" id="coolMin" onchange="roastProfile.setEventTimeMin(event.target.value, 'COOL')" placeholder="m" maxlength="2" />:<input type="number" id="coolSec" onchange="roastProfile.setEventTimeSec(event.target.value, 'COOL')" placeholder="s" maxlength="2" />
</div>
</div>
</div>
<span class="propertySectionTitle">Roast Profile Management</span>
<div style="display: flex; flex-direction: row; justify-content: flex-start; align-items: center;">
<div style="width:49%; display:flex; flex-direction: row; justify-content: space-evenly; align-items:center;">
<!--We'll be able to read/write a file using this.files[0] here-->
<span class="button" onclick="loadRoastProfile()">Load</span>
<!--Icons created by Kiranshastry - Flaticon-->
<input type="text" placeholder="Filename" readonly="readonly" class="filePickerInput" onclick="document.getElementById('filePicker').click();" style="width:75%;" id="fileLoadPath" />
<input type="file" id="filePicker" accept=".json" style="display:none;" onchange="document.getElementById('fileLoadPath').value = this.files[0].name; fileToLoad = this.files[0];" />
</div>
<div style="min-width:2%;height:1px;"></div>
<div style="width:49%; display:flex; flex-direction: row; justify-content: space-evenly; align-items:center;">
<input type="text" placeholder="Filename" readonly="readonly" class="filePickerInput" onclick="pickSaveFile()" style="width: 75%; text-align: right; padding-right: 16px;" id="fileSavePath" />
<!--Icons created by Kiranshastry - Flaticon-->
<span class="button" onclick="saveRoastProfile()">Save</span>
</div>
</div>
<span class="propertySectionTitle">Connection settings</span>
<div style="margin-top: 0px; margin-bottom: 5px; ">
<input type="text" id="wsAddress" placeholder="Websocket address: ws://xxx.xxx.xxx.xxx:xxxxx" style=" width: 350px; margin-right: 10px; " />
<span id="connectButton" class="button" onclick="connect()" style="margin-right:10px;">Connect</span>
<span id="disconnectButton" class="button disabledElement" onclick="disconnect()">Disconnect</span>
</div>
<div id="websocketMessages" class="textBox" style="height:60px;"></div>
</div>
<div id="backgroundBlur"></div>
<div style="display: flex; flex-direction: row;">
<div id="actions">
<div class="button actionButton" onclick="showRoastProperties();" title="Show settings dialog">
<img src="img/properties.png" width="40" id="propertiesIcon" />
<!--Icon created by Freepik - Flaticon-->
</div>
<div id="startButton" class="button actionButton" onclick="roastProfile.setStart();" title="Start Roasting">
<span>START</span>
</div>
<div id="chargeButton" class="button actionButton" onclick="roastProfile.setCharge();" title="Charge beans (Drying Phase Start)">
<span>CHG</span>
</div>
<div id="dryEndButton" class="button actionButton" onclick="roastProfile.setDryEnd();" title="Insert Drying Phase End Event">
<span>DRY<br />END</span>
</div>
<div id="fcStartButton" class="button actionButton" onclick="roastProfile.setFirstCrackStart();" title="Insert First Crack Start Event">
<span>FC<br />START</span>
</div>
<div id="fcEndButton" class="button actionButton" onclick="roastProfile.setFirstCrackEnd();" title="Insert First Crack End Event">
<span>FC<br />END</span>
</div>
<div id="scStartButton" class="button actionButton" onclick="roastProfile.setSecondCrackStart();" title="Insert Second Crack Start Event">
<span>SC<br />START</span>
</div>
<div id="scEndButton" class="button actionButton" onclick="roastProfile.setSecondCrackEnd();" title="Insert Second Crack End Event">
<span>SC<br />END</span>
</div>
<div id="coolButton" class="button actionButton" onclick="roastProfile.setCool();" title="Start Cooldown (fan max, drum max, heater min)">
<span>COOL</span>
</div>
<div id="stopButton" class="button actionButton" onclick="roastProfile.setStop();" title="Stop Roasting">
<span>STOP</span>
</div>
<!--
<div class="button actionButton" title="Replay Roast Profile">
<img src="img/replay.png" width="40" style="opacity: 0.5; padding: 5px;" />
<!--Icon created by Freepik - Flaticon--
</div>
-->
</div>
<canvas id="lineChart" class="lineChart">
Your browser does not support the canvas element.
</canvas>
<div id="lineChartTooltip" class="lineChartHover">
<span id="lineChartTooltipText" class="lineChartHoverText"></span>
</div>
<div id="lineChartTimeHover" class="lineChartHover">
<span id="lineChartTimeHoverText" class="lineChartHoverText"></span>
</div>
<div id="lineChartTempHover" class="lineChartHover">
<span id="lineChartTempHoverText" class="lineChartHoverText"></span>
</div>
<div id="lineChartRorHover" class="lineChartHover">
<span id="lineChartRorHoverText" class="lineChartHoverText"></span>
</div>
<div id="lineChartVerticalIndicator"></div>
<div id="lineChartHorizontalIndicator"></div>
<div id="beanTemperatureProjection"></div>
<div style="display: flex; flex-direction: column;">
<canvas id="thermalCamera" width="320" height="240" class="thermalCam">
Your browser does not support the canvas element.
</canvas>
<span id="thermalCamTooltip"></span>
<span id="offlineText">OFFLINE</span>
<div style="display:flex; flex-direction:column; padding:10px;">
<canvas id="thermalCamHistogram" width="300" height="150" style="border: 1px solid #bebebe; background-color: #d1d4e0"></canvas>
<div style="display: flex; flex-direction: row; justify-content: space-around;">
<span id="thermalCamMin"></span>
<span id="thermalCamMostFreq"></span>
<span id="thermalCamMiddle"></span>
<span id="thermalCamAvg"></span>
<span id="thermalCamMax"></span>
</div>
<div style="display: flex; flex-direction: row; justify-content: space-around;">
<span>min</span>
<span>mof</span>
<span>mid</span>
<span>avg</span>
<span>max</span>
</div>
</div>
<div id="controllers" style="display: flex; flex-direction: row; justify-content: space-evenly;">
<div id="fanController" class="controller disabledElement" title="Cooling Fan Control">
<span style="height: 0%;">
<span><img src="img/fan.png" width="30" id="fanImage" /></span>
<!--Icon created by Dreamstale - Flaticon-->
</span>
</div>
<div id="drumController" class="controller disabledElement" title="Drum Motor Control">
<span style="height: 50%;">
<span><img src="img/motor.png" width="50" style="opacity:0.75; rotate: 270deg;" /></span>
<!--Icon created by monkik - Flaticon-->
</span>
</div>
<div id="heaterController" class="controller disabledElement" title="Heater Element Control">
<span style="height: 25%;">
<span><img src="img/fire.png" width="40" style="opacity:0.75;" /></span>
<!--Icon created by Those Icons - Flaticon-->
</span>
</div>
</div>
</div>
<div class="checkbox" id="beanFilterMaskCheckbox" onclick="toggleBeanFilterMask()">
<span class="checkmark">x</span>
</div>
</div>
<div id="phaseContainer">
<div>
<span>Drying Phase</span>
<span id="dryingPhaseTime"></span>
<span id="dryingPhaseStat"></span>
</div>
<div>
<span>Maillard Phase</span>
<span id="maillardPhaseTime"></span>
<span id="maillardPhaseStat"></span>
</div>
<div>
<span>Development Phase</span>
<span id="developmentPhaseTime"></span>
<span id="developmentPhaseStat"></span>
</div>
<div>
<span>Cooling Phase</span>
<span id="coolingPhaseTime"></span>
<span id="coolingPhaseStat"></span>
</div>
</div>
<div style="display: flex; flex-direction: row; justify-content: space-evenly; width: 1160px; left: 205px; top: 30px; position: absolute;">
<span id="auc"></span>
<span id="ror"></span>
<span id="bt"></span>
<span id="camt">CamT: xx*C</span>
<span id="airt">AirT: xx*C</span>
</div>
<script>
class MovingAverage {
#containerMA = [];
#maxSize = 1000;
constructor(ms) {
this.#maxSize = ms;
}
ma(x) {
this.#containerMA.push(x);
var avg = 0;
for (var v of this.#containerMA) {
avg += v;
}
avg /= this.#containerMA.length;
if (this.#containerMA.length >= this.#maxSize) {
this.#containerMA.shift();
}
return avg;
}
min() {
var minval = this.#containerMA[0];
for (var v of this.#containerMA) {
if (v < minval) minval = v;
}
return minval;
}
max() {
var maxval = this.#containerMA[0];
for (var v of this.#containerMA) {
if (v > maxval) maxval = v;
}
return maxval;
}
}
class LineChart {
#horizontalMinVal;
#horizontalMaxVal;
#verticalMinVal;
#verticalMaxVal;
#secondaryVerticalMinVal;
#secondaryVerticalMaxVal;
#canvasWidth;
#canvasHeight;
#ctx;
#vertAxisOffsetX;
getWidth() { return this.#canvasWidth; }
getHeight() { return this.#canvasHeight; }
constructor(canvas, cWidth, cHeight, hMinVal, hMaxVal, vMinVal, vMaxVal, vsMinVal, vsMaxVal) {
var c = canvas.getContext("2d");
var wh = scaleCanvas(canvas, c, cWidth, cHeight);
cWidth = wh[0];
cHeight = wh[1];
this.#ctx = c;
this.#canvasWidth = cWidth;
this.#canvasHeight = cHeight;
this.#horizontalMinVal = hMinVal;
this.#horizontalMaxVal = hMaxVal;
this.#verticalMinVal = vMinVal;
this.#verticalMaxVal = vMaxVal;
this.#vertAxisOffsetX = 0;
this.#secondaryVerticalMinVal = vsMinVal;
this.#secondaryVerticalMaxVal = vsMaxVal;
}
canvasYoffsetToVal(y) {
y = this.#canvasHeight - y;
var v = y - 20;
var h = this.#canvasHeight - 40 * 2;
var r = v / h;
var s = r * this.#verticalMaxVal - this.#verticalMinVal;
return s;
}
canvasYoffsetToValSecondaryAxis(y) {
y = this.#canvasHeight - y;
var v = y - 20;
var h = this.#canvasHeight - 40 * 2;
var r = v / h;
var s = r * this.#secondaryVerticalMaxVal - this.#secondaryVerticalMinVal;
return s;
}
valToCanvasYoffset(v) {
var spaceAvailable = this.#canvasHeight - 40 * 2;
return this.#canvasHeight - 40 - (v - this.#verticalMinVal) / (this.#verticalMaxVal - this.#verticalMinVal) * spaceAvailable;
}
valToCanvasYoffsetSecondaryAxis(v) {
var spaceAvailable = this.#canvasHeight - 40 * 2;
return this.#canvasHeight - 40 - (v - this.#secondaryVerticalMinVal) / (this.#secondaryVerticalMaxVal - this.#secondaryVerticalMinVal) * spaceAvailable;
}
#drawHorizontalLines(v, xOffset) {
var line = new Path2D();
var yOffset = this.valToCanvasYoffset(v);
line.moveTo(xOffset + 15, yOffset);
line.lineTo(this.#canvasWidth - 40, yOffset);
this.#ctx.stroke(line);
}
#drawHorizontalSecondaryLines(xOffset, v) {
var line = new Path2D();
var yOffset = this.valToCanvasYoffsetSecondaryAxis(v);
var chartWidth = (this.#canvasWidth - 40) - (xOffset + 15);
line.moveTo(xOffset + 15 + chartWidth - 5, yOffset);
line.lineTo(xOffset + 15 + chartWidth + 5, yOffset);
this.#ctx.stroke(line);
}
#drawVerticalAxisText(v) {
var lineOffsetY = this.valToCanvasYoffset(v);
this.#ctx.fillText(v, 5, lineOffsetY + 7);
return this.#ctx.measureText(v).width;
}
#drawSecondaryVerticalAxisText(xOffset, v) {
var lineOffsetY = this.valToCanvasYoffsetSecondaryAxis(v);
var chartWidth = (this.#canvasWidth - 40) - (xOffset + 15);
this.#ctx.fillText(v, xOffset + 15 + chartWidth + 15, lineOffsetY + 7);
}
valToCanvasXoffset(v) {
var spaceAvailable = this.#canvasWidth - 40 - (this.#vertAxisOffsetX + 20);
return this.#vertAxisOffsetX + 20 + (v - this.#horizontalMinVal) / (this.#horizontalMaxVal - this.#horizontalMinVal) * spaceAvailable;
}
canvasXoffsetToVal(x) {
var v = x - this.#vertAxisOffsetX - 20;
var w = this.#canvasWidth - 40 - (this.#vertAxisOffsetX + 20);
var r = v / w;
var s = r * this.#horizontalMaxVal - this.#horizontalMinVal;
return s;
}
#drawHorizontalAxisText(v) {
var offsetX = this.valToCanvasXoffset(v);
var textWidth = this.#ctx.measureText(v).width;
this.#ctx.fillText(v, offsetX - textWidth / 2, this.#canvasHeight - 10);
}
#drawVertixalLines(v, offsetY) {
var offsetX = this.valToCanvasXoffset(v);
var line = new Path2D();
line.moveTo(offsetX, this.#canvasHeight - 40 + offsetY);
line.lineTo(offsetX, 40);
this.#ctx.stroke(line);
}
drawEventLine(x, title, subtitle, subsubtitle) {
var xPos = this.valToCanvasXoffset(x);
this.#ctx.font = "13px Verdana";
this.#ctx.fillText(title, xPos - this.#ctx.measureText(title).width / 2, 55);
this.#ctx.fillText(subtitle, xPos - this.#ctx.measureText(subtitle).width / 2, 55 + 13);
this.#ctx.fillText(subsubtitle, xPos - this.#ctx.measureText(subsubtitle).width / 2, 55 + 13 * 2);
var line = new Path2D();
line.moveTo(xPos, this.#canvasHeight - 40);
line.lineTo(xPos, 50 + 3 * 13);
this.#ctx.lineWidth = 2.0;
this.#ctx.strokeStyle = '#676767';
this.#ctx.stroke(line);
}
drawLineChartBackground(
horizontalAxisTitleStr, verticalAxisTitleStr,
secondaryVerticalAxisTitleStr,
horizontalLabelArray, verticalLabelArray,
secondaryVerticalLabelArray
) {
//vertical axis title
this.#ctx.font = "20px Verdana";
this.#ctx.fillStyle = "#676767";
this.#ctx.fillText(verticalAxisTitleStr, 10, 20);
//horizontal axis title
var horizontalAxisTextSize = this.#ctx.measureText(horizontalAxisTitleStr).width;
this.#ctx.fillText(horizontalAxisTitleStr, this.#canvasWidth - horizontalAxisTextSize - 20, this.#canvasHeight - 10);
this.#ctx.fillText(secondaryVerticalAxisTitleStr, this.#canvasWidth - this.#ctx.measureText(secondaryVerticalAxisTitleStr).width - 20, 20);
//draw vertical axis texts
for (var i of verticalLabelArray) {
this.#vertAxisOffsetX = Math.max(this.#vertAxisOffsetX, this.#drawVerticalAxisText(i));
}
//draw secondary vertical axis texts
for (var i of secondaryVerticalLabelArray) {
this.#drawSecondaryVerticalAxisText(this.#vertAxisOffsetX, i);
this.#drawHorizontalSecondaryLines(this.#vertAxisOffsetX, i);
}
//draw horizontal axis texts
for (var i of horizontalLabelArray) {
this.#drawHorizontalAxisText(i);
}
//draw horizontal lines
this.#ctx.strokeStyle = 'rgba(0, 0, 0, 0.25)';
this.#drawHorizontalLines(this.#verticalMinVal, this.#vertAxisOffsetX + 5);
this.#drawHorizontalLines(this.#verticalMaxVal, this.#vertAxisOffsetX + 5);
for (var i of verticalLabelArray) {
this.#drawHorizontalLines(i, this.#vertAxisOffsetX);
}
//draw vertical lines
this.#drawVertixalLines(this.#horizontalMinVal, 0);
this.#drawVertixalLines(this.#horizontalMaxVal, 0)
for (var i of horizontalLabelArray) {
this.#drawVertixalLines(i, 5);
}
}
drawCurveSegment(prevH, prevV, h, v, secondary = false, colour = '#676767') {
this.#ctx.strokeStyle = colour;
this.#ctx.lineCap = "round";
this.#ctx.lineJoin = "round";
this.#ctx.lineWidth = 4.0;
var line = new Path2D();
var xfrom = this.valToCanvasXoffset(prevH);
var xto = this.valToCanvasXoffset(h);
var yfrom = 0;
var yto = 0;
if (!secondary) {
yfrom = this.valToCanvasYoffset(prevV);
yto = this.valToCanvasYoffset(v);
}
else {
yfrom = this.valToCanvasYoffsetSecondaryAxis(prevV);
yto = this.valToCanvasYoffsetSecondaryAxis(v);
}
line.moveTo(xfrom, yfrom);
line.lineTo(xto, yto);
this.#ctx.stroke(line);
}
}
class RoastProfile {
#startTime = null; //in milliseconds using performance.now()
#chargeTime = null;
#dryEndTime = null;
#firstCrackStartTime = null;
#firstCrackEndTime = null;
#secondCrackStartTime = null;
#secondCrackEndTime = null;
#coolTime = null
#stopTime = null;
#fanSettings = []; //stores pairs of (performance.now(), percentage%)
#heaterSettings = [];
#drumSettings = [];
#beanTemperatures = []; //stores pairs of (performance.now(), temperature[] in C)
#airTemperatures = [];
#exhaustTemperatures = [];
#name = null;
#date = null; //JS Date()
#beanType = null;
#moistureContent = null; //%
#beanScreenSize = null; //1/64"
#weight = null; //g
#volume = null; //mL
#density = null; //g/mL
#endWeight = null;
#endVolume = null;
#endDensity = null;
#ambientTemperature = null;
#ambientHumidity = null; //%
#ambientPressure = null; //atm
#colourIndex = null;
#roastingNotes = null;
#heaterLineColour = "#F09D9D";
#drumMotorLineColour = "#F9F392";
#fanMotorLineColour = "#A7C7E7";
stringify() {