3 **/ |
3 **/ |
4 |
4 |
5 #include <locale.h> |
5 #include <locale.h> |
6 #include "iec_types.h" |
6 #include "iec_types.h" |
7 /* |
7 /* |
8 * Prototypes of functions provied by generated C softPLC |
8 * Prototypes of functions provided by generated C softPLC |
9 **/ |
9 **/ |
10 void config_run__(int tick); |
10 void config_run__(unsigned long tick); |
11 void config_init__(void); |
11 void config_init__(void); |
12 |
12 |
13 /* |
13 /* |
14 * Prototypes of functions provied by generated target C code |
14 * Prototypes of functions provided by generated target C code |
15 * */ |
15 * */ |
16 void __init_debug(void); |
16 void __init_debug(void); |
17 void __cleanup_debug(void); |
17 void __cleanup_debug(void); |
18 /*void __retrieve_debug(void);*/ |
18 /*void __retrieve_debug(void);*/ |
19 void __publish_debug(void); |
19 void __publish_debug(void); |
20 |
20 |
21 /* |
21 /* |
22 * Variables used by generated C softPLC and plugins |
22 * Variables used by generated C softPLC and plugins |
23 **/ |
23 **/ |
24 IEC_TIME __CURRENT_TIME; |
24 IEC_TIME __CURRENT_TIME; |
25 IEC_BOOL __DEBUG; |
25 IEC_BOOL __DEBUG = 0; |
26 int __tick = -1; |
26 unsigned long __tick = -1; |
|
27 |
|
28 /* |
|
29 * Variable generated by C softPLC and plugins |
|
30 **/ |
|
31 extern unsigned long greatest_tick_count__; |
27 |
32 |
28 /* Help to quit cleanly when init fail at a certain level */ |
33 /* Help to quit cleanly when init fail at a certain level */ |
29 static int init_level = 0; |
34 static int init_level = 0; |
30 |
35 |
31 /* |
36 /* |
83 static int calibration_count = NOT_CALIBRATED; |
90 static int calibration_count = NOT_CALIBRATED; |
84 static IEC_TIME cal_begin; |
91 static IEC_TIME cal_begin; |
85 static long long Tsync = 0; |
92 static long long Tsync = 0; |
86 static long long FreqCorr = 0; |
93 static long long FreqCorr = 0; |
87 static int Nticks = 0; |
94 static int Nticks = 0; |
88 static int last_tick = 0; |
95 static unsigned long last_tick = 0; |
89 static long long Ttick = 0; |
96 static long long Ttick = 0; |
90 #define mod %% |
97 #define mod %% |
91 /* |
98 /* |
92 * Call this on each external sync, |
99 * Call this on each external sync, |
93 * @param sync_align_ratio 0->100 : align ratio, < 0 : no align, calibrate period |
100 * @param sync_align_ratio 0->100 : align ratio, < 0 : no align, calibrate period |