Example #1
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void SummaryMenuDisplay(WND_LAYOUT_STRUCT *wnd_layout_ptr)
{
	SUMMARY_MENU_EVENT_CACHE_STRUCT* eventInfo;
	char dateBuff[25];
	char lineBuff[30];
	char modeBuff[2];
	uint16 itemsDisplayed = 1;
	uint16 length;
	uint16 tempSummaryIndex = 0;

	// Clear the LCD map
	memset(&(g_mmap[0][0]), 0, sizeof(g_mmap));

	// Display the Title centered on the Top line
	sprintf(lineBuff, "-%s-", getLangText(LIST_OF_SUMMARIES_TEXT));
	length = (uint8)strlen((char*)lineBuff);
	wnd_layout_ptr->curr_row = DEFAULT_MENU_ROW_ZERO;
	wnd_layout_ptr->curr_col = (uint16)(((wnd_layout_ptr->end_col)/2) - ((length * SIX_COL_SIZE)/2));
	WndMpWrtString((uint8*)(&lineBuff[0]), wnd_layout_ptr, SIX_BY_EIGHT_FONT, REG_LN);

	// Setup layout
	wnd_layout_ptr->curr_row = wnd_layout_ptr->start_row;
	wnd_layout_ptr->curr_col = wnd_layout_ptr->start_col;
	wnd_layout_ptr->next_row = wnd_layout_ptr->start_row;
	wnd_layout_ptr->next_col = wnd_layout_ptr->start_col;

	// Check if s_topMenuSummaryIndex is valid
	if (s_topMenuSummaryIndex == s_totalRamSummaries)
	{
		debug("Summary List: No valid summary found for display\r\n");
		sprintf(lineBuff, "<%s>", getLangText(EMPTY_TEXT));
		WndMpWrtString((uint8*)(&lineBuff[0]), wnd_layout_ptr, SIX_BY_EIGHT_FONT, REG_LN);
		// We're done
	}
	else // s_topMenuSummaryIndex is a valid index indicating valid events in storage
	{
		tempSummaryIndex = s_topMenuSummaryIndex;

		while ((itemsDisplayed <= SUMMARY_MENU_ACTIVE_ITEMS) && (tempSummaryIndex < s_totalRamSummaries))
		{
			// Check if entry is cached to prevent long delay reading files
			eventInfo = GetSummaryEventInfo(tempSummaryIndex);

			// Clear and setup the time stamp string for the current event
			memset(&dateBuff[0], 0, sizeof(dateBuff));

			ConvertTimeStampToString(dateBuff, &(eventInfo->eventTime), REC_DATE_TIME_DISPLAY);

			// Clear and setup the mode string for the curent event
			memset(&modeBuff[0], 0, sizeof(modeBuff));

			switch (eventInfo->mode)
			{
				case WAVEFORM_MODE: 		strcpy(modeBuff, "W"); break;
				case BARGRAPH_MODE: 		strcpy(modeBuff, "B"); break;
				case COMBO_MODE:	 		strcpy(modeBuff, "C"); break;
				case MANUAL_CAL_MODE:		strcpy(modeBuff, "P"); break;
				case MANUAL_TRIGGER_MODE:	strcpy(modeBuff, "M"); break;
			}
			
			// Clear and setup the event line string for the curent event
			memset(&lineBuff[0], 0, sizeof(lineBuff));
			sprintf(lineBuff, "E%03d %s %s", (int)eventInfo->eventNumber, dateBuff, modeBuff);

			// Check if the current line is to be highlighted
			if (tempSummaryIndex == s_currentSummaryIndex)
			{
				WndMpWrtString((uint8*)(&lineBuff[0]), wnd_layout_ptr, SIX_BY_EIGHT_FONT, CURSOR_LN);
			}
			else // Print as a regular line
			{
				WndMpWrtString((uint8*)(&lineBuff[0]), wnd_layout_ptr, SIX_BY_EIGHT_FONT, REG_LN);
			}

			// Set the current row as the next row
			wnd_layout_ptr->curr_row = wnd_layout_ptr->next_row;

			// Increment the items displayed
			itemsDisplayed++;
			
			tempSummaryIndex = GetNextValidRamSummaryIndex(tempSummaryIndex);
		}

		// Check if the summary index is at the end of the list and still room on the LCD
		if ((itemsDisplayed <= SUMMARY_MENU_ACTIVE_ITEMS) && (tempSummaryIndex == s_totalRamSummaries))
		{
			debug("Summary List: End of the list\r\n");
			sprintf(lineBuff, "<%s>", getLangText(END_TEXT));
			WndMpWrtString((uint8*)(&lineBuff[0]), wnd_layout_ptr, SIX_BY_EIGHT_FONT, REG_LN);
		}
	}
}
Example #2
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void LoadFactorySetupRecord(void)
{
	DATE_TIME_STRUCT tempTime;
	char buff[50];

	GetRecordData(&g_factorySetupRecord, DEFAULT_RECORD, REC_FACTORY_SETUP_TYPE);

	// Check if the Factory Setup Record is invalid
	if (g_factorySetupRecord.invalid)
	{
		// Warn the user
		debugWarn("Factory setup record not found.\r\n");
		OverlayMessage(getLangText(ERROR_TEXT), getLangText(FACTORY_SETUP_DATA_COULD_NOT_BE_FOUND_TEXT), (2 * SOFT_SECS));

		// Check if the Shadow Factory setup is valid
		if (!SHADOW_FACTORY_SETUP_CLEARED)
		{
			// Warn the user
			debugWarn("Factory setup shadow copy exists.\r\n");
			if (MessageBox(getLangText(CONFIRM_TEXT), getLangText(RESTORE_FACTORY_SETUP_FROM_BACKUP_Q_TEXT), MB_YESNO) == MB_FIRST_CHOICE)
			{
				GetFlashUserPageFactorySetup(&g_factorySetupRecord);
				SaveRecordData(&g_factorySetupRecord, DEFAULT_RECORD, REC_FACTORY_SETUP_TYPE);
			}
		}
	}

	// Check if the Factory Setup Record is valid (in case shadow factory setup was copied over)
	if (!g_factorySetupRecord.invalid)
	{
		if (g_seismicSmartSensorMemory.version & SMART_SENSOR_OVERLAY_KEY)
		{
			g_factorySetupRecord.seismicSensorType = (pow(2, g_seismicSmartSensorMemory.sensorType) * SENSOR_2_5_IN);
		}

		if (g_acousticSmartSensorMemory.version & SMART_SENSOR_OVERLAY_KEY)
		{
			if ((g_acousticSmartSensorMemory.sensorType == SENSOR_MIC_148) || (g_acousticSmartSensorMemory.sensorType == SENSOR_MIC_160))
			{
				g_factorySetupRecord.acousticSensorType = g_acousticSmartSensorMemory.sensorType;
			}
		}

		UpdateWorkingCalibrationDate();

		// Print the Factory Setup Record to the console
		memset(&buff[0], 0, sizeof(buff));
		ConvertCalDatetoDateTime(&tempTime, &g_currentCalibration.date);
		ConvertTimeStampToString(buff, &tempTime, REC_DATE_TYPE);

		if (g_factorySetupRecord.seismicSensorType > SENSOR_ACC_RANGE_DIVIDER) { strcpy((char*)&g_spareBuffer, "Acc"); }
		else { sprintf((char*)&g_spareBuffer, "%3.1f in", (float)g_factorySetupRecord.seismicSensorType / (float)204.8); }

		// Check if an older unit doesn't have the Analog Channel Config set
		if ((g_factorySetupRecord.analogChannelConfig != CHANNELS_R_AND_V_SCHEMATIC) && (g_factorySetupRecord.analogChannelConfig != CHANNELS_R_AND_V_SWAPPED))
		{
			// Set the default
			g_factorySetupRecord.analogChannelConfig = CHANNELS_R_AND_V_SWAPPED;
		}

		debug("Factory Setup: Serial #: %s\r\n", g_factorySetupRecord.unitSerialNumber);
		debug("Factory Setup: Cal Date: %s\r\n", buff);
		debug("Factory Setup: Sensor Type: %s\r\n", (char*)g_spareBuffer);
		debug("Factory Setup: A-Weighting: %s\r\n", (g_factorySetupRecord.aWeightOption == YES) ? "Enabled" : "Disabled");
		debug("Factory Setup: Analog Channel Config: %s\r\n", (g_factorySetupRecord.analogChannelConfig == CHANNELS_R_AND_V_SCHEMATIC) ? "Schematic" : "Swapped");
	}
}