This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalogSettings.c
158 lines (146 loc) · 6.26 KB
/
AnalogSettings.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
@file AnalogSettings.c
@brief Sets the AnalogChannelProperties for each analog line.
*/
#include "AnalogSettings.h"
#include <ansi_c.h>
#include <userint.h>
#include "AnalogSettings2.h"
#include "GUIDesign.h"
#include "vars.h"
/**
@brief Callback for the Allow Changes button. Switches components from Indicator
to Hot so changes can be made. Adds flag that values have been changed so ADwin
array is rebuilt on next run.
*/
int CVICALLBACK CMD_ALLOWCHANGE_CALLBACK(int panel, int control, int event,
void* callbackData, int eventData1,
int eventData2) {
switch (event) {
case EVENT_COMMIT:
SetCtrlAttribute(panelHandle2, ANLGPANEL_CMD_SETCHANGES, ATTR_VISIBLE, 1);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_ACHANNEL, ATTR_CTRL_MODE,
VAL_HOT);
SetCtrlAttribute(panelHandle2, ANLGPANEL_STR_CHANNELNAME, ATTR_CTRL_MODE,
VAL_HOT);
SetCtrlAttribute(panelHandle2, ANLGPANEL_STRING_UNITS, ATTR_CTRL_MODE,
VAL_HOT);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_CHANNELPROP, ATTR_CTRL_MODE,
VAL_HOT);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_CHANNELBIAS, ATTR_CTRL_MODE,
VAL_HOT);
SetCtrlAttribute(panelHandle2, ANLGPANEL_CHKBOX_RESET, ATTR_CTRL_MODE,
VAL_HOT);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_MINV, ATTR_CTRL_MODE,
VAL_HOT);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_MAXV, ATTR_CTRL_MODE,
VAL_HOT);
ChangedVals = TRUE;
break;
}
return 0;
}
/**
@brief Callback for the Set Changes button. Takes inputs from the panel and
updates the relevant AnalogChannelProperties in AChName.
*/
int CVICALLBACK CMD_SETCHANGES_CALLBACK(int panel, int control, int event,
void* callbackData, int eventData1,
int eventData2) {
char buff[51] = "", buff2[51] = "";
int channel = 0, line = 0, val = 0;
double prop = 0, bias = 0, vmin = 0, vmax = 0;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(panelHandle2, ANLGPANEL_NUM_ACHANNEL, &channel);
GetCtrlVal(panelHandle2, ANLGPANEL_NUM_ACH_LINE, &line);
GetCtrlVal(panelHandle2, ANLGPANEL_NUM_CHANNELPROP, &prop);
GetCtrlVal(panelHandle2, ANLGPANEL_NUM_CHANNELBIAS, &bias);
GetCtrlVal(panelHandle2, ANLGPANEL_STR_CHANNELNAME, buff);
GetCtrlVal(panelHandle2, ANLGPANEL_STRING_UNITS, buff2);
GetCtrlVal(panelHandle2, ANLGPANEL_CHKBOX_RESET, &val);
GetCtrlVal(panelHandle2, ANLGPANEL_NUM_MINV, &vmin);
GetCtrlVal(panelHandle2, ANLGPANEL_NUM_MAXV, &vmax);
AChName[line].resettozero = val;
AChName[line].chnum = channel;
AChName[line].tfcn = prop;
AChName[line].tbias = bias;
AChName[line].maxvolts = vmax;
AChName[line].minvolts = vmin;
sprintf(AChName[line].chname, buff);
sprintf(AChName[line].units, buff2);
SetAnalogChannels();
// Next we will update the channel list and redisplay ;)
break;
}
return 0;
}
/**
@brief Callback for the Done button. Sets all controls to Indicator and hides
the panel.
*/
int CVICALLBACK CMD_DONEANALOG_CALLBACK(int panel, int control, int event,
void* callbackData, int eventData1,
int eventData2) {
switch (event) {
case EVENT_COMMIT:
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_ACHANNEL, ATTR_CTRL_MODE,
VAL_INDICATOR);
SetCtrlAttribute(panelHandle2, ANLGPANEL_STR_CHANNELNAME, ATTR_CTRL_MODE,
VAL_INDICATOR);
SetCtrlAttribute(panelHandle2, ANLGPANEL_STRING_UNITS, ATTR_CTRL_MODE,
VAL_INDICATOR);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_CHANNELPROP, ATTR_CTRL_MODE,
VAL_INDICATOR);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_CHANNELBIAS, ATTR_CTRL_MODE,
VAL_INDICATOR); /* added by Seth, Oct 28, 2004 */
SetCtrlAttribute(panelHandle2, ANLGPANEL_CHKBOX_RESET, ATTR_CTRL_MODE,
VAL_INDICATOR);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_MINV, ATTR_CTRL_MODE,
VAL_INDICATOR);
SetCtrlAttribute(panelHandle2, ANLGPANEL_NUM_MAXV, ATTR_CTRL_MODE,
VAL_INDICATOR);
SetCtrlAttribute(panelHandle2, ANLGPANEL_CMD_SETCHANGES, ATTR_VISIBLE, 0);
HidePanel(panelHandle2);
break;
}
return 0;
}
/**
@brief Updates the main panel to display new values in AChName.
*/
void SetAnalogChannels(void) {
for (int i = 1; i <= NUMBERANALOGCHANNELS; i++) {
SetTableCellAttribute(panelHandle, PANEL_TBL_ANAMES, MakePoint(1, i),
ATTR_CTRL_VAL, AChName[i].chname);
SetTableCellAttribute(panelHandle, PANEL_TBL_ANAMES, MakePoint(2, i),
ATTR_CTRL_VAL, AChName[i].chnum);
SetTableCellAttribute(panelHandle, PANEL_TBL_ANALOGUNITS, MakePoint(1, i),
ATTR_CTRL_VAL, AChName[i].units);
}
}
/**
@brief Callback for the Line number box. Updates the displayed information as we
change the line number.
*/
int CVICALLBACK NUM_ACH_LINE_CALLBACK(int panel, int control, int event,
void* callbackData, int eventData1,
int eventData2) {
int line = 0;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal(panelHandle2, ANLGPANEL_NUM_ACH_LINE, &line);
SetCtrlVal(panelHandle2, ANLGPANEL_NUM_ACHANNEL, AChName[line].chnum);
SetCtrlVal(panelHandle2, ANLGPANEL_NUM_CHANNELPROP, AChName[line].tfcn);
SetCtrlVal(panelHandle2, ANLGPANEL_NUM_CHANNELBIAS,
AChName[line].tbias); /* added by Seth, Oct 28, 2004 */
SetCtrlVal(panelHandle2, ANLGPANEL_STR_CHANNELNAME, AChName[line].chname);
SetCtrlVal(panelHandle2, ANLGPANEL_STRING_UNITS, AChName[line].units);
SetCtrlVal(panelHandle2, ANLGPANEL_CHKBOX_RESET,
AChName[line].resettozero);
SetCtrlVal(panelHandle2, ANLGPANEL_NUM_MINV, AChName[line].minvolts);
SetCtrlVal(panelHandle2, ANLGPANEL_NUM_MAXV, AChName[line].maxvolts);
break;
}
return 0;
}