Rev 161 | Rev 163 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 161 | Rev 162 | ||
---|---|---|---|
Line 12... | Line 12... | ||
12 | } |
12 | } |
13 | 13 | ||
14 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
14 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
15 | LPSTR lpszCmdLine, int nCmdShow) { |
15 | LPSTR lpszCmdLine, int nCmdShow) { |
16 | 16 | ||
- | 17 | const int mo=3; |
|
- | 18 | const int ch0=100*mo; |
|
- | 19 | ||
17 | int mainonoff, |
20 | int mainonoff,HVonoffall; |
- | 21 | int HVonoff[4],HVonoff_rID[4]={P1_HVonoff_0,P1_HVonoff_1,P1_HVonoff_2,P1_HVonoff_3}; |
|
- | 22 | int HVvdis_rID[4]={P1_HVvdis_0,P1_HVvdis_1,P1_HVvdis_2,P1_HVvdis_3}; |
|
18 | int |
23 | int HVcdis_rID[4]={P1_HVcdis_0,P1_HVcdis_1,P1_HVcdis_2,P1_HVcdis_3}; |
19 | int iret; |
24 | int iret; |
20 | int i, j; |
25 | int i, j; |
21 | double ret; |
26 | double ret; |
22 | double |
27 | double HVvset[4],HVcset[4],HVvrise,HVvfall; |
- | 28 | double HVvdis[4],HVcdis[4]; |
|
23 | char cret[2000]; |
29 | char cret[2000]; |
24 | char cMainSwitch[2][30]= {"Turn system OFF?","Turn system ON?"}; |
30 | char cMainSwitch[2][30]= {"Turn system OFF?","Turn system ON?"}; |
25 | 31 | ||
26 | HSNMP crate1; |
32 | HSNMP crate1; |
27 | 33 | ||
28 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
34 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
29 | return -1; /* out of memory */ |
35 | return -1; /* out of memory */ |
30 | 36 | ||
31 | MPOD_Start(); |
37 | MPOD_Start(); |
32 | MPOD_Open(0,"arich-mpod1.kek.jp"); |
- | |
33 | // MPOD_Open(0,"f9mpod.ijs.si"); |
38 | // MPOD_Open(0,"f9mpod.ijs.si"); |
- | 39 | MPOD_Open(0,"arich-mpod1.kek.jp"); |
|
34 | crate1 = crateHsnmp[0]; |
40 | crate1 = crateHsnmp[0]; |
35 | 41 | ||
36 |
|
42 | // iret=MPOD_GetInt(0,"moduleNumber.0"); |
37 |
|
43 | // printf("Module Number = %i\n", iret); |
38 | - | ||
39 |
|
44 | // strcpy(cret, MPOD_GetString(0,"moduleDescription.ma2")); |
40 |
|
45 | // printf("Module type: %s\n",cret); |
41 | - | ||
42 | - | ||
43 |
|
46 | // iret=MPOD_GetIntCh(0,"fanNominalSpeed",0); |
44 |
|
47 | // printf("Fan nominal speed = %i\n", iret); |
45 | 48 | ||
46 | if ((p1h = LoadPanel (0, "HVtest_ui.uir", P1)) < 0) return -1; |
49 | if ((p1h = LoadPanel (0, "HVtest_ui.uir", P1)) < 0) return -1; |
47 | DisplayPanel (p1h); |
50 | DisplayPanel (p1h); |
48 | 51 | ||
49 | //Initial state |
52 | //Initial state |
50 | mainonoff=getMainSwitch(crate1); |
53 | mainonoff=getMainSwitch(crate1); |
51 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
54 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
52 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
55 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
53 | iret=getMainStatus(crate1); |
56 | iret=getMainStatus(crate1); |
54 | SetCtrlVal (p1h, P1_MST, iret); |
57 | SetCtrlVal (p1h, P1_MST, iret); |
55 | iret=getFanNominalSpeed(crate1); |
58 | iret=getFanNominalSpeed(crate1); |
56 | SetCtrlVal (p1h, P1_MFS, iret); |
59 | SetCtrlVal (p1h, P1_MFS, iret); |
57 | - | ||
58 | if (mainonoff) { |
60 | if (mainonoff) { |
- | 61 | HVonoffall=0; |
|
- | 62 | for (i=0;i<4;i++) { |
|
59 |
|
63 | HVonoff[i]=getChannelSwitch(crate1, ch0+i); |
- | 64 | if (HVonoff[i]) HVonoffall=1; |
|
- | 65 | } |
|
- | 66 | for (i=0;i<4;i++) { |
|
- | 67 | if (!HVonoffall) HVonoff[i]=1; |
|
60 | SetCtrlVal |
68 | SetCtrlVal (p1h, HVonoff_rID[i], HVonoff[i]); |
- | 69 | } |
|
61 |
|
70 | HVvset[0]=getOutputVoltage(crate1,ch0); |
62 | SetCtrlVal (p1h, |
71 | SetCtrlVal (p1h, P1_HVvset, HVvset[0]); |
63 |
|
72 | HVcset[0]=1e+6*getOutputCurrent(crate1,ch0); |
64 | SetCtrlVal (p1h, |
73 | SetCtrlVal (p1h, P1_HVcset, HVcset[0]); |
65 |
|
74 | HVvrise=getModuleRampSpeedVoltage(crate1,mo); |
66 | SetCtrlVal (p1h, |
75 | SetCtrlVal (p1h, P1_HVvrise, HVvrise); |
67 | // vfall[0]=abs(getOutputFallRate(crate1,ch)); |
76 | // vfall[0]=abs(getOutputFallRate(crate1,ch)); |
68 | // SetCtrlVal (p1h, P1_VFA0, vfall[0]); |
77 | // SetCtrlVal (p1h, P1_VFA0, vfall[0]); |
69 | } |
78 | } |
70 | // QueueUserEvent (1000, p1h, P1_RESET); |
79 | // QueueUserEvent (1000, p1h, P1_RESET); |
71 | QueueUserEvent (9000, p1h, P1_REFRESHTIMER); |
80 | QueueUserEvent (9000, p1h, P1_REFRESHTIMER); |
Line 78... | Line 87... | ||
78 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
87 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
79 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
88 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
80 | iret=getMainStatus(crate1); |
89 | iret=getMainStatus(crate1); |
81 | SetCtrlVal (p1h, P1_MST, iret); |
90 | SetCtrlVal (p1h, P1_MST, iret); |
82 | // ret=getOutputSenseMeasurement(crate1, ch); |
91 | // ret=getOutputSenseMeasurement(crate1, ch); |
- | 92 | for (i=0;i<4;i++) { |
|
83 |
|
93 | HVvdis[i]=getOutputTerminalMeasurement(crate1, ch0+i); |
84 |
|
94 | SetCtrlVal (p1h, HVvdis_rID[i], HVvdis[i]); |
85 |
|
95 | HVcdis[i]=1e+6*getCurrentMeasurement(crate1, ch0+i); |
86 |
|
96 | SetCtrlVal (p1h, HVcdis_rID[i], HVcdis[i]); |
87 |
|
97 | PlotStripChart (p1h, P1_G1, HVcdis, 4, 0, 0, VAL_DOUBLE); |
88 | break; |
98 | break; |
89 | case P1_MSW: |
99 | case P1_MSW: |
90 | GetCtrlVal (p1h, P1_MSW, &mainonoff); |
100 | GetCtrlVal (p1h, P1_MSW, &mainonoff); |
91 | if (ConfirmPopup("Main switch!!!", cMainSwitch[mainonoff])) |
101 | if (ConfirmPopup("Main switch!!!", cMainSwitch[mainonoff])) |
92 | setMainSwitch(crate1, mainonoff); |
102 | setMainSwitch(crate1, mainonoff); |
93 | if ( |
103 | if (mainonoff) { |
94 |
|
104 | Delay(5); |
- | 105 | HVonoffall=0; |
|
- | 106 | for (i=0; i<4; i++) { |
|
95 |
|
107 | HVonoff[i]=getChannelSwitch(crate1, ch0+i); |
96 |
|
108 | if (HVonoff[i]) HVonoffall=1; |
- | 109 | } |
|
- | 110 | for (i=0; i<4; i++) { |
|
97 |
|
111 | if (!HVonoffall) HVonoff[i]=1; |
98 |
|
112 | SetCtrlVal (p1h, HVonoff_rID[i], HVonoff[i]); |
- | 113 | } |
|
99 |
|
114 | HVvset[0]=getOutputVoltage(crate1,ch0); |
100 | SetCtrlVal (p1h, |
115 | SetCtrlVal (p1h, P1_HVvset, HVvset[0]); |
101 |
|
116 | HVcset[0]=1e+6*getOutputCurrent(crate1,ch0); |
102 | SetCtrlVal (p1h, |
117 | SetCtrlVal (p1h, P1_HVcset, HVcset[0]); |
103 |
|
118 | HVvrise=getModuleRampSpeedVoltage(crate1,mo); |
104 |
|
119 | SetCtrlVal (p1h, P1_HVvrise, HVvrise); |
- | 120 | } |
|
105 | break; |
121 | break; |
106 | } |
122 | } |
107 | if (!mainonoff) continue; |
123 | if (!mainonoff) continue; |
108 | switch (rID) { |
124 | switch (rID) { |
109 | case |
125 | case P1_HVonoff: |
110 | GetCtrlVal (p1h, |
126 | GetCtrlVal (p1h, P1_HVonoff, &HVonoffall); |
111 |
|
127 | for (i=0;i<4;isetChannelSwitch(crate1, ch, onoff[0]); |
112 | // Delay(1); |
- | |
113 | break; |
128 | break; |
114 | case P1_V0: |
129 | case P1_V0: |
115 | GetCtrlVal (p1h, P1_V0, &vset[0]); |
130 | GetCtrlVal (p1h, P1_V0, &vset[0]); |
116 | setOutputVoltage(crate1, ch, vset[0]); |
131 | setOutputVoltage(crate1, ch, vset[0]); |
117 | break; |
132 | break; |