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

#include <vcl.h>
#pragma hdrstop

#include "ThreeDSensorStatusCheck_Form.h"
#include "Environment.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "TntExtCtrls"
#pragma link "TntStdCtrls"
#pragma resource "*.dfm"
TThreeDSensorStatusCheckForm *ThreeDSensorStatusCheckForm;
//---------------------------------------------------------------------------
__fastcall TThreeDSensorStatusCheckForm::TThreeDSensorStatusCheckForm(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TThreeDSensorStatusCheckForm::ThreeDSensorCheckTimerTimer(
      TObject *Sender)
{
  if(Machine.Status.OperationState == MACHINE_STATE_STOP)
  {
    MachineStatusPanel->Caption = "STOP";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_RUN)
  {
    MachineStatusPanel->Caption = "RUN";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_CLEANING)
  {
    MachineStatusPanel->Caption = "CLEANING";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_ATTACHING)
  {
    MachineStatusPanel->Caption = "ATTACHING";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_DETACHING)
  {
    MachineStatusPanel->Caption = "DETACHING";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_STARTING)
  {
    MachineStatusPanel->Caption = "STARTING";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_STOPPING)
  {
    MachineStatusPanel->Caption = "STOPPING";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_WAIT_STOP)
  {
    MachineStatusPanel->Caption = "WAIT_STOP";
  }
  else if(Machine.Status.OperationState == MACHINE_STATE_EMERGENCY_STOP)
  {
    MachineStatusPanel->Caption = "EMG_STOP";
  }
  else
  {
    MachineStatusPanel->Caption = "Invalid Action(" + IntToStr(Machine.Status.OperationState) + ")";
  }

  if(Disk1ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_GOOD)
  {
    if(ThreeDSensorActiveStatus)
    {
      ThreeDCameraSensorActivePanel1->Caption = "O";
    }
    else
    {
      ThreeDCameraSensorActivePanel1->Caption = "X";
    }
  }
  else
  {
    ThreeDCameraSensorActivePanel1->Caption = "X";
  }

  if(Disk2ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_GOOD)
  {
    if(ThreeDSensorActiveStatus)
    {
      ThreeDCameraSensorActivePanel2->Caption = "O";
    }
    else
    {
      ThreeDCameraSensorActivePanel2->Caption = "X";
    }
  }
  else
  {
    ThreeDCameraSensorActivePanel2->Caption = "X";
  }

  if(Disk1ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_GOOD)
  {
    ThreeDCameraSensorErrorCodePanel1->Caption = "GOOD";
  }
  else if(Disk1ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_BRD_DISCONNECTED)
  {
    ThreeDCameraSensorErrorCodePanel1->Caption = "Brd Disconnected";
  }
  else if(Disk1ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_INVALID_MAPPING)
  {
    ThreeDCameraSensorErrorCodePanel1->Caption = "Invalid Mapping";
  }
  else if(Disk1ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_CAMERA_DISCONNECTED)
  {
    ThreeDCameraSensorErrorCodePanel1->Caption = "Cam Disconnected";
  }
  else
  {
    ThreeDCameraSensorErrorCodePanel1->Caption = "Unknown Error(" + IntToStr(Disk1ThreeDSensorErrorCode) + ")";
  }

  if(Disk2ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_GOOD)
  {
    ThreeDCameraSensorErrorCodePanel2->Caption = "GOOD";
  }
  else if(Disk2ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_BRD_DISCONNECTED)
  {
    ThreeDCameraSensorErrorCodePanel2->Caption = "Brd Disconnected";
  }
  else if(Disk2ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_INVALID_MAPPING)
  {
    ThreeDCameraSensorErrorCodePanel2->Caption = "Invalid Mapping";
  }
  else if(Disk2ThreeDSensorErrorCode == THREED_SENSOR_ERROR_CODE_CAMERA_DISCONNECTED)
  {
    ThreeDCameraSensorErrorCodePanel2->Caption = "Cam Disconnected";
  }
  else
  {
    ThreeDCameraSensorErrorCodePanel2->Caption = "Unknown Error(" + IntToStr(Disk2ThreeDSensorErrorCode) + ")";
  }

  if(RecentDisk1ThreeDCameraLSFValue != -1)
  {
    ThreeDCameraSensorLSFValuePanel1->Caption = IntToStr(RecentDisk1ThreeDCameraLSFValue);
    ThreeDCameraSensorRemarkPanel1->Caption = "Set";
  }
  else
  {
    ThreeDCameraSensorLSFValuePanel1->Caption = IntToStr(RANGER_3D_BASE_SHUTTER_SPEED);
    ThreeDCameraSensorRemarkPanel1->Caption = "Default";
  }

  if(RecentDisk2ThreeDCameraLSFValue != -1)
  {
    ThreeDCameraSensorLSFValuePanel2->Caption = IntToStr(RecentDisk2ThreeDCameraLSFValue);
    ThreeDCameraSensorRemarkPanel2->Caption = "Set";
  }
  else
  {
    ThreeDCameraSensorLSFValuePanel2->Caption = IntToStr(RANGER_3D_BASE_SHUTTER_SPEED2);
    ThreeDCameraSensorRemarkPanel2->Caption = "Default";
  }
}
//---------------------------------------------------------------------------
