00001
00010 #include <stdlib.h>
00011 #include <stdio.h>
00012 #include <errno.h>
00013 #include <math.h>
00014 #include "network.h"
00015
00016
00017
00019
00021 CLASS* regulator::oclass = NULL;
00022 CLASS* regulator::pclass = NULL;
00023 regulator *regulator::defaults = NULL;
00024
00025 regulator::regulator(MODULE *mod) : link(mod)
00026 {
00027
00028 if (oclass==NULL)
00029 {
00030
00031 regulator_class = oclass = gl_register_class(mod,"regulator",sizeof(regulator),PC_BOTTOMUP);
00032 if (oclass==NULL)
00033 GL_THROW("unable to register object class implemented by %s",__FILE__);
00034
00035
00036 if (gl_publish_variable(oclass,
00037 PT_enumeration,"Type",PADDR(Type),
00038 PT_KEYWORD,"RT_LTC",RT_LTC,
00039 PT_KEYWORD,"RT_VR",RT_VR,
00040 PT_double, "Vmax", PADDR(Vmax),
00041 PT_double, "Vmin", PADDR(Vmin),
00042 PT_double, "Vstep", PADDR(Vstep),
00043 PT_object, "CTlink", PADDR(CTlink),
00044 PT_object, "PTbus", PADDR(PTbus),
00045 PT_double, "TimeDelay", PADDR(TimeDelay),
00046 NULL)<1) GL_THROW("unable to publish properties in %s",__FILE__);
00047
00048
00049 defaults = this;
00050 }
00051
00052 }
00053
00054 int regulator::create()
00055 {
00056 int result = link::create();
00057 memcpy(this,defaults,sizeof(*this));
00058 return result;
00059 }
00060
00061 TIMESTAMP regulator::sync(TIMESTAMP t0)
00062 {
00063 node *f = OBJECTDATA(from,node);
00064 node *t = OBJECTDATA(to,node);
00065 if (f==NULL || t==NULL)
00066 return TS_NEVER;
00067
00068 return link::sync(t0);
00069 }
00071
00073
00074 EXPORT int create_regulator(OBJECT **obj, OBJECT *parent)
00075 {
00076 *obj = gl_create_object(regulator_class);
00077 if (*obj!=NULL)
00078 {
00079 regulator *my = OBJECTDATA(*obj,regulator);
00080 gl_set_parent(*obj,parent);
00081 my->create();
00082 return 1;
00083 }
00084 return 0;
00085 }
00086
00087 EXPORT TIMESTAMP sync_regulator(OBJECT *obj, TIMESTAMP t0)
00088 {
00089 TIMESTAMP t1 = OBJECTDATA(obj,regulator)->sync(t0);
00090 obj->clock = t0;
00091 return t1;
00092 }
00093
00094