первый

This commit is contained in:
2024-11-01 12:23:13 +05:00
parent 801d9d33fa
commit 0688c46a7e
226 changed files with 162921 additions and 0 deletions

View File

@ -0,0 +1,94 @@
//---------------------------------------------------------------------------
#pragma hdrstop
#include "CCNETDeviceClass.h"
#include "CCNETDeviceThread.h"
#include "DeviceClass.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TCCNETDeviceClass::TCCNETDeviceClass(int id, int ComPort,TLogClass* _Log): CValidator(id, ComPort,_Log, "CCNETValidator")
{
DataLengthIndex = 2;
BeginByte = 0x02;
LoggingErrors = true;
COMParameters->DtrControl = DTR_CONTROL_DISABLE;
COMParameters->RtsControl = RTS_CONTROL_DISABLE;
Port->ReopenPort();
}
TCCNETDeviceClass::~TCCNETDeviceClass()
{
}
void TCCNETDeviceClass::Start()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (DeviceState->State != NotRun)
return;
DeviceState->State = Wait;
DeviceThread = new TCCNETDeviceThread();
DeviceThread->Log = Log;
DeviceThread->DeviceState = DeviceState;
DeviceThread->CommandParameters = CommandParameters;
DeviceThread->SendType = SendType;
DeviceThread->Port = Port;
DeviceThread->Command = Command;
DeviceThread->CommandSize = CommandSize;
DeviceThread->Answer = Answer;
DeviceThread->AnswerSize = AnswerSize;
DeviceThread->data = data;
DeviceThread->len_data = &len_data;
DeviceThread->CommandCriticalSection = CommandCriticalSection;
DeviceThread->DataLengthIndex = DataLengthIndex;
DeviceThread->BeginByte = BeginByte;
DeviceThread->LoggingErrors = LoggingErrors;
DeviceThread->LastError = LastError;
DeviceThread->EndByte = EndByte;
DeviceThread->CRCLength = CRCLength;
DeviceThread->DataLength = DataLength;
DeviceThread->DeviceStarted = DeviceStarted;
DeviceThread->DeviceStopped = DeviceStopped;
DeviceThread->DevicePaused = DevicePaused;
DeviceThread->DeviceStateChanged = DeviceStateChanged;
DeviceThread->CommandStarted = CommandStarted;
DeviceThread->CommandPaused = CommandPaused;
DeviceThread->CommandFinished = CommandFinished;
DeviceThread->MaxCash = MaxCash;
DeviceThread->MinCash = MinCash;
DeviceThread->ChangeEvent = ChangeEvent;
((TCCNETDeviceThread*)DeviceThread)->DisabledNominals = DisabledNominals;
DeviceState->Nominal = 0;
DeviceThread->ExchangeRate = ExchangeRate;
DeviceThread->Currency = Currency;
}
bool TCCNETDeviceClass::IsItYou()
{
if (DeviceState->StateCode == 0xFF)
return false;
DisableBill();
Sleep(800);
if (DeviceState->StateCode != 0x19)
return false;
EnableBill();
Sleep(800);
if (DeviceState->StateCode != 0x14)
return false;
DisableBill();
return true;
}

View File

@ -0,0 +1,18 @@
//---------------------------------------------------------------------------
#ifndef CCNETDeviceClassH
#define CCNETDeviceClassH
//---------------------------------------------------------------------------
#include "CValidator.h"
class TCCNETDeviceClass : public CValidator
{
protected:
virtual void Start();
public:
TCCNETDeviceClass(int id, int ComPort,TLogClass* _Log = NULL);
virtual ~TCCNETDeviceClass();
virtual bool IsItYou();
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
//---------------------------------------------------------------------------
#ifndef CCNETDeviceThreadH
#define CCNETDeviceThreadH
//---------------------------------------------------------------------------
#include "DeviceThread.h"
class TCCNETDeviceThread : public TDeviceThread
{
protected:
BYTE inter_crc_h;
BYTE inter_crc_l;
unsigned int mask;
int OfflineCount;
AnsiString BillDescr;
AnsiString RejectingDescr;
AnsiString FailureDescr;
int ResetCount;
clock_t DisableTime;
bool InitDisable;
int LastEnDisCommand;//0-ok,1-disable,2-enable;
virtual void SendPacket(BYTE command,int len_packet, BYTE* data);
virtual void calc_crc(BYTE byte);
unsigned short Calc_CRC16CCNET(BYTE* DataBuf, unsigned short BufLen);
virtual void ParseAnswer(int mode = 0);
virtual void GetStay();
virtual void Reset();
virtual void Return();
virtual void Hold();
virtual int Stack();
virtual void EnableAll();
virtual void Disable();
virtual void PollingLoop();
virtual void SendACK();
virtual void SendNAK();
std::string GetMainFailureDescription(BYTE StatusCode);
std::string GetHardwareFailureDescription(BYTE StatusCode);
std::string GetStatusDescription(BYTE StatusCode);
AnsiString GetRejectionDescription(BYTE StatusCode);
AnsiString GetFailureDescription(BYTE StatusCode);
virtual std::string GetStateDescription();
virtual void __fastcall ProcessLoopCommand();
virtual void ProcessOutCommand();
public:
__fastcall TCCNETDeviceThread();
virtual __fastcall ~TCCNETDeviceThread();
void CommandDisable();
bool IsItYou();
};
#endif

View File

@ -0,0 +1,19 @@
#pragma hdrstop
#include "CCNETdevice.h"
#include "CCNETDeviceThread.h"
#pragma package(smart_init)
TCCNETdevice::TCCNETdevice(int id, int ComPort,TLogClass* _Log) : TCCNETDeviceClass(id, ComPort,_Log)
{
LoggingErrors = false;
DisableBill();
DeviceName = "CCNETValidator";
DeviceState->OutStateCode = DSE_NOTMOUNT;
}
TCCNETdevice::~TCCNETdevice()
{
}

View File

@ -0,0 +1,20 @@
#ifndef CCNETdeviceH
#define CCNETdeviceH
#include <math.h>
#include "CCNETDeviceClass.h"
//#include "CValidator.h"
//class TCCNETdevice : public TDeviceClass
class TCCNETdevice : public TCCNETDeviceClass
{
private:
protected:
public:
TCCNETdevice(int id, int ComPort,TLogClass* _Log = NULL);
virtual ~TCCNETdevice();
};
#endif

View File

@ -0,0 +1,94 @@
//---------------------------------------------------------------------------
#pragma hdrstop
#include "CCNETDeviceClass.h"
#include "CCNETDeviceThread.h"
#include "DeviceClass.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TCCNETDeviceClass::TCCNETDeviceClass(int id, int ComPort,TLogClass* _Log): CValidator(id, ComPort,_Log, "CCNETValidator")
{
DataLengthIndex = 2;
BeginByte = 0x02;
LoggingErrors = true;
COMParameters->DtrControl = DTR_CONTROL_DISABLE;
COMParameters->RtsControl = RTS_CONTROL_DISABLE;
Port->ReopenPort();
}
TCCNETDeviceClass::~TCCNETDeviceClass()
{
}
void TCCNETDeviceClass::Start()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (DeviceState->State != NotRun)
return;
DeviceState->State = Wait;
DeviceThread = new TCCNETDeviceThread();
DeviceThread->Log = Log;
DeviceThread->DeviceState = DeviceState;
DeviceThread->CommandParameters = CommandParameters;
DeviceThread->SendType = SendType;
DeviceThread->Port = Port;
DeviceThread->Command = Command;
DeviceThread->CommandSize = CommandSize;
DeviceThread->Answer = Answer;
DeviceThread->AnswerSize = AnswerSize;
DeviceThread->data = data;
DeviceThread->len_data = &len_data;
DeviceThread->CommandCriticalSection = CommandCriticalSection;
DeviceThread->DataLengthIndex = DataLengthIndex;
DeviceThread->BeginByte = BeginByte;
DeviceThread->LoggingErrors = LoggingErrors;
DeviceThread->LastError = LastError;
DeviceThread->EndByte = EndByte;
DeviceThread->CRCLength = CRCLength;
DeviceThread->DataLength = DataLength;
DeviceThread->DeviceStarted = DeviceStarted;
DeviceThread->DeviceStopped = DeviceStopped;
DeviceThread->DevicePaused = DevicePaused;
DeviceThread->DeviceStateChanged = DeviceStateChanged;
DeviceThread->CommandStarted = CommandStarted;
DeviceThread->CommandPaused = CommandPaused;
DeviceThread->CommandFinished = CommandFinished;
DeviceThread->MaxCash = MaxCash;
DeviceThread->MinCash = MinCash;
DeviceThread->ChangeEvent = ChangeEvent;
((TCCNETDeviceThread*)DeviceThread)->DisabledNominals = DisabledNominals;
DeviceState->Nominal = 0;
DeviceThread->ExchangeRate = ExchangeRate;
DeviceThread->Currency = Currency;
}
bool TCCNETDeviceClass::IsItYou()
{
if (DeviceState->StateCode == 0xFF)
return false;
DisableBill();
Sleep(800);
if (DeviceState->StateCode != 0x19)
return false;
EnableBill();
Sleep(800);
if (DeviceState->StateCode != 0x14)
return false;
DisableBill();
return true;
}

View File

@ -0,0 +1,18 @@
//---------------------------------------------------------------------------
#ifndef CCNETDeviceClassH
#define CCNETDeviceClassH
//---------------------------------------------------------------------------
#include "CValidator.h"
class TCCNETDeviceClass : public CValidator
{
protected:
virtual void Start();
public:
TCCNETDeviceClass(int id, int ComPort,TLogClass* _Log = NULL);
virtual ~TCCNETDeviceClass();
virtual bool IsItYou();
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
//---------------------------------------------------------------------------
#ifndef CCNETDeviceThreadH
#define CCNETDeviceThreadH
//---------------------------------------------------------------------------
#include "DeviceThread.h"
class TCCNETDeviceThread : public TDeviceThread
{
protected:
BYTE inter_crc_h;
BYTE inter_crc_l;
unsigned int mask;
int OfflineCount;
AnsiString BillDescr;
AnsiString RejectingDescr;
AnsiString FailureDescr;
int ResetCount;
clock_t DisableTime;
bool InitDisable;
int LastEnDisCommand;//0-ok,1-disable,2-enable;
virtual void SendPacket(BYTE command,int len_packet, BYTE* data);
virtual void calc_crc(BYTE byte);
unsigned short Calc_CRC16CCNET(BYTE* DataBuf, unsigned short BufLen);
virtual void ParseAnswer(int mode = 0);
virtual void GetStay();
virtual void Reset();
virtual void Return();
virtual void Hold();
virtual int Stack();
virtual void EnableAll();
virtual void Disable();
virtual void PollingLoop();
virtual void SendACK();
virtual void SendNAK();
std::string GetMainFailureDescription(BYTE StatusCode);
std::string GetHardwareFailureDescription(BYTE StatusCode);
std::string GetStatusDescription(BYTE StatusCode);
AnsiString GetRejectionDescription(BYTE StatusCode);
AnsiString GetFailureDescription(BYTE StatusCode);
virtual std::string GetStateDescription();
virtual void __fastcall ProcessLoopCommand();
virtual void ProcessOutCommand();
public:
__fastcall TCCNETDeviceThread();
virtual __fastcall ~TCCNETDeviceThread();
void CommandDisable();
bool IsItYou();
};
#endif

View File

@ -0,0 +1,19 @@
#pragma hdrstop
#include "CCNETdevice.h"
#include "CCNETDeviceThread.h"
#pragma package(smart_init)
TCCNETdevice::TCCNETdevice(int id, int ComPort,TLogClass* _Log) : TCCNETDeviceClass(id, ComPort,_Log)
{
LoggingErrors = false;
DisableBill();
DeviceName = "CCNETValidator";
DeviceState->OutStateCode = DSE_NOTMOUNT;
}
TCCNETdevice::~TCCNETdevice()
{
}

View File

@ -0,0 +1,20 @@
#ifndef CCNETdeviceH
#define CCNETdeviceH
#include <math.h>
#include "CCNETDeviceClass.h"
//#include "CValidator.h"
//class TCCNETdevice : public TDeviceClass
class TCCNETdevice : public TCCNETDeviceClass
{
private:
protected:
public:
TCCNETdevice(int id, int ComPort,TLogClass* _Log = NULL);
virtual ~TCCNETdevice();
};
#endif