当前位置: 首页>>代码示例>>C++>>正文


C++ OBJECTHDR函数代码示例

本文整理汇总了C++中OBJECTHDR函数的典型用法代码示例。如果您正苦于以下问题:C++ OBJECTHDR函数的具体用法?C++ OBJECTHDR怎么用?C++ OBJECTHDR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OBJECTHDR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OBJECTHDR

int generator::init(node *parent)
{
	// check sanity of initial state
	if (parent->type==PQ && !Qcontrolled)
	{
		OBJECT *obj = OBJECTHDR(this);
		gl_error("generator:%d is Qcontrolled but is not connected to a PQ bus", obj->id);
		return 0;
	}
	else if (parent->type!=PQ && Qcontrolled)
	{
		OBJECT *obj = OBJECTHDR(this);
		gl_error("generator:%d is not Qcontrolled but is connected to a PQ bus", obj->id);
		return 0;
	}
	else if (Qcontrolled && Qdesired_MVAR<Qmin_MVAR && Qdesired_MVAR>Qmax_MVAR)
	{
		OBJECT *obj = OBJECTHDR(this);
		gl_error("generator:%d Qdesired is out of Qmin/Qmax limits", obj->id);
		return 0;
	}
	else if (parent->type!=SWING && Pdesired_MW>Pmax_MW)
	{
		OBJECT *obj = OBJECTHDR(this);
		gl_error("generator:%d Pdesired exceeds Pmax", obj->id);
		return 0;
	}
	return 1;
}
开发者ID:SanjayaDeSilva,项目名称:GridLAB-D,代码行数:29,代码来源:generator.cpp

示例2: OBJECTHDR

int motor::init(OBJECT *parent)
{
	int result = node::init();

	OBJECT *obj = OBJECTHDR(this);
	return result;
}
开发者ID:GridOPTICS,项目名称:FNCS-gridlab-d,代码行数:7,代码来源:motor.cpp

示例3: OBJECTHDR

int residential_enduse::init(OBJECT *parent)
{
	OBJECT *hdr = OBJECTHDR(this);
	hdr->flags |= OF_SKIPSAFE;
	ATTACHFUNCTION attach = 0;

	//	pull parent attach_enduse and attach the enduseload
	if(parent)
		attach = (ATTACHFUNCTION)(gl_get_function(parent, "attach_enduse"));
	if(parent && attach)
		pCircuit = (*attach)(parent, &load, load.breaker_amps, (load.config&EUC_IS220)!=0);
	else if (parent)
		gl_warning("%s (%s:%d) parent %s (%s:%d) does not export attach_enduse function so voltage response cannot be modeled", hdr->name?hdr->name:"(unnamed)", hdr->oclass->name, hdr->id, parent->name?parent->name:"(unnamed)", parent->oclass->name, parent->id);
		/* TROUBLESHOOT
			Enduses must have a voltage source from a parent object that exports an attach_enduse function.  
			The residential_enduse object references a parent object that does not conform with this requirement.
			Fix the parent reference and try again.
		 */

	if (load.shape!=NULL) {
		if (load.shape->schedule==NULL)
		{
			gl_verbose("%s (%s:%d) schedule is not specified so the load may be inactive", hdr->name?hdr->name:"(unnamed)", hdr->oclass->name, hdr->id);
			/* TROUBLESHOOT
				The residential_enduse object requires a schedule that defines how
				the load behaves.  Omitting this schedule effectively shuts the enduse
				load off and this is not typically intended.
			 */
		}
	}

	return 1;
}
开发者ID:mikesligo,项目名称:gridlab-d,代码行数:33,代码来源:residential_enduse.cpp

示例4: complex

int dishwasher::create() 
{
	int res = residential_enduse::create();

	// name of enduse
	load.name = oclass->name;

	load.power = load.admittance = load.current = load.total = complex(0,0,J);
	load.voltage_factor = 1.0;
	load.power_factor = 0.95;
	load.power_fraction = 1;
	is_240 = true;

	state = dishwasher_STOPPED;
	
	energy_used = 0;
	
	coil_power[0] = -1;
	motor_on_off = motor_coil_on_off = both_coils_on_off = 0;

	last_t = 0;
	

	gl_warning("explicit %s model is experimental and has not been validated", OBJECTHDR(this)->oclass->name);
	/* TROUBLESHOOT
		The dishwasher explicit model has some serious issues and should be considered for complete
		removal.  It is highly suggested that this model NOT be used.
	*/

	return res;
}
开发者ID:GridOPTICS,项目名称:FNCS-gridlab-d,代码行数:31,代码来源:dishwasher.cpp

示例5: OBJECTHDR

void range::wrong_model(enumeration msg)
{
	char *errtxt[] = {"model is not one-zone","model is not two-zone"};
	OBJECT *obj = OBJECTHDR(this);
	gl_warning("%s (range:%d): %s", obj->name?obj->name:"(anonymous object)", obj->id, errtxt[msg]);
	throw msg; // this must be caught by the range code, not by the core
}
开发者ID:brennane,项目名称:gridpot,代码行数:7,代码来源:range.cpp

示例6: complex

int dryer::create() 
{
	int res = residential_enduse::create();

	// name of enduse
	load.name = oclass->name;

	load.power = load.admittance = load.current = load.total = complex(0,0,J);
	load.voltage_factor = 1.0;
	load.power_factor = 0.95;
	load.power_fraction = 1;
	is_240 = true;

	coil_power[0] = -1;

	state = DRYER_STOPPED;
	
	energy_used = 0;	
	
	last_t = 0;	

	gl_warning("explicit %s model is experimental", OBJECTHDR(this)->oclass->name);

	return res;
}
开发者ID:SanjayaDeSilva,项目名称:GridLAB-D,代码行数:25,代码来源:dryer.cpp

示例7: OBJECTHDR

int transmissioncom::init(OBJECT *parent)
{
	OBJECT *hdr = OBJECTHDR(this);
	

	// input validation checks
	// * parent is a controller
	if(0 == parent){
		gl_error("init(): no parent object");
		return 0;
	}

	if(!gl_object_isa(parent, "substation", "powerflow") && !gl_object_isa(parent, "meter", "powerflow")){
		gl_error("init(): parent is not a powerflow:substation or a powerflow:meter.");
		return 0;
	}

	//TODO: datafromgld=gl_get_property.....
	datafromgld = get_complex(parent, power_property);
	datatogld = get_complex(parent, voltage_property);
	if(gl_object_isa(parent, "substation", "powerflow")){
		powerdiff = get_double(parent,"power_convergence_value");
	} else {
		default_powerdiff = 1; //default is 1 VA
		powerdiff = &default_powerdiff;
	}
	myinterface=Integrator::getCommInterface(hdr->name);
	printf("MY INTEFRACE is mull %d\n",myinterface==NULL);
}
开发者ID:GridOPTICS,项目名称:FNCS-gridlab-d,代码行数:29,代码来源:transmission_interface.cpp

示例8: memory_open_collector

/*******************************************************************
 * collectors 
 */
int memory_open_collector(struct collector *my, char *fname, char *flags)
{
	time_t now=time(NULL);
	OBJECT *obj=OBJECTHDR(my);

	my->memory = (MEMORY*)malloc(sizeof(MEMORY));
	if (my->memory==NULL)
	{
		gl_error("memory_open_collector(struct recorder *my={...}, char *fname='%s', char *flags='%s'): %s", fname, flags, strerror(errno));
		my->status = TS_DONE;
		return 0;
	}
	my->memory->buffer = gl_global_find(fname);
	if (my->memory->buffer==NULL)
	{
		gl_error("memory_open_collector(struct recorder *my={...}, char *fname='%s', char *flags='%s'): global '%s' not found", fname, flags, fname);
		my->status = TS_DONE;
		return 0;
	}
	my->memory->index = 0;
	my->type = FT_MEMORY;
	my->last.ts = TS_ZERO;
	my->status=TS_OPEN;
	my->samples=0;
	return 1;

}
开发者ID:GridOPTICS,项目名称:FNCS-gridlab-d,代码行数:30,代码来源:memory.c

示例9: file_open_recorder

/*******************************************************************
 * recorders 
 */
int file_open_recorder(struct recorder *my, char *fname, char *flags)
{
	time_t now=time(NULL);
	OBJECT *obj=OBJECTHDR(my);
	
	my->fp = (strcmp(fname,"-")==0?stdout:fopen(fname,flags));
	if (my->fp==NULL)
	{
		gl_error("recorder file %s: %s", fname, strerror(errno));
		my->status = TS_DONE;
		return 0;
	}
	my->type = FT_FILE;
	my->last.ts = TS_ZERO;
	my->status=TS_OPEN;
	my->samples=0;

	/* put useful header information in file first */
	fprintf(my->fp,"# file...... %s\n", my->file);
	fprintf(my->fp,"# date...... %s", asctime(localtime(&now)));
#ifdef WIN32
	fprintf(my->fp,"# user...... %s\n", getenv("USERNAME"));
	fprintf(my->fp,"# host...... %s\n", getenv("MACHINENAME"));
#else
	fprintf(my->fp,"# user...... %s\n", getenv("USER"));
	fprintf(my->fp,"# host...... %s\n", getenv("HOST"));
#endif
	fprintf(my->fp,"# target.... %s %d\n", obj->parent->oclass->name, obj->parent->id);
	fprintf(my->fp,"# trigger... %s\n", my->trigger[0]=='\0'?"(none)":my->trigger);
	fprintf(my->fp,"# interval.. %d\n", my->interval);
	fprintf(my->fp,"# limit..... %d\n", my->limit);
	fprintf(my->fp,"# timestamp,%s\n", my->property);

	return 1;
}
开发者ID:devendrashelar7,项目名称:gridnetd,代码行数:38,代码来源:file.c

示例10: OBJECTHDR

//Module-level deltamode call
SIMULATIONMODE switch_object::inter_deltaupdate_switch(unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val,bool interupdate_pos)
{
	OBJECT *hdr = OBJECTHDR(this);
	TIMESTAMP t0_val, t2_val;
	unsigned char work_phases_pre, work_phases_post;

	//Initialize - just set to random values, not used here
	t0_val = TS_NEVER;
	t2_val = TS_NEVER;

	if (interupdate_pos == false)	//Before powerflow call
	{
		//Link presync stuff
		NR_link_presync_fxn();

		//Switch sync item - pre-items
		BOTH_switch_sync_pre(&work_phases_pre,&work_phases_post);

		//Switch sync item - post items
		NR_switch_sync_post(&work_phases_pre,&work_phases_post,hdr,&t0_val,&t2_val);
		
		return SM_DELTA;	//Just return something other than SM_ERROR for this call
	}
	else	//After the call
	{
		//Call postsync
		BOTH_link_postsync_fxn();
		
		return SM_EVENT;	//Links always just want out
	}
}//End module deltamode
开发者ID:ryuever,项目名称:sgrid,代码行数:32,代码来源:switch_object.cpp

示例11: OBJECTHDR

double waterheater::actual_kW(void)
{
	OBJECT *obj = OBJECTHDR(this);
	const double nominal_voltage = 240.0; //@TODO:  Determine if this should be published or how we want to obtain this from the equipment/network
    static int trip_counter = 0;

	// calculate rated heat capacity adjusted for the current line voltage
	if (heat_needed && re_override != OV_OFF)
    {
		if(heat_mode == GASHEAT){
			return heating_element_capacity; /* gas heating is voltage independent. */
		}
		const double actual_voltage = pCircuit ? pCircuit->pV->Mag() : nominal_voltage;
        if (actual_voltage > 2.0*nominal_voltage)
        {
            if (trip_counter++ > 10)
				GL_THROW("Water heater line voltage for waterheater:%d is too high, exceeds twice nominal voltage.",obj->id);
			/*	TROUBLESHOOT
				The waterheater is receiving twice the nominal voltage consistantly, or about 480V on what
				should be a 240V circuit.  Please sanity check your powerflow model as it feeds to the
				meter and to the house.
			*/
            else
                return 0.0;         // @TODO:  This condition should trip the breaker with a counter
        }
		double test = heating_element_capacity * (actual_voltage*actual_voltage) / (nominal_voltage*nominal_voltage);
		return test;
    }
	else
		return 0.0;
}
开发者ID:mafoti,项目名称:StrategicConsumersFullCode,代码行数:31,代码来源:waterheater.cpp

示例12: OBJECTHDR

TIMESTAMP refrigerator::presync(TIMESTAMP t0, TIMESTAMP t1){
	OBJECT *hdr = OBJECTHDR(this);
	double t = 0.0, dt = 0.0;
	double nHours = (gl_tohours(t1)- gl_tohours(t0))/TS_SECOND;

	Tout = *pTout;

	if(nHours > 0 && t0 > 0){ /* skip this on TS_INIT */
		const double COP = COPcoef*((-3.5/45)*(Tout-70)+4.5); /* come from ??? */

		if(t1 == next_time){
			/* lazy skip-ahead */
			load.heatgain = (-((Tair - Tout) * exp(-(UAr+UAf)/Cf) + Tout - Tair) * Cf + Qr * COP) * KWPBTUPH;
			Tair = Tevent;
		} else {
			/* run calculations */
			const double C1 = Cf/(UAr+UAf);
			const double C2 = Tout - Qr/UAr;
			load.heatgain = (-((Tair - Tout) * exp(-(UAr+UAf)/Cf) + Tout - Tair) * Cf  + Qr * COP) * KWPBTUPH;;
			Tair = (Tair-C2)*exp(-nHours/C1)+C2;
		}
		if (Tair < 32 || Tair > 55)
			throw "refrigerator air temperature out of control";
		last_time = t1;
	}

	return TS_NEVER;
}
开发者ID:gelliravi,项目名称:gridspice.simulator,代码行数:28,代码来源:refrigerator.cpp

示例13: OBJECTHDR

double house::get_Tsolar(int hour, int month, double Tair, double Tout)
{
	// Wood frame wall CLTD values from ASHRAE 1989 (for sunlighted walls in the north latitude)
	static double CLTD[] = {4.25, 2.75, 1.63, 0.50, -0.50, 3.50, 11.25, 17.88, 22.50, 25.88, 27.88, 29.25, 31.63, 35.13, 38.50, 40.38, 36.88, 28.00, 19.00, 14.00, 11.13, 8.63, 6.25};

	static double LM[4][24] =	{	
		{-1.33, -1.44, -0.89, -1.00, -0.67, -0.44, -0.67, -1.00, -0.89, -1.44, -1.33, -1.22},  // latitude 24
		{-2.89, -1.89, -0.78, -0.44, -0.11, -0.11, -0.11, -0.44, -0.78, -1.89, -2.89, -4.67},  // latitude 32
		{-5.44, -3.22, -1.11, -0.11, 0.22, 0.67, 0.22, -0.11, -1.11, -3.22, -5.44, -6.33},  // latitude 40
		{-7.56, -5.11, -1.78, -0.11, 1.33, 2.00, 1.33, -0.11, -1.78, -5.11, -7.56} // latitude 48
	};

	static double ColorSurface = 0.75;
	static double DR = 15.0;
	double solarTemp = Tair;
	double LMnow = 0.0;
	int LMcol = month-1;

	OBJECT *hdr = OBJECTHDR(this);

	if (hdr->latitude <= 24.0)
		LMnow = LM[0][LMcol];
	else if (hdr->latitude <= 32.)
		LMnow = LM[0][LMcol] + ((LM[1][LMcol]-LM[0][LMcol])*(hdr->latitude-24.0)/12.0);
	else if (hdr->latitude <= 40.)
		LMnow = LM[1][LMcol] + ((LM[2][LMcol]-LM[1][LMcol])*(hdr->latitude-32.0)/12.0);
	else if (hdr->latitude <= 48.)
		LMnow = LM[2][LMcol] + ((LM[3][LMcol]-LM[2][LMcol])*(hdr->latitude-40.0)/12.0);
	else // if (hdr->latitude > 48.0)
		LMnow = LM[3][LMcol];

	solarTemp += (CLTD[hour] + LMnow)*ColorSurface + (78. - Tair) + ((*pTout) - DR/2. - 85.);

	return solarTemp;
}
开发者ID:brennane,项目名称:gridpot,代码行数:35,代码来源:house_a.cpp

示例14: OBJECTHDR

int schedule::init(OBJECT *parent)
{
	OBJECT *hdr = OBJECTHDR(this);
	int rv = 1;

	currval = default_value;
	if(filename[0] == 0){
		rv = parse_schedule();
	} else {
		rv = open_sched_file();
	}
	
	if(rv == 0){
		state = TS_ERROR;
		strcpy(errmsg, "Error reading & parsing schedule input source");
	}
	/* group rules together here */

	/* ...or not (yet). */

	if(state == TS_INIT){
		state = TS_OPEN;
	} else if(state == TS_ERROR){
		gl_error("unable to open schedule");
		state = TS_DONE;
	}

	return 1;
}
开发者ID:devendrashelar7,项目名称:gridnetd,代码行数:29,代码来源:schedule.cpp

示例15: init

/* Object initialization is called once after all object have been created */
int stubauction::init(OBJECT *parent)
{
	OBJECT *obj=OBJECTHDR(this);
	market_id = 0;
	if(period == 0) period = 300;
	clearat = nextclear();
	return 1; /* return 1 on success, 0 on failure */
}
开发者ID:AMFIRNAS,项目名称:wso2-gridlabd,代码行数:9,代码来源:stubauction.cpp


注:本文中的OBJECTHDR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。