author | lbessard |
Mon, 30 Jun 2008 14:28:48 +0200 | |
changeset 186 | ed2a408d79b6 |
parent 110 | a05e8b30c024 |
child 196 | 93d06827e31b |
permissions | -rw-r--r-- |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
1 |
#include <stdio.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
2 |
#include <sys/timeb.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
3 |
#include <time.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
4 |
#include <windows.h> |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
5 |
|
110
a05e8b30c024
Fixed way apps are launched in parralel with single log window... Tested in win32 only.
etisserant
parents:
79
diff
changeset
|
6 |
int localcount = 0; |
a05e8b30c024
Fixed way apps are launched in parralel with single log window... Tested in win32 only.
etisserant
parents:
79
diff
changeset
|
7 |
|
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
8 |
void timer_notify() |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
9 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
10 |
struct _timeb timebuffer; |
110
a05e8b30c024
Fixed way apps are launched in parralel with single log window... Tested in win32 only.
etisserant
parents:
79
diff
changeset
|
11 |
if(++localcount % 50 == 0){ |
a05e8b30c024
Fixed way apps are launched in parralel with single log window... Tested in win32 only.
etisserant
parents:
79
diff
changeset
|
12 |
printf("PLC tick : %d\n",localcount); |
a05e8b30c024
Fixed way apps are launched in parralel with single log window... Tested in win32 only.
etisserant
parents:
79
diff
changeset
|
13 |
fflush(stdout); |
a05e8b30c024
Fixed way apps are launched in parralel with single log window... Tested in win32 only.
etisserant
parents:
79
diff
changeset
|
14 |
} |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
15 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
16 |
_ftime( &timebuffer ); |
75 | 17 |
__CURRENT_TIME.tv_sec = timebuffer.time; |
18 |
__CURRENT_TIME.tv_nsec = timebuffer.millitm * 1000000; |
|
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
19 |
__run(); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
20 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
21 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
22 |
int main(int argc,char **argv) |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
23 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
24 |
HANDLE hTimer = NULL; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
25 |
LARGE_INTEGER liDueTime; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
26 |
|
75 | 27 |
liDueTime.QuadPart = -10000 * maxval(common_ticktime__,1); |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
28 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
29 |
// Create a waitable timer. |
75 | 30 |
hTimer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer"); |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
31 |
if (NULL == hTimer) |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
32 |
{ |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
33 |
printf("CreateWaitableTimer failed (%d)\n", GetLastError()); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
34 |
return 1; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
35 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
36 |
|
57 | 37 |
if( __init(argc,argv) == 0 ){ |
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
38 |
|
75 | 39 |
printf("Tick Time : %d ms\n", common_ticktime__); |
57 | 40 |
// Set a timer |
41 |
if (!SetWaitableTimer(hTimer, &liDueTime, common_ticktime__, NULL, NULL, 0)) |
|
42 |
{ |
|
43 |
printf("SetWaitableTimer failed (%d)\n", GetLastError()); |
|
44 |
return 2; |
|
45 |
} |
|
46 |
||
47 |
while(1){ |
|
48 |
// Wait for the timer. |
|
49 |
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0) |
|
50 |
{ |
|
51 |
printf("WaitForSingleObject failed (%d)\n", GetLastError()); |
|
52 |
break; |
|
53 |
} |
|
79 | 54 |
if (kbhit()) |
55 |
{ |
|
56 |
printf("Finishing\n"); |
|
57 |
break; |
|
58 |
} |
|
57 | 59 |
timer_notify(); |
60 |
} |
|
49
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
61 |
} |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
62 |
__cleanup(); |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
63 |
|
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
64 |
return 0; |
45dc6a944ab6
On the long wat towards generated code comilation...
etisserant
parents:
diff
changeset
|
65 |
} |