/******************************************************************************* * モジュール名称 :Application Rdn Core関数定義 * * モジュールラベル :Core App * * タスク区分 :Core Functions * * 機能 :Core部の共通routine * * 使用上の注意 :特になし * * 作成日・作成者 :2013/1/20 Y.K. * *******************************************************************************/ #include "dpu_api.h" #include "dpu_api_proto.h" #include "app_core.h" #include "app_rdn_core.h" #ifdef _APP_RDN_ // ******************** // *** Rdn Get Data *** // ******************** int app_Rdn_getData( unsigned int ui_getaddress, // ADDRESS int i_dataSize, // Size unsigned char * uc_data ) // Data { int i_flag; /*************************** M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; :衛星時刻(1LSB=1.953ms) // unsigned int ui_currentTime2; :衛星時刻(1LSB=31.25ms) unsigned int ui_load; // msec i_flag = dpu_getTime( &t_timeInfo ); // (no return) ui_load = t_timeInfo.ui_currentTime2; // LSB:32msec **************************/ // *** Read *** i_flag = rap_sv_getRdnData( ui_getaddress, i_dataSize, uc_data ); /************************** i_flag = dpu_getTime( &t_timeInfo ); // (no return) ui_load = t_timeInfo.ui_currentTime2 - ui_load; // LSB:32msec **************************/ // *** Finish *** return( i_flag ); } // ****************** // *** Rdn or Not *** // ****************** // 0: normal // 2: other DPU - RDN int app_Rdn_nodeId( unsigned char uc_nodeId ) { if ( Guc_dpuRdn==2 ) { if ( Guc_dpuNo==0 ) { if ( uc_nodeId == Gd_N_DPU2 ) return( 2 ); if ( uc_nodeId >= Gd_N_MGFI && uc_nodeId <= Gd_N_MWE && uc_nodeId != Gd_N_EWO+1 ) return( 2 ); } else { if ( uc_nodeId == Gd_N_DPU1 ) return( 2 ); if ( uc_nodeId >= Gd_N_MEA1 && uc_nodeId <= Gd_N_MGFO ) return( 2 ); } } return( 0 ); } // *********************** // *** SunPulse in RDN *** // *********************** // --------------------------------------------------------------------------------------------------------- // (1) dpu_waitSunpulse(1)をコールし、次の SUNPULSE 発生まで待機する。 // (2) rap_sv_sendRdnSunpulseTime()をコールし、ミッション機器へ衛星時刻のRMAP Write Command を送信する。 // (3) 冗長側全 8 機器に対し、(2)を繰り返す。 // --------------------------------------------------------------------------------------------------------- /* void app_Rdn_SunPulse() { int i; int i_flag; if (Guc_dpuNo==0) { // *** from DPU1 to DPU2 for (i=Gd_N_MGFI; i<=Gd_N_MWE; i++) if (i!=0x11) i_flag = rap_sv_sendRdnSunpulseTime( i ); i_flag = app_Rdn_EWOclct(); } else { // *** from DPU2 to DPU1 for (i=Gd_N_MEA1; i<=Gd_N_MGFO; i++) i_flag = rap_sv_sendRdnSunpulseTime( i ); } } */ // --------------------------------------------------------------------------------- // ********************************* // *** EWO @ MissoinCLCT ENA/DIS *** // ********************************* // (1) rap_sv_sendRdnEwoMemInfo()をコールし、EWO へミッションデータ書込み許可及びSDRAM 管理情報を通知するRMAP Write Command を送信する。 // (7) rap_sv_sendRdnEwoMemInfo()をコールし、EWO へミッションデータ書込み禁止を通知するRMAP Write Command を送信する。 // --------------------------------------------------------------------------------------------------------- int app_Rdn_EWOclctStart( int i_EWOclct ) { int i_flag; unsigned int ui_startAddr[4]; unsigned int ui_endAddr[4]; ui_startAddr[0] = Gd_EWOE_RdnAdr; ui_endAddr[0] = Gd_EWOE_RdnAdrE; ui_startAddr[1] = Gd_AM2P_RdnAdr; ui_endAddr[1] = Gd_AM2P_RdnAdrE; ui_startAddr[2] = Gd_EFD_RdnAdr ; ui_endAddr[2] = Gd_EFD_RdnAdrE; ui_startAddr[3] = Gd_EWOB_RdnAdr; ui_endAddr[3] = Gd_EWOB_RdnAdrE; i_flag = rap_sv_sendRdnEwoMemInfo( i_EWOclct, Gd_DPU_EWOLogAdr, ui_startAddr, ui_endAddr ); return( i_flag ); } // ************************** // *****Redundancy関数******* // ************************** int app_Rdn_getBlockNo( unsigned char uc_nodeId, // ミッション機器ID(3.2参照) unsigned char uc_dataId, // ミッションデータID(3.2参照) int * ip_blockNo ) // 【出力】バッファに格納されているBlock数 { if (uc_nodeId==Gd_N_EWO && uc_dataId) uc_nodeId = uc_dataId-1; * ip_blockNo = Gt_rdnBLOCK[uc_nodeId].uc_BlockLatest - Gt_rdnBLOCK[uc_nodeId].uc_BlockOldest; if (* ip_blockNo < 0) * ip_blockNo += Gt_rdnBLOCK[uc_nodeId].uc_BlockNumMax; return(0); } int app_Rdn_seekNewestOldestBlock( unsigned char uc_nodeId, // ミッション機器ID(3.2参照) unsigned char uc_dataId, // ミッションデータID(3.2参照) int i_mode, // 0:newest 1:oldest M_T_BLOCK_INFO * tp_blockInfo ) // 【出力】ミッションデータBLOCK 管理情報の構造体 { unsigned int ui_index; if (uc_nodeId==Gd_N_EWO && uc_dataId) uc_nodeId = uc_dataId - 1; if ( i_mode == 0 ) ui_index = tp_blockInfo->ui_blockIndex = Gt_rdnBLOCK[uc_nodeId].uc_BlockLatest; else ui_index = tp_blockInfo->ui_blockIndex = Gt_rdnBLOCK[uc_nodeId].uc_BlockOldest; tp_blockInfo->ui_createTime = Gt_rdnBLOCK[uc_nodeId].ui_createTime[ ui_index ]; tp_blockInfo->i_replyNum = Gt_rdnBLOCK[uc_nodeId].i_replyNum [ ui_index ]; tp_blockInfo->c_invalidFlg = Gt_rdnBLOCK[uc_nodeId].c_invalidFlg [ ui_index ]; if ( tp_blockInfo->ui_createTime == 0 ) return (1); return(0); } int app_Rdn_shiftBlock( unsigned char uc_nodeId, // ミッション機器ID(3.2参照) unsigned char uc_dataId, // ミッションデータID(3.2参照) int i_shiftCnt, // 移動するBLOCK の個数 M_T_BLOCK_INFO * tp_blockInfo ) // 【出力】ミッションデータBLOCK 管理情報の構造体 { if (uc_nodeId==Gd_N_EWO && uc_dataId) uc_nodeId = uc_dataId - 1; if (i_shiftCnt>1 || i_shiftCnt<-1 || i_shiftCnt==0) return(-1); if (i_shiftCnt==1) { if ( tp_blockInfo->ui_blockIndex == Gt_rdnBLOCK[uc_nodeId].uc_BlockLatest ) return( -1 ); // **** No-data (latest) if ( tp_blockInfo->ui_blockIndex == Gt_rdnBLOCK[uc_nodeId].uc_BlockNumMax-1) tp_blockInfo->ui_blockIndex = 0; else tp_blockInfo->ui_blockIndex ++; } else { if ( tp_blockInfo->ui_blockIndex == Gt_rdnBLOCK[uc_nodeId].uc_BlockOldest ) return( -1 ); // **** No-data (oldest) if ( tp_blockInfo->ui_blockIndex == 0) tp_blockInfo->ui_blockIndex = Gt_rdnBLOCK[uc_nodeId].uc_BlockNumMax-1; else tp_blockInfo->ui_blockIndex --; } tp_blockInfo->ui_createTime = Gt_rdnBLOCK[uc_nodeId].ui_createTime[ tp_blockInfo->ui_blockIndex ]; tp_blockInfo->i_replyNum = Gt_rdnBLOCK[uc_nodeId].i_replyNum [ tp_blockInfo->ui_blockIndex ]; tp_blockInfo->c_invalidFlg = Gt_rdnBLOCK[uc_nodeId].c_invalidFlg [ tp_blockInfo->ui_blockIndex ]; if ( tp_blockInfo->ui_createTime == 0 ) return (1); return(0); } /************************************************************************ *************************************************************************/ int app_Rdn_getBlock( unsigned char uc_nodeId, // ミッション機器ID(3.2参照) unsigned char uc_dataId, // ミッションデータID(3.2参照) M_T_BLOCK_INFO * tp_blockInfo, // ミッションデータBLOCK 管理情報の構造体 unsigned char uc_data[] ) // 【出力】BLOCK 格納領域 { int i_flag; unsigned int ui_getaddress; // *** Head ID *** unsigned char uc_headId; if (uc_nodeId==Gd_N_EWO && uc_dataId) uc_headId = uc_dataId-1; else uc_headId = uc_nodeId; // *** Address *** i_flag = rap_mm_calcBlockAddr ( uc_nodeId, uc_dataId, Gt_rdnBLOCK[uc_headId].ui_AddStart, tp_blockInfo->ui_blockIndex, & ui_getaddress); if ( i_flag ) return( i_flag ); // *** Block Size *** M_T_MIS_DATA_PLAN t_MisDataPlan; // unsigned char uc_cpuInt : CPU-INT(定期コマンド発行間隔) [sec] // unsigned char uc_number : 送信RMAP Command 数 [個] // unsigned char uc_interval : RMAP Command 送信間隔 [msec] // unsigned int ui_readSize : ミッションデータサイズ [バイト] // unsigned int ui_replySize : RMAP Read Reply パケットサイズ [バイト] // unsigned int ui_blockSize : ブロックサイズ [バイト] i_flag = rap_mm_getMisDataPlan( uc_nodeId, uc_dataId, &t_MisDataPlan); if ( i_flag ) return( i_flag ); i_flag = app_Rdn_getData ( ui_getaddress, t_MisDataPlan.ui_blockSize, uc_data ); // **** <1MB *** return( i_flag ); } int app_Rdn_getReply( unsigned char uc_nodeId, // ミッション機器ID(3.2参照) unsigned char uc_dataId, // ミッションデータID(3.2参照) M_T_BLOCK_INFO * tp_blockInfo, // ミッションデータBLOCK 管理情報の構造体 int i_packetNo, // 取得するReply 番号 int i_offset, // Reply の先頭からのバイト数 int i_dataSize, // 取得するバイト数(8 の倍数であること) unsigned char uc_data[] ) // 【出力】Read-Reply 格納領域 { // tp_blockInfo->ui_blockIndex Block を特定する番号 int i_flag; unsigned int ui_getaddress; // *** Head ID *** unsigned char uc_headId; if (uc_nodeId==Gd_N_EWO && uc_dataId) uc_headId = uc_dataId-1; else uc_headId = uc_nodeId; // *** Address *** i_flag = rap_mm_calcReplyAddr ( uc_nodeId, uc_dataId, Gt_rdnBLOCK[uc_headId].ui_AddStart, tp_blockInfo->ui_blockIndex, i_packetNo, & ui_getaddress); if ( i_flag ) return( i_flag ); // *** Read *** i_flag = app_Rdn_getData ( ui_getaddress + i_offset, i_dataSize, uc_data ); // **** <1MB *** return( i_flag ); } // *********************** // *** MEM-DUMP in RDN *** // *********************** int app_Rdn_memDump( int i_dpuNo, unsigned char uc_data[Gd_dataPacLen] ) { int i_flag; unsigned char uc_cmp; unsigned int ui_dumpAdr; unsigned char uc_nodeId = Guc_RDN_MemDump_NID & 0x1F; if ( Guc_HK_link[uc_nodeId] == 0 ) { Guc_RDN_MemDump_NID = 0x1D; return(0x1D); } // **** HK-31 usage **** // b7 (0x80) BUSY // -------------------- // b5 (0x20) reading // b0-4 NID // ********************* // --- DUMP --- ui_dumpAdr = Gt_rdnBLOCK[ uc_nodeId ].ui_AddStart - 0x8000; if ( (Guc_RDN_MemDump_NID & 0x60) == 0 ) { // b6-5 0x00 pre if ( Gt_rdnBLOCK[ uc_nodeId ].ui_AddStart ) { i_flag = rap_sv_sendRdnMemDump( uc_nodeId, Gui_RDN_MemDump_Address, 512, ui_dumpAdr ); } else { i_flag = 1; } if ( i_flag==0 ) { Guc_RDN_MemDump_NID |= 0x20; return(0); // MEM-DUMP CMD sent } else { // --- FINISH --- Guc_RDN_MemDump_NID = 0x1E; return(0x1E); } } // --- TLM --- i_flag = app_Rdn_getData ( ui_dumpAdr, 528, uc_data ); if (i_flag==0) { uc_data[0] = 0xFF; uc_data[1] = uc_nodeId; memcpy( &(uc_data[2]), &(Gui_RDN_MemDump_Address), 4); memcpy( &(uc_data[6]), &(uc_data[12]), 512); // DUMP uc_cmp = Guc_TLMm_cmp[Gd_N_DPU1 + i_dpuNo]; i_flag = app_PutTlm( 3 + i_dpuNo*10, // [INPUT] APP-NUM = 2 Gd_N_DPU1 + i_dpuNo, // [INPUT] Node-ID 0, // [INPUT] Data-ID Gd_N_DPU1 + i_dpuNo, // [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)] uc_cmp, // [INPUT] Comp mode [0:non 1:JPEG-rev 2:Math 3-7:After-User-COMP] uc_nodeId + 0x80, // [INPUT] Packet ID <<<< USER-DEF: 0x00- 0xFF >>>> Gui_RDN_MemDump_Address, // [INPUT] Data TI <<<< USER-DEF: 0x00000000-0xFFFFFFFF >>>> Guc_cmdDummy, // [INPUT] Comment <<<< USER-DEF: <128B >>>> 0, // [INPUT] Comment - Size <<<< USER-DEF: <128B >>>> uc_data, // [INPUT] Data <<<< USER-DEF: <0x1E00 >>>> 518); // [INPUT] Data - Size <<<< USER-DEF: <0x1E00 >>>> Guc_RDN_MemDump_NID &= 0x1F; if ( Guc_RDN_MemDump_Times ){ // Gui_RDN_MemDump_Address += 512; // ADDRESSは固定。同じものを何度かDUMP Guc_RDN_MemDump_NID += 0x80; Guc_RDN_MemDump_Times --; } } return( i_flag ); } #endif // _APP_RDN_