author | Edouard Tisserant |
Thu, 08 Nov 2018 11:14:06 +0100 | |
changeset 2330 | 8c18b1a3e2bf |
parent 2174 | 55611282b909 |
child 3295 | 0375d801fff7 |
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 |
||
2174
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
57 |
int PLC_shutdown; |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
58 |
|
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
59 |
int ForceSaveRetainReq(void) { |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
60 |
return PLC_shutdown; |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
61 |
} |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
62 |
|
229 | 63 |
/* Variable used to stop plcloop thread */ |
64 |
void PlcLoop() |
|
65 |
{ |
|
2174
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
66 |
PLC_shutdown = 0; |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
67 |
while(!PLC_shutdown) { |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
68 |
if (WaitForSingleObject(PLC_timer, INFINITE) != WAIT_OBJECT_0) |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
69 |
PLC_shutdown = 1; |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
70 |
PLC_timer_notify(); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
71 |
} |
205 | 72 |
} |
73 |
||
229 | 74 |
HANDLE PLC_thread; |
244 | 75 |
HANDLE debug_sem; |
329 | 76 |
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
|
77 |
HANDLE python_sem; |
329 | 78 |
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
|
79 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
80 |
#define maxval(a,b) ((a>b)?a:b) |
229 | 81 |
int startPLC(int argc,char **argv) |
205 | 82 |
{ |
229 | 83 |
unsigned long thread_id = 0; |
954 | 84 |
BOOL tmp; |
568 | 85 |
setlocale(LC_NUMERIC, "C"); |
205 | 86 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
87 |
debug_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
88 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
89 |
1, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
90 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
91 |
NULL); // unnamed semaphore |
329 | 92 |
if (debug_sem == NULL) |
244 | 93 |
{ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
94 |
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
|
95 |
return 1; |
244 | 96 |
} |
329 | 97 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
98 |
debug_wait_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
99 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
100 |
0, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
101 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
102 |
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
|
103 |
|
329 | 104 |
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
|
105 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
106 |
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
|
107 |
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
|
108 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
109 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
110 |
python_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
111 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
112 |
1, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
113 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
114 |
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
|
115 |
|
329 | 116 |
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
|
117 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
118 |
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
|
119 |
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
|
120 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
121 |
python_wait_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
122 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
123 |
0, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
124 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
125 |
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
|
126 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
127 |
|
329 | 128 |
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
|
129 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
130 |
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
|
131 |
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
|
132 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
133 |
|
329 | 134 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
135 |
/* Create a waitable timer */ |
685 | 136 |
timeBeginPeriod(1); |
205 | 137 |
PLC_timer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer"); |
138 |
if(NULL == PLC_timer) |
|
139 |
{ |
|
140 |
printf("CreateWaitableTimer failed (%d)\n", GetLastError()); |
|
141 |
return 1; |
|
142 |
} |
|
143 |
if( __init(argc,argv) == 0 ) |
|
144 |
{ |
|
1428
e14003eb4d42
Simplified use of runtime's global variable __common_ticktime accross extensions.
Edouard Tisserant
parents:
985
diff
changeset
|
145 |
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
|
146 |
PLC_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlcLoop, NULL, 0, &thread_id); |
205 | 147 |
} |
229 | 148 |
else{ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
149 |
return 1; |
229 | 150 |
} |
205 | 151 |
return 0; |
152 |
} |
|
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
|
153 |
static unsigned long __debug_tick; |
244 | 154 |
|
155 |
int TryEnterDebugSection(void) |
|
156 |
{ |
|
157 |
//printf("TryEnterDebugSection\n"); |
|
469 | 158 |
if(WaitForSingleObject(debug_sem, 0) == WAIT_OBJECT_0){ |
159 |
/* Only enter if debug active */ |
|
160 |
if(__DEBUG){ |
|
161 |
return 1; |
|
162 |
} |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
163 |
ReleaseSemaphore(debug_sem, 1, NULL); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
164 |
} |
469 | 165 |
return 0; |
244 | 166 |
} |
167 |
||
168 |
void LeaveDebugSection(void) |
|
169 |
{ |
|
170 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
171 |
//printf("LeaveDebugSection\n"); |
|
172 |
} |
|
229 | 173 |
|
174 |
int stopPLC() |
|
175 |
{ |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
176 |
CloseHandle(PLC_timer); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
177 |
WaitForSingleObject(PLC_thread, INFINITE); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
178 |
__cleanup(); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
179 |
CloseHandle(debug_wait_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
180 |
CloseHandle(debug_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
181 |
CloseHandle(python_wait_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
182 |
CloseHandle(python_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
183 |
CloseHandle(PLC_thread); |
229 | 184 |
} |
185 |
||
186 |
/* from plc_debugger.c */ |
|
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
187 |
int WaitDebugData(unsigned long *tick) |
229 | 188 |
{ |
709
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
189 |
DWORD res; |
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
190 |
res = WaitForSingleObject(debug_wait_sem, INFINITE); |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
191 |
*tick = __debug_tick; |
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
192 |
/* Wait signal from PLC thread */ |
709
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
193 |
return res != WAIT_OBJECT_0; |
229 | 194 |
} |
329 | 195 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
196 |
/* Called by PLC thread when debug_publish finished |
229 | 197 |
* This is supposed to unlock debugger thread in WaitDebugData*/ |
198 |
void InitiateDebugTransfer() |
|
199 |
{ |
|
244 | 200 |
/* remember tick */ |
201 |
__debug_tick = __tick; |
|
202 |
/* 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
|
203 |
ReleaseSemaphore(debug_wait_sem, 1, NULL); |
229 | 204 |
} |
244 | 205 |
|
614 | 206 |
int suspendDebug(int disable) |
469 | 207 |
{ |
244 | 208 |
/* 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
|
209 |
WaitForSingleObject(debug_sem, INFINITE); |
469 | 210 |
__DEBUG = !disable; |
484 | 211 |
if(disable) |
212 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
614 | 213 |
return 0; |
244 | 214 |
} |
215 |
||
216 |
void resumeDebug() |
|
217 |
{ |
|
290
3bd617ae7a05
Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents:
280
diff
changeset
|
218 |
__DEBUG = 1; |
244 | 219 |
/* Let PLC enter debug code */ |
220 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
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 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
223 |
/* 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
|
224 |
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
|
225 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
226 |
/* Wait signal from PLC thread */ |
329 | 227 |
return WaitForSingleObject(python_wait_sem, INFINITE); |
228 |
} |
|
229 |
||
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
230 |
/* 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
|
231 |
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
|
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 |
/* 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
|
234 |
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
|
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 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
237 |
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
|
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 |
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
|
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 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
242 |
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
|
243 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
244 |
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
|
245 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
246 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
247 |
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
|
248 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
249 |
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
|
250 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
251 |
|
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
|
252 |
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
|
253 |
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
|
254 |
{ |
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
|
255 |
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
|
256 |
|
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
|
257 |
} |
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
|
258 |
|
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
|
259 |
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
|
260 |
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
|
261 |
{ |
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
|
262 |
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
|
263 |
} |
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
|
264 |