Rev 159 | Rev 162 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
159 | f9daq | 1 | #include "MPOD.h" |
2 | #include "HVtest_ui.h" |
||
3 | |||
161 | f9daq | 4 | #define HVSLOT 3 |
5 | |||
159 | f9daq | 6 | static int p1h, pID, rID, tfID; |
7 | |||
8 | int CVICALLBACK refreshTimer (int panel, int control, int event, void *callbackData, |
||
9 | int eventData1, int eventData2) { |
||
10 | QueueUserEvent (9000, p1h, P1_REFRESHTIMER); |
||
11 | return (0); |
||
12 | } |
||
13 | |||
14 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
||
15 | LPSTR lpszCmdLine, int nCmdShow) { |
||
16 | |||
17 | int mainonoff,onoff[4]; |
||
161 | f9daq | 18 | int ch=100*HVSLOT,mo=HVSLOT; |
159 | f9daq | 19 | int iret; |
20 | int i, j; |
||
21 | double ret; |
||
22 | double vset[4],cset[4],vrise[4],vfall[4]; |
||
23 | char cret[2000]; |
||
24 | char cMainSwitch[2][30]= {"Turn system OFF?","Turn system ON?"}; |
||
25 | |||
26 | HSNMP crate1; |
||
27 | |||
28 | if (InitCVIRTE (hInstance, 0, 0) == 0) |
||
29 | return -1; /* out of memory */ |
||
30 | |||
31 | MPOD_Start(); |
||
161 | f9daq | 32 | MPOD_Open(0,"arich-mpod1.kek.jp"); |
33 | // MPOD_Open(0,"f9mpod.ijs.si"); |
||
159 | f9daq | 34 | crate1 = crateHsnmp[0]; |
35 | |||
36 | iret=MPOD_GetInt(0,"moduleNumber.0"); |
||
37 | printf("Module Number = %i\n", iret); |
||
38 | |||
39 | strcpy(cret, MPOD_GetString(0,"moduleDescription.ma2")); |
||
40 | printf("Module type: %s\n",cret); |
||
41 | |||
42 | |||
43 | iret=MPOD_GetIntCh(0,"fanNominalSpeed",0); |
||
44 | printf("Fan nominal speed = %i\n", iret); |
||
45 | |||
46 | if ((p1h = LoadPanel (0, "HVtest_ui.uir", P1)) < 0) return -1; |
||
47 | DisplayPanel (p1h); |
||
48 | |||
49 | //Initial state |
||
50 | mainonoff=getMainSwitch(crate1); |
||
51 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
||
52 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
||
53 | iret=getMainStatus(crate1); |
||
54 | SetCtrlVal (p1h, P1_MST, iret); |
||
55 | iret=getFanNominalSpeed(crate1); |
||
56 | SetCtrlVal (p1h, P1_MFS, iret); |
||
57 | |||
58 | if (mainonoff) { |
||
59 | onoff[0]=getChannelSwitch(crate1, ch); |
||
60 | SetCtrlVal (p1h, P1_ONOFF0, onoff[0]); |
||
61 | vset[0]=getOutputVoltage(crate1,ch); |
||
62 | SetCtrlVal (p1h, P1_V0, vset[0]); |
||
63 | cset[0]=1e+6*getOutputCurrent(crate1,ch); |
||
64 | SetCtrlVal (p1h, P1_C0, cset[0]); |
||
65 | vrise[0]=getModuleRampSpeedVoltage(crate1,mo); |
||
66 | SetCtrlVal (p1h, P1_VRI0, vrise[0]); |
||
67 | // vfall[0]=abs(getOutputFallRate(crate1,ch)); |
||
68 | // SetCtrlVal (p1h, P1_VFA0, vfall[0]); |
||
69 | } |
||
70 | // QueueUserEvent (1000, p1h, P1_RESET); |
||
71 | QueueUserEvent (9000, p1h, P1_REFRESHTIMER); |
||
72 | |||
73 | do { |
||
74 | GetUserEvent (1, &pID, &rID); |
||
75 | switch (rID) { |
||
76 | case P1_REFRESHTIMER: |
||
77 | mainonoff=getMainSwitch(crate1); |
||
78 | SetCtrlVal (p1h, P1_MSW, mainonoff); |
||
79 | SetCtrlVal (p1h, P1_MSWLED, mainonoff); |
||
80 | iret=getMainStatus(crate1); |
||
81 | SetCtrlVal (p1h, P1_MST, iret); |
||
82 | // ret=getOutputSenseMeasurement(crate1, ch); |
||
83 | ret=getOutputTerminalMeasurement(crate1, ch); |
||
84 | SetCtrlVal (p1h, P1_VD0, ret); |
||
85 | ret=1e+6*getCurrentMeasurement(crate1, ch); |
||
86 | SetCtrlVal (p1h, P1_CD0, ret); |
||
87 | PlotStripChartPoint (p1h, P1_G1, ret); |
||
88 | break; |
||
89 | case P1_MSW: |
||
90 | GetCtrlVal (p1h, P1_MSW, &mainonoff); |
||
91 | if (ConfirmPopup("Main switch!!!", cMainSwitch[mainonoff])) |
||
92 | setMainSwitch(crate1, mainonoff); |
||
93 | if (!mainonoff) break; |
||
94 | // Delay(1); |
||
95 | onoff[0]=getChannelSwitch(crate1, ch); |
||
96 | SetCtrlVal (p1h, P1_ONOFF0, onoff[0]); |
||
97 | vset[0]=getOutputVoltage(crate1,ch); |
||
98 | SetCtrlVal (p1h, P1_V0, vset[0]); |
||
99 | cset[0]=1e+6*getOutputCurrent(crate1,ch); |
||
100 | SetCtrlVal (p1h, P1_C0, cset[0]); |
||
101 | vrise[0]=getModuleRampSpeedVoltage(crate1,mo); |
||
102 | SetCtrlVal (p1h, P1_VRI0, vrise[0]); |
||
103 | // vfall[0]=abs(getOutputFallRate(crate1,ch)); |
||
104 | // SetCtrlVal (p1h, P1_VFA0, vfall[0]); |
||
105 | break; |
||
106 | } |
||
107 | if (!mainonoff) continue; |
||
108 | switch (rID) { |
||
109 | case P1_ONOFF0: |
||
110 | GetCtrlVal (p1h, P1_ONOFF0, &onoff[0]); |
||
111 | setChannelSwitch(crate1, ch, onoff[0]); |
||
112 | // Delay(1); |
||
113 | break; |
||
114 | case P1_V0: |
||
115 | GetCtrlVal (p1h, P1_V0, &vset[0]); |
||
116 | setOutputVoltage(crate1, ch, vset[0]); |
||
117 | break; |
||
118 | case P1_C0: |
||
119 | GetCtrlVal (p1h, P1_C0, &cset[0]); |
||
120 | cset[0]/=1e+6; //[uA] |
||
121 | setOutputCurrent(crate1, ch, cset[0]); |
||
122 | break; |
||
123 | case P1_VRI0: |
||
124 | GetCtrlVal (p1h, P1_VRI0, &ret); |
||
125 | setModuleRampSpeedVoltage(crate1, mo, ret); |
||
126 | vrise[0]=getModuleRampSpeedVoltage(crate1,mo); |
||
127 | SetCtrlVal (p1h, P1_VRI0, vrise[0]); |
||
128 | break; |
||
129 | // case P1_VFA0: |
||
130 | // GetCtrlVal (p1h, P1_VFA0, &ret); |
||
131 | // setOutputFallRate(crate1, ch, ret); |
||
132 | // vfall[0]=abs(getOutputFallRate(crate1,ch)); |
||
133 | // SetCtrlVal (p1h, P1_VFA0, vfall[0]); |
||
134 | // break; |
||
135 | } |
||
136 | } while ((rID != P1_EXIT)); |
||
137 | |||
138 | DiscardPanel (p1h); |
||
139 | |||
140 | MPOD_Close(0); |
||
141 | MPOD_End(); |
||
142 | |||
143 | return 0; |
||
144 | } |