@mchp-mcc/scf-pic8-opamp-v2 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1601 @@
1
+ import { DerivedData } from "@microchip/melody-automodule-interface/lib/src/DerivedData";
2
+ import { AppModel } from "../generated_module/src/types/AutoModuleTypes";
3
+ import { getModel, mockState } from "../generated_module/tests/AppModel.test";
4
+ import { mockAssignedModule } from "../generated_module/tests/processor.test";
5
+ import { EmptyDerivedData, getDerivedData } from "./DerivedData";
6
+ import { getGeneratorModel } from "./GeneratorModel";
7
+
8
+ describe("EmptyDerivedData Tests", () => {
9
+ it("Test for new EmptyDerivedData", () => {
10
+ expect(new EmptyDerivedData().getMyFunctions()).toStrictEqual({});
11
+ expect(new EmptyDerivedData().getModel()).toBeUndefined();
12
+ });
13
+ });
14
+
15
+ describe("Template Data Tests", () => {
16
+ const mockModule = mockAssignedModule(mockState());
17
+ const model = getModel(mockModule, getDerivedData);
18
+ const derivedData = model?.getDerivedData() as DerivedData;
19
+ const derivedFunctions = derivedData?.getMyFunctions();
20
+
21
+ const templateData = {
22
+ componentName: "OPA2",
23
+ header: { name: "opa2.h", path: "../" },
24
+ moduleInstance: "OPA2",
25
+ moduleNameLowerCase: "opa2",
26
+ moduleNameUpperCase: "OPA2",
27
+ };
28
+ expect(derivedFunctions.templateData?.()?.header).toEqual(templateData.header);
29
+ expect(derivedFunctions.templateData?.()?.moduleInstance).toEqual(
30
+ templateData.moduleInstance,
31
+ );
32
+ expect(derivedFunctions.templateData?.()?.moduleNameLowerCase).toEqual(
33
+ templateData.moduleNameLowerCase,
34
+ );
35
+ expect(derivedFunctions.templateData?.()?.moduleNameUpperCase).toEqual(
36
+ templateData.moduleNameUpperCase,
37
+ );
38
+ });
39
+
40
+ describe("Positive Sources Enumeration Tests", () => {
41
+ let mockModule = mockAssignedModule(mockState());
42
+ mockModule = {
43
+ ...mockModule,
44
+ state: {
45
+ ...mockModule.state,
46
+ main: {
47
+ channelSel: {
48
+ pchOpacon2: "OPA2IN+",
49
+ pssOpacon3: "OPA2IN0+",
50
+ },
51
+ },
52
+ },
53
+ imports: {
54
+ ...mockModule.imports,
55
+ pin_standard: {
56
+ interfaceId: {
57
+ name: "pin-standard",
58
+ version: "^0",
59
+ },
60
+ handle: {
61
+ exportId: "mockExportId",
62
+ providerId: "mockProviderId",
63
+ },
64
+ payload: {
65
+ allpins: {
66
+ RA0: {
67
+ OPA2: {
68
+ "OPA2IN3+": {
69
+ alias: "OPA2IN3+",
70
+ },
71
+ "OPA2IN3-": {
72
+ alias: "OPA2IN3-",
73
+ },
74
+ },
75
+ },
76
+ RA2: {
77
+ OPA2: {
78
+ "OPA2IN2+": {
79
+ alias: "OPA2IN2+",
80
+ },
81
+ "OPA2IN2-": {
82
+ alias: "OPA2IN2-",
83
+ },
84
+ },
85
+ },
86
+ RB4: {
87
+ OPA2: {
88
+ "OPA2IN0-": {
89
+ alias: "OPA2IN0-",
90
+ },
91
+ },
92
+ },
93
+ RB5: {
94
+ OPA2: {
95
+ "OPA2IN0+": {
96
+ alias: "OPA2IN0+",
97
+ },
98
+ },
99
+ },
100
+ RC2: {
101
+ OPA2: {
102
+ OPA2OUT: {
103
+ alias: "OPA2OUT",
104
+ },
105
+ },
106
+ },
107
+ RC3: {
108
+ OPA2: {
109
+ "OPA2IN1-": {
110
+ alias: "OPA2IN1-",
111
+ },
112
+ "OPA2IN1+": {
113
+ alias: "OPA2IN1+",
114
+ },
115
+ },
116
+ },
117
+ },
118
+ },
119
+ },
120
+ },
121
+ };
122
+
123
+ const model = getModel(mockModule, getDerivedData);
124
+ const derivedData = model?.getDerivedData() as DerivedData;
125
+ const derivedFunctions = derivedData?.getMyFunctions();
126
+
127
+ const templateData = {
128
+ posSources: [
129
+ { name: "RB5_IN0_pos", value: "0x0" },
130
+ { name: "RC3_IN1_pos", value: "0x1" },
131
+ { name: "RA2_IN2_pos", value: "0x2" },
132
+ { name: "RA0_IN3_pos", value: "0x3" },
133
+ ],
134
+ };
135
+
136
+ expect(derivedFunctions.templateData?.()?.posSources).toEqual(
137
+ templateData.posSources,
138
+ );
139
+ });
140
+
141
+ describe("Positive Sources Custom Name Enumeration Tests", () => {
142
+ let mockModule = mockAssignedModule(mockState());
143
+ mockModule = {
144
+ ...mockModule,
145
+ state: {
146
+ ...mockModule.state,
147
+ main: {
148
+ software: {
149
+ cnameAttribforPosPins: '{ "RB5": { "cname": "RB5_IN0_c" } }',
150
+ },
151
+ channelSel: {
152
+ pchOpacon2: "OPA2IN+",
153
+ pssOpacon3: "OPA2IN0+",
154
+ },
155
+ },
156
+ },
157
+ imports: {
158
+ ...mockModule.imports,
159
+ pin_standard: {
160
+ interfaceId: {
161
+ name: "pin-standard",
162
+ version: "^0",
163
+ },
164
+ handle: {
165
+ exportId: "mockExportId",
166
+ providerId: "mockProviderId",
167
+ },
168
+ payload: {
169
+ allpins: {
170
+ RA0: {
171
+ OPA2: {
172
+ "OPA2IN3+": {
173
+ alias: "OPA2IN3+",
174
+ },
175
+ "OPA2IN3-": {
176
+ alias: "OPA2IN3-",
177
+ },
178
+ },
179
+ },
180
+ RA2: {
181
+ OPA2: {
182
+ "OPA2IN2+": {
183
+ alias: "OPA2IN2+",
184
+ },
185
+ "OPA2IN2-": {
186
+ alias: "OPA2IN2-",
187
+ },
188
+ },
189
+ },
190
+ RB4: {
191
+ OPA2: {
192
+ "OPA2IN0-": {
193
+ alias: "OPA2IN0-",
194
+ },
195
+ },
196
+ },
197
+ RB5: {
198
+ OPA2: {
199
+ "OPA2IN0+": {
200
+ alias: "OPA2IN0+",
201
+ },
202
+ },
203
+ },
204
+ RC2: {
205
+ OPA2: {
206
+ OPA2OUT: {
207
+ alias: "OPA2OUT",
208
+ },
209
+ },
210
+ },
211
+ RC3: {
212
+ OPA2: {
213
+ "OPA2IN1-": {
214
+ alias: "OPA2IN1-",
215
+ },
216
+ "OPA2IN1+": {
217
+ alias: "OPA2IN1+",
218
+ },
219
+ },
220
+ },
221
+ },
222
+ },
223
+ },
224
+ },
225
+ };
226
+
227
+ const model = getModel(mockModule, getDerivedData);
228
+ const derivedData = model?.getDerivedData() as DerivedData;
229
+ const derivedFunctions = derivedData?.getMyFunctions();
230
+
231
+ const templateData = {
232
+ posSources: [
233
+ { name: "RB5_IN0_c_pos", value: "0x0" },
234
+ { name: "RC3_IN1_pos", value: "0x1" },
235
+ { name: "RA2_IN2_pos", value: "0x2" },
236
+ { name: "RA0_IN3_pos", value: "0x3" },
237
+ ],
238
+ };
239
+
240
+ expect(derivedFunctions.templateData?.()?.posSources).toEqual(
241
+ templateData.posSources,
242
+ );
243
+ });
244
+
245
+ describe("Negative Sources Enumeration Tests", () => {
246
+ let mockModule = mockAssignedModule(mockState());
247
+ mockModule = {
248
+ ...mockModule,
249
+ state: {
250
+ ...mockModule.state,
251
+ main: {
252
+ channelSel: {
253
+ nchOpacon2: "OPA2IN-",
254
+ nssOpacon1: "OPA2IN0-",
255
+ },
256
+ },
257
+ },
258
+ imports: {
259
+ ...mockModule.imports,
260
+ pin_standard: {
261
+ interfaceId: {
262
+ name: "pin-standard",
263
+ version: "^0",
264
+ },
265
+ handle: {
266
+ exportId: "mockExportId",
267
+ providerId: "mockProviderId",
268
+ },
269
+ payload: {
270
+ allpins: {
271
+ RA0: {
272
+ OPA2: {
273
+ "OPA2IN3+": {
274
+ alias: "OPA2IN3+",
275
+ },
276
+ "OPA2IN3-": {
277
+ alias: "OPA2IN3-",
278
+ },
279
+ },
280
+ },
281
+ RA2: {
282
+ OPA2: {
283
+ "OPA2IN2+": {
284
+ alias: "OPA2IN2+",
285
+ },
286
+ "OPA2IN2-": {
287
+ alias: "OPA2IN2-",
288
+ },
289
+ },
290
+ },
291
+ RB4: {
292
+ OPA2: {
293
+ "OPA2IN0-": {
294
+ alias: "OPA2IN0-",
295
+ },
296
+ },
297
+ },
298
+ RB5: {
299
+ OPA2: {
300
+ "OPA2IN0+": {
301
+ alias: "OPA2IN0+",
302
+ },
303
+ },
304
+ },
305
+ RC2: {
306
+ OPA2: {
307
+ OPA2OUT: {
308
+ alias: "OPA2OUT",
309
+ },
310
+ },
311
+ },
312
+ RC3: {
313
+ OPA2: {
314
+ "OPA2IN1-": {
315
+ alias: "OPA2IN1-",
316
+ },
317
+ "OPA2IN1+": {
318
+ alias: "OPA2IN1+",
319
+ },
320
+ },
321
+ },
322
+ },
323
+ },
324
+ },
325
+ },
326
+ };
327
+
328
+ const model = getModel(mockModule, getDerivedData);
329
+ const derivedData = model?.getDerivedData() as DerivedData;
330
+ const derivedFunctions = derivedData?.getMyFunctions();
331
+
332
+ const templateData = {
333
+ negSources: [
334
+ { name: "RB4_IN0_neg", value: "0x0" },
335
+ { name: "RC3_IN1_neg", value: "0x1" },
336
+ { name: "RA2_IN2_neg", value: "0x2" },
337
+ { name: "RA0_IN3_neg", value: "0x3" },
338
+ { name: "Vss", value: "0x7" },
339
+ ],
340
+ };
341
+
342
+ expect(derivedFunctions.templateData?.()?.negSources).toEqual(
343
+ templateData.negSources,
344
+ );
345
+ });
346
+
347
+ describe("Negative Sources Custom Name Enumeration Tests", () => {
348
+ let mockModule = mockAssignedModule(mockState());
349
+ mockModule = {
350
+ ...mockModule,
351
+ state: {
352
+ ...mockModule.state,
353
+ main: {
354
+ software: {
355
+ cnameAttribforNegPins: '{ "RB4": { "cname": "RB4_IN0_c" } }',
356
+ },
357
+ channelSel: {
358
+ nchOpacon2: "OPA2IN-",
359
+ nssOpacon1: "OPA2IN0-",
360
+ },
361
+ },
362
+ },
363
+ imports: {
364
+ ...mockModule.imports,
365
+ pin_standard: {
366
+ interfaceId: {
367
+ name: "pin-standard",
368
+ version: "^0",
369
+ },
370
+ handle: {
371
+ exportId: "mockExportId",
372
+ providerId: "mockProviderId",
373
+ },
374
+ payload: {
375
+ allpins: {
376
+ RA0: {
377
+ OPA2: {
378
+ "OPA2IN3+": {
379
+ alias: "OPA2IN3+",
380
+ },
381
+ "OPA2IN3-": {
382
+ alias: "OPA2IN3-",
383
+ },
384
+ },
385
+ },
386
+ RA2: {
387
+ OPA2: {
388
+ "OPA2IN2+": {
389
+ alias: "OPA2IN2+",
390
+ },
391
+ "OPA2IN2-": {
392
+ alias: "OPA2IN2-",
393
+ },
394
+ },
395
+ },
396
+ RB4: {
397
+ OPA2: {
398
+ "OPA2IN0-": {
399
+ alias: "OPA2IN0-",
400
+ },
401
+ },
402
+ },
403
+ RB5: {
404
+ OPA2: {
405
+ "OPA2IN0+": {
406
+ alias: "OPA2IN0+",
407
+ },
408
+ },
409
+ },
410
+ RC2: {
411
+ OPA2: {
412
+ OPA2OUT: {
413
+ alias: "OPA2OUT",
414
+ },
415
+ },
416
+ },
417
+ RC3: {
418
+ OPA2: {
419
+ "OPA2IN1-": {
420
+ alias: "OPA2IN1-",
421
+ },
422
+ "OPA2IN1+": {
423
+ alias: "OPA2IN1+",
424
+ },
425
+ },
426
+ },
427
+ },
428
+ },
429
+ },
430
+ },
431
+ };
432
+
433
+ const model = getModel(mockModule, getDerivedData);
434
+ const derivedData = model?.getDerivedData() as DerivedData;
435
+ const derivedFunctions = derivedData?.getMyFunctions();
436
+
437
+ const templateData = {
438
+ negSources: [
439
+ { name: "RB4_IN0_c_neg", value: "0x0" },
440
+ { name: "RC3_IN1_neg", value: "0x1" },
441
+ { name: "RA2_IN2_neg", value: "0x2" },
442
+ { name: "RA0_IN3_neg", value: "0x3" },
443
+ { name: "Vss", value: "0x7" },
444
+ ],
445
+ };
446
+
447
+ expect(derivedFunctions.templateData?.()?.negSources).toEqual(
448
+ templateData.negSources,
449
+ );
450
+ });
451
+
452
+ describe("Enumeration Tests with undefined hardware", () => {
453
+ let mockModule = mockAssignedModule(mockState());
454
+ mockModule = {
455
+ ...mockModule,
456
+ imports: {
457
+ ...mockModule.imports,
458
+ pin_standard: {
459
+ interfaceId: {
460
+ name: "pin-standard",
461
+ version: "^0",
462
+ },
463
+ handle: {
464
+ exportId: "mockExportId",
465
+ providerId: "mockProviderId",
466
+ },
467
+ payload: {
468
+ allpins: {
469
+ RA0: {
470
+ OPA2: {
471
+ "OPA2IN3+": {
472
+ alias: "OPA2IN3+",
473
+ },
474
+ "OPA2IN3-": {
475
+ alias: "OPA2IN3-",
476
+ },
477
+ },
478
+ },
479
+ RA2: {
480
+ OPA2: {
481
+ "OPA2IN2+": {
482
+ alias: "OPA2IN2+",
483
+ },
484
+ "OPA2IN2-": {
485
+ alias: "OPA2IN2-",
486
+ },
487
+ },
488
+ },
489
+ RB4: {
490
+ OPA2: {
491
+ "OPA2IN0-": {
492
+ alias: "OPA2IN0-",
493
+ },
494
+ },
495
+ },
496
+ RB5: {
497
+ OPA2: {
498
+ "OPA2IN0+": {
499
+ alias: "OPA2IN0+",
500
+ },
501
+ },
502
+ },
503
+ RC2: {
504
+ OPA2: {
505
+ OPA2OUT: {
506
+ alias: "OPA2OUT",
507
+ },
508
+ },
509
+ },
510
+ RC3: {
511
+ OPA2: {
512
+ "OPA2IN1-": {
513
+ alias: "OPA2IN1-",
514
+ },
515
+ "OPA2IN1+": {
516
+ alias: "OPA2IN1+",
517
+ },
518
+ },
519
+ },
520
+ },
521
+ },
522
+ },
523
+ scf_pic8_opamp_v2: {
524
+ interfaceId: {
525
+ name: "scf-pic8-opamp-v2",
526
+ version: "^1.0.0",
527
+ },
528
+ handle: undefined,
529
+ payload: undefined,
530
+ },
531
+ },
532
+ };
533
+
534
+ const model = getModel(mockModule, getDerivedData);
535
+ const derivedData = model?.getDerivedData() as DerivedData;
536
+ const derivedFunctions = derivedData?.getMyFunctions();
537
+
538
+ expect(derivedFunctions.templateData?.()?.posSources).toEqual([]);
539
+ expect(derivedFunctions.templateData?.()?.negSources).toEqual([]);
540
+ });
541
+
542
+ describe("GeneratorModel Test", () => {
543
+ const mockModule = mockAssignedModule(mockState());
544
+ const model = getModel(mockModule, getDerivedData) as AppModel;
545
+
546
+ const templateData = {
547
+ componentName: "OPA2",
548
+ header: [{ name: "opa2.h", path: "../" }],
549
+ moduleInstance: "OPA2",
550
+ moduleNameLowerCase: "opa2",
551
+ moduleNameUpperCase: "OPA2",
552
+ negSources: [
553
+ { name: "RB4_IN0_neg", value: "0x0" },
554
+ { name: "RC3_IN1_neg", value: "0x1" },
555
+ { name: "RA2_IN2_neg", value: "0x2" },
556
+ { name: "RA0_IN3_neg", value: "0x3" },
557
+ { name: "Vss", value: "0x7" },
558
+ ],
559
+ posSources: [
560
+ { name: "RB5_IN0_pos", value: "0x0" },
561
+ { name: "RC3_IN1_pos", value: "0x1" },
562
+ { name: "RA2_IN2_pos", value: "0x2" },
563
+ { name: "RA0_IN3_pos", value: "0x3" },
564
+ ],
565
+ };
566
+
567
+ const posSourceModel = [
568
+ { customName: "RB5_IN0", source: "OPA2IN0+" },
569
+ { customName: "RC3_IN1", source: "OPA2IN1+" },
570
+ { customName: "RA2_IN2", source: "OPA2IN2+" },
571
+ { customName: "RA0_IN3", source: "OPA2IN3+" },
572
+ ];
573
+
574
+ const negSourceModel = [
575
+ { customName: "RB4_IN0", source: "OPA2IN0-" },
576
+ { customName: "RC3_IN1", source: "OPA2IN1-" },
577
+ { customName: "RA2_IN2", source: "OPA2IN2-" },
578
+ { customName: "RA0_IN3", source: "OPA2IN3-" },
579
+ { customName: "Vss", source: "Vss" },
580
+ ];
581
+
582
+ it("Test for GeneratorModel", () => {
583
+ expect(
584
+ getGeneratorModel?.(
585
+ model,
586
+ posSourceModel,
587
+ negSourceModel,
588
+ templateData.header,
589
+ ).posSources,
590
+ ).toEqual(templateData.posSources);
591
+ expect(
592
+ getGeneratorModel?.(
593
+ model,
594
+ posSourceModel,
595
+ negSourceModel,
596
+ templateData.header,
597
+ ).negSources,
598
+ ).toEqual(templateData.negSources);
599
+ });
600
+ });
601
+
602
+ describe("Template Data Test with Undefined Hardware", () => {
603
+ let mockModule = mockAssignedModule(mockState());
604
+ mockModule = {
605
+ ...mockModule,
606
+ imports: {
607
+ ...mockModule.imports,
608
+ scf_pic8_opamp_v2: {
609
+ interfaceId: {
610
+ name: "scf-pic8-opamp-v2",
611
+ version: "1.0.0",
612
+ },
613
+ handle: undefined,
614
+ payload: undefined,
615
+ },
616
+ },
617
+ };
618
+
619
+ const model = getModel(mockModule, getDerivedData) as AppModel;
620
+
621
+ const templateData = {
622
+ componentName: "OPA",
623
+ header: [{ name: "opa2.h", path: "../" }],
624
+ moduleInstance: "OPA",
625
+ moduleNameLowerCase: "OPA",
626
+ moduleNameUpperCase: "OPA",
627
+ negSources: [],
628
+ posSources: [],
629
+ };
630
+
631
+ const posSourceModel = [
632
+ { customName: "RB5_IN0", source: "OPA2IN0+" },
633
+ { customName: "RC3_IN1", source: "OPA2IN1+" },
634
+ { customName: "RA2_IN2", source: "OPA2IN2+" },
635
+ { customName: "RA0_IN3", source: "OPA2IN3+" },
636
+ ];
637
+
638
+ const negSourceModel = [
639
+ { customName: "RB4_IN0", source: "OPA2IN0-" },
640
+ { customName: "RC3_IN1", source: "OPA2IN1-" },
641
+ { customName: "RA2_IN2", source: "OPA2IN2-" },
642
+ { customName: "RA0_IN3", source: "OPA2IN3-" },
643
+ { customName: "Vss", source: "Vss" },
644
+ ];
645
+
646
+ it("Test for GeneratorModel", () => {
647
+ expect(
648
+ getGeneratorModel?.(
649
+ model,
650
+ posSourceModel,
651
+ negSourceModel,
652
+ templateData.header,
653
+ ).posSources,
654
+ ).toEqual(templateData.posSources);
655
+ expect(
656
+ getGeneratorModel?.(
657
+ model,
658
+ posSourceModel,
659
+ negSourceModel,
660
+ templateData.header,
661
+ ).negSources,
662
+ ).toEqual(templateData.negSources);
663
+ });
664
+ });
665
+
666
+ describe("opa Export Interface Tests", () => {
667
+ const mockModule = mockAssignedModule(mockState());
668
+ const model = getModel(mockModule, getDerivedData);
669
+ const derivedData = model?.getDerivedData() as DerivedData;
670
+ const derivedFunctions = derivedData?.getMyFunctions();
671
+
672
+ const export_interface = {
673
+ moduleName: "OPA2",
674
+ customName: "OPA",
675
+ hasInterrupts: false,
676
+ };
677
+
678
+ it("Test for opa Export", () => {
679
+ expect(derivedFunctions?.["opa-output-parameters_payload"]?.()).toEqual(
680
+ export_interface,
681
+ );
682
+ });
683
+ });
684
+
685
+ describe("DAC Notification Test", () => {
686
+ let mockModule = mockAssignedModule(mockState());
687
+ mockModule = {
688
+ ...mockModule,
689
+ state: {
690
+ ...mockModule.state,
691
+ main: {
692
+ channelSel: {
693
+ pchOpacon2: "DAC1_OUT",
694
+ nchOpacon2: "DAC2_OUT",
695
+ },
696
+ },
697
+ },
698
+ };
699
+
700
+ const model = getModel(mockModule, getDerivedData);
701
+ const derivedData = model?.getDerivedData() as DerivedData;
702
+ const derivedFunctions = derivedData?.getMyFunctions();
703
+
704
+ it("Test for DAC Notifications", () => {
705
+ expect(derivedFunctions?.alerts?.()).toEqual([
706
+ {
707
+ text:
708
+ "OPA2 uses DAC1 as Positive Channel. Ensure DAC1 has been configured.",
709
+ type: "warning",
710
+ },
711
+ {
712
+ text:
713
+ "OPA2 uses DAC2 as Negative Channel. Ensure DAC2 has been configured.",
714
+ type: "warning",
715
+ },
716
+ ]);
717
+ });
718
+ });
719
+
720
+ describe("TMR1 Notification Test", () => {
721
+ let mockModule = mockAssignedModule(mockState());
722
+ mockModule = {
723
+ ...mockModule,
724
+ state: {
725
+ ...mockModule.state,
726
+ main: {
727
+ channelSel: {
728
+ nssOpacon1: "OPA2IN1-",
729
+ },
730
+ overrideSel: {
731
+ orsOpaors: "TMR1_OUT",
732
+ },
733
+ },
734
+ },
735
+ };
736
+
737
+ const model = getModel(mockModule, getDerivedData);
738
+ const derivedData = model?.getDerivedData() as DerivedData;
739
+ const derivedFunctions = derivedData?.getMyFunctions();
740
+
741
+ it("Test for TMR1 Notifications", () => {
742
+ expect(derivedFunctions?.alerts?.()).toEqual([
743
+ {
744
+ text:
745
+ "Ensure that the module selected as Hardware Override Source is configured.",
746
+ type: "hint",
747
+ },
748
+ ]);
749
+ });
750
+ });
751
+
752
+ describe("Notification Test with undefined component values", () => {
753
+ let mockModule = mockAssignedModule(mockState());
754
+ mockModule = {
755
+ ...mockModule,
756
+ state: {
757
+ ...mockModule.state,
758
+ main: {
759
+ channelSel: {
760
+ pssOpacon3: undefined,
761
+ nssOpacon1: undefined,
762
+ pchOpacon2: undefined,
763
+ nchOpacon2: undefined,
764
+ },
765
+ overrideSel: {
766
+ orenOpahwc: undefined,
767
+ orsOpaors: undefined,
768
+ },
769
+ },
770
+ },
771
+ };
772
+
773
+ const model = getModel(mockModule, getDerivedData);
774
+ const derivedData = model?.getDerivedData() as DerivedData;
775
+ const derivedFunctions = derivedData?.getMyFunctions();
776
+
777
+ it("Test for Notifications", () => {
778
+ expect(derivedFunctions?.alerts?.()).toEqual([
779
+ {
780
+ text: "Both the Positive and Negative Sources are mapped to the same pin",
781
+ type: "warning",
782
+ },
783
+ ]);
784
+ });
785
+ });
786
+
787
+ describe("Calculations Test", () => {
788
+ let mockModule = mockAssignedModule(mockState());
789
+ mockModule = {
790
+ ...mockModule,
791
+ state: {
792
+ ...mockModule.state,
793
+ main: {
794
+ feedbackSel: {
795
+ gselOpacon1: "R1 = 15R and R2 = 1R, R2/R1 = 0.07",
796
+ },
797
+ },
798
+ },
799
+ };
800
+
801
+ const model = getModel(mockModule, getDerivedData);
802
+ const derivedData = model?.getDerivedData() as DerivedData;
803
+ const derivedFunctions = derivedData?.getMyFunctions();
804
+
805
+ it("Test for nonInvGain", () => {
806
+ expect(derivedFunctions.nonInvGain?.()).toEqual("1.07");
807
+ });
808
+
809
+ it("Test for invGain", () => {
810
+ expect(derivedFunctions.invGain?.()).toEqual("1.07(Vref/Vin) - 0.07");
811
+ });
812
+ });
813
+
814
+ describe("Override Default Value Test for Direct Connection to Pins", () => {
815
+ const mockModule = mockAssignedModule(mockState());
816
+
817
+ const model = getModel(mockModule, getDerivedData);
818
+ const derivedData = model?.getDerivedData() as DerivedData;
819
+ const derivedFunctions = derivedData?.getMyFunctions();
820
+
821
+ const image =
822
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAABGBAMAAADoTebLAAAABGdBT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mp+Knhj/eJBSimllNJ/VX8D9jO384MoF/wAAAAASUVORK5CYII=";
823
+
824
+ it("Test for schematic", () => {
825
+ expect(derivedFunctions.overrideDefaultValues?.("schematic")).toEqual(image);
826
+ });
827
+ it("Test for mindiLink", () => {
828
+ expect(derivedFunctions.overrideDefaultValues?.("mindiLink")).toEqual(
829
+ "https://kits.microchip.com/redirect/4/PIC18Q71-00",
830
+ );
831
+ });
832
+ it("Test for pchOpacon2", () => {
833
+ expect(derivedFunctions.overrideDefaultValues?.("pchOpacon2")).toEqual("OPA2IN+");
834
+ });
835
+ it("Test for pssOpacon3", () => {
836
+ expect(derivedFunctions.overrideDefaultValues?.("pssOpacon3")).toEqual(
837
+ "OPA2IN0+",
838
+ );
839
+ });
840
+ it("Test for nchOpacon2", () => {
841
+ expect(derivedFunctions.overrideDefaultValues?.("nchOpacon2")).toEqual("OPA2IN-");
842
+ });
843
+ it("Test for nssOpacon1", () => {
844
+ expect(derivedFunctions.overrideDefaultValues?.("nssOpacon1")).toEqual(
845
+ "OPA2IN0-",
846
+ );
847
+ });
848
+ it("Test for resonOpacon1", () => {
849
+ expect(derivedFunctions.overrideDefaultValues?.("resonOpacon1")).toEqual(
850
+ "Disabled",
851
+ );
852
+ });
853
+ it("Test for gselOpacon1", () => {
854
+ expect(derivedFunctions.overrideDefaultValues?.("gselOpacon1")).toEqual(
855
+ "R1 = 15R and R2 = 1R, R2/R1 = 0.07",
856
+ );
857
+ });
858
+ it("Test for fmsOpacon3", () => {
859
+ expect(derivedFunctions.overrideDefaultValues?.("fmsOpacon3")).toEqual(
860
+ "No Connection",
861
+ );
862
+ });
863
+ it("Test for ugOpacon0", () => {
864
+ expect(derivedFunctions.overrideDefaultValues?.("ugOpacon0")).toEqual(
865
+ "OPAIN- pin",
866
+ );
867
+ });
868
+ });
869
+
870
+ describe("Override Default Value Test for Unity Gain Buffer", () => {
871
+ let mockModule = mockAssignedModule(mockState());
872
+ mockModule = {
873
+ ...mockModule,
874
+ state: {
875
+ ...mockModule.state,
876
+ main: {
877
+ hardware: {
878
+ customConfig: "Unity Gain Buffer",
879
+ },
880
+ },
881
+ },
882
+ };
883
+
884
+ const model = getModel(mockModule, getDerivedData);
885
+ const derivedData = model?.getDerivedData() as DerivedData;
886
+ const derivedFunctions = derivedData?.getMyFunctions();
887
+
888
+ const image =
889
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATAAAABeBAMAAABWXFVeAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAqUExURf///z09PQICAqqqqtTU1CUlJVlZWefn5xISEomJiZubm729vfb29nV1dR8w18cAAASySURBVGje7dnvSxtnAAfwb5ZLziQXSKpxlbYv4qxaQiFdqHPK4LShMjbBNkSs7sVFR9yUA+mcrmO+sFWJq4VoyzCuL651dk4txLSuP8IgnYjaTVDnHGP6v+y5xGgyY7W1xmflvkSRPLnkk+f3PQJKlChRokSJEiV0hXW2z0ZohKly5fh8brfZbM72ekVx/e/A0NiwozT80FlR0f7NocFWnM5w2OEYGwsE1tdFr9dLgBZ3je9qbjybajGtMP+ORVx7a2ui2muhBBZNYv8boQkGBabAFJgCe4NgxbTCRpUa+5/AuAZKYWxuFqUwW30jnbA85sganTCoa/x0wjDfbacThg4rTycM5/Nb6IRh6nSEThjOfkspjBusoxMGtj6LAtgfDjnD5KckD62t0f7FHGk8fJgvmkL5l40zm6Xos4aatcOGJWSzKUn03RKdMCxYg9te8JgGGNryty0B71IBQ9m2iTZEBwxneyN0wjDqorIpyRPLx+isMTDJe+1k2EjhGizuHBiPA2oBCxcvQcOjaMbtrj5wGAxJe+0kmLGO9aDWOWWfywTuCvDwZcJbPO4w57oqDh6WvNfehFWS2fcyjxm7C0bhzBnoTwiGPrBdMgyGKqQBlrTXjsO4tadkzJJKE1x45s+c4zm9oDMBn6cThrZCN0m3OzETRhABdILb0jnbp12EXjAKgJhOGLd8YozkpiMhJf6F6PqkXbzkjBhP1vQhVmM5GTy+SxOMG61N8crAX8CcHV8FyUSnea+9lsDIxUyBxg4xTbCp3lQ3AKw8YHsfVIPApoB+AsPg+KhfV/ukKz2wsp1vmVCZbccKMEa6YYvBD4OnGSjK5sEsHjys7QU3mYc58893Bl/93b5wlG7W9kPS8glf0RAI4qPtV0xH9gjT+6R9fM2Q+eip+N+iQVBtvRd71NsZ6d9+RfkeYan3/XuHRTAQr7Lf9SZu61NVx/Hl4qvDmF0Oy/YAK+c7soPcUhNulvUYwwLO416OXNICtdR/JxPznka22eNXD2UHUZQTicF+41PCIltbnizsF3Z3tueJTdtcbBc76lQ/5mHV6JokQ/ZPuXigYZn3hC2staRX1/NBge7apBCD/fN9KhgjxCfWQdc+h1LI6zmlq8KSao3hRb1JJYnc9V+DTAGwJBcPIsN+CyHWBq+uD9cy7GxeFMZI2hLH8NZjiCw7P+Xh6bGW+LZ6v2M8FBjitQKKDb4GEJhGeqyuKjebbRs11g+N9NxzlS3AKlnNXJfN5nc2YCpzYi7I/6K3cavVsb3E5I4nPi/TlJBhmP5sMVpjGT/7y0vDj2J9zCTDLLdCm7Dx8KNYU66kbkoTdjkjeymY/hN4tEFdlaiv0kjG+pY5O/M2MCOQB4GRXjcwuwHLkNisGGw6ZefnojNqhzWI1wLjLty/bqwd8YuG088kxgpd7wjpxEz3upvMY5qJnvcvtm/A1DdGTLtOF89fdA6753wYXTtEHvcaUIr7X/MYB35pkj/8ijiBc9DzlU3zH9/GA8aOH+SSK7vA1DW3QVdisF3O+g8NxtZ/Chph3H/ucamBpdxJUwCbuhGhElb2GibWg4BZ83lQCTsZBJ3hoUSJEiVKlLxp+RcOfYAxQu3JIwAAAABJRU5ErkJggg==";
890
+
891
+ it("Test for schematic", () => {
892
+ expect(derivedFunctions.overrideDefaultValues?.("schematic")).toEqual(image);
893
+ });
894
+ it("Test for mindiLink", () => {
895
+ expect(derivedFunctions.overrideDefaultValues?.("mindiLink")).toEqual(
896
+ "https://kits.microchip.com/redirect/4/PIC18Q71-01",
897
+ );
898
+ });
899
+ it("Test for pchOpacon2", () => {
900
+ expect(derivedFunctions.overrideDefaultValues?.("pchOpacon2")).toEqual("OPA2IN+");
901
+ });
902
+ it("Test for pssOpacon3", () => {
903
+ expect(derivedFunctions.overrideDefaultValues?.("pssOpacon3")).toEqual(
904
+ "OPA2IN0+",
905
+ );
906
+ });
907
+ it("Test for nchOpacon2", () => {
908
+ expect(derivedFunctions.overrideDefaultValues?.("nchOpacon2")).toEqual(
909
+ "No Connection",
910
+ );
911
+ });
912
+ it("Test for nssOpacon1", () => {
913
+ expect(derivedFunctions.overrideDefaultValues?.("nssOpacon1")).toEqual(
914
+ "OPA2IN0-",
915
+ );
916
+ });
917
+ it("Test for resonOpacon1", () => {
918
+ expect(derivedFunctions.overrideDefaultValues?.("resonOpacon1")).toEqual(
919
+ "Disabled",
920
+ );
921
+ });
922
+ it("Test for gselOpacon1", () => {
923
+ expect(derivedFunctions.overrideDefaultValues?.("gselOpacon1")).toEqual(
924
+ "R1 = 15R and R2 = 1R, R2/R1 = 0.07",
925
+ );
926
+ });
927
+ it("Test for fmsOpacon3", () => {
928
+ expect(derivedFunctions.overrideDefaultValues?.("fmsOpacon3")).toEqual(
929
+ "No Connection",
930
+ );
931
+ });
932
+ it("Test for ugOpacon0", () => {
933
+ expect(derivedFunctions.overrideDefaultValues?.("ugOpacon0")).toEqual(
934
+ "OPA Output",
935
+ );
936
+ });
937
+ });
938
+
939
+ describe("Override Default Value Test for Non-Inverting Programmable Gain Amplifier", () => {
940
+ let mockModule = mockAssignedModule(mockState());
941
+ mockModule = {
942
+ ...mockModule,
943
+ state: {
944
+ ...mockModule.state,
945
+ main: {
946
+ hardware: {
947
+ customConfig: "Non-Inverting Programmable Gain Amplifier",
948
+ },
949
+ },
950
+ },
951
+ };
952
+
953
+ const model = getModel(mockModule, getDerivedData);
954
+ const derivedData = model?.getDerivedData() as DerivedData;
955
+ const derivedFunctions = derivedData?.getMyFunctions();
956
+
957
+ const image =
958
+ "data:image/png;base64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Uy+Sd5cJm+xj0RK0cPSbTZXbE2cqTMW1caaOFUjwnhupfcb7oeCNViom1tRLM4jwHhY9Xo1cuWGvPuCAanAfgJTpkyZMmXK1Aei/wADP5Z2u2OzAwAAAABJRU5ErkJggg==";
959
+
960
+ it("Test for schematic", () => {
961
+ expect(derivedFunctions.overrideDefaultValues?.("schematic")).toEqual(image);
962
+ });
963
+ it("Test for mindiLink", () => {
964
+ expect(derivedFunctions.overrideDefaultValues?.("mindiLink")).toEqual(
965
+ "https://kits.microchip.com/redirect/4/PIC18Q71-02",
966
+ );
967
+ });
968
+ it("Test for pchOpacon2", () => {
969
+ expect(derivedFunctions.overrideDefaultValues?.("pchOpacon2")).toEqual("OPA2IN+");
970
+ });
971
+ it("Test for pssOpacon3", () => {
972
+ expect(derivedFunctions.overrideDefaultValues?.("pssOpacon3")).toEqual(
973
+ "OPA2IN0+",
974
+ );
975
+ });
976
+ it("Test for nchOpacon2", () => {
977
+ expect(derivedFunctions.overrideDefaultValues?.("nchOpacon2")).toEqual("GSEL");
978
+ });
979
+ it("Test for nssOpacon1", () => {
980
+ expect(derivedFunctions.overrideDefaultValues?.("nssOpacon1")).toEqual("Vss");
981
+ });
982
+ it("Test for resonOpacon1", () => {
983
+ expect(derivedFunctions.overrideDefaultValues?.("resonOpacon1")).toEqual(
984
+ "Enabled",
985
+ );
986
+ });
987
+ it("Test for gselOpacon1", () => {
988
+ expect(derivedFunctions.overrideDefaultValues?.("gselOpacon1")).toEqual(
989
+ "R1 = 15R and R2 = 1R, R2/R1 = 0.07",
990
+ );
991
+ });
992
+ it("Test for fmsOpacon3", () => {
993
+ expect(derivedFunctions.overrideDefaultValues?.("fmsOpacon3")).toEqual("OPA2OUT");
994
+ });
995
+ it("Test for ugOpacon0", () => {
996
+ expect(derivedFunctions.overrideDefaultValues?.("ugOpacon0")).toEqual(
997
+ "OPAIN- pin",
998
+ );
999
+ });
1000
+ });
1001
+
1002
+ describe("Override Default Value Test for Inverting Programmable Gain Amplifier", () => {
1003
+ let mockModule = mockAssignedModule(mockState());
1004
+ mockModule = {
1005
+ ...mockModule,
1006
+ state: {
1007
+ ...mockModule.state,
1008
+ main: {
1009
+ hardware: {
1010
+ customConfig: "Inverting Programmable Gain Amplifier",
1011
+ },
1012
+ },
1013
+ },
1014
+ };
1015
+
1016
+ const model = getModel(mockModule, getDerivedData);
1017
+ const derivedData = model?.getDerivedData() as DerivedData;
1018
+ const derivedFunctions = derivedData?.getMyFunctions();
1019
+
1020
+ const image =
1021
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXsAAABqBAMAAACv7eyyAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAqUExURf///woKCkhISF1dXTMzM8TExJmZmYaGhh0dHa2trXJycvT09NfX1+fn57FfLu4AAAhxSURBVHja7Zr9TxN5HsfftJ2285SIlocCJkNdXRY1KaCroiRTRRddTaZK18dL6p3U4nlJZRU8vR9aZdmqRzJezpW6XjKsu+IBPwzr3fq0m4wP7K2nmxRZblm9P+a+U54KlMoJnJ1c3ynJMO1MX31/v9/Pw7cFssoqq6yyyiqrrLLKKqsM1WcBjWs0Lv6Fz/740zXFsPhhNPezomHx247thC1k3MkT1PCxced+mBYZxcD4WNfR4jcsvox/fRSQswkkq/8/8YBqYPwDYAWYDIt/EvQiDEhGxXfFmeU4ZtTExb4vm66ixgg129GWCZ3pamkONMZk+rgyeBtCrwHwHa4kvVNbF43k5jGa0GiiFG9ubm40WjuhbRlYXKaIOyasrGH+IVG+WCwQSBqc84bAtzzGKYH+9fTI/0Hm4Tunn2I2YHeIXwYj4KdwnypGn4Q2GNR9uPWMu8mo7o9INaz7M8lI7iPrftb9eXR/x1tm/bNrOczxN3b/beMfxRO+LG5Y9wk+98i47gfrlsM0s/uva8/L37b71IdT8ZPcZ9oyHR830rhvjmzNdPy/STNHHnNN56qMxk8f981urrTGYPjJ7rtBec4a2H3AGvVnLj77OveBOw5pXvCDG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UkiGpcyFbt88fAxHvJU3eqJauM22NX96bHD7bBkBrBn/G7FUPgP1oSh3Hx03yvaAD8Ow4ZxsWno34YF3+tpwcGxs+tMTA9bKuQVVZZZZXVW9J/AIvebuUe8PLBAAAAAElFTkSuQmCC";
1022
+
1023
+ it("Test for schematic", () => {
1024
+ expect(derivedFunctions.overrideDefaultValues?.("schematic")).toEqual(image);
1025
+ });
1026
+ it("Test for mindiLink", () => {
1027
+ expect(derivedFunctions.overrideDefaultValues?.("mindiLink")).toEqual(
1028
+ "https://kits.microchip.com/redirect/4/PIC18Q71-03",
1029
+ );
1030
+ });
1031
+ it("Test for pchOpacon2", () => {
1032
+ expect(derivedFunctions.overrideDefaultValues?.("pchOpacon2")).toEqual("Vdd/2");
1033
+ });
1034
+ it("Test for pssOpacon3", () => {
1035
+ expect(derivedFunctions.overrideDefaultValues?.("pssOpacon3")).toEqual(
1036
+ "OPA2IN0+",
1037
+ );
1038
+ });
1039
+ it("Test for nchOpacon2", () => {
1040
+ expect(derivedFunctions.overrideDefaultValues?.("nchOpacon2")).toEqual("GSEL");
1041
+ });
1042
+ it("Test for nssOpacon1", () => {
1043
+ expect(derivedFunctions.overrideDefaultValues?.("nssOpacon1")).toEqual(
1044
+ "OPA2IN0-",
1045
+ );
1046
+ });
1047
+ it("Test for resonOpacon1", () => {
1048
+ expect(derivedFunctions.overrideDefaultValues?.("resonOpacon1")).toEqual(
1049
+ "Enabled",
1050
+ );
1051
+ });
1052
+ it("Test for gselOpacon1", () => {
1053
+ expect(derivedFunctions.overrideDefaultValues?.("gselOpacon1")).toEqual(
1054
+ "R1 = 15R and R2 = 1R, R2/R1 = 0.07",
1055
+ );
1056
+ });
1057
+ it("Test for fmsOpacon3", () => {
1058
+ expect(derivedFunctions.overrideDefaultValues?.("fmsOpacon3")).toEqual("OPA2OUT");
1059
+ });
1060
+ it("Test for ugOpacon0", () => {
1061
+ expect(derivedFunctions.overrideDefaultValues?.("ugOpacon0")).toEqual(
1062
+ "OPAIN- pin",
1063
+ );
1064
+ });
1065
+ });
1066
+
1067
+ describe("Override Default Value Test for Custom Configuration", () => {
1068
+ let mockModule = mockAssignedModule(mockState());
1069
+ mockModule = {
1070
+ ...mockModule,
1071
+ state: {
1072
+ ...mockModule.state,
1073
+ main: {
1074
+ hardware: {
1075
+ customConfig: "Custom Configuration",
1076
+ },
1077
+ },
1078
+ },
1079
+ };
1080
+
1081
+ const model = getModel(mockModule, getDerivedData);
1082
+ const derivedData = model?.getDerivedData() as DerivedData;
1083
+ const derivedFunctions = derivedData?.getMyFunctions();
1084
+
1085
+ const image =
1086
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAABGBAMAAADoTebLAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAtUExURf///ysrKwQEBPT09BUVFZycnENDQ76+vuTk5NHR0XR0dIeHh66urlRUVGNjY5G2d0oAAAXuSURBVGje7ZntT1NXHMe/cLnc3j6QtraOTTBQ5KECy5VqAhINVVAUScrDiItvAGHZbLqUplNjlqVW4tBt5Kaok0WTDg1q4ouLLpq9K4wtbNEEdZLF2QTROJcZ/oadc2mlpMC0Laxb+k16e+7zJ+f8ns65QEoppZRSSv97nUoynqEXycXzrf5mUvEMs7W2pOJBdb4zqXjQXyQmFQ/OvetJKh70NAgr+Q7mTXnQWhfXC90BaKTIA7Ys//zOYZMRPdE3ZYhL8zA33oqHx1WPzEgeLk897yPq0r5mmzv6pnTn0jxQzPwWD08u5bkggvmZh+KIsMVceUIEL1RN0H6QoNK6uR/AkAsGLniYgSMC+IkQzwFxUR7wnZfi4PEFMqVtjXvh7ugUnt3bc7zoq6tmuCt1XSS2uaizuDoMnjOORpTrytS6rmxFR5dN5lEHLi3OA7Uh9kDtUtVnSiNCb2AdZqrq8TGXp/E/wqxmkishtilfEdgkzcLnKcdzdRlTl9XOm2UeJXp0YRnoxoq7wQfyQ1XWQMw8yM2UHHd++rMEPoE5m0t5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gFZXtTUhrKRz0HaU8rLipdoE2YNR6MAGlKldCDGYWXN5W/dsyj6LkFp+v0zkpCj4n9mzk9I4Cr0dFefaTMxOURy2ePhLWp3QzBcvjuYATTykv2w/tbLZmgL8n88BuVJjBC1CUAZcpT8VNLszTUgxeHi/m5Yuo8bomN0YbEDcPsZ/pdRgmk2VSvo3vhENoJq502ckWUh6vc1tJiMc2JYz1yfZcJSzuX+c2CvHzsLJ/7dH4e0vs2DyN49Z9NDyaNtgoj7JoXXGY56S1bll/7491qhxZ1xKXIE8ZpG2PRT5ySj5aJdIdC4lGFoa05FPkjLA0z9akWfMdXnxK8a/ycIbk+WYwTMvTJPqmMhznUmbCeeJc6k04T5xL4YnW0Mp+Knhj/eJBSimllNJ/VX8D9jO384MoF/wAAAAASUVORK5CYII=";
1087
+
1088
+ it("Test for schematic", () => {
1089
+ expect(derivedFunctions.overrideDefaultValues?.("schematic")).toEqual(image);
1090
+ });
1091
+ it("Test for mindiLink", () => {
1092
+ expect(derivedFunctions.overrideDefaultValues?.("mindiLink")).toEqual(
1093
+ "https://kits.microchip.com/redirect/4/PIC18Q71-00",
1094
+ );
1095
+ });
1096
+ it("Test for pchOpacon2", () => {
1097
+ expect(derivedFunctions.overrideDefaultValues?.("pchOpacon2")).toEqual("Vss");
1098
+ });
1099
+ it("Test for pssOpacon3", () => {
1100
+ expect(derivedFunctions.overrideDefaultValues?.("pssOpacon3")).toEqual(
1101
+ "OPA2IN0+",
1102
+ );
1103
+ });
1104
+ it("Test for nchOpacon2", () => {
1105
+ expect(derivedFunctions.overrideDefaultValues?.("nchOpacon2")).toEqual(
1106
+ "No Connection",
1107
+ );
1108
+ });
1109
+ it("Test for nssOpacon1", () => {
1110
+ expect(derivedFunctions.overrideDefaultValues?.("nssOpacon1")).toEqual(
1111
+ "OPA2IN0-",
1112
+ );
1113
+ });
1114
+ it("Test for resonOpacon1", () => {
1115
+ expect(derivedFunctions.overrideDefaultValues?.("resonOpacon1")).toEqual(
1116
+ "Disabled",
1117
+ );
1118
+ });
1119
+ it("Test for gselOpacon1", () => {
1120
+ expect(derivedFunctions.overrideDefaultValues?.("gselOpacon1")).toEqual(
1121
+ "R1 = 15R and R2 = 1R, R2/R1 = 0.07",
1122
+ );
1123
+ });
1124
+ it("Test for fmsOpacon3", () => {
1125
+ expect(derivedFunctions.overrideDefaultValues?.("fmsOpacon3")).toEqual(
1126
+ "No Connection",
1127
+ );
1128
+ });
1129
+ it("Test for ugOpacon0", () => {
1130
+ expect(derivedFunctions.overrideDefaultValues?.("ugOpacon0")).toEqual(
1131
+ "OPAIN- pin",
1132
+ );
1133
+ });
1134
+ });
1135
+
1136
+ describe("Notification Test for Direct Connection to Pins 1", () => {
1137
+ let mockModule = mockAssignedModule(mockState());
1138
+ mockModule = {
1139
+ ...mockModule,
1140
+ state: {
1141
+ ...mockModule.state,
1142
+ main: {
1143
+ channelSel: {
1144
+ pchOpacon2: "GSEL",
1145
+ pssOpacon3: "OPA2IN1+",
1146
+ nchOpacon2: "GSEL",
1147
+ nssOpacon1: "OPA2IN1-",
1148
+ },
1149
+ },
1150
+ },
1151
+ };
1152
+
1153
+ const model = getModel(mockModule, getDerivedData);
1154
+ const derivedData = model?.getDerivedData() as DerivedData;
1155
+ const derivedFunctions = derivedData?.getMyFunctions();
1156
+
1157
+ it("Test for Invalid Notifications", () => {
1158
+ expect(derivedFunctions?.alerts?.()).toEqual([
1159
+ {
1160
+ text: "Invalid selection for Positive Channel in this configuration",
1161
+ type: "warning",
1162
+ },
1163
+ {
1164
+ text: "Invalid selection for Negative Channel in this configuration",
1165
+ type: "warning",
1166
+ },
1167
+ ]);
1168
+ });
1169
+ });
1170
+
1171
+ describe("Notification Test for Direct Connection to Pins 2", () => {
1172
+ let mockModule = mockAssignedModule(mockState());
1173
+ mockModule = {
1174
+ ...mockModule,
1175
+ state: {
1176
+ ...mockModule.state,
1177
+ main: {
1178
+ channelSel: {
1179
+ pssOpacon3: "OPA2IN1+",
1180
+ nssOpacon1: "OPA2IN1-",
1181
+ },
1182
+ },
1183
+ },
1184
+ };
1185
+
1186
+ const model = getModel(mockModule, getDerivedData);
1187
+ const derivedData = model?.getDerivedData() as DerivedData;
1188
+ const derivedFunctions = derivedData?.getMyFunctions();
1189
+
1190
+ it("Test for Invalid Notifications", () => {
1191
+ expect(derivedFunctions?.alerts?.()).toEqual([
1192
+ {
1193
+ text: "Both the Positive and Negative Sources are mapped to the same pin",
1194
+ type: "warning",
1195
+ },
1196
+ ]);
1197
+ });
1198
+ });
1199
+
1200
+ describe("Notification Test for Direct Connection to Pins 3", () => {
1201
+ let mockModule = mockAssignedModule(mockState());
1202
+ mockModule = {
1203
+ ...mockModule,
1204
+ state: {
1205
+ ...mockModule.state,
1206
+ main: {
1207
+ channelSel: {
1208
+ pssOpacon3: "OPA2IN1+",
1209
+ nssOpacon1: "OPA2IN0-",
1210
+ },
1211
+ },
1212
+ },
1213
+ };
1214
+
1215
+ const model = getModel(mockModule, getDerivedData);
1216
+ const derivedData = model?.getDerivedData() as DerivedData;
1217
+ const derivedFunctions = derivedData?.getMyFunctions();
1218
+
1219
+ it("Test for Invalid Notifications", () => {
1220
+ expect(derivedFunctions?.alerts?.()).toEqual([]);
1221
+ });
1222
+ });
1223
+
1224
+ describe("Notification Test for Unity Gain Buffer 1", () => {
1225
+ let mockModule = mockAssignedModule(mockState());
1226
+ mockModule = {
1227
+ ...mockModule,
1228
+ state: {
1229
+ ...mockModule.state,
1230
+ main: {
1231
+ hardware: {
1232
+ customConfig: "Unity Gain Buffer",
1233
+ },
1234
+ channelSel: {
1235
+ pchOpacon2: "GSEL",
1236
+ },
1237
+ },
1238
+ },
1239
+ };
1240
+
1241
+ const model = getModel(mockModule, getDerivedData);
1242
+ const derivedData = model?.getDerivedData() as DerivedData;
1243
+ const derivedFunctions = derivedData?.getMyFunctions();
1244
+
1245
+ it("Test for Invalid Notifications", () => {
1246
+ expect(derivedFunctions?.alerts?.()).toEqual([
1247
+ {
1248
+ text: "Invalid selection for Positive Channel in this configuration",
1249
+ type: "warning",
1250
+ },
1251
+ ]);
1252
+ });
1253
+ });
1254
+
1255
+ describe("Notification Test for Unity Gain Buffer 2", () => {
1256
+ let mockModule = mockAssignedModule(mockState());
1257
+ mockModule = {
1258
+ ...mockModule,
1259
+ state: {
1260
+ ...mockModule.state,
1261
+ main: {
1262
+ hardware: {
1263
+ customConfig: "Unity Gain Buffer",
1264
+ },
1265
+ channelSel: {
1266
+ pchOpacon2: "OPA2IN+",
1267
+ },
1268
+ },
1269
+ },
1270
+ };
1271
+
1272
+ const model = getModel(mockModule, getDerivedData);
1273
+ const derivedData = model?.getDerivedData() as DerivedData;
1274
+ const derivedFunctions = derivedData?.getMyFunctions();
1275
+
1276
+ it("Test for Invalid Notifications", () => {
1277
+ expect(derivedFunctions?.alerts?.()).toEqual([]);
1278
+ });
1279
+ });
1280
+
1281
+ describe("Notification Test for Non-Inverting Programmable Gain Amplifier 1", () => {
1282
+ let mockModule = mockAssignedModule(mockState());
1283
+ mockModule = {
1284
+ ...mockModule,
1285
+ state: {
1286
+ ...mockModule.state,
1287
+ main: {
1288
+ hardware: {
1289
+ customConfig: "Non-Inverting Programmable Gain Amplifier",
1290
+ },
1291
+ channelSel: {
1292
+ pchOpacon2: "GSEL",
1293
+ nchOpacon2: "OPA2IN-",
1294
+ nssOpacon1: "OPA2IN0-",
1295
+ },
1296
+ feedbackSel: {
1297
+ fmsOpacon3: "No Connection",
1298
+ },
1299
+ },
1300
+ },
1301
+ };
1302
+
1303
+ const model = getModel(mockModule, getDerivedData);
1304
+ const derivedData = model?.getDerivedData() as DerivedData;
1305
+ const derivedFunctions = derivedData?.getMyFunctions();
1306
+
1307
+ it("Test for Invalid Notifications", () => {
1308
+ expect(derivedFunctions?.alerts?.()).toEqual([
1309
+ {
1310
+ text: "Invalid selection for Positive Channel in this configuration",
1311
+ type: "warning",
1312
+ },
1313
+ {
1314
+ text: "Invalid selection for Negative Channel in this configuration",
1315
+ type: "warning",
1316
+ },
1317
+ {
1318
+ text: "Invalid selection for Negative Source in this configuration",
1319
+ type: "warning",
1320
+ },
1321
+ {
1322
+ text:
1323
+ "Invalid selection for Feedback Mode Selection in this configuration",
1324
+ type: "warning",
1325
+ },
1326
+ ]);
1327
+ });
1328
+ });
1329
+
1330
+ describe("Notification Test for Non-Inverting Programmable Gain Amplifier 2", () => {
1331
+ let mockModule = mockAssignedModule(mockState());
1332
+ mockModule = {
1333
+ ...mockModule,
1334
+ state: {
1335
+ ...mockModule.state,
1336
+ main: {
1337
+ hardware: {
1338
+ customConfig: "Non-Inverting Programmable Gain Amplifier",
1339
+ },
1340
+ channelSel: {
1341
+ pchOpacon2: "OPA2IN+",
1342
+ nchOpacon2: "GSEL",
1343
+ nssOpacon1: "Vss",
1344
+ },
1345
+ feedbackSel: {
1346
+ fmsOpacon3: "OPA2OUT",
1347
+ },
1348
+ },
1349
+ },
1350
+ };
1351
+
1352
+ const model = getModel(mockModule, getDerivedData);
1353
+ const derivedData = model?.getDerivedData() as DerivedData;
1354
+ const derivedFunctions = derivedData?.getMyFunctions();
1355
+
1356
+ it("Test for Invalid Notifications", () => {
1357
+ expect(derivedFunctions?.alerts?.()).toEqual([]);
1358
+ });
1359
+ });
1360
+
1361
+ describe("Notification Test for Inverting Programmable Gain Amplifier 1", () => {
1362
+ let mockModule = mockAssignedModule(mockState());
1363
+ mockModule = {
1364
+ ...mockModule,
1365
+ state: {
1366
+ ...mockModule.state,
1367
+ main: {
1368
+ hardware: {
1369
+ customConfig: "Inverting Programmable Gain Amplifier",
1370
+ },
1371
+ channelSel: {
1372
+ pchOpacon2: "GSEL",
1373
+ nchOpacon2: "OPA2IN-",
1374
+ },
1375
+ feedbackSel: {
1376
+ fmsOpacon3: "No Connection",
1377
+ },
1378
+ },
1379
+ },
1380
+ };
1381
+
1382
+ const model = getModel(mockModule, getDerivedData);
1383
+ const derivedData = model?.getDerivedData() as DerivedData;
1384
+ const derivedFunctions = derivedData?.getMyFunctions();
1385
+
1386
+ it("Test for Invalid Notifications", () => {
1387
+ expect(derivedFunctions?.alerts?.()).toEqual([
1388
+ {
1389
+ text: "Invalid selection for Positive Channel in this configuration",
1390
+ type: "warning",
1391
+ },
1392
+ {
1393
+ text: "Invalid selection for Negative Channel in this configuration",
1394
+ type: "warning",
1395
+ },
1396
+ {
1397
+ text:
1398
+ "Invalid selection for Feedback Mode Selection in this configuration",
1399
+ type: "warning",
1400
+ },
1401
+ ]);
1402
+ });
1403
+ });
1404
+
1405
+ describe("Notification Test for Inverting Programmable Gain Amplifier 2", () => {
1406
+ let mockModule = mockAssignedModule(mockState());
1407
+ mockModule = {
1408
+ ...mockModule,
1409
+ state: {
1410
+ ...mockModule.state,
1411
+ main: {
1412
+ hardware: {
1413
+ customConfig: "Inverting Programmable Gain Amplifier",
1414
+ },
1415
+ channelSel: {
1416
+ pchOpacon2: "Vss",
1417
+ nchOpacon2: "OPA2IN-",
1418
+ },
1419
+ feedbackSel: {
1420
+ fmsOpacon3: "No Connection",
1421
+ },
1422
+ },
1423
+ },
1424
+ };
1425
+
1426
+ const model = getModel(mockModule, getDerivedData);
1427
+ const derivedData = model?.getDerivedData() as DerivedData;
1428
+ const derivedFunctions = derivedData?.getMyFunctions();
1429
+
1430
+ it("Test for Invalid Notifications", () => {
1431
+ expect(derivedFunctions?.alerts?.()).toEqual([
1432
+ {
1433
+ text: "Invalid selection for Positive Channel in this configuration",
1434
+ type: "warning",
1435
+ },
1436
+ {
1437
+ text: "Invalid selection for Negative Channel in this configuration",
1438
+ type: "warning",
1439
+ },
1440
+ {
1441
+ text:
1442
+ "Invalid selection for Feedback Mode Selection in this configuration",
1443
+ type: "warning",
1444
+ },
1445
+ ]);
1446
+ });
1447
+ });
1448
+
1449
+ describe("Notification Test for Inverting Programmable Gain Amplifier 3", () => {
1450
+ let mockModule = mockAssignedModule(mockState());
1451
+ mockModule = {
1452
+ ...mockModule,
1453
+ state: {
1454
+ ...mockModule.state,
1455
+ main: {
1456
+ hardware: {
1457
+ customConfig: "Inverting Programmable Gain Amplifier",
1458
+ },
1459
+ channelSel: {
1460
+ pchOpacon2: "OPA2IN+",
1461
+ nchOpacon2: "GSEL",
1462
+ },
1463
+ feedbackSel: {
1464
+ fmsOpacon3: "OPA2OUT",
1465
+ },
1466
+ },
1467
+ },
1468
+ };
1469
+
1470
+ const model = getModel(mockModule, getDerivedData);
1471
+ const derivedData = model?.getDerivedData() as DerivedData;
1472
+ const derivedFunctions = derivedData?.getMyFunctions();
1473
+
1474
+ it("Test for Invalid Notifications", () => {
1475
+ expect(derivedFunctions?.alerts?.()).toEqual([]);
1476
+ });
1477
+ });
1478
+
1479
+ describe("Import Interface Tests", () => {
1480
+ const mockModule = mockAssignedModule(mockState());
1481
+ const model = getModel(mockModule, getDerivedData);
1482
+ const derivedData = model?.getDerivedData() as DerivedData;
1483
+ const derivedFunctions = derivedData?.getMyFunctions();
1484
+
1485
+ const initializer_system_results = {
1486
+ initializer: {
1487
+ name: "OPA2_Initialize",
1488
+ header: {
1489
+ name: "opa2.h",
1490
+ path: "opa/",
1491
+ },
1492
+ },
1493
+ };
1494
+
1495
+ it("Test for system interface", () => {
1496
+ expect(derivedFunctions?.initializer_system_results?.()).toEqual(
1497
+ initializer_system_results,
1498
+ );
1499
+ });
1500
+ });
1501
+
1502
+ describe("isVibleTest Tests", () => {
1503
+ let mockModule = mockAssignedModule(mockState());
1504
+ mockModule = {
1505
+ ...mockModule,
1506
+ state: {
1507
+ ...mockModule.state,
1508
+ main: {
1509
+ overrideSel: {
1510
+ hwclOpahwc: "Trough detect configuration with unity gain feedback",
1511
+ },
1512
+ },
1513
+ },
1514
+ };
1515
+
1516
+ const model = getModel(mockModule, getDerivedData);
1517
+ const derivedData = model?.getDerivedData() as DerivedData;
1518
+ const derivedFunctions = derivedData?.getMyFunctions();
1519
+
1520
+ it("Test for isVisible", () => {
1521
+ expect(derivedFunctions.isVisible?.("ptresOpacon4")).toEqual(true);
1522
+ });
1523
+ });
1524
+
1525
+ describe("API Tests", () => {
1526
+ let mockModule = mockAssignedModule(mockState());
1527
+ mockModule = {
1528
+ ...mockModule,
1529
+ state: {
1530
+ ...mockModule.state,
1531
+ main: {
1532
+ hardware: {
1533
+ customConfig: "Non-Inverting Programmable Gain Amplifier",
1534
+ },
1535
+ channelSel: {
1536
+ nchOpacon2: "GSEL",
1537
+ },
1538
+ overrideSel: {
1539
+ hwchOpahwc: "Peak detect configuration with user defined feedback",
1540
+ hwclOpahwc: "Trough detect configuration with unity gain feedback",
1541
+ },
1542
+ },
1543
+ },
1544
+ };
1545
+
1546
+ const model = getModel(mockModule, getDerivedData);
1547
+ const derivedData = model?.getDerivedData() as DerivedData;
1548
+ const derivedFunctions = derivedData?.getMyFunctions();
1549
+
1550
+ it("Test for moduleName", () => {
1551
+ expect(derivedFunctions.moduleName?.()).toEqual("OPA2");
1552
+ });
1553
+
1554
+ const pin_args = { queryAdapterMap: { allpins: "^OPA[0-9]$" } };
1555
+
1556
+ it("Test for pin_standard_args", () => {
1557
+ expect(derivedFunctions.pin_standard_args?.()).toEqual(pin_args);
1558
+ });
1559
+
1560
+ it("Test for doNotShow", () => {
1561
+ expect(derivedFunctions.doNotShow?.()).toEqual(false);
1562
+ });
1563
+
1564
+ it("Test for isEnabled", () => {
1565
+ expect(derivedFunctions.isEnabled?.("nssOpacon1")).toEqual(true);
1566
+ });
1567
+
1568
+ it("Test for isVisible", () => {
1569
+ expect(derivedFunctions.isVisible?.("ptresOpacon4")).toEqual(true);
1570
+ });
1571
+ });
1572
+
1573
+ describe("API Test with Undefined Values", () => {
1574
+ let mockModule = mockAssignedModule(mockState());
1575
+ mockModule = {
1576
+ ...mockModule,
1577
+ imports: {
1578
+ ...mockModule.imports,
1579
+ scf_pic8_opamp_v2: {
1580
+ interfaceId: {
1581
+ name: "scf-pic8-opamp-v2",
1582
+ version: "1.0.0",
1583
+ },
1584
+ handle: undefined,
1585
+ payload: undefined,
1586
+ },
1587
+ },
1588
+ };
1589
+
1590
+ const model = getModel(mockModule, getDerivedData);
1591
+ const derivedData = model?.getDerivedData() as DerivedData;
1592
+ const derivedFunctions = derivedData?.getMyFunctions();
1593
+
1594
+ it("Test for undefined Hardware", () => {
1595
+ expect(derivedFunctions.moduleName?.()).toEqual("OPA");
1596
+ expect(derivedFunctions.alerts?.()).toBeDefined();
1597
+ expect(
1598
+ derivedFunctions?.["opa-output-parameters_payload"]?.()?.moduleName,
1599
+ ).toEqual("OPA");
1600
+ });
1601
+ });