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

#ifndef obrionH
#define obrionH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <dialogs.hpp>
#include <stdio.h>
#include <dos.h>
#include <dir.h>
#include <math.h>
#include "..\\main\\main.h"
#include "..\\monitoring\\monitoring.h"
#include "..\\telegram\\telegram.h"
#include <Menus.hpp>
#include <Dialogs.hpp>
#include <ComCtrls.hpp>
#include <Chart.hpp>
#include <Series.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
//---------------------------------------------------------------------------
class TIon : public TForm
{
__published:	// IDE-managed Components
        TRadioGroup *RadioGroup1;
        TImage *Image1;
        TPopupMenu *PopupColor;
        TMenuItem *N1;
        TMenuItem *N2;
        TColorDialog *ColorDialog1;
        TStatusBar *StatusBar1;
        TMenuItem *O1;
        TMenuItem *X1;
        TChart *Chart1;
        TLineSeries *Series1;
        TLineSeries *Series2;
        TLineSeries *Series3;
        TLineSeries *Series4;
        TButton *Button4;
        TLineSeries *Series5;
        TLineSeries *Series6;
        TButton *Button10;
        TMemo *Memo1;
        TButton *Button11;
        TButton *Button1;
        TGroupBox *GroupBox1;
        TLabel *Label1;
        TLabel *Label2;
        TLabel *Label3;
        TLabel *Label4;
        TLabel *Label5;
        TLabel *Label6;
        TLabel *Label8;
        TLabel *Label9;
        TLabel *Label10;
        TLabel *Label11;
        TLabel *Label12;
        TLabel *Label13;
        TLabel *Label7;
        TLabel *Label14;
        TLabel *Label15;
        TRadioGroup *RadioGroup2;
        TEdit *Edit1;
        TEdit *Edit2;
        TEdit *Edit3;
        TEdit *Edit4;
        TEdit *Edit5;
        TEdit *Edit6;
        TEdit *Edit8;
        TEdit *Edit9;
        TEdit *Edit10;
        TEdit *Edit11;
        TEdit *Edit13;
        TEdit *Edit7;
        TEdit *Edit12;
        TEdit *Edit14;
        TEdit *Edit15;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall N2Click(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall N1Click(TObject *Sender);
        void __fastcall O1Click(TObject *Sender);
        void __fastcall X1Click(TObject *Sender);
        void __fastcall Image1MouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
        void __fastcall Button4Click(TObject *Sender);
        void __fastcall Image1MouseDown(TObject *Sender,
          TMouseButton Button, TShiftState Shift, int X, int Y);
        void __fastcall Image1MouseUp(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
        void __fastcall Image1DblClick(TObject *Sender);
        void __fastcall Button10Click(TObject *Sender);
        void __fastcall Button11Click(TObject *Sender);
        void __fastcall Button1Click(TObject *Sender);
private:	// User declarations
        float Uhod[3], B, StB[3];
        int Xx[1000], Ymin[1000], Ymax[1000];
        int plot[1000][500];
        void Sglash(float *x, int n, int p);
        int X0, Y0, MX, MY, BX, BY;
public:		// User declarations
        float Ak[2][1000][500], Aki[2][1000][500];
        float Ampl[8][1000][500], Faz[8][1000][500], DtFaz[8][1000][500];
        float SAmpl[1000][500], DpFaz[4][4][1000][500];
        float I[8][1000][500],Q[8][1000][500];
        TColor clFon, clIon, clO, clX;
        int RC, GC, BC;
        void rgbColor(TColor cl);
        void WriteIonPar(void);
        void ReadIonPar(void);
        void Setka(void);
        void SaveIon(int year, int mon, int day, int hour, int min, int sec);
        void ReadIQ(void);
        void PlotnostY(void);
        void AkToAki(int x1, int y1, int x2, int y2);
        void Sleds(void);
        void OprAkX(int x1, int y1, int x2, int y2);
        void IzobrIon(void);
        void InitIon(void);
        void RashetIon(int x1, int y1, int x2, int y2);
                struct ion_head {
//               unsigned char st;	      // Station  <IZMIRAN=0>
                 short f_str,             // ORIGN FREQUENCY
                       f_stp,             // STEP FREQUENCY
                       f_fin,             // Final frequency
                       samples,           // Sampling time
                       scale;             // Scale type & points
                                        // Format: <S_ppppppppppppp>
                                        //      S=0 -> line
                                        //      S=1 -> log
                char sec,               // Seconds
                     min,               // Minutes
                     hr,                // Hours
                     data,              // Data
                     mon,               // Month
                     yr;                // Year
       unsigned char fr,                // Rept_freq (HZ)
                     an,                // Ant_type &
                                        //     polarisation flag &
                                        //        Doppler flag &
                                        //         number of pulses
                                        // Format: <AAPDnnnn>
                     ka,                // Attenuation
                                        // Flags of configuration:
                     p_len,             // Pulse length (n*50 Mks)
                     power,             // Transmitter power n Kwt
                     ch_r,              //
                     ver;               // Version of program
               short reserv0,           // etc
                     reserv1,
                     reserv2,
		     reserv3;
          } ion_head;
        __fastcall TIon(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TIon *Ion;
//---------------------------------------------------------------------------
#endif
