author | laurent |
Wed, 18 Jul 2012 00:44:29 +0200 | |
changeset 789 | b1b1a8f85e2f |
parent 568 | 20a223828a06 |
permissions | -rw-r--r-- |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
1 |
/** |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
2 |
* Code common to all C targets |
332 | 3 |
**/ |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
4 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
5 |
#include "iec_types.h" |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
6 |
/* |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
7 |
* Prototypes of functions provided by generated C softPLC |
332 | 8 |
**/ |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
9 |
void config_run__(unsigned long tick); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
10 |
void config_init__(void); |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
11 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
12 |
/* |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
13 |
* Prototypes of functions provided by generated target C code |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
14 |
* */ |
235 | 15 |
void __init_debug(void); |
16 |
void __cleanup_debug(void); |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
17 |
/*void __retrieve_debug(void);*/ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
18 |
void __publish_debug(void); |
235 | 19 |
|
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
20 |
/* |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
21 |
* Variables used by generated C softPLC and plugins |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
22 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
23 |
IEC_TIME __CURRENT_TIME; |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
24 |
IEC_BOOL __DEBUG = 0; |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
423
diff
changeset
|
25 |
unsigned long __tick = 0; |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
26 |
|
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
27 |
/* |
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
28 |
* Variable generated by C softPLC and plugins |
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
29 |
**/ |
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
30 |
extern unsigned long greatest_tick_count__; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
31 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
32 |
/* Help to quit cleanly when init fail at a certain level */ |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
33 |
static int init_level = 0; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
34 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
35 |
/* |
332 | 36 |
* Prototypes of functions exported by plugins |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
37 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
38 |
%(calls_prototypes)s |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
39 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
40 |
/* |
332 | 41 |
* Retrieve input variables, run PLC and publish output variables |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
42 |
**/ |
423 | 43 |
void __run(void) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
44 |
{ |
236 | 45 |
__tick++; |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
46 |
if (greatest_tick_count__) |
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
47 |
__tick %%= greatest_tick_count__; |
236 | 48 |
|
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
49 |
%(retrieve_calls)s |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
50 |
|
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
51 |
/*__retrieve_debug();*/ |
332 | 52 |
|
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
53 |
config_run__(__tick); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
54 |
|
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
55 |
__publish_debug(); |
332 | 56 |
|
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
57 |
%(publish_calls)s |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
58 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
59 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
60 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
61 |
/* |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
62 |
* Initialize variables according to PLC's default values, |
332 | 63 |
* and then init plugins with that values |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
64 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
65 |
int __init(int argc,char **argv) |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
66 |
{ |
386 | 67 |
int res = 0; |
423 | 68 |
init_level = 0; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
69 |
config_init__(); |
235 | 70 |
__init_debug(); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
71 |
%(init_calls)s |
386 | 72 |
return res; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
73 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
74 |
/* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
75 |
* Calls plugin cleanup proc. |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
76 |
**/ |
423 | 77 |
void __cleanup(void) |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
78 |
{ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
79 |
%(cleanup_calls)s |
235 | 80 |
__cleanup_debug(); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
81 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
82 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
83 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
84 |
void PLC_GetTime(IEC_TIME *CURRENT_TIME); |
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
446
diff
changeset
|
85 |
void PLC_SetTimer(unsigned long long next, unsigned long long period); |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
86 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
87 |
#define CALIBRATED -2 |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
88 |
#define NOT_CALIBRATED -1 |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
89 |
static int calibration_count = NOT_CALIBRATED; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
90 |
static IEC_TIME cal_begin; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
91 |
static long long Tsync = 0; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
92 |
static long long FreqCorr = 0; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
93 |
static int Nticks = 0; |
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
94 |
static unsigned long last_tick = 0; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
95 |
static long long Ttick = 0; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
96 |
#define mod %% |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
97 |
/* |
332 | 98 |
* Call this on each external sync, |
99 |
* @param sync_align_ratio 0->100 : align ratio, < 0 : no align, calibrate period |
|
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
100 |
**/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
101 |
void align_tick(int sync_align_ratio) |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
102 |
{ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
103 |
/* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
104 |
printf("align_tick(%%d)\n", calibrate); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
105 |
*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
106 |
if(sync_align_ratio < 0){ /* Calibration */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
107 |
if(calibration_count == CALIBRATED) |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
108 |
/* Re-calibration*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
109 |
calibration_count = NOT_CALIBRATED; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
110 |
if(calibration_count == NOT_CALIBRATED) |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
111 |
/* Calibration start, get time*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
112 |
PLC_GetTime(&cal_begin); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
113 |
calibration_count++; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
114 |
}else{ /* do alignment (if possible) */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
115 |
if(calibration_count >= 0){ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
116 |
/* End of calibration */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
117 |
/* Get final time */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
118 |
IEC_TIME cal_end; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
119 |
PLC_GetTime(&cal_end); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
120 |
/*adjust calibration_count*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
121 |
calibration_count++; |
332 | 122 |
/* compute mean of Tsync, over calibration period */ |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
123 |
Tsync = ((long long)(cal_end.tv_sec - cal_begin.tv_sec) * (long long)1000000000 + |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
124 |
(cal_end.tv_nsec - cal_begin.tv_nsec)) / calibration_count; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
125 |
if( (Nticks = (Tsync / Ttick)) > 0){ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
126 |
FreqCorr = (Tsync mod Ttick); /* to be divided by Nticks */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
127 |
}else{ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
128 |
FreqCorr = Tsync - (Ttick mod Tsync); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
129 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
130 |
/* |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
131 |
printf("Tsync = %%ld\n", Tsync); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
132 |
printf("calibration_count = %%d\n", calibration_count); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
133 |
printf("Nticks = %%d\n", Nticks); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
134 |
*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
135 |
calibration_count = CALIBRATED; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
136 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
137 |
if(calibration_count == CALIBRATED){ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
138 |
/* Get Elapsed time since last PLC tick (__CURRENT_TIME) */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
139 |
IEC_TIME now; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
140 |
long long elapsed; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
141 |
long long Tcorr; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
142 |
long long PhaseCorr; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
143 |
long long PeriodicTcorr; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
144 |
PLC_GetTime(&now); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
145 |
elapsed = (now.tv_sec - __CURRENT_TIME.tv_sec) * 1000000000 + now.tv_nsec - __CURRENT_TIME.tv_nsec; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
146 |
if(Nticks > 0){ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
147 |
PhaseCorr = elapsed - (Ttick + FreqCorr/Nticks)*sync_align_ratio/100; /* to be divided by Nticks */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
148 |
Tcorr = Ttick + (PhaseCorr + FreqCorr) / Nticks; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
149 |
if(Nticks < 2){ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
150 |
/* When Sync source period is near Tick time */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
151 |
/* PhaseCorr may not be applied to Periodic time given to timer */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
152 |
PeriodicTcorr = Ttick + FreqCorr / Nticks; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
153 |
}else{ |
332 | 154 |
PeriodicTcorr = Tcorr; |
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
155 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
156 |
}else if(__tick > last_tick){ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
157 |
last_tick = __tick; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
158 |
PhaseCorr = elapsed - (Tsync*sync_align_ratio/100); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
159 |
PeriodicTcorr = Tcorr = Ttick + PhaseCorr + FreqCorr; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
160 |
}else{ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
161 |
/*PLC did not run meanwhile. Nothing to do*/ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
162 |
return; |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
163 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
164 |
/* DO ALIGNEMENT */ |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
165 |
PLC_SetTimer(Tcorr - elapsed, PeriodicTcorr); |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
166 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
167 |
} |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
diff
changeset
|
168 |
} |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
169 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
170 |
/** |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
171 |
* Prototypes for function provided by arch-specific code (main) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
172 |
* is concatained hereafter |
332 | 173 |
**/ |