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

#ifndef MAINH
#define MAINH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <vcl\Registry.hpp>
#include "Serial.h"
#include <Menus.hpp>
#include <ExtCtrls.hpp>

#define Read_Coils              0x01
#define Read_Discrete_Inputs    0x02
#define Diagnostics             0x08
#define Get_Comm_Event_Counter  0x0B
#define Write_Multiple_Coils    0x0F
#define Read_Device_Identification      0x2B
#define MEI     0x0E

#define Button_Events   0x66       //User Defined Function
#define Cyclic_Read     0x67       //User Defined Function
#define Read_AD         0x68       //User Defined Function
#define Write_DA        0x69       //User Defined Function
//dignostika
#define Restart_Communications_Option   0x01
#define Clear_Counters           0x0A
#define Return_Bus_Message_Count 0x0B
#define Return_Bus_Communication_Error_Count    0x0C
#define Return_Bus_Exception_Error_Count        0x0D
#define Return_Slave_Message_Count              0x0E
#define Return_Slave_No_Response_Count          0x0F
#define Return_Bus_Character_Overrun_Count      0x12

//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published:	// IDE-managed Components
        TMainMenu *MainMenu1;
        TMenuItem *Nastaveni;
        TButton *Button1;
        TPanel *Panel1;
        TLabel *Label4;
        TLabel *Label5;
        TLabel *Label6;
        TLabel *Label7;
        TLabel *Label8;
        TLabel *Label9;
        TLabel *Label10;
        TLabel *Label13;
        TLabel *Label14;
        TButton *Button2;
        TButton *Button3;
        TPanel *Panel2;
        TPanel *Panel3;
        TPanel *Panel4;
        TLabel *Label3;
        TScrollBar *ScrollBar1;
        TLabel *Label15;
        TLabel *Label16;
        TTimer *Timer1;
        TButton *Button4;
        TButton *Button5;
        TButton *Button6;
        TLabel *Label1;
        TCheckBox *CheckBox1;
        TCheckBox *CheckBox2;
        TCheckBox *CheckBox3;
        TCheckBox *CheckBox4;
        TCheckBox *CheckBox5;
        TCheckBox *CheckBox6;
        TCheckBox *CheckBox7;
        TCheckBox *CheckBox8;
        TButton *Button7;
        TLabel *Label25;
        TLabel *Label26;
        TLabel *Label27;
        TLabel *Label28;
        TLabel *Label29;
        TLabel *Label30;
        TLabel *Label31;
        TLabel *Label32;
        TPanel *Panel5;
        TLabel *Label33;
        TLabel *Label34;
        TLabel *Label35;
        TLabel *Label36;
        TLabel *Label37;
        TLabel *Label38;
        TLabel *Label39;
        TLabel *Label40;
        TLabel *Label41;
        TCheckBox *CheckBox9;
        TCheckBox *CheckBox10;
        TCheckBox *CheckBox11;
        TCheckBox *CheckBox12;
        TCheckBox *CheckBox13;
        TCheckBox *CheckBox14;
        TCheckBox *CheckBox15;
        TCheckBox *CheckBox16;
        TButton *Button9;
        TLabel *Label2;
        TLabel *Label42;
        TPanel *Panel6;
        TLabel *Label43;
        TLabel *Label44;
        TLabel *Label45;
        TLabel *Label46;
        TScrollBar *ScrollBar2;
        TButton *Button10;
        TLabel *Label47;
        TLabel *Label48;
        TButton *Button12;
        TMenuItem *S1;
        TMenuItem *Konec1;
        TTimer *Timer2;
        TButton *Button8;
        TLabel *Label11;
        TComboBox *ComboBox1;
        TLabel *Label17;
        TLabel *Label18;
        TLabel *Label19;
        TLabel *Label20;
        TLabel *Label21;
        TLabel *Label22;
        TLabel *Label23;
        TLabel *Label24;
        TLabel *Label51;
        TLabel *Label50;
        TLabel *Label49;
        TLabel *Label12;
        TLabel *Label52;
        TLabel *Label53;
        TLabel *Label54;
        TLabel *Label55;
        TLabel *Label56;
        TLabel *Label57;
        TLabel *Label58;
        TLabel *Label59;
        TLabel *Label60;
        TLabel *Label61;
        TLabel *Label62;
        TLabel *Label63;
        TLabel *Label64;
        TLabel *Label65;
        TLabel *Label66;
        TLabel *Label67;
        TLabel *Label68;
        TLabel *Label69;
        TLabel *Label70;
        TLabel *Label71;
        TLabel *Label72;
        TLabel *Label73;
        TLabel *Label74;
        TLabel *Label75;
        TLabel *Label76;
        TLabel *Label77;
        TLabel *Label78;
        TLabel *Label79;
        TLabel *Label80;
        TLabel *Label81;
        TLabel *Label82;
        TLabel *Label83;
        TLabel *Label84;
        TLabel *Label85;
        TLabel *Label86;
        TPanel *Panel7;
        TLabel *Label87;
        TButton *Button13;
        TLabel *Label88;
        TLabel *Label89;
        TButton *Button11;
        TButton *Button14;
        TLabel *Label90;
        TButton *Button15;
        TButton *Button16;
        TButton *Button17;
        TButton *Button18;
        TButton *Button19;
        TLabel *Label91;
        TLabel *Label92;
        TLabel *Label93;
        TLabel *Label94;
        TLabel *Label95;
        TLabel *Label96;
        TButton *Button20;
        TButton *Button21;
        TLabel *Label97;
        TLabel *Label98;
        TLabel *Label99;
        void __fastcall NastaveniClick(TObject *Sender);
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall Button3Click(TObject *Sender);
        void __fastcall Button4Click(TObject *Sender);
        void __fastcall Button5Click(TObject *Sender);
        void __fastcall Button6Click(TObject *Sender);
        void __fastcall Button7Click(TObject *Sender);
        void __fastcall Button8Click(TObject *Sender);
        void __fastcall Button9Click(TObject *Sender);
        void __fastcall ScrollBar1Change(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall Button12Click(TObject *Sender);
        void __fastcall Timer2Timer(TObject *Sender);
        void __fastcall ComboBox1Change(TObject *Sender);
        void __fastcall Button10Click(TObject *Sender);
        void __fastcall Konec1Click(TObject *Sender);
        void __fastcall Button13Click(TObject *Sender);
        void __fastcall Button14Click(TObject *Sender);
        void __fastcall Button11Click(TObject *Sender);
        void __fastcall Button15Click(TObject *Sender);
        void __fastcall Button16Click(TObject *Sender);
        void __fastcall Button17Click(TObject *Sender);
        void __fastcall Button18Click(TObject *Sender);
        void __fastcall Button19Click(TObject *Sender);
        void __fastcall Button20Click(TObject *Sender);
        void __fastcall Button21Click(TObject *Sender);

private:	// User declarations
        int ReadIntervalTimeout,BaudRate,ByteSize,
        ReadTotalTimeoutMultiplier,ReadTotalTimeoutConstant,
        WriteTotalTimeoutMultiplier,WriteTotalTimeoutConstant;
public:		// User declarations
        __fastcall TMainForm(TComponent* Owner);
        __fastcall ~TMainForm();
        TSerial *Serial;
        TConfigPanel    *cp;
        AnsiString Adresar;
        int CisloPortu,Parita,Pocetbitu;
        unsigned char modbus_adresa;
        unsigned char TX_DATA[256];
        unsigned char RX_DATA[256];
        byte DA1_value1,DA1_value2;
        byte DA2_value1,DA2_value2;
};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif
 