equal
deleted
inserted
replaced
22 /* |
22 /* |
23 * Functions and variables provied by generated C softPLC |
23 * Functions and variables provied by generated C softPLC |
24 **/ |
24 **/ |
25 void config_run__(int tick); |
25 void config_run__(int tick); |
26 void config_init__(void); |
26 void config_init__(void); |
|
27 void __init_debug(void); |
|
28 void __cleanup_debug(void); |
|
29 |
27 |
30 |
28 /* |
31 /* |
29 * Functions and variables to export to generated C softPLC and plugins |
32 * Functions and variables to export to generated C softPLC and plugins |
30 **/ |
33 **/ |
31 |
34 |
32 IEC_TIME __CURRENT_TIME; |
35 IEC_TIME __CURRENT_TIME; |
33 int __tick = 0; |
36 int __tick = 0; |
34 |
37 |
35 static int init_level = 0; |
38 static int init_level = 0; |
36 static int Debugging = 1; |
39 static int Debugging = 0; |
|
40 static int WasDebugging = 0; |
|
41 void AbortDebug(); |
37 |
42 |
38 /* |
43 /* |
39 * Prototypes of functions exported by plugins |
44 * Prototypes of functions exported by plugins |
40 **/ |
45 **/ |
41 %(calls_prototypes)s |
46 %(calls_prototypes)s |
50 if(Debugging) __retrieve_debug(); |
55 if(Debugging) __retrieve_debug(); |
51 |
56 |
52 config_run__(__tick); |
57 config_run__(__tick); |
53 |
58 |
54 if(Debugging) __publish_debug(); |
59 if(Debugging) __publish_debug(); |
|
60 else if(WasDebugging) AbortDebug(); |
|
61 WasDebugging = Debugging; |
55 |
62 |
56 %(publish_calls)s |
63 %(publish_calls)s |
57 |
64 |
58 __tick++; |
65 __tick++; |
59 } |
66 } |
64 **/ |
71 **/ |
65 int __init(int argc,char **argv) |
72 int __init(int argc,char **argv) |
66 { |
73 { |
67 int res; |
74 int res; |
68 config_init__(); |
75 config_init__(); |
|
76 __init_debug(); |
69 %(init_calls)s |
77 %(init_calls)s |
70 return 0; |
78 return 0; |
71 } |
79 } |
72 /* |
80 /* |
73 * Calls plugin cleanup proc. |
81 * Calls plugin cleanup proc. |
74 **/ |
82 **/ |
75 void __cleanup() |
83 void __cleanup() |
76 { |
84 { |
77 %(cleanup_calls)s |
85 %(cleanup_calls)s |
|
86 __cleanup_debug(); |
78 } |
87 } |
79 |
88 |
80 |
89 |
81 void PLC_GetTime(IEC_TIME *CURRENT_TIME); |
90 void PLC_GetTime(IEC_TIME *CURRENT_TIME); |
82 void PLC_SetTimer(long long next, long long period); |
91 void PLC_SetTimer(long long next, long long period); |
162 PLC_SetTimer(Tcorr - elapsed, PeriodicTcorr); |
171 PLC_SetTimer(Tcorr - elapsed, PeriodicTcorr); |
163 } |
172 } |
164 } |
173 } |
165 } |
174 } |
166 |
175 |
167 int suspendDebug() |
176 extern int WaitDebugData(); |
|
177 void suspendDebug() |
168 { |
178 { |
169 /* Prevent PLC to enter debug code */ |
179 /* Prevent PLC to enter debug code */ |
170 Debugging = 0; |
180 Debugging = 0; |
|
181 /* wait next tick end to be sure*/ |
|
182 WaitDebugData(); |
171 } |
183 } |
172 |
184 |
173 int resumeDebug() |
185 void resumeDebug() |
174 { |
186 { |
175 /* Let PLC enter debug code */ |
187 /* Let PLC enter debug code */ |
176 Debugging = 1; |
188 Debugging = 1; |
177 } |
189 } |