summaryrefslogtreecommitdiff
path: root/lib/visual_state_api/src/SEMLibE.h
blob: 6262d60aea9daf9e6f12a96a9ec9e0f41b4896c2 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
/*
 * Type:        Header File
 * 
 * Id:          SEMLibE.h
 *
 * Function:    Header file for the SEM Library Expert version 4 definitions 
 *              and function prototypes.
 *
 * Portability: ANSI-C Compiler.
 *
 * Copyright (c) 1999-2006 IAR Systems. All rights reserved.
 */

/*
 * Version   ! Date   ! Status ! Changes
 *----------------------------------------------------------------------------
 * 4.0.0.9   ! 240299 ! Closed ! -
 * 4.0.4     ! 010799 ! Closed ! Minor update, there might be no changes to this particular file.
 */

#ifndef __SEMLIBE_H
#define __SEMLIBE_H


#include <stddef.h>
#include <stdlib.h>


/* Include SEM Library Definition Header File. */
#include "SEMEDef.h"


#ifndef VS_CODER_GUID
#error The generated files were generated by a visualSTATE Coder, which is not compliant with this version of the visualSTATE Expert API.
#endif


#ifdef VISUALSTATE_EXPERT_DLL
#include "SEMEdll.h"
#else
#define VS_CALL_CONV
#define VS_CONTEXT_TYPE SEMContext
#endif


#ifndef VS_TRUE
#define VS_TRUE (1)
#endif

#ifndef VS_FALSE
#define VS_FALSE (0)
#endif


#define SEM_VERS_ID   0X050


#ifdef VS_RUNTIME_INFO
typedef struct
{
  char pSignatureVersion[VS_SIGNATURE_VERSION_LENGTH];
  char pSignatureContent[VS_SIGNATURE_CONTENT_LENGTH];
} VSRunTimeInfo;
#endif


typedef struct
{
  unsigned long             IdAndEventGroupType;
  unsigned long             nNofEvents;
  unsigned long             nNofSignals;
  unsigned long             nNofStates;
  unsigned long             nNofStateMachines;
  unsigned long             nNofActionFunctions;
  unsigned long             nNofInstances;
  unsigned long             SSize;
  unsigned long             SMIPos;
  unsigned long             EGTPos;
  unsigned long             EGTIPos;
  unsigned long             RDPos;
  unsigned long             RIPos;
  unsigned long             RTIPos;
  unsigned long             TSPos;
  unsigned long             ENIPos;
  unsigned long             SNIPos;
  unsigned long             ANIPos;
  unsigned long             EEIPos;
  unsigned long             SEIPos;
  unsigned long             AEIPos;
  unsigned long             contextPtrOffset;
} RBH;


extern SEM_CONTEXT *SEMContext;
extern unsigned char SEMInitCC;     


enum
{
  /*
   * Status code 0:   SES_OKAY.
   *
   * Explanation:     Function performed successfully.
   *
   * Solution:        None.
   */
  SES_OKAY, /* 0 */


  /*
   * Status code:     SES_FOUND.
   *
   * Explanation:     The called function has returned an identifier index
   *                  number.
   *
   * Solution:        Process the returned identifier index number. If the
   *                  function SEM_GetInput/SMP_GetInput or SEM_GetOutput/
   *                  SMP_GetOutput was called, the function can be called 
   *                  again to find more events or action expressions.
   */
  SES_FOUND, /* 1 */


  /*
   * Status code:     SES_ACTIVE.
   *
   * Explanation:     The completion code has one of the two expositions:
   *                  1)  A state/event deduction is started, while an event
   *                      inquiry is active. All inquired events have not been
   *                      returned by the function SEM_GetInput/SMP_GetInput.
   *                  2)  An event inquiry is started, while a state/event
   *                      deduction is active. All deduced action expressions 
   *                      have not been returned by the function SEM_GetOutput/
   *                      SMP_GetOutput and the SEM_NextState/SMP_NextState has 
   *                      not been called to finish the state/event deduction.
   *
   * Solution:        The completion code is a warning and perhaps the
   *                  application program should be rewritten. An event inquiry
   *                  and a state/event deduction should not be active at the
   *                  same time.
   */
  SES_ACTIVE, /* 2 */


  /*
   * Error code:      SES_CONTRADICTION.
   *
   * Explanation:     A contradiction has been detected between two states in a
   *                  state machine.
   *
   * Solution:        Check the VS System.
   */
  SES_CONTRADICTION, /* 3 */


  /*
   * Error code:      SES_RANGE_ERR.
   *
   * Explanation:     You are making a reference to an identifier that does not
   *                  exist. Note that the first index number is 0. If the rule
   *                  base has 4 identifier of the same type and you use a
   *                  function with the variable parameter = 4, the function 
   *                  will return with a SES_RANGE_ERR error. In this case the 
   *                  highest variable index number is 3.
   *
   * Solution:        The application program may check the index parameters 
   *                  with one of the following variables in the SEM_Context 
   *                  struct:
   *
   *                    nNofEvents
   *                    nNofStates
   *                    nNofActionFunctions
   *                    nNofStateMachines
   */
  SES_RANGE_ERR, /* 4 */


  /*
   * Error code:      SES_TEXT_TOO_LONG.
   *
   * Explanation:     The requested text is longer than the specified maximum
   *                  length.
   *
   * Solution:        Increase the maximum length.
   */
  SES_TEXT_TOO_LONG, /* 5 */


  /*
   * Error code:      SES_TYPE_ERR.
   *
   * Explanation:     A text function has been called with the wrong identifier
   *                  type or the specified text is not included in the VS 
   *                  System source file.
   *
   * Solution:        Use the indentifier type symbols (EVENT_TYPE, STATE_TYPE
   *                  or ACTION_TYPE) defined in the SEMlibE.h file and remember
   *                  to include wanted text in the VS System.
   */
  SES_TYPE_ERR, /* 6 */


  /*
   * Error code:      SES_EMPTY.
   *
   * Explanation:     No events has been given to the SEM_Deduct/SMP_Deduct 
   *                  function before calling this function.
   *
   * Solution:        Call the SEM_Deduct/SMP_Deduct function with an event 
   *                  number.
   */
  SES_EMPTY, /* 7 */


  /*
   * Error code:      SES_BUFFER_OVERFLOW.
   *
   * Explanation:     A destination buffer cannot hold the number of items 
   *                  found.
   *
   * Solution:        Call the function with an extended buffer as destination.
   */
  SES_BUFFER_OVERFLOW, /* 8 */


  /*
   * Error code:      SES_SIGNAL_QUEUE_FULL.
   *
   * Explanation:     Signal queue is full.
   *
   * Solution:        Increase the maximum signal queue size in the VS System or
   *                  via the VS Coder signal queue size option.
   */
  SES_SIGNAL_QUEUE_FULL, /* 9 */


  /*
   * Status code:     SES_VERS_ERR
   *
   * Explanation:     Incompatible version of VS System attempted loaded.
   *
   * Solution:        Recompile the VS System.
   */
  SES_VERS_ERR = 16, /* 16 */


  /*
   * Status code:     SES_FILE_ERR
   *
   * Explanation:     Error while accessing VS System file.
   *
   * Solution:        1)  Check file name.
   *                  2)  Regenerate VS System.
   */
  SES_FILE_ERR, /* 17 */


  /*
   * Status code:     SES_MEM_ERR
   *
   * Explanation:     Error while allocating memory for VS System.
   *
   * Solution:        1)  Free some memory in your computer.
   *                  2)  On PCs, use a large-data memory model.
   */
  SES_MEM_ERR, /* 18 */


  /*
   * Status code:     SES_NOT_LOADED
   *
   * Explanation:     No VS System is loaded.
   *
   * Solution:        Load a VS System before calling the function.
   */
  SES_NOT_LOADED, /* 19 */


  /*
   * Status code:     SES_NOT_COMPATIBLE
   *
   * Explanation:     Function is not compatible with current setup.
   *
   * Solution:        Use an other function.
   */
  SES_NOT_COMPATIBLE, /* 20 */


  /*
   * Status code:     SES_TYPE_OVERFLOW
   *
   * Explanation:     The number of instances * state machines exceeds 
   *                  the range for an unsigned long.
   *
   * Solution:        Reduce the number of instances or state machines.
   */
  SES_TYPE_OVERFLOW /* 21 */
};


/* Identifier types, used when getting texts and explanations. */
enum {EVENT_TYPE, STATE_TYPE, ACTION_TYPE};


/*
 * Used internal in SMPMain.c
 */
#define STATE_SEM_INITIALIZE  0x00
#define STATE_SEM_SIGNAL      0x01
#define STATE_SEM_PREPARE     0x02
#define STATE_SEM_CONSULT     0x03
#define STATE_SEM_OUTPUT      0x04
#define STATE_SEM_OKAY        0x05

// added by GL 29/10/2007
#define SEM_FUNC_OLD_NAMING_STYLE 0
/*
 * State/event naming style.
 */
#if (SEM_FUNC_OLD_NAMING_STYLE)
#define SEM_Load                  sem_load
#define SEM_Connect               sem_connect
#define SEM_Free                  sem_free
#define SEM_Init                  sem_init
#define SEM_InitGuardCallBack     sem_init_guard_call_back
#define SEM_InitSignalDBCallBack  sem_init_signal_d_b_call_back
#define SEM_InitSignalQueue       sem_init_signal_queue
#define SEM_InitInstances         sem_init_instances
#define SEM_SetInstance           sem_set_instance
#define SEM_Deduct                sem_deduct
#define SEM_GetOutput             sem_get_output
#define SEM_GetOutputAll          sem_get_output_all
#define SEM_NextState             sem_next_state
#define SEM_NextStateChg          sem_next_state_chg
#define SEM_Inquiry               sem_inquiry
#define SEM_GetInput              sem_get_input
#define SEM_GetInputAll           sem_get_input_all
#define SEM_Name                  sem_name
#define SEM_NameAbs               sem_name_abs
#define SEM_Expl                  sem_expl
#define SEM_ExplAbs               sem_expl_abs
#define SEM_State                 sem_state
#define SEM_StateAll              sem_state_all
#define SEM_Machine               sem_machine
#define SEM_ForceState            sem_force_state

#define SMP_Connect               smp_connect
#define SMP_Load                  smp_load
#define SMP_Free                  smp_free
#define SMP_Init                  smp_init
#define SMP_InitGuardCallBack     smp_init_guard_call_back
#define SMP_InitSignalDBCallBack  smp_init_signal_d_b_call_back
#define SMP_InitSignalQueue       smp_init_signal_queue
#define SMP_InitInstances         smp_init_instances
#define SMP_SetInstance           smp_set_instance
#define SMP_Deduct                smp_deduct
#define SMP_GetOutput             smp_get_output
#define SMP_GetOutputAll          smp_get_output_all
#define SMP_NextState             smp_next_state
#define SMP_NextStateChg          smp_next_state_chg
#define SMP_Inquiry               smp_inquiry
#define SMP_GetInput              smp_get_input
#define SMP_GetInputAll           smp_get_input_all
#define SMP_Name                  smp_name
#define SMP_NameAbs               smp_name_abs
#define SMP_Expl                  smp_expl
#define SMP_ExplAbs               smp_expl_abs
#define SMP_State                 smp_state
#define SMP_StateAll              smp_state_all
#define SMP_Machine               smp_machine
#define SMP_ForceState            smp_force_state
#endif


/*
 * Name        :    SEM_Load   
 *
 * Description :    Calls SMP_Load.
 *
 * Argument    :    See 'argument' section for SMP_Load.
 *
 * Return      :    See 'return' section for SMP_Load.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_Load (const char *FileName);


/*
 * Name        :    SEM_Connect 
 *
 * Description :    Calls SMP_Connect.
 *
 * Argument    :    See 'argument' section for SMP_Connect.
 *
 * Return      :    See 'return' section for SMP_Connect.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SEM_Connect (void VS_TQ_RULEBASE *VSData);


/*
 * Name        :    SEM_Free 
 *
 * Description :    Calls SMP_Free.
 *
 * Argument    :    See 'argument' section for SMP_Free.
 *
 * Return      :    See 'return' section for SMP_Free.
 *
 * Portability :    ANSI-C Compiler.
 */
extern void VS_CALL_CONV SEM_Free (void);


/*
 * Name        :    SEM_Init 
 *
 * Description :    Calls SMP_Init.
 *
 * Argument    :    See 'argument' section for SMP_Init.
 *
 * Return      :    See 'return' section for SMP_Init.
 *
 * Portability :    ANSI-C Compiler.
 */
extern void VS_CALL_CONV SEM_Init (void);


/*
 * Name        :    SEM_InitGuardCallBack
 *
 * Description :    Calls SEM_InitGuardCallBack.
 *
 * Argument    :    See 'argument' section for SEM_InitGuardCallBack.
 *
 * Return      :    See 'return' section for SEM_InitGuardCallBack.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_GUARD_EXPRESSION)
#if (SEM_FUNCEXPHANDLING == 0)
void SEM_InitGuardCallBack (VS_GUARDEXPR_TYPE VS_TQ_GUARDEXPRCOL * Guard);
#else
void SEM_InitGuardCallBack (unsigned char (*Guard)(struct SEM_CONTEXT VS_TQ_CONTEXT *Context, SEM_GUARD_EXPRESSION_TYPE i));
#endif
#endif


/*
 * Name        :    SEM_InitSignalDBCallBack
 *
 * Description :    Calls SEM_InitSignalDBCallBack.
 *
 * Argument    :    See 'argument' section for SEM_InitSignalDBCallBack.
 *
 * Return      :    See 'return' section for SEM_InitSignalDBCallBack.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_SIGNAL_DB)
void SEM_InitSignalDBCallBack (void (*SEM_SignalDB)(SEM_CONTEXT VS_TQ_CONTEXT *Context, SEM_EVENT_TYPE SignalNo));
#endif


/*
 * Name        :    SEM_InitSignalQueue
 *
 * Description :    Calls SMP_InitSignalQueue.
 *
 * Argument    :    See 'argument' section for SMP_InitSignalQueue.
 *
 * Return      :    See 'return' section for SMP_InitSignalQueue.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_SIGNAL)
extern void VS_CALL_CONV SEM_InitSignalQueue (void);
#endif


/*
 * Name        :    SEM_InitInstances 
 *
 * Description :    Calls SMP_InitInstances.
 *
 * Argument    :    See 'argument' section for SMP_InitInstances.
 *
 * Return      :    See 'return' section for SMP_InitInstances.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_InitInstances (void);

      
/*
 * Name        :    SEM_SetInstance 
 *
 * Description :    Calls SMP_SetInstance.
 *
 * Argument    :    See 'argument' section for SMP_SetInstance.
 *
 * Return      :    See 'return' section for SMP_SetInstance.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_SetInstance (SEM_INSTANCE_TYPE Instance);


/*
 * Name        :    SEM_Deduct
 *
 * Description :    Calls SMP_Deduct.
 *
 * Argument    :    See 'argument' section for SMP_Deduct.
 *
 * Return      :    See 'return' section for SMP_Deduct.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_Deduct (SEM_EVENT_TYPE EventNo);


/*
 * Name        :    SEM_GetOutput 
 *
 * Description :    Calls SMP_GetOutput.
 *
 * Argument    :    See 'argument' section for SMP_GetOutput.
 *
 * Return      :    See 'return' section for SMP_GetOutput.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_GetOutput (SEM_ACTION_EXPRESSION_TYPE *ActionNo);


/*
 * Name        :    SEM_GetOutputAll 
 *
 * Description :    Calls SMP_GetOutputAll.
 *
 * Argument    :    See 'argument' section for SMP_GetOutputAll.
 * 
 * Return      :    See 'return' section for SMP_GetOutputAll.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_GetOutputAll (
  SEM_ACTION_EXPRESSION_TYPE *ActionExprVector, 
  SEM_ACTION_EXPRESSION_TYPE MaxSize);


/*
 * Name        :    SEM_NextState 
 *
 * Description :    Calls SMP_NextState.
 *
 * Argument    :    See 'argument' section for SMP_NextState.
 *
 * Return      :    See 'return' section for SMP_NextState.
 *
 * Portability :    ANSI-C Compiler.
 */
#if !defined SEM_NEXT_STATE_CHG || defined VISUALSTATE_EXPERT_DLL
extern unsigned char VS_CALL_CONV SEM_NextState (void);
#endif


/*
 * Name        :    SEM_NextStateChg 
 *
 * Description :    Calls SMP_NextStateChg.
 *
 * Argument    :    See 'argument' section for SMP_NextStateChg.
 *
 * Return      :    See 'return' section for SMP_NextStateChg.
 *
 * Portability :    ANSI-C Compiler.
 */
#if defined SEM_NEXT_STATE_CHG || defined VISUALSTATE_EXPERT_DLL
extern unsigned char VS_CALL_CONV SEM_NextStateChg (void);
#endif


/*
 * Name        :    SEM_Inquiry 
 *
 * Description :    Calls SMP_Inquiry.
 *
 * Argument    :    See 'argument' section for SMP_Inquiry.
 *
 * Return      :    See 'return' section for SMP_Inquiry.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_Inquiry (void);


/*
 * Name        :    SEM_GetInput
 *
 * Description :    Calls SMP_GetInput.
 *
 * Argument    :    See 'argument' section for SMP_GetInput.
 *
 * Return      :    See 'return' section for SMP_GetInput.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_GetInput (SEM_EVENT_TYPE *EventNo,
  SEM_EVENT_TYPE *EventList);


/*
 * Name        :    SEM_GetInputAll 
 *
 * Description :    Calls SMP_GetInputAll.
 *
 * Argument    :    See 'argument' section for SMP_GetInputAll.
 *
 * Return      :    See 'return' section for SMP_GetInputAll.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_GetInputAll (SEM_EVENT_TYPE *EventVector, 
  SEM_EVENT_TYPE *EventList, SEM_EVENT_TYPE MaxSize);


/*
 * Name        :    SEM_Name
 *
 * Description :    Calls SMP_Name.
 *
 * Argument    :    See 'argument' section for SMP_Name.
 *
 * Return      :    See 'return' section for SMP_Name.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_Name (unsigned char IdentType, 
  SEM_EXPLANATION_TYPE IdentNo, char *Text, unsigned short MaxSize);


/*
 * Name        :    SEM_NameAbs 
 *
 * Description :    Calls SMP_NameAbs.
 *
 * Argument    :    See 'argument' section for SMP_NameAbs.
 *
 * Return      :    See 'return' section for SMP_NameAbs.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_NameAbs (unsigned char IdentType, 
  SEM_EXPLANATION_TYPE IdentNo, char VS_TQ_RULEBASE **Text);


/*
 * Name        :    SEM_Expl
 *
 * Description :    Calls SMP_Expl.
 *
 * Argument    :    See 'argument' section for SMP_Expl.
 *
 * Return      :    See 'return' section for SMP_Expl.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_Expl (unsigned char IdentType, 
  SEM_EXPLANATION_TYPE IdentNo, char *Text, unsigned short MaxSize);


/*
 * Name        :    SEM_ExplAbs
 *
 * Description :    Calls SMP_ExplAbs.
 *
 * Argument    :    See 'argument' section for SMP_ExplAbs.
 *
 * Return      :    See 'return' section for SMP_ExplAbs
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_ExplAbs (unsigned char IdentType, 
  SEM_EXPLANATION_TYPE IdentNo, char VS_TQ_RULEBASE **Text);


/*
 * Name        :    SEM_State
 *
 * Description :    Calls SMP_State.
 *
 * Argument    :    See 'argument' section for SMP_State.
 *
 * Return      :    See 'return' section for SMP_State.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_State (SEM_STATE_MACHINE_TYPE StateMachineNo,
  SEM_STATE_TYPE *StateNo);


/*
 * Name        :    SEM_StateAll
 *
 * Description :    Calls SMP_StateAll.
 *
 * Argument    :    See 'argument' section for SMP_StateAll.
 *
 * Return      :    See 'return' section for SMP_StateAll.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_StateAll (SEM_STATE_TYPE *StateVector, 
  SEM_STATE_MACHINE_TYPE MaxSize);


/*
 * Name        :    SEM_Machine 
 *
 * Description :    Calls SMP_Machine.
 *
 * Argument    :    See 'argument' section for SMP_Machine.
 *
 * Return      :    See 'return' section for SMP_Machine.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_Machine (SEM_STATE_TYPE StateNo,
  SEM_STATE_MACHINE_TYPE *StateMachineNo);


/*
 * Name        :    SEM_ForceState
 *
 * Description :    Calls SMP_ForceState.
 *
 * Argument    :    See 'argument' section for SMP_ForceState.
 *
 * Return      :    See 'return' section for SMP_ForceState.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char VS_CALL_CONV SEM_ForceState (SEM_STATE_TYPE StateNo);


/*
 * Name        :    SEM_Action 
 *
 * Description :    The macro will call an action function by using the
 *                  VSAction function pointer table.
 *
 * Argument    :    ActionNo:
 *                    Action index number.
 * 
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_FUNC_OLD_NAMING_STYLE)
#define sem_action(ActionNo) (*VSAction[ActionNo])(VS_CONTEXT_TYPE)
#else
#define SEM_Action(ActionNo) (*VSAction[ActionNo])(VS_CONTEXT_TYPE)
#endif


/*
 * Name        :    SEM_TableAction 
 *
 * Description :    The macro will call an action function by using the
 *                  specified function pointer table.
 *
 * Argument    :    Table:
 *                    Function pointer table.
 *
 *                  ActionNo:
 *                    Action index number.
 *
 *                  Context (not in DLL):
 *                    A pointer to a VS system context.
 *
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_FUNC_OLD_NAMING_STYLE)
#define sem_table_action(Table, ActionNo) (* (Table)[ActionNo])(VS_CONTEXT_TYPE)
#else
#define SEM_TableAction(Table, ActionNo) (* (Table)[ActionNo])(VS_CONTEXT_TYPE)
#endif


/*
 * Name        :    SMP_Connect
 *
 * Description :    This function connects to a binary VS System already 
 *                  residing in memory.
 *
 * Argument    :    Context:
 *                    A pointer pointer to a VS System context.
 *
 *                  VSData:
 *                    A pointer to the memory area where the VS System
 *                    resides. 
 *                    The VS System area must be an image of the binary 
 *                    VS System file including texts.
 *
 * Return      :    Completion code:
 *
 *                    SES_FILE_ERR:
 *                      VS System file version error.
 *
 *                    SES_MEM_ERR:
 *                      There is not enough heap memory.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Connect(SEM_CONTEXT **Context, void VS_TQ_RULEBASE *VSDdata);


/*
 * Name        :    SMP_Load  
 *
 * Description :    This function loads a binary VS System from a file.
 *                  A new context is allocated, the VS System is loaded and 
 *                  the context is initialized. 
 *                  Futhermore SMP_Init is called. SMP_InitSignalQueue is also
 *                  called if the VS System has signals.
 *                  Texts are not loaded into memory.
 *
 * Argument    :    Context:
 *                    A pointer pointer to a VS System context.
 *
 *                  FileName:
 *                    A pointer to the character string containing the name of 
 *                    the VS System file to be loaded.
 *
 * Return      :    Completion code:
 *
 *                    SES_FILE_ERR:
 *                      VS System file version error.
 *
 *                    SES_MEM_ERR:
 *                      There is not enough heap memory.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Load (SEM_CONTEXT **Context, const char *FileName);


/*
 * Name        :    SMP_Free
 *
 * Description :    This function frees the memory allocated by a previous
 *                  call to SMP_Load or SMP_Connect. If the VS System was 
 *                  loaded from disk, the corresponding heap memory is 
 *                  deallocated.
 *                  If context is not equal to NULL, SMP_Free will free the
 *                  memory allocated by the VS System and the context. 
 *                  If the VS System was loaded from disk, the VS System file 
 *                  is closed. 
 *                  If context is NULL, nothing is done.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
extern void SMP_Free (SEM_CONTEXT VS_TQ_CONTEXT *Context);


/*
 * Name        :    SMP_Init
 *
 * Description :    This function (re)initializes the VS System. 
 *                  Before calling any of the following SEM functions, this
 *                  function can be called to initialize the state/event 
 *                  system. 
 *                  Both SMP_Load and SMP_Connect implicitly calls SMP_Init 
 *                  and SMP_InitSignalQueue, thus no call should be 
 *                  neccessary except if reinitialization is needed.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Init (SEM_CONTEXT VS_TQ_CONTEXT *Context);


/*
 * Name        :    SMP_InitGuardCallBack
 *
 * Description :    This function initializes the guard expression call back
 *                  function.
 *                  This function should be called after the 
 *                  SMP_Load/SMP_Connect function if the VS System contains
 *                  guard expressions.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  Guard:
 *                    If function pointer tables are not used:
 *                      A pointer pointer to the VS System guard function 
 *                    else 
 *                      A pointer pointer to the VS System guard expression 
 *                      function pointer table.
 *
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_GUARD_EXPRESSION)
#if (SEM_FUNCEXPHANDLING == 0)
extern void SMP_InitGuardCallBack (SEM_CONTEXT VS_TQ_CONTEXT *Context, VS_GUARDEXPR_TYPE VS_TQ_GUARDEXPRCOL * Guard);
#else
extern void SMP_InitGuardCallBack (SEM_CONTEXT VS_TQ_CONTEXT *Context, unsigned char (* Guard)(SEM_CONTEXT VS_TQ_CONTEXT *Context, SEM_GUARD_EXPRESSION_TYPE i));
#endif
#endif


/*
 * Name        :    SMP_InitSignalDBCallBack
 *
 * Description :    This function initializes the signal double buffer call 
 *                  back function.
 *                  This function should be called after the 
 *                  SMP_Load/SMP_Connect function if the VS System used
 *                  double buffering for any signals.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  SEM_SignalDB:
 *                    A pointer to the VS System signal double buffer function
 *                    pointer table.
 *
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_SIGNAL_DB)
extern void SMP_InitSignalDBCallBack (SEM_CONTEXT VS_TQ_CONTEXT *Context,
  void (*SEM_SignalDB)(SEM_CONTEXT VS_TQ_CONTEXT *Context, SEM_EVENT_TYPE SignalNo));
#endif


/*
 * Name        :    SMP_InitSignalQueue
 *
 * Description :    This function (re)initialize the signal queue in a 
 *                  VS System. This function must be called together with 
 *                  the SMP_Init function.
 *                  Both SMP_Load and SMP_Connect implicitly calls SMP_Init 
 *                  and SMP_InitSignalQueue, thus no call should be 
 *                  neccessary except if reinitialization is needed.
 *                  The function will only be avaliable if the signal queue 
 *                  is enable.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_SIGNAL)
extern void SMP_InitSignalQueue (SEM_CONTEXT VS_TQ_CONTEXT *Context);
#endif


/*
 * Name        :    SMP_InitInstances
 *
 * Description :    Initialize a set of instances of the VS System.
 *                  The function is used for initializing a number of 
 *                  instances of the VS System. 
 *                  If the function has already been called, previous 
 *                  instances are deallocated and a new set is allocated.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_MEM_ERR:
 *                      There is not enough heap memory.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_InitInstances (SEM_CONTEXT VS_TQ_CONTEXT *Context);


/*
 * Name        :    SMP_SetInstance
 *
 * Description :    The function is used for setting up the instances of 
 *                  the VS System. The instance will be active until 
 *                  another call of the function.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  Instances:
 *                    The number of VS System instances to be initialized.
 *
 * Return      :    Completion code:
 *
 *                    SES_ACTIVE:
 *                      The function was attempted executed while a deduct or
 *                      inquiry session was active. The function is not 
 *                      executed.
 *  
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      The index number of the VS System instance is 
 *                      invalid.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_SetInstance (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_INSTANCE_TYPE Instance);


/*
 * Name        :    SMP_Deduct
 *
 * Description :    The function prepares the reception of action expressions, 
 *                  that can be deduced on basis of the given event, the 
 *                  internal current state vector and the rules in the 
 *                  VS System.
 *                  All action expressions are deduced by continously calling 
 *                  the function SMP_GetOutput or by one call to 
 *                  SMP_GetOutputAll.
 *                  Before calling the SMP_Deduct function again, the 
 *                  SMP_NextState or SMP_NextStateChg should be called to 
 *                  enter the new states, if any.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  EventNo:
 *                    Event number to be processed.
 *
 * Return      :    Completion code:
 *
 *                    SES_ACTIVE:
 *                      The function SMP_Inquiry has been called. All inquired
 *                      events have not been returned by the function 
 *                      SMP_GetInput or SMP_GetInputAll. 
 *                      The deduction is okay, but the user should not call the 
 *                      function SMP_GetInput before the functions 
 *                      SMP_NextState or SMP_NextStateChg and SMP_Inquiry have
 *                      been called.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      Event is out of range.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Deduct (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_EVENT_TYPE EventNo);



/*
 * Name        :    SMP_GetOutput
 *
 * Description :    The function finds an action expressions, if any has been
 *                  deduced on basis of the event given to the function 
 *                  SMP_Deduct, the internal current state vector and the 
 *                  rules in the VS System.
 *                  All action expressions are found by continuous calls to 
 *                  the SMP_GetOutput function. When the SMP_GetOutput returns 
 *                  the completion code SES_OKAY all action expressions have 
 *                  been found.
 *                  Use the SMP_Action or SMP_TableAction macros to call the 
 *                  action expressions.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  ActionNo:
 *                    Pointer to store the deduced action expression.
 *
 * Return      :    Completion code:
 *
 *                  SES_CONTRADICTION:
 *                    Contradiction detected, the VS System is not consistent.
 *                    Check the VS System.
 *
 *                  SES_EMPTY:
 *                    No event has been given to the SMP_Deduct function, i.e.
 *                    SMP_Deduct has not been called before calling the 
 *                    SMP_GetOutput function.
 *
 *                  SES_FOUND:
 *                    An action expression has been found. The user can 
 *                    continue to call the SMP_GetOutput, more action 
 *                    expressions may be found.
 *
 *                  SES_NOT_LOADED:
 *                    No VS System loaded or connected.
 *
 *                  SES_OKAY:
 *                    All action expressions have been found.
 *                    The user can now call the SMP_NextState or 
 *                    SMP_NextStateChg function to change state.
 *                    If SMP_deduct is called with the same event and 
 *                    SMP_NextState and SMP_NextStateChg is not called, all
 *                    action expressions can be found again by calling 
 *                    SMP_GetOutput.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_GetOutput (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_ACTION_EXPRESSION_TYPE *ActionNo);


/*
 * Name        :    SMP_GetOutputAll
 *
 * Description :    The function finds all action expression, if any has been 
 *                  deduced on basis of the event given to the function 
 *                  SMP_Deduct, the internal current state vector and the 
 *                  rules in the VS System.
 *                  All action expressions are found by one call to the 
 *                  SMP_GetOutputAll function.
 *                  SMP_GetOutputAll returns the completion code SES_OKAY if 
 *                  all action expression have succesfully been found.
 *                  Defining the symbol SEM_GET_OUTPUT_ALL for your 
 *                  preprocessor/compiler will enable this function.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  ActionExprVector:
 *                    A pointer to array to store the deduced outputs.
 *
 *                  MaxSize:
 *                    Specifies the maximum length of the output vector
 *                    including the symbol ACTION_EXPRESSION_TERMINATION_ID.
 *
 * Return      :    Completion code:
 *
 *                    SES_BUFFER_OVERFLOW:
 *                      The specified MaxSize is too small. The action 
 *                      expressions vector array is not valid.
 *
 *                    SES_CONTRADICTION:
 *                      Contradiction detected, the VS System is not 
 *                      consistent. Check the VS System.
 *
 *                    SES_EMPTY:
 *                      No event has been given to the SMP_Deduct function, 
 *                      i.e. SMP_Deduct has not been called before calling the 
 *                      SMP_GetOutputAll function.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_OKAY:
 *                      All action expressions have been found.
 *                      The user can now call the SMP_NextState or 
 *                      SMP_NextStateChg function to change state.
 *                      If SMP_Deduct is called with the same event and
 *                      SMP_NextState or SMP_NextStateChg is not called, all
 *                      action expressions can be found again by calling 
 *                      SMP_GetOutpuAll.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_GetOutputAll (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_ACTION_EXPRESSION_TYPE *ActionExprVector, 
  SEM_ACTION_EXPRESSION_TYPE MaxSize);


#if defined SEM_NEXT_STATE_CHG || defined VISUALSTATE_EXPERT_DLL

extern unsigned char _SMP_NextStateChg(SEM_CONTEXT VS_TQ_CONTEXT *Context, unsigned char nextStateChg);

#else

extern unsigned char _SMP_NextStateChg(SEM_CONTEXT VS_TQ_CONTEXT *Context);

#endif


/*
 * Name        :    SMP_NextState
 *
 * Description :    The function will update the intern current state vector, 
 *                  if any states can be found on basis of the event given to 
 *                  the function SMP_Deduct, the internal current state vector 
 *                  and the rules in the VS System. 
 *                  The field StateChange in the current SEM_CONTEXT is VS_FALSE 
 *                  if no state change has occurred, else VS_TRUE. 
 *                  The state change feature can also be reached by using the 
 *                  function SMP_NextStateChg. This function is mutually 
 *                  exclusive with the SMP_NextStateChg function.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 * Return      :    Completion code:
 *
 *                    SES_CONTRADICTION:
 *                      Contradiction detected, the VS System is not 
 *                      consistent. Check the VS System.
 *
 *                    SES_EMPTY:
 *                      No event has been given to the SMP_Deduct function,
 *                      i.e. SMP_deduct has not been called before calling
 *                      the SMP_NextState function.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
#if defined VISUALSTATE_EXPERT_DLL

#define SMP_NextState(Context) _SMP_NextStateChg(Context, VS_FALSE)

#elif !defined SEM_NEXT_STATE_CHG

/* default for normal users */
#define SMP_NextState(Context) _SMP_NextStateChg(Context)

#endif


/*
 * Name        :    SMP_NextStateChg
 *
 * Description :    The function will update the internal current state 
 *                  vector, if any states can be found on basis of the event
 *                  given to the function SMP_Deduct, the internal current 
 *                  state vector and the rules in the VS System. 
 *                  The returned completion code will tell if the internal
 *                  state vector was updated with a new value or not, see also 
 *                  SMP_NextState. This feature could be used to determine if
 *                  the SMP_Inquiry function needs to be called.
 *                  This function is mutually exclusive with SMP_NextState and
 *                  must be enabled by defining the symbol SEM_NEXT_STATE_CHG
 *                  for your preprocessor/compiler.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 * Return      :    Completion code:
 *
 *                    SES_CONTRADICTION:
 *                      Contradiction detected, the VS System is not 
 *                      consistent. Check the VS System.
 *
 *                    SES_EMPTY:
 *                      No event has been given to the SMP_Deduct function,
 *                      i.e. SMP_Deduct has not been called before calling the
 *                      SMP_NextStateChg function.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_FOUND:
 *                      Success. The internal state vector was updated with a 
 *                      new value.
 *
 *                    SES_OKAY:
 *                      Success. The internal state vector did not change 
 *                      value.
 *
 * Portability :    ANSI-C Compiler.
 */
#if defined SEM_NEXT_STATE_CHG || defined VISUALSTATE_EXPERT_DLL

#define SMP_NextStateChg(Context) _SMP_NextStateChg(Context, VS_TRUE)

#endif


/*
 * Name        :    SMP_Inquiry
 *
 * Description :    The function prepares for finding events that can be used 
 *                  to perform transitions from the current state. 
 *                  All events are found by continuous calls to the function 
 *                  SMP_GetInput or one call to SMP_GetInputAll.
 *                  As the function will inquire events on the basis of the
 *                  internal current state vector, a state transition should
 *                  be finished, i.e. the previously called function should
 *                  be SMP_Load, SMP_Connect, SMP_Init, SMP_NextState or
 *                  SMP_NextStateChg.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 * Return      :    Completion code:
 *
 *                    SES_ACTIVE:
 *                      A state transition has not been finished. The user 
 *                      should not call the function SMP_GetInput, because
 *                      wrong events could be inquired, if the function 
 *                      SMP_NextState is called to finish running transitions.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Inquiry (SEM_CONTEXT VS_TQ_CONTEXT *Context);


/*
 * Name        :    SMP_GetInput
 *
 * Description :    The function is used to find events that can be used to 
 *                  perform state/event transitions and/or to derive action
 *                  expressions from the current state. All events are found 
 *                  by continuous calls to this function.
 *                  Because the function will inquire events on the basis of 
 *                  he internal current state vector, a state/event deduction
 *                  should not be inquired.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  EventNo:
 *                    A pointer to array to store the inquired event number.
 *
 *                  EventList:
 *                    A pointer to an array which holds the event numbers that
 *                    can be inquired. The EventList must be terminated with 
 *                    the symbol EVENT_TERMINATION_ID.
 *                    If the pointer is a NULL pointer, then all events can be 
 *                    inquired.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      Event number form the EventList is out of range.
 *
 *                    SES_FOUND:
 *                      Success. An event has been found. The user should 
 *                      continue to call the SMP_GetInput, since more events 
 *                      may be found.
 *
 *                    SES_OKAY:
 *                      Success. No more events can be found.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_GetInput (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_EVENT_TYPE *EventNo, SEM_EVENT_TYPE *EventList);


/*
 * Name        :    SMP_GetInputAll
 *
 * Description :    The function is used to find all events that can be used 
 *                  to perform state/event transitions and/or to derive action
 *                  expressions from the current state. 
 *                  All events are found by one call to this function.
 *                  Because the function will inquire events on the basis of 
 *                  the internal current state vector, a state/event deduction
 *                  should not be running.
 *                  Defining the symbol SEM_GET_INPUT_ALL for your 
 *                  preprocessor/compiler will enable this function.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  EventVector:
 *                    A pointer to array to store the inquired event numbers.
 *
 *                  EventList:
 *                    Pointer to an array that holds the event numbers that
 *                    can be inquired. The EventList must be terminated with
 *                    the symbol EVENT_TERMINATION_ID.
 *                    If the pointer is a NULL pointer, then all events can be 
 *                    inquired.
 *      
 *                  MaxSize:
 *                    Specifies the maximum length of the event vector 
 *                    including the symbol EVENT_TERMINATION_ID.
 *
 * Return      :    Completion code:
 *
 *                    SES_BUFFER_OVERFLOW:
 *                      Event number from the EventList is out of range.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      Event number from the EventList is out of range.
 *
 *                    SES_OKAY:
 *                      Success. All events are found successfully.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_GetInputAll (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_EVENT_TYPE *EventVector, SEM_EVENT_TYPE *EventList, 
  SEM_EVENT_TYPE MaxSize);


/*
 * Name        :    SMP_Name
 *
 * Description :    The function get the ASCII name of the specified 
 *                  identifier.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  IdentType:
 *                    Must contain the identifier type of the identifier
 *                    number which can be EVENT_TYPE, STATE_TYPE or 
 *                    ACTION_TYPE.
 *
 *                  IdentNo:
 *                    Must contain the index number of an identifier.
 *
 *                  Test:
 *                    A pointer to a text string. If the function terminates
 *                    successfully, the text string contains the name of the 
 *                    specified identifier.
 *
 *                  MazSize:
 *                    Specifies the maximum length of the text including the
 *                    NULL termination character.
 *
 * Return      :    Completion code:
 *
 *                    SES_FILE_ERR:
 *                      Unable to read from file.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      Identifier number is out of range.
 *
 *                    SES_TEXT_TOO_LONG:
 *                      The text is longer than MazSize.
 *
 *                    SES_TYPE_ERR:
 *                      The identifier type is not correct. Remember to 
 *                      include the desired text in the VS System and specify the 
 *                      correct identifier type when calling this function.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Name (SEM_CONTEXT VS_TQ_CONTEXT *Context, unsigned char IdentType, 
  SEM_EXPLANATION_TYPE IdentNo, char *Text, unsigned short MazSize);


/*
 * Name        :    SMP_NameAbs    
 *
 * Description :    The function gets the pointer to the ASCII name of the 
 *                  specified identifier.
 *                  This function will not work together with the VS Systems
 *                  loaded from disk.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  IdentType:
 *                    Must contain the identifier type of the identifier 
 *                    number which can be EVENT_TYPE, STATE_TYPE or 
 *                    ACTION_TYPE.
 *
 *                  IdentNo:
 *                    Must contain the index number of an identifier.
 *
 *                  Text:
 *                    Must be a pointer to a char pointer. If the function
 *                    terminates successfully, the pointer points to the text
 *                    containing the name of the specified identifier.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_COMPATIBLE:
 *                      The function is not compatible with current setup. The
 *                      VS System is probably loaded from disk. 
 *                      Use the SMP_Name function or compile/link the 
 *                      VS System into the application.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      Identifier number is out of range.
 *
 *                    SES_TYPE_ERR:
 *                      The identifier type is not correct. Remember to 
 *                      include the desired text in the VS System and specify 
 *                      the correct identifier type when calling this 
 *                      function.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_NameAbs (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  unsigned char IdentType, SEM_EXPLANATION_TYPE IdentNo, char VS_TQ_RULEBASE **Text);


/*
 * Name        :    SMP_Expl
 *
 * Description :    The function get the ASCII explanation text of the 
 *                  specified identifier.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  IdentType:
 *                    Must contain the identifier type of the identifier 
 *                    number which can be EVENT_TYPE, STATE_TYPE or 
 *                    ACTION_TYPE.
 *
 *                  IdentNo:
 *                    Must contain the index number of an identifier.
 *
 *                  Text:
 *                    Must be a pointer to a char pointer. If the function
 *                    terminates successfully, the pointer points to the text
 *                    containing the name of the specified identifier.
 *
 *                  MazSize:
 *                    Specifies the maximum length of the Text including the
 *                    NULL termination character.
 *
 * Return      :    Completion code:
 *
 *                    SES_FILE_ERR:
 *                      Unable to read from file.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      Identifier number is out of range.
 *
 *                    SES_TEXT_TOO_LONG:
 *                      The text is longer than MazSize.
 *
 *                    SES_TYPE_ERR:
 *                      The identifier type is not correct. Remember to 
 *                      include the desired text in the VS System and specify the 
 *                      correct identifier type when calling this function.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Expl (SEM_CONTEXT VS_TQ_CONTEXT *Context, unsigned char IdentType, 
  SEM_EXPLANATION_TYPE IdentNo, char *Text, unsigned short MaxSize);


/*
 * Name        :    SMP_ExplAbs
 *
 * Description :    The function get the pointer to the ASCII explanation text
 *                  of the specified identifier. 
 *                  This function will not work together with VS Systems 
 *                  loaded from disk.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  IdentType:
 *                    Must contain the identifier type of the identifier 
 *                    number which can be EVENT_TYPE, STATE_TYPE or 
 *                    ACTION_TYPE.
 *
 *                  IdentNo:
 *                    Must contain the index number of an identifier.
 *
 *                  Text:
 *                    Must be a pointer to a char pointer. If the function
 *                    terminates successfully, the pointer points to the Text
 *                    containing the name of the specified identifier.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_COMPATIBLE:
 *                      The function is not compatible with current setup. The
 *                      VS System is probably loaded from disk. 
 *                      Use the SMP_Expl function or compile/link the 
 *                      VS System into the application.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      Identifier number is out of range.
 *
 *                    SES_TYPE_ERR:
 *                      The identifier type is not correct. Remember to 
 *                      include the desired text in the VS System and specify 
 *                      the correct identifier type when calling this 
 *                      function.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_ExplAbs (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  unsigned char IdentType, SEM_EXPLANATION_TYPE IdentNo, char VS_TQ_RULEBASE **Text);


/*
 * Name        :    SMP_State
 *
 * Description :    The function will return the current state of the 
 *                  specified state machine.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  StateMachineNo:
 *                    State machine number.
 *
 *                  StateNo:
 *                    Pointer to store the current state of the specified
 *                    state machine.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      State machine index is out of range.
 *
 *                    SES_FOUND:
 *                      Success. State number index found.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_State (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_STATE_MACHINE_TYPE StateMachineNo, SEM_STATE_TYPE *StateNo);


/*
 * Name        :    SMP_StateAll
 *
 * Description :    The function will find the current state of all state 
 *                  machines.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  StateVector:
 *                    A pointer to array to store the current state of the
 *                    state machines.
 *
 *                  MaxSize:
 *                    Specifies the maximum length of the state vector. 
 *                    Normally the length will be equal to the number of state
 *                    machines. The array is not terminated.
 *
 * Return      :    Completion code:
 *
 *                    SES_BUFFER_OVERFLOW:
 *                      The specified MaxSize is too small. The state vector 
 *                      is not valid.
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_FOUND:
 *                      Success. State numbers are found successfully.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_StateAll (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_STATE_TYPE *StateVector, SEM_STATE_MACHINE_TYPE MaxSize);


/*
 * Name        :    SMP_Machine
 *
 * Description :    The function will return the state machine index of the
 *                  specified state.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  StateNo:
 *                    State index number.
 *
 *                  StateMachineNo:
 *                    A pointer to store the found state machine index number
 *                    of the specified state.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      State index is out of range.
 *
 *                    SES_FOUND:
 *                      Success. State machine index number found.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_Machine (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_STATE_TYPE StateNo, SEM_STATE_MACHINE_TYPE *StateMachineNo);


/*
 * Name        :    SMP_ForceState
 *
 * Description :    The function is used for forcing the internal state vector
 *                  into the specified state. 
 *                  The funcition is useful, if the user wants to reestablish 
 *                  the internal state vector after a power failure of the 
 *                  target system. 
 *                  Before calling this function the first time after a power 
 *                  down, the SMP_Init function should be called to initialize 
 *                  the VS system.
 *                  The state vector established by calls to SMP_ForceState
 *                  should be stored in EEPROM before power down.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  StateNo:
 *                    State index number.
 *
 * Return      :    Completion code:
 *
 *                    SES_NOT_LOADED:
 *                      No VS System loaded or connected.
 *
 *                    SES_RANGE_ERR:
 *                      State index is out of range.
 *
 *                    SES_OKAY:
 *                      Success.
 *
 * Portability :    ANSI-C Compiler.
 */
extern unsigned char SMP_ForceState (SEM_CONTEXT VS_TQ_CONTEXT *Context, 
  SEM_STATE_TYPE StateNo);


/*
 * Name        :    SMP_Action 
 *
 * Description :    The macro will call an action function by using the
 *                  VSAction function pointer table.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
 *                  ActionNo:
 *                    Action index number.
 *
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_FUNC_OLD_NAMING_STYLE)

#if (SEM_FUNCEXPHANDLING == 0)
#define smp_action(Context, ActionNo) (*VSAction[ActionNo])(Context)
#else
#define smp_action(Context, ActionNo) VSAction(Context, ActionNo)
#endif

#else

#if (SEM_FUNCEXPHANDLING == 0)
#define SMP_Action(Context, ActionNo) (*VSAction[ActionNo])(Context)
#else
#define SMP_Action(Context, ActionNo) VSAction(Context, ActionNo)
#endif

#endif


/*
 * Name        :    SMP_TableAction 
 *
 * Description :    The macro will call an action function by using the
 *                  specified function pointer table.
 *
 * Argument    :    Context:
 *                    A pointer to a VS System context.
 *
*                   Table:
 *                    Function pointer table.
 *
 *                  ActionNo:
 *                    Action index number.
 *
 * Return      :    None.
 *
 * Portability :    ANSI-C Compiler.
 */
#if (SEM_FUNC_OLD_NAMING_STYLE)

#if (SEM_FUNCEXPHANDLING == 0)
#define smp_table_action(Context, Table, ActionNo) (* (Table)[ActionNo])(Context)
#else
#define smp_table_action(Context, Func, ActionNo) Func(Context, ActionNo)
#endif

#else

#if (SEM_FUNCEXPHANDLING == 0)
#define SMP_TableAction(Context, Table, ActionNo) (* (Table)[ActionNo])(Context)
#else
#define SMP_TableAction(Context, Func, ActionNo) Func(Context, ActionNo)
#endif

#endif

#endif