Ejemplo n.º 1
0
R_API void r_hash_do_begin(RHash *ctx, int flags) {
	CHKFLAG (flags, R_HASH_MD5) MD5Init (&ctx->md5);
	CHKFLAG (flags, R_HASH_SHA1) SHA1_Init (&ctx->sha1);
	CHKFLAG (flags, R_HASH_SHA256) SHA256_Init (&ctx->sha256);
	CHKFLAG (flags, R_HASH_SHA384) SHA384_Init (&ctx->sha384);
	CHKFLAG (flags, R_HASH_SHA512) SHA512_Init (&ctx->sha512);
	ctx->rst = 0;
}
Ejemplo n.º 2
0
R_API void r_hash_do_end(RHash *ctx, int flags) {
	CHKFLAG (flags, R_HASH_MD5) MD5Final (ctx->digest, &ctx->md5);
	CHKFLAG (flags, R_HASH_SHA1) SHA1_Final (ctx->digest, &ctx->sha1);
	CHKFLAG (flags, R_HASH_SHA256) SHA256_Final (ctx->digest, &ctx->sha256);
	CHKFLAG (flags, R_HASH_SHA384) SHA384_Final (ctx->digest, &ctx->sha384);
	CHKFLAG (flags, R_HASH_SHA512) SHA512_Final (ctx->digest, &ctx->sha512);
	ctx->rst = 1;
}
Ejemplo n.º 3
0
/********************************************************************
* updateFlowRate:													*
* determines whether to change the frequency on the VFD to 			*
* match the desired flow rate 										*
********************************************************************/
void updateFlowRate()
{
	float prevFreq = update.frequency;	// Save the previous frequency

	// Save off desired flow in case server updates while in this function
	// If this happens, it will be updated on the next pass
	float currentDesiredFlow = update.desiredFlowRate;

	// If desired flow was updated via server
	// start with frequency based on lookup table
	if(CHKFLAG(update.updateFlag, UPDATE_FLOW))
	{
		//TODO: Change/update LUT for how frequency is first determined
		update.frequency = currentDesiredFlow*(60/3.5); //TEMPORARY
		printf("Update Flow set, flow: %f, freq: %f\n", currentDesiredFlow, update.frequency);

		// clear update flow flag
		LOCK(&flagMutex);
		CLRFLAG(update.updateFlag, UPDATE_FLOW);
		UNLOCK(&flagMutex);
	}
	else //adjust flow rate based on how off it is from actual
	{
		// float difference = 0;
		// difference = data.flowRate - currentDesiredFlow;
		// if (difference > FLOW_THRESH || difference < -FLOW_THRESH)
		// {
		// 	//TODO: Change how frequency is calculated
		// 	update.frequency -=  (difference*10); //TEMPORARY

		// 	if (update.frequency > MAX_FREQ)
		// 	{
		// 		update.frequency = MAX_FREQ;
		// 		printf("frequency calculated above %d\n", MAX_FREQ);
		// 	}
		// 	else if (update.frequency < MIN_FREQ)
		// 	{
		// 		update.frequency = MIN_FREQ;
		// 		printf("frequency calculated below %d\n", MIN_FREQ);
		// 	}
		// }
	}

	// update flag if frequency changed
	if (prevFreq != update.frequency)
	{
		LOCK(&flagMutex);
		SETFLAG(update.updateFlag, UPDATE_FREQ);
		UNLOCK(&flagMutex);
	}
}