//---------------------------------------------------------------------------

#include <vcl.h>
#include "AppGlobalF.h"
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "FrmVmsOprMainF.h"
#include "CenterCommF.h"
#include "ITSLangTransF.h"
#pragma hdrstop

#include "FRAME_VmsStatusF.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFRAME_VmsStatus *FRAME_VmsStatus;
//---------------------------------------------------------------------------
__fastcall TFRAME_VmsStatus::TFRAME_VmsStatus(TComponent* Owner)
    : TFrame(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFRAME_VmsStatus::LoadLocalSkin()
{
    PnlDoor->ParentColor = false;
    PnlFan->ParentColor = false;
    PnlHeater->ParentColor = false;
    PnlModule->ParentColor = false;
    PnlPower->ParentColor = false;
    PnlTemp->ParentColor = false;
    PnlOprMode->ParentColor = false;
}
//---------------------------------------------------------------------------

void __fastcall TFRAME_VmsStatus::RefreshStatus(TVmsCtlr *AObj)
{
    TVmsCtlr *FVmsObj = AObj;

    PnlDoor->Caption    = VmsModuleDoor(FVmsObj);     //도어
    PnlFan->Caption     = VmsModuleFan(FVmsObj);      //팬
    PnlHeater->Caption  = VmsModuleHeater(FVmsObj);   //히터
    PnlModule->Caption  = VmsModuleState(FVmsObj);    //모듈상태
    PnlPower->Caption   = VmsModulePower(FVmsObj);    //전원상태
    PnlTemp->Caption    = VmsModuleTemp(FVmsObj);     //온도
    PnlOprMode->Caption = VmsOperMode(FVmsObj);

    TColor clrState = clLime;

    //운영모드
#if 0
    if (FVmsObj->OPER_MODE != "A")
    {
        clrState = clYellow;
    }
#else
    String sVmsMode = PnlOprMode->Caption;
#if 0
    if      (sVmsMode == "자동") clrState = clLime;
    else if (sVmsMode == "고정") clrState = clFuchsia;
    else                         clrState = clYellow;
#else
    if      (sVmsMode == FrmLang->lblOperA->Caption) clrState = clLime;
    else if (sVmsMode == FrmLang->lblOperF->Caption) clrState = clFuchsia;
    else                                             clrState = clYellow;
#endif
#endif
    if (PnlOprMode->Color != clrState) PnlOprMode->Color = clrState;

    if (FVmsObj->STATE.Comm != vms_comm_normal)
    {
        PnlDoor->Color   = clGray;  //도어
        PnlFan->Color    = clGray;  //팬
        PnlHeater->Color = clGray;  //히터
        PnlModule->Color = clGray;  //모듈상태
        PnlPower->Color  = clGray;  //전원상태
        PnlTemp->Color   = clGray;  //온도
        return;
    }

    //모듈전원상태
    clrState = clLime;
    if (FVmsObj->STATE.ModulePowerStatus == vms_module_power_off)
        clrState = clRed;
    if (FVmsObj->STATE.ModulePowerStatus == vms_module_power_unknown)
        clrState = clGray;
    if (PnlPower->Color != clrState) PnlPower->Color = clrState;

#if 0
    //모듈상태 - 싸인텔레콤은 사용안함
    clrState = clLime;
    if (FVmsObj->STATE.ModuleState == vms_comm_error)
        clrState = clRed;
    if (PnlModule->Color != clrState) PnlModule->Color = clrState;
#endif

    //도어상태
    clrState = clLime;
    if (FVmsObj->STATE.DoorStatus == vms_door_open)
        clrState = clRed;
    if (FVmsObj->STATE.DoorStatus == vms_door_unknown)
        clrState = clGray;
    if (PnlDoor->Color != clrState) PnlDoor->Color = clrState;

    //팬상태
    clrState = clLime;
    if (FVmsObj->STATE.FanStatus == vms_fan_on)
        clrState = clYellow;
    if (PnlFan->Color != clrState) PnlFan->Color = clrState;

    //히터상태
    clrState = clLime;
    if (FVmsObj->STATE.HeaterStatus == vms_heater_on)
        clrState = clYellow;
    if (FVmsObj->STATE.HeaterStatus == vms_heater_unknown)
        clrState = clGray;
    if (PnlHeater->Color != clrState) PnlHeater->Color = clrState;

    //온도
    clrState = clLime;
    if (PnlTemp->Color != clrState) PnlTemp->Color = clrState;
}
//---------------------------------------------------------------------------

