/*******************************************************************************
*   モジュール名称      :アプリケーション04 - Mission TLM Production (2)      *
*   モジュールラベル    :dpu_app14                                            *
*   タスク区分          :アプリケーションタスク                               *
*   機能                :                                                     *
*   コーリングシーケンス:void dpu_app14(int mode)                             *
*   引数                :int mode  冗長機能ON/OFF (0:OFF/1:ON)                *
*   戻り値              :void                                                 *
*   使用上の注意        :なし                                                 *
*   エラー処理          :なし                                                 *
*   作成日・作成者      :2013/3/12     Y.Kasaba                               *
*******************************************************************************/
#include "dpu_api.h"
#include "dpu_api_proto.h"
#include "app_core.h"

void dpu_app14(int mode)
{
	int				i_flag;
	unsigned int	ui_load;			// msec
unsigned int	ui_load2;				// **TMP**
	
	// *************************************
    // *** STOP @ DPU1 in non-redundancy ***
    // *************************************
	if (Guc_dpuNo==0 && Guc_dpuRdn==0) {												// DPU2 in non-Redundancy
	    dpu_WDTEna(0);		// WDT: DIS
	    dpu_appStop();		// *** End ***
	}

    // ************
    // *** MAIN ***
    // ************
	dpu_waitProcessingSlot(32);
    for (;;) {
		// *** WAIT ***
		app_WhoWhere( 5, Gd_N_COM, 0x01 );
		dpu_waitSunpulse(1);

		// *************
		// *** START ***
		// *************
		app_WhoWhere( 5, Gd_N_COM, 0x02 );
		app_START( 5, &ui_load );
		// *** CMD-buffer clear (for BroadCast) ***
		app_WhoWhere( 5, Gd_N_COM, 0x03 );
		dpu_getCommand( Guc_cmdDummy, &i_flag);
		
		if ( Guc_TLMm_enadis ) {
			// *****************
			// *** TLM: DPU2 ***
			// *****************
			if (Guc_dpuNo==1 || Guc_dpuRdn==2) {														// *** RDN: OK
i_flag = app_MONITOR( 3,         0,  ui_load2, & ui_load2 );		// **TMP**
				app_WhoWhere( 5, Gd_N_MSAS, 0x00 );	
				app14_MSASI    ( Gui_hkApp_counter[5] );
i_flag = app_MONITOR( 3, Gd_N_MSAS,  ui_load2, & ui_load2 );		// **TMP**
				app_WhoWhere( 5, Gd_N_EWO, 0x00 );	
				app14_EWO_CAL  ( Gui_hkApp_counter[5] );
				app_WhoWhere( 5, Gd_N_AM2P, 0x00 );	
				app14_AM2P     ( Gui_hkApp_counter[5] );
				app_WhoWhere( 5, Gd_N_EWO, 0x10 );	
				app14_EWO_WFC  ( Gui_hkApp_counter[5] );
i_flag = app_MONITOR( 3, Gd_N_EWO+1, ui_load2, & ui_load2 );		// **TMP**
			}
		}

		// *** APP STATUS ***
		app_WhoWhere( 5, Gd_N_COM, 0x0F );		
		app_END( 5, &ui_load );
   }
   dpu_WDTEna(0);		// WDT: DIS
   dpu_appStop();		// *** End ***
}