network/network.cpp

Go to the documentation of this file.
00001 
00050 #include <stdlib.h>
00051 #include <stdio.h>
00052 #include <errno.h>
00053 #include <math.h>
00054 #include "network.h"
00055 
00056 #ifdef _DEBUG
00057 EXPORT int cmdargs(int argc, char *argv[])
00058 {
00059     int n=0;
00060     int i;
00061     for (i=0; i<argc; i++)
00062     {
00063         if (strncmp(argv[i],"--debug_node=",13)==0)
00064         {
00065             debug_node = atoi(argv[i]+13);
00066             n++;
00067         }
00068         else if (strncmp(argv[i],"--debug_link=",13)==0)
00069         {
00070             debug_link = atoi(argv[i]+13);
00071             n++;
00072         }
00073     }
00074     if (debug_node>0) gl_debug("network node debugging mode %d", debug_node);
00075     if (debug_link>0) gl_debug("network link debugging mode %d", debug_link);
00076     return n;
00077 }
00078 #endif // _DEBUG
00079 
00080 /*
00081 int generator_state_from_string(void *addr, char *value)
00082 {
00083     if (strcmp(value,"STOPPED")==0)
00084         *(enumeration*)addr = generator::STOPPED;
00085     else if (strcmp(value,"STANDBY")==0)
00086         *(enumeration*)addr = generator::STANDBY;
00087     else if (strcmp(value,"ONLINE")==0)
00088         *(enumeration*)addr = generator::ONLINE;
00089     else if (strcmp(value,"TRIPPED")==0)
00090         *(enumeration*)addr = generator::TRIPPED;
00091     else
00092         return 0;
00093     return 1;
00094 }
00095 
00096 int generator_state_to_string(void *addr, char *value, int size)
00097 {
00098     enumeration state = *(enumeration*)addr;
00099     switch (state) {
00100     case generator::STOPPED: if (size>7) strcpy(value,"STOPPED"); else return 0;
00101         return 1;
00102     case generator::STANDBY: if (size>7) strcpy(value,"STANDBY"); else return 0;
00103         return 1;
00104     case generator::ONLINE: if (size>6) strcpy(value,"ONLINE"); else return 0;
00105         return 1;
00106     case generator::TRIPPED: if (size>7) strcpy(value,"TRIPPED"); else return 0;
00107         return 1;
00108     default:
00109         return 0;
00110     }
00111 }*/
00112 
00113 EXPORT CLASS *init(CALLBACKS *fntable, MODULE *module, int argc, char *argv[])
00114 {
00115 #ifdef _DEBUG
00116     cmdargs(argc,argv);
00117 #endif // _DEBUG
00118 
00119     if (set_callback(fntable)==NULL)
00120     {
00121         errno = EINVAL;
00122         return NULL;
00123     }
00124     CLASS *first = (new node(module))->oclass;
00125     new link(module);
00126     new capbank(module);
00127     new fuse(module);
00128     new relay(module);
00129     new regulator(module);
00130     new transformer(module);
00131     new meter(module);
00132     new generator(module);
00133 
00134     /* always return the first class registered */
00135     return first;
00136 }
00137 
00138 CDECL int do_kill()
00139 {
00140     /* if global memory needs to be released, this is a good time to do it */
00141     return 0;
00142 }
00143 
00144 

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