Beispiel #1
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void LoadUnitConfig(void)
{
	GetRecordData(&g_unitConfig, DEFAULT_RECORD, REC_UNIT_CONFIG_TYPE);

	// Check if the Unit Config is uninitialized
	if (g_unitConfig.validationKey != 0xA5A5)
	{
		// Set defaults in Unit Config
		debugWarn("Unit Config: Not found.\r\n");
#if EXTENDED_DEBUG
		debug("Loading Unit Config Defaults\r\n");
#endif

		LoadUnitConfigDefaults((UNIT_CONFIG_STRUCT*)&g_unitConfig);
		SaveRecordData(&g_unitConfig, DEFAULT_RECORD, REC_UNIT_CONFIG_TYPE);
	}
	else
	{
		// Unit Config is valid
#if EXTENDED_DEBUG
		debug("Unit Config record is valid\r\n");
#endif

		if ((g_unitConfig.pretrigBufferDivider != PRETRIGGER_BUFFER_QUARTER_SEC_DIV) && (g_unitConfig.pretrigBufferDivider != PRETRIGGER_BUFFER_HALF_SEC_DIV) &&
			(g_unitConfig.pretrigBufferDivider != PRETRIGGER_BUFFER_FULL_SEC_DIV))
		{
			g_unitConfig.pretrigBufferDivider = PRETRIGGER_BUFFER_QUARTER_SEC_DIV;
			SaveRecordData(&g_unitConfig, DEFAULT_RECORD, REC_UNIT_CONFIG_TYPE);
		}

#if 1 // Forcing flash wrapping to be disabled
		g_unitConfig.flashWrapping = NO;
#endif

#if 0 // Moved this init to the hardware section to allow for the saved Baud rate to be established from the start
		// Set the baud rate to the user stored baud rate setting (initialized to 115200)
		switch (g_unitConfig.baudRate)
		{
			case BAUD_RATE_57600: rs232Options.baudrate = 57600; break;
			case BAUD_RATE_38400: rs232Options.baudrate = 38400; break;
			case BAUD_RATE_19200: rs232Options.baudrate = 19200; break;
			case BAUD_RATE_9600: rs232Options.baudrate = 9600; break;
		}

		if (g_unitConfig.baudRate != BAUD_RATE_115200)
		{
			// Re-Initialize the RS232 with the stored baud rate
			usart_init_rs232(&AVR32_USART1, &rs232Options, FOSC0);
		}
#endif
	}
}
Beispiel #2
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void LoadDefaultTriggerRecord(void)
{
	GetRecordData(&g_triggerRecord, DEFAULT_RECORD, REC_TRIGGER_USER_MENU_TYPE);

	// Check if the Default Trig Record is uninitialized
	if (g_triggerRecord.validRecord != YES)
	{
		debugWarn("Default Trigger Record: Invalid, loading defaults\r\n");
		LoadTrigRecordDefaults(&g_triggerRecord, WAVEFORM_MODE);
		SaveRecordData(&g_triggerRecord, DEFAULT_RECORD, REC_TRIGGER_USER_MENU_TYPE);
	}
	else
	{
		debug("Default Trigger record is valid\r\n");
	}
}
Beispiel #3
0
size_t RecordRead(RecordReader* reader, FILE* stream, void* buf, size_t amount)
{
	size_t i = 0;

	while(i < amount)
	{
		size_t remaining = reader->dataSize - reader->dataIndex;
		if(remaining > 0)
		{
			size_t read = amount - i < remaining ? amount - i : remaining;
			GetRecordData(reader, stream, buf + i, read);
			i += read;
		}
		else if(LoadRecord(reader, stream))
		{
			return i;
		}
	}

	return i;
}
Beispiel #4
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void LoadModemSetupRecord(void)
{
	GetRecordData(&g_modemSetupRecord, 0, REC_MODEM_SETUP_TYPE);

	// Check if the Modem Setup Record is invalid
	if (g_modemSetupRecord.invalid)
	{
		// Warn the user
		debugWarn("Modem setup record not found.\r\n");

		// Initialize the Modem Setup Record
		LoadModemSetupRecordDefaults();

		// Save the Modem Setup Record
		SaveRecordData(&g_modemSetupRecord, DEFAULT_RECORD, REC_MODEM_SETUP_TYPE);
	}
	else
	{
#if EXTENDED_DEBUG
		debug("Modem Setup record is valid\r\n");
#endif
		ValidateModemSetupParameters();
	}
}
Beispiel #5
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void LoadRecordMenuProc(INPUT_MSG_STRUCT msg, WND_LAYOUT_STRUCT *wnd_layout_ptr, MN_LAYOUT_STRUCT *mn_layout_ptr)
{
    uint8 buff[20];
    REC_EVENT_MN_STRUCT temp_rec;
    INPUT_MSG_STRUCT mn_msg;
    uint32 input;
    uint8 i;

    switch (msg.cmd)
    {
    case (ACTIVATE_MENU_CMD):
        wnd_layout_ptr->start_col = LOAD_REC_WND_STARTING_COL;
        wnd_layout_ptr->end_col = LOAD_REC_WND_END_COL;
        wnd_layout_ptr->start_row = LOAD_REC_WND_STARTING_ROW;
        wnd_layout_ptr->end_row = LOAD_REC_WND_END_ROW;

        mn_layout_ptr->curr_ln = 1;
        mn_layout_ptr->top_ln = 1;

        LoadTempMenuTable(s_loadRecordMenuTable);

        for (i = 1; i <= MAX_NUM_OF_SAVED_SETUPS; i++)
        {
            GetRecordData(&temp_rec, i, REC_TRIGGER_USER_MENU_TYPE);

            if (temp_rec.validRecord == YES)
            {
                switch (temp_rec.opMode)
                {
                case (WAVEFORM_MODE):
                    sprintf((char*)buff, "%s (%s)", (char*)temp_rec.name, getLangText(SELF_TRG_TEXT));
                    break;
                case (BARGRAPH_MODE):
                    sprintf((char*)buff, "%s (%s)", (char*)temp_rec.name, getLangText(BAR_TEXT));
                    break;
                case (COMBO_MODE):
                    sprintf((char*)buff, "%s (%s)", (char*)temp_rec.name, getLangText(COMBO_TEXT));
                    break;
                default:
                    sprintf((char*)buff, "%s (UNK)", (char*)temp_rec.name);
                    break;
                }

            }
            else
            {
                sprintf((char*)buff, "<%s>", getLangText(EMPTY_TEXT));
            }

            // Add 3 to i to offset past the default settings
            strcpy((char*)&(g_menuPtr[i + 3].data[0]), (char*)buff);
        }

        // Add in the "<END>" text to signal the end of the list
        sprintf((char*)buff, "<%s>", getLangText(END_TEXT));
        strcpy((char*)&(g_menuPtr[i + 3].data[0]), (char*)buff);
        i++;

        // Add the end string to allow other routines to match on the end of the menu
        strcpy((char*)&(g_menuPtr[i + 3].data[0]), ".end.");
        break;

    case (KEYPRESS_MENU_CMD):
        input = msg.data[0];
        switch (input)
        {
        case (ENTER_KEY):
            switch (mn_layout_ptr->curr_ln)
            {
            case (1):
                LoadTrigRecordDefaults(&g_triggerRecord, WAVEFORM_MODE);
                break;
            case (2):
                LoadTrigRecordDefaults(&g_triggerRecord, BARGRAPH_MODE);
                break;
            case (3):
                LoadTrigRecordDefaults(&g_triggerRecord, COMBO_MODE);
                break;
            default:
                // Check if the first char matches a "<" for either "<EMPTY>" or "<END>"
                if (strncmp((char*)&g_menuPtr[mn_layout_ptr->curr_ln].data[0], "<", 1) == 0)
                {
                    // Record slot is empty, do nothing
                    return;
                }
                else
                {
                    GetRecordData(&g_triggerRecord, (uint32)(mn_layout_ptr->curr_ln - 3), REC_TRIGGER_USER_MENU_TYPE);
                }
                break;
            }

            UpdateModeMenuTitle(g_triggerRecord.opMode);
            SETUP_USER_MENU_MSG(&modeMenu, MONITOR);
            JUMP_TO_ACTIVE_MENU();
            break;

        case (DELETE_KEY):
            // Check if the current line is beyond the default entries
            if (mn_layout_ptr->curr_ln > 3)
            {
                GetRecordData(&temp_rec, (uint32)(mn_layout_ptr->curr_ln - 3), REC_TRIGGER_USER_MENU_TYPE);

                if (temp_rec.validRecord == YES)
                {
                    sprintf((char*)g_spareBuffer, "%s (%s)", getLangText(DELETE_SAVED_SETUP_Q_TEXT), temp_rec.name);

                    if (MessageBox(getLangText(WARNING_TEXT), (char*)g_spareBuffer, MB_YESNO) == MB_FIRST_CHOICE)
                    {
                        memset(&temp_rec.name, 0, sizeof(temp_rec.name));
                        temp_rec.validRecord = NO;

                        SaveRecordData(&temp_rec, (uint32)(mn_layout_ptr->curr_ln - 3), REC_TRIGGER_USER_MENU_TYPE);

                        sprintf((char*)&(g_menuPtr[mn_layout_ptr->curr_ln].data[0]), "<%s>", getLangText(EMPTY_TEXT));
                    }
                }
            }
            break;

        case (DOWN_ARROW_KEY):
            MenuScroll(DOWN, SELECT_MN_WND_LNS, mn_layout_ptr);

            // Prevent the cursor from selecting the "<END>" text
            if (mn_layout_ptr->curr_ln == 18)
            {
                mn_layout_ptr->curr_ln = 17;
            }
            break;
        case (UP_ARROW_KEY):
            MenuScroll(UP, SELECT_MN_WND_LNS, mn_layout_ptr);
            break;
        case (ESC_KEY):
            SETUP_MENU_MSG(MAIN_MENU);
            mn_msg.data[0] = ESC_KEY;
            JUMP_TO_ACTIVE_MENU();
            break;
        case (HELP_KEY):
            SETUP_USER_MENU_MSG(&helpMenu, CONFIG);
            JUMP_TO_ACTIVE_MENU();
            break;
        default:
            break;
        }
        break;

    default:
        break;
    }
}
Beispiel #6
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");
	}
}