/* * Copyright (C) 1998 by Southwest Research Institute (SwRI) * * All rights reserved under U.S. Copyright Law and International Conventions. * * The development of this Software was supported by contracts NAG5-3148, * NAG5-6855, NAS8-36840, NAG5-2323, and NAG5-7043 issued on behalf of * the United States Government by its National Aeronautics and Space * Administration. Southwest Research Institute grants to the Government, * and others acting on its behalf, a paid-up nonexclusive, irrevocable, * worldwide license to reproduce, prepare derivative works, and perform * publicly and display publicly, by or on behalf of the Government. * Other than those rights granted to the United States Government, no part * of this Software may be reproduced in any form or by any means, electronic * or mechanical, including photocopying, without permission in writing from * Southwest Research Institute. All inquiries should be addressed to: * * Director of Contracts * Southwest Research Institute * P. O. Drawer 28510 * San Antonio, Texas 78228-0510 * * * Use of this Software is governed by the terms of the end user license * agreement, if any, which accompanies or is included with the Software * (the "License Agreement"). An end user will be unable to install any * Software that is accompanied by or includes a License Agreement, unless * the end user first agrees to the terms of the License Agreement. Except * as set forth in the applicable License Agreement, any further copying, * reproduction or distribution of this Software is expressly prohibited. * Installation assistance, product support and maintenance, if any, of the * Software is available from SwRI and/or the Third Party Providers, as the * case may be. * * Disclaimer of Warranty * * SOFTWARE IS WARRANTED, IF AT ALL, IN ACCORDANCE WITH THESE TERMS OF THE * LICENSE AGREEMENT. UNLESS OTHERWISE EXPLICITLY STATED, THIS SOFTWARE IS * PROVIDED "AS IS", IS EXPERIMENTAL, AND IS FOR NON-COMMERCIAL USE ONLY, * AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT * SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. * * Limitation of Liability * * SwRI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED AS A RESULT OF USING, * MODIFYING, CONTRIBUTING, COPYING, DISTRIBUTING, OR DOWNLOADING THIS * SOFTWARE. IN NO EVENT SHALL SwRI BE LIABLE FOR ANY INDIRECT, PUNITIVE, * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGE (INCLUDING LOSS OF BUSINESS, * REVENUE, PROFITS, USE, DATA OR OTHER ECONOMIC ADVANTAGE) HOWEVER IT ARISES, * WHETHER FOR BREACH OF IN TORT, EVEN IF SwRI HAS BEEN PREVIOUSLY ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. YOU HAVE SOLE RESPONSIBILITY FOR ADEQUATE * PROTECTION AND BACKUP OF DATA AND/OR EQUIPMENT USED IN CONNECTION WITH THE * SOFTWARE AND WILL NOT MAKE A CLAIM AGAINST SwRI FOR LOST DATA, RE-RUN TIME, * INACCURATE OUTPUT, WORK DELAYS OR LOST PROFITS RESULTING FROM THE USE OF * THIS SOFTWARE. YOU AGREE TO HOLD SwRI HARMLESS FROM, AND YOU COVENANT NOT * TO SUE SwRI FOR, ANY CLAIMS BASED ON USING THE SOFTWARE. * * Local Laws: Export Control * * You acknowledge and agree this Software is subject to the U.S. Export * Administration Laws and Regulations. Diversion of such Software contrary * to U.S. law is prohibited. You agree that none of the Software, nor any * direct product therefrom, is being or will be acquired for, shipped, * transferred, or reexported, directly or indirectly, to proscribed or * embargoed countries or their nationals, nor be used for nuclear activities, * chemical biological weapons, or missile projects unless authorized by U.S. * Government. Proscribed countries are set forth in the U.S. Export * Administration Regulations. Countries subject to U.S embargo are: Cuba, * Iran, Iraq, Libya, North Korea, Syria, and the Sudan. This list is subject * to change without further notice from SwRI, and you must comply with the * list as it exists in fact. You certify that you are not on the U.S. * Department of Commerce's Denied Persons List or affiliated lists or on the * U.S. Department of Treasury's Specially Designated Nationals List. You agree * to comply strictly with all U.S. export laws and assume sole responsibilities * for obtaining licenses to export or reexport as may be required. * * General * * These Terms represent the entire understanding relating to the use of the * Software and prevail over any prior or contemporaneous, conflicting or * additional, communications. SwRI can revise these Terms at any time * without notice by updating this posting. * * Trademarks * * The SwRI logo is a trademark of SwRI in the United States and other countries. * */ #include #include #include "ret_codes.h" #include "user_defs.h" #include "libVIDF.h" #include "libbase_idfs.h" #include "libCfg.h" #include "libdb.h" /* This routine processes playback data for all RTLA sensors. */ void main (void) { struct idf_data *EXP_DATA; SDDAS_FLOAT conv_data[1000]; SDDAS_LONG btime_sec, btime_nano, etime_sec, etime_nano; SDDAS_LONG new_start_sec, new_start_nsec, rval, *tbl_oper; SDDAS_ULONG data_key; SDDAS_USHORT version; register SDDAS_USHORT k; SDDAS_SHORT sensor, ret_val, num_sensor, rcode, new_year, new_day; SDDAS_SHORT btime_yr, btime_day, etime_yr, etime_day; SDDAS_CHAR extension[3], full_swp = 1, fwd = 1, *tbls_to_apply, num_tbls; char more_data = 1; void *idf_data_ptr; /**************************************************************************/ /* Set the start and stop time. This example uses year 1984, day 257, */ /* starting at 13:20:00 (hh:mm:ss) - 48000 seconds - and ending at */ /* 13:20:20 (hh:mm:ss) - 48020 seconds. */ /**************************************************************************/ btime_yr = 1984; btime_day = 257; btime_sec = 48000; btime_nano = 0; etime_yr = 1984; etime_day = 257; etime_sec = 48020; etime_nano = 0; /*************************************************************************/ /* Set the data file of interest ("" means default file is to be used). */ /*************************************************************************/ strcpy (extension,""); CfgInit(); dbInitialize (); init_idfs (); /***********************************************************************/ /* Retreive the key that is associated with the project, mission, */ /* experiment, instrument and virtual instrument specified. */ /***********************************************************************/ ret_val = get_data_key ("AMPTE", "AMPTE-UK", "TDIE", "TDIE", "TDFR", &data_key); if (ret_val != ALL_OKAY) { printf ("\n Error %d from get_data_key routine.\n", ret_val); exit (-1); } get_version_number (&version); /************************************************************************/ /* Create one instance of the data structure. */ /************************************************************************/ ret_val = create_idf_data_structure (&idf_data_ptr); if (ret_val != ALL_OKAY) { printf ("\n Error %d from create_idf_data_structure routine.\n", ret_val); exit (-1); } EXP_DATA = (struct idf_data *) idf_data_ptr; /*********************************************************************/ /* Open the data files associated with the time period selected for */ /* this data set/extension/version combination. */ /*********************************************************************/ ret_val = file_open (data_key, extension, version, btime_yr, btime_day, btime_sec, btime_nano, etime_yr, etime_day, etime_sec, etime_nano, 0); if (ret_val != ALL_OKAY) { printf ("\n Error %d from file_open routine.\n", ret_val); exit (-1); } /***********************************************************************/ /* Find the position in the data file closest to the requested */ /* start time for this data set. Unlike real-time, if an error is */ /* encountered, the system should terminate - no need to retry in */ /* anticipation of incoming data. */ /***********************************************************************/ ret_val = file_pos (data_key, extension, version, idf_data_ptr, btime_yr, btime_day, btime_sec, btime_nano, etime_yr, etime_day, etime_sec, etime_nano); if (ret_val != ALL_OKAY) { printf ("\n Error %d from file_pos.\n", ret_val); exit (-1); } /************************************************************************/ /* Find out the number of sensors defined for this virtual instrument. */ /************************************************************************/ rval = read_idf (data_key, extension, version, (SDDAS_CHAR *) &num_sensor, _SEN, 0, 0, 1); if (rval < 0) { printf ("\n Error %ld from read_idf routine.\n", (long int) rval); exit (-1); } /*********************************************************************/ /* Retrieve the raw units for the data. */ /*********************************************************************/ num_tbls = 0; tbls_to_apply = NULL; tbl_oper = NULL; /*************************************************************************/ /* Get the data for all sensors. */ /*************************************************************************/ while (more_data) { for (sensor = 0; sensor < num_sensor; ++sensor) { /******************************************************************/ /* Advance to the next data set only if the last sensor is */ /* being processed to ensure all samples which occur at the same */ /* time are processed simultaneously. */ /******************************************************************/ fwd = (sensor == num_sensor - 1) ? 1 : 0; ret_val = read_drec (data_key, extension, version, idf_data_ptr, sensor, fwd, full_swp); if (ret_val < 0) { printf ("\nError %d from read_drec.\n", ret_val); exit (-1); } /*******************************************************************/ /* The sensor data was found within the time being processed. */ /*******************************************************************/ if (ret_val == ALL_OKAY || EXP_DATA->filled_data) { /******************************************************************/ /* If the time of the sample is past the requested end time, stop*/ /* processing data. */ /******************************************************************/ if (EXP_DATA->byear > etime_yr || (EXP_DATA->byear == etime_yr && EXP_DATA->bday > etime_day) || (EXP_DATA->byear == etime_yr && EXP_DATA->bday == etime_day && EXP_DATA->bsec > etime_sec) || (EXP_DATA->byear == etime_yr && EXP_DATA->bday == etime_day && EXP_DATA->bsec == etime_sec && EXP_DATA->bnsec > etime_nano)) { more_data = 0; break; } rcode = convert_to_units (data_key, extension, version, idf_data_ptr, sensor, SENSOR, 0, num_tbls, tbls_to_apply, tbl_oper, conv_data, 0, 0); if (rcode != ALL_OKAY) { printf ("\nError %d from convert_to_units.\n", rcode); exit (-1); } /******************************************************************/ /* Print the times for the sample being returned. */ /******************************************************************/ printf ("\n\nSENSOR %d's START TIME_MS = %ld", sensor, (long int) EXP_DATA->bmilli); printf ("\nSENSOR %d's START TIME_NS = %ld", sensor, (long int) EXP_DATA->bnano); printf ("\nSENSOR %d's END TIME_MS = %ld", sensor, (long int) EXP_DATA->emilli); printf ("\nSENSOR %d's END TIME_NS = %ld", sensor, (long int) EXP_DATA->enano); /******************************************************************/ /* Print the data, 6 values per row, in exponential format. */ /******************************************************************/ for (k = 0; k < EXP_DATA->num_sample; ++k) { if (k % 6 == 0) printf ("\n"); printf ("%10.2e ", conv_data[k]); } printf ("\n\n"); } if (ret_val == LOS_STATUS || ret_val == NEXT_FILE_STATUS) { /***************************************************************/ /* Get the start time to use to get the next data file. */ /***************************************************************/ rcode = next_file_start_time (data_key, extension, version, 0, &new_year, &new_day, &new_start_sec, &new_start_nsec); if (rcode != ALL_OKAY) { printf ("\n Error %d from next_file_start_time.\n", rcode); exit (-1); } rcode = reset_experiment_info (data_key, extension, version, new_year, new_day, new_start_sec, new_start_nsec, etime_yr, etime_day, etime_sec, etime_nano); if (rcode == NO_DATA) { more_data = 0; break; } else if (rcode != ALL_OKAY) { printf ("\n Error %d from reset_experiment_info.\n", rcode); exit (-1); } rcode = file_pos (data_key, extension, version, idf_data_ptr, new_year, new_day, new_start_sec, new_start_nsec, etime_yr, etime_day, etime_sec, etime_nano); if (rcode != ALL_OKAY) { printf ("\n Error %d from file_pos.\n", rcode); exit (-1); } } } } free_experiment_info(); }