108{
110
111 data.name = m_textCtrlName->GetValue();
112
113 if(!m_load->
DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower,
114 _("Value entered incorrectly in the field \"Active power\".")))
115 return false;
116 switch(m_choiceActivePower->GetSelection()) {
117 case 0: {
119 } break;
120 case 1: {
122 } break;
123 case 2: {
125 } break;
126 case 3: {
128 } break;
129 }
130
131 if(!m_load->
DoubleFromString(m_parent, m_textCtrlReactivePower->GetValue(), data.reactivePower,
132 _("Value entered incorrectly in the field \"Reactive power\".")))
133 return false;
134 switch(m_choiceReactivePower->GetSelection()) {
135 case 0: {
137 } break;
138 case 1: {
140 } break;
141 case 2: {
143 } break;
144 case 3: {
146 } break;
147 }
148
149 switch(m_choiceType->GetSelection()) {
150 case 0: {
151 data.loadType = CONST_POWER;
152 } break;
153 case 1: {
154 data.loadType = CONST_IMPEDANCE;
155 } break;
156 }
157
158 data.plotLoad = m_checkBoxPlotData->GetValue();
159
160 data.useCompLoad = m_checkBoxUseCompLoad->GetValue();
161
163 this, m_textCtrlActivePowerImp->GetValue(), data.constImpedanceActive,
164 _("Value entered incorrectly in the field \"Constant impedance portion of active power\".")))
165 return false;
167 this, m_textCtrlActivePowerCur->GetValue(), data.constCurrentActive,
168 _("Value entered incorrectly in the field \"Constant current portion of active power\".")))
169 return false;
171 this, m_textCtrlActivePowerPow->GetValue(), data.constPowerActive,
172 _("Value entered incorrectly in the field \"Constant power portion of active power\".")))
173 return false;
175 this, m_textCtrlReactivePowerImp->GetValue(), data.constImpedanceReactive,
176 _("Value entered incorrectly in the field \"Constant impedance portion of reactive power\".")))
177 return false;
179 this, m_textCtrlReactivePowerCur->GetValue(), data.constCurrentReactive,
180 _("Value entered incorrectly in the field \"Constant current portion of reactive power\".")))
181 return false;
183 this, m_textCtrlReactivePowerPow->GetValue(), data.constPowerReactive,
184 _("Value entered incorrectly in the field \"Constant power portion of reactive power\".")))
185 return false;
186
187 double sum = data.constImpedanceActive + data.constCurrentActive + data.constPowerActive;
188 if(sum > 100.01 || sum < 99.99) {
189 wxMessageDialog msgDialog(this, _("The sum of active power load composition must be 100%."), _("Error"),
190 wxOK | wxCENTRE | wxICON_ERROR);
191 msgDialog.ShowModal();
192 return false;
193 }
194 sum = data.constImpedanceReactive + data.constCurrentReactive + data.constPowerReactive;
195 if(sum > 100.01 || sum < 99.99) {
196 wxMessageDialog msgDialog(this, _("The sum of reactive power load composition must be 100%."), _("Error"),
197 wxOK | wxCENTRE | wxICON_ERROR);
198 msgDialog.ShowModal();
199 return false;
200 }
201
202 m_load->SetElectricalData(data);
203 return true;
204}
static bool DoubleFromString(wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
Get a double value from a string. Show a error message if the conversion fail.