-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel-based-diagnosis.clp
1049 lines (795 loc) · 20.8 KB
/
model-based-diagnosis.clp
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
;;;;; THE PROGRAM RUNS IN CLIPS 6.3 ;;;;;;
;DEFINE ALL CLASSES
(defclass systemEntity
(is-a USER)
(role abstract)
(slot suspect
(type SYMBOL)
(allowed-values yes no)
(default no)
;(cardinality 0 1)
(create-accessor read-write))
(slot out
(type INTEGER)
(range 0 31)
;(cardinality 0 1)
(create-accessor read-write)))
(defclass command
(is-a systemEntity)
(role concrete)
(pattern-match reactive))
(defclass component
(is-a systemEntity)
(role abstract))
(defclass sensor
(is-a component)
(role concrete)
(pattern-match reactive)
(slot theoretical
(type INTEGER)
(range 0 31)
;(cardinality 0 1)
(create-accessor read-write))
(slot out
(type INTEGER)
(range 0 31)
;(cardinality 0 0)
(create-accessor read-write))
(slot reading
(type INTEGER)
(range 0 31)
;(cardinality 0 1)
(create-accessor read-write))
(slot input
(type INSTANCE)
(allowed-classes internal-component)
;(cardinality 0 1)
(create-accessor read-write)))
(defclass internal-component
(is-a component)
(role concrete)
(pattern-match reactive)
(slot short-out
(type INTEGER)
(range 0 0)
(default 0)
;(cardinality 0 1)
(create-accessor read-write))
(multislot output
(type INSTANCE)
(allowed-classes component)
(create-accessor read-write))
(slot msb-out
(type INTEGER)
(range 0 15)
;(cardinality 0 1)
(create-accessor read-write))
(slot input2
(type INSTANCE)
(allowed-classes systemEntity)
;(cardinality 0 1)
(create-accessor read-write))
(slot input1
(type INSTANCE)
(allowed-classes systemEntity)
;(cardinality 0 1)
(create-accessor read-write)))
(defclass adder
(is-a internal-component)
(pattern-match reactive)
(role concrete))
;message-handler function for calculate the sum of 2 numbers,then module them
(defmessage-handler adder calculate-add primary (?inp1 ?inp2 ?flag)
(if (= ?flag 1)
then
(return (mod (+ ?inp1 ?inp2) 32))
else
(return (mod (+ ?inp1 ?inp2) 16))
)
)
(defclass multiplier
(is-a internal-component)
(pattern-match reactive)
(role concrete))
;message-handler function for calculate the multiplication of 2 numbers
(defmessage-handler multiplier calculate-multiply primary (?inp1 ?inp2 ?flag)
(if (= ?flag 1)
then
(return (mod (* ?inp1 ?inp2) 32));for regular output
else
(return (mod (* ?inp1 ?inp2) 16)) ;for msb output
)
)
(defclass circuit
(is-a systemEntity)
(role concrete)
(multislot outputs
(type INSTANCE)
(allowed-classes sensor)
(create-accessor read-write))
(multislot has-components
(type INSTANCE)
(allowed-classes component)
(create-accessor read-write))
(multislot inputs
(type INSTANCE)
(allowed-classes command)
(create-accessor read-write)))
(defclass data
(is-a USER)
(role abstract)
(slot clock
(type INTEGER)
(range 1 ?VARIABLE)
;(cardinality 0 1)
(create-accessor read-write))
(slot object
(type INSTANCE)
(allowed-classes systemEntity)
;(cardinality 0 1)
(create-accessor read-write))
(slot value
(type INTEGER)
;(cardinality 0 1)
(create-accessor read-write)))
(defclass command_data
(is-a data)
(role concrete)
(pattern-match reactive)
(slot object
(type INSTANCE)
(allowed-classes command)
;(cardinality 0 1)
(create-accessor read-write)))
(defclass reading_data
(is-a data)
(role concrete)
(pattern-match reactive)
(slot object
(type INSTANCE)
(allowed-classes sensor)
;(cardinality 0 1)
(create-accessor read-write)))
;DEFINE ALL INSTANCES
(definstances facts
([a1] of adder
(input1 [input_1])
(input2 [input_1])
(output
[m1]
[p1])
(short-out 0)
(suspect no))
([a2] of adder
(input1 [p1])
(input2 [p2])
(output [out1])
(short-out 0)
(suspect no))
([circuit_1] of circuit
(has-components
[m1]
[m2]
[m3]
[out1]
[a1]
[a2]
[p1]
[p2])
(inputs
[input_1]
[input_2]
[input_3]
[input_4])
(outputs [out1])
(suspect no))
([command_10_inp1] of command_data
(clock 10)
(object [input_1])
(value 6))
([command_10_inp2] of command_data
(clock 10)
(object [input_2])
(value 4))
([command_10_inp3] of command_data
(clock 10)
(object [input_3])
(value 25))
([command_10_inp4] of command_data
(clock 10)
(object [input_4])
(value 12))
([command_1_inp1] of command_data
(clock 1)
(object [input_1])
(value 21))
([command_1_inp2] of command_data
(clock 1)
(object [input_2])
(value 28))
([command_1_inp3] of command_data
(clock 1)
(object [input_3])
(value 10))
([command_1_inp4] of command_data
(clock 1)
(object [input_4])
(value 25))
([command_2_inp1] of command_data
(clock 2)
(object [input_1])
(value 7))
([command_2_inp2] of command_data
(clock 2)
(object [input_2])
(value 25))
([command_2_inp3] of command_data
(clock 2)
(object [input_3])
(value 13))
([command_2_inp4] of command_data
(clock 2)
(object [input_4])
(value 15))
([command_3_inp1] of command_data
(clock 3)
(object [input_1])
(value 11))
([command_3_inp2] of command_data
(clock 3)
(object [input_2])
(value 17))
([command_3_inp3] of command_data
(clock 3)
(object [input_3])
(value 24))
([command_3_inp4] of command_data
(clock 3)
(object [input_4])
(value 31))
([command_4_inp1] of command_data
(clock 4)
(object [input_1])
(value 18))
([command_4_inp2] of command_data
(clock 4)
(object [input_2])
(value 11))
([command_4_inp3] of command_data
(clock 4)
(object [input_3])
(value 28))
([command_4_inp4] of command_data
(clock 4)
(object [input_4])
(value 21))
([command_5_inp1] of command_data
(clock 5)
(object [input_1])
(value 25))
([command_5_inp2] of command_data
(clock 5)
(object [input_2])
(value 24))
([command_5_inp3] of command_data
(clock 5)
(object [input_3])
(value 30))
([command_5_inp4] of command_data
(clock 5)
(object [input_4])
(value 10))
([command_6_inp1] of command_data
(clock 6)
(object [input_1])
(value 12))
([command_6_inp2] of command_data
(clock 6)
(object [input_2])
(value 19))
([command_6_inp3] of command_data
(clock 6)
(object [input_3])
(value 11))
([command_6_inp4] of command_data
(clock 6)
(object [input_4])
(value 19))
([command_7_inp1] of command_data
(clock 7)
(object [input_1])
(value 1))
([command_7_inp2] of command_data
(clock 7)
(object [input_2])
(value 31))
([command_7_inp3] of command_data
(clock 7)
(object [input_3])
(value 7))
([command_7_inp4] of command_data
(clock 7)
(object [input_4])
(value 22))
([command_8_inp1] of command_data
(clock 8)
(object [input_1])
(value 0))
([command_8_inp2] of command_data
(clock 8)
(object [input_2])
(value 31))
([command_8_inp3] of command_data
(clock 8)
(object [input_3])
(value 3))
([command_8_inp4] of command_data
(clock 8)
(object [input_4])
(value 23))
([command_9_inp1] of command_data
(clock 9)
(object [input_1])
(value 31))
([command_9_inp2] of command_data
(clock 9)
(object [input_2])
(value 1))
([command_9_inp3] of command_data
(clock 9)
(object [input_3])
(value 6))
([command_9_inp4] of command_data
(clock 9)
(object [input_4])
(value 8))
([input_1] of command
(suspect no))
([input_2] of command
(suspect no))
([input_3] of command
(suspect no))
([input_4] of command
(suspect no))
([m1] of sensor
(input [a1])
(suspect no))
([m2] of sensor
(input [p1])
(suspect no))
([m3] of sensor
(input [p2])
(suspect no))
([out1] of sensor
(input [a2])
(suspect no))
([p1] of multiplier
(input1 [input_2])
(input2 [a1])
(output
[m2]
[a2])
(short-out 0)
(suspect no))
([p2] of multiplier
(input1 [input_3])
(input2 [input_4])
(output
[m3]
[a2])
(short-out 0)
(suspect no))
([reading_10_m1] of reading_data
(clock 10)
(object [m1])
(value 12))
([reading_10_m2] of reading_data
(clock 10)
(object [m2])
(value 31))
([reading_10_m3] of reading_data
(clock 10)
(object [m3])
(value 12))
([reading_10_out] of reading_data
(clock 10)
(object [out1])
(value 28))
([reading_1_m1] of reading_data
(clock 1)
(object [m1])
(value 10))
([reading_1_m2] of reading_data
(clock 1)
(object [m2])
(value 24))
([reading_1_m3] of reading_data
(clock 1)
(object [m3])
(value 26))
([reading_1_out] of reading_data
(clock 1)
(object [out1])
(value 18))
([reading_2_m1] of reading_data
(clock 2)
(object [m1])
(value 0))
([reading_2_m2] of reading_data
(clock 2)
(object [m2])
(value 0))
([reading_2_m3] of reading_data
(clock 2)
(object [m3])
(value 3))
([reading_2_out] of reading_data
(clock 2)
(object [out1])
(value 3))
([reading_3_m1] of reading_data
(clock 3)
(object [m1])
(value 22))
([reading_3_m2] of reading_data
(clock 3)
(object [m2])
(value 6))
([reading_3_m3] of reading_data
(clock 3)
(object [m3])
(value 8))
([reading_3_out] of reading_data
(clock 3)
(object [out1])
(value 14))
([reading_4_m1] of reading_data
(clock 4)
(object [m1])
(value 4))
([reading_4_m2] of reading_data
(clock 4)
(object [m2])
(value 12))
([reading_4_m3] of reading_data
(clock 4)
(object [m3])
(value 12))
([reading_4_out] of reading_data
(clock 4)
(object [out1])
(value 0))
([reading_5_m1] of reading_data
(clock 5)
(object [m1])
(value 18))
([reading_5_m2] of reading_data
(clock 5)
(object [m2])
(value 16))
([reading_5_m3] of reading_data
(clock 5)
(object [m3])
(value 12))
([reading_5_out] of reading_data
(clock 5)
(object [out1])
(value 12))
([reading_6_m1] of reading_data
(clock 6)
(object [m1])
(value 8))
([reading_6_m2] of reading_data
(clock 6)
(object [m2])
(value 24))
([reading_6_m3] of reading_data
(clock 6)
(object [m3])
(value 17))
([reading_6_out] of reading_data
(clock 6)
(object [out1])
(value 9))
([reading_7_m1] of reading_data
(clock 7)
(object [m1])
(value 2))
([reading_7_m2] of reading_data
(clock 7)
(object [m2])
(value 0))
([reading_7_m3] of reading_data
(clock 7)
(object [m3])
(value 26))
([reading_7_out] of reading_data
(clock 7)
(object [out1])
(value 26))
([reading_8_m1] of reading_data
(clock 8)
(object [m1])
(value 0))
([reading_8_m2] of reading_data
(clock 8)
(object [m2])
(value 0))
([reading_8_m3] of reading_data
(clock 8)
(object [m3])
(value 0))
([reading_8_out] of reading_data
(clock 8)
(object [out1])
(value 0))
([reading_9_m1] of reading_data
(clock 9)
(object [m1])
(value 30))
([reading_9_m2] of reading_data
(clock 9)
(object [m2])
(value 30))
([reading_9_m3] of reading_data
(clock 9)
(object [m3])
(value 0))
([reading_9_out] of reading_data
(clock 9)
(object [out1])
(value 30))
)
;RULES BEGINNING
(defrule begin
?x <- (initial-fact)
=>
(retract ?x)
(set-strategy mea)
(assert (print clock-time))
(assert (time 1)) ;fact that defines the current cycle after every execution
)
(defrule print-clock-time
?x <- (print clock-time)
(time ?t)
=>
(retract ?x)
(printout t "------ CLOCK: " ?t " ------" crlf)
(assert (goal bind-values))
)
;rule for binding the values from the data to the sensors and inputs
(defrule bind-values
?x <- (goal bind-values)
(time ?t)
(object (is-a command_data) (clock ?t) (value ?v) (object ?input))
(object (is-a reading_data) (clock ?t) (value ?v1) (object ?sensor))
=>
(modify-instance ?input (out ?v))
(modify-instance ?sensor (reading ?v1))
(printout t "Binding values..." crlf)
)
;rule changer after successfully binding the values to sensors and inputs
(defrule change-goal-to-calc-a1-output
?x <- (goal bind-values)
(time ?t)
=>
(retract ?x)
(assert (goal calc-a1-output))
)
;rule for calculating the adder [a1] out and msb-out slots
;SLOT out: declares the output of : (in1+in2) mod 32
;SLOT msb-out: declares the output of : (in1+in2) mod 16
(defrule calc-a1-output
?x <- (goal calc-a1-output)
=>
(printout t "Calculating the output values of A1" crlf)
(retract ?x)
;bind the 2 inputs of [a1] to 2 variables
(bind ?input1 (send [a1] get-input1))
(bind ?input2 (send [a1] get-input2))
;bind the result of the inputs to 2 variables
(bind ?value1 (send ?input1 get-out))
(bind ?value2 (send ?input2 get-out))
;calculate the sum of 2 numbers MOD 32
(modify-instance [a1] (out (send [a1] calculate-add ?value1 ?value2 1)))
;calculate the sum of 2 numbers MOD 16
(modify-instance [a1] (msb-out (send [a1] calculate-add ?value1 ?value2 0)))
(assert (goal calc-p1-output))
)
;rule for calculating the multiplier [p1] out and msb-out slots
;SLOT out: declares the output of : (in1*in2) mod 32
;SLOT msb-out: declares the output of : (in1*in2) mod 16
(defrule calc-p1-output
?x <- (goal calc-p1-output)
=>
(printout t "Calculating the output values of P1" crlf)
(retract ?x)
;bind the 2 inputs of [p1] to 2 variables
(bind ?input1 (send [p1] get-input1))
(bind ?input2 (send [p1] get-input2))
;bind the result of the inputs to 2 variables
(bind ?value1 (send ?input1 get-out))
(bind ?value2 (send ?input2 get-out))
;calculate the multiplication of 2 numbers MOD 32
(modify-instance [p1] (out (send [p1] calculate-multiply ?value1 ?value2 1)))
;calculate the multiplication of 2 numbers MOD 16
(modify-instance [p1] (msb-out (send [p1] calculate-multiply ?value1 ?value2 0)))
(assert (goal calc-p2-output))
)
;rule for calculating the multiplier [p2] out and msb-out slots
;SLOT out: declares the output of : (in1*in2) mod 32
;SLOT msb-out: declares the output of : (in1*in2) mod 16
(defrule calc-p2-output
?x <- (goal calc-p2-output)
=>
(printout t "Calculating the output values of P2" crlf)
(retract ?x)
;bind the 2 inputs of [p2] to 2 variables
(bind ?input1 (send [p2] get-input1))
(bind ?input2 (send [p2] get-input2))
;bind the result of the inputs to 2 variables
(bind ?value1 (send ?input1 get-out))
(bind ?value2 (send ?input2 get-out))
;calculate the multiplication of 2 numbers MOD 32
(modify-instance [p2] (out (send [p2] calculate-multiply ?value1 ?value2 1)))
;calculate the multiplication of 2 numbers MOD 16
(modify-instance [p2] (msb-out (send [p2] calculate-multiply ?value1 ?value2 0)))
(assert (goal calc-a2-output))
)
;rule for calculating the adder [a2] out and msb-out slots
;SLOT out: declares the output of : (in1+in2) mod 32
;SLOT msb-out: declares the output of : (in1+in2) mod 16
(defrule calc-a2-output
?x <- (goal calc-a2-output)
=>
(printout t "Calculating the output values of A2" crlf)
(retract ?x)
;bind the 2 inputs of [a2] to 2 variables
(bind ?input1 (send [a2] get-input1))
(bind ?input2 (send [a2] get-input2))
;bind the result of the inputs to 2 variables
(bind ?value1 (send ?input1 get-out))
(bind ?value2 (send ?input2 get-out))
;calculate the sum of 2 numbers MOD 32
(modify-instance [a2] (out (send [a2] calculate-add ?value1 ?value2 1)))
;calculate the sum of 2 numbers MOD 16
(modify-instance [a2] (msb-out (send [a2] calculate-add ?value1 ?value2 0)))
(assert (goal assign-sensor-out-values))
)
;Calculating the outputs of all the internal components (adder,multiplier) is DONE.
;The next rule is responsible for assigning the sensors` out slot with
;the values of the internal component`s out slot that are connected with
;For example
;1) the (slot:out) of sensor [m1] in (time 1) will have the value of 10
;2) the (slot:out) of sensor [m1] in (time 2) will have the value of 14
(defrule assign-sensor-out-values
?x <- (goal assign-sensor-out-values)
(object (is-a sensor) (name ?sensor) (input ?internal_component))
(object (is-a internal-component) (name ?internal_component) (out ?v))
=>
(modify-instance ?sensor (out ?v))
)
;rule changer
(defrule change-goal-to-check-discrepancy
?x <- (goal assign-sensor-out-values)
=>
(retract ?x)
(assert (check-discrepancy))
(assert (discrepancy no)) ;default value of discrepancy
)
;rules that checks if there is an discrepancy in the system
;Discrepancy exists when the sensor`s (slot:reading) is not equal to the (slot:output)
(defrule check-discrepancy
?x <- (check-discrepancy)
?y <- (discrepancy no)
(time ?t)
(object (is-a sensor) (name ?sensor) (reading ?read) (out ?output) (input ?internal_component))
=>
(printout t "Checking if there is a discrepancy in clock: " ?t crlf)
(if (<> ?read ?output)
then
(retract ?x)
(retract ?y)
(assert (discrepancy yes))
(assert (suspects ?sensor ?internal_component)) ;2 possible suspects for the malfunction
)
)
;if there is no discrepancy the system operated normally and it is ready to advance to the next cycle
(defrule discrepancy-no
?x <- (check-discrepancy)
?y <- (discrepancy no)
(time ?t)
=>
(printout t "No discrepancy in clock : " ?t crlf)
(retract ?x)
(retract ?y)
(printout t "Time: " ?t " --> Normal Operation!" crlf)
(assert (goal change-time))
)
;if there is a discrepancy there is a malfunction in the circuit
(defrule discrepancy-yes
?x <- (discrepancy yes)
(suspects ?sensor ?internal_component)
(time ?t)
=>
(printout t "There is a discrepancy in clock: " ?t crlf)
(retract ?x)
(assert (goal init-suspects))
)
;rule for changing the component`s slot suspect from no to yes
(defrule init-suspects
?x <- (goal init-suspects)
(suspects ?sensor ?internal_component)
(object (is-a sensor) (name ?sensor) (suspect no))
(object (is-a internal-component) (name ?internal_component) (suspect no))
=>
(printout t "Suspects of the discrepancy are: " crlf)
(printout t "1) Sensor: " ?sensor crlf)
(printout t "2) " (class ?internal_component) ": " ?internal_component crlf)
(retract ?x)
(modify-instance ?sensor (suspect yes))
(modify-instance ?internal_component (suspect yes))
(assert (goal decide-type-of-malfunction))
)
;rule for printing the type of the malfunction
;There are 2 types of malfunction:
;1: cutting of the most significant bit
;2: the output is zero regardless of input
(defrule decide-type-of-malfunction
?x <- (goal decide-type-of-malfunction)
(time ?t)
(suspects ?sensor ?internal_component)
=>
(retract ?x)
(bind ?sensor_reading (send ?sensor get-reading)) ;bind the sensor`s reading slot to a variable
(bind ?component_msb_out (send ?internal_component get-msb-out)) ;bind the internal component`s msb-out slot to a variable
(bind ?component_out (send ?internal_component get-out));bind the internal component`s out slot to a variable
;if the (slot:reading) of the sensor is equal to the (slot:msb-out) of the intenal component value that means we have cutting of the most significant bit
(if (= ?sensor_reading ?component_msb_out)
then (printout t "Time: " ?t " --> " (class ?internal_component) " " ?internal_component " error: Most Significant Bit is off!" crlf)
else
;if the (slot:reading) of the sensor is equal to zero then there is a malfunction to the internal component