/******************************************************************************* * モジュール名称 :APP01 - CMD from DMC to DPU * * 作成日・作成者 :2016/2/26 Y.K. * ********************************************************************************/ #include "dpu_api.h" #include "dpu_api_proto.h" #include "app_core.h" #include "app_rdn_core.h" // *** Prototype - Local *** unsigned char app01_DPU ( unsigned int, unsigned char * , int); // unsigned char app01_InitVar ( void ); unsigned char app01_ErrClr ( void ); // unsigned char app01_JpegSet ( void ); // unsigned char app01_BufCollectSet ( unsigned char, unsigned char ); unsigned char app01_BufOvwSet ( unsigned char, unsigned char ); unsigned char app01_BufChange ( unsigned char, unsigned char ); // unsigned char app01_HkSet ( unsigned char, unsigned char ); unsigned char app01_Hk_OneShot ( unsigned char ); // unsigned char app01_Tlm_CmpSet ( unsigned char, unsigned char, unsigned char ); unsigned char app01_TlmH_Dump ( unsigned char, unsigned char, unsigned char, unsigned short, unsigned short ); // ******************************** // *** CMD analyses / execution *** // ******************************** unsigned char app01_DPU ( unsigned int ui_Cntl, unsigned char uc_Data[], int i_Size ) { unsigned char uc_flag = 0xFF; unsigned short us_TIbefore, us_TIlen; int i; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; :衛星時刻(1LSB=1.953ms) // unsigned int ui_currentTime2; :衛星時刻(1LSB=31.25ms) i = dpu_getTime( &t_timeInfo ); // ************************************ // ***** CMD: MMO_MD?U_* 0x03 ----- // ************************************ // -------------------------------------------------------- // ----- Admin -------------------------------------------- // -------------------------------------------------------- if (ui_Cntl==0x0000) { // MD*U_INIT if (i_Size!=0) return(0xFF); uc_flag = app01_InitVar(); // uc_flag = app01_JpegSet(); uc_flag = app01_ErrClr (); Gt_cmdDMC[0].uc_GetCount = 1; } else if (ui_Cntl==0x0001) { // MD*U_ERRCLR if (i_Size!=0) return(0xFF); uc_flag = app01_ErrClr (); Gt_cmdDMC[0].uc_GetCount = 1; } else if (ui_Cntl==0x0004 || ui_Cntl==0x0005) { // MD*U_WDT_ENA, MD*U_WDT_DIS if (i_Size!=0) return(0xFF); uc_flag = 0; Guc_WDTena = 5 - ui_Cntl; } #ifndef _APP_RDN_ else if (ui_Cntl==0x0006 || ui_Cntl==0x0007) { // MD*U_OPE_CRUISE, MD*U_OPE_NRM if (i_Size!=0) return(0xFF); uc_flag = 0; Guc_OpeMode = 7 - ui_Cntl; } #endif // -------------------------------------------------------- // ----- Buffer ------------------------------------------- // -------------------------------------------------------- else if (ui_Cntl==0x0008) { // MD*U_BUF_CLCT (node-ID) (0:DIS 1:ENA) if (i_Size!=2) return(0xFF); uc_flag = app01_BufCollectSet(uc_Data[0], uc_Data[1]); } #ifndef _APP_RDN_ else if (ui_Cntl==0x0009) { // MD*U_BUF_OVW (node-ID) (0*:Long 1*: Short / *1:ENA *0:DIS) if (i_Size!=2) return(0xFF); uc_flag = app01_BufOvwSet (uc_Data[0], uc_Data[1]); } #endif else if (ui_Cntl==0x000A || ui_Cntl==0x000B) { // MD*U_MDM_LONG / MD*U_MDM_SHORT if (i_Size!=1) return(0xFF); uc_flag = app01_BufChange (uc_Data[0], ui_Cntl - 0xA); } else if (ui_Cntl==0x000C) { // MD*U_BUF_CLCT_MSAS (NumSpin[00-FF]) if (i_Size!=1) return(0xFF); uc_flag = 0; Guc_MSAS_BufClct = uc_Data[0]; if (Guc_MSAS_BufClct == 0xFF) { Guc_Spec_Code = 0x10; } else if (Guc_MSAS_BufClct == 0x00) { Guc_Spec_Code = 0x00; } else { if (Guc_MSAS_BufClct) app01_BufCollectSet( Gd_N_MSAS, 1 ); } } // -------------------------------------------------------- // ----- HK ----------------------------------------------- // -------------------------------------------------------- /* else if (ui_Cntl==0x0100 || ui_Cntl==0x0101) { // MD*U-HK-STRT // MD*U-HK-STOP if (i_Size!=0) return(0xFF); uc_flag = 0; Guc_HK_repEna = 0x101-ui_Cntl; } */ else if (ui_Cntl==0x0102) { // MD*U-HK-SET (N-ID) (B0-3:INT[2^X s]) if (i_Size!=2) return(0xFF); uc_flag = app01_HkSet (uc_Data[0], uc_Data[1]); } else if (ui_Cntl==0x0103) { // MD*U-OneShot (N-ID) if (i_Size!=1) return(0xFF); uc_flag = app01_Hk_OneShot (uc_Data[0]); } // else if (ui_Cntl==0x0108 || ui_Cntl==0x0109) { // MD*U-HK-MODE-CHK // MD*U-HK-MODE-NML ***ADD:110615*** if (i_Size!=0) return(0xFF); uc_flag = 0; Guc_dpuHkMode = 0x109 - ui_Cntl; } // -------------------------------------------------------- // ----- Mission-Data ------------------------------------- // -------------------------------------------------------- /* else if (ui_Cntl==0x0200 || ui_Cntl==0x0201) { // MD*U_TLM_LM_STRT // MD*U_TLM_LM_STOP if (i_Size!=0) return(0xFF); uc_flag = 0; Guc_TLMm_enadis = 0x201-ui_Cntl; } */ else if (ui_Cntl==0x0204) { // MD*U_TLM_CMP (N-ID) (D-ID) (COMP [b4-7:H b0-3:ML]) if (i_Size!=3) return(0xFF); uc_flag = app01_Tlm_CmpSet(uc_Data[0], uc_Data[1], uc_Data[2]); } // -------------------------------------------------------- // ----- Mission-Data : H --------------------------------- // -------------------------------------------------------- else if (ui_Cntl==0x0300) { // MD*U_TLMH_Dump (N-ID [FF:all EE:cancel]) (D-ID) (DR:0-5) (TI-before[2]) (TI-end[2]) if (i_Size!=7) return(0xFF); us_TIbefore = ((unsigned short)uc_Data[3] << 8) + ((unsigned short)uc_Data[4] ); us_TIlen = ((unsigned short)uc_Data[5] << 8) + ((unsigned short)uc_Data[6] ); uc_flag = app01_TlmH_Dump (uc_Data[0], uc_Data[1], uc_Data[2], us_TIbefore, us_TIlen); } // ========================================================================================================== // [Variables] // B1 Guc_TLMh_ScoreLen // B2 Guc_TLMh_ScoreTh // B3-4/5-6/7-8/9-10 Guc_TLMh_trgID, Guc_TLMh_trgTh // (INIT) Gui_TRG_TiStart, Gui_TRG_TiEnd, Gui_TRG_ScoreTotal // Guc_TLMh_storeId1, Guc_TLMh_storeId2, Guc_TLMh_storeDrId, Guc_TLMh_storeDrOvw, Guc_TLMh_storeTimePre, Guc_TLMh_storeTimeLen // ========================================================================================================== // (usage) MD2U_TLMH_TRG_SET (Score-LEN) (Score-th) (Para-1[2B]) (Para-2[2B]) (Para-3[2B]) (Para-4[2B]) // ------------------------------------------------------------ // Score-LEN b7 Score policy (0:Sum of count 1:Sum of (Value/Threshold) // b0-3 Score length (x 4sec) MAX:15spin = 0x0F // Score-Th Score threshold (b4-7:signed) * 2^(b0-3) // ------------------------------------------------------------ // Para-X 0B b7 0:> 1:< // b6 0:nrm 1:diff // b0-5 Parameter ID // Bx:1 By:2 Bz:3 Brms:4 |Bx|:5 |By|:6 |Bz|:7 |B|:8 // Te:9 // Nhi:A // Ehe:B, Ihe:C D // Ni:D Ti:E // Energy-spectrum_Ch0-6:10-16 // Vx:17 Vy:18 Vz:19 |Vx|:1A |Vy|:1B |Vz|:1C |V|:1D // flag:1F // ---------------------------- // Bx:21 By:22 Bz:23 Brms:24 |Bx|:25 |By|:26 |Bz|:27 |B|:28 // Ne:29, Te:2A // Pot:2B |E|:2C Erms:2D // E-spectrum_Ch0-7:30-37 // B-spectrum_Ch0-7:38-3F // 1B Threshold sign b7 0:> 1:< // value (b4-6) * 2^(b0-3) // ------------------------------------------------------------ else if (ui_Cntl==0x0302) { // MD?U_TLM_H_TRG_SET (B1:Score-LEN) (B2:Score-th) (B3-4:Para-1) (B5-6:Para-2) (B7-8:Para-3) (B9-10:Para-4) if ( i_Size!=10 ) return(0xFF); // --- Initialize --- Gui_TRG_TiStart = Gui_TRG_TiEnd = Gui_TRG_ScoreTotal = Guc_TLMh_DrNum = 0; // Trigger-Score OFF Guc_TLMh_storeId1 = Guc_TLMh_storeId2 = Guc_TLMh_storeDrId = Guc_TLMh_storeDrOvw = Guc_TLMh_storeTimePre = Guc_TLMh_storeTimeLen = 0; // Trigger-Set OFF // if ( uc_Data[0]==0 ) { Guc_TLMh_ScoreLen = Guc_TLMh_ScoreTh = 0; for (i=0; i<4; i++) Guc_TLMh_trgTh[i] = Guc_TLMh_trgID[i] = 0; } else { Guc_TLMh_ScoreLen = (uc_Data[0] & 0x8F); // MAX: 15 = 60sec // if ((Guc_TLMh_ScoreLen & 0x7F) > 16) Guc_TLMh_ScoreLen = 16 + (Guc_TLMh_ScoreLen & 0x80); // MAX: 16 = 64sec // Guc_TLMh_ScoreTh = uc_Data[1]; // Guc_TLMh_trgID_num = 0; for (i=0; i<4; i++) { Guc_TLMh_trgID[i] = uc_Data[i*2+2]; Guc_TLMh_trgTh[i] = uc_Data[i*2+3]; if ( Guc_TLMh_trgID[i] & 0x3F ) Guc_TLMh_trgID_num ++; } if (Guc_TLMh_trgID_num > 1) Guc_TLMh_ScoreLen &= 0x7F; } uc_flag = 0; } // ================================================================================================= // MD?U_TLM_H_TRG_STRT (B1:SEL-DPU1) (B2:SEL-DPU2) (B3:DR-ID) (B4:TI-PRE) (B5:TI-LEN) // Guc_TLMh_storeId1 = uc_Data[0]; // Guc_TLMh_storeId2 = uc_Data[1]; // SEL1/SEL2 Data select DPU1 DPU2 // b0 MEA1 MGFI // b1 MEA2 ---- // b2 MIA ---- // b3 MSA EWOE // b4 HEPE ---- // b5 HEPI EFD // b6 ---- EWOB // b7 MGFO SOR // // Guc_TLMh_storeDrId = uc_Data[2] & 0x1F; // Guc_TLMh_storeDrOvw = uc_Data[2] & 0x80; // DR-ID b7 OverWrite to Lowest-SCORE (ENA:1 DIS:0) // b0-4 Used Dr-ID(b0:H1 b1:H2 b2:H3 b3:H4 b4:H5 (ENA:1 DIS:0) // // Guc_TLMh_storeTimePre = uc_Data[3]; // TI-PRE(* 8sec) Data start-time before the trigger [0xFF: All data at the latch] // // Guc_TLMh_storeTimeLen = uc_Data[4]; // TI-AFT(* 8sec) Data end-time after the trigger [0xFF: All data in the SDRAM] // ================================================================================================= else if (ui_Cntl==0x0303) { if (i_Size!=5) return(0xFF); if ( uc_Data[0]==0 && uc_Data[1]==0 ) { Guc_TLMh_storeId1 = Guc_TLMh_storeId2 = Guc_TLMh_storeDrId = Guc_TLMh_storeDrOvw = Guc_TLMh_storeTimePre = Guc_TLMh_storeTimeLen = 0; } else { Guc_TLMh_storeId1 = uc_Data[0]; Guc_TLMh_storeId2 = uc_Data[1]; Guc_TLMh_storeDrId = uc_Data[2] & 0x1F; Guc_TLMh_storeDrOvw = uc_Data[2] & 0x80; Guc_TLMh_storeTimePre = uc_Data[3]; Guc_TLMh_storeTimeLen = uc_Data[4]; } uc_flag = 0; } else if (ui_Cntl==0x0304) { // MD?U_TLM_H_DR_SET (B1:H-DR1) (B2:H-DR2) (B3:H-DR3) (B4:H-DR4) (B5:H-DR5) if (i_Size!=5) return(0xFF); for (i=0; i<5; i++) { Guc_TLMh_DrEmpty[i+1] = uc_Data[i] & 0x1; Guc_TLMh_DrOvw [i+1] = (uc_Data[i]>> 4) & 0x1; Guc_TLMh_DrWrite[i+1] = 0; // ***ADDED: 140119*** if ( Guc_TLMh_DrEmpty[i+1] == 0 ) Gui_TLMh_DrTI[i+1] = Gui_TLMh_DrScore[i+1] = 0; } uc_flag = 0; } // -------------------------------------------------------- // ----- SPECIAL ------------------------------------------ // -------------------------------------------------------- #ifdef _APP_DMY_ else if (ui_Cntl==0xFF11) { // MD*U-SP-TLM-DUMMY (Code [*0:OFF *1:HK *2:OneShot *4:LM *8:H 8*:non-stop(1)/stop(0)] (1*:MSASI) if (i_Size!=1) return(0xFF); uc_flag = 0; Guc_Spec_Code = uc_Data[0] & 0x0F; if ( (uc_Data[0] & 0x80) == 0 ) Gui_Spec_Code_TI = t_timeInfo.ui_currentTime2; } #endif // _APP_DMY_ // ERROR else uc_flag = 0xEE; // *** Error: CMD not found *** return( uc_flag ); } // ********************************************************************************************************** // ********************************************************************************************************** // -------------------------------------------------------- // ----- Buffer ------------------------------------------- // -------------------------------------------------------- // ========================================================================================================== // [0008] MD*U_BUF_CLCT // (N-ID) 0xFF: all // (0:DIS 1:ENA) // [000C] MD*U_BUF_CLCT_MSAS // (NumSpin[00-FF]) // ========================================================================================================== unsigned char app01_BufCollectSet(unsigned char uc_nodeId, unsigned char uc_enadis) // MD*U_BUFF_CLCTSET (node-ID) (1:ENA 0:DIS) { int i_nodeID_once[8]; int i_switch_once[8]; int i_flag = -0xFF; int i; // ************************ // **** BUFFER ENA/DIS **** // ************************ if (uc_enadis) uc_enadis = 1; // Mission data collect start // **** START/STOP of each buffer **** if ( uc_nodeId != 0xFF ) { // *** CMD: DPU1 *** if (Guc_dpuNo==0 || Guc_dpuRdn) { if (uc_nodeId>=Gd_N_MEA1 && uc_nodeId<=Gd_N_MGFO) { #ifdef _APP_RDN_ Guc_rdn_missionClct[uc_nodeId] = uc_enadis; // **** REDUNDANCY **** if (Guc_dpuNo==0) #endif // _APP_RDN_ i_flag = dpu_missionCollect( uc_nodeId, uc_enadis); // **** Normal **** } } // *** CMD: DPU2 *** if (Guc_dpuNo==1 || Guc_dpuRdn) { if (uc_nodeId>=Gd_N_MGFI && uc_nodeId<=Gd_N_SOR && uc_nodeId!=Gd_N_EWO+1) { #ifdef _APP_RDN_ Guc_rdn_missionClct[uc_nodeId] = uc_enadis; // **** REDUNDANCY **** if (Guc_dpuNo==0) { if (Guc_dpuRdn==2 && uc_nodeId==Gd_N_EWO) { i_flag = app_Rdn_EWOclctStart( uc_enadis ); } } else #endif // _APP_RDN_ i_flag = dpu_missionCollect( uc_nodeId, uc_enadis); // **** Normal **** } } } else { // **** START/STOP of all buffer **** // *** CMD: DPU1 *** if (Guc_dpuNo==0 || Guc_dpuRdn) { for (i=0; i<8; i++) { i_nodeID_once[i] = Gd_N_MEA1+i; i_switch_once[i] = uc_enadis; #ifdef _APP_RDN_ Guc_rdn_missionClct[Gd_N_MEA1+i] = uc_enadis; #endif // _APP_RDN_ } if (Guc_dpuNo==0) i_flag = dpu_missionCollectAtOnce( i_nodeID_once, i_switch_once); // **** normal **** } // *** CMD: DPU2 *** if (Guc_dpuNo==1 || Guc_dpuRdn) { i_nodeID_once[0] = Gd_N_MGFI; i_nodeID_once[1] = Gd_N_MDM; i_nodeID_once[2] = Gd_N_EWO; i_nodeID_once[3] = Gd_N_SOR; for (i=0; i<4; i++) i_switch_once[i] = uc_enadis; for (i=4; i<8; i++) i_nodeID_once[i] = i_switch_once[i] = 0; #ifdef _APP_RDN_ Guc_rdn_missionClct[Gd_N_MGFI] = uc_enadis; Guc_rdn_missionClct[Gd_N_MDM ] = uc_enadis; Guc_rdn_missionClct[Gd_N_EWO ] = uc_enadis; Guc_rdn_missionClct[Gd_N_SOR ] = uc_enadis; #endif if (Guc_dpuNo==1) i_flag = dpu_missionCollectAtOnce( i_nodeID_once, i_switch_once); // **** normal **** } } return( -i_flag ); } // ========================================================================================================== // MD*U_BUFF_OVWSET (node-ID) (4-7b Long(1:Ena 0:Dis) 0-3b Short(1:Ena 0:Dis)) // ========================================================================================================== int app01_BufOvwSet_sub( unsigned char uc_dpuNo, unsigned char uc_nodeId, unsigned char uc_ovw ) { int i_flag = 0; #ifdef _APP_RDN_ Guc_rdn_missionOvw[uc_nodeId] = uc_ovw; // **** REDUNDANCY **** #endif if (Guc_dpuNo==uc_dpuNo) { i_flag = dpu_setOverWriteMode( uc_nodeId, 0, uc_ovw); // **** normal **** i_flag = dpu_setOverWriteMode( uc_nodeId, 1, uc_ovw); // **** normal **** } return( i_flag ); } unsigned char app01_BufOvwSet(unsigned char uc_nodeId, unsigned char uc_enadis) { int i; int i_flag = 0; unsigned char uc_ovw; if (uc_enadis) uc_ovw = 1; else uc_ovw = 0; if ( uc_nodeId != 0xFF ) { // **** OverWrite ENA/DIS of each buffer **** // *** CMD: DPU1 *** if (Guc_dpuNo==0 || Guc_dpuRdn) { // *** RDN: OK if (uc_nodeId>=Gd_N_MEA1 && uc_nodeId<=Gd_N_MGFO) { i_flag = app01_BufOvwSet_sub( 0, uc_nodeId, uc_ovw ); } } // *** CMD: DPU2 *** if (Guc_dpuNo==1 || Guc_dpuRdn) { // *** RDN: OK if ((uc_nodeId>=Gd_N_MGFI && uc_nodeId<=Gd_N_MSAS) || uc_nodeId==Gd_N_SOR) { i_flag = app01_BufOvwSet_sub( 1, uc_nodeId, uc_ovw ); } } } else { // **** START/STOP of all buffer **** // *** CMD: DPU1 *** if (Guc_dpuNo==0 || Guc_dpuRdn) { // *** RDN: OK for (i= 0x05; i<0x0D; i++) { if ( i == Gd_N_ENA ) continue; // ENA: OVW-DIS if ( app01_BufOvwSet_sub( 0, i, uc_ovw ) ) i_flag = -1; } } // *** CMD: DPU2 *** if (Guc_dpuNo==1 || Guc_dpuRdn) { // *** RDN: OK for (i= 0x0D; i<0x13; i++) { if ( i == 0x10 || i == 0x11 ) continue; // EWO: no OVW-mode change if ( app01_BufOvwSet_sub( 1, i, uc_ovw ) ) i_flag = -1; } } } return( -i_flag ); } // ========================================================================================================== // [000A] MD*U_BUF_LONG (not for ENA/MDM/MSASI/SOR) // [000B] MD*U_BUF_SHORT (not for ENA/MDM/MSASI/SOR) // (N-ID) 0xFF: all // ========================================================================================================== unsigned char app01_BufChange (unsigned char uc_nodeId, unsigned char uc_bufId ) // MD*U_BUFF_SHORT/LONG (node-ID) (0:L 1:S) { int i; int i_flag = -0xFF; if ( uc_bufId ) uc_bufId = 1; // 0:Long, 1:Short if ( uc_nodeId != 0xFF ) { // *** CMD: DPU1 *** if (Guc_dpuNo==0) { if (uc_nodeId>=Gd_N_MEA1 && uc_nodeId<=Gd_N_MGFO && uc_nodeId!=Gd_N_ENA) i_flag = dpu_bufferChange( uc_nodeId, uc_bufId ); // **** normal **** } // *** CMD: DPU2 *** if (Guc_dpuNo==1) { if (uc_nodeId==Gd_N_MGFI || uc_nodeId==Gd_N_MDM || uc_nodeId==Gd_N_EWO) i_flag = dpu_bufferChange( uc_nodeId, uc_bufId ); // **** normal **** } } else { // *** CMD: DPU1 *** if (Guc_dpuNo==0) { for (i= 0x05; i<0x0D; i++) { if (i != Gd_N_ENA) { i_flag = dpu_bufferChange( i, uc_bufId ); // **** normal **** } } } // *** CMD: DPU2 *** if (Guc_dpuNo==1 ) { i_flag = dpu_bufferChange( Gd_N_MDM, uc_bufId); // ****REDUNDANCY-CASE:REVISION in future**** i_flag = dpu_bufferChange( Gd_N_MGFI, uc_bufId); // ****REDUNDANCY-CASE:REVISION in future**** i_flag = dpu_bufferChange( Gd_N_EWO, uc_bufId); // ****REDUNDANCY-CASE:REVISION in future**** } } return( -i_flag ); } // ********************************************************************************************************** // ********************************************************************************************************** // -------------------------------------------------------- // ----- HK ----------------------------------------------- // -------------------------------------------------------- unsigned char app01_HkSet( unsigned char uc_nodeId, unsigned char uc_hkInt) // MD*U-HK-SET (N-ID) (b0-3:INT[2^X s], b7:HK) // REVISE:20120613 { int i; unsigned char uc_cmpHK = (uc_hkInt >> 7); // cmp for HK // REVISE:20120613 uc_hkInt = (uc_hkInt & 0xF); // HK-interval: 2^X s 0-1sec, F-9.1h if (uc_nodeId == 0xFF) { for (i=0; i<0x15; i++) { if ( Guc_HK_repInt[i] < 0x10 ) { Guc_HK_repInt[i] = uc_hkInt; Guc_TLMhk_cmp[i] = uc_cmpHK; // REVISE:20120613 } } } else if (uc_nodeId>=Gd_N_DPU1 && uc_nodeId<=Gd_N_MWE) { if ( Guc_HK_repInt[uc_nodeId] < 0x10 ) { Guc_HK_repInt[uc_nodeId] = uc_hkInt; Guc_TLMhk_cmp[uc_nodeId] = uc_cmpHK; // REVISE:20120613 } } else return(1); // *** ERR-1: Node-ID Error return(0); } unsigned char app01_Hk_OneShot( unsigned char uc_nodeId ) // **** MD*U-HK-OneShot (N-ID) *** { int i; if (uc_nodeId == 0xFF) { for (i=0; i<0x15; i++) Guc_HK_OneShot[i] = 1; } else if (uc_nodeId>=Gd_N_DPU1 && uc_nodeId<=Gd_N_MWE) { Guc_HK_OneShot[uc_nodeId] = 1; } else return(1); return(0); } // ********************************************************************************************************** // -------------------------------------------------------- // ----- TLM ---------------------------------------------- // -------------------------------------------------------- // **** MD?U_Tlm_CmpSet (N-ID, D-ID, CMP) **** // ========================================================================================================== // [0204] MD*U_TLM_CMP (N-ID) 0xFF: all // (D-ID) // (COMP) [b4-6:H] Comp mode [0:non 1:Arith0 2:Arith1 4:RICE, 3,5-7:User-COMP] // [b0-3:ML] Comp mode [0:non 1:Arith0 2:Arith1 4:RICE, 3,5-7:User-COMP] // ========================================================================================================== unsigned char app01_Tlm_CmpSet( unsigned char uc_nodeId, unsigned char uc_dataId, unsigned char uc_cmp ) { unsigned char uc_headId; int i; unsigned char uc_cmpM = (uc_cmp ) & 0x07; unsigned char uc_cmpH = (uc_cmp >> 4) & 0x07; // --------------------------------- // *** CCSDS Header Definition *** // --------------------------------- if (uc_nodeId == Gd_N_EWO) { if (uc_dataId) uc_headId = uc_dataId-1; else uc_headId = Gd_N_EWO; Guc_TLMm_cmp [uc_headId] = uc_cmpM; if (uc_headId==Gd_N_EFD) Guc_TLMh_cmp [uc_headId] = uc_cmpH; } else if (uc_nodeId==Gd_N_DPU1 && uc_nodeId==Gd_N_DPU2) { if (uc_cmpM) Guc_TLMm_cmp [uc_nodeId] = 1; else Guc_TLMm_cmp [uc_nodeId] = 0; if (uc_cmpH) Guc_TLMh_cmp [uc_nodeId] = 1; else Guc_TLMh_cmp [uc_nodeId] = 0; } else if (uc_nodeId>=Gd_N_MEA1 && uc_nodeId<=Gd_N_SOR && uc_nodeId != Gd_N_ENA) { Guc_TLMm_cmp [uc_nodeId] = uc_cmpM; Guc_TLMh_cmp [uc_nodeId] = uc_cmpH; } else if (uc_nodeId== 0xFF) { for (i=0; i<0x13; i++) { if ( iGd_N_MSA && i != Gd_N_ENA && i!=Gd_N_EWOE+1) ) { // 設定しないもの: DPU1/DPU2, MEA1/2-MIA-MSA, ENA, EWO-E+1 Guc_TLMm_cmp [i] = uc_cmpM; if (i!=Gd_N_AM2P && i!=Gd_N_EWOB && i!=Gd_N_EWOE) Guc_TLMh_cmp [i] = uc_cmpH; // 設定しないもの: EWO-E/B, AM2P } } if (uc_cmpM) { Guc_TLMm_cmp [Gd_N_DPU1] = Guc_TLMm_cmp [Gd_N_DPU2] = 1; } else { Guc_TLMm_cmp [Gd_N_DPU1] = Guc_TLMm_cmp [Gd_N_DPU2] = 0; } if (uc_cmpH) { Guc_TLMh_cmp [Gd_N_DPU1] = Guc_TLMh_cmp [Gd_N_DPU2] = 1; } else { Guc_TLMh_cmp [Gd_N_DPU1] = Guc_TLMh_cmp [Gd_N_DPU2] = 0; } } else return(1); // *** ERR-1: Incorrect Node-ID & Data-ID return(0); } // *************************************************************** // **** MD?U_TlmH_Dump (N-ID, D-ID, DrID, TI-BEFOUR, TI-LEN) **** // *************************************************************** // [0300] MD?U_TlmH_Dump // (N-ID [FF:all-exceptEWO, FF:all FE:all except EWO EE:EWO-all 00:cancel]) // (D-ID) // (DR:0-5) 0:CAL etc 1-5:Sync Trigger // (TI-BEFOUR[2]) 0000:LATEST block/packet) // (TI-LEN[2]) 0000:1-packet 0001:1-block FFFF:All // // during DUMP BUF: SHORT // after DUMP BUF: LONG unsigned char app01_TlmH_Dump ( unsigned char uc_nodeId, unsigned char uc_dataId, unsigned char uc_drID, unsigned short us_TIstart, unsigned short us_TIlen) { unsigned char uc_headId; int i; int i_flag_nrm, i_flag_ewo; unsigned int ui_TIs; M_T_TIME_INFO t_timeInfo; // unsigned int ui_currentTime; :衛星時刻(1LSB=1.953ms) // unsigned int ui_currentTime2; :衛星時刻(1LSB=31.25ms) if ( uc_drID > 5 ) return(1); // ****ERROR: Parameter incorrect**** // --------------------------------- // ***CANCEL*** // --------------------------------- if (uc_nodeId == 0) { for (i=0; i<0x11; i++) { if (i==Gd_N_ENA || i==Gd_N_MDM || i==Gd_N_MSAS) continue; // ***ADDED: 140119*** SKIP if (i>=Gd_N_MEA1) app01_BufChange ( i, 0 ); // ***ADDED: 140119*** CHANGE to Long BUFFER Guc_TLMh_enadis [i] = 0; } return(0); } // ---- Conversion: Start-TI / len ---- i = dpu_getTime( &t_timeInfo ); // current time if ( us_TIstart ) { if ( us_TIstart > 0xE000 ) us_TIstart = 0xE000; if ( us_TIstart + 0x100 < us_TIlen ) us_TIlen = us_TIstart + 0x100; } else { if ( us_TIlen > 1 ) us_TIlen = 1; } ui_TIs = t_timeInfo.ui_currentTime2 - us_TIstart; // --------------------------------- // ***Exe Check*** // --------------------------------- i_flag_nrm = 0; for (i=Gd_N_MEA1; i<=Gd_N_MGFI; i++) if (i!=Gd_N_ENA) i_flag_nrm += Guc_TLMh_enadis [i]; i_flag_ewo = Guc_TLMh_enadis[Gd_N_EWOE] + Guc_TLMh_enadis[Gd_N_EWOB] + Guc_TLMh_enadis[Gd_N_EFD]; // + Guc_TLMh_enadis[Gd_N_AM2P]; // --------------------------------- // ***Each*** // --------------------------------- if (uc_nodeId>=Gd_N_MEA1 && uc_nodeId<=Gd_N_MGFI && uc_nodeId!=Gd_N_ENA) { uc_headId = uc_nodeId; if ( Guc_TLMh_enadis[uc_headId] == 1 ) return(2); app01_BufChange (uc_nodeId, 1 ); // CHANGE to Short BUFFER // Guc_TLMh_enadis[uc_headId] = 1; Gui_TLMh_TIstart [0] = ui_TIs; // [INPUT] TI - Dump start TI (0000: from LATEST) Gus_TLMh_TIlen [0] = us_TIlen; // [INPUT] TI - Dump Length (0x0000: 1 Packet 0x0001: 1 Block) Guc_TLMh_drID [0] = uc_drID; // [INPUT] DR ID 0:CAL etc 1-5:Sync Trigger Gui_TLMh_TIdump_start0[0] = Gui_TLMh_TIdump_end0 [0] = 0xFFFFFFFF; return(0); } if (uc_nodeId == Gd_N_EWO) { if (uc_dataId) { uc_headId = uc_dataId-1; if (uc_dataId==1) return(3); // AM2P: DIS } else uc_headId = Gd_N_EWOE; if ( Guc_TLMh_enadis[uc_headId] == 1 ) return(4); if ( i_flag_ewo==0 ) app01_BufChange (Gd_N_EWO, 1 ); // CHANGE to Short BUFFER (EWOE/EWOB/EFD/AM2P) // Guc_TLMh_enadis[uc_headId] = 1; Gui_TLMh_TIstart [1] = ui_TIs; // [INPUT] TI - Dump Start TI (0x0000: from LATEST) Gus_TLMh_TIlen [1] = us_TIlen; // [INPUT] TI - Dump Length (0x0000: 1 Packet 0x0001: 1 Block) Guc_TLMh_drID [1] = uc_drID; // [INPUT] DR ID 0:CAL etc 1-5:Sync Trigger Gui_TLMh_TIdump_start0[1] = Gui_TLMh_TIdump_end0 [1] = 0xFFFFFFFF; return(0); } // ***EWO all*** if (uc_nodeId == 0xEE || uc_nodeId == 0xFF) { // EWO-E/B/EFD trigger in same interval if ( i_flag_ewo == 0) { for (i=0; i<0x4; i++) { if (i==1) continue; // Skip - AM2P if (i) uc_headId = i-1; else uc_headId = Gd_N_EWOE; // Guc_TLMh_enadis [uc_headId] = 1; } Gui_TLMh_TIstart [1] = ui_TIs; // [INPUT] TI - Dump Start TI (0x0000: from LATEST) Gus_TLMh_TIlen [1] = us_TIlen; // [INPUT] TI - Dump Length (0x0000: 1 Packet 0x0001: 1 Block) Guc_TLMh_drID [1] = uc_drID; // [INPUT] DR ID 0:CAL etc 1-5:Sync Trigger Gui_TLMh_TIdump_start0[1] = Gui_TLMh_TIdump_end0 [1] = 0xFFFFFFFF; app01_BufChange (Gd_N_EWO, 1 ); // CHANGE to Short BUFFER (EWOE/EWOB/EFD/AM2P) } if (uc_nodeId == 0xEE) return(0); } // ***ALL without EWO*** if (uc_nodeId == 0xFE || uc_nodeId == 0xFF) { if ( i_flag_nrm ) return(5); for (i=Gd_N_MEA1; i<=Gd_N_MGFI; i++) { if (i==Gd_N_ENA) continue; Guc_TLMh_enadis [i] = 1; app01_BufChange ( i, 1 ); // CHANGE to Short BUFFER } Gui_TLMh_TIstart [0] = ui_TIs; // [INPUT] TI - Dump Start TI (0x0000: from LATEST) Gus_TLMh_TIlen [0] = us_TIlen; // [INPUT] TI - Dump Length (0x0000: 1 Packet 0x0001: 1 Block) Guc_TLMh_drID [0] = uc_drID; // [INPUT] DR ID 0:CAL etc 1-5:Sync Trigger Gui_TLMh_TIdump_start0[0] = Gui_TLMh_TIdump_end0 [0] = 0xFFFFFFFF; return(0); } return(6); }