powerflow/powerflow_object.h

00001 
00008 #ifndef _POWERFLOWOBJECT_H
00009 #define _POWERFLOWOBJECT_H
00010 
00011 #include "gridlabd.h"
00012 
00018 #define OC_NORMAL           0x0000  
00019 /* contact flags */
00020 #define OC_CONTACT          0x1000  
00021 #define OC_PHASE_A_CONTACT  0x1001  
00022 #define OC_PHASE_B_CONTACT  0x1002  
00023 #define OC_PHASE_C_CONTACT  0x1004  
00024 #define OC_NEUTRAL_CONTACT  0x1008  
00025 #define OC_SPLIT_1_CONTACT  0x1010  
00026 #define OC_SPLIT_2_CONTACT  0x1020  
00027 #define OC_SPLIT_N_CONTACT  0x1040  
00028 #define OC_GROUND_CONTACT   0x1080  
00029 #define OC_CONTACT_ALL      0x10ff  
00030 /* open flags */
00031 #define OC_OPEN             0x2000  
00032 #define OC_PHASE_A_OPEN     0x2001  
00033 #define OC_PHASE_B_OPEN     0x2002  
00034 #define OC_PHASE_C_OPEN     0x2004  
00035 #define OC_NEUTRAL_OPEN     0x2008  
00036 #define OC_SPLIT_1_OPEN     0x2010  
00037 #define OC_SPLIT_2_OPEN     0x2020  
00038 #define OC_SPLIT_N_OPEN     0x2040  
00039 #define OC_GROUND_OPEN      0x2080  
00040 #define OC_OPEN_ALL         0x20ff  
00041 /* condition mask */
00042 #define OC_INFO             0x3000  
00049 #define NO_PHASE    0x0000      
00050 /* three phase configurations */
00051 #define PHASE_A     0x0001      
00052 #define PHASE_B     0x0002      
00053 #define PHASE_C     0x0004      
00054 #define PHASE_ABC   0x0007      
00055 #define PHASE_N     0x0008      
00056 #define PHASE_ABCN  0x000f      
00057 /* split phase configurations */
00058 #define PHASE_S1    0x0010      
00059 #define PHASE_S2    0x0020      
00060 #define PHASE_SN    0x0040      
00061 #define PHASE_S     0x0070      
00062 #define GROUND      0x0080      
00063 /* delta configuration */
00064 #define PHASE_D     0x010f      
00065 /* phase info mask */
00066 #define PHASE_INFO  0x01ff      
00075 #define PS_NORMAL   0x00        
00076 #define PS_OUTAGE   0x01        
00077 /* Note: Only define solution modes that are known to ALL objects.
00078    Add object specific modes to the appropriate objects 
00079    */
00080 
00081 class powerflow_object
00082 {
00083 public:
00084     // this isn't needed if phase is a set
00085     set phases;             
00086     set condition;          
00087     enumeration solution;   
00088 public:
00089     static CLASS *oclass; 
00090     static CLASS *pclass;
00091     static powerflow_object *defaults;
00092 
00093     /* is_normal checks whether the current operating condition is normal */
00094     inline bool is_normal(void) const { return condition==OC_NORMAL;};
00095     
00096     /* is_open checks whether particulars phases are open (no connection when there should be one) */
00097     inline bool is_open(set ph=PHASE_INFO) const { return (condition&OC_OPEN)!=0 && (condition&ph)==ph;};
00098 
00099     /* is_open_any checks whether any phase is open (no connection when there should be one) */
00100     inline bool is_open_any(set ph=PHASE_INFO) const { return (condition&OC_OPEN)!=0 && (condition&ph)!=0;};
00101 
00102     /* is_contact_any checks whether particulars phases are contacting another */
00103     inline bool is_contact(set ph=PHASE_INFO) const { return (condition&OC_CONTACT)!=0 && (condition&ph)==ph;};
00104     
00105     /* is_contact_any checks whether any phase is contacting another */
00106     inline bool is_contact_any(set ph=PHASE_INFO) const { return (condition&OC_CONTACT)!=0 && (condition&ph)!=0;};
00107     
00108     /* get_name acquires the name of an object or 'unnamed' if non set */
00109     inline const char *get_name(void) const { OBJECT *obj=OBJECTHDR(this); return obj->name?obj->name:"unnamed";};
00110     
00111     /* get_id acquires the object's id */
00112     inline unsigned int get_id(void) const {return OBJECTHDR(this)->id;};
00113     
00114     /* has_phase checks whether a particular phase is configured */
00115     inline bool has_phase(set ph, set flags=0) const { return ((flags?flags:phases)& ph)==ph; };
00116     
00117     /* phase_index returns the array index of a phase if configured (use flags to test another variable) */
00118     inline unsigned int phase_index(set ph, set flags=0) const { return ((unsigned int)(flags?flags:phases)>>2)%3;};
00119     
00120     /* get_phases acquires the phase part of the flags given */
00121     inline set get_phases(set flags) const { return flags&PHASE_INFO;};
00122 public:
00123     int create(void);
00124     int init(void);
00125     TIMESTAMP presync(TIMESTAMP t0);
00126     TIMESTAMP sync(TIMESTAMP t0);
00127     TIMESTAMP postsync(TIMESTAMP t0);
00128     powerflow_object(MODULE *mod);
00129     int isa(char *classname);
00130 };
00131 
00132 #endif // _POWERFLOWOBJECT_H
00133 

GridLAB-DTM Version 1.0
An open-source project initiated by the US Department of Energy