summaryrefslogtreecommitdiffstats
path: root/Project/Bus.h
blob: 836d2f779becf8e55db36c25be3030fc4e99f764 (plain)
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
#ifndef BUS_H
#define BUS_H

#include "BusForm.h"
#include "Element.h"

struct BusElectricalData {
    int number = 0;
    wxString name = "";
    double nominalVoltage = 138.0;
    ElectricalUnit nominalVoltageUnit = UNIT_kV;
    bool isVoltageControlled = false;
    double controlledVoltage = 1.0;
    int controlledVoltageUnitChoice = 0;  // 0 = p.u., 1 = same as nominalVoltageUnit (UNIT_V or UNIT_kV).
    bool slackBus = false;

    // Power flow (p.u.)
    std::complex<double> voltage = std::complex<double>(1.0, 0.0);

    // Fault
    bool hasFault = false;
    FaultData faultType = FAULT_THREEPHASE;
    FaultData faultLocation = FAULT_LINE_A;
    double faultResistance = 0.0;
    double faultReactance = 0.0;

    // Stability
    bool plotBus = false;
    bool stabHasFault = false;
    double stabFaultTime = 0.0;
    double stabFaultLength = 0.0;
    double stabFaultResistance = 0.0;
    double stabFaultReactance = 0.0;
};

class Bus : public Element
{
   public:
    Bus();
    Bus(wxPoint2DDouble position);
    Bus(wxPoint2DDouble position, wxString name);
    ~Bus();
    virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return true; }
    virtual bool Contains(wxPoint2DDouble position) const;
    virtual bool Intersects(wxRect2DDouble rect) const;
    virtual void Draw(wxPoint2DDouble translation, double scale) const;
    virtual void Rotate(bool clockwise = true);
    virtual wxCursor GetBestPickboxCursor() const;
    virtual void MovePickbox(wxPoint2DDouble position);
    virtual bool PickboxContains(wxPoint2DDouble position);
    virtual bool GetContextMenu(wxMenu& menu);
    virtual BusElectricalData GetEletricalData() const { return m_electricalData; }
    virtual void SetElectricalData(BusElectricalData electricalData) { m_electricalData = electricalData; }
    virtual bool ShowForm(wxWindow* parent, Element* element);

   protected:
    BusElectricalData m_electricalData;
};

#endif  // BUS_H