Beispiel #1
0
long WINAPI DLLExport GetHHMMSS(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	rdPtr->rHo.hoFlags |= HOF_STRING;
	if(p1==-1)
		return (long)"Error: Invalid TimeStamp";

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
			return (long)"Error: Invalid TimeStamp";
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
	}

	static char temp[7]="HHMMSS";
	temp[0]='0'+rdPtr->datetime.tm_hour/10;
	temp[1]='0'+rdPtr->datetime.tm_hour%10;
	temp[2]='0'+rdPtr->datetime.tm_min/10;
	temp[3]='0'+rdPtr->datetime.tm_min%10;
	temp[4]='0'+rdPtr->datetime.tm_sec/10;
	temp[5]='0'+rdPtr->datetime.tm_sec%10;
	return (long)temp;
}
Beispiel #2
0
long WINAPI DLLExport GetYYYYMMDD(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	rdPtr->rHo.hoFlags |= HOF_STRING;
	if(p1==-1)
		return (long)"Error: Invalid TimeStamp";

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
			return (long)"Error: Invalid TimeStamp";
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
	}

	static char temp[9]="YYYYMMDD";
	temp[0]=(rdPtr->datetime.tm_year>=100)?'2':'1';//(rdPtr->datetime.tm_year+1900>=2000)
	temp[1]='0'+(rdPtr->datetime.tm_year/100+9)%10;
	temp[2]='0'+(rdPtr->datetime.tm_year/10)%10;
	temp[3]='0'+rdPtr->datetime.tm_year%10;
	temp[4]='0'+(rdPtr->datetime.tm_mon+1)/10;
	temp[5]='0'+(rdPtr->datetime.tm_mon+1)%10;
	temp[6]='0'+rdPtr->datetime.tm_mday/10;
	temp[7]='0'+rdPtr->datetime.tm_mday%10;
	return (long)temp;
}
Beispiel #3
0
long WINAPI DLLExport AddSeconds(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	if(p1==-1)
		return -1;

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		temptime->tm_sec+=p2;
		temptime->tm_isdst=-1;
		timestamp=_mktime64(temptime);
		if(timestamp>4294967294 || timestamp==-1)
			return -1;
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
		return (time_t)timestamp;
	}

	tm datetime;
	datetime=rdPtr->datetime;
	datetime.tm_sec+=p2;
//	datetime.tm_isdst=-1;
	__time64_t timestamp=_mktime64(&datetime);
	if(timestamp>4294967294 || timestamp==-1)
		return -1;
	rdPtr->datetime=datetime;
	rdPtr->timestamp=(time_t)timestamp;
	return (time_t)timestamp;
}
Beispiel #4
0
long WINAPI DLLExport GetTimeStamp(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	long p3=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	long p4=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	long p5=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	long p6=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);

	tm datetime;
	datetime.tm_year=p1-1900;
	datetime.tm_mon=p2-1;
	datetime.tm_mday=p3;
	datetime.tm_hour=p4;
	datetime.tm_min=p5;
	datetime.tm_sec=p6;
	datetime.tm_isdst=-1;
	datetime.tm_wday=0;
	datetime.tm_yday=0;

	__time64_t timestamp=_mktime64(&datetime);
	if(timestamp>4294967294 || timestamp==-1)
		return -1;

	rdPtr->datetime=datetime;
	rdPtr->timestamp=(time_t)timestamp;
	return (time_t)timestamp;
}
Beispiel #5
0
long WINAPI DLLExport GetMonthDiff(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	if(p1==-1 || p2==-1)
		return -1;
	if(p1==p2)
		return 0;

	tm datetime;
	int mon1;
	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		datetime=*temptime;
		mon1=temptime->tm_mon;
	}
	else
	{
		datetime=rdPtr->datetime;
		mon1=datetime.tm_mon;
	}

	int year2, mon2;
	if(p2!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p2;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		year2=temptime->tm_year;
		mon2=temptime->tm_mon;
	}
	else
	{
		year2=rdPtr->datetime.tm_year;
		mon2=rdPtr->datetime.tm_mon;
	}

	datetime.tm_year=year2;
	datetime.tm_mon=mon2;
	__time64_t timestamp1a=_mktime64(&datetime);
	if(timestamp1a==-1) // shouldn't happen
		return -1;

	if((unsigned)p1>(unsigned)p2)
		if(timestamp1a>=(__time64_t)(unsigned)p2)
			return (mon1-mon2+12)%12;
		else
			return (mon1-mon2+11)%12;
	else
		if(timestamp1a<=(__time64_t)(unsigned)p2)
			return (mon1-mon2-12)%12;
		else
			return (mon1-mon2-11)%12;
}
Beispiel #6
0
long WINAPI DLLExport Expression3(LPRDATA rdPtr,long param1)
{
	long p1 = CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2 = CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);

	return GetNthBit(p1,p2);

}
Beispiel #7
0
long WINAPI DLLExport GetSecondsDiff(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	__time64_t timestamp1 = (unsigned)p1;
	__time64_t timestamp2 = (unsigned)p2;
	return (long)((timestamp1-timestamp2)%60);
}
Beispiel #8
0
long WINAPI DLLExport Expression2(LPRDATA rdPtr,long param1)
{

	long p1 = CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	char* p3 = (char*)CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_STRING);

	return SingleMask(p1,p3);
}
Beispiel #9
0
long WINAPI DLLExport exp_EaseOut(LPRDATA rdPtr,long param1)
{
	int function = CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	float step = RecastFloat(CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_FLOAT));

	rdPtr->rHo.hoFlags |= HOF_FLOAT;
	return RecastFloatToLong((float)calculateEasingValue(EASEOUT, function, 0, (float)step, rdPtr->easingVars));
}
Beispiel #10
0
long WINAPI DLLExport GetVal(LPRDATA rdPtr, long param1)
{
	char* p1=(char*)CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_STRING);

	unsigned int temp = -1;
	temp = (unsigned int)_atoi64(p1);
	return (long)temp;
}
Beispiel #11
0
long WINAPI DLLExport Expression(LPRDATA rdPtr,long param1)
{

	long p1 = CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2 = CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	char* p3 = (char*)CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_STRING);

	// Performs the wonderfull calculation
	return BitMask(p1,p2,p3);
}
Beispiel #12
0
long WINAPI DLLExport exp_EaseInBetween(LPRDATA rdPtr,long param1)
{
	float valueA = RecastFloat(CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_FLOAT));
	float valueB = RecastFloat(CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_FLOAT));
	int function = CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	float step = RecastFloat(CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_FLOAT));
	float ease = (float)calculateEasingValue(EASEIN, function, 0, step, rdPtr->easingVars);

	rdPtr->rHo.hoFlags |= HOF_FLOAT;
	return RecastFloatToLong(valueA + (valueB-valueA)*ease);
}
Beispiel #13
0
long WINAPI DLLExport GetAsText(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	rdPtr->rHo.hoFlags |= HOF_STRING;
	if(p1==-1)
		return (long)"Error: Invalid TimeStamp";

	static char temp[66]=""; //_i64toa docs say that it can never write more than 65 chars + null
	_i64toa((unsigned)p1, temp, 10);
	return (long)temp;
}
Beispiel #14
0
long WINAPI DLLExport exp_GetPeriod(LPRDATA rdPtr,long param1)
{
	rdPtr->rHo.hoFlags |= HOF_FLOAT;
	int fixed = CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	for(unsigned int i=0; i<rdPtr->controlled.size(); ++i)
	{
		MoveStruct moved = rdPtr->controlled.at(i);
		if(moved.fixedValue == fixed)
			return RecastFloatToLong(moved.vars.period);
	}
	
	return RecastFloatToLong(0);
}
Beispiel #15
0
long WINAPI DLLExport GetFullString(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	rdPtr->rHo.hoFlags |= HOF_STRING;
	if(p1==-1)
		return (long)"Error: Invalid TimeStamp";

	__time64_t timestamp=(unsigned)p1;
	char* temp;
	if((temp=_ctime64(&timestamp))==0)
		return (long)"Error: Invalid TimeStamp";
	else
		return (long)temp;
}
Beispiel #16
0
long WINAPI DLLExport GetDayofWeek(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	if(p1==-1)
		return -1;

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
		return temptime->tm_wday;
	}
	return rdPtr->datetime.tm_wday;
}
Beispiel #17
0
long WINAPI DLLExport GetDayDiff(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	if(p1==-1 || p2==-1)
		return -1;
	if(p1==p2)
		return 0;

	tm datetime1;
	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		datetime1=*temptime;
	}
	else
	{
		datetime1=rdPtr->datetime;
	}

	tm datetime2;
	if(p2!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p2;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		datetime2=*temptime;
	}
	else
	{
		datetime2=rdPtr->datetime;
	}

	// move datetime1 into the same dst block as datetime2
	// alter the hour instead of the isdst setting because a negative
	// isdst makes it set the isdst instead of alter the hour.
	datetime1.tm_hour += datetime2.tm_isdst - datetime1.tm_isdst;
	_mktime64(&datetime1);

	// prepare a datetime that is datetime1's time and datetime 2's date
	tm datetime1a = datetime1;
	datetime1a.tm_year=datetime2.tm_year;
	datetime1a.tm_mon=datetime2.tm_mon;
	datetime1a.tm_mday=datetime2.tm_mday;

	__time64_t timestamp1a=_mktime64(&datetime1a);
	if(timestamp1a==-1) // shouldn't happen
		return -1;

	if((unsigned)p1>(unsigned)p2)
	{

		if(timestamp1a>=(__time64_t)(unsigned)p2)
		{
			if(datetime1.tm_mday<datetime2.tm_mday)
				datetime1a.tm_mon++;
			datetime1a.tm_mday=datetime1.tm_mday;
			if(_mktime64(&datetime1a)==-1)
				return -1; // shouldn't happen
			return datetime1a.tm_yday-datetime2.tm_yday;
		}
		else
		{
			if(datetime1.tm_mday<=datetime2.tm_mday)
				datetime1a.tm_mon++;
			datetime1a.tm_mday=datetime1.tm_mday;
			if(_mktime64(&datetime1a)==-1)
				return -1; // shouldn't happen
			return datetime1a.tm_yday-datetime2.tm_yday-1;
		}
	}
	else
	{
		if(timestamp1a<=(__time64_t)(unsigned)p2)
		{
			if(datetime1.tm_mday>datetime2.tm_mday)
				datetime1a.tm_mon--;
			datetime1a.tm_mday=datetime1.tm_mday;
			if(_mktime64(&datetime1a)==-1)
				return -1; // shouldn't happen
			return datetime1a.tm_yday-datetime2.tm_yday;
		}
		else
		{
			if(datetime1.tm_mday>=datetime2.tm_mday)
				datetime1a.tm_mon--;
			datetime1a.tm_mday=datetime1.tm_mday;
			if(_mktime64(&datetime1a)==-1)
				return -1; // shouldn't happen
			return datetime1a.tm_yday-datetime2.tm_yday+1;
		}
	}
}