/******************************************************************************* * モジュール名称 :アプリケーション03 - Mission TLM Production (1) * * モジュールラベル :dpu_app03 * * タスク区分 :アプリケーションタスク * * 機能 : * * コーリングシーケンス:void dpu_app03(int mode) * * 引数 :int mode 冗長機能ON/OFF (0:OFF/1:ON) * * 戻り値 :void * * 使用上の注意 :なし * * エラー処理 :なし * * 作成日・作成者 :2013/9/16 Y.K. * *******************************************************************************/ #include "dpu_api.h" #include "dpu_api_proto.h" #include "app_core.h" #include "app_rdn_core.h" #include "app_common.h" // **** MACRO: local **** extern int M_Gi_imitateSunpulseCnt; // for DEBUG: --- MW内 SunPulse Timer --- // #ifdef _APP_DMY_ int app03_LM_Dummy ( int ); // ***TMP!!*** #endif // _APP_DMY_ void dpu_app03(int mode) { int i_flag; unsigned int ui_load; // msec unsigned int ui_load2; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; :衛星時刻(1LSB=1.953ms) // unsigned int ui_currentTime2; :衛星時刻(1LSB=31.25ms) // unsigned int ui_sunpulseTime; :SUNPULSE 受信時刻(1LSB=1.953ms) // ************************************* // *** STOP @ DPU2 in non-redundancy *** // ************************************* if (Guc_dpuNo==1 && Guc_dpuRdn==0) { // DPU2 in non-Redundancy dpu_WDTEna(0); // WDT: DIS dpu_appStop(); // *** End *** } // ************ // *** MAIN *** // ************ dpu_waitProcessingSlot(32); for (;;) { // *** WAIT *** app_WhoWhere( 2, Gd_N_COM, 0x01 ); dpu_waitSunpulse(1); if ( Guc_dpuSunMode == 1 && Guc_dpuNo==0 ) M_Gi_imitateSunpulseCnt = 33; // N=1(=125ms) N=36(=4500ms)*/ // ************* // *** START *** // ************* app_WhoWhere( 2, Gd_N_COM, 0x02 ); app_START( 2, &ui_load ); // *** CMD-buffer clear (for BroadCast) *** app_WhoWhere( 2, Gd_N_COM, 0x03 ); dpu_getCommand( Guc_cmdDummy, &i_flag); // *** SPIN-EXE: Counter increment & Sync between DPU1&DPU2 *** app_WhoWhere( 2, Gd_N_COM, 0x04 ); while (1) { i_flag = dpu_getTime( &t_timeInfo ); if ( t_timeInfo.ui_sunpulseTime <= t_timeInfo.ui_currentTime ) break; dpu_delay(10); } if ( Gui_TRG_TiLAST==0 ) Gui_TRG_TiLAST = t_timeInfo.ui_currentTime2 + 0x80; app03_DPU1_SPIN( Gui_hkApp_counter[2], t_timeInfo.ui_sunpulseTime, t_timeInfo.ui_currentTime2 ); i_flag = app_MONITOR( 0, 0, ui_load2, & ui_load2 ); if ( Guc_TLMm_enadis ) { // ***************** // *** TLM: DPU1 *** // ***************** if (Guc_dpuNo==0 || Guc_dpuRdn==2) { // *** RDN: OK app_WhoWhere( 2, Gd_N_MGFO, 0x00 ); app03_MGFO ( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_MGFO, ui_load2, & ui_load2 ); app_WhoWhere( 2, Gd_N_MIA, 0x00 ); app03_MIA ( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_MIA, ui_load2, & ui_load2 ); app_WhoWhere( 2, Gd_N_MSA, 0x00 ); app03_MSA ( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_MSA, ui_load2, & ui_load2 ); app_WhoWhere( 2, Gd_N_MEA1, 0x00 ); app03_MEA1 ( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_MEA1, ui_load2, & ui_load2 ); app_WhoWhere( 2, Gd_N_MEA2, 0x00 ); app03_MEA2 ( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_MEA2, ui_load2, & ui_load2 ); app_WhoWhere( 2, Gd_N_HEPE, 0x00 ); app03_HEPE ( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_HEPE, ui_load2, & ui_load2 ); app_WhoWhere( 2, Gd_N_HEPI, 0x00 ); app03_HEPI ( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_HEPI, ui_load2, & ui_load2 ); } } if (Guc_dpuNo==0 || Guc_dpuRdn==2) { // *** RDN: OK // *********************** // *** TLM: Integrated *** // *********************** app_WhoWhere( 2, Gd_N_DPU1, 0x00 ); app03_DPU1( Gui_hkApp_counter[2] ); i_flag = app_MONITOR( 0, Gd_N_DPU1, ui_load2, & ui_load2 ); } #ifdef _APP_RDN_ if (Guc_dpuNo==1 && Guc_dpuRdn==2) { // *** RDN: OK // *** MEM-DUMP *** if ( (Guc_RDN_MemDump_NID & 0x80) ) { i_flag = app_Rdn_memDump( 0, G03uc_packet ); // MEM-DUMP } } #endif // _APP_RDN_ #ifdef _APP_DMY_ // --- DUMMY:LM --- if ( Guc_Spec_Code & 0x04 ) { app03_LM_Dummy(0); app03_LM_Dummy(1); } #endif // _APP_DMY_ // *** APP STATUS *** app_WhoWhere( 2, Gd_N_COM, 0x0F ); app_END ( 2, &ui_load ); } dpu_WDTEna(0); // WDT: DIS dpu_appStop(); // *** End *** } #ifdef _APP_DMY_ // ***************** // *** DUMMY-LM *** // ***************** int app03_LM_Dummy( int i_mode ) { int i, j; int i_flag; unsigned char uc_nodeID, uc_dataID, uc_headID; // **** TI **** unsigned int ui_time; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; :衛星時刻(1LSB=1.953ms) i_flag = dpu_getTime( &t_timeInfo ); ui_time = t_timeInfo.ui_currentTime; // **** Data load (dummy) **** for (i=0; i<1000; i++) G03uc_data[i] = ( (i>>4) & 0xFF ); // **** Data Put (DPU1 -> EWO) **** for (i=Gd_N_DPU1; i<=Gd_N_MGFO; i++) { if (i==Gd_N_DPU2) continue; if (i==Gd_N_ENA && i_mode==1) continue; uc_nodeID = i; uc_dataID = 0; uc_headID = i; // for (j=0; j<4; j++) { app_WhoWhere( 2, Gd_N_COM, i_mode + 0xEE ); i_flag = app_PutTlm( 5, // [INPUT] APP-NUM = 5 uc_nodeID, // [INPUT] Node-ID uc_dataID, // [INPUT] Data-ID uc_headID, // [INPUT] Header-ID (for PID-ID, CAT-ID setting) 2+i_mode, // [INPUT] DR-ID (for CAT-ID) [0:HK 1:OS 2:L 3:M 4-9:H(0-5)] (j%4), // [INPUT] Comp mode [0:non 1:Arith0 2:Arith1 3:After-User-COMP 4:RICE] j & 0xFF, // [INPUT] Packet ID <<<< USER-DEF: 0x00- 0xFF >>>> ui_time, // [INPUT] Data TI <<<< USER-DEF: 0x00000000-0xFFFFFFFF >>>> (2msec) Guc_cmdDummy, // [INPUT] Comment <<<< USER-DEF: <128B >>>> 0, // [INPUT] Comment - Size <<<< USER-DEF: <128B >>>> G03uc_data, // [INPUT] Data <<<< USER-DEF: <0x1E00 >>>> 100+900*i_mode ); // [INPUT] Data - Size <<<< USER-DEF: <0x1E00 >>>> } } return(0); } #endif // _APP_DMY_ /* // =============== TMP ============== // =============== TMP ============== // =============== TMP ============== // =============== TMP ============== unsigned int Gui_TI_tmp; void app03_MGFOtest( unsigned int ui_sunpulseCnt ) { int i; int i_flag; // === BLOCK read === int i_bufId; // Buffer ID int i_numNewBlock; // Num of blocks with new data unsigned int ui_timeData; // Processing data TI unsigned int ui_timeData2; // Processing data TI unsigned int ui_timeData3; // Processing data TI M_T_BLOCK_INFO t_blockInfo; // unsigned int ui_createTime Block 生成開始時衛星時刻(1LSB=31,25ms) // int i_replyNum Block 登録Read-Reply個数 // char c_invalidFlg Block 内データ異常 [0:異常なし 1:異常あり] // unsigned int ui_blockIndex LongBuffer/ShortBuffer 内Block特定番号 (先頭Block:0) // ----------------------------------------------------------- // -- Set at the buffer with the oldest non-processed block -- // ----------------------------------------------------------- i_bufId = app_CheckNonProcBlock ( Gd_N_MGFO, 0, // [INPUT] NodeID = Gd_N_MDM, Data ID = 0 Gui_TLMm_blockTime[Gd_N_MGFO], // [INPUT] TI of Processed Block & ui_timeData); // [OUTPUT] TI of Newest Block in the selected buffer // (return) Buffer-ID (0:L, 1:S, -1:no data) if ( i_bufId < 0 ) return; // === No data === // ------------------------------------------- // -- Set at the oldest non-processed block -- // ------------------------------------------- // Newest Block i_numNewBlock = app_SetNonProcBlock( Gd_N_MGFO, 0, // [INPUT] NodeID = Gd_N_MDM, Data ID = 0 i_bufId, // [INPUT] Buffer ID (0:L, 1:S) Gui_TLMm_blockTime[Gd_N_MGFO], // [INPUT] TI of Processed Block &t_blockInfo); // [OUTPUT] Block Info // (return) >0:Num of blocks, <=0:No data (error) if ( i_numNewBlock < 1 ) { Gui_TLMm_blockTime[Gd_N_MGFO] = ui_timeData; // === shift to newest data for SKIP === return; } // --------------------- // -- Read Block data -- // --------------------- for (i=0; i Gui_TLMm_blockTime[Gd_N_MGFO] && // NEW data t_blockInfo.i_replyNum > 0 && // Data available t_blockInfo.c_invalidFlg == 0 // Data correct ) { // **************************** // **** Packet header read **** // **************************** // RMAP-read-header 12B // Contents ?B i_flag = app_GetBlock( 3, // [INPUT] App-No:3 Gd_N_MGFO, 0, // [INPUT] NodeID = Gd_N_MDM, Data ID = 0 i_bufId, // [INPUT] Buffer ID &t_blockInfo, // [INPUT] Block Info G03uc_data ); // [OUTPUT] 1 Block Data - copied if ( i_flag ) continue; Gui_TLMm_blockTime[Gd_N_MGFO] = t_blockInfo.ui_createTime; // !!! Successfuly Processed !!! ui_timeData = Gui_TLMm_blockTime[Gd_N_MGFO]; ui_timeData2 = G03uc_data[12 ]*0x1000000 + G03uc_data[13 ]*0x10000 + G03uc_data[14 ]*0x100 + G03uc_data[15 ] + ( G03uc_data[16 ]*0x100 + G03uc_data[17 ] ) * 512 / 10000; ui_timeData3 = G03uc_data[12+224*8]*0x1000000 + G03uc_data[13+224*8]*0x10000 + G03uc_data[14+224*8]*0x100 + G03uc_data[15+224*8] + ( G03uc_data[16+224*8]*0x100 + G03uc_data[17+224*8] ) * 512 / 10000; i_flag = ui_timeData2 - Gui_TI_tmp; G03uc_data[0] = (unsigned char)((i_flag >> 16) & 0xFF); G03uc_data[1] = (unsigned char)((i_flag >> 8) & 0xFF); G03uc_data[2] = (unsigned char)((i_flag ) & 0xFF); if ( i_flag < 0 ) ui_timeData = (ui_timeData & 0x00FFFFFF) + 0xFF000000; if ( i_flag > 512) ui_timeData = (ui_timeData & 0x00FFFFFF) + 0xEE000000; i_flag = ui_timeData3 - ui_timeData2; G03uc_data[3] = (unsigned char)((i_flag >> 16) & 0xFF); G03uc_data[4] = (unsigned char)((i_flag >> 8) & 0xFF); G03uc_data[5] = (unsigned char)((i_flag ) & 0xFF); if ( i_flag < 0) ui_timeData = (ui_timeData & 0xFF00FFFF) + 0x00FF0000; if ( i_flag > 512) ui_timeData = (ui_timeData & 0xFF00FFFF) + 0x00EE0000; memcpy( &(G03uc_data[6]), &(G03uc_data[12+224*0]), 6); // TI memcpy( &(G03uc_data[12]), &(G03uc_data[12+224*1]), 6); // TI memcpy( &(G03uc_data[18]), &(G03uc_data[12+224*2]), 6); // TI memcpy( &(G03uc_data[24]), &(G03uc_data[12+224*3]), 6); // TI memcpy( &(G03uc_data[30]), &(G03uc_data[12+224*4]), 6); // TI memcpy( &(G03uc_data[36]), &(G03uc_data[12+224*5]), 6); // TI memcpy( &(G03uc_data[42]), &(G03uc_data[12+224*6]), 6); // TI memcpy( &(G03uc_data[48]), &(G03uc_data[12+224*7]), 6); // TI memcpy( &(G03uc_data[54]), &(G03uc_data[12+224*8]), 6); // TI Gui_TI_tmp = ui_timeData3; // ***************** // **** Put TLM **** // ***************** i_flag = app_PutTlm(3, // [INPUT] APP-NUM = 13 Gd_N_MGFO, // [INPUT] Node-ID 0, // [INPUT] Data-ID Gd_N_MGFO, // [INPUT] Header-ID (for PID-ID, CAT-ID setting) 2, // [INPUT] DR-ID (for CAT-ID) [0:HK 1:OS 2:L 3:M 4-9:H(0-5)] Guc_TLMm_cmp[Gd_N_MGFO], // [INPUT] Comp mode [0:non 1:JPEG-rev 2:Math 3-7:After-User-COMP] i + (i_numNewBlock << 4), // [INPUT] Packet ID <<<< USER-DEF: 0x00- 0xFF >>>> ui_timeData, // [INPUT] Data TI <<<< USER-DEF: 0x00000000-0xFFFFFFFF >>>> Guc_cmdDummy, // [INPUT] Comment <<<< USER-DEF: <128B >>>> 0, // [INPUT] Comment - Size <<<< USER-DEF: <128B >>>> G03uc_data , // [INPUT] Data <<<< USER-DEF: <0x1E00 >>>> 60); // [INPUT] Data - Size <<<< USER-DEF: <0x1E00 >>>> } // To next block i_flag = app_NextBlock( Gd_N_MGFO, 0, // [INPUT] NodeID = Gd_N_MDM, Data ID = 0 i_bufId, // [INPUT] Buffer ID &t_blockInfo); // [OUTPUT] Block Info if ( i_flag ) break; // no data } return; } */