00001
00009 #ifndef _POWERFLOWOBJECT_H
00010 #define _POWERFLOWOBJECT_H
00011
00012 #include "gridlabd.h"
00013
00014
00015
00016
00017 #ifdef SUPPORT_OUTAGES
00018
00023 #define OC_NORMAL 0x0000
00024
00025 #define OC_CONTACT 0x1000
00026 #define OC_PHASE_A_CONTACT 0x1001
00027 #define OC_PHASE_B_CONTACT 0x1002
00028 #define OC_PHASE_C_CONTACT 0x1004
00029 #define OC_NEUTRAL_CONTACT 0x1008
00030 #define OC_SPLIT_1_CONTACT 0x1010
00031 #define OC_SPLIT_2_CONTACT 0x1020
00032 #define OC_SPLIT_N_CONTACT 0x1040
00033 #define OC_GROUND_CONTACT 0x1080
00034 #define OC_CONTACT_ALL 0x10ff
00035
00036 #define OC_OPEN 0x2000
00037 #define OC_PHASE_A_OPEN 0x2001
00038 #define OC_PHASE_B_OPEN 0x2002
00039 #define OC_PHASE_C_OPEN 0x2004
00040 #define OC_NEUTRAL_OPEN 0x2008
00041 #define OC_SPLIT_1_OPEN 0x2010
00042 #define OC_SPLIT_2_OPEN 0x2020
00043 #define OC_SPLIT_N_OPEN 0x2040
00044 #define OC_GROUND_OPEN 0x2080
00045 #define OC_OPEN_ALL 0x20ff
00046
00047 #define OC_INFO 0x3000
00048 #endif
00049
00055 #define NO_PHASE 0x0000
00056
00057 #define PHASE_A 0x0001
00058 #define PHASE_B 0x0002
00059 #define PHASE_C 0x0004
00060 #define PHASE_ABC 0x0007
00061 #define PHASE_N 0x0008
00062 #define PHASE_ABCN 0x000f
00063
00064 #define PHASE_S1 0x0010
00065 #define PHASE_S2 0x0020
00066 #define PHASE_SN 0x0040
00067 #define PHASE_S 0x0070
00068 #define GROUND 0x0080
00069
00070 #define PHASE_D 0x0100
00071
00072 #define PHASE_INFO 0x01ff
00081 #define PS_NORMAL 0x00
00082 #ifdef SUPPORT_OUTAGES
00083 #define PS_OUTAGE 0x01
00084 #endif
00085
00086
00087
00088
00089 class powerflow_object
00090 {
00091 public:
00092 set phases;
00093 double nominal_voltage;
00094 #ifdef SUPPORT_OUTAGES
00095 set condition;
00096 enumeration solution;
00097 #endif
00098 public:
00099 static CLASS *oclass;
00100 static CLASS *pclass;
00101 #ifdef SUPPORT_OUTAGES
00102
00103 inline bool is_normal(void) const { return condition==OC_NORMAL;};
00104
00105
00106 inline bool is_open(set ph=PHASE_INFO) const { return (condition&OC_OPEN)!=0 && (condition&ph)==ph;};
00107
00108
00109 inline bool is_open_any(set ph=PHASE_INFO) const { return (condition&OC_OPEN)!=0 && (condition&ph)!=0;};
00110
00111
00112 inline bool is_contact(set ph=PHASE_INFO) const { return (condition&OC_CONTACT)!=0 && (condition&ph)==ph;};
00113
00114
00115 inline bool is_contact_any(set ph=PHASE_INFO) const { return (condition&OC_CONTACT)!=0 && (condition&ph)!=0;};
00116 #endif
00117
00118 inline const char *get_name(void) const { static char tmp[64]; OBJECT *obj=OBJECTHDR(this); return obj->name?obj->name:(sprintf(tmp,"%s:%d",obj->oclass->name,obj->id)>0?tmp:"(unknown)");};
00119
00120
00121 inline unsigned int get_id(void) const {return OBJECTHDR(this)->id;};
00122
00123
00124 inline bool has_phase(set ph, set flags=0) const { return ((flags?flags:phases)& ph)==ph; };
00125
00126
00127 inline unsigned int phase_index(set ph=0) const { return ((unsigned int)((ph?ph:phases)&PHASE_ABC)>>2)%3;};
00128
00129
00130 inline set get_phases(set flags) const { return flags&PHASE_INFO;};
00131
00132 inline OBJECT* objecthdr() const { return OBJECTHDR(this);}
00133 public:
00134 int create(void);
00135 int init(OBJECT *parent);
00136 TIMESTAMP presync(TIMESTAMP t0);
00137 TIMESTAMP sync(TIMESTAMP t0);
00138 TIMESTAMP postsync(TIMESTAMP t0);
00139 powerflow_object(MODULE *mod);
00140 powerflow_object(CLASS *cl=oclass);
00141 int isa(char *classname);
00142
00143 int kmldump(FILE *fp);
00144 };
00145
00146 #endif // _POWERFLOWOBJECT_H
00147