/******************************************************************************* * モジュール名称 :アプリケーション02 - HK read & anaylses - MEF * * 参考 : app02_MEF.c を参照 * * 注意 : EDIT権限は、EXT組 (MEFISTOから委託) * * 作成日・作成者 :2012/4/23 Y.K. * * Modified : 2012/6/20 A.K. Initialization of i_D_STEP_DIFF * * was added in order to avoid * * compile warning * * Modified : 2012/8/4 A.K. The way of lenght counter check * * was changed (Not absolute lenght * * but variation from initial * * length have to be checked) * * Modified : 2012/12/27 Y.K. MEF SWEEP-TABLE CHKSUM & USERREQ * * Modified : 2012/12/31 A.K. Corrected(USERREQ) * * Modified : 2013/02/16 A.K. Deleted(USERREQ) * * Modified : 2017/07/13 A.K. Added(app15_putAplHK_MEFI) * * To check SW-HK by on-off keying * * during deployment operation * *******************************************************************************/ #include "app_common.h" #include "app_MEF.h" #include "app_EWO.h" #define d_SIZEhk_MEF (36) // HK-size 0x24 #define D_N_CHK (3) //AK110611// Number of bad HK set for identification of emergency // ******************************************************************** // *** MEF : HK analyses, HW CMD production, HK packet production *** // ******************************************************************** int app02_MEF ( unsigned char uc_dataHK[], unsigned int ui_counter, unsigned char uc_link ) { // unsigned char uc_dpuSwHk[132]; // ----- corrected by YK: 以降すべてG2uc_packetに差し替え ----- int i_dpuSwHK_size = 0; int i_flag; int i; // ***************************** // *** HW-HK & CMD actions *** // ***************************** if ( uc_link ) { // --- HW-ON --- // ------------------------- // --- HK-copy --- // ------------------------- for (i=0; i<36; i++) { Guc_MEF_HK[i] = uc_dataHK[i]; } // ------------------------- // --- CMD Actions --- // ------------------------- // MEF: E2PROM operation (128B x4) -- 1:start 2:Write-1 3:Write-2 4:Write-3 5:Write-4 0:none if ( G1uc_MEF_E2PROM>1 && G1uc_MEF_E2PROM<5 ) { // --------------------------------------------------------- // MEF: E2PROM operation: 1:start -> 2:Write-1 // MEF: E2PROM operation: 2:Write-1 -> 3:Write-2 // MEF: E2PROM operation: 3:Write-2 -> 4:Write-3 // MEF: E2PROM operation: 4:Write-2 -> 5:Write-4 // --------------------------------------------------------- // ROM read: MEF-SWEEP [EFD-ROM領域: 先頭から(128*i)B, size:128B) G2uc_packet[0x00] = 0x0B; G2uc_packet[0x01] = 0x00; G2uc_packet[0x02] = 0x00; G2uc_packet[0x03] = G1uc_MEF_E2PROM; i_flag = app_readROM( Gd_MEF_RomAdr + 128*(G1uc_MEF_E2PROM-1), 128, &(G2uc_packet[0x04]) ); for (i=4; i<132; i++) G1uc_MEF_E2PROM_sum += G2uc_packet[i]; // *** rev 121227 by Y.K. *** // CMD to MEFISTO: "LOAD_TABLE" i_flag = app_PiCmd( Gd_N_MEF, G2uc_packet, 132 ); // Counter up G1uc_MEF_E2PROM ++; } else { G1uc_MEF_E2PROM = 0x00; } // STATUS-variable: for SOR & EFD // EFD SOR // b7 AM2P-activate // b6 AM2P-activate // b5 MEF-CAL B19 b7 MEF-CAL B19 b7 // b4 MEF-Pre-PWR B19 b6 MEF-BIAS B19 b6 // b3 WPT-Loop B1 b7 MEF-GAIN B19 b3 // b2 WPT-Bias B0 b6 WPT-CAL // b1 WPT-Cal B0 b3 WPT-BIAS // b0 WPT-Pre-PWR B0 b1 WPT-GAIN B0 b2 if ( uc_dataHK[19]& 0x80){ Guc_EFD_data_status |= 0x20; Guc_SOR_data_status |= 0x20; } // MEF-CAL else { Guc_EFD_data_status &= 0xDF; Guc_SOR_data_status &= 0xDF; } if ( uc_dataHK[19]& 0x40){ Guc_EFD_data_status |= 0x10; Guc_SOR_data_status |= 0x10; } // MEF-Pre/BIAS else { Guc_EFD_data_status &= 0xEF; Guc_SOR_data_status &= 0xEF; } if ( uc_dataHK[19]& 0x08){ Guc_SOR_data_status |= 0x08; } // WPT-GAIN B0 b2 else { Guc_SOR_data_status &= 0xF7; } } else { // --- HW-OFF --- // ------------------------- // --- HK clear --- // --- CMD clear --- // ------------------------- for (i=0; iPara_NH) or uc_dataHK[0] > Guc_MEF_H_Para_NU || // (HV posPara_PH), uc_dataHK[1] < Guc_MEF_H_Para_PL || // a flag in uc_H_EMG (0x80) will be set uc_dataHK[1] > Guc_MEF_H_Para_PU) uc_H_EMG|=0x80; } // Para_NL: HV_CNTL_ENA arg-1 // Para_NU: HV_CNTL_ENA arg-2 // Para_PL: HV_CNTL_ENA arg-3 // Para_PU: HV_CNTL_ENA arg-4 // ---------------------------------------------------------------------- // --- Update of H_EMGOFF (Identification of Emergency off necessity) --- // ---------------------------------------------------------------------- for (i=0; i ( Gi_MEF_D_Para_LB) || // if |i_D_DIFF|>Para_LB, a flag in uc_D_EMG (0x80) will be set i_D_DIFF < (-Gi_MEF_D_Para_LB)) uc_D_EMG |= 0x80; // Para_LA: EXTSTOP_PARA arg-1,2 } // Para_LB: EXTSTOP_PARA arg-3,4 // S1 deployment counter: HK[24](upper 8 bit),HK[25](lower 8 bit) // STEP_H: HK[28](upper 8 bit), HK[29](lower 8 bit) if (Guc_MEF_D_Off_Chk & 0x40) { // Control for Event-2(0x40): S2 Length consistency check i_D_DIFF = i_D_LEN2 * Gi_MEF_D_Para_LA - i_D_STEP_H; // i_D_DIFF: difference between (S2 deployment counter)*Para_LA and step counter if (i_D_DIFF > ( Gi_MEF_D_Para_LB) || // if |i_D_DIFF|>Para_LB, a flag in uc_D_EMG (0x40) will be set i_D_DIFF < (-Gi_MEF_D_Para_LB)) uc_D_EMG |= 0x40; // Para_LA: EXTSTOP_PARA arg-1,2 } // Para_LB: EXTSTOP_PARA arg-3,4 // S2 deployment counter: HK[26](upper 8 bit),HK[27](lower 8 bit) // Step counter: HK[28](upper 8 bit), HK[29](lower 8 bit) if (Guc_MEF_D_Off_Chk & 0x20) { // Control for Event-3(0x20): Difference check between S1&S2 deployment counters i_D_DIFF = i_D_LEN1 - i_D_LEN2; // i_D_DIFF: difference between S1 and S2 deployment counters if (i_D_DIFF > ( Gi_MEF_D_Para_LD) || // if |i_D_DIFF|>Para_LD, a flag in uc_D_EMG (0x20) will be set i_D_DIFF < (-Gi_MEF_D_Para_LD)) uc_D_EMG |= 0x20; // Para_LD: EXTSTOP_PARA arg-5 } // S1 deployment counter: HK[24](upper 8 bit),HK[25](lower 8 bit) // S2 deployment counter: HK[26](upper 8 bit),HK[27](lower 8 bit) if (Guc_MEF_D_Off_Chk & 0x10) { // Control for Event-4(0x10): Check of step counter stop if (i_D_STEP_DIFF==0) uc_D_EMG |= 0x10; // if the step counter value is the same with the previous value, } // a flag in uc_D_EMG (0x10) will be set } // Step counter: HK[28](upper 8 bit), HK[29](lower 8 bit) if (Guc_MEF_D_Off_Chk & 0x08) { // Control for Event-5(0x08): S1 temperature check if (uc_dataHK[3] < Guc_MEF_D_Para_TL || // if (S1 TempPara_TU), a flag in uc_D_EMG (0x08) will be set uc_dataHK[3] > Guc_MEF_D_Para_TU) uc_D_EMG|=0x08; // Para_TU: EXTSTOP_PARA arg-6 } // Para_TL: EXTSTOP_PARA arg-7 // S1 Temperature: HK[3] if (Guc_MEF_D_Off_Chk & 0x04) { // Control for Event-6(0x04): S2 temperature check if (uc_dataHK[2] < Guc_MEF_D_Para_TL || // if (S2 TempPara_TU), a flag in uc_D_EMG (0x04) will be set uc_dataHK[2] > Guc_MEF_D_Para_TU) uc_D_EMG|=0x04; // Para_TU: EXTSTOP_PARA arg-6 } // Para_TL: EXTSTOP_PARA arg-7 // S2 Temperature: HK[2] if (Guc_MEF_D_Off_Chk & 0x02) { // Control for Event-7(0x02): Timeup check if (Gus_MEF_D_Timer) { Gus_MEF_D_Timer--; // If countdown timer becomes 0, a flag in uc_D_EMG (0x02) will be set if (0==Gus_MEF_D_Timer) { uc_D_EMG|=0x02; } } } //if (uc_D_EMG) Gi_MEF_D_DBG2++; // ---------------------------------------------------------------------- // --- Update of D_EMGOFF (Identification of Emergency off necessity) --- // ---------------------------------------------------------------------- for (i=0; i OFF // ---------------------------------------------------------------------- // --- Execution of Emergency off based on uc_D_EMGOFF --- // ---------------------------------------------------------------------- switch (Guc_MEF_D_EMG2) { //AK110611// case 0: //AK110611// if (uc_D_EMGOFF) { Guc_MEF_D_Off_Chk = 0; // Auto-Cntl: OFF Guc_MEF_D_Off_Res1 |= uc_D_EMGOFF; // Res1: ACT if (uc_dataHK[8] & 0x80) // MOTOR_ON/OFF = ON Guc_MEF_D_Off_Res2 |= uc_D_EMGOFF; // Res2: ACT (Motor ON->OFF) uc_cmd_buf[0] = 0x07; uc_cmd_buf[1] = 0x00; uc_cmd_buf[2] = 0x00; uc_cmd_buf[3] = 0x00; i_cmd_num = 4; i_flag = app_PiCmd(Gd_N_MEF, uc_cmd_buf, i_cmd_num ); Guc_MEF_D_EMG2++; //Gi_MEF_D_DBG1++; } break; //AK110611// case 1: //AK110611// //if (Guc_MEF_D_Off_Chk2 & 0x02) app_DmcRequestCmd(0x1B); //AK130216// REQCMD:MOTOR-PSU OFF(Deleted) Guc_MEF_D_Off_Res1 |= 0x01; //AK110611// REQCMD timig flag Guc_MEF_D_EMG2++; //AK110611// break; //AK110611// case 2: //AK110611// //if (uc_dataHK[8] & 0x80) { //AK130216// If MOTOR is still ON //if (Guc_MEF_D_Off_Chk2 & 0x01) app_DmcRequestCmd(0x1E); //AK130216// REQCMD:MEFISTO-E OFF //} //AK130216// Guc_MEF_D_EMG2++; //AK110611// break; //AK110611// case 3: //AK110611// case 4: //AK110611// case 5: //AK110611// case 6: //AK110611// case 7: //AK110611// case 8: //AK110611// Guc_MEF_D_EMG2++; //AK110611// break; //AK110611// case 9: //AK110611// if (uc_dataHK[8] & 0x80) { //AK110611// If MOTOR is still ON Guc_MEF_D_Off_Res2 |= 0x01; //AK110611// REQCMD timig flag } //AK110611// Guc_MEF_D_EMG2 = 0; //AK110611// break; //AK110611// } //AK110611// } // ------------------- // --- Software HK --- // ------------------- G2uc_packet[0] = Gus_MEF_D_Timer >> 8; G2uc_packet[1] = Gus_MEF_D_Timer & 0xFF; G2uc_packet[2] = Guc_MEF_D_Off_Chk; G2uc_packet[3] = Guc_MEF_D_Off_Res1; G2uc_packet[4] = Guc_MEF_D_Off_Res2; //i_dpuSwHK_size = 5; //AK110611// G2uc_packet[5] = ((unsigned short)Gi_MEF_D_Para_LA)>>8; //AK110611// G2uc_packet[6] = ((unsigned short)Gi_MEF_D_Para_LA)&0xFF; //AK110611// G2uc_packet[7] = ((unsigned short)Gi_MEF_D_Para_LB)>>8; //AK110611// G2uc_packet[8] = ((unsigned short)Gi_MEF_D_Para_LB)&0xFF; //AK110611// G2uc_packet[9] = ((unsigned short)Gi_MEF_D_Para_LD)&0xFF; //AK110611// G2uc_packet[10] = Guc_MEF_D_Para_TU; //AK110611// G2uc_packet[11] = Guc_MEF_D_Para_TL; //AK110611// if (Guc_MEF_H_Off_Chk) { //AK120804// G2uc_packet[12] = Guc_MEF_H_Para_NL; //AK120421// G2uc_packet[13] = Guc_MEF_H_Para_NU; //AK120421// G2uc_packet[14] = Guc_MEF_H_Para_PL; //AK120421// G2uc_packet[15] = Guc_MEF_H_Para_PU; //AK120421// } //AK120804// else { //AK120804// G2uc_packet[12] = ((unsigned short)Gi_MEF_D_LEN1)&0xFF; //AK120804// G2uc_packet[13] = ((unsigned short)Gi_MEF_D_LEN2)&0xFF; //AK120804// G2uc_packet[14] = ((unsigned short)Gi_MEF_D_STEP_H)&0xFF; //AK120804// G2uc_packet[15] = Guc_MEF_D_Off_Chk2; //AK120805// } //AK120804// G2uc_packet[16] = (0x80&Guc_MEF_H_Off_Chk)| //AK120804// (0x40&Guc_MEF_H_Off_Res)| //AK120804// (0x00)| //AK120804// For Version Check (0x0F&Guc_MEF_Cmd_Cnt); //AK120421// G2uc_packet[17] = G1uc_MEF_E2PROM_sum; // rev. Y.K. *** 121227 *** i_dpuSwHK_size = 18; // rev. Y.K. *** 121227 *** // *********************************************** //AK170713 // *** Special HK Packet for MGA on-off keying *** //AK170713 // *********************************************** //AK170713 app15_putAplHK_MEFI(G2uc_packet); //AK170713 // ***************************** // *** HK Packet production *** // ***************************** if ( i_dpuSwHK_size > 0) memcpy( &(uc_dataHK[d_SIZEhk_MEF]), G2uc_packet, i_dpuSwHK_size ); else i_dpuSwHK_size = 0; // ****************************** // *** HK Production in 'OFF *** // ****************************** if ( uc_link == 0 ) return( 0 ); else return( d_SIZEhk_MEF+i_dpuSwHK_size ); }