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 CLASS *regulator_class = (NULL);
00025
00026 regulator::regulator(MODULE *mod) : link(mod)
00027 {
00028
00029 if (oclass==NULL)
00030 {
00031
00032 regulator_class = oclass = gl_register_class(mod,"regulator",sizeof(regulator),PC_BOTTOMUP);
00033 if (oclass==NULL)
00034 throw "unable to register class regulator";
00035 else
00036 oclass->trl = TRL_CONCEPT;
00037
00038
00039 if (gl_publish_variable(oclass,
00040 PT_enumeration,"Type",PADDR(Type),
00041 PT_KEYWORD,"RT_LTC",RT_LTC,
00042 PT_KEYWORD,"RT_VR",RT_VR,
00043 PT_double, "Vmax", PADDR(Vmax),
00044 PT_double, "Vmin", PADDR(Vmin),
00045 PT_double, "Vstep", PADDR(Vstep),
00046 PT_object, "CTlink", PADDR(CTlink),
00047 PT_object, "PTbus", PADDR(PTbus),
00048 PT_double, "TimeDelay", PADDR(TimeDelay),
00049 NULL)<1) GL_THROW("unable to publish properties in %s",__FILE__);
00050
00051
00052 defaults = this;
00053 }
00054
00055 }
00056
00057 int regulator::create()
00058 {
00059 int result = link::create();
00060 memcpy(this,defaults,sizeof(*this));
00061 return result;
00062 }
00063
00064 TIMESTAMP regulator::sync(TIMESTAMP t0)
00065 {
00066 node *f = OBJECTDATA(from,node);
00067 node *t = OBJECTDATA(to,node);
00068 if (f==NULL || t==NULL)
00069 return TS_NEVER;
00070
00071 return link::sync(t0);
00072 }
00074
00076
00077 EXPORT int create_regulator(OBJECT **obj, OBJECT *parent)
00078 {
00079 *obj = gl_create_object(regulator_class);
00080 if (*obj!=NULL)
00081 {
00082 regulator *my = OBJECTDATA(*obj,regulator);
00083 gl_set_parent(*obj,parent);
00084 my->create();
00085 return 1;
00086 }
00087 return 0;
00088 }
00089
00090 EXPORT TIMESTAMP sync_regulator(OBJECT *obj, TIMESTAMP t0)
00091 {
00092 TIMESTAMP t1 = OBJECTDATA(obj,regulator)->sync(t0);
00093 obj->clock = t0;
00094 return t1;
00095 }
00096
00097