author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Tue, 20 Aug 2024 00:31:45 +0200 | |
changeset 3971 | f1c673cddc1f |
parent 3947 | 9b5cb90297e4 |
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 |
|
3296
3bcd5ec67521
Win32 runtime: fix build with gcc 9.3.0 from msys2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3295
diff
changeset
|
29 |
struct timeb timetmp; |
205 | 30 |
void PLC_GetTime(IEC_TIME *CURRENT_TIME) |
31 |
{ |
|
3296
3bcd5ec67521
Win32 runtime: fix build with gcc 9.3.0 from msys2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3295
diff
changeset
|
32 |
ftime(&timetmp); |
329 | 33 |
|
205 | 34 |
(*CURRENT_TIME).tv_sec = timetmp.time; |
35 |
(*CURRENT_TIME).tv_nsec = timetmp.millitm * 1000000; |
|
36 |
} |
|
37 |
||
38 |
HANDLE PLC_timer = NULL; |
|
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
484
diff
changeset
|
39 |
void PLC_SetTimer(unsigned long long next, unsigned long long period) |
205 | 40 |
{ |
229 | 41 |
LARGE_INTEGER liDueTime; |
205 | 42 |
/* arg 2 of SetWaitableTimer take 100 ns interval*/ |
43 |
liDueTime.QuadPart = next / (-100); |
|
329 | 44 |
|
685 | 45 |
if (!SetWaitableTimer(PLC_timer, &liDueTime, period<1000000?1:period/1000000, NULL, NULL, 0)) |
205 | 46 |
{ |
47 |
printf("SetWaitableTimer failed (%d)\n", GetLastError()); |
|
48 |
} |
|
229 | 49 |
} |
50 |
||
2174
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
51 |
int PLC_shutdown; |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
52 |
|
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
53 |
int ForceSaveRetainReq(void) { |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
54 |
return PLC_shutdown; |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
55 |
} |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
56 |
|
229 | 57 |
/* Variable used to stop plcloop thread */ |
58 |
void PlcLoop() |
|
59 |
{ |
|
2174
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
60 |
PLC_shutdown = 0; |
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
61 |
while(!PLC_shutdown) { |
3850
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
62 |
if (WaitForSingleObject(PLC_timer, INFINITE) != WAIT_OBJECT_0){ |
2174
55611282b909
Use the same retain implementation for Win32 targets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
63 |
PLC_shutdown = 1; |
3850
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
64 |
break; |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
65 |
} |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
66 |
PLC_GetTime(&__CURRENT_TIME); |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
67 |
__run(); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
68 |
} |
205 | 69 |
} |
70 |
||
229 | 71 |
HANDLE PLC_thread; |
244 | 72 |
HANDLE debug_sem; |
329 | 73 |
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
|
74 |
HANDLE python_sem; |
329 | 75 |
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
|
76 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
77 |
#define maxval(a,b) ((a>b)?a:b) |
229 | 78 |
int startPLC(int argc,char **argv) |
205 | 79 |
{ |
229 | 80 |
unsigned long thread_id = 0; |
954 | 81 |
BOOL tmp; |
205 | 82 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
83 |
debug_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
84 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
85 |
1, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
86 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
87 |
NULL); // unnamed semaphore |
329 | 88 |
if (debug_sem == NULL) |
244 | 89 |
{ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
90 |
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
|
91 |
return 1; |
244 | 92 |
} |
329 | 93 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
94 |
debug_wait_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
95 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
96 |
0, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
97 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
98 |
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
|
99 |
|
329 | 100 |
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
|
101 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
102 |
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
|
103 |
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
|
104 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
105 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
106 |
python_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
107 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
108 |
1, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
109 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
110 |
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
|
111 |
|
329 | 112 |
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
|
113 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
114 |
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
|
115 |
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
|
116 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
117 |
python_wait_sem = CreateSemaphore( |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
118 |
NULL, // default security attributes |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
119 |
0, // initial count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
120 |
1, // maximum count |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
121 |
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
|
122 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
123 |
|
329 | 124 |
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
|
125 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
129 |
|
329 | 130 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
131 |
/* Create a waitable timer */ |
685 | 132 |
timeBeginPeriod(1); |
205 | 133 |
PLC_timer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer"); |
134 |
if(NULL == PLC_timer) |
|
135 |
{ |
|
136 |
printf("CreateWaitableTimer failed (%d)\n", GetLastError()); |
|
137 |
return 1; |
|
138 |
} |
|
139 |
if( __init(argc,argv) == 0 ) |
|
140 |
{ |
|
1428
e14003eb4d42
Simplified use of runtime's global variable __common_ticktime accross extensions.
Edouard Tisserant
parents:
985
diff
changeset
|
141 |
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
|
142 |
PLC_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlcLoop, NULL, 0, &thread_id); |
205 | 143 |
} |
229 | 144 |
else{ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
145 |
return 1; |
229 | 146 |
} |
205 | 147 |
return 0; |
148 |
} |
|
3947
9b5cb90297e4
All Runtimes: Now sizeof(tick)=4 on all platforms (unsigned int).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3850
diff
changeset
|
149 |
static unsigned int __debug_tick; |
244 | 150 |
|
151 |
int TryEnterDebugSection(void) |
|
152 |
{ |
|
153 |
//printf("TryEnterDebugSection\n"); |
|
469 | 154 |
if(WaitForSingleObject(debug_sem, 0) == WAIT_OBJECT_0){ |
155 |
/* Only enter if debug active */ |
|
156 |
if(__DEBUG){ |
|
157 |
return 1; |
|
158 |
} |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
159 |
ReleaseSemaphore(debug_sem, 1, NULL); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
160 |
} |
469 | 161 |
return 0; |
244 | 162 |
} |
163 |
||
164 |
void LeaveDebugSection(void) |
|
165 |
{ |
|
166 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
167 |
//printf("LeaveDebugSection\n"); |
|
168 |
} |
|
229 | 169 |
|
170 |
int stopPLC() |
|
171 |
{ |
|
3850
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
172 |
|
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
173 |
PLC_shutdown = 1; |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
174 |
// force last wakeup of PLC thread |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
175 |
SetWaitableTimer(PLC_timer, 0, 0, NULL, NULL, 0); |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
176 |
// wait end of PLC thread |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
177 |
WaitForSingleObject(PLC_thread, INFINITE); |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
178 |
|
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
179 |
__cleanup(); |
722846bd6680
Win32 rutime: fix PLC Stop freezing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3731
diff
changeset
|
180 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
181 |
CloseHandle(PLC_timer); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
182 |
CloseHandle(debug_wait_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
183 |
CloseHandle(debug_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
184 |
CloseHandle(python_wait_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
185 |
CloseHandle(python_sem); |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
469
diff
changeset
|
186 |
CloseHandle(PLC_thread); |
229 | 187 |
} |
188 |
||
189 |
/* from plc_debugger.c */ |
|
3947
9b5cb90297e4
All Runtimes: Now sizeof(tick)=4 on all platforms (unsigned int).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3850
diff
changeset
|
190 |
int WaitDebugData(unsigned int *tick) |
229 | 191 |
{ |
709
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
192 |
DWORD res; |
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
193 |
res = WaitForSingleObject(debug_wait_sem, INFINITE); |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
194 |
*tick = __debug_tick; |
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
195 |
/* Wait signal from PLC thread */ |
709
fe65601bd983
Fixing bug in debugger sending wrong tick with values
laurent
parents:
685
diff
changeset
|
196 |
return res != WAIT_OBJECT_0; |
229 | 197 |
} |
329 | 198 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
199 |
/* Called by PLC thread when debug_publish finished |
229 | 200 |
* This is supposed to unlock debugger thread in WaitDebugData*/ |
201 |
void InitiateDebugTransfer() |
|
202 |
{ |
|
244 | 203 |
/* remember tick */ |
204 |
__debug_tick = __tick; |
|
205 |
/* 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
|
206 |
ReleaseSemaphore(debug_wait_sem, 1, NULL); |
229 | 207 |
} |
244 | 208 |
|
614 | 209 |
int suspendDebug(int disable) |
469 | 210 |
{ |
244 | 211 |
/* 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
|
212 |
WaitForSingleObject(debug_sem, INFINITE); |
469 | 213 |
__DEBUG = !disable; |
484 | 214 |
if(disable) |
215 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
614 | 216 |
return 0; |
244 | 217 |
} |
218 |
||
219 |
void resumeDebug() |
|
220 |
{ |
|
290
3bd617ae7a05
Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents:
280
diff
changeset
|
221 |
__DEBUG = 1; |
244 | 222 |
/* Let PLC enter debug code */ |
223 |
ReleaseSemaphore(debug_sem, 1, NULL); |
|
224 |
} |
|
280
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 |
/* 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
|
227 |
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
|
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 |
/* Wait signal from PLC thread */ |
329 | 230 |
return WaitForSingleObject(python_wait_sem, INFINITE); |
231 |
} |
|
232 |
||
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
233 |
/* 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
|
234 |
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
|
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 |
/* 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
|
237 |
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
|
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 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
240 |
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
|
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 |
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
|
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 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
245 |
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
|
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 |
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
|
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 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
250 |
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
|
251 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
252 |
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
|
253 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
276
diff
changeset
|
254 |
|
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
|
255 |
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
|
256 |
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
|
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 |
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
|
259 |
|
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 |
} |
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 |
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
|
263 |
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
|
264 |
{ |
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
|
265 |
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
|
266 |
} |
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
|
267 |
|
3295
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
268 |
struct RT_to_nRT_signal_s { |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
269 |
HANDLE sem; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
270 |
}; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
271 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
272 |
typedef struct RT_to_nRT_signal_s RT_to_nRT_signal_t; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
273 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
274 |
#define _LogAndReturnNull(text) \ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
275 |
{\ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
276 |
char mstr[256] = text " for ";\ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
277 |
strncat(mstr, name, 255);\ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
278 |
LogMessage(LOG_CRITICAL, mstr, strlen(mstr));\ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
279 |
return NULL;\ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
280 |
} |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
281 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
282 |
void *create_RT_to_nRT_signal(char* name){ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
283 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)malloc(sizeof(RT_to_nRT_signal_t)); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
284 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
285 |
if(!sig) |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
286 |
_LogAndReturnNull("Failed allocating memory for RT_to_nRT signal"); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
287 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
288 |
sig->sem = CreateSemaphore( |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
289 |
NULL, // default security attributes |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
290 |
1, // initial count |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
291 |
1, // maximum count |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
292 |
NULL); // unnamed semaphore |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
293 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
294 |
if(sig->sem == NULL) |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
295 |
{ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
296 |
char mstr[256]; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
297 |
snprintf(mstr, 255, "startPLC CreateSemaphore %s error: %d\n", name, GetLastError()); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
298 |
LogMessage(LOG_CRITICAL, mstr, strlen(mstr)); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
299 |
return NULL; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
300 |
} |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
301 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
302 |
return (void*)sig; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
303 |
} |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
304 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
305 |
void delete_RT_to_nRT_signal(void* handle){ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
306 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
307 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
308 |
CloseHandle(python_sem); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
309 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
310 |
free(sig); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
311 |
} |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
312 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
313 |
int wait_RT_to_nRT_signal(void* handle){ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
314 |
int ret; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
315 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
316 |
return WaitForSingleObject(sig->sem, INFINITE); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
317 |
} |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
318 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
319 |
int unblock_RT_to_nRT_signal(void* handle){ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
320 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle; |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
321 |
return ReleaseSemaphore(sig->sem, 1, NULL); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
322 |
} |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
323 |
|
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
324 |
void nRT_reschedule(void){ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
325 |
SwitchToThread(); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
326 |
} |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2174
diff
changeset
|
327 |