Commit e7083f64 authored by Claes's avatar Claes

Misc minor changes

parent 6546dcec
......@@ -21,6 +21,7 @@
#include <math.h>
#include <stdlib.h>
#include <float.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_miscellaneousclasses.h"
......@@ -29,6 +30,7 @@
#include "co_time.h"
#define BASE_SPEED 10
#define MAX_ANGLE 60
static float my_random() {
static unsigned int seed = 100;
......@@ -66,7 +68,7 @@ void Misc_PingPongFo_init( pwr_sClass_Misc_PingPongFo *o)
void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
{
pwr_sClass_Misc_PingPong *co = (pwr_sClass_Misc_PingPong *) o->PlcConnectP;
if ( !co)
if ( !co || fabs(co->Width < FLT_EPSILON))
return;
co->XCoordinate += co->Speed * tp->PlcThread->ScanTime * cos(co->Direction/180*M_PI);
......@@ -81,7 +83,7 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
co->RightPos = *co->RightKnobPtr;
else
co->RightPos = co->RightSlider;
switch ( co->Mode) {
case pwr_eMisc_PingPongModeEnum_Idle: {
if ( co->OldMode != co->Mode) {
......@@ -100,7 +102,7 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
co->Direction = -co->Direction + 180 + my_random() * 10;
else
co->Direction = -co->Direction - 180 + my_random() * 10;
if ( fabs(co->Direction) > 45)
if ( fabs(co->Direction) > MAX_ANGLE)
co->Direction = my_random() * 10;
}
......@@ -151,7 +153,7 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
co->Direction = -co->Direction + 180 + my_random() * 20;
else
co->Direction = -co->Direction - 180 + my_random() * 20;
if ( fabs(co->Direction) > 45)
if ( fabs(co->Direction) > MAX_ANGLE)
co->Direction = my_random() * 10;
co->Speed = BASE_SPEED * co->LeftLevel * co->LevelFactor;
}
......@@ -212,7 +214,8 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
break;
}
case pwr_eMisc_PingPongModeEnum_TwoPlayers: {
if ( co->OldMode != co->Mode) {
if ( co->OldMode != co->Mode || co->NewMatch) {
co->NewMatch = 0;
co->State = pwr_eMisc_PingPongStateEnum_ServeRight;
time_GetTime( &co->StateShiftTime);
co->LeftScore = 0;
......@@ -239,7 +242,7 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
co->Direction = -co->Direction + 180 + my_random() * 20;
else
co->Direction = -co->Direction - 180 + my_random() * 20;
if ( fabs(co->Direction) > 45)
if ( fabs(co->Direction) > MAX_ANGLE)
co->Direction = my_random() * 10;
co->Speed = BASE_SPEED * co->LeftLevel * co->LevelFactor;
}
......@@ -323,5 +326,21 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
break;
}
}
float height;
if ( fabs(co->Direction) < 90) {
if ( co->XCoordinate < co->Width * 3/4)
height = (1 - co->XCoordinate / co->Width * 4 / 3);
else
height = ((co->XCoordinate - co->Width * 3/4) / co->Width * 4);
}
else {
if ( co->XCoordinate < co->Width / 4)
height = (1 - co->XCoordinate / co->Width * 4);
else
height = ((co->XCoordinate - co->Width / 4) / co->Width * 4/3);
}
co->XShadow = co->XCoordinate + height * 4;
co->YShadow = co->YCoordinate + height * 1;
co->OldMode = co->Mode;
}
......@@ -1150,7 +1150,7 @@ pwr_exe:
1204 0
99
13
1302 1
1302 0
1303 3
1304 0
1305 0
......
......@@ -4,14 +4,14 @@
100 11.5137
135 11.5137
101 20
102 -47
103 -64
102 -103
103 -102
104 2.15174
136 2.15174
105 100
106 -8
107 -11
108 53.6751
106 -19
107 -19
108 53.5883
109 -3.48664
110 39.285
111 -3.56335
......@@ -36,7 +36,7 @@
134
22
2200 0
2201 41
2201 50
2202 pwr_c_misc_pingpong
2203 31
2205 0
......@@ -1357,14 +1357,65 @@ pwr_exe:
125
2
19
1904 O37
1900 53.6752
1901 -3.30175
1902 -0.545933
1903 -1.4765
1904 O2
1900 50
1901 0
1902 35
1903 0
1908 0
1909 32
1910 32
1909 66
1910 66
1911 1
1915 0
1913 5
1916 2
1914 0
1918 0
1919 0
1920 0
1917 0
1921 0
1922 4
1923 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 0
701 0
99
503
7
700 50
701 35
99
99
1912
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
99
19
1904 O49
1900 28.7561
1901 25.2742
1902 35.0886
1903 0.173706
1908 0
1909 66
1910 66
1911 0
1915 0
1913 5
......@@ -1374,8 +1425,8 @@ pwr_exe:
1919 0
1920 0
1917 0
1921 2
1922 2
1921 6
1922 1
1923 0
1907 0
1906
......@@ -1387,31 +1438,135 @@ pwr_exe:
505 1
502
7
700 -3.12671
701 -1.4765
700 25.2742
701 0.173706
99
503
7
700 53.6752
701 -0.173706
700 28.3141
701 35.0886
99
99
1912
28
2800 1.00308
2800 1.1454
2801 0
2802 -3.67494
2803 0
2804 1
2805 0
2806 0
99
99
19
1904 O40
1900 50.0274
1901 0.0868531
1902 17.6312
1903 17.1969
1908 0
1909 31
1910 31
1911 0
1915 0
1913 5
1916 2
1914 0
1918 0
1919 0
1920 0
1917 0
1921 0
1922 4
1923 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 0.0868531
701 16.7626
99
503
7
700 50.0274
701 17.1969
99
99
1912
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0.434265
2806 0
99
99
19
1904 O39
1900 25.1874
1901 24.7628
1902 35.0018
1903 0.173706
1908 0
1909 31
1910 31
1911 0
1915 0
1913 5
1916 2
1914 0
1918 0
1919 0
1920 0
1917 0
1921 0
1922 4
1923 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 22.3212
701 0.0868531
99
503
7
700 23.2766
701 34.9149
99
99
1912
28
2800 0.444444
2801 0
2802 -0.165409
2802 14.8422
2803 0
2804 0.714286
2805 -0.421858
2804 1
2805 0.0868531
2806 0
99
99
35
3500
27
2703 10000
2704 10000
2704 67
2722 10000
2705 10000
2705 67
2723 10000
2706 10000
2708 0
......@@ -1429,8 +1584,8 @@ pwr_exe:
2701
2700
10
1000 pwr_menubar2
1002 O25
1000 Grp46_
1002 Grp46_
1005
0
0
......@@ -1464,14 +1619,14 @@ pwr_exe:
0
0
0
1006 53.5243
1007 -3.48664
1008 -1.56335
1009 -3.56335
1013 53.5243
1014 -3.48664
1015 -1.56335
1016 -3.56335
1006 1.43427
1007 -0.565733
1008 1.1737
1009 -0.826304
1013 1.43427
1014 -0.565733
1015 1.1737
1016 -0.826304
1003
0
0
......@@ -1486,8 +1641,8 @@ pwr_exe:
1004
1001
7
700 -0.838163
701 -3.8316
700 0
701 0
99
1010
1011
......@@ -1508,29 +1663,233 @@ pwr_exe:
99
2707
28
2800 2.07313
2800 1
2801 0
2802 2.43189
2803 0
2804 1
2805 2.34503
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2727 0
2728 303
2729 9999
2721
1
100 8192
101 0
102 33619964
103 2
15
1500 $object.XShadow##Float32
1501 $object.YShadow##Float32
1505
1506
1502 0
1503 0
1504 1
1509 1
1507 1
1510 1
1508 0
99
99
99
3501
36
3600
3
300 Grp46_
301
2
24
2404 O6
2400 -0.99762
2401 -2.99762
2402 -1.17133
2403 -3.17133
2408 0
2409 47
2410 47
2411 0
2415 0
2413 5
2416 2
2414 0
2417 0
2421 0
2418 0
2419 4
2420 0
2422 0
2407 0
2406
2405
8
802 0
803 1
800 0
801 360
806 1
804
7
700 -1
701 -1
99
805
7
700 1
701 1
99
99
2412
28
2800 1
2801 0
2802 -1.99762
2803 0
2804 1
2805 -2.17133
2806 0
99
99
99
302 0
304 0
303
305 0
306
307
308 0
321 0
309 0
313 0
322 0
323 0
324 0
325 0
326 0
327 0
310 0
311 0
312
314
315 1
316 1
317 0
318 0
319 0
320 0
328 0
99
99
99
19
1904 O37
1900 53.5882
1901 -3.3886
1902 -0.0289518
1903 -1.4765
1908 0
1909 32
1910 32
1911 0
1915 0
1913 5
1916 2
1914 0
1918 0
1919 0
1920 0
1917 0
1921 2
1922 2
1923 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 -3.12671
701 -1.4765
99
503
7
700 53.6752
701 -0.173706
99
99
1912
28
2800 1.00308
2801 0
2802 -0.252262
2803 0
2804 1.11111
2805 0.164055
2806 0
99
99
19
1904 O47
1900 -0.0868531
1901 -3.03986
1902 35.0886
1903 -0.173706
1908 0
1909 31
1910 31
1911 0
1915 0
1913 5
1916 2
1914 0
1918 0
1919 0
1920 0
1917 0
1921 0
1922 4
1923 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 -3.03986
701 0.0868531
99
503
7
700 -0.0868531
701 35.3492
99
99
1912
28
2800 1
2801 0
2802 -3.48664
2802 0
2803 0
2804 2
2805 -3.56335
2804 1
2805 -0.260559
2806 0
99
2716 0
2718
2717
2719 0
2724 1
2727 0
2728 303
2729 9999
2721
1
100 1
101 1
102 33619964
103 0
99
99
27
2703 10000
......@@ -1554,8 +1913,8 @@ pwr_exe:
2701
2700
10
1000 pwr_pulldownmenu2
1002 O26
1000 pwr_menubar2
1002 O25
1005
0
0
......@@ -1589,17 +1948,17 @@ pwr_exe:
0
0
0
1006 5.5
1007 2.5
1006 53.5243
1007 -3.48664
1008 -1.56335
1009 -3.56335
1013 5.5
1014 2.5
1013 53.5243
1014 -3.48664
1015 -1.56335
1016 -3.56335
1003
0
5
0
0
0
0
......@@ -1609,11 +1968,10 @@ pwr_exe:
0
0
1004
"File"
1001
7
700 3.30041
701 -1.6502
700 -0.838163
701 -3.8316
99
1010
1011
......@@ -1634,9 +1992,9 @@ pwr_exe:
99
2707
28
2800 1
2800 2.07313
2801 0
2802 2.5
2802 -3.48664
2803 0
2804 2
2805 -3.56335
......@@ -1656,85 +2014,8 @@ pwr_exe:
101 1
102 33619964
103 0
68
6800 3
6801 Settings
6833
1
100 1
101 65
102 33619964
103 0
55
5500 open graph "$pwr_exe/misc_pingpong_settings"/inst=$object
99
99
6802 Close
6834
1
100 1
101 262145
102 33619964
103 0
67
99
99
99
99
99
19
1904 O2
1900 50
1901 0
1902 35
1903 0
1908 0
1909 66
1910 66
1911 1
1915 0
1913 5
1916 2
1914 0
1918 0
1919 0
1920 0
1917 0
1921 0
1922 4
1923 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 0
701 0
99
503
7
700 50
701 35
99
99
1912
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
99
35
3500
27
2703 10000
2704 10000
......@@ -1757,8 +2038,8 @@ pwr_exe:
2701
2700
10
1000 Grp11_
1002 Grp11_
1000 pwr_pulldownmenu2
1002 O26
1005
0
0
......@@ -1792,17 +2073,17 @@ pwr_exe:
0
0
0
1006 0
1007 -0.5
1008 2.5
1009 -2.5
1013 0
1014 -0.5
1015 2.5
1016 -2.5
1006 1.41791
1007 -1.58209
1008 -1.56335
1009 -3.56335
1013 1.41791
1014 -1.58209
1015 -1.56335
1016 -3.56335
1003
0
0
5
0
0
0
......@@ -1812,10 +2093,11 @@ pwr_exe:
0
0
1004
"File"
1001
7
700 0
701 0
700 3.30041
701 -1.6502
99
1010
1011
......@@ -1838,127 +2120,62 @@ pwr_exe:
28
2800 1
2801 0
2802 0
2802 -1.58209
2803 0
2804 1
2805 0
2804 2
2805 -3.56335
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2724 1
2727 0
2728 303
2729 9999
2721
1
100 8193
100 1
101 1
102 33619964
103 2
15
1500
1501 $object.LeftPos##Float32
1505
1506 $object.RacketWidth##Float32
1502 0
1503 0
1504 1
1509 1
1507 1
1510 0.2
1508 8
99
99
99
3501
36
3600
3
300 Grp11_
301
2
19
1904 O10
1900 0
1901 -0.5
1902 2.5
1903 -2.5
1908 0
1909 38
1910 38
1911 1
1915 0
1913 5
1916 2
1914 0
1918 0
1919 0
1920 0
1917 0
1921 0
1922 4
1923 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 -0.5
701 -2.5
99
503
7
700 0
701 2.5
99
99
1912
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
103 0
68
6800 7
6801 New
6833
1
100 1
101 5
102 33619964
103 0
51
5100 $object.NewMatch##Boolean
5101 1
5102 1
99
99
6802 Settings
6834
1
100 1
101 65
102 33619964
103 0
55
5500 open graph "$pwr_exe/misc_pingpong_settings"/inst=$object
99
99
6803 Close
6835
1
100 1
101 262145
102 33619964
103 0
67
99
99
302 0
304 0
303
305 0
306
307
308 0
321 0
309 0
313 0
322 0
323 0
324 0
325 0
326 0
327 0
310 0
311 0
312
314
315 1
316 1
317 0
318 0
319 0
320 0
328 0
99
99
99
......@@ -1986,8 +2203,8 @@ pwr_exe:
2701
2700
10
1000 Grp12_
1002 Grp12_
1000 Grp11_
1002 Grp11_
1005
0
0
......@@ -2021,12 +2238,12 @@ pwr_exe:
0
0
0
1006 50.5
1007 50
1006 0
1007 -0.5
1008 2.5
1009 -2.5
1013 50.5
1014 50
1013 0
1014 -0.5
1015 2.5
1016 -2.5
1003
......@@ -2089,7 +2306,7 @@ pwr_exe:
103 2
15
1500
1501 $object.RightPos##Float32
1501 $object.LeftPos##Float32
1505
1506 $object.RacketWidth##Float32
1502 0
......@@ -2106,13 +2323,13 @@ pwr_exe:
36
3600
3
300 Grp12_
300 Grp11_
301
2
19
1904 O8
1900 50.5
1901 50
1904 O10
1900 0
1901 -0.5
1902 2.5
1903 -2.5
1908 0
......@@ -2140,12 +2357,12 @@ pwr_exe:
505 1
502
7
700 50
700 -0.5
701 -2.5
99
503
7
700 50.5
700 0
701 2.5
99
99
......@@ -3296,11 +3513,11 @@ pwr_exe:
99
99
19
1904 O39
1900 25.1874
1901 24.7628
1902 35.0018
1903 0.173706
1904 O48
1900 53.0672
1901 50.1142
1902 35.1755
1903 -0.0868529
1908 0
1909 31
1910 31
......@@ -3326,36 +3543,183 @@ pwr_exe:
505 1
502
7
700 22.3212
700 -3.03986
701 0.0868531
99
503
7
700 23.2766
701 34.9149
700 -0.0868531
701 35.3492
99
99
1912
28
2800 0.444444
2800 1
2801 0
2802 14.8422
2802 53.1541
2803 0
2804 1
2805 0.0868531
2805 -0.173706
2806 0
99
99
35
3500
27
2703 10000
2704 10000
2722 10000
2705 10000
2723 10000
2706 10000
2708 0
2709 0
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2725 0
2726 0
2702 0
2701
2700
10
1000 Grp12_
1002 Grp12_
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 50.5
1007 50
1008 2.5
1009 -2.5
1013 50.5
1014 50
1015 2.5
1016 -2.5
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 0
701 0
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 33619964
1028 0
1029
99
2707
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2727 0
2728 303
2729 9999
2721
1
100 8193
101 1
102 33619964
103 2
15
1500
1501 $object.RightPos##Float32
1505
1506 $object.RacketWidth##Float32
1502 0
1503 0
1504 1
1509 1
1507 1
1510 0.2
1508 8
99
99
99
3501
36
3600
3
300 Grp12_
301
2
19
1904 O40
1900 50.0274
1901 0.0868531
1902 17.6312
1903 17.1969
1904 O8
1900 50.5
1901 50
1902 2.5
1903 -2.5
1908 0
1909 31
1910 31
1911 0
1909 38
1910 38
1911 1
1915 0
1913 5
1916 2
......@@ -3377,13 +3741,13 @@ pwr_exe:
505 1
502
7
700 0.0868531
701 16.7626
700 50
701 -2.5
99
503
7
700 50.0274
701 17.1969
700 50.5
701 2.5
99
99
1912
......@@ -3393,10 +3757,41 @@ pwr_exe:
2802 0
2803 0
2804 1
2805 0.434265
2805 0
2806 0
99
99
99
302 0
304 0
303
305 0
306
307
308 0
321 0
309 0
313 0
322 0
323 0
324 0
325 0
326 0
327 0
310 0
311 0
312
314
315 1
316 1
317 0
318 0
319 0
320 0
328 0
99
99
99
35
3500
27
......
......@@ -121,7 +121,7 @@ Volume Miscellaneous $ClassVolume 0.0.0.9
Object RtBody $ObjBodyDef 1 08-APR-2011 08:56:23.47
Body SysBody 08-APR-2011 08:56:23.47
Attr StructName = "Misc_PingPong"
Attr NextAix = "_X33"
Attr NextAix = "_X36"
EndBody
!/**
! Mode idle, one player or two players.
......@@ -287,6 +287,20 @@ Volume Miscellaneous $ClassVolume 0.0.0.9
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object XShadow $Attribute 34 25-MAY-2011 19:08:53.70
Body SysBody 25-MAY-2011 19:08:55.25
Attr PgmName = "XShadow"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object YShadow $Attribute 33 25-MAY-2011 19:09:01.74
Body SysBody 25-MAY-2011 19:09:02.90
Attr PgmName = "YShadow"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Racket width.
!*/
......@@ -349,7 +363,6 @@ Volume Miscellaneous $ClassVolume 0.0.0.9
Object LeftPos $Attribute 31 25-MAY-2011 10:51:24.12
Body SysBody 25-MAY-2011 10:51:26.62
Attr PgmName = "LeftPos"
Attr Flags = 16777216
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
......@@ -359,7 +372,6 @@ Volume Miscellaneous $ClassVolume 0.0.0.9
Object RightPos $Attribute 32 25-MAY-2011 10:51:37.69
Body SysBody 25-MAY-2011 10:51:39.58
Attr PgmName = "RightPos"
Attr Flags = 16777216
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
......@@ -401,6 +413,13 @@ Volume Miscellaneous $ClassVolume 0.0.0.9
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object NewMatch $Attribute 35 26-MAY-2011 16:36:33.79
Body SysBody 26-MAY-2011 16:36:24.24
Attr PgmName = "NewMatch"
Attr Flags = 16778240
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object OldMode $Attribute 22 08-APR-2011 15:09:14.47
Body SysBody 08-APR-2011 15:09:16.01
Attr PgmName = "OldMode"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment