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

#ifndef NFA2DCameraSetting_FormH
#define NFA2DCameraSetting_FormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "CSPIN.h"
#include <ExtCtrls.hpp>
#include "TntExtCtrls.hpp"
#include "TntStdCtrls.hpp"
#include "TntForms.hpp"
#include "Environment.h"
#include <Buttons.hpp>
#include <Grids.hpp>

//---------------------------------------------------------------------------
#define ERROR_CODE_NONE         0
#define ERROR_CODE_ROI1         1
#define ERROR_CODE_ROI2         2
#define ERROR_CODE_IMAGE_MODE   3
//---------------------------------------------------------------------------

class TNFA2DCameraSettingForm : public TTntForm
{
__published:	// IDE-managed Components
	TTntPanel *SettingPanel;
	TTntLabel *Label2;
	TTntLabel *lblCameraID;
	TTntButton *ReadAllButton;
	TTntButton *WriteAllButton;
	TTntButton *SetDefaultButton;
	TTntButton *CloseButton;
  TTntLabel *TntLabel1;
  TCSpinEdit *cmdNFACameraData14;
  TTntLabel *TntLabel2;
  TTntLabel *TntLabel3;
  TTntComboBox *cmdNFACameraData1;
  TTntComboBox *cmdNFACameraData2;
  TTntLabel *TntLabel5;
  TTntLabel *TntLabel6;
  TCSpinEdit *cmdNFACameraData3;
  TTntLabel *TntLabel7;
  TTntLabel *TntLabel8;
  TCSpinEdit *cmdNFACameraData4;
  TTntLabel *TntLabel9;
  TTntLabel *TntLabel10;
  TCSpinEdit *cmdNFACameraData5;
  TTntLabel *TntLabel11;
  TTntLabel *TntLabel12;
  TCSpinEdit *cmdNFACameraData6;
  TTntLabel *TntLabel13;
  TTntLabel *TntLabel14;
  TTntLabel *TntLabel15;
  TCSpinEdit *cmdNFACameraData13;
  TTntLabel *TntLabel16;
  TCSpinEdit *cmdNFACameraData11;
  TTntLabel *TntLabel17;
  TTntLabel *TntLabel18;
  TTntLabel *TntLabel19;
  TCSpinEdit *cmdNFACameraData9;
  TTntLabel *TntLabel20;
  TTntLabel *TntLabel21;
  TCSpinEdit *cmdNFACameraData10;
  TTntLabel *TntLabel22;
  TTntLabel *TntLabel24;
  TTntComboBox *cmdNFACameraData15;
  TTntComboBox *cmdNFACameraData8;
  TTntLabel *TntLabel23;
  TTntComboBox *cmdNFACameraData16;
  TTntLabel *TntLabel25;
  TTntComboBox *cmdNFACameraData17;
  TGroupBox *GroupBox1;
  TEdit *SendPacketLengthEdit;
  TLabel *Label1;
  TLabel *Label3;
  TEdit *ReceivePacketLengthEdit;
  TStringGrid *SendPacketStringGrid;
  TStringGrid *ReceivePacketStringGrid;
  TLabel *Label4;
  TLabel *Label5;
  TBitBtn *SendTestPacketBtn;
  TGroupBox *GB;
  TSpeedButton *ReadOrWriteBtn1;
  TSpeedButton *ReadOrWriteBtn2;
  TSpeedButton *DataIndexBtn1;
  TSpeedButton *DataIndexBtn2;
  TSpeedButton *DataIndexBtn3;
  TSpeedButton *DataIndexBtn4;
  TSpeedButton *DataIndexBtn5;
  TSpeedButton *DataIndexBtn6;
  TSpeedButton *DataIndexBtn7;
  TSpeedButton *DataIndexBtn8;
  TSpeedButton *DataIndexBtn10;
  TSpeedButton *DataIndexBtn11;
  TSpeedButton *DataIndexBtn12;
  TSpeedButton *DataIndexBtn13;
  TBitBtn *BitBtn1;
  TSpeedButton *None1;
  TSpeedButton *None2;
  TRadioButton *ImageModeRB1;
  TRadioButton *ImageModeRB2;
  TTntLabel *TntLabel4;
  TCSpinEdit *cmdNFACameraData12;
  TSpeedButton *DataIndexBtn9;
  TTntLabel *TntLabel26;
  TCSpinEdit *cmdNFACameraData14_2;
  TCSpinEdit *cmdNFACameraData12_2;
  TCSpinEdit *cmdNFACameraData13_2;
  TCSpinEdit *cmdNFACameraData11_2;
  TTntLabel *TntLabel27;
  TTntButton *SaveToFlashBtn;
	void __fastcall NumSpinEditClick(TObject *Sender);
	void __fastcall SetDefaultButtonClick(TObject *Sender);
	void __fastcall CloseButtonClick(TObject *Sender);
  void __fastcall WriteAllButtonClick(TObject *Sender);
  void __fastcall ReadAllButtonClick(TObject *Sender);
  void __fastcall SendPacketLengthEditChange(TObject *Sender);
  void __fastcall ReceivePacketLengthEditChange(TObject *Sender);
  void __fastcall SendPacketLengthEditClick(TObject *Sender);
  void __fastcall ReceivePacketLengthEditClick(TObject *Sender);
  void __fastcall SendPacketStringGridSelectCell(TObject *Sender, int ACol,
          int ARow, bool &CanSelect);
  void __fastcall SendTestPacketBtnClick(TObject *Sender);
  void __fastcall SendPacketLengthEditKeyPress(TObject *Sender, char &Key);
  void __fastcall ReceivePacketLengthEditKeyPress(TObject *Sender,
          char &Key);
  void __fastcall Label2DblClick(TObject *Sender);
  void __fastcall BitBtn1Click(TObject *Sender);
  void __fastcall ReadOrWriteBtn1Click(TObject *Sender);
  void __fastcall SaveToFlashBtnClick(TObject *Sender);
private:	// User declarations
	int GlobalCameraIndex;
  int Data[MAX_2D_CAMERA_DATA_INDEX];

  bool UserSelect;
  bool bETCCamera;

  bool __fastcall             RequestCameraCommand(char *sendData, char *receivedData, unsigned int txDataLength, unsigned int rxDataLength);

  // NFA CAMERA
  TCommDataLength __fastcall  MakeCameraDataPacket(char *code, int dataIndex, bool bRead);
  unsigned char __fastcall    TxValueInterpreter(int dIndex);
  int  __fastcall             RxValueInterpreter(char data, int dIndex);
  void __fastcall             GetCameraValue(char *buff, int dIndex);
  void __fastcall             SetDefaultPacket(int SendPacketLength, bool bSend, int existDataSW, char *existedData);

  char __fastcall StrToHex(AnsiString aValue);

  WideString ErrorMsg[10];

public:		// User declarations
	__fastcall TNFA2DCameraSettingForm(TComponent* Owner);
  void __fastcall SetGlobalCameraIndex(int cameraIndex);

  int SelectedBoardID;
  int SelectedCameraID;
};
//---------------------------------------------------------------------------
extern PACKAGE TNFA2DCameraSettingForm *NFA2DCameraSettingForm;
//---------------------------------------------------------------------------
#endif
