первый
This commit is contained in:
94
devices/Validators/CCNETdevice/CCNETDeviceClass.cpp
Normal file
94
devices/Validators/CCNETdevice/CCNETDeviceClass.cpp
Normal 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;
|
||||
}
|
||||
|
||||
18
devices/Validators/CCNETdevice/CCNETDeviceClass.h
Normal file
18
devices/Validators/CCNETdevice/CCNETDeviceClass.h
Normal 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
|
||||
1379
devices/Validators/CCNETdevice/CCNETDeviceThread.cpp
Normal file
1379
devices/Validators/CCNETdevice/CCNETDeviceThread.cpp
Normal file
File diff suppressed because it is too large
Load Diff
57
devices/Validators/CCNETdevice/CCNETDeviceThread.h
Normal file
57
devices/Validators/CCNETdevice/CCNETDeviceThread.h
Normal 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
|
||||
19
devices/Validators/CCNETdevice/CCNETdevice.cpp
Normal file
19
devices/Validators/CCNETdevice/CCNETdevice.cpp
Normal 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()
|
||||
{
|
||||
}
|
||||
20
devices/Validators/CCNETdevice/CCNETdevice.h
Normal file
20
devices/Validators/CCNETdevice/CCNETdevice.h
Normal 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
|
||||
94
devices/Validators/CCNETdevice/_CCNETDeviceClass.cpp
Normal file
94
devices/Validators/CCNETdevice/_CCNETDeviceClass.cpp
Normal 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;
|
||||
}
|
||||
|
||||
18
devices/Validators/CCNETdevice/_CCNETDeviceClass.h
Normal file
18
devices/Validators/CCNETdevice/_CCNETDeviceClass.h
Normal 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
|
||||
1379
devices/Validators/CCNETdevice/_CCNETDeviceThread.cpp
Normal file
1379
devices/Validators/CCNETdevice/_CCNETDeviceThread.cpp
Normal file
File diff suppressed because it is too large
Load Diff
57
devices/Validators/CCNETdevice/_CCNETDeviceThread.h
Normal file
57
devices/Validators/CCNETdevice/_CCNETDeviceThread.h
Normal 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
|
||||
19
devices/Validators/CCNETdevice/_CCNETdevice.cpp
Normal file
19
devices/Validators/CCNETdevice/_CCNETdevice.cpp
Normal 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()
|
||||
{
|
||||
}
|
||||
20
devices/Validators/CCNETdevice/_CCNETdevice.h
Normal file
20
devices/Validators/CCNETdevice/_CCNETdevice.h
Normal 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
|
||||
Reference in New Issue
Block a user