#ifndef _DATADESC_H_
#define _DATADESC_H_

#include "data.h"
#include "control.h"

#define TERMINAL_PROTOCOL_TTK2  0
#define TERMINAL_PROTOCOL_VTK   1

#define PRETEXT_LINE_COUNT 4

#define INCAS_SEND_FLAG     0x87654321

#define MAX_PRICE 9999

#define DEFAULT_PASSWORD 1111

#if defined(BOARD_SOLARIUM_WEB)
    #define MASTER_PASSWORD 7051UL
#else
    #define MASTER_PASSWORD 1234567890UL
#endif

#define MONEY_KEY_COUNT     8

// ��������� ������������ �������
typedef struct{
  // ��������� ������
  CPU_INT32U  Enable[CHANNELS_NUM];
  // ����-��� ����� ����������, ���.
  CPU_INT32U  TimeOutBefore[CHANNELS_NUM];
  // ����-��� ����� ����������, ���.
  CPU_INT32U  TimeOutAfter[CHANNELS_NUM];
  // ������������ ����� ������, ���.
  CPU_INT32U  MaxWorkTime[CHANNELS_NUM];
  // ����������� ����� ������, ���.
  CPU_INT32U  MinWorkTime[CHANNELS_NUM];
  // ��������� �������, ������
  CPU_INT32U  WeekEnd[CHANNELS_NUM];
    #define WEEKEND_NO                0
    #define WEEKEND_FRIDAY_SUNDAY     1
    #define WEEKEND_SATURDAY_SUNDAY   2
    #define WEEKEND_FRIDAY_SATURDAY   3
    #define WEEKEND_FRIDAY_MONDAY     4
  // �������� ������
  CPU_INT32U  Name[CHANNELS_NUM];
  
  // �������
    #define PRICE_PERIODS_NUM   4
  CPU_INT32U  T_Start_Weekdays[CHANNELS_NUM][PRICE_PERIODS_NUM];
  CPU_INT32U  T_End_Weekdays[CHANNELS_NUM][PRICE_PERIODS_NUM];
  CPU_INT32U  T_Start_Weekend[CHANNELS_NUM][PRICE_PERIODS_NUM];
  CPU_INT32U  T_End_Weekend[CHANNELS_NUM][PRICE_PERIODS_NUM];
  // ����
  CPU_INT32U  Price_Weekdays[CHANNELS_NUM][PRICE_PERIODS_NUM];
  CPU_INT32U  Price_Weekend[CHANNELS_NUM][PRICE_PERIODS_NUM];
  CPU_INT32U  PriceTime_Weekdays[CHANNELS_NUM][PRICE_PERIODS_NUM];
  CPU_INT32U  PriceTime_Weekend[CHANNELS_NUM][PRICE_PERIODS_NUM];

  CPU_INT32U  post_ip[CHANNELS_NUM];
  CPU_INT32U  select_protect[CHANNELS_NUM];
  CPU_INT32U  imp_len[CHANNELS_NUM];
  CPU_INT32U  pause_len[CHANNELS_NUM];
  CPU_INT32U  imp_cost[CHANNELS_NUM];
  CPU_INT32U  minute_cost[CHANNELS_NUM];
  CPU_INT32U  pause[CHANNELS_NUM];
  CPU_INT32U  timer[CHANNELS_NUM];
  CPU_INT32U  signal[CHANNELS_NUM];

  
}TChannelConfig;



// ��������� ������������ ����������
typedef struct{
  CPU_INT32U  EnableValidator;
  CPU_INT32U  EnableCoinAcceptor;
  CPU_INT32U  EnableAbonementAcceptor;
  CPU_INT32U  CountUseAbonement;
  CPU_INT32U  EnableModem;
  CPU_INT32U  EnableFiscal;
  CPU_INT32U  EnableFiscalDayClear;
  CPU_INT32U  ServiceName;

  CPU_INT32U  CoinPerPulse; // ���� �������� ���������������
  CPU_INT32U  BillFormat;
  
  CPU_INT32U  DisableFiscalErrors; // ���������� ������� �� ������ ��
  
  CPU_INT32U  EnableEmailErrorSend;
  CPU_INT32U  EnableEmailStatSend;
  CPU_INT32U  EnableEmailJournalSend;
  CPU_INT32U  ClearJournalAfterSend;
  CPU_INT32U  StatSendHourMin;
  
  CPU_INT32U  DeviceId;
  CPU_INT32U  EnablePrintReports;

  CPU_INT32U  terminal_ip;
  CPU_INT32U  terminal_port;
  CPU_INT32U  terminal_enable;
  CPU_INT32U  terminal_money_table[MONEY_KEY_COUNT];
  CPU_INT32U  key_action[MONEY_KEY_COUNT];
      
}TDeviceConfig;


extern CPU_INT32U PeriodIndex;
extern CPU_INT32U  ChannelIndex;
extern CPU_INT32U file_menu_cmd;

extern TDataDescStruct const DeviceIDDesc;
extern TDataDescStruct const LastEmailSendTime;
extern TDataDescStruct const ChannelIndexDesc;
extern TDataDescStruct const EnableChannelDesc;
extern TDataDescStruct const TimeOutBeforeDesc;
extern TDataDescStruct const TimeOutAfterDesc;
extern TDataDescStruct const MaxWorkTimeDesc;
extern TDataDescStruct const MinWorkTimeDesc;
extern TDataDescStruct const WeekEndDesc;
extern TDataDescStruct const DeferredStartDesc;

extern TDataDescStruct const PeriodWeekendIndexDesc;
extern TDataDescStruct const PeriodWeekdaysIndexDesc;
extern TDataDescStruct const ServiceNameDesc;
extern TDataDescStruct const PassDesc;
extern TDataDescStruct const PassCRCDesc;
extern TDataDescStruct const PassTempDesc;
extern CPU_INT32U TempPass;
extern TDataDescStruct const PassTempDesc1;
extern TDataDescStruct const PassTempDesc2;

extern TDataDescStruct const PriceWeekendDesc;
extern TDataDescStruct const PriceWeekdaysDesc;
extern TDataDescStruct const PriceTimeWeekendDesc;
extern TDataDescStruct const PriceTimeWeekdaysDesc;
extern TDataDescStruct const T_Start_WeekdaysDesc;
extern TDataDescStruct const T_End_WeekdaysDesc;
extern TDataDescStruct const T_Start_WeekendDesc;
extern TDataDescStruct const T_End_WeekendDesc;

extern TDataDescStruct const EnableFiscalDesc;
extern TDataDescStruct const EnableCoinDesc;
extern TDataDescStruct const EnableAbonementDesc;
extern TDataDescStruct const CountUseAbonementDesc;
extern TDataDescStruct const ClearStatAbonementCmdDesc;
extern TDataDescStruct const AbonementCounterIndexDesc;
extern TDataDescStruct const EnableModemDesc;
extern TDataDescStruct const EnableValidatorDesc;
extern TDataDescStruct const CoinPerPulseDesc;
extern TDataDescStruct const EnableFiscalDayClearDesc;

extern TDataDescStruct const InitByDefaultDesc;
extern TDataDescStruct const PrintZReportDesc;
extern TDataDescStruct const PrintXReportDesc;

extern TDataDescStruct const EventJournalIndexDesc; 
extern TDataDescStruct const JournalEventTimeDesc;

extern TDataDescStruct const JournalErrorNumberDesc0;
extern TDataDescStruct const JournalErrorNumberDesc1;
extern TDataDescStruct const ClearJournalCmdDesc;


extern TDataDescStruct const SystemTimeDesc;
extern TDataDescStruct const SystemTimeEditDesc;

extern const TDataDescArrayStruct AllDataArray[];

extern CPU_INT32U ErrorJournalIndex;
extern CPU_INT32U EventJournalIndex;

extern TDataDescStruct const CounterRunDesc;
extern TDataDescStruct const CounterMoneyDesc;
extern TDataDescStruct const CounterTimeDesc;
extern TDataDescStruct const CounterChannelRunDesc;
extern TDataDescStruct const CounterChannelMoneyDesc;
extern TDataDescStruct const CounterChannelAbonementDesc;
extern TDataDescStruct const CounterChannelTimeDesc;
extern TDataDescStruct const ChannelStIndexDesc;
extern TDataDescStruct const ClearStatCmdDesc;
extern TDataDescStruct const BillFormatDesc;
extern TDataDescStruct const NameChannelDesc;

extern TDataDescStruct const AcceptedMoneyDesc;
extern TDataDescStruct const AcceptedMoneyCRC16Desc;

extern TDataDescStruct const DisableFiscalErrorsDesc;

extern TDataDescStruct const StartButtonNameDesc;

extern TDataDescStruct const EnableEmailErrorSendDesc;
extern TDataDescStruct const EnableEmailJournalSendDesc;
extern TDataDescStruct const ClearJournalAfterSendDesc;
extern TDataDescStruct const StatSendPeriodDesc;
extern TDataDescStruct const JournalErrorNumberDescEng;
extern TDataDescStruct const SendTestEmailDesc;
extern TDataDescStruct const ModemStatusDesc;

extern TDataDescStruct const BillnomIndexDesc;
extern TDataDescStruct const BillnomDesc;
extern TDataDescStruct const BillnomCountersDesc;
extern TDataDescStruct const BillCounterDesc;

extern TDataDescStruct const CounterLongRunDesc;
extern TDataDescStruct const CounterLongMoneyDesc;
extern TDataDescStruct const CounterLongTimeDesc;

extern TDataDescStruct const MasterPassTempDesc;

extern TDataDescStruct const CounterChannelRunLongDesc;
extern TDataDescStruct const CounterChannelMoneyLongDesc;
extern TDataDescStruct const CounterChannelTimeLongDesc;
extern TDataDescStruct const ChannelStLongIndexDesc;

extern TDataDescStruct const StatSendHourMinDesc;
extern TDataDescStruct const IncasSendFlagDesc;
extern TDataDescStruct const IncasMoneyDesc;
extern TDataDescStruct const IncasTimeDesc;

extern TDataDescStruct const GatewayDesc;
extern TDataDescStruct const NetMaskDesc;
extern TDataDescStruct const IpAddrDesc;

extern TDataDescStruct const PostIpAddrDesc;
extern TDataDescStruct const SelectProtectDesc;
extern TDataDescStruct const PostImpCostDesc;
extern TDataDescStruct const PostLenCostDesc;
extern TDataDescStruct const PostMinutePriceDesc;
extern TDataDescStruct const PostPauseDesc;

extern TDataDescStruct const EnablePrintReportsDesc;
extern TDataDescStruct const TerminalIpAddrDesc;
extern TDataDescStruct const TerminalPortDesc;
extern TDataDescStruct const EnableTerminalDesc;
extern TDataDescStruct const SelectedMoneyDesc;
extern TDataDescStruct const KeyMoneyDesc;

extern TDataDescStruct const MakeSverkaDesc;
extern TDataDescStruct const MakeSyncDesc;

extern TDataDescStruct const CounterChannelCardDesc;
extern TDataDescStruct const CounterCardDesc;
extern TDataDescStruct const CounterAbonementDesc;
extern TDataDescStruct const CounterChannelCardLongDesc;
extern TDataDescStruct const CounterChannelAbonementLongDesc;
extern TDataDescStruct const CounterLongCardDesc;
extern TDataDescStruct const CounterLongAbonementDesc;

extern int ReadPrecheckText(char *buf, int i);
extern void OnChangeInitByDefault(void);
extern TDataDescStruct const KeyActionDesc;
extern void OnChangeKeyAction();
extern void CheckKeysCorrect();
extern void InitPrecheckText();

extern TDataDescStruct const PostTimerDesc;
extern TDataDescStruct const PostSignalDesc;
extern TDataDescStruct const TaxFormatDesc;
extern TDataDescStruct const SubjSellDesc;
extern TDataDescStruct const CommandV2Desc;
extern TDataDescStruct const TaxSystemDesc;

extern CPU_INT32U PostStatus[CHANNELS_NUM];
extern TDataDescStruct const PostIpStatusDesc;
extern TDataDescStruct const SolariumTypeDesc;
extern TDataDescStruct const SolariumTimeoutDesc;
extern TDataDescStruct const SolariumPauseDesc;
extern TDataDescStruct const SolariumVentilationTimeDesc;
extern TDataDescStruct const SolariumPricePerMinDesc;
extern TDataDescStruct const SolariumMinTimeDesc;
extern TDataDescStruct const SolariumMaxTimeDesc;
extern TDataDescStruct const ZummerEnableDesc;
extern void OnZummerEnabledChange(void);
extern TDataDescStruct const SoundTypeDesc;
extern TDataDescStruct const PlayerStatusDesc;
extern TDataDescStruct const SdCardStatusDesc;
extern TDataDescStruct const SoundVolumeDesc;
extern TDataDescStruct const SoundFileIndexDesc;
extern TDataDescStruct const SolariumModesDesc;
extern TDataDescStruct const SolarLampsCountDesc;
extern TDataDescStruct const SolarPricePerMinuteDesc;
extern TDataDescStruct const SolarMaximumTimeMinutesDesc;
extern TDataDescStruct const SolarMinimumTimeMinutesDesc;
extern TDataDescStruct const SolarVentilationTimeMinutesDesc;
extern TDataDescStruct const SolarTimeoutBeforeMinutesDesc;
extern TDataDescStruct const DiscountIndexHourDesc;
extern TDataDescStruct const DiscountBeginHourDesc;
extern TDataDescStruct const DiscountEndHourDesc;
extern TDataDescStruct const DiscountValueHourDesc;
extern TDataDescStruct const DiscountIndexDayDesc;
extern TDataDescStruct const DiscountValueDayDesc;
extern TDataDescStruct const DiscountIndexMonthDesc;
extern TDataDescStruct const DiscountValueMonthDesc;
extern TDataDescStruct const DiscountIndexCustomDesc;
extern TDataDescStruct const DiscountValueCustomDesc;
extern TDataDescStruct const DiscountDateBeginCustomDesc;
extern TDataDescStruct const DiscountDateEndCustomDesc;
extern TDataDescStruct const DiscountValueCurrentDesc;
extern TDataDescStruct const TerminalProtocolDesc;
extern TDataDescStruct const PostPauseLenCostDesc;
extern TDataDescStruct const ScoreIndexDesc;
extern TDataDescStruct const ScoreRs485SpeedDesc;
extern TDataDescStruct const ScoreRs485AddressDesc;
extern TDataDescStruct const ScoreCommandDesc;
extern TDataDescStruct const ScoreStateDesc;
extern TDataDescStruct const ScoreEnableDesc;
extern TDataDescStruct const RelayIndexDesc;
extern TDataDescStruct const RelayEnableDesc;
extern TDataDescStruct const RelayIpAddrDesc;
extern TDataDescStruct const RelayChannelDesc;
extern TDataDescStruct const RelayOpenTimeDesc;
extern TDataDescStruct const RelayCommandDesc;
extern TDataDescStruct const SolariumTimePayedDesc;
extern TDataDescStruct const SolariumMoneyPayedDesc;
extern TDataDescStruct const SolariumTimePayedCrc16Desc;
extern TDataDescStruct const SolarTimeoutAfterMinutesDesc;
extern TDataDescStruct const SolarControlChannelDesc;
extern TDataDescStruct const CounterSolarMoneyDesc;
extern TDataDescStruct const CounterSolarCardMoneyDesc;
extern TDataDescStruct const CounterSolarCardBonusDesc;
extern TDataDescStruct const CounterSolarRunsDesc;
extern TDataDescStruct const CounterSolarWorkTimeDesc;
extern TDataDescStruct const SolariumModeIndexDesc;
extern TDataDescStruct const CounterModeMoneyDesc;
extern TDataDescStruct const CounterModeCardMoneyDesc;
extern TDataDescStruct const CounterModeCardBonusDesc;
extern TDataDescStruct const CounterModeRunsDesc;
extern TDataDescStruct const CounterModeWorkTimeDesc;
extern TDataDescStruct const CounterCollatenTimeDesc;
extern TDataDescStruct const CounterUFTimeDesc;
extern TDataDescStruct const CounterCommonMoneyDesc;
extern TDataDescStruct const CounterCashMoneyDesc;
extern TDataDescStruct const CounterCardMoneyDesc;
extern TDataDescStruct const CounterAbonementMoneyDesc;
extern TDataDescStruct const SolarCurrentPricePerMinuteDesc;
extern TDataDescStruct const SolarCurrentPricePerMinuteForViewDesc;
extern TDataDescStruct const ScoreColumnDesc;
extern TDataDescStruct const SkinTypeIndexDesc;
extern TDataDescStruct const SkinCollatenMaxTimeDesc;
extern TDataDescStruct const SkinUFMaxTimeDesc;
extern TDataDescStruct const SkinMaximalMaxTimeDesc;
extern TDataDescStruct const EnableGlobalPassDesc;
extern TDataDescStruct const CoinPulseLenDesc;
extern TDataDescStruct const CoinPulseDeltaDesc;
extern TDataDescStruct const CoinPauseLenDesc;
extern TDataDescStruct const FtpServerIpAddrDesc;
extern TDataDescStruct const FtpEnableDesc;
extern TDataDescStruct const FtpSendHourMinDesc;
extern TDataDescStruct const FtpSendIntervalDesc;
extern TDataDescStruct const FtpLastSendTimeDesc;
extern TDataDescStruct const FtpLastSendResultDesc;
extern TDataDescStruct const FtpSendNowCmdDesc;
extern TDataDescStruct const FtpDeviceNumberDesc;
extern TDataDescStruct const FtpServerLoginDesc;
extern TDataDescStruct const FtpServerPassDesc;
extern TDataDescStruct const SoundIpAddrDesc;
extern TDataDescStruct const PassDescAdmin;
extern TDataDescStruct const PassDescCleaning;
extern TDataDescStruct const PassDescService;
extern TDataDescStruct const PassDescTest;
extern TDataDescStruct const PassVladCrc;
extern TDataDescStruct const CounterCleaningTimeDesc;
extern TDataDescStruct const CounterCleaningCountDesc;
extern TDataDescStruct const CounterCleaningMeanTimeDesc;
extern TDataDescStruct const CounterSolarTestRunsDesc;
extern TDataDescStruct const CounterModeTestRunsDesc;
extern TDataDescStruct const CounterSolarTestWorkTimeDesc;
extern TDataDescStruct const CounterModeWorkTestTimeDesc;
extern TDataDescStruct const CounterUFTestCountDesc;
extern TDataDescStruct const CounterAllTestTimeDesc;
extern TDataDescStruct const CounterAllTestCountDesc;
extern TDataDescStruct const CounterTestMeanTimeDesc;
extern TDataDescStruct const SolarCleaningTimeoutMinutesDesc;
extern TDataDescStruct const AbonementIndexDesc;
extern TDataDescStruct const AbonementMoneyDesc;
extern TDataDescStruct const AbonementBonusDesc;
extern TDataDescStruct const AbonementBestBeforeDesc;
extern TDataDescStruct const CounterMoneyAbonementDesc;
extern TDataDescStruct const CounterBonusAbonementDesc;
extern TDataDescStruct const CounterRunsAbonementDesc;

extern void CheckVladPasswords(void);

extern CPU_INT32U solar_modes_index;
extern CPU_INT32U discount_index;
extern CPU_INT32U abonement_index;
extern CPU_INT32U current_discount;
extern CPU_INT32U score_cmd;
extern CPU_INT32U relay_cmd;
extern CPU_INT32U ftp_send_cmd;

#endif //#ifndef _DATADESC_H_
