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);
179 case TYPE_SYNC_MOTOR:
180 case TYPE_IND_MOTOR: {
181 switch (m_choiceTextType->GetSelection()) {
183 m_text->SetDataType(DATA_NAME);
186 m_text->SetDataType(DATA_ACTIVE_POWER);
189 m_text->SetDataType(DATA_REACTIVE_POWER);
194 case TYPE_INDUCTOR: {
195 switch (m_choiceTextType->GetSelection()) {
197 m_text->SetDataType(DATA_NAME);
200 m_text->SetDataType(DATA_REACTIVE_POWER);
209 if (m_text->GetDataType() == DATA_NAME || m_text->GetDataType() == DATA_PQ_THD) Preview();
212bool TextForm::LoadChoices()
214 if (m_text->GetElementTypeText() == TYPE_NONE)
return false;
218 m_choiceName->SetSelection(m_text->GetElementNumber());
219 ElementNumberChoice();
223 switch (m_text->GetElementTypeText()) {
225 m_choiceElement->SetSelection(0);
226 switch (m_text->GetDataType()) {
228 m_choiceTextType->SetSelection(0);
231 m_choiceTextType->SetSelection(1);
232 switch (m_text->GetUnit()) {
233 case ElectricalUnit::UNIT_PU: {
234 m_choiceTextUnit->SetSelection(0);
236 case ElectricalUnit::UNIT_V: {
237 m_choiceTextUnit->SetSelection(1);
239 case ElectricalUnit::UNIT_kV: {
240 m_choiceTextUnit->SetSelection(2);
248 m_choiceTextType->SetSelection(2);
249 switch (m_text->GetUnit()) {
250 case ElectricalUnit::UNIT_DEGREE: {
251 m_choiceTextUnit->SetSelection(0);
253 case ElectricalUnit::UNIT_RADIAN: {
254 m_choiceTextUnit->SetSelection(1);
260 case DATA_SC_CURRENT: {
261 m_choiceTextType->SetSelection(3);
262 switch (m_text->GetUnit()) {
263 case ElectricalUnit::UNIT_PU: {
264 m_choiceTextUnit->SetSelection(0);
266 case ElectricalUnit::UNIT_A: {
267 m_choiceTextUnit->SetSelection(1);
269 case ElectricalUnit::UNIT_kA: {
270 m_choiceTextUnit->SetSelection(2);
276 case DATA_SC_VOLTAGE: {
277 m_choiceTextType->SetSelection(4);
278 switch (m_text->GetUnit()) {
279 case ElectricalUnit::UNIT_PU: {
280 m_choiceTextUnit->SetSelection(0);
282 case ElectricalUnit::UNIT_V: {
283 m_choiceTextUnit->SetSelection(1);
285 case ElectricalUnit::UNIT_kV: {
286 m_choiceTextUnit->SetSelection(2);
292 case DATA_SC_POWER: {
293 m_choiceTextType->SetSelection(5);
294 switch (m_text->GetUnit()) {
295 case ElectricalUnit::UNIT_PU: {
296 m_choiceTextUnit->SetSelection(0);
298 case ElectricalUnit::UNIT_VA: {
299 m_choiceTextUnit->SetSelection(1);
301 case ElectricalUnit::UNIT_kVA: {
302 m_choiceTextUnit->SetSelection(2);
304 case ElectricalUnit::UNIT_MVA: {
305 m_choiceTextUnit->SetSelection(3);
312 m_choiceTextType->SetSelection(6);
318 case TYPE_SYNC_GENERATOR: {
319 m_choiceElement->SetSelection(1);
320 switch (m_text->GetDataType()) {
322 m_choiceTextType->SetSelection(0);
324 case DATA_ACTIVE_POWER: {
325 m_choiceTextType->SetSelection(1);
326 switch (m_text->GetUnit()) {
327 case ElectricalUnit::UNIT_PU: {
328 m_choiceTextUnit->SetSelection(0);
330 case ElectricalUnit::UNIT_W: {
331 m_choiceTextUnit->SetSelection(1);
333 case ElectricalUnit::UNIT_kW: {
334 m_choiceTextUnit->SetSelection(2);
336 case ElectricalUnit::UNIT_MW: {
337 m_choiceTextUnit->SetSelection(3);
343 case DATA_REACTIVE_POWER: {
344 m_choiceTextType->SetSelection(2);
345 switch (m_text->GetUnit()) {
346 case ElectricalUnit::UNIT_PU: {
347 m_choiceTextUnit->SetSelection(0);
349 case ElectricalUnit::UNIT_var: {
350 m_choiceTextUnit->SetSelection(1);
352 case ElectricalUnit::UNIT_kvar: {
353 m_choiceTextUnit->SetSelection(2);
355 case ElectricalUnit::UNIT_Mvar: {
356 m_choiceTextUnit->SetSelection(3);
362 case DATA_SC_CURRENT: {
363 m_choiceTextType->SetSelection(3);
364 switch (m_text->GetUnit()) {
365 case ElectricalUnit::UNIT_PU: {
366 m_choiceTextUnit->SetSelection(0);
368 case ElectricalUnit::UNIT_A: {
369 m_choiceTextUnit->SetSelection(1);
371 case ElectricalUnit::UNIT_kA: {
372 m_choiceTextUnit->SetSelection(2);
383 m_choiceElement->SetSelection(2);
384 switch (m_text->GetDataType()) {
386 m_choiceTextType->SetSelection(0);
388 case DATA_PF_ACTIVE: {
389 m_choiceTextType->SetSelection(1);
390 switch (m_text->GetUnit()) {
391 case ElectricalUnit::UNIT_PU: {
392 m_choiceTextUnit->SetSelection(0);
394 case ElectricalUnit::UNIT_W: {
395 m_choiceTextUnit->SetSelection(1);
397 case ElectricalUnit::UNIT_kW: {
398 m_choiceTextUnit->SetSelection(2);
400 case ElectricalUnit::UNIT_MW: {
401 m_choiceTextUnit->SetSelection(3);
407 case DATA_PF_REACTIVE: {
408 m_choiceTextType->SetSelection(2);
409 switch (m_text->GetUnit()) {
410 case ElectricalUnit::UNIT_PU: {
411 m_choiceTextUnit->SetSelection(0);
413 case ElectricalUnit::UNIT_var: {
414 m_choiceTextUnit->SetSelection(1);
416 case ElectricalUnit::UNIT_kvar: {
417 m_choiceTextUnit->SetSelection(2);
419 case ElectricalUnit::UNIT_Mvar: {
420 m_choiceTextUnit->SetSelection(3);
426 case DATA_PF_LOSSES: {
427 m_choiceTextType->SetSelection(3);
428 switch (m_text->GetUnit()) {
429 case ElectricalUnit::UNIT_PU: {
430 m_choiceTextUnit->SetSelection(0);
432 case ElectricalUnit::UNIT_W: {
433 m_choiceTextUnit->SetSelection(1);
435 case ElectricalUnit::UNIT_kW: {
436 m_choiceTextUnit->SetSelection(2);
438 case ElectricalUnit::UNIT_MW: {
439 m_choiceTextUnit->SetSelection(3);
445 case DATA_PF_CURRENT: {
446 m_choiceTextType->SetSelection(4);
447 switch (m_text->GetUnit()) {
448 case ElectricalUnit::UNIT_PU: {
449 m_choiceTextUnit->SetSelection(0);
451 case ElectricalUnit::UNIT_A: {
452 m_choiceTextUnit->SetSelection(1);
454 case ElectricalUnit::UNIT_kA: {
455 m_choiceTextUnit->SetSelection(2);
461 case DATA_SC_CURRENT: {
462 m_choiceTextType->SetSelection(5);
463 switch (m_text->GetUnit()) {
464 case ElectricalUnit::UNIT_PU: {
465 m_choiceTextUnit->SetSelection(0);
467 case ElectricalUnit::UNIT_A: {
468 m_choiceTextUnit->SetSelection(1);
470 case ElectricalUnit::UNIT_kA: {
471 m_choiceTextUnit->SetSelection(2);
473 case ElectricalUnit::UNIT_MW: {
474 m_choiceTextUnit->SetSelection(3);
484 case TYPE_TRANSFORMER: {
485 m_choiceElement->SetSelection(3);
486 switch (m_text->GetDataType()) {
488 m_choiceTextType->SetSelection(0);
490 case DATA_PF_ACTIVE: {
491 m_choiceTextType->SetSelection(1);
492 switch (m_text->GetUnit()) {
493 case ElectricalUnit::UNIT_PU: {
494 m_choiceTextUnit->SetSelection(0);
496 case ElectricalUnit::UNIT_W: {
497 m_choiceTextUnit->SetSelection(1);
499 case ElectricalUnit::UNIT_kW: {
500 m_choiceTextUnit->SetSelection(2);
502 case ElectricalUnit::UNIT_MW: {
503 m_choiceTextUnit->SetSelection(3);
509 case DATA_PF_REACTIVE: {
510 m_choiceTextType->SetSelection(2);
511 switch (m_text->GetUnit()) {
512 case ElectricalUnit::UNIT_PU: {
513 m_choiceTextUnit->SetSelection(0);
515 case ElectricalUnit::UNIT_var: {
516 m_choiceTextUnit->SetSelection(1);
518 case ElectricalUnit::UNIT_kvar: {
519 m_choiceTextUnit->SetSelection(2);
521 case ElectricalUnit::UNIT_Mvar: {
522 m_choiceTextUnit->SetSelection(3);
528 case DATA_PF_LOSSES: {
529 m_choiceTextType->SetSelection(3);
530 switch (m_text->GetUnit()) {
531 case ElectricalUnit::UNIT_PU: {
532 m_choiceTextUnit->SetSelection(0);
534 case ElectricalUnit::UNIT_W: {
535 m_choiceTextUnit->SetSelection(1);
537 case ElectricalUnit::UNIT_kW: {
538 m_choiceTextUnit->SetSelection(2);
540 case ElectricalUnit::UNIT_MW: {
541 m_choiceTextUnit->SetSelection(3);
547 case DATA_PF_CURRENT: {
548 m_choiceTextType->SetSelection(4);
549 switch (m_text->GetUnit()) {
550 case ElectricalUnit::UNIT_PU: {
551 m_choiceTextUnit->SetSelection(0);
553 case ElectricalUnit::UNIT_A: {
554 m_choiceTextUnit->SetSelection(1);
556 case ElectricalUnit::UNIT_kA: {
557 m_choiceTextUnit->SetSelection(2);
563 case DATA_SC_CURRENT: {
564 m_choiceTextType->SetSelection(5);
565 switch (m_text->GetUnit()) {
566 case ElectricalUnit::UNIT_PU: {
567 m_choiceTextUnit->SetSelection(0);
569 case ElectricalUnit::UNIT_A: {
570 m_choiceTextUnit->SetSelection(1);
572 case ElectricalUnit::UNIT_kA: {
573 m_choiceTextUnit->SetSelection(2);
584 m_choiceElement->SetSelection(4);
585 switch (m_text->GetDataType()) {
587 m_choiceTextType->SetSelection(0);
589 case DATA_ACTIVE_POWER: {
590 m_choiceTextType->SetSelection(1);
591 switch (m_text->GetUnit()) {
592 case ElectricalUnit::UNIT_PU: {
593 m_choiceTextUnit->SetSelection(0);
595 case ElectricalUnit::UNIT_W: {
596 m_choiceTextUnit->SetSelection(1);
598 case ElectricalUnit::UNIT_kW: {
599 m_choiceTextUnit->SetSelection(2);
601 case ElectricalUnit::UNIT_MW: {
602 m_choiceTextUnit->SetSelection(3);
608 case DATA_REACTIVE_POWER: {
609 m_choiceTextType->SetSelection(2);
610 switch (m_text->GetUnit()) {
611 case ElectricalUnit::UNIT_PU: {
612 m_choiceTextUnit->SetSelection(0);
614 case ElectricalUnit::UNIT_var: {
615 m_choiceTextUnit->SetSelection(1);
617 case ElectricalUnit::UNIT_kvar: {
618 m_choiceTextUnit->SetSelection(2);
620 case ElectricalUnit::UNIT_Mvar: {
621 m_choiceTextUnit->SetSelection(3);
631 case TYPE_CAPACITOR: {
632 m_choiceElement->SetSelection(5);
633 switch (m_text->GetDataType()) {
635 m_choiceTextType->SetSelection(0);
637 case DATA_REACTIVE_POWER: {
638 m_choiceTextType->SetSelection(1);
639 switch (m_text->GetUnit()) {
640 case ElectricalUnit::UNIT_PU: {
641 m_choiceTextUnit->SetSelection(0);
643 case ElectricalUnit::UNIT_var: {
644 m_choiceTextUnit->SetSelection(1);
646 case ElectricalUnit::UNIT_kvar: {
647 m_choiceTextUnit->SetSelection(2);
649 case ElectricalUnit::UNIT_Mvar: {
650 m_choiceTextUnit->SetSelection(3);
660 case TYPE_INDUCTOR: {
661 m_choiceElement->SetSelection(6);
662 switch (m_text->GetDataType()) {
664 m_choiceTextType->SetSelection(0);
666 case DATA_REACTIVE_POWER: {
667 m_choiceTextType->SetSelection(1);
668 switch (m_text->GetUnit()) {
669 case ElectricalUnit::UNIT_PU: {
670 m_choiceTextUnit->SetSelection(0);
672 case ElectricalUnit::UNIT_var: {
673 m_choiceTextUnit->SetSelection(1);
675 case ElectricalUnit::UNIT_kvar: {
676 m_choiceTextUnit->SetSelection(2);
678 case ElectricalUnit::UNIT_Mvar: {
679 m_choiceTextUnit->SetSelection(3);
689 case TYPE_SYNC_MOTOR: {
690 m_choiceElement->SetSelection(7);
691 switch (m_text->GetDataType()) {
693 m_choiceTextType->SetSelection(0);
695 case DATA_ACTIVE_POWER: {
696 m_choiceTextType->SetSelection(1);
697 switch (m_text->GetUnit()) {
698 case ElectricalUnit::UNIT_PU: {
699 m_choiceTextUnit->SetSelection(0);
701 case ElectricalUnit::UNIT_W: {
702 m_choiceTextUnit->SetSelection(1);
704 case ElectricalUnit::UNIT_kW: {
705 m_choiceTextUnit->SetSelection(2);
707 case ElectricalUnit::UNIT_MW: {
708 m_choiceTextUnit->SetSelection(3);
714 case DATA_REACTIVE_POWER: {
715 m_choiceTextType->SetSelection(2);
716 switch (m_text->GetUnit()) {
717 case ElectricalUnit::UNIT_PU: {
718 m_choiceTextUnit->SetSelection(0);
720 case ElectricalUnit::UNIT_var: {
721 m_choiceTextUnit->SetSelection(1);
723 case ElectricalUnit::UNIT_kvar: {
724 m_choiceTextUnit->SetSelection(2);
726 case ElectricalUnit::UNIT_Mvar: {
727 m_choiceTextUnit->SetSelection(3);
737 case TYPE_IND_MOTOR: {
738 m_choiceElement->SetSelection(8);
739 switch (m_text->GetDataType()) {
741 m_choiceTextType->SetSelection(0);
743 case DATA_ACTIVE_POWER: {
744 m_choiceTextType->SetSelection(1);
745 switch (m_text->GetUnit()) {
746 case ElectricalUnit::UNIT_PU: {
747 m_choiceTextUnit->SetSelection(0);
749 case ElectricalUnit::UNIT_W: {
750 m_choiceTextUnit->SetSelection(1);
752 case ElectricalUnit::UNIT_kW: {
753 m_choiceTextUnit->SetSelection(2);
755 case ElectricalUnit::UNIT_MW: {
756 m_choiceTextUnit->SetSelection(3);
762 case DATA_REACTIVE_POWER: {
763 m_choiceTextType->SetSelection(2);
764 switch (m_text->GetUnit()) {
765 case ElectricalUnit::UNIT_PU: {
766 m_choiceTextUnit->SetSelection(0);
768 case ElectricalUnit::UNIT_var: {
769 m_choiceTextUnit->SetSelection(1);
771 case ElectricalUnit::UNIT_kvar: {
772 m_choiceTextUnit->SetSelection(2);
774 case ElectricalUnit::UNIT_Mvar: {
775 m_choiceTextUnit->SetSelection(3);
789 if (m_choiceTextFromBus->IsEnabled()) m_choiceTextFromBus->SetSelection(m_text->GetDirection());
790 if (m_choiceTextToBus->IsEnabled()) m_choiceTextToBus->SetSelection(m_text->GetDirection());
792 m_textCtrlDecimal->SetValue(wxString::Format(
"%d", m_text->GetDecimalPlaces()));
798void TextForm::ElementTypeChoice()
800 m_choiceTextType->Enable(
false);
801 m_choiceTextFromBus->Enable(
false);
802 m_choiceTextToBus->Enable(
false);
803 m_choiceTextUnit->Enable(
false);
804 m_choiceTextType->Clear();
805 m_choiceTextFromBus->Clear();
806 m_choiceTextToBus->Clear();
807 m_choiceTextUnit->Clear();
809 m_choiceName->Clear();
810 wxArrayString arrayString;
811 switch (m_text->GetElementTypeText()) {
813 for (
int i = 0; i < (int)m_allElements.
GetBusList().size(); i++) {
815 arrayString.Add(bus->GetElectricalData().name);
818 case TYPE_SYNC_GENERATOR: {
821 arrayString.Add(syncGenerator->GetElectricalData().name);
825 for (
int i = 0; i < (int)m_allElements.
GetLineList().size(); i++) {
827 arrayString.Add(line->GetElectricalData().name);
830 case TYPE_TRANSFORMER: {
833 arrayString.Add(transformer->GetElectricalData().name);
837 for (
int i = 0; i < (int)m_allElements.
GetLoadList().size(); i++) {
839 arrayString.Add(load->GetElectricalData().name);
842 case TYPE_CAPACITOR: {
845 arrayString.Add(capacitor->GetElectricalData().name);
848 case TYPE_INDUCTOR: {
849 for (
int i = 0; i < (int)m_allElements.
GetInductorList().size(); i++) {
851 arrayString.Add(inductor->GetElectricalData().name);
854 case TYPE_SYNC_MOTOR: {
857 arrayString.Add(syncMotor->GetElectricalData().name);
860 case TYPE_IND_MOTOR: {
861 for (
int i = 0; i < (int)m_allElements.
GetIndMotorList().size(); i++) {
863 arrayString.Add(indMotor->GetElectricalData().name);
870 m_choiceName->Append(arrayString);
871 m_choiceName->Enable();
874void TextForm::ElementNumberChoice()
876 m_choiceTextFromBus->Enable(
false);
877 m_choiceTextToBus->Enable(
false);
878 m_choiceTextUnit->Enable(
false);
879 m_choiceTextFromBus->Clear();
880 m_choiceTextToBus->Clear();
881 m_choiceTextUnit->Clear();
883 int index = m_choiceName->GetSelection();
884 m_text->SetElementNumber(index);
886 m_choiceTextType->Clear();
887 wxArrayString arrayString;
888 switch (m_text->GetElementTypeText()) {
891 m_text->SetElement(bus);
893 arrayString.Add(_(
"Name"));
894 arrayString.Add(_(
"Voltage"));
895 arrayString.Add(_(
"Angle"));
896 arrayString.Add(_(
"Fault current"));
897 arrayString.Add(_(
"Fault voltage"));
898 arrayString.Add(_(
"Short-circuit power"));
899 arrayString.Add(_(
"Voltage THD"));
901 case TYPE_SYNC_GENERATOR: {
903 m_text->SetElement(syncGenerator);
905 arrayString.Add(_(
"Name"));
906 arrayString.Add(_(
"Active power"));
907 arrayString.Add(_(
"Reactive power"));
908 arrayString.Add(_(
"Fault current"));
912 m_text->SetElement(line);
914 arrayString.Add(_(
"Name"));
915 arrayString.Add(_(
"Active power flow"));
916 arrayString.Add(_(
"Reactive power flow"));
917 arrayString.Add(_(
"Losses"));
918 arrayString.Add(_(
"Current"));
919 arrayString.Add(_(
"Fault current"));
921 case TYPE_TRANSFORMER: {
923 m_text->SetElement(transformer);
925 arrayString.Add(_(
"Name"));
926 arrayString.Add(_(
"Active power flow"));
927 arrayString.Add(_(
"Reactive power flow"));
928 arrayString.Add(_(
"Losses"));
929 arrayString.Add(_(
"Current"));
930 arrayString.Add(_(
"Fault current"));
934 m_text->SetElement(load);
936 arrayString.Add(_(
"Name"));
937 arrayString.Add(_(
"Active power"));
938 arrayString.Add(_(
"Reactive power"));
940 case TYPE_CAPACITOR: {
942 m_text->SetElement(capacitor);
944 arrayString.Add(_(
"Name"));
945 arrayString.Add(_(
"Reactive power"));
947 case TYPE_INDUCTOR: {
949 m_text->SetElement(inductor);
951 arrayString.Add(_(
"Name"));
952 arrayString.Add(_(
"Reactive power"));
954 case TYPE_SYNC_MOTOR: {
956 m_text->SetElement(syncMotor);
958 arrayString.Add(_(
"Name"));
959 arrayString.Add(_(
"Active power"));
960 arrayString.Add(_(
"Reactive power"));
962 case TYPE_IND_MOTOR: {
964 m_text->SetElement(indMotor);
966 arrayString.Add(_(
"Name"));
967 arrayString.Add(_(
"Active power"));
968 arrayString.Add(_(
"Reactive power"));
974 m_choiceTextType->Append(arrayString);
975 m_choiceTextType->Enable();
978void TextForm::DataTypeChoice()
980 m_choiceTextFromBus->Enable(
false);
981 m_choiceTextToBus->Enable(
false);
983 m_choiceTextToBus->Clear();
984 m_choiceTextFromBus->Clear();
985 m_choiceTextUnit->Clear();
987 m_choiceTextUnit->Enable();
989 wxArrayString arrayString;
990 switch (m_text->GetDataType()) {
993 m_choiceTextUnit->Enable(
false);
997 case DATA_SC_VOLTAGE: {
998 arrayString.Add(_(
"p.u."));
999 arrayString.Add(_(
"V"));
1000 arrayString.Add(_(
"kV"));
1003 arrayString.Add(_(
"Degrees"));
1004 arrayString.Add(_(
"Radians"));
1006 case DATA_SC_CURRENT:
1007 case DATA_PF_CURRENT: {
1008 arrayString.Add(_(
"p.u."));
1009 arrayString.Add(_(
"A"));
1010 arrayString.Add(_(
"kA"));
1012 case DATA_SC_POWER: {
1013 arrayString.Add(_(
"p.u."));
1014 arrayString.Add(_(
"VA"));
1015 arrayString.Add(_(
"kVA"));
1016 arrayString.Add(_(
"MVA"));
1018 case DATA_ACTIVE_POWER:
1019 case DATA_PF_ACTIVE:
1020 case DATA_PF_LOSSES: {
1021 arrayString.Add(_(
"p.u."));
1022 arrayString.Add(_(
"W"));
1023 arrayString.Add(_(
"kW"));
1024 arrayString.Add(_(
"MW"));
1025 m_choiceTextUnit->Enable();
1027 case DATA_REACTIVE_POWER:
1028 case DATA_PF_REACTIVE: {
1029 arrayString.Add(_(
"p.u."));
1030 arrayString.Add(_(
"var"));
1031 arrayString.Add(_(
"kvar"));
1032 arrayString.Add(_(
"Mvar"));
1037 m_choiceTextUnit->Append(arrayString);
1039 switch (m_text->GetElementTypeText()) {
1041 if (m_text->GetDataType() != DATA_PF_LOSSES) {
1049 wxString bus1Name = bus1->GetElectricalData().name;
1050 wxString bus2Name = bus2->GetElectricalData().name;
1052 m_choiceTextFromBus->Append(bus1Name);
1053 m_choiceTextFromBus->Append(bus2Name);
1054 m_choiceTextToBus->Append(bus2Name);
1055 m_choiceTextToBus->Append(bus1Name);
1056 m_choiceTextFromBus->SetSelection(0);
1057 m_choiceTextToBus->SetSelection(0);
1059 m_choiceTextFromBus->Enable();
1060 m_choiceTextToBus->Enable();
1063 case TYPE_TRANSFORMER: {
1064 if (m_text->GetDataType() != DATA_PF_LOSSES) {
1071 wxString bus1Name = bus1->GetElectricalData().name;
1072 wxString bus2Name = bus2->GetElectricalData().name;
1074 m_choiceTextFromBus->Append(bus1Name);
1075 m_choiceTextFromBus->Append(bus2Name);
1076 m_choiceTextToBus->Append(bus2Name);
1077 m_choiceTextToBus->Append(bus1Name);
1078 m_choiceTextFromBus->SetSelection(0);
1079 m_choiceTextToBus->SetSelection(0);
1081 m_choiceTextFromBus->Enable();
1082 m_choiceTextToBus->Enable();
1090void TextForm::UnitChoice()
1092 switch (m_text->GetDataType()) {
1094 m_choiceTextUnit->Enable(
false);
1098 case DATA_SC_VOLTAGE: {
1099 switch (m_choiceTextUnit->GetSelection()) {
1101 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1104 m_text->SetUnit(ElectricalUnit::UNIT_V);
1107 m_text->SetUnit(ElectricalUnit::UNIT_kV);
1114 switch (m_choiceTextUnit->GetSelection()) {
1116 m_text->SetUnit(ElectricalUnit::UNIT_DEGREE);
1119 m_text->SetUnit(ElectricalUnit::UNIT_RADIAN);
1125 case DATA_SC_CURRENT:
1126 case DATA_PF_CURRENT: {
1127 switch (m_choiceTextUnit->GetSelection()) {
1129 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1132 m_text->SetUnit(ElectricalUnit::UNIT_A);
1135 m_text->SetUnit(ElectricalUnit::UNIT_kA);
1141 case DATA_SC_POWER: {
1142 switch (m_choiceTextUnit->GetSelection()) {
1144 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1147 m_text->SetUnit(ElectricalUnit::UNIT_VA);
1150 m_text->SetUnit(ElectricalUnit::UNIT_kVA);
1153 m_text->SetUnit(ElectricalUnit::UNIT_MVA);
1159 case DATA_ACTIVE_POWER:
1160 case DATA_PF_ACTIVE:
1161 case DATA_PF_LOSSES: {
1162 switch (m_choiceTextUnit->GetSelection()) {
1164 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1167 m_text->SetUnit(ElectricalUnit::UNIT_W);
1170 m_text->SetUnit(ElectricalUnit::UNIT_kW);
1173 m_text->SetUnit(ElectricalUnit::UNIT_MW);
1179 case DATA_REACTIVE_POWER:
1180 case DATA_PF_REACTIVE: {
1181 switch (m_choiceTextUnit->GetSelection()) {
1183 m_text->SetUnit(ElectricalUnit::UNIT_PU);
1186 m_text->SetUnit(ElectricalUnit::UNIT_var);
1189 m_text->SetUnit(ElectricalUnit::UNIT_kvar);
1192 m_text->SetUnit(ElectricalUnit::UNIT_Mvar);
1203void TextForm::Preview()
1205 double decimalPlaces = m_text->GetDecimalPlaces();
1206 if (m_textCtrlDecimal->GetValue().ToDouble(&decimalPlaces)) m_text->SetDecimalPlaces(decimalPlaces);
1208 m_text->UpdateText(m_systemPowerBase);
1210 m_textCtrlPreview->SetValue(m_text->GetText());
1213bool TextForm::ValidateData()
1215 if (m_choiceElement->GetSelection() == -1)
return false;
1216 if (m_choiceName->GetSelection() == -1)
return false;
1217 if (m_choiceTextType->GetSelection() == -1)
return false;
1218 if (m_text->GetDataType() != DATA_NAME && m_text->GetDataType() != DATA_PQ_THD &&
1219 m_choiceTextUnit->GetSelection() == -1)
1221 if (m_text->GetElementTypeText() == TYPE_LINE || m_text->GetElementTypeText() == TYPE_TRANSFORMER) {
1222 if (m_text->GetDataType() != DATA_PF_LOSSES && m_text->GetDataType() != DATA_NAME) {
1223 if (m_choiceTextFromBus->GetSelection() == -1)
return false;
1224 if (m_choiceTextToBus->GetSelection() == -1)
return false;
1228 if (m_choiceTextFromBus->IsEnabled() && m_choiceTextToBus->IsEnabled())
1229 m_text->SetDirection(m_choiceTextFromBus->GetSelection());
1230 double decimalPlaces = m_text->GetDecimalPlaces();
1231 if (m_textCtrlDecimal->GetValue().ToDouble(&decimalPlaces)) m_text->SetDecimalPlaces(decimalPlaces);
1233 m_textToEdit->SetElementTypeText(m_text->GetElementTypeText());
1234 m_textToEdit->SetElementNumber(m_text->GetElementNumber());
1235 m_textToEdit->SetElement(m_text->GetElement());
1236 m_textToEdit->SetDataType(m_text->GetDataType());
1237 m_textToEdit->SetDirection(m_text->GetDirection());
1238 m_textToEdit->SetUnit(m_text->GetUnit());
1239 m_textToEdit->SetDecimalPlaces(decimalPlaces);
1240 m_textToEdit->UpdateText(m_systemPowerBase);
1245void TextForm::OnOKButtonClick(wxCommandEvent& event)
1247 if (ValidateData()) {
1251 wxString errorMsg = _(
"There are blank fields.");
1252 wxMessageDialog msgDialog(
this, errorMsg, _(
"Error"), wxOK | wxCENTRE | wxICON_ERROR);
1253 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.