-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_tab_parameters.cpp
More file actions
192 lines (174 loc) · 8.13 KB
/
Copy pathui_tab_parameters.cpp
File metadata and controls
192 lines (174 loc) · 8.13 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include "stdafx.h"
#include "f1.h"
#include <stdio.h>
#include <windows.h>
namespace robot_ui
{
/******************************************************************************************************************************************
*
******************************************************************************************************************************************/
System::Void f1::parameters_dataGridView_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)
{
int r,c;
float f;
c = e->ColumnIndex;
r = e->RowIndex;
//log("parameters_dataGridView_CellContentClick\n");
//don't allow a change if this is a group name definition only
if(Convert::ToInt16(parameters_dataGridView->Rows[r]->Cells[1]->Value)==0) return;
if(r>=0 && c==5)
{
f = (float)(Convert::ToSingle(parameters_dataGridView->Rows[r]->Cells[4]->Value));
f+=1;
parameters_dataGridView->Rows[r]->Cells[4]->Value = Convert::ToString(f);
}
if(r>=0 && c==6)
{
f = (float)(Convert::ToSingle(parameters_dataGridView->Rows[r]->Cells[4]->Value));
f-=1;
parameters_dataGridView->Rows[r]->Cells[4]->Value = Convert::ToString(f);
}
}
/******************************************************************************************************************************************
*
******************************************************************************************************************************************/
System::Void f1::parameters_dataGridView_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)
{
t_config_value v;
int r,c,grp,id,i;
if(!ignore_parameter_changes)
{
c = e->ColumnIndex;
r = e->RowIndex;
grp = Convert::ToInt32(parameters_dataGridView->Rows[r]->Cells[0]->Value);
id = Convert::ToInt32(parameters_dataGridView->Rows[r]->Cells[1]->Value);
i = cfg_get_index_by_grp_and_id(grp,id);
log("parameters_dataGridView_CellValueChanged(): ");
log(Convert::ToString(e->RowIndex) + "," + Convert::ToString(e->ColumnIndex) + " = ");
switch(config[i].type)
{
case U08_VALUE:
v.u08 = (uint8) Convert::ToUInt16(parameters_dataGridView->Rows[r]->Cells[4]->Value);
log(Convert::ToString(v.u08) + "\n");
break;
case S08_VALUE:
v.s08 = (sint8) Convert::ToInt16(parameters_dataGridView->Rows[r]->Cells[4]->Value);
log(Convert::ToString(v.s08) + "\n");
break;
case U16_VALUE:
v.u16 = Convert::ToUInt16(parameters_dataGridView->Rows[r]->Cells[4]->Value);
log(Convert::ToString(v.u16) + "\n");
break;
case S16_VALUE:
v.s16 = Convert::ToInt16(parameters_dataGridView->Rows[r]->Cells[4]->Value);
log(Convert::ToString(v.s16) + "\n");
break;
case U32_VALUE:
v.u32 = Convert::ToUInt32(parameters_dataGridView->Rows[r]->Cells[4]->Value);
log(Convert::ToString((unsigned int)v.u32) + "\n");
break;
case S32_VALUE:
v.s32 = Convert::ToInt32(parameters_dataGridView->Rows[r]->Cells[4]->Value);
log(Convert::ToString(v.s32) + "\n");
break;
case FLT_VALUE:
v.f = Convert::ToSingle(parameters_dataGridView->Rows[r]->Cells[4]->Value);
log(Convert::ToString(v.f) + "\n");
break;
}
log("\n");
//TODO: for some reasone, issuing commands from here results in some seq # skipping
cfg_set_value_by_grp_id(grp,id, v);
CMD_set_config_value(grp,id, (uint8*)&v);
CMD_send();
}
}
/******************************************************************************************************************************************
*
******************************************************************************************************************************************/
void f1::InitializeParametersTab(void)
{
int i;
for(i=0; i<=MAX_CFG_ITEMS;i++)
{
if(config[i].grp == 255) break;
parameters_dataGridView->Rows->Add();
parameters_dataGridView->Rows[i]->Cells[0]->Value = config[i].grp;
parameters_dataGridView->Rows[i]->Cells[1]->Value = config[i].id;
if(config[i].id == 0)
{
parameters_dataGridView->Rows[i]->Cells[0]->Value = Convert::ToString(config[i].grp) + " - " + gcnew String(config[i].name);
parameters_dataGridView->Rows[i]->Cells[2]->Value = Convert::ToString(config[i].grp) + " - " + gcnew String(config[i].name);
parameters_dataGridView->Rows[i]->Cells[0]->Style->BackColor = System::Drawing::Color::Yellow;
parameters_dataGridView->Rows[i]->Cells[1]->Style->BackColor = System::Drawing::Color::Yellow;
parameters_dataGridView->Rows[i]->Cells[2]->Style->BackColor = System::Drawing::Color::Yellow;
parameters_dataGridView->Rows[i]->Cells[3]->Style->BackColor = System::Drawing::Color::Yellow;
parameters_dataGridView->Rows[i]->Cells[4]->Style->BackColor = System::Drawing::Color::Yellow;
parameters_dataGridView->Rows[i]->Cells[5]->Style->BackColor = System::Drawing::Color::Yellow;
parameters_dataGridView->Rows[i]->Cells[6]->Style->BackColor = System::Drawing::Color::Yellow;
parameters_dataGridView->Rows[i]->Cells[0]->Style->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
parameters_dataGridView->Rows[i]->Cells[1]->Style->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
parameters_dataGridView->Rows[i]->Cells[2]->Style->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
parameters_dataGridView->Rows[i]->Cells[3]->Style->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
parameters_dataGridView->Rows[i]->Cells[4]->Style->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
}
else
{
parameters_dataGridView->Rows[i]->Cells[2]->Value = gcnew String(config[i].name);
}
parameters_dataGridView->Rows[i]->Cells[5]->Value = "+";
parameters_dataGridView->Rows[i]->Cells[6]->Value = "-";
switch(config[i].type)
{
case U08_VALUE:
parameters_dataGridView->Rows[i]->Cells[3]->Value = "u08";
parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString(config[i].v.u08);
break;
case S08_VALUE:
parameters_dataGridView->Rows[i]->Cells[3]->Value = "s08";
parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString(config[i].v.s08);
break;
case U16_VALUE:
parameters_dataGridView->Rows[i]->Cells[3]->Value = "u16";
parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString(config[i].v.u16);
break;
case S16_VALUE:
parameters_dataGridView->Rows[i]->Cells[3]->Value = "s16";
parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString(config[i].v.s16);
break;
case U32_VALUE:
parameters_dataGridView->Rows[i]->Cells[3]->Value = "u32";
parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString((unsigned int)config[i].v.u32);
break;
case S32_VALUE:
parameters_dataGridView->Rows[i]->Cells[3]->Value = "s32";
parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString(config[i].v.s32);
break;
case FLT_VALUE:
parameters_dataGridView->Rows[i]->Cells[3]->Value = "flt";
//parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString(config[i].v.f);
parameters_dataGridView->Rows[i]->Cells[4]->Value = Convert::ToString(config_float_only[i].f);
config[i].v.f = config_float_only[i].f;
break;
} //switch
} //for
} //function
System::Void f1::parameters_btn_write_all_Click(System::Object^ sender, System::EventArgs^ e)
{
int i;
i=0;
Application::UseWaitCursor = 1;
while(config[i].grp != 255)
{
if(config[i].id != 0)
{
CMD_set_config_value(config[i].grp, config[i].id, (uint8*)&(config[i].v));
CMD_send();
Sleep(50);
Application::DoEvents();
}
i++;
}
Application::UseWaitCursor = 0;
}
}