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


#include "FrmResourceF.h"
#pragma hdrstop

#include "VmsCommInfoF.h"

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

#pragma package(smart_init)

TVmsCtlr *FindVms(String ACtrlId)
{
    TVmsCtlr *pObj = NULL;

    VmsIterator it;
    for(it=VmsCtlrManager->FLists.FObjects.begin(); it != VmsCtlrManager->FLists.FObjects.end(); ++it)
    {
        TVmsCtlr *pTmpObj = (TVmsCtlr*)it->second;
        if (pTmpObj->VMS_CTLR_ID == ACtrlId)
        {
            pObj = pTmpObj;
            break;
        }
    }
    return pObj;
}
//---------------------------------------------------------------------------

String VmsOperMode(TVmsCtlr *AObj)
{
    if (AObj->OPER_MODE == "A") return FrmLang->lblOperA->Caption;//"자동";
    if (AObj->OPER_MODE == "B") return FrmLang->lblOperD->Caption;//"기본";
    return                             FrmLang->lblOperF->Caption;//"고정";
}
//---------------------------------------------------------------------------

String VmsComm(TVmsCtlr *AObj)
{
#if 0
    if (AObj->STATE.Comm == vms_comm_normal) return FrmLang->lblState0->Caption;//"정상";
    return                                          FrmLang->lblState1->Caption;//"장애";
#else
    if (AObj->STATE.Comm == vms_comm_normal) return "통신정상";
    return                                          "통신장애";
#endif
}
//---------------------------------------------------------------------------

String VmsModuleState(TVmsCtlr *AObj)
{
    if (AObj->STATE.Comm != vms_comm_normal) return "-";

#if 0
    if (AObj->STATE.ModuleState == vms_comm_normal) return FrmLang->lblState0->Caption;//"정상";
    if (AObj->STATE.ModuleState == vms_comm_normal) return FrmLang->lblState1->Caption;//"장애";
#else
    if (AObj->STATE.ModuleState == vms_comm_normal) return "모듈정상";
    if (AObj->STATE.ModuleState == vms_comm_normal) return "모듈장애";
#endif
    return "?";//"알수없음";
}
//---------------------------------------------------------------------------

String VmsModulePower(TVmsCtlr *AObj)
{
    if (AObj->STATE.Comm != vms_comm_normal) return "-";

#if 0
    if (AObj->STATE.ModulePowerStatus == vms_module_power_on ) return FrmLang->lblPOWER0->Caption;//"켜짐";
    if (AObj->STATE.ModulePowerStatus == vms_module_power_off) return FrmLang->lblPOWER1->Caption;//"꺼짐";
#else
    if (AObj->STATE.ModulePowerStatus == vms_module_power_on ) return "전원켜짐";
    if (AObj->STATE.ModulePowerStatus == vms_module_power_off) return "전원꺼짐";
#endif
    return "?";//"알수없음";
}
//---------------------------------------------------------------------------

String VmsModuleLuminance(TVmsCtlr *AObj)
{
    if (AObj->STATE.Comm != vms_comm_normal) return "-";
    int nLuminance = AObj->STATE.LuminanceStatus;
    return String(nLuminance);
}
//---------------------------------------------------------------------------

String VmsModuleDoor(TVmsCtlr *AObj)
{
    if (AObj->STATE.Comm != vms_comm_normal) return "-";

#if 0
    if (AObj->STATE.DoorStatus == vms_door_open ) return FrmLang->lblCDS1->Caption;//"열림";
    if (AObj->STATE.DoorStatus == vms_door_close) return FrmLang->lblCDS0->Caption;//"닫힘";
#else
    if (AObj->STATE.DoorStatus == vms_door_open ) return "문열림";
    if (AObj->STATE.DoorStatus == vms_door_close) return "문닫힘";
#endif
    return "?";//"알수없음";
}
//---------------------------------------------------------------------------

String VmsModuleFan(TVmsCtlr *AObj)
{
    if (AObj->STATE.Comm != vms_comm_normal) return "-";

#if 0
    if (AObj->STATE.FanStatus == vms_fan_on ) return FrmLang->lblFAN0->Caption;//"동작";
    if (AObj->STATE.FanStatus == vms_fan_off) return FrmLang->lblFAN1->Caption;//"정지";
#else
    if (AObj->STATE.FanStatus == vms_fan_on ) return "팬동작";
    if (AObj->STATE.FanStatus == vms_fan_off) return "팬정지";
#endif
    return "?";//"알수없음";
}
//---------------------------------------------------------------------------

String VmsModuleHeater(TVmsCtlr *AObj)
{
    if (AObj->STATE.Comm != vms_comm_normal) return "-";

#if 0
    if (AObj->STATE.HeaterStatus == vms_heater_on ) return FrmLang->lblHEAT0->Caption;//"가동";
    if (AObj->STATE.HeaterStatus == vms_heater_off) return FrmLang->lblHEAT1->Caption;//"중지";
#else
    if (AObj->STATE.HeaterStatus == vms_heater_on ) return "히터가동";
    if (AObj->STATE.HeaterStatus == vms_heater_off) return "히터중지";
#endif
    return "?";//"알수없음";
}
//---------------------------------------------------------------------------

String VmsModuleTemp(TVmsCtlr *AObj)
{
    if (AObj->STATE.Comm != vms_comm_normal) return "-";
    int nTemp = AObj->STATE.BodyTemp;
    //return String(nTemp)+"℃";
    return String(nTemp);
}
//---------------------------------------------------------------------------



