20TextForm::TextForm(wxWindow* parent,
Text* text, std::vector<Element*> elementList,
double systemPowerBase)
21 : TextFormBase(parent)
23 SetSize(GetBestSize());
26 m_allElements.GetElementsFromList(elementList);
27 m_systemPowerBase = systemPowerBase;
30 m_text->SetElementTypeText(text->GetElementTypeText());
31 m_text->SetElementNumber(text->GetElementNumber());
32 m_text->SetElement(text->GetElement());
33 m_text->SetDataType(text->GetDataType());
34 m_text->SetDirection(text->GetDirection());
35 m_text->SetUnit(text->GetUnit());
36 m_text->SetDecimalPlaces(text->GetDecimalPlaces());
39 m_choiceName->Enable(
false);
40 m_choiceTextType->Enable(
false);
41 m_choiceTextFromBus->Enable(
false);
42 m_choiceTextToBus->Enable(
false);
43 m_choiceTextUnit->Enable(
false);
47TextForm::~TextForm() {}
48void TextForm::OnElementChoiceSelected(wxCommandEvent& event)
50 switch (m_choiceElement->GetSelection()) {
52 m_text->SetElementTypeText(TYPE_BUS);
55 m_text->SetElementTypeText(TYPE_SYNC_GENERATOR);
58 m_text->SetElementTypeText(TYPE_LINE);
61 m_text->SetElementTypeText(TYPE_TRANSFORMER);
64 m_text->SetElementTypeText(TYPE_LOAD);
67 m_text->SetElementTypeText(TYPE_CAPACITOR);
70 m_text->SetElementTypeText(TYPE_INDUCTOR);
73 m_text->SetElementTypeText(TYPE_SYNC_MOTOR);
76 m_text->SetElementTypeText(TYPE_IND_MOTOR);
86void TextForm::OnFromBusChoiceSelected(wxCommandEvent& event)
88 m_text->SetDirection(m_choiceTextFromBus->GetSelection());
89 m_choiceTextToBus->SetSelection(m_choiceTextFromBus->GetSelection());
92void TextForm::OnNameChoiceSelected(wxCommandEvent& event)
94 m_text->SetElementNumber(m_choiceName->GetSelection());
95 ElementNumberChoice();
98void TextForm::OnTextEnter(wxCommandEvent& event) { Preview(); }
99void TextForm::OnToBusChoiceSelected(wxCommandEvent& event)
101 m_text->SetDirection(m_choiceTextToBus->GetSelection());
102 m_choiceTextFromBus->SetSelection(m_choiceTextToBus->GetSelection());
105void TextForm::OnUnitChoiceSelected(wxCommandEvent& event)
111void TextForm::OnTypeChoiceSelected(wxCommandEvent& event)
113 switch (m_text->GetElementTypeText()) {
115 switch (m_choiceTextType->GetSelection()) {
117 m_text->SetDataType(DATA_NAME);
120 m_text->SetDataType(DATA_VOLTAGE);
123 m_text->SetDataType(DATA_ANGLE);
126 m_text->SetDataType(DATA_SC_CURRENT);
129 m_text->SetDataType(DATA_SC_VOLTAGE);
132 m_text->SetDataType(DATA_SC_POWER);
135 m_text->SetDataType(DATA_PQ_THD);
139 case TYPE_SYNC_GENERATOR: {
140 switch (m_choiceTextType->GetSelection()) {
142 m_text->SetDataType(DATA_NAME);
145 m_text->SetDataType(DATA_ACTIVE_POWER);
148 m_text->SetDataType(DATA_REACTIVE_POWER);
151 m_text->SetDataType(DATA_SC_CURRENT);
156 case TYPE_TRANSFORMER: {
157 switch (m_choiceTextType->GetSelection()) {
159 m_text->SetDataType(DATA_NAME);
162 m_text->SetDataType(DATA_PF_ACTIVE);
165 m_text->SetDataType(DATA_PF_REACTIVE);
168 m_text->SetDataType(DATA_PF_LOSSES);
171 m_text->SetDataType(DATA_PF_CURRENT);
174 m_text->SetDataType(DATA_SC_CURRENT);
177 m_text->SetDataType(DATA_TRANSFORMER_TAP);
178 m_text->SetUnit(ElectricalUnit::UNIT_PU);
183 case TYPE_SYNC_MOTOR:
184 case TYPE_IND_MOTOR: {
185 switch (m_choiceTextType->GetSelection()) {
187 m_text->SetDataType(DATA_NAME);
190 m_text->SetDataType(DATA_ACTIVE_POWER);
193 m_text->SetDataType(DATA_REACTIVE_POWER);
198 case TYPE_INDUCTOR: {
199 switch (m_choiceTextType->GetSelection()) {
201 m_text->SetDataType(DATA_NAME);
204 m_text->SetDataType(DATA_REACTIVE_POWER);
213 if (m_text->GetDataType() == DATA_NAME || m_text->GetDataType() == DATA_PQ_THD || m_text->GetDataType() == DATA_TRANSFORMER_TAP) Preview();
216bool TextForm::LoadChoices()
218 if (m_text->GetElementTypeText() == TYPE_NONE)
return false;
222 m_choiceName->SetSelection(m_text->GetElementNumber());
223 ElementNumberChoice();
227 switch (m_text->GetElementTypeText()) {
229 m_choiceElement->SetSelection(0);
230 switch (m_text->GetDataType()) {
232 m_choiceTextType->SetSelection(0);
235 m_choiceTextType->SetSelection(1);
236 switch (m_text->GetUnit()) {
237 case ElectricalUnit::UNIT_PU: {
238 m_choiceTextUnit->SetSelection(0);
240 case ElectricalUnit::UNIT_V: {
241 m_choiceTextUnit->SetSelection(1);
243 case ElectricalUnit::UNIT_kV: {
244 m_choiceTextUnit->SetSelection(2);
252 m_choiceTextType->SetSelection(2);
253 switch (m_text->GetUnit()) {
254 case ElectricalUnit::UNIT_DEGREE: {
255 m_choiceTextUnit->SetSelection(0);
257 case ElectricalUnit::UNIT_RADIAN: {
258 m_choiceTextUnit->SetSelection(1);
264 case DATA_SC_CURRENT: {
265 m_choiceTextType->SetSelection(3);
266 switch (m_text->GetUnit()) {
267 case ElectricalUnit::UNIT_PU: {
268 m_choiceTextUnit->SetSelection(0);
270 case ElectricalUnit::UNIT_A: {
271 m_choiceTextUnit->SetSelection(1);
273 case ElectricalUnit::UNIT_kA: {
274 m_choiceTextUnit->SetSelection(2);
280 case DATA_SC_VOLTAGE: {
281 m_choiceTextType->SetSelection(4);
282 switch (m_text->GetUnit()) {
283 case ElectricalUnit::UNIT_PU: {
284 m_choiceTextUnit->SetSelection(0);
286 case ElectricalUnit::UNIT_V: {
287 m_choiceTextUnit->SetSelection(1);
289 case ElectricalUnit::UNIT_kV: {
290 m_choiceTextUnit->SetSelection(2);
296 case DATA_SC_POWER: {
297 m_choiceTextType->SetSelection(5);
298 switch (m_text->GetUnit()) {
299 case ElectricalUnit::UNIT_PU: {
300 m_choiceTextUnit->SetSelection(0);
302 case ElectricalUnit::UNIT_VA: {
303 m_choiceTextUnit->SetSelection(1);
305 case ElectricalUnit::UNIT_kVA: {
306 m_choiceTextUnit->SetSelection(2);
308 case ElectricalUnit::UNIT_MVA: {
309 m_choiceTextUnit->SetSelection(3);
316 m_choiceTextType->SetSelection(6);
322 case TYPE_SYNC_GENERATOR: {
323 m_choiceElement->SetSelection(1);
324 switch (m_text->GetDataType()) {
326 m_choiceTextType->SetSelection(0);
328 case DATA_ACTIVE_POWER: {
329 m_choiceTextType->SetSelection(1);
330 switch (m_text->GetUnit()) {
331 case ElectricalUnit::UNIT_PU: {
332 m_choiceTextUnit->SetSelection(0);
334 case ElectricalUnit::UNIT_W: {
335 m_choiceTextUnit->SetSelection(1);
337 case ElectricalUnit::UNIT_kW: {
338 m_choiceTextUnit->SetSelection(2);
340 case ElectricalUnit::UNIT_MW: {
341 m_choiceTextUnit->SetSelection(3);
347 case DATA_REACTIVE_POWER: {
348 m_choiceTextType->SetSelection(2);
349 switch (m_text->GetUnit()) {
350 case ElectricalUnit::UNIT_PU: {
351 m_choiceTextUnit->SetSelection(0);
353 case ElectricalUnit::UNIT_var: {
354 m_choiceTextUnit->SetSelection(1);
356 case ElectricalUnit::UNIT_kvar: {
357 m_choiceTextUnit->SetSelection(2);
359 case ElectricalUnit::UNIT_Mvar: {
360 m_choiceTextUnit->SetSelection(3);
366 case DATA_SC_CURRENT: {
367 m_choiceTextType->SetSelection(3);
368 switch (m_text->GetUnit()) {
369 case ElectricalUnit::UNIT_PU: {
370 m_choiceTextUnit->SetSelection(0);
372 case ElectricalUnit::UNIT_A: {
373 m_choiceTextUnit->SetSelection(1);
375 case ElectricalUnit::UNIT_kA: {
376 m_choiceTextUnit->SetSelection(2);
387 m_choiceElement->SetSelection(2);
388 switch (m_text->GetDataType()) {
390 m_choiceTextType->SetSelection(0);
392 case DATA_PF_ACTIVE: {
393 m_choiceTextType->SetSelection(1);
394 switch (m_text->GetUnit()) {
395 case ElectricalUnit::UNIT_PU: {
396 m_choiceTextUnit->SetSelection(0);
398 case ElectricalUnit::UNIT_W: {
399 m_choiceTextUnit->SetSelection(1);
401 case ElectricalUnit::UNIT_kW: {
402 m_choiceTextUnit->SetSelection(2);
404 case ElectricalUnit::UNIT_MW: {
405 m_choiceTextUnit->SetSelection(3);
411 case DATA_PF_REACTIVE: {
412 m_choiceTextType->SetSelection(2);
413 switch (m_text->GetUnit()) {
414 case ElectricalUnit::UNIT_PU: {
415 m_choiceTextUnit->SetSelection(0);
417 case ElectricalUnit::UNIT_var: {
418 m_choiceTextUnit->SetSelection(1);
420 case ElectricalUnit::UNIT_kvar: {
421 m_choiceTextUnit->SetSelection(2);
423 case ElectricalUnit::UNIT_Mvar: {
424 m_choiceTextUnit->SetSelection(3);
430 case DATA_PF_LOSSES: {
431 m_choiceTextType->SetSelection(3);
432 switch (m_text->GetUnit()) {
433 case ElectricalUnit::UNIT_PU: {
434 m_choiceTextUnit->SetSelection(0);
436 case ElectricalUnit::UNIT_W: {
437 m_choiceTextUnit->SetSelection(1);
439 case ElectricalUnit::UNIT_kW: {
440 m_choiceTextUnit->SetSelection(2);
442 case ElectricalUnit::UNIT_MW: {
443 m_choiceTextUnit->SetSelection(3);
449 case DATA_PF_CURRENT: {
450 m_choiceTextType->SetSelection(4);
451 switch (m_text->GetUnit()) {
452 case ElectricalUnit::UNIT_PU: {
453 m_choiceTextUnit->SetSelection(0);
455 case ElectricalUnit::UNIT_A: {
456 m_choiceTextUnit->SetSelection(1);
458 case ElectricalUnit::UNIT_kA: {
459 m_choiceTextUnit->SetSelection(2);
465 case DATA_SC_CURRENT: {
466 m_choiceTextType->SetSelection(5);
467 switch (m_text->GetUnit()) {
468 case ElectricalUnit::UNIT_PU: {
469 m_choiceTextUnit->SetSelection(0);
471 case ElectricalUnit::UNIT_A: {
472 m_choiceTextUnit->SetSelection(1);
474 case ElectricalUnit::UNIT_kA: {
475 m_choiceTextUnit->SetSelection(2);
477 case ElectricalUnit::UNIT_MW: {
478 m_choiceTextUnit->SetSelection(3);
488 case TYPE_TRANSFORMER: {
489 m_choiceElement->SetSelection(3);
490 switch (m_text->GetDataType()) {
492 m_choiceTextType->SetSelection(0);
494 case DATA_PF_ACTIVE: {
495 m_choiceTextType->SetSelection(1);
496 switch (m_text->GetUnit()) {
497 case ElectricalUnit::UNIT_PU: {
498 m_choiceTextUnit->SetSelection(0);
500 case ElectricalUnit::UNIT_W: {
501 m_choiceTextUnit->SetSelection(1);
503 case ElectricalUnit::UNIT_kW: {
504 m_choiceTextUnit->SetSelection(2);
506 case ElectricalUnit::UNIT_MW: {
507 m_choiceTextUnit->SetSelection(3);
513 case DATA_PF_REACTIVE: {
514 m_choiceTextType->SetSelection(2);
515 switch (m_text->GetUnit()) {
516 case ElectricalUnit::UNIT_PU: {
517 m_choiceTextUnit->SetSelection(0);
519 case ElectricalUnit::UNIT_var: {
520 m_choiceTextUnit->SetSelection(1);
522 case ElectricalUnit::UNIT_kvar: {
523 m_choiceTextUnit->SetSelection(2);
525 case ElectricalUnit::UNIT_Mvar: {
526 m_choiceTextUnit->SetSelection(3);
532 case DATA_PF_LOSSES: {
533 m_choiceTextType->SetSelection(3);
534 switch (m_text->GetUnit()) {
535 case ElectricalUnit::UNIT_PU: {
536 m_choiceTextUnit->SetSelection(0);
538 case ElectricalUnit::UNIT_W: {
539 m_choiceTextUnit->SetSelection(1);
541 case ElectricalUnit::UNIT_kW: {
542 m_choiceTextUnit->SetSelection(2);
544 case ElectricalUnit::UNIT_MW: {
545 m_choiceTextUnit->SetSelection(3);
551 case DATA_PF_CURRENT: {
552 m_choiceTextType->SetSelection(4);
553 switch (m_text->GetUnit()) {
554 case ElectricalUnit::UNIT_PU: {
555 m_choiceTextUnit->SetSelection(0);
557 case ElectricalUnit::UNIT_A: {
558 m_choiceTextUnit->SetSelection(1);
560 case ElectricalUnit::UNIT_kA: {
561 m_choiceTextUnit->SetSelection(2);
567 case DATA_SC_CURRENT: {
568 m_choiceTextType->SetSelection(5);
569 switch (m_text->GetUnit()) {
570 case ElectricalUnit::UNIT_PU: {
571 m_choiceTextUnit->SetSelection(0);
573 case ElectricalUnit::UNIT_A: {
574 m_choiceTextUnit->SetSelection(1);
576 case ElectricalUnit::UNIT_kA: {
577 m_choiceTextUnit->SetSelection(2);
583 case DATA_TRANSFORMER_TAP: {
584 m_choiceTextType->SetSelection(6);
585 switch (m_text->GetUnit()) {
586 case ElectricalUnit::UNIT_PU: {
587 m_choiceTextUnit->SetSelection(0);
589 case ElectricalUnit::UNIT_NONE: {
590 m_choiceTextUnit->SetSelection(1);
593 m_choiceTextUnit->SetSelection(0);
602 m_choiceElement->SetSelection(4);
603 switch (m_text->GetDataType()) {
605 m_choiceTextType->SetSelection(0);
607 case DATA_ACTIVE_POWER: {
608 m_choiceTextType->SetSelection(1);
609 switch (m_text->GetUnit()) {
610 case ElectricalUnit::UNIT_PU: {
611 m_choiceTextUnit->SetSelection(0);
613 case ElectricalUnit::UNIT_W: {
614 m_choiceTextUnit->SetSelection(1);
616 case ElectricalUnit::UNIT_kW: {
617 m_choiceTextUnit->SetSelection(2);
619 case ElectricalUnit::UNIT_MW: {
620 m_choiceTextUnit->SetSelection(3);
626 case DATA_REACTIVE_POWER: {
627 m_choiceTextType->SetSelection(2);
628 switch (m_text->GetUnit()) {
629 case ElectricalUnit::UNIT_PU: {
630 m_choiceTextUnit->SetSelection(0);
632 case ElectricalUnit::UNIT_var: {
633 m_choiceTextUnit->SetSelection(1);
635 case ElectricalUnit::UNIT_kvar: {
636 m_choiceTextUnit->SetSelection(2);
638 case ElectricalUnit::UNIT_Mvar: {
639 m_choiceTextUnit->SetSelection(3);
649 case TYPE_CAPACITOR: {
650 m_choiceElement->SetSelection(5);
651 switch (m_text->GetDataType()) {
653 m_choiceTextType->SetSelection(0);
655 case DATA_REACTIVE_POWER: {
656 m_choiceTextType->SetSelection(1);
657 switch (m_text->GetUnit()) {
658 case ElectricalUnit::UNIT_PU: {
659 m_choiceTextUnit->SetSelection(0);
661 case ElectricalUnit::UNIT_var: {
662 m_choiceTextUnit->SetSelection(1);
664 case ElectricalUnit::UNIT_kvar: {
665 m_choiceTextUnit->SetSelection(2);
667 case ElectricalUnit::UNIT_Mvar: {
668 m_choiceTextUnit->SetSelection(3);
678 case TYPE_INDUCTOR: {
679 m_choiceElement->SetSelection(6);
680 switch (m_text->GetDataType()) {
682 m_choiceTextType->SetSelection(0);
684 case DATA_REACTIVE_POWER: {
685 m_choiceTextType->SetSelection(1);
686 switch (m_text->GetUnit()) {
687 case ElectricalUnit::UNIT_PU: {
688 m_choiceTextUnit->SetSelection(0);
690 case ElectricalUnit::UNIT_var: {
691 m_choiceTextUnit->SetSelection(1);
693 case ElectricalUnit::UNIT_kvar: {
694 m_choiceTextUnit->SetSelection(2);
696 case ElectricalUnit::UNIT_Mvar: {
697 m_choiceTextUnit->SetSelection(3);
707 case TYPE_SYNC_MOTOR: {
708 m_choiceElement->SetSelection(7);
709 switch (m_text->GetDataType()) {
711 m_choiceTextType->SetSelection(0);
713 case DATA_ACTIVE_POWER: {
714 m_choiceTextType->SetSelection(1);
715 switch (m_text->GetUnit()) {
716 case ElectricalUnit::UNIT_PU: {
717 m_choiceTextUnit->SetSelection(0);
719 case ElectricalUnit::UNIT_W: {
720 m_choiceTextUnit->SetSelection(1);
722 case ElectricalUnit::UNIT_kW: {
723 m_choiceTextUnit->SetSelection(2);
725 case ElectricalUnit::UNIT_MW: {
726 m_choiceTextUnit->SetSelection(3);
732 case DATA_REACTIVE_POWER: {
733 m_choiceTextType->SetSelection(2);
734 switch (m_text->GetUnit()) {
735 case ElectricalUnit::UNIT_PU: {
736 m_choiceTextUnit->SetSelection(0);
738 case ElectricalUnit::UNIT_var: {
739 m_choiceTextUnit->SetSelection(1);
741 case ElectricalUnit::UNIT_kvar: {
742 m_choiceTextUnit->SetSelection(2);
744 case ElectricalUnit::UNIT_Mvar: {
745 m_choiceTextUnit->SetSelection(3);
755 case TYPE_IND_MOTOR: {
756 m_choiceElement->SetSelection(8);
757 switch (m_text->GetDataType()) {
759 m_choiceTextType->SetSelection(0);
761 case DATA_ACTIVE_POWER: {
762 m_choiceTextType->SetSelection(1);
763 switch (m_text->GetUnit()) {
764 case ElectricalUnit::UNIT_PU: {
765 m_choiceTextUnit->SetSelection(0);
767 case ElectricalUnit::UNIT_W: {
768 m_choiceTextUnit->SetSelection(1);
770 case ElectricalUnit::UNIT_kW: {
771 m_choiceTextUnit->SetSelection(2);
773 case ElectricalUnit::UNIT_MW: {
774 m_choiceTextUnit->SetSelection(3);
780 case DATA_REACTIVE_POWER: {
781 m_choiceTextType->SetSelection(2);
782 switch (m_text->GetUnit()) {
783 case ElectricalUnit::UNIT_PU: {
784 m_choiceTextUnit->SetSelection(0);
786 case ElectricalUnit::UNIT_var: {
787 m_choiceTextUnit->SetSelection(1);
789 case ElectricalUnit::UNIT_kvar: {
790 m_choiceTextUnit->SetSelection(2);
792 case ElectricalUnit::UNIT_Mvar: {
793 m_choiceTextUnit->SetSelection(3);
807 if (m_choiceTextFromBus->IsEnabled()) m_choiceTextFromBus->SetSelection(m_text->GetDirection());
808 if (m_choiceTextToBus->IsEnabled()) m_choiceTextToBus->SetSelection(m_text->GetDirection());
810 m_textCtrlDecimal->SetValue(wxString::Format(
"%d", m_text->GetDecimalPlaces()));
816void TextForm::ElementTypeChoice()
818 m_choiceTextType->Enable(
false);
819 m_choiceTextFromBus->Enable(
false);
820 m_choiceTextToBus->Enable(
false);
821 m_choiceTextUnit->Enable(
false);
822 m_choiceTextType->Clear();
823 m_choiceTextFromBus->Clear();
824 m_choiceTextToBus->Clear();
825 m_choiceTextUnit->Clear();
827 m_choiceName->Clear();
828 wxArrayString arrayString;
829 switch (m_text->GetElementTypeText()) {
831 for (
int i = 0; i < (int)m_allElements.
GetBusList().size(); i++) {
833 arrayString.Add(bus->GetElectricalData().name);
836 case TYPE_SYNC_GENERATOR: {
839 arrayString.Add(syncGenerator->GetElectricalData().name);
843 for (
int i = 0; i < (int)m_allElements.
GetLineList().size(); i++) {
845 arrayString.Add(line->GetElectricalData().name);
848 case TYPE_TRANSFORMER: {
851 arrayString.Add(transformer->GetElectricalData().name);
855 for (
int i = 0; i < (int)m_allElements.
GetLoadList().size(); i++) {
857 arrayString.Add(load->GetElectricalData().name);
860 case TYPE_CAPACITOR: {
863 arrayString.Add(capacitor->GetElectricalData().name);
866 case TYPE_INDUCTOR: {
867 for (
int i = 0; i < (int)m_allElements.
GetInductorList().size(); i++) {
869 arrayString.Add(inductor->GetElectricalData().name);
872 case TYPE_SYNC_MOTOR: {
875 arrayString.Add(syncMotor->GetElectricalData().name);
878 case TYPE_IND_MOTOR: {
879 for (
int i = 0; i < (int)m_allElements.
GetIndMotorList().size(); i++) {
881 arrayString.Add(indMotor->GetElectricalData().name);
888 m_choiceName->Append(arrayString);
889 m_choiceName->Enable();
892void TextForm::ElementNumberChoice()
894 m_choiceTextFromBus->Enable(
false);
895 m_choiceTextToBus->Enable(
false);
896 m_choiceTextUnit->Enable(
false);
897 m_choiceTextFromBus->Clear();
898 m_choiceTextToBus->Clear();
899 m_choiceTextUnit->Clear();
901 int index = m_choiceName->GetSelection();
902 m_text->SetElementNumber(index);
904 m_choiceTextType->Clear();
905 wxArrayString arrayString;
906 switch (m_text->GetElementTypeText()) {
909 m_text->SetElement(bus);
911 arrayString.Add(_(
"Name"));
912 arrayString.Add(_(
"Voltage"));
913 arrayString.Add(_(
"Angle"));
914 arrayString.Add(_(
"Fault current"));
915 arrayString.Add(_(
"Fault voltage"));
916 arrayString.Add(_(
"Short-circuit power"));
917 arrayString.Add(_(
"Voltage THD"));
919 case TYPE_SYNC_GENERATOR: {
921 m_text->SetElement(syncGenerator);
923 arrayString.Add(_(
"Name"));
924 arrayString.Add(_(
"Active power"));
925 arrayString.Add(_(
"Reactive power"));
926 arrayString.Add(_(
"Fault current"));
930 m_text->SetElement(line);
932 arrayString.Add(_(
"Name"));
933 arrayString.Add(_(
"Active power flow"));
934 arrayString.Add(_(
"Reactive power flow"));
935 arrayString.Add(_(
"Losses"));
936 arrayString.Add(_(
"Current"));
937 arrayString.Add(_(
"Fault current"));
939 case TYPE_TRANSFORMER: {
941 m_text->SetElement(transformer);
943 arrayString.Add(_(
"Name"));
944 arrayString.Add(_(
"Active power flow"));
945 arrayString.Add(_(
"Reactive power flow"));
946 arrayString.Add(_(
"Losses"));
947 arrayString.Add(_(
"Current"));
948 arrayString.Add(_(
"Fault current"));
949 arrayString.Add(_(
"Tap"));
953 m_text->SetElement(load);
955 arrayString.Add(_(
"Name"));
956 arrayString.Add(_(
"Active power"));
957 arrayString.Add(_(
"Reactive power"));
959 case TYPE_CAPACITOR: {
961 m_text->SetElement(capacitor);
963 arrayString.Add(_(
"Name"));
964 arrayString.Add(_(
"Reactive power"));
966 case TYPE_INDUCTOR: {
968 m_text->SetElement(inductor);
970 arrayString.Add(_(
"Name"));
971 arrayString.Add(_(
"Reactive power"));
973 case TYPE_SYNC_MOTOR: {
975 m_text->SetElement(syncMotor);
977 arrayString.Add(_(
"Name"));
978 arrayString.Add(_(
"Active power"));
979 arrayString.Add(_(
"Reactive power"));
981 case TYPE_IND_MOTOR: {
983 m_text->SetElement(indMotor);
985 arrayString.Add(_(
"Name"));
986 arrayString.Add(_(
"Active power"));
987 arrayString.Add(_(
"Reactive power"));
993 m_choiceTextType->Append(arrayString);
994 m_choiceTextType->Enable();
997void TextForm::DataTypeChoice()
999 m_choiceTextFromBus->Enable(
false);
1000 m_choiceTextToBus->Enable(
false);
1002 m_choiceTextToBus->Clear();
1003 m_choiceTextFromBus->Clear();
1004 m_choiceTextUnit->Clear();
1006 m_choiceTextUnit->Enable();
1008 wxArrayString arrayString;
1009 switch (m_text->GetDataType()) {
1012 m_choiceTextUnit->Enable(
false);
1016 case DATA_SC_VOLTAGE: {
1017 arrayString.Add(_(
"p.u."));
1018 arrayString.Add(_(
"V"));
1019 arrayString.Add(_(
"kV"));
1022 arrayString.Add(_(
"Degrees"));
1023 arrayString.Add(_(
"Radians"));
1025 case DATA_SC_CURRENT:
1026 case DATA_PF_CURRENT: {
1027 arrayString.Add(_(
"p.u."));
1028 arrayString.Add(_(
"A"));
1029 arrayString.Add(_(
"kA"));
1031 case DATA_SC_POWER: {
1032 arrayString.Add(_(
"p.u."));
1033 arrayString.Add(_(
"VA"));
1034 arrayString.Add(_(
"kVA"));
1035 arrayString.Add(_(
"MVA"));
1037 case DATA_ACTIVE_POWER:
1038 case DATA_PF_ACTIVE:
1039 case DATA_PF_LOSSES: {
1040 arrayString.Add(_(
"p.u."));
1041 arrayString.Add(_(
"W"));
1042 arrayString.Add(_(
"kW"));
1043 arrayString.Add(_(
"MW"));
1044 m_choiceTextUnit->Enable();
1046 case DATA_REACTIVE_POWER:
1047 case DATA_PF_REACTIVE: {
1048 arrayString.Add(_(
"p.u."));
1049 arrayString.Add(_(
"var"));
1050 arrayString.Add(_(
"kvar"));
1051 arrayString.Add(_(
"Mvar"));
1053 case DATA_TRANSFORMER_TAP: {
1054 arrayString.Add(_(
"p.u."));
1055 arrayString.Add(_(
"None"));
1060 m_choiceTextUnit->Append(arrayString);
1062 if (m_text->GetDataType() == DATA_TRANSFORMER_TAP) {
1063 m_choiceTextUnit->SetSelection(m_text->GetUnit() == ElectricalUnit::UNIT_NONE ? 1 : 0);
1066 switch (m_text->GetElementTypeText()) {
1068 if (m_text->GetDataType() != DATA_PF_LOSSES) {
1076 wxString bus1Name = bus1->GetElectricalData().name;
1077 wxString bus2Name = bus2->GetElectricalData().name;
1079 m_choiceTextFromBus->Append(bus1Name);
1080 m_choiceTextFromBus->Append(bus2Name);
1081 m_choiceTextToBus->Append(bus2Name);
1082 m_choiceTextToBus->Append(bus1Name);
1083 m_choiceTextFromBus->SetSelection(0);
1084 m_choiceTextToBus->SetSelection(0);
1086 m_choiceTextFromBus->Enable();
1087 m_choiceTextToBus->Enable();
1090 case TYPE_TRANSFORMER: {
1091 if (m_text->GetDataType() != DATA_PF_LOSSES && m_text->GetDataType() != DATA_TRANSFORMER_TAP) {
1098 wxString bus1Name = bus1->GetElectricalData().name;
1099 wxString bus2Name = bus2->GetElectricalData().name;
1101 m_choiceTextFromBus->Append(bus1Name);
1102 m_choiceTextFromBus->Append(bus2Name);
1103 m_choiceTextToBus->Append(bus2Name);
1104 m_choiceTextToBus->Append(bus1Name);
1105 m_choiceTextFromBus->SetSelection(0);
1106 m_choiceTextToBus->SetSelection(0);
1108 m_choiceTextFromBus->Enable();
1109 m_choiceTextToBus->Enable();
1117void TextForm::UnitChoice()
1119 switch (m_text->GetDataType()) {
1121 m_choiceTextUnit->Enable(
false);
1125 case DATA_SC_VOLTAGE: {
1126 switch (m_choiceTextUnit->GetSelection()) {
1128 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1131 m_text->SetUnit(ElectricalUnit::UNIT_V);
1134 m_text->SetUnit(ElectricalUnit::UNIT_kV);
1141 switch (m_choiceTextUnit->GetSelection()) {
1143 m_text->SetUnit(ElectricalUnit::UNIT_DEGREE);
1146 m_text->SetUnit(ElectricalUnit::UNIT_RADIAN);
1152 case DATA_SC_CURRENT:
1153 case DATA_PF_CURRENT: {
1154 switch (m_choiceTextUnit->GetSelection()) {
1156 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1159 m_text->SetUnit(ElectricalUnit::UNIT_A);
1162 m_text->SetUnit(ElectricalUnit::UNIT_kA);
1168 case DATA_SC_POWER: {
1169 switch (m_choiceTextUnit->GetSelection()) {
1171 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1174 m_text->SetUnit(ElectricalUnit::UNIT_VA);
1177 m_text->SetUnit(ElectricalUnit::UNIT_kVA);
1180 m_text->SetUnit(ElectricalUnit::UNIT_MVA);
1186 case DATA_ACTIVE_POWER:
1187 case DATA_PF_ACTIVE:
1188 case DATA_PF_LOSSES: {
1189 switch (m_choiceTextUnit->GetSelection()) {
1191 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1194 m_text->SetUnit(ElectricalUnit::UNIT_W);
1197 m_text->SetUnit(ElectricalUnit::UNIT_kW);
1200 m_text->SetUnit(ElectricalUnit::UNIT_MW);
1206 case DATA_REACTIVE_POWER:
1207 case DATA_PF_REACTIVE: {
1208 switch (m_choiceTextUnit->GetSelection()) {
1210 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1213 m_text->SetUnit(ElectricalUnit::UNIT_var);
1216 m_text->SetUnit(ElectricalUnit::UNIT_kvar);
1219 m_text->SetUnit(ElectricalUnit::UNIT_Mvar);
1225 case DATA_TRANSFORMER_TAP: {
1226 switch (m_choiceTextUnit->GetSelection()) {
1228 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1231 m_text->SetUnit(ElectricalUnit::UNIT_NONE);
1242void TextForm::Preview()
1244 double decimalPlaces = m_text->GetDecimalPlaces();
1245 if (m_textCtrlDecimal->GetValue().ToDouble(&decimalPlaces)) m_text->SetDecimalPlaces(decimalPlaces);
1247 m_text->UpdateText(m_systemPowerBase);
1249 m_textCtrlPreview->SetValue(m_text->GetText());
1252bool TextForm::ValidateData()
1254 if (m_choiceElement->GetSelection() == -1)
return false;
1255 if (m_choiceName->GetSelection() == -1)
return false;
1256 if (m_choiceTextType->GetSelection() == -1)
return false;
1257 if (m_text->GetDataType() != DATA_NAME && m_text->GetDataType() != DATA_PQ_THD &&
1258 m_choiceTextUnit->GetSelection() == -1)
1260 if (m_text->GetElementTypeText() == TYPE_LINE || m_text->GetElementTypeText() == TYPE_TRANSFORMER) {
1261 if (m_text->GetDataType() != DATA_PF_LOSSES && m_text->GetDataType() != DATA_NAME && m_text->GetDataType() != DATA_TRANSFORMER_TAP) {
1262 if (m_choiceTextFromBus->GetSelection() == -1)
return false;
1263 if (m_choiceTextToBus->GetSelection() == -1)
return false;
1267 if (m_choiceTextFromBus->IsEnabled() && m_choiceTextToBus->IsEnabled())
1268 m_text->SetDirection(m_choiceTextFromBus->GetSelection());
1269 double decimalPlaces = m_text->GetDecimalPlaces();
1270 if (m_textCtrlDecimal->GetValue().ToDouble(&decimalPlaces)) m_text->SetDecimalPlaces(decimalPlaces);
1272 m_textToEdit->SetElementTypeText(m_text->GetElementTypeText());
1273 m_textToEdit->SetElementNumber(m_text->GetElementNumber());
1274 m_textToEdit->SetElement(m_text->GetElement());
1275 m_textToEdit->SetDataType(m_text->GetDataType());
1276 m_textToEdit->SetDirection(m_text->GetDirection());
1277 m_textToEdit->SetUnit(m_text->GetUnit());
1278 m_textToEdit->SetDecimalPlaces(decimalPlaces);
1279 m_textToEdit->UpdateText(m_systemPowerBase);
1284void TextForm::OnOKButtonClick(wxCommandEvent& event)
1286 if (ValidateData()) {
1290 wxString errorMsg = _(
"There are blank fields.");
1291 wxMessageDialog msgDialog(
this, errorMsg, _(
"Error"), wxOK | wxCENTRE | wxICON_ERROR);
1292 msgDialog.ShowModal();
Node for power elements. All others power elements are connected through this.
Shunt capactior power element.
const std::vector< IndMotor * > GetIndMotorList() const
Get the induction motors of the system (use GetElementsFromList first).
const std::vector< Load * > GetLoadList() const
Get the loads of the system (use GetElementsFromList first).
const std::vector< SyncMotor * > GetSyncMotorList() const
Get the synchronous motors of the system (use GetElementsFromList first).
const std::vector< SyncGenerator * > GetSyncGeneratorList() const
Get the synchronous generators of the system (use GetElementsFromList first).
const std::vector< Transformer * > GetTransformerList() const
Get the transformers of the system (use GetElementsFromList first).
const std::vector< Capacitor * > GetCapacitorList() const
Get the capacitors of the system (use GetElementsFromList first).
const std::vector< Inductor * > GetInductorList() const
Get the inductors of the system (use GetElementsFromList first).
const std::vector< Line * > GetLineList() const
Get the lines of the system (use GetElementsFromList first).
const std::vector< Bus * > GetBusList() const
Get the buses of the system (use GetElementsFromList first).
virtual std::vector< Element * > GetParentList() const
Get the parent list.
Induction motor power element.
Inductor shunt power element.
Loas shunt power element.
Synchronous generator power element.
Synchronous motor (synchronous compensator) power element.
Element that shows power element informations in workspace.