/******************************************************************************* * ƒ‚ƒWƒ…[ƒ‹–ผฬ FƒAƒvƒŠƒP[ƒVƒ‡ƒ“02 - HK read & anaylses * * ƒR[ƒŠƒ“ƒOƒV[ƒPƒ“ƒXFvoid dpu_app02(int mode) * * ˆ๘” Fint mode ็’ท‹@”\ON * * ์ฌ“๚E์ฌŽา F2013/7/23 Y.K. * ********************************************************************************/ #include "dpu_api.h" #include "dpu_api_proto.h" #include "app_core.h" #include "app_rdn_core.h" // *** Prototype - Local *** unsigned char app02_Hk_Dump ( unsigned char, unsigned int, int ); int app02_Hk_Analysis( unsigned char, unsigned int ); void app02_HK_putTLM ( unsigned char, unsigned int, int, unsigned char [], int); // *** Prototype - app02_Rdn_Hk.c *** void app02_Rdn_MwHk(); int app02_Rdn_memDump(); // *** Macro - app02_Cmd/Hk/Data.c *** void app02_Rdn_Cmd(); void app02_Rdn_PiHk(); #ifdef _APP_DMY_ int app02_HK_Dummy ( int, unsigned int ); #endif // _APP_DMY_ // *** APP02 Common Grobal Variable (in app.h / app_variable.c) *** //unsigned char G2uc_data[1268]; // 1268 B (less than 404B in future) unsigned int app_MONITOR2(unsigned char, unsigned int, unsigned int * ); void dpu_app02(int mode) { int i_flag; unsigned int ui_load; // msec // M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; F‰qฏŽž(1LSB=1.953ms) // unsigned int ui_currentTime2; F‰qฏŽž(1LSB=31.25ms) int i_slot; // Slot No.: 0-7 int i; unsigned int ui_load2 = 0; // ************ // *** MAIN *** // ************ dpu_waitProcessingSlot(32); for (;;) { // ******************* // *** Wait Slot-7 *** // ******************* app_WhoWhere( 1, Gd_N_COM, 0x01 ); i_slot = dpu_waitProcessingSlot(0); i_slot = 6 - i_slot; if (i_slot < 1) i_slot += 8; i_slot = dpu_waitProcessingSlot(i_slot); // ************* // *** START *** // ************* app_WhoWhere( 1, Gd_N_COM, 0x02 ); app_START( 1, &ui_load ); // *** CMD-buffer clear (for BroadCast) *** app_WhoWhere( 1, Gd_N_COM, 0x03 ); dpu_getCommand( Guc_cmdDummy, &i_flag); // ***************************** // *** RDN *** // ***************************** #ifdef _APP_RDN_ if (Guc_dpuRdn == 2) { // -------------------------- // --- CMD in Redundancy ---- // -------------------------- // SunPulse & CMD send app_WhoWhere( 1, Gd_N_COM, 0xF5 ); app02_Rdn_Cmd(); // ***RDN*** // -------------------------- // --- HK in Redundancy ----- // -------------------------- app_WhoWhere( 1, Gd_N_COM, 0xF6 ); app02_Rdn_PiHk(); // ***RDN*** } if (Guc_dpuRdn) app02_Rdn_MwHk(); #endif // _APP_RDN_ i_flag = app_MONITOR2( 0, ui_load2, & ui_load2 ); // **TMP** // *** HK: DPU *** if (Guc_dpuNo==0) { app_WhoWhere( 1, Gd_N_DPU1, 0x00 ); i_flag = app02_Hk_Dump( Gd_N_DPU1, Gui_hkApp_counter[1], 0 ); Guc_HK_OneShot[Gd_N_DPU1] = 0; i_flag = app_MONITOR2( Gd_N_DPU1, ui_load2, & ui_load2 ); // **TMP** #ifdef _APP_RDN_ if (Guc_dpuRdn == 2) { i_flag = app02_Hk_Dump( Gd_N_DPU2, Gui_hkApp_counter[1], 1 ); Guc_HK_OneShot[Gd_N_DPU2] = 0; } i_flag = app_MONITOR2( Gd_N_DPU2, ui_load2, & ui_load2 ); // **TMP** #endif // _APP_RDN_ } else { app_WhoWhere( 1, Gd_N_DPU2, 0x00 ); i_flag = app02_Hk_Dump( Gd_N_DPU2, Gui_hkApp_counter[1], 1 ); Guc_HK_OneShot[Gd_N_DPU2] = 0; i_flag = app_MONITOR2( Gd_N_DPU2, ui_load2, & ui_load2 ); // **TMP** #ifdef _APP_RDN_ if (Guc_dpuRdn == 2) { i_flag = app02_Hk_Dump( Gd_N_DPU1, Gui_hkApp_counter[1], 0 ); Guc_HK_OneShot[Gd_N_DPU1] = 0; } i_flag = app_MONITOR2( Gd_N_DPU1, ui_load2, & ui_load2 ); // **TMP** #endif // _APP_RDN_ } // *** HK: DPU1 *** if (Guc_dpuNo==0 || Guc_dpuRdn==2) { for (i=Gd_N_MEA1; i<=Gd_N_MGFO; i++) { app_WhoWhere( 1, i, 0x00 ); i_flag = app02_Hk_Dump( i, Gui_hkApp_counter[1], i ); Guc_HK_OneShot[i] = 0; i_flag = app_MONITOR2( i, ui_load2, & ui_load2 ); // **TMP** } } // *** HK: DPU2 *** if (Guc_dpuNo==1 || Guc_dpuRdn==2) { for (i=Gd_N_MGFI; i<=Gd_N_MWE; i++) { if (i==Gd_N_EWO+1) continue; app_WhoWhere( 1, i, 0x00 ); i_flag = app02_Hk_Dump( i, Gui_hkApp_counter[1], i ); Guc_HK_OneShot[i] = 0; i_flag = app_MONITOR2( i, ui_load2, & ui_load2 ); // **TMP** } } #ifdef _APP_DMY_ // *** HK: DUMMY: 32packet * 60sec *** if ( Guc_Spec_Code & 0x01 ) { app02_HK_Dummy(0, Gui_hkApp_counter[1]); } if ( Guc_Spec_Code & 0x02 ) { app02_HK_Dummy(1, Gui_hkApp_counter[1]); } #endif // _APP_DMY_ // ****************** // *** APP STATUS *** // ****************** app_WhoWhere( 1, Gd_N_COM, 0x0F ); app_END( 1, &ui_load ); } // ************ // *** EXIT *** // ************ dpu_WDTEna(0); // WDT: DIS dpu_appStop(); // *** End *** } // *************************************** // *** HK analyses / Packet production *** // *************************************** // ------------------------ // --- HK Dump --- // ------------------------ unsigned char app02_Hk_Dump( unsigned char uc_nodeId, unsigned int ui_counter, int i_dumpShift ) { unsigned char uc_hkSent = 0xFF; int i_flag = 0; int i_sizeData; unsigned int ui_counter0; // *** Time *** unsigned int ui_time; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; F‰qฏŽž(1LSB=1.953ms) i_flag = dpu_getTime( &t_timeInfo ); ui_time = t_timeInfo.ui_currentTime; // LSB:1.953msec // ************************* // *** H/W-HK READ *** // ************************* i_flag = app_HkRead( uc_nodeId, G2uc_data ); if (i_flag) return(1); // *** ERR-1: Node-ID Error // ************************* // *** Merge with S/W-HK *** // ************************* i_sizeData = app02_Hk_Analysis( uc_nodeId, ui_counter ); // Packet size: 'H/W HK' + 'S/W HK' if (i_sizeData <= 0) return(2); // *** ERR-2: HK packet sizing error // ******************* // *** One Shot HK *** // ******************* if (Guc_HK_OneShot[uc_nodeId]) { app02_HK_putTLM ( uc_nodeId, // [INPUT] Node ID ui_time, // [INPUT] TI (LSB:1.953msec) 1, // [INPUT] OneShot HK data G2uc_data, // [INPUT] Packet data i_sizeData); // [INPUT] Packet size (2B x 2set) Guc_HK_OneShot[uc_nodeId] = 0; uc_hkSent = 0; } // **************** // *** Usual HK *** // **************** if ( Guc_HK_repEna || uc_nodeId==Gd_N_DPU1 || uc_nodeId==Gd_N_DPU2 ) { if ( Guc_HK_repInt[uc_nodeId] < 0x10 ) { ui_counter += i_dumpShift * 5; ui_counter0 = ((ui_counter >> Guc_HK_repInt[uc_nodeId]) << Guc_HK_repInt[uc_nodeId]); if ( ui_counter - ui_counter0 == 0 ) { app02_HK_putTLM ( uc_nodeId, // [INPUT] Node ID ui_time, // [INPUT] TI (LSB:32msec) 0, // [INPUT] OneShot HK data G2uc_data, // [INPUT] Packet data (copied in app03_EFD_readPacket) i_sizeData); // [INPUT] Packet size (2B x 2set) uc_hkSent = 0; } } } return(uc_hkSent); } // ------------------------ // --- HK Analysis --- // ------------------------ int app02_Hk_Analysis( unsigned char uc_nodeId, unsigned int ui_counter ) { int i_size = 0; if (uc_nodeId == Gd_N_DPU1) i_size = app02_DPU ( G2uc_data, ui_counter, 0 ); else if (uc_nodeId == Gd_N_MEA1) i_size = app02_MEA1 ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_MEA2) i_size = app02_MEA2 ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_MIA ) i_size = app02_MIA ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_MSA ) i_size = app02_MSA ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_HEPE) i_size = app02_HEPE ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_HEPI) i_size = app02_HEPI ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_ENA ) i_size = app02_ENA ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_MGFO) i_size = app02_MGFO ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); // if (uc_nodeId == Gd_N_DPU2) i_size = app02_DPU ( G2uc_data, ui_counter, 1 ); else if (uc_nodeId == Gd_N_MGFI) i_size = app02_MGFI ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_MSAS) i_size = app02_MSAS ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_EWO ) i_size = app02_EWO ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_SOR ) i_size = app02_SOR ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_MEF ) i_size = app02_MEF ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); else if (uc_nodeId == Gd_N_MWE ) i_size = app02_MWE ( G2uc_data, ui_counter, Guc_HK_link[uc_nodeId] ); return(i_size); } // *************** // *** HK-Dump *** // *************** // =========================================================================== // app02_HK_putTLM // [INPUT] unsigned char uc_nodeId Node ID // unsigned int ui_dataTi Header: TI // int i_drId, DR-ID = L or H0 (for CAT-ID) [0:HK 1:OS 2:L 3:M 4-9:H(0-5)] // unsigned char uc_data[] Data // int i_dataSize Data Size // =========================================================================== void app02_HK_putTLM( unsigned char uc_nodeId, // [INPUT] Node ID unsigned int ui_dataTi, // [INPUT] TI int i_drId, // [INPUT] DR-ID L/M/H0 (for CAT-ID) [0:HK 1:OS 2:L 3:M 4-9:H(0-5)] unsigned char uc_data[], // [INPUT] Data int i_dataSize) // [INPUT] Data Size (Byte) { int i_flag; unsigned char uc_cmp; uc_cmp = Guc_TLMhk_cmp[uc_nodeId]*2; // ----------------------------- // --- Non-Compressed Packet --- // ----------------------------- i_flag = app_PutTlm( 2, // [INPUT] APP-NUM = 2 uc_nodeId, // [INPUT] Node-ID 0, // [INPUT] Data-ID uc_nodeId, // [INPUT] Header-ID (for PID-ID, CAT-ID setting) i_drId, // [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] i_drId, // [INPUT] Packet ID <<<< USER-DEF: 0x00- 0xFF >>>> ui_dataTi, // [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 >>>> i_dataSize); // [INPUT] Data - Size <<<< USER-DEF: <0x1E00 >>>> return; } #ifdef _APP_DMY_ // **************** // *** DUMMY-HK *** // **************** int app02_HK_Dummy( int i_drId, unsigned int ui_cnt ) { int i; int i_flag; // **** TI **** unsigned int ui_time; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; F‰qฏŽž(1LSB=1.953ms) i_flag = dpu_getTime( &t_timeInfo ); ui_time = t_timeInfo.ui_currentTime; // **** Data load (dummy) **** for (i=0; i<100; i++) G2uc_data[i] = ( (i>>4) & 0xFF ); // **** Data Put (DPU1 -> EWO) **** for (i=Gd_N_DPU1; i<=Gd_N_MWE; i++) { if (iGd_N_MGFO) continue; } else { if (i==Gd_N_DPU1) continue; if (i> Gd_N_DPU2 && i>>> ui_time, // [INPUT] Data TI <<<< USER-DEF: 0x00000000-0xFFFFFFFF >>>> (2msec) Guc_cmdDummy, // [INPUT] Comment <<<< USER-DEF: <128B >>>> 0, // [INPUT] Comment - Size <<<< USER-DEF: <128B >>>> G2uc_data, // [INPUT] Data <<<< USER-DEF: <0x1E00 >>>> 100 ); // [INPUT] Data - Size <<<< USER-DEF: <0x1E00 >>>> } return(0); } #endif // _APP_DMY_ // // ---------APP operation ****TMP**** -------- // unsigned int app_MONITOR2(unsigned char uc_nodeId, // NodeID unsigned int ui_time0, // Last TI unsigned int * ui_time ) // Current TI { M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; F‰qฏŽž(1LSB=1.953ms) // unsigned int ui_currentTime2; F‰qฏŽž(1LSB=31.25ms) int i_flag; i_flag = dpu_getTime( &t_timeInfo ); *ui_time = t_timeInfo.ui_currentTime2; i_flag = *ui_time - ui_time0; if (i_flag > 0xFF) Guc_hkApp_loadNID2[uc_nodeId] = 0xFF; else Guc_hkApp_loadNID2[uc_nodeId] = i_flag; if ( Guc_hkApp_loadNID2[uc_nodeId] > Guc_hkApp_loadNIDmax2[uc_nodeId] ) Guc_hkApp_loadNIDmax2[uc_nodeId] = Guc_hkApp_loadNID2[uc_nodeId]; return ( i_flag ); // LSB:32msec }