Пример #1
0
void CPPgScheduler::FillScheduleList() {

	m_list.DeleteAllItems();
	
// MORPH START  leuk_he: Remove 2nd apply in scheduler
    bSuppressModifications=true;
	m_actions.DeleteAllItems(); // clear
//MORPH END leuk_he: Remove 2nd apply in scheduler	
	for (uint8 index=0;index<theApp.scheduler->GetCount();index++) {
		m_list.InsertItem(index , theApp.scheduler->GetSchedule(index)->title );
		CTime time(theApp.scheduler->GetSchedule(index)->time);
		CString timeS;
		m_list.SetItemText(index, 1, GetDayLabel(theApp.scheduler->GetSchedule(index)->day));
		timeS.Format(_T("%s"),time.Format(_T("%H:%M")));
		m_list.SetItemText(index, 2, timeS);
	}
	if (m_list.GetItemCount()>0) {
		m_list.SetSelectionMark(0);
		m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
		LoadSchedule(0);
	}
// MORPH START  leuk_he: Remove 2nd apply in scheduler
	bSuppressModifications=false;
//MORPH END leuk_he: Remove 2nd apply in scheduler
}
Пример #2
0
static void JSONSchedule(const KVPairs & key_value_pairs, FILE * stream_file)
{
	int sched_num = -1;
	freeMemory();

	// Iterate through the kv pairs and search for the id.
	for (int i = 0; i < key_value_pairs.num_pairs; i++)
	{
		const char * key = key_value_pairs.keys[i];
		const char * value = key_value_pairs.values[i];
		if (strcmp(key, "id") == 0)
		{
			sched_num = atoi(value);
		}
	}

	// Now check to see if the id is in range.
	const uint8_t numSched = GetNumSchedules();
	if ((sched_num < 0) || (sched_num >= numSched))
	{
		ServeError(stream_file);
		return;
	}

	// Now construct the response and send it
	ServeHeader(stream_file, 200, "OK", false, "text/plain");
	Schedule sched;
	LoadSchedule(sched_num, &sched);
	fprintf_P(stream_file,
			PSTR("{\n\t\"name\" : \"%s\",\n\t\"enabled\" : \"%s\",\n\t\"wadj\" : \"%s\",\n\t\"type\" : \"%s\",\n\t\"d1\" : \"%s\",\n\t\"d2\" : \"%s\""),
			sched.name, sched.IsEnabled() ? "on" : "off", sched.IsWAdj() ? "on" : "off", sched.IsInterval() ? "off" : "on", sched.day & 0x01 ? "on" : "off",
			sched.day & 0x02 ? "on" : "off");
	fprintf_P(stream_file,
			PSTR(",\n\t\"d3\" : \"%s\",\n\t\"d4\" : \"%s\",\n\t\"d5\" : \"%s\",\n\t\"d6\" : \"%s\",\n\t\"d7\" : \"%s\",\n\t\"interval\" : \"%d\",\n\t\"times\" : [\n"),
			sched.day & 0x04 ? "on" : "off", sched.day & 0x08 ? "on" : "off", sched.day & 0x10 ? "on" : "off", sched.day & 0x20 ? "on" : "off",
			sched.day & 0x40 ? "on" : "off", sched.interval);
	for (int i = 0; i < 4; i++)
	{
		if (sched.time[i] == -1)
		{
			fprintf_P(stream_file, PSTR("%s\t\t{\"t\" : \"00:00\", \"e\" : \"off\" }"), (i == 0) ? "" : ",\n");
		}
		else
		{
			fprintf_P(stream_file, PSTR("%s\t\t{\"t\" : \"%02d:%02d\", \"e\" : \"on\" }"), (i == 0) ? "" : ",\n", sched.time[i] / 60, sched.time[i] % 60);
		}
	}
	fprintf_P(stream_file, PSTR("\n\t],\n\t\"zones\" : [\n"));
	for (int i = 0; i < NUM_ZONES; i++)
	{
		FullZone zone;
		LoadZone(i, &zone);
		fprintf(stream_file, "%s\t\t{\"name\" : \"%s\", \"e\":\"%s\", \"duration\" : %d}", (i == 0) ? "" : ",\n", zone.name, zone.bEnabled ? "on" : "off",
				sched.zone_duration[i]);
	}
	fprintf(stream_file, " ]\n}");
}
Пример #3
0
static void JSONSchedules(const KVPairs & key_value_pairs, FILE * stream_file)
{
	ServeHeader(stream_file, 200, "OK", false, "text/plain");
	int iNumSchedules = GetNumSchedules();
	fprintf(stream_file, "{\n\"Table\" : [\n");
	Schedule sched;
	for (int i = 0; i < iNumSchedules; i++)
	{
		LoadSchedule(i, &sched);
		fprintf_P(stream_file, PSTR("%s\t{\"id\" : %d, \"name\" : \"%s\", \"e\" : \"%s\" }"), (i == 0) ? "" : ",\n", i, sched.name,
				(sched.IsEnabled()) ? "on" : "off");
	}
	fprintf(stream_file, "\n]}");
}
Пример #4
0
void CPPgScheduler::FillScheduleList() {

	m_list.DeleteAllItems();
	
	for (uint8 index=0;index<theApp.scheduler->GetCount();index++) {
		m_list.InsertItem(index , theApp.scheduler->GetSchedule(index)->title );
		CTime time(theApp.scheduler->GetSchedule(index)->time);
		CString timeS;
		m_list.SetItemText(index, 1, GetDayLabel(theApp.scheduler->GetSchedule(index)->day));
		timeS.Format(_T("%s"),time.Format(_T("%H:%M")));
		m_list.SetItemText(index, 2, timeS);
	}
	if (m_list.GetItemCount()>0) {
		m_list.SetSelectionMark(0);
		m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
		LoadSchedule(0);
	}
}
Пример #5
0
static void ServeSchedPage(FILE * stream_file)
{
	Schedule sched;
	freeMemory();
	ServeHeader(stream_file, 200, "OK", false);
	const uint8_t numSched = GetNumSchedules();
	for (uint8_t iSchedNum = 0; iSchedNum < numSched; iSchedNum++)
	{
		LoadSchedule(iSchedNum, &sched);
		fprintf_P(stream_file, PSTR("<hr/>Schedule #%d<br/>"), iSchedNum);
		if (sched.IsEnabled())
			fprintf_P(stream_file, PSTR("Enabled"));
		else
			fprintf_P(stream_file, PSTR("Not Enabled"));
		fprintf_P(stream_file, PSTR("<br/>Name:%s<br/>"), sched.name);
		if (sched.IsInterval())
			fprintf_P(stream_file, PSTR("Interval : %d"), sched.interval);
		else
		{
			fprintf_P(stream_file, PSTR("Day :"));
			if (sched.day & 0x01)
				fprintf(stream_file, "Su");
			if (sched.day & 0x02)
				fprintf(stream_file, "M");
			if (sched.day & 0x04)
				fprintf(stream_file, "T");
			if (sched.day & 0x08)
				fprintf(stream_file, "W");
			if (sched.day & 0x10)
				fprintf(stream_file, "R");
			if (sched.day & 0x20)
				fprintf(stream_file, "F");
			if (sched.day & 0x40)
				fprintf(stream_file, "Sa");
			fprintf_P(stream_file, PSTR("(%d)"), sched.day);
		}
		for (uint8_t i = 0; i < 4; i++)
			fprintf_P(stream_file, PSTR("<br/>Time %d:%02d:%02d(%d)"), i + 1, sched.time[i] / 60, sched.time[i] % 60, sched.time[i]);
		for (uint8_t i = 0; i < NUM_ZONES; i++)
			fprintf_P(stream_file, PSTR("<br/>Zone %d Duration:%d"), i + 1, sched.zone_duration[i]);
	}
}
Пример #6
0
// MORPH START  leuk_he: Remove 2nd apply in scheduler continue:
void CPPgScheduler::OnNmClickList(NMHDR* /*pNMHDR*/, LRESULT* pResult)
{  
	// If there are modifications you first need to appy before 
	// an other schedule can be select. 
	if (m_list.GetSelectionMark()>-1) 
		if (!modified) {   miActiveSelection=m_list.GetSelectionMark() ;
			               LoadSchedule(miActiveSelection);
		}
		else // reset to previous selection and tell the user once he should apply
		{   static bool WarnOnce=false;
			//m_list.SetSelectionMark(prevsel);
 	        // m_list.SetItemState(miActiveSelection,LVIS_SELECTED, LVIS_SELECTED);
			if (!WarnOnce) {
				MessageBox(GetResString(IDS_SCHED_WARN_APPLY), //Press Ok or Apply before selecting an other schedule"
					   GetResString(IDS_SCHED_WARN_APPLY_TITLE ));
				WarnOnce=true;
			}
			*pResult=TRUE;
		}
}
Пример #7
0
void CPPgScheduler::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult){
	if (m_list.GetSelectionMark()>-1) LoadSchedule(m_list.GetSelectionMark());
}
Пример #8
0
void CPPgScheduler::OnNmClickList(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
{
	if (m_list.GetSelectionMark()>-1) LoadSchedule(m_list.GetSelectionMark());
}