![]() |
libHiRISE
|
00001 /* Observation_ID 00002 00003 PIRL CVS ID: Observation_ID.hh,v 2.7 2020/02/14 00:58:12 schaller Exp 00004 00005 Copyright (C) 2003-2020 Arizona Board of Regents on behalf of the Lunar and 00006 Planetary Laboratory at the University of Arizona. 00007 00008 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 00009 this file except in compliance with the License. You may obtain a copy of the 00010 License at 00011 00012 http://www.apache.org/licenses/LICENSE-2.0 00013 00014 Unless required by applicable law or agreed to in writing, software distributed 00015 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00016 CONDITIONS OF ANY KIND, either express or implied. See the License for the 00017 specific language governing permissions and limitations under the License. 00018 00019 */ 00020 #ifndef _UA_HIRISE_OBSERVATION_ID_HEADER_ 00021 #define _UA_HIRISE_OBSERVATION_ID_HEADER_ 00022 00023 #include "Instrument.hh" 00024 #include "Exceptions.hh" 00025 00026 #include <iostream> 00027 #include <string> 00028 00029 00030 namespace UA 00031 { 00032 namespace HiRISE 00033 { 00034 /*============================================================================== 00035 Types 00036 */ 00037 typedef unsigned int u_int_32; 00038 00039 00216 class Observation_ID 00217 { 00218 public: 00219 00220 /*============================================================================== 00221 Constants 00222 */ 00224 static const char* 00225 ID; 00226 00233 static const int 00234 EPOCH; 00235 00246 enum Mission_Phase 00247 { 00248 INTEGRATION_AND_TESTING = 0, 00249 CALIBRATION, 00250 ATLO, 00251 KENNEDY_SPACE_CENTER, 00252 LAUNCH, 00253 CRUISE, 00254 APPROACH, 00255 AEROBRAKING, 00256 TRANSITION, 00257 PRIMARY_SCIENCE_PHASE, 00258 RELAY, 00259 EXTENDED_SCIENCE_PHASE, 00260 RESERVED_1, 00261 RESERVED_2, 00262 RESERVED_3, 00263 RESERVED_4, 00264 RESERVED_5, 00265 RESERVED_6, 00266 RESERVED_7, 00267 RESERVED_8, 00268 RESERVED_9, 00269 RESERVED_10, 00270 RESERVED_11, 00271 RESERVED_12, 00272 RESERVED_13, 00273 RESERVED_14, 00274 RESERVED_15, 00275 RESERVED_16, 00276 RESERVED_17, 00277 RESERVED_18, 00278 RESERVED_19, 00279 SVT, 00280 00281 // Total number of phases 00282 TOTAL_MISSION_PHASES 00283 }; 00284 00285 /* 00286 00287 A note about future mission phases: 00288 00289 When adding a mission phase, bump the reserved set such that the next phase 00290 following the new phase is still "Reserved 1." Software should not be using the 00291 reserved phases, so this change is defined to be safe. 00292 00293 At Deputy Principal Investigator Candice Hansen's and Principal Investigator 00294 Alfred McEwen's direction, the extended mission phases are to be abbreviated 00295 YM3, YM4, etc., for "Year of Mars 3," "Year of Mars 4," etc., where PSP and ESP 00296 are considered Year of Mars 1 and Year of Mars 2, respectively. 00297 00298 E-mail from Candice to Alfred, GDS Manager Eric Eliason, and Chris Schaller on 00299 October 6, 2008 3:01:36 PM GMT-07:00: 00300 00301 "How about YM3, YM4, etc. after ESP? (Year of Mars so that it doesn't seem like 00302 Mega Year). If we last to > 10 we can just drop the M." 00303 00304 */ 00305 00306 static const Mission_Phase 00308 LAST_PREORBIT_PHASE, 00310 DEFAULT_PREORBIT_PHASE, 00312 DEFAULT_INORBIT_PHASE, 00316 DEFAULT_MISSION_PHASE; 00317 00319 static const char* 00320 MISSION_PHASE_ABBREVIATION[]; 00321 00326 static const char* 00327 MISSION_PHASE_NAME[]; 00328 00337 static const int 00338 MISSION_PHASE_MAX_TIME[]; 00339 00343 static const unsigned int 00344 MISSION_PHASE_MAX_ORBIT[]; 00345 00346 static const u_int_32 00347 DEFAULT_OBSERVATION_ID, 00348 INVALID_OBSERVATION_ID; 00349 00350 static const unsigned int 00351 DEFAULT_TIME, 00352 DEFAULT_ORBIT_NUMBER, 00353 DEFAULT_TARGET; 00354 00355 // Text parsing 00356 static const char 00357 TEXT_DELIMITER, 00358 EXTENSION_DELIMITER; 00359 00360 static const char 00361 *STANDARD_TIME_TEXT_FORMAT, 00362 *RSDS_TIME_TEXT_FORMAT, 00363 *JPL_TIME_TEXT_FORMAT; 00364 00365 /*------------------------------------------------------------------------------ 00366 Bitfield constants 00367 */ 00368 static const u_int_32 00369 MISSION_PHASE_START, 00370 MISSION_PHASE_BIT_COUNT, 00371 MISSION_PHASE_MAX, 00372 MISSION_PHASE_MASK, 00373 00374 TIME_START, 00375 TIME_BIT_COUNT, 00376 TIME_MAX, 00377 TIME_MASK, 00378 00379 ORBIT_NUMBER_START, 00380 ORBIT_NUMBER_BIT_COUNT, 00381 ORBIT_NUMBER_MIN, 00382 ORBIT_NUMBER_MAX, 00383 ORBIT_NUMBER_MASK, 00384 00385 TARGET_START, 00386 TARGET_BIT_COUNT, 00387 TARGET_MAX, 00388 TARGET_MASK; 00389 00390 /*============================================================================== 00391 Constructors 00392 */ 00393 /*------------------------------------------------------------------------------ 00394 Observation_ID::Observation_ID (const u_int_32) 00395 */ 00402 explicit 00403 Observation_ID 00404 ( 00405 const u_int_32 id_value = DEFAULT_OBSERVATION_ID 00406 ) 00407 : Value (id_value) { }; 00408 00409 /*------------------------------------------------------------------------------ 00410 Observation_ID::Observation_ID (const Mission_Phase, const int) 00411 */ 00432 Observation_ID 00433 ( 00434 const Mission_Phase mission_phase_value, 00435 const time_t seconds = -1 00436 ); 00437 00438 /*------------------------------------------------------------------------------ 00439 Observation_ID::Observation_ID (const Mission_Phase, const unsigned int, ...) 00440 */ 00464 Observation_ID 00465 ( 00466 const Mission_Phase mission_phase_value, 00467 const unsigned int orbit_number_value, 00468 const unsigned int target_value 00469 ); 00470 00471 /*------------------------------------------------------------------------------ 00472 Observation_ID::Observation_ID (const std::string&) 00473 */ 00484 explicit 00485 Observation_ID 00486 ( 00487 const std::string& id_text 00488 ); 00489 00490 /*============================================================================== 00491 Accessors 00492 */ 00493 /*------------------------------------------------------------------------------ 00494 Observation_ID::value () 00495 */ 00500 u_int_32 00501 value () const { return Value; } 00502 00503 /*------------------------------------------------------------------------------ 00504 Observation_ID::value (const u_int_32) 00505 */ 00511 Observation_ID& 00512 value 00513 ( 00514 const u_int_32 id_value 00515 ) 00516 { Value = id_value; return *this; } 00517 00518 /*------------------------------------------------------------------------------ 00519 Observation_ID::value (const std::string&) 00520 */ 00531 Observation_ID& 00532 value 00533 ( 00534 const std::string& id_text 00535 ) 00536 throw (Invalid_Argument); 00537 00538 /*------------------------------------------------------------------------------ 00539 Observation_ID::hex_value (const std::string&) 00540 */ 00551 Observation_ID& 00552 hex_value 00553 ( 00554 const std::string& id_text 00555 ) 00556 throw (Invalid_Argument); 00557 00558 /*------------------------------------------------------------------------------ 00559 Observation_ID::mission_phase () 00560 */ 00565 Mission_Phase 00566 mission_phase () const; 00567 00568 /*------------------------------------------------------------------------------ 00569 Observation_ID::mission_phase (const Mission_Phase) 00570 */ 00580 Observation_ID& 00581 mission_phase 00582 ( 00583 const Mission_Phase mission_phase_value 00584 ) 00585 throw (Out_of_Range); 00586 00587 /*------------------------------------------------------------------------------ 00588 Observation_ID::mission_phase (const std::string&) 00589 */ 00602 Observation_ID& 00603 mission_phase 00604 ( 00605 const std::string& mission_phase_text 00606 ) 00607 throw (Invalid_Argument); 00608 00609 /*------------------------------------------------------------------------------ 00610 Observation_ID::mission_phase (const time_t) 00611 */ 00639 Observation_ID& 00640 mission_phase 00641 ( 00642 time_t seconds 00643 ) 00644 throw (Out_of_Range); 00645 00646 /*------------------------------------------------------------------------------ 00647 Observation_ID::mission_phase (const unsigned int) 00648 */ 00660 Observation_ID& 00661 mission_phase 00662 ( 00663 const unsigned int orbit_number 00664 ) 00665 throw (Out_of_Range); 00666 00667 00668 /*------------------------------------------------------------------------------ 00669 Observation_ID::time () 00670 */ 00680 time_t 00681 time () const 00682 throw (Invalid_Argument); 00683 00684 /*------------------------------------------------------------------------------ 00685 Observation_ID::time (const time_t) 00686 */ 00700 Observation_ID& 00701 time 00702 ( 00703 const time_t seconds 00704 ) 00705 throw (Invalid_Argument, Out_of_Range); 00706 00707 /*------------------------------------------------------------------------------ 00708 Observation_ID::time (const std::string&, const std::string&) 00709 */ 00729 Observation_ID& 00730 time 00731 ( 00732 const std::string& time_text, 00733 const std::string& time_text_format = STANDARD_TIME_TEXT_FORMAT 00734 ) 00735 throw (Invalid_Argument, Out_of_Range); 00736 00737 /*------------------------------------------------------------------------------ 00738 Observation_ID::time_now () 00739 */ 00751 Observation_ID& 00752 time_now () 00753 throw (Invalid_Argument); 00754 00755 /*------------------------------------------------------------------------------ 00756 Observation_ID::orbit_number () 00757 */ 00763 unsigned int 00764 orbit_number () const 00765 throw (Invalid_Argument); 00766 00767 /*------------------------------------------------------------------------------ 00768 Observation_ID::orbit_number (const unsigned int) 00769 */ 00778 Observation_ID& 00779 orbit_number 00780 ( 00781 const unsigned int orbit_number_value 00782 ) 00783 throw (Invalid_Argument, Out_of_Range); 00784 00785 /*------------------------------------------------------------------------------ 00786 Observation_ID::orbit_number (const std::string&) 00787 */ 00799 Observation_ID& 00800 orbit_number 00801 ( 00802 const std::string& orbit_number_text 00803 ) 00804 throw (Invalid_Argument, Out_of_Range); 00805 00806 /*------------------------------------------------------------------------------ 00807 Observation_ID::target () 00808 */ 00824 unsigned int 00825 target () const 00826 throw (Invalid_Argument); 00827 00828 /*------------------------------------------------------------------------------ 00829 Observation_ID::target (const unsigned int) 00830 */ 00839 Observation_ID& 00840 target 00841 ( 00842 const unsigned int target_value 00843 ) 00844 throw (Invalid_Argument, Out_of_Range); 00845 00846 /*------------------------------------------------------------------------------ 00847 Observation_ID::target (const std::string&) 00848 */ 00861 Observation_ID& 00862 target 00863 ( 00864 const std::string& target_text 00865 ) 00866 throw (Invalid_Argument, Out_of_Range); 00867 00868 /*============================================================================== 00869 Text representation 00870 */ 00871 /*------------------------------------------------------------------------------ 00872 Observation_ID::text () 00873 */ 00878 std::string 00879 text () const; 00880 00881 /*------------------------------------------------------------------------------ 00882 Observation_ID::text (const std::string&) 00883 */ 00901 Observation_ID& 00902 text 00903 ( 00904 const std::string& id_text 00905 ) 00906 throw (Invalid_Argument, Out_of_Range); 00907 00908 /*------------------------------------------------------------------------------ 00909 Observation_ID::parse (const std::string&) 00910 */ 00963 std::string 00964 parse 00965 ( 00966 const std::string& id_text 00967 ) 00968 throw (Invalid_Argument, Out_of_Range); 00969 00970 /*============================================================================== 00971 Utility methods 00972 */ 00973 /*------------------------------------------------------------------------------ 00974 Observation_ID::is_preorbit () 00975 */ 00981 bool 00982 is_preorbit () const 00983 { return (mission_phase () > LAST_PREORBIT_PHASE ? false : true); } 00984 00985 /*------------------------------------------------------------------------------ 00986 Observation_ID::print (std::ostream&) 00987 */ 00993 std::ostream& print 00994 ( 00995 std::ostream& stream = std::cout 00996 ) const; 00997 00998 /*============================================================================== 00999 Data 01000 */ 01001 private: 01002 01004 u_int_32 01005 Value; 01006 01007 /*------------------------------------------------------------------------------ 01008 Regular expression elements 01009 */ 01010 protected: 01011 01013 static const char* 01014 DELIMITER_PATTERN; 01015 static const char* 01016 REQUIRED_DELIMITER_PATTERN; 01017 static const char* 01018 OPTIONAL_DELIMITER_PATTERN; 01019 static const char* 01020 PREFIX_PATTERN; 01021 static const char* 01022 SUFFIX_PATTERN; 01023 01024 }; // Observation_ID class 01025 01026 /*============================================================================== 01027 Utility functions 01028 */ 01029 /*------------------------------------------------------------------------------ 01030 UA::HiRISE::sync_to_day_of_year (struct tm*) 01031 */ 01053 void 01054 sync_to_day_of_year 01055 ( 01056 struct tm *time_struct 01057 ); 01058 01059 /*------------------------------------------------------------------------------ 01060 UA::HiRISE::time_text (const int, const std::string&, const int) 01061 */ 01083 std::string 01084 time_text 01085 ( 01086 const int time = 0, 01087 const std::string& format = Observation_ID::STANDARD_TIME_TEXT_FORMAT, 01088 const int epoch = Observation_ID::EPOCH 01089 ); 01090 01091 /*------------------------------------------------------------------------------ 01092 UA::HiRISE::operator<< (std::ostream&, const Observation_ID&) 01093 */ 01101 std::ostream& 01102 operator<< 01103 ( 01104 std::ostream& stream, 01105 const Observation_ID& obs_id 01106 ); 01107 01108 } // HiRISE namespace 01109 01110 } // UA namespace 01111 01112 #endif