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