301{
302 if (m_syncGenerator) {
304 data.name = m_textCtrlName->GetValue();
305
306 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlnominalPower->GetValue(), data.nominalPower,
307 _("Value entered incorrectly in the field \"Nominal power\".")))
308 return false;
309 switch (m_choiceNominalPower->GetSelection()) {
310 case 0:
311 data.nominalPowerUnit = ElectricalUnit::UNIT_VA;
312 break;
313 case 1:
314 data.nominalPowerUnit = ElectricalUnit::UNIT_kVA;
315 break;
316 case 2:
317 data.nominalPowerUnit = ElectricalUnit::UNIT_MVA;
318 break;
319 }
320
321 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower,
322 _("Value entered incorrectly in the field \"Active power\".")))
323 return false;
324 switch (m_choiceActivePower->GetSelection()) {
325 case 0:
326 data.activePowerUnit = ElectricalUnit::UNIT_PU;
327 break;
328 case 1:
329 data.activePowerUnit = ElectricalUnit::UNIT_W;
330 break;
331 case 2:
332 data.activePowerUnit = ElectricalUnit::UNIT_kW;
333 break;
334 case 3:
335 data.activePowerUnit = ElectricalUnit::UNIT_MW;
336 break;
337 }
338
339 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlReactivePower->GetValue(), data.reactivePower,
340 _("Value entered incorrectly in the field \"Reactive power\".")))
341 return false;
342 switch (m_choiceReactivePower->GetSelection()) {
343 case 0:
344 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
345 break;
346 case 1:
347 data.reactivePowerUnit = ElectricalUnit::UNIT_var;
348 break;
349 case 2:
350 data.reactivePowerUnit = ElectricalUnit::UNIT_kvar;
351 break;
352 case 3:
353 data.reactivePowerUnit = ElectricalUnit::UNIT_Mvar;
354 break;
355 }
356
357 data.haveMaxReactive = m_checkBoxMaxReactive->GetValue();
358 if (data.haveMaxReactive) {
359 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlMaxRectivePower->GetValue(), data.maxReactive,
360 _("Value entered incorrectly in the field \"Max reactive power\".")))
361 return false;
362 switch (m_choiceMaxRectivePower->GetSelection()) {
363 case 0:
364 data.maxReactiveUnit = ElectricalUnit::UNIT_PU;
365 break;
366 case 1:
367 data.maxReactiveUnit = ElectricalUnit::UNIT_var;
368 break;
369 case 2:
370 data.maxReactiveUnit = ElectricalUnit::UNIT_kvar;
371 break;
372 case 3:
373 data.maxReactiveUnit = ElectricalUnit::UNIT_Mvar;
374 break;
375 }
376 }
377
378 data.haveMinReactive = m_checkBoxMinReactive->GetValue();
379 if (data.haveMinReactive) {
380 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlMinRectivePower->GetValue(), data.minReactive,
381 _("Value entered incorrectly in the field \"Min reactive power\".")))
382 return false;
383 switch (m_choiceMinRectivePower->GetSelection()) {
384 case 0:
385 data.minReactiveUnit = ElectricalUnit::UNIT_PU;
386 break;
387 case 1:
388 data.minReactiveUnit = ElectricalUnit::UNIT_var;
389 break;
390 case 2:
391 data.minReactiveUnit = ElectricalUnit::UNIT_kvar;
392 break;
393 case 3:
394 data.minReactiveUnit = ElectricalUnit::UNIT_Mvar;
395 break;
396 }
397 }
398
399 data.useMachineBase = m_checkBoxUseMachinePower->GetValue();
400
401 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlPosResistance->GetValue(), data.positiveResistance,
402 _("Value entered incorrectly in the field \"Positive resistance\".")))
403 return false;
404
405 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlPosReactance->GetValue(), data.positiveReactance,
406 _("Value entered incorrectly in the field \"Positive reactance\".")))
407 return false;
408
409 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlNegResistance->GetValue(), data.negativeResistance,
410 _("Value entered incorrectly in the field \"Negative resistance\".")))
411 return false;
412
413 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlNegReactance->GetValue(), data.negativeReactance,
414 _("Value entered incorrectly in the field \"Negative reactance\".")))
415 return false;
416
417 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlZeroResistance->GetValue(), data.zeroResistance,
418 _("Value entered incorrectly in the field \"Zero resistance\".")))
419 return false;
420
421 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlZeroReactance->GetValue(), data.zeroReactance,
422 _("Value entered incorrectly in the field \"Zero reactance\".")))
423 return false;
424
425 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlGrdResistance->GetValue(), data.groundResistance,
426 _("Value entered incorrectly in the field \"Ground resistance\".")))
427 return false;
428
429 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlGrdReactance->GetValue(), data.groundReactance,
430 _("Value entered incorrectly in the field \"Ground reactance\".")))
431 return false;
432
433 data.groundNeutral = m_checkBoxGroundNeutral->GetValue();
434
435 m_syncGenerator->SetElectricalData(data);
436 }
437 else if (m_syncMotor) {
439 data.name = m_textCtrlName->GetValue();
440
441 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlnominalPower->GetValue(), data.nominalPower,
442 _("Value entered incorrectly in the field \"Nominal power\".")))
443 return false;
444 switch (m_choiceNominalPower->GetSelection()) {
445 case 0:
446 data.nominalPowerUnit = ElectricalUnit::UNIT_VA;
447 break;
448 case 1:
449 data.nominalPowerUnit = ElectricalUnit::UNIT_kVA;
450 break;
451 case 2:
452 data.nominalPowerUnit = ElectricalUnit::UNIT_MVA;
453 break;
454 }
455
456 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower,
457 _("Value entered incorrectly in the field \"Active power\".")))
458 return false;
459 switch (m_choiceActivePower->GetSelection()) {
460 case 0:
461 data.activePowerUnit = ElectricalUnit::UNIT_PU;
462 break;
463 case 1:
464 data.activePowerUnit = ElectricalUnit::UNIT_W;
465 break;
466 case 2:
467 data.activePowerUnit = ElectricalUnit::UNIT_kW;
468 break;
469 case 3:
470 data.activePowerUnit = ElectricalUnit::UNIT_MW;
471 break;
472 }
473
474 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlReactivePower->GetValue(), data.reactivePower,
475 _("Value entered incorrectly in the field \"Reactive power\".")))
476 return false;
477 switch (m_choiceReactivePower->GetSelection()) {
478 case 0:
479 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
480 break;
481 case 1:
482 data.reactivePowerUnit = ElectricalUnit::UNIT_var;
483 break;
484 case 2:
485 data.reactivePowerUnit = ElectricalUnit::UNIT_kvar;
486 break;
487 case 3:
488 data.reactivePowerUnit = ElectricalUnit::UNIT_Mvar;
489 break;
490 }
491
492 data.haveMaxReactive = m_checkBoxMaxReactive->GetValue();
493 if (data.haveMaxReactive) {
494 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlMaxRectivePower->GetValue(), data.maxReactive,
495 _("Value entered incorrectly in the field \"Max reactive power\".")))
496 return false;
497 switch (m_choiceMaxRectivePower->GetSelection()) {
498 case 0:
499 data.maxReactiveUnit = ElectricalUnit::UNIT_PU;
500 break;
501 case 1:
502 data.maxReactiveUnit = ElectricalUnit::UNIT_var;
503 break;
504 case 2:
505 data.maxReactiveUnit = ElectricalUnit::UNIT_kvar;
506 break;
507 case 3:
508 data.maxReactiveUnit = ElectricalUnit::UNIT_Mvar;
509 break;
510 }
511 }
512
513 data.haveMinReactive = m_checkBoxMinReactive->GetValue();
514 if (data.haveMinReactive) {
515 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlMinRectivePower->GetValue(), data.minReactive,
516 _("Value entered incorrectly in the field \"Min reactive power\".")))
517 return false;
518 switch (m_choiceMinRectivePower->GetSelection()) {
519 case 0:
520 data.minReactiveUnit = ElectricalUnit::UNIT_PU;
521 break;
522 case 1:
523 data.minReactiveUnit = ElectricalUnit::UNIT_var;
524 break;
525 case 2:
526 data.minReactiveUnit = ElectricalUnit::UNIT_kvar;
527 break;
528 case 3:
529 data.minReactiveUnit = ElectricalUnit::UNIT_Mvar;
530 break;
531 }
532 }
533
534 data.useMachineBase = m_checkBoxUseMachinePower->GetValue();
535
536 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlPosResistance->GetValue(), data.positiveResistance,
537 _("Value entered incorrectly in the field \"Positive resistance\".")))
538 return false;
539
540 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlPosReactance->GetValue(), data.positiveReactance,
541 _("Value entered incorrectly in the field \"Positive reactance\".")))
542 return false;
543
544 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlNegResistance->GetValue(), data.negativeResistance,
545 _("Value entered incorrectly in the field \"Negative resistance\".")))
546 return false;
547
548 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlNegReactance->GetValue(), data.negativeReactance,
549 _("Value entered incorrectly in the field \"Negative reactance\".")))
550 return false;
551
552 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlZeroResistance->GetValue(), data.zeroResistance,
553 _("Value entered incorrectly in the field \"Zero resistance\".")))
554 return false;
555
556 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlZeroReactance->GetValue(), data.zeroReactance,
557 _("Value entered incorrectly in the field \"Zero reactance\".")))
558 return false;
559
560 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlGrdResistance->GetValue(), data.groundResistance,
561 _("Value entered incorrectly in the field \"Ground resistance\".")))
562 return false;
563
564 if (!m_syncMotor->
DoubleFromString(m_parent, m_textCtrlGrdReactance->GetValue(), data.groundReactance,
565 _("Value entered incorrectly in the field \"Ground reactance\".")))
566 return false;
567
568 data.groundNeutral = m_checkBoxGroundNeutral->GetValue();
569
570 m_syncMotor->SetElectricalData(data);
571 }
572 return true;
573}
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.