author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Fri, 13 Jan 2017 19:51:36 +0300 | |
changeset 1631 | 940e20a8865b |
parent 1573 | 6dbc61e3dd65 |
child 1903 | 084256be3658 |
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:
276
diff
changeset
|
1 |
/** |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
2 |
* Win32 specific code |
329 | 3 |
**/ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
4 |
|
205 | 5 |
#include <stdio.h> |
6 |
#include <sys/timeb.h> |
|
7 |
#include <time.h> |
|
8 |
#include <windows.h> |
|
568 | 9 |
#include <locale.h> |
205 | 10 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
11 |
|
244 | 12 |
long AtomicCompareExchange(long* atomicvar, long compared, long exchange) |
205 | 13 |
{ |
14 |
return InterlockedCompareExchange(atomicvar, exchange, compared); |
|
15 |
} |
|
954 | 16 |
CRITICAL_SECTION Atomic64CS; |
17 |
long long AtomicCompareExchange64(long long* atomicvar, long long compared, long long exchange) |
|
18 |
{ |
|
19 |
long long res; |
|
20 |
EnterCriticalSection(&Atomic64CS); |
|
21 |
res=*atomicvar; |
|
22 |
if(*atomicvar == compared){ |
|
23 |
*atomicvar = exchange; |
|
24 |
} |
|
25 |
LeaveCriticalSection(&Atomic64CS); |
|
26 |
return res; |
|
27 |
} |
|
205 | 28 |
|
29 |
struct _timeb timetmp; |
|
30 |
void PLC_GetTime(IEC_TIME *CURRENT_TIME) |
|
31 |
{ |
|
32 |
_ftime(&timetmp); |
|
329 | 33 |
|
205 | 34 |
(*CURRENT_TIME).tv_sec = timetmp.time; |
35 |
(*CURRENT_TIME).tv_nsec = timetmp.millitm * 1000000; |
|
36 |
} |
|
37 |
||
38 |
void PLC_timer_notify() |
|
39 |
{ |
|
40 |
PLC_GetTime(&__CURRENT_TIME); |
|
41 |
__run(); |
|
42 |
} |
|
43 |
||
44 |
HANDLE PLC_timer = NULL; |
|
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
484
diff
changeset
|
45 |
void PLC_SetTimer(unsigned long long next, unsigned long long period) |
205 | 46 |
{ |
229 | 47 |
LARGE_INTEGER liDueTime; |
205 | 48 |
/* arg 2 of SetWaitableTimer take 100 ns interval*/ |
49 |
liDueTime.QuadPart = next / (-100); |
|
329 | 50 |
|
685 | 51 |
if (!SetWaitableTimer(PLC_timer, &liDueTime, period<1000000?1:period/1000000, NULL, NULL, 0)) |
205 | 52 |
{ |
53 |
printf("SetWaitableTimer failed (%d)\n", GetLastError()); |
|
54 |
} |
|
229 | 55 |
} |
56 |
||
57 |
/* Variable used to stop plcloop thread */ |
|
58 |
void PlcLoop() |
|
59 |
{ |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
60 |
while(WaitForSingleObject(PLC_timer, INFINITE) == WAIT_OBJECT_0) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
61 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
62 |
PLC_timer_notify(); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
63 |
} |
205 | 64 |
} |
65 |
||
229 | 66 |
HANDLE PLC_thread; |
244 | 67 |
HANDLE debug_sem; |
329 | 68 |
HANDLE debug_wait_sem; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
69 |
HANDLE python_sem; |
329 | 70 |
HANDLE python_wait_sem; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
71 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
72 |
#define maxval(a,b) ((a>b)?a:b) |
229 | 73 |
int startPLC(int argc,char **argv) |
205 | 74 |
{ |
229 | 75 |
unsigned long thread_id = 0; |
954 | 76 |
BOOL tmp; |
568 | 77 |
setlocale(LC_NUMERIC, "C"); |
205 | 78 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
79 |
debug_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
80 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
81 |
1, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
82 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
83 |
NULL); // unnamed semaphore |
329 | 84 |
if (debug_sem == NULL) |
244 | 85 |
{ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
86 |
printf("startPLC CreateSemaphore debug_sem error: %d\n", GetLastError()); |
1573
6dbc61e3dd65
fix warning: 'return' with no value in function startPLC
ctbenergy <ewald.weinahndl@gmail.com>
parents:
1466
diff
changeset
|
87 |
return 1; |
244 | 88 |
} |
329 | 89 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
90 |
debug_wait_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
91 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
92 |
0, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
93 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
94 |
NULL); // unnamed semaphore |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
95 |
|
329 | 96 |
if (debug_wait_sem == NULL) |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
97 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
98 |
printf("startPLC CreateSemaphore debug_wait_sem error: %d\n", GetLastError()); |
1573
6dbc61e3dd65
fix warning: 'return' with no value in function startPLC
ctbenergy <ewald.weinahndl@gmail.com>
parents:
1466
diff
changeset
|
99 |
return 1; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
100 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
101 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
102 |
python_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
103 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
104 |
1, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
105 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
106 |
NULL); // unnamed semaphore |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
107 |
|
329 | 108 |
if (python_sem == NULL) |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
109 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
110 |
printf("startPLC CreateSemaphore python_sem error: %d\n", GetLastError()); |
1573
6dbc61e3dd65
fix warning: 'return' with no value in function startPLC
ctbenergy <ewald.weinahndl@gmail.com>
parents:
1466
diff
changeset
|
111 |
return 1; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
112 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
113 |
python_wait_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
114 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
115 |
0, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
116 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
117 |
NULL); // unnamed semaphore |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
118 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
119 |
|
329 | 120 |
if (python_wait_sem == NULL) |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
121 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
122 |
printf("startPLC CreateSemaphore python_wait_sem error: %d\n", GetLastError()); |
1573
6dbc61e3dd65
fix warning: 'return' with no value in function startPLC
ctbenergy <ewald.weinahndl@gmail.com>
parents:
1466
diff
changeset
|
123 |
return 1; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
124 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
125 |
|
329 | 126 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
127 |
/* Create a waitable timer */ |
685 | 128 |
timeBeginPeriod(1); |
205 | 129 |
PLC_timer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer"); |
130 |
if(NULL == PLC_timer) |
|
131 |
{ |
|
132 |
printf("CreateWaitableTimer failed (%d)\n", GetLastError()); |
|
133 |
return 1; |
|
134 |
} |
|
135 |
if( __init(argc,argv) == 0 ) |
|
136 |
{ |
|
1428
e14003eb4d42
Simplified use of runtime's global variable __common_ticktime accross extensions.
Edouard Tisserant
parents:
985
diff
changeset
|
137 |
PLC_SetTimer(common_ticktime__,common_ticktime__); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
138 |
PLC_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlcLoop, NULL, 0, &thread_id); |
205 | 139 |
} |
229 | 140 |
else{ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
141 |
return 1; |
229 | 142 |
} |
205 | 143 |
return 0; |
144 |
} |
|
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
329
diff
changeset
|
145 |
static unsigned long __debug_tick; |
244 | 146 |
|
147 |
int TryEnterDebugSection(void) |
|
148 |
{ |
|
149 |
//printf("TryEnterDebugSection\n"); |
|
469 | 150 |
if(WaitForSingleObject(debug_sem, 0) == WAIT_OBJECT_0){ |
151 |
/* Only enter if debug active */ |
|
152 |
if(__DEBUG){ |
|
153 |
return 1; |
|
154 |
} |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
155 |
ReleaseSemaphore(debug_sem, 1, NULL); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
156 |
} |
469 | 157 |
return 0; |
244 | 158 |
} |
159 |
||
160 |
void LeaveDebugSection(void) |
|
161 |
{ |
|
162 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
163 |
//printf("LeaveDebugSection\n"); |
|
164 |
} |
|
229 | 165 |
|
166 |
int stopPLC() |
|
167 |
{ |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
168 |
CloseHandle(PLC_timer); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
169 |
WaitForSingleObject(PLC_thread, INFINITE); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
170 |
__cleanup(); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
171 |
CloseHandle(debug_wait_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
172 |
CloseHandle(debug_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
173 |
CloseHandle(python_wait_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
174 |
CloseHandle(python_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
175 |
CloseHandle(PLC_thread); |
229 | 176 |
} |
177 |
||
178 |
/* from plc_debugger.c */ |
|
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
179 |
int WaitDebugData(unsigned long *tick) |
229 | 180 |
{ |
709
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
181 |
DWORD res; |
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
182 |
res = WaitForSingleObject(debug_wait_sem, INFINITE); |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
183 |
*tick = __debug_tick; |
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
184 |
/* Wait signal from PLC thread */ |
709
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
185 |
return res != WAIT_OBJECT_0; |
229 | 186 |
} |
329 | 187 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
188 |
/* Called by PLC thread when debug_publish finished |
229 | 189 |
* This is supposed to unlock debugger thread in WaitDebugData*/ |
190 |
void InitiateDebugTransfer() |
|
191 |
{ |
|
244 | 192 |
/* remember tick */ |
193 |
__debug_tick = __tick; |
|
194 |
/* signal debugger thread it can read data */ |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
195 |
ReleaseSemaphore(debug_wait_sem, 1, NULL); |
229 | 196 |
} |
244 | 197 |
|
614 | 198 |
int suspendDebug(int disable) |
469 | 199 |
{ |
244 | 200 |
/* Prevent PLC to enter debug code */ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
201 |
WaitForSingleObject(debug_sem, INFINITE); |
469 | 202 |
__DEBUG = !disable; |
484 | 203 |
if(disable) |
204 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
614 | 205 |
return 0; |
244 | 206 |
} |
207 |
||
208 |
void resumeDebug() |
|
209 |
{ |
|
290
3bd617ae7a05
Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents:
280
diff
changeset
|
210 |
__DEBUG = 1; |
244 | 211 |
/* Let PLC enter debug code */ |
212 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
213 |
} |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
214 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
215 |
/* from plc_python.c */ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
216 |
int WaitPythonCommands(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
217 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
218 |
/* Wait signal from PLC thread */ |
329 | 219 |
return WaitForSingleObject(python_wait_sem, INFINITE); |
220 |
} |
|
221 |
||
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
222 |
/* Called by PLC thread on each new python command*/ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
223 |
void UnBlockPythonCommands(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
224 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
225 |
/* signal debugger thread it can read data */ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
226 |
ReleaseSemaphore(python_wait_sem, 1, NULL); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
227 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
228 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
229 |
int TryLockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
230 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
231 |
return WaitForSingleObject(python_sem, 0) == WAIT_OBJECT_0; |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
232 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
233 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
234 |
void UnLockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
235 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
236 |
ReleaseSemaphore(python_sem, 1, NULL); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
237 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
238 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
239 |
void LockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
240 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
241 |
WaitForSingleObject(python_sem, INFINITE); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
242 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
243 |
|
1457
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
244 |
void InitRetain(void) |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
245 |
{ |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
246 |
} |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
247 |
|
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
248 |
void CleanupRetain(void) |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
249 |
{ |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
250 |
} |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
251 |
|
521
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
252 |
int CheckRetainBuffer(void) |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
253 |
{ |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
254 |
return 1; |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
255 |
} |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
256 |
|
580 | 257 |
void ValidateRetainBuffer(void) |
258 |
{ |
|
259 |
} |
|
260 |
||
261 |
void InValidateRetainBuffer(void) |
|
262 |
{ |
|
263 |
} |
|
264 |
||
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
265 |
void Retain(unsigned int offset, unsigned int count, void * p) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
266 |
{ |
681
383864958dac
commented out noisy printf in Win32 target
Edouard Tisserant
parents:
614
diff
changeset
|
267 |
/* |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
268 |
unsigned int position; |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
269 |
for(position=0; position<count; position++ ){ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
270 |
printf("%d : 0x%2.2x\n", offset+position, ((char*)p)[position]); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
271 |
} |
681
383864958dac
commented out noisy printf in Win32 target
Edouard Tisserant
parents:
614
diff
changeset
|
272 |
*/ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
273 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
274 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
275 |
void Remind(unsigned int offset, unsigned int count, void *p) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
276 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
277 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
278 |
|
1465
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
279 |
static void __attribute__((constructor)) |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
280 |
beremiz_dll_init(void) |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
281 |
{ |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
282 |
InitializeCriticalSection(&Atomic64CS); |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
283 |
|
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
284 |
} |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
285 |
|
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
286 |
static void __attribute__((destructor)) |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
287 |
beremiz_dll_destroy(void) |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
288 |
{ |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
289 |
DeleteCriticalSection(&Atomic64CS); |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
290 |
} |
9011e2ceea85
Fixed win32 runtime crashing when attempting to log before errors before PLC start. Added pictures to wxHMI and fixed it so that it loads on windows as well
Edouard Tisserant
parents:
1457
diff
changeset
|
291 |