Exemple #1
0
//--------------------------------------------------------------
void Timeline::M_programUntil(string strDateEnd)
{
	int timezone=0;
	Poco::DateTime dateEnd;
	Poco::DateTimeParser::parse(__DATE_FORMAT__, strDateEnd, dateEnd, timezone);

	Poco::DateTime now = nowLocal()+Poco::Timespan(5,0);
	m_deltaTime = dateEnd - now; 


	M_empty();
	M_getPropertiesJS();
	M_addAnimationEvents(nowLocal(),dateEnd);
}
Exemple #2
0
//--------------------------------------------------------------
void Timeline::M_programColorChangeEvery(int nbSecondsInterval, string strDateEnd)
{
	int timezone=0;
	Poco::DateTime dateEnd;
	Poco::DateTimeParser::parse(__DATE_FORMAT__, strDateEnd, dateEnd, timezone);

	
	Poco::DateTime dateEventColor = nowLocal()+Poco::Timespan(5,0);
	ofColor c;
	TimelineEvent* pEventPrev=0;
	while(dateEventColor<dateEnd)
	{
		// TODO : pick colors in palette
		//c.set(ofRandom(0,255),ofRandom(0,255),ofRandom(0,255),255);
		int indexColor = (int) ofRandom(0,m_listColors.size());
		if (indexColor>=m_listColors.size())
			indexColor = m_listColors.size()-1;


		
		TimelineEvent* pEvent = M_addEventColor(dateEventColor, m_listColors[indexColor] );		
		if (pEventPrev){
			pEventPrev->mp_eventNext = pEvent;
		}
		pEventPrev = pEvent;

		dateEventColor	+= Poco::Timespan(0,0,0,nbSecondsInterval,0);
//	Timespan(int days, int hours, int minutes, int seconds, int microseconds);
	}
}
Exemple #3
0
//--------------------------------------------------------------
void Timeline::M_setActive(bool is)
{
	m_isActive = is;
	if (is)
	{

		if (m_listEvents.size()>0)
		{
			Poco::DateTime now = nowLocal();
			vector<TimelineEvent*> listEventsDelete;

			string strNow = Poco::DateTimeFormatter::format(now, __DATE_FORMAT__);
			printf("Timeline::M_setActive() - NOW:%s\n",strNow.c_str());

			int index = 0;
			TimelineEvent* pNextEvent = m_listEvents[index];
			while(m_listEvents.size()>0 && pNextEvent->m_datetime <= now)
			{
				pNextEvent = m_listEvents[++index];
			}
			
			if (index > 1){
				index = index-1;
				for (int i=0;i<=index;i++){
					string strDate = Poco::DateTimeFormatter::format(m_listEvents[i]->m_datetime, __DATE_FORMAT__);
					printf("  - deleting event [date=%s]\n",strDate.c_str());
					delete m_listEvents[i];
				}
				m_listEvents.erase(m_listEvents.begin(), m_listEvents.begin()+index+1);
			}

		}
	}
}
CString CSaveModifiedItemsDialog::FormatLastModifiedDateString(DATE lastModifiedUTC)
{
	CString lastModifiedString;

	if(lastModifiedUTC != 0)
	{
		SYSTEMTIME lastModifiedUTCSystem = {0};
		::VariantTimeToSystemTime(lastModifiedUTC, &lastModifiedUTCSystem);
		FILETIME lastModifiedUTCFileTime = {0};
		::SystemTimeToFileTime(&lastModifiedUTCSystem, &lastModifiedUTCFileTime);
		FILETIME lastModifiedLocalFileTime = {0};
		::FileTimeToLocalFileTime(&lastModifiedUTCFileTime, &lastModifiedLocalFileTime);

		COleDateTime nowLocal(COleDateTime::GetCurrentTime());
		COleDateTime dateTimeModifiedLocal(lastModifiedLocalFileTime);

		CString fullDateTimeString = dateTimeModifiedLocal.Format(_T("%#m/%#d/%Y %#I:%M %p"));;
		CString timeString = dateTimeModifiedLocal.Format(_T("%#I:%M %p"));;

		int yearDifference = (nowLocal.GetYear() - dateTimeModifiedLocal.GetYear());
		int dayOfYearDifference = (nowLocal.GetDayOfYear() - dateTimeModifiedLocal.GetDayOfYear());
		int hourDifference = (nowLocal.GetHour() - dateTimeModifiedLocal.GetHour());
		int minuteDifference = (nowLocal.GetMinute() - dateTimeModifiedLocal.GetMinute());
		int secondDifference = (nowLocal.GetSecond() - dateTimeModifiedLocal.GetSecond());
		if(	yearDifference >= 1 ||
			dayOfYearDifference > 1 ||
			nowLocal < dateTimeModifiedLocal)
		{
			lastModifiedString = fullDateTimeString;
		}
		else if(dayOfYearDifference == 1)
		{
			lastModifiedString.Format(_T("Yesterday, %s"), timeString);
		}
		else if(hourDifference >= 1)
		{
			lastModifiedString.Format(_T("%d hour%s ago"), hourDifference,
				(hourDifference!=1) ? _T("s") : _T(""));
		}
		else if(minuteDifference >= 1)
		{
			lastModifiedString.Format(_T("%d minute%s ago"), minuteDifference,
				(minuteDifference!=1) ? _T("s") : _T(""));
		}
		else if(secondDifference >= 1)
		{
			lastModifiedString.Format(_T("%d second%s ago"), secondDifference,
				(secondDifference!=1) ? _T("s") : _T(""));
		}
		else
		{
			lastModifiedString = fullDateTimeString;
		}
	}

	return lastModifiedString;
}
Exemple #5
0
//--------------------------------------------------------------
int Timeline::M_getElapsedSeconds()
{
	Poco::DateTime now = nowLocal();
	if (now > m_dateStart){
		Poco::Timespan delta = now-m_dateStart;
		return delta.totalSeconds();
	}
	return 0;
}
Exemple #6
0
//--------------------------------------------------------------
void Timeline::M_programFor(int nbHours)
{
	M_empty();
	M_getPropertiesJS();
	
	Poco::DateTime now = nowLocal();
	Poco::DateTime end = now + Poco::Timespan(0, nbHours, 0, 0, 0);
	m_deltaTime = end - now; 

	m_dateStart = now;
	m_dateEnd = end;

	M_addAnimationEvents(now,end);

	//M_sortEventByDate();
}
Exemple #7
0
//--------------------------------------------------------------
string nowLocalFormatUnderscore()
{
	Poco::DateTime now = nowLocal();
	return Poco::DateTimeFormatter::format(now, "%H_%M_%S");
}
Exemple #8
0
//--------------------------------------------------------------
void Timeline::M_update()
{
/*
	if (!m_isActive) 
		return;
*/

	Poco::DateTime now = nowLocal();
	if (m_listEvents.size()>0)
	{
		TimelineEvent* pNextEvent = m_listEvents[0];
//		printf("now : %s - event:%s\n",dateNow.c_str(),dateEvent.c_str());
		if (pNextEvent->m_datetime <= now)
		{
			string dateEvent = Poco::DateTimeFormatter::format(pNextEvent->m_datetime, __DATE_FORMAT__);
			int typeEvent = pNextEvent->m_type;

			bool bTriggerAnim = true;
			// ========================================================================
			// ANIM CHANGE
			// ========================================================================
/*
			if (typeEvent == TimelineEvent::TYPE_ANIM_CHANGE)
			{
				// Scene index changing now
				// Look for active client ? = sound activity + network activity 
				Animation* pAnimation = Globals::instance()->mp_animationManager->M_getAnimationByName(pNextEvent->m_animationName);
				if (pAnimation->m_theme == Animation::THEME_SCENE)
				{
					// Change the index
					Globals::instance()->mp_osc->M_changeIndexClientActive();	
					
					// Is new active ? 
					OSCClient* pClientActive = Globals::instance()->mp_osc->M_getClientActive();
					
					// Anyone ? 
					int nbOscClients = Globals::instance()->mp_osc->M_getClientNb();
					
					// Not active or no clients... -> do something
					if ( (nbOscClients==0) || (pClientActive && pClientActive->M_isClientActive() == false))
					{
						// Dont trigger anim Scene if no sound on it
						bTriggerAnim = false;
					
						if (pClientActive)
							printf(">>> WARNING client %s INACTIVE...\n", pClientActive->m_ip.c_str());
						else
							printf(">>> WARNING NO CLIENTS...\n");
						
						printf(">>> WONT TRIGGER ANIM SCENE \n");

						// Replace next animation with theme=contemplation
						// Look for next event of type Animation
						TimelineEvent* pEventAfter = 0;
						for (int i=1;i<m_listEvents.size();i++){
							if (m_listEvents[i]->m_type == TimelineEvent::TYPE_ANIM_CHANGE){
								pEventAfter = m_listEvents[i];
								break;
							}
						}

						if (pEventAfter)
						{
							string animationNamePrev = pEventAfter->m_animationName;
						
							Animation* pAnimationContemplation = Globals::instance()->mp_animationManager->M_getAnimationByThemeRnd(Animation::THEME_CONTEMPLATION);
							if (pAnimationContemplation){
								pEventAfter->m_animationName = pAnimationContemplation->m_name;
								printf(">>> CHANGING next animation [%s] to [%s]\n", animationNamePrev.c_str(), pEventAfter->m_animationName.c_str());
							}
						}
					}
				}

				// Active ? fire an event to animation manager
				if (m_isActive && bTriggerAnim==true)
				{ 
					Globals::instance()->mp_animationManager->M_setAnimation(pNextEvent->m_animationName, pNextEvent->m_animationArgs);
					printf("ANIM CHANGE %s [date=%s]\n", pNextEvent->m_animationName.c_str(), dateEvent.c_str());
				}
			}
			
			// ========================================================================
			// COLOR CHANGE
			// ========================================================================
			else 
			if (typeEvent == TimelineEvent::TYPE_COLOR_CHANGE)
			{
				//Globals::instance()->mp_animationManager->M_setAnimation(pNextEvent->m_animationName, pNextEvent->m_animationArgs);
				if (pNextEvent->mp_eventNext){
					string dateEventNext = Poco::DateTimeFormatter::format(pNextEvent->mp_eventNext->m_datetime, __DATE_FORMAT__);

					Globals::instance()->mp_app->versatubesSetColorNext(pNextEvent->m_color,pNextEvent->mp_eventNext->m_datetime);
					printf("COLOR CHANGE [date=%s] [next=%s] [color=(%.1f,%.1f,%.1f)]\n", dateEvent.c_str(), dateEventNext.c_str(), (float)pNextEvent->m_color.r,(float)pNextEvent->m_color.g, (float)pNextEvent->m_color.b);
				}
			}
*/

			m_listEvents.erase(m_listEvents.begin());
			delete pNextEvent;
		}
	}
}
Exemple #9
0
//--------------------------------------------------------------
void Timeline::M_init(string filename, float interval)
{
	printf("Timeline::M_init(){\n");

	Poco::DateTime now = nowLocal();
	string nowPoco = Poco::DateTimeFormatter::format(now, __DATE_FORMAT__);
	printf("NOW=%s\n", nowPoco.c_str());

	// Parse animations from XML
	string strDateEnd = __EMPTY__;
	string strDateStart = __EMPTY__;
	int timezone=0;
	ofxXmlSettings *XML = new ofxXmlSettings(); 
	if (XML->loadFile(filename))
	{
		int nbTagDays = XML->getNumTags("day");
		if (nbTagDays>0){

			strDateStart = XML->getAttribute("day", "dateStart", __EMPTY__, 0);
			strDateEnd = XML->getAttribute("day", "dateEnd", __EMPTY__, nbTagDays-1);

			for(int i = 0; i < nbTagDays; i++)
			{
				printf("+ DAY %d\n", i);
				
				XML->pushTag("day", i);
				int nbTagEvents = XML->getNumTags("event");
				for(int j = 0; j < nbTagEvents; j++)
				{
					string date = XML->getAttribute("event", "date", __EMPTY__, j);
					if (date != "__EMPTY__"){

						Poco::DateTime datetime;
						Poco::DateTimeParser::parse(__DATE_FORMAT__, date, datetime, timezone);

						if (datetime>=now){
							string animationName = XML->getAttribute("event", "animation",		__EMPTY__, j);
							string animationArgs = XML->getAttribute("event", "animationArgs",	__EMPTY__, j);

							if (animationName != "__EMPTY__"){
								TimelineEvent* pTimelineEvent = new TimelineEvent(datetime,animationName);
								m_listEvents.push_back(pTimelineEvent);
							}
						}

						string datePoco = Poco::DateTimeFormatter::format(datetime, __DATE_FORMAT__);
						//printf("    - EVENT date=\"%s\", datePoco=\"%s\", year=%d [%s]\n", date.c_str(), datePoco.c_str(), datetime.year(), datetime>now ? "à venir" : "passé");
					}
				}

				XML->popTag();
			}
		}


		// add animations every (n) minutes
		if (strDateEnd!=__EMPTY__ && Globals::instance()->mp_animationManager){
			Poco::DateTime dateEnd;
			Poco::DateTimeParser::parse(__DATE_FORMAT__, strDateEnd, dateEnd, timezone);
			Poco::DateTime dateEvent = now;
//			M_addAnimationEvents(now,dateEnd);
		}
	}
	delete XML;


	printf("}\n");
}