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
00090 #define NF_NONE 0x0000
00091 #define NF_HASSOURCE 0x0001
00092 #define NF_ISSOURCE 0x0002
00093
00094 class powerflow_object : public gld_object
00095 {
00096 public:
00097 set phases;
00098 double nominal_voltage;
00099 INRUSHINTMETHOD inrush_integration_method;
00100 #ifdef SUPPORT_OUTAGES
00101 set condition;
00102 enumeration solution;
00103 #endif
00104 public:
00105 static CLASS *oclass;
00106 static CLASS *pclass;
00107 #ifdef SUPPORT_OUTAGES
00108
00109 inline bool is_normal(void) const { return condition==OC_NORMAL;};
00110
00111
00112 inline bool is_open(set ph=PHASE_INFO) const { return (condition&OC_OPEN)!=0 && (condition&ph)==ph;};
00113
00114
00115 inline bool is_open_any(set ph=PHASE_INFO) const { return (condition&OC_OPEN)!=0 && (condition&ph)!=0;};
00116
00117
00118 inline bool is_contact(set ph=PHASE_INFO) const { return (condition&OC_CONTACT)!=0 && (condition&ph)==ph;};
00119
00120
00121 inline bool is_contact_any(set ph=PHASE_INFO) const { return (condition&OC_CONTACT)!=0 && (condition&ph)!=0;};
00122 #endif
00123
00124 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)");};
00125
00126
00127 inline unsigned int get_id(void) const {return OBJECTHDR(this)->id;};
00128
00129
00130 inline bool has_phase(set ph, set flags=0) const { return ((flags?flags:phases)& ph)==ph; };
00131
00132
00133 inline unsigned int phase_index(set ph=0) const { return ((unsigned int)((ph?ph:phases)&PHASE_ABC)>>2)%3;};
00134
00135
00136 inline set get_phases(set flags) const { return flags&PHASE_INFO;};
00137
00138 inline OBJECT* objecthdr() const { return OBJECTHDR(this);}
00139 public:
00140 int create(void);
00141 int init(OBJECT *parent);
00142 TIMESTAMP presync(TIMESTAMP t0);
00143 TIMESTAMP sync(TIMESTAMP t0);
00144 TIMESTAMP postsync(TIMESTAMP t0);
00145 powerflow_object(MODULE *mod);
00146 powerflow_object(CLASS *cl=oclass);
00147 int isa(char *classname);
00148
00149 int kmldump(FILE *fp);
00150 };
00151
00152 #endif // _POWERFLOWOBJECT_H
00153