Fórum Ajuda com Classe TECF, (Impressoras Fiscais sem DLL´s) #231165
10/05/2004
0
Ola, para todos...
Gostaria a ajuda dos programadores que utilizam ECF´s em suas aplicações comerciais...
Estou desenvolvendo uma classe para acesso direto (sem DLL´s) e multiplataforma (Linux) para varios ECFs
Dentre as vantagens, está o fato da sua aplicação comercial ter total controle sobre o ECF... Que tal dispara um evento quando a Impressora sair de Linha ?
Gostaria de sugestões sobre as Propriedades, Procedures, e Functions...
Existe alguma função ou procedure faltando ? Com as Procedures e functions, existentes, seria possivel usar a Classe em sua aplicação comercial ?
Procurei deixar as Procedures mais votadas para o programador que para o ECF, exemplo, a Procedure VendeItem, se encarrega de Vender, efetuar desconto/acrescimo, já verifica se o Valor e Qtd possuem 2 ou 3 decimais.... Ou seja, a procedure irá enviar todos os comandos necessários para fazer a venda do Item...
const cTimeout = 5 ; // Tempo para msg de falha de comunicacao
cTempoInicioMensagem = 3 ; // Tempo para exibir msg ´Aguarde o Fim da Impressao´
cMsgAguardando = ´Aguardando termino da Impressão: ¬d seg´ ;
type
TModeloECF = (ecfNaoFiscal, ecfBematech, ecfSweda, ecfDaruma, ecfSchalter, ecfMecaf);
ECMDInvalido = class(Exception) ;
EECFNaoResponde = class(Exception) ;
EECFNaoInicializado = class(Exception) ;
TECFMensagemEspera = class
private
fsMensagem: String ;
fsTempoInicio: Integer ;
fsControle: TObject ;
fsControlePropriedade: String ;
fsTextoSalvo : String ;
procedure SetMensagem(const Value: String);
procedure SetTempoInicio(const Value: Integer);
procedure SetControle(const Value: TObject);
procedure SetControlePropridade(const Value: String);
public
Constructor create ;
Property Mensagem : String read fsMensagem write SetMensagem ;
Property TempoInicio : Integer read fsTempoInicio write SetTempoInicio ;
Property Controle : TObject read fsControle write SetControle ;
Property ControlePropriedade : String read fsControlePropriedade write SetControlePropridade ;
Procedure SalvaTexto ;
Procedure RestauraTexto ;
Procedure EscreveTexto( Texto : String ) ;
end ;
TModouEmLinhaEvent = procedure(Sender: TObject) of object;
TECF = class
private
fsTimeOut: Integer ;
fsPorta : String ;
fsRetentar: Boolean;
fsColunas: Integer;
fsMensagemAguardando: TECFMensagemEspera;
fsMudouEmLinha: TModouEmLinhaEvent;
fsEmLinhaTimer: Integer;
fsTimerEmLinha : TTimer ;
procedure SetTimeOut(const Value : Integer);
procedure SetRetentar(const Value: Boolean);
procedure SetColunas(const Value: Integer);
procedure SetMudouEmLinha(const Value: TModouEmLinhaEvent);
procedure SetEmLinhaTimer(const Value: Integer);
Protected
fsComandoEnviado: String;
fsRespostaComando: String;
fsModelo : TModeloECF ;
fsAguardandoResposta: Boolean;
function GetEmLinha: Boolean; virtual ;
function GetDataHora: TDateTime; virtual ; abstract ;
function GetNumCupom: String; virtual ;
function GetNumECF: String; virtual ;
function GetNumSerie: String; virtual ;
function GetNumVersao: Single; virtual ; abstract ;
function GetSubTotal: Double; virtual ; abstract ;
function GetTotalPago: Double; virtual ; abstract ;
function GetCupomAberto: Boolean; virtual ; abstract ;
function GetGavetaAberta: Boolean; virtual ; abstract ;
function GetPoucoPapel : Boolean; virtual ; abstract ;
function GetDiaFechado : Boolean; virtual ; abstract ;
function GetPodeAbrirCupom : Boolean; virtual ; abstract ;
function GetChequePronto: Boolean; virtual ; abstract ;
function GetEmPagamento : Boolean; virtual ; abstract ;
public
Constructor create( sPorta : String) ;
Destructor Destroy ; override ;
property QuandoMudarEmLinha : TModouEmLinhaEvent read fsMudouEmLinha write SetMudouEmLinha ;
Property EmLinhaMillisecTest : Integer read fsEmLinhaTimer write SetEmLinhaTimer ;
property Modelo : TModeloECF read fsModelo ;
Property Porta : String read fsPorta ;
Property TimeOut : Integer read fsTimeOut write SetTimeOut ;
Property Retentar : Boolean read fsRetentar write SetRetentar ;
Property Colunas : Integer read fsColunas write SetColunas ;
Property MensagemAguardando : TECFMensagemEspera read fsMensagemAguardando ;
Property EmLinha : Boolean read GetEmLinha ;
Property AguardandoResposta : Boolean read fsAguardandoResposta ;
// String com Comando exatamente como foi enviado para impressora //
Property ComandoEnviado : String read fsComandoEnviado ;
// String com a Resposta Completa da Impressora (sem tratamentos) //
Property RespostaComando : String read fsRespostaComando ;
// ?? Tela para configurar e testar a impressora ?? //
Procedure ConfigurarForm ; virtual ;
// ?? Dialog exibindo algumas informaçoes da Impressora ?? //
Procedure TestarDialog ; virtual ;
// Variaveis //
Property DataHora : TDateTime read GetDataHora ;
Property NumCupom : String read GetNumCupom ;
Property NumECF : String read GetNumECF ;
Property NumSerie : String read GetNumSerie ;
Property NumVersao : Single read GetNumVersao ;
// Flags //
Property PoucoPapel : Boolean read GetPoucoPapel ;
Property DiaFechado : Boolean read GetDiaFechado ;
Property PodeAbrirCupom : Boolean read GetPodeAbrirCupom ;
Property CupomAberto : Boolean read GetCupomAberto ;
Property EmPagamento : Boolean read GetEmPagamento ;
// Procedimentos de Cupom Fiscal //
Procedure AbreCupom( CIC_CNPJ : String ) ; virtual ; abstract ;
Procedure VendeItem( Codigo, Descrica : String; AliqotaValor, Qtd : Single ;
ValorUnitario : Double; DescontoPorc : Single ; Unidade : String ) ; virtual ; abstract ;
Procedure SubtotalizaCupom( DescontoAcrescimo : Double ) ; virtual ; abstract ;
Procedure EfetuaPagamento( CodFormaPagto : String; Valor : Double;
Observacao : String; ImprimeVinculado : Boolean) ; virtual ; abstract ;
Procedure FechaCupom( Observacao : String ) ; virtual ; abstract ;
// Para varias linhas nos parametros Observacao use o sinal | (pipe)
// para quebra de linha
Property Subtotal : Double read GetSubTotal ;
Property TotalPago : Double read GetTotalPago ;
Procedure CancelaCupom ; virtual ; abstract ;
Procedure CancelaItemVendido( NumItem : Integer ) ; virtual ; abstract ;
// Gaveta de dinheiro //
Procedure AbreGaveta ; virtual ;
Property GavetaAberta : Boolean read GetGavetaAberta ;
// Relatorios //
Procedure LeituraX ; virtual ; abstract ;
Procedure ReducaoZ(DataHora : TDateTime) ; virtual ; abstract ;
Procedure RelatorioGerencial(Relatorio : TStrings; Vias : Integer) ; virtual ; abstract ;
Procedure CupomVinculado(COO, CodFormaPagto : String; Valor : Double;
Relatorio : TStrings; Vias : Integer) ; virtual ; abstract ;
Procedure FechaRelatorio ; virtual ; abstract ;
// Cheques //
Procedure ImprimeCheque(Banco : String; Valor : Double ; Favorecido, Cidade : String;
Data : TDateTime ;Observacao : String) ; virtual ;
Procedure CancelaImpressaoCheque ; virtual ;
Property ChequePronto : Boolean read GetChequePronto ;
// Utilitarios e Diversos //
Function Aliquotas : TStrings ; virtual ; abstract ;
Function AchaAliquota( AliquotaValor : Single ) : String ; virtual ; abstract ;
Function AchaFormaPagamento( DescFormaPagamento : String ;
var ImprimeVinculado : Boolean ) : String ; virtual ; abstract ;
Procedure MudaHorarioVerao ; virtual ; abstract ;
// Carrega as Formas, de Pagamento e CNF, verifica por Vinculos, etc Particular de cada ECF //
Procedure PreparaTEF ; virtual ; abstract ;
// Verifica o estado da impressora e tenta deixar em estado Livre //
Procedure CorrigeEstadoErro ; virtual ; abstract ;
Procedure ImpactoAgulhas ; virtual ;
Function EnviaComando( cmd : String; BytesResp : Integer) : String ; overload ; virtual ; abstract ;// Retorna a Resposta
// Permitindo mudar o TimeOut padrao //
Function EnviaComando( cmd : String; BytesResp, TimeOut : Integer) : String ; overload ;virtual ; abstract ; // Retorna a Resposta
end ;
Gostaria a ajuda dos programadores que utilizam ECF´s em suas aplicações comerciais...
Estou desenvolvendo uma classe para acesso direto (sem DLL´s) e multiplataforma (Linux) para varios ECFs
Dentre as vantagens, está o fato da sua aplicação comercial ter total controle sobre o ECF... Que tal dispara um evento quando a Impressora sair de Linha ?
Gostaria de sugestões sobre as Propriedades, Procedures, e Functions...
Existe alguma função ou procedure faltando ? Com as Procedures e functions, existentes, seria possivel usar a Classe em sua aplicação comercial ?
Procurei deixar as Procedures mais votadas para o programador que para o ECF, exemplo, a Procedure VendeItem, se encarrega de Vender, efetuar desconto/acrescimo, já verifica se o Valor e Qtd possuem 2 ou 3 decimais.... Ou seja, a procedure irá enviar todos os comandos necessários para fazer a venda do Item...
const cTimeout = 5 ; // Tempo para msg de falha de comunicacao
cTempoInicioMensagem = 3 ; // Tempo para exibir msg ´Aguarde o Fim da Impressao´
cMsgAguardando = ´Aguardando termino da Impressão: ¬d seg´ ;
type
TModeloECF = (ecfNaoFiscal, ecfBematech, ecfSweda, ecfDaruma, ecfSchalter, ecfMecaf);
ECMDInvalido = class(Exception) ;
EECFNaoResponde = class(Exception) ;
EECFNaoInicializado = class(Exception) ;
TECFMensagemEspera = class
private
fsMensagem: String ;
fsTempoInicio: Integer ;
fsControle: TObject ;
fsControlePropriedade: String ;
fsTextoSalvo : String ;
procedure SetMensagem(const Value: String);
procedure SetTempoInicio(const Value: Integer);
procedure SetControle(const Value: TObject);
procedure SetControlePropridade(const Value: String);
public
Constructor create ;
Property Mensagem : String read fsMensagem write SetMensagem ;
Property TempoInicio : Integer read fsTempoInicio write SetTempoInicio ;
Property Controle : TObject read fsControle write SetControle ;
Property ControlePropriedade : String read fsControlePropriedade write SetControlePropridade ;
Procedure SalvaTexto ;
Procedure RestauraTexto ;
Procedure EscreveTexto( Texto : String ) ;
end ;
TModouEmLinhaEvent = procedure(Sender: TObject) of object;
TECF = class
private
fsTimeOut: Integer ;
fsPorta : String ;
fsRetentar: Boolean;
fsColunas: Integer;
fsMensagemAguardando: TECFMensagemEspera;
fsMudouEmLinha: TModouEmLinhaEvent;
fsEmLinhaTimer: Integer;
fsTimerEmLinha : TTimer ;
procedure SetTimeOut(const Value : Integer);
procedure SetRetentar(const Value: Boolean);
procedure SetColunas(const Value: Integer);
procedure SetMudouEmLinha(const Value: TModouEmLinhaEvent);
procedure SetEmLinhaTimer(const Value: Integer);
Protected
fsComandoEnviado: String;
fsRespostaComando: String;
fsModelo : TModeloECF ;
fsAguardandoResposta: Boolean;
function GetEmLinha: Boolean; virtual ;
function GetDataHora: TDateTime; virtual ; abstract ;
function GetNumCupom: String; virtual ;
function GetNumECF: String; virtual ;
function GetNumSerie: String; virtual ;
function GetNumVersao: Single; virtual ; abstract ;
function GetSubTotal: Double; virtual ; abstract ;
function GetTotalPago: Double; virtual ; abstract ;
function GetCupomAberto: Boolean; virtual ; abstract ;
function GetGavetaAberta: Boolean; virtual ; abstract ;
function GetPoucoPapel : Boolean; virtual ; abstract ;
function GetDiaFechado : Boolean; virtual ; abstract ;
function GetPodeAbrirCupom : Boolean; virtual ; abstract ;
function GetChequePronto: Boolean; virtual ; abstract ;
function GetEmPagamento : Boolean; virtual ; abstract ;
public
Constructor create( sPorta : String) ;
Destructor Destroy ; override ;
property QuandoMudarEmLinha : TModouEmLinhaEvent read fsMudouEmLinha write SetMudouEmLinha ;
Property EmLinhaMillisecTest : Integer read fsEmLinhaTimer write SetEmLinhaTimer ;
property Modelo : TModeloECF read fsModelo ;
Property Porta : String read fsPorta ;
Property TimeOut : Integer read fsTimeOut write SetTimeOut ;
Property Retentar : Boolean read fsRetentar write SetRetentar ;
Property Colunas : Integer read fsColunas write SetColunas ;
Property MensagemAguardando : TECFMensagemEspera read fsMensagemAguardando ;
Property EmLinha : Boolean read GetEmLinha ;
Property AguardandoResposta : Boolean read fsAguardandoResposta ;
// String com Comando exatamente como foi enviado para impressora //
Property ComandoEnviado : String read fsComandoEnviado ;
// String com a Resposta Completa da Impressora (sem tratamentos) //
Property RespostaComando : String read fsRespostaComando ;
// ?? Tela para configurar e testar a impressora ?? //
Procedure ConfigurarForm ; virtual ;
// ?? Dialog exibindo algumas informaçoes da Impressora ?? //
Procedure TestarDialog ; virtual ;
// Variaveis //
Property DataHora : TDateTime read GetDataHora ;
Property NumCupom : String read GetNumCupom ;
Property NumECF : String read GetNumECF ;
Property NumSerie : String read GetNumSerie ;
Property NumVersao : Single read GetNumVersao ;
// Flags //
Property PoucoPapel : Boolean read GetPoucoPapel ;
Property DiaFechado : Boolean read GetDiaFechado ;
Property PodeAbrirCupom : Boolean read GetPodeAbrirCupom ;
Property CupomAberto : Boolean read GetCupomAberto ;
Property EmPagamento : Boolean read GetEmPagamento ;
// Procedimentos de Cupom Fiscal //
Procedure AbreCupom( CIC_CNPJ : String ) ; virtual ; abstract ;
Procedure VendeItem( Codigo, Descrica : String; AliqotaValor, Qtd : Single ;
ValorUnitario : Double; DescontoPorc : Single ; Unidade : String ) ; virtual ; abstract ;
Procedure SubtotalizaCupom( DescontoAcrescimo : Double ) ; virtual ; abstract ;
Procedure EfetuaPagamento( CodFormaPagto : String; Valor : Double;
Observacao : String; ImprimeVinculado : Boolean) ; virtual ; abstract ;
Procedure FechaCupom( Observacao : String ) ; virtual ; abstract ;
// Para varias linhas nos parametros Observacao use o sinal | (pipe)
// para quebra de linha
Property Subtotal : Double read GetSubTotal ;
Property TotalPago : Double read GetTotalPago ;
Procedure CancelaCupom ; virtual ; abstract ;
Procedure CancelaItemVendido( NumItem : Integer ) ; virtual ; abstract ;
// Gaveta de dinheiro //
Procedure AbreGaveta ; virtual ;
Property GavetaAberta : Boolean read GetGavetaAberta ;
// Relatorios //
Procedure LeituraX ; virtual ; abstract ;
Procedure ReducaoZ(DataHora : TDateTime) ; virtual ; abstract ;
Procedure RelatorioGerencial(Relatorio : TStrings; Vias : Integer) ; virtual ; abstract ;
Procedure CupomVinculado(COO, CodFormaPagto : String; Valor : Double;
Relatorio : TStrings; Vias : Integer) ; virtual ; abstract ;
Procedure FechaRelatorio ; virtual ; abstract ;
// Cheques //
Procedure ImprimeCheque(Banco : String; Valor : Double ; Favorecido, Cidade : String;
Data : TDateTime ;Observacao : String) ; virtual ;
Procedure CancelaImpressaoCheque ; virtual ;
Property ChequePronto : Boolean read GetChequePronto ;
// Utilitarios e Diversos //
Function Aliquotas : TStrings ; virtual ; abstract ;
Function AchaAliquota( AliquotaValor : Single ) : String ; virtual ; abstract ;
Function AchaFormaPagamento( DescFormaPagamento : String ;
var ImprimeVinculado : Boolean ) : String ; virtual ; abstract ;
Procedure MudaHorarioVerao ; virtual ; abstract ;
// Carrega as Formas, de Pagamento e CNF, verifica por Vinculos, etc Particular de cada ECF //
Procedure PreparaTEF ; virtual ; abstract ;
// Verifica o estado da impressora e tenta deixar em estado Livre //
Procedure CorrigeEstadoErro ; virtual ; abstract ;
Procedure ImpactoAgulhas ; virtual ;
Function EnviaComando( cmd : String; BytesResp : Integer) : String ; overload ; virtual ; abstract ;// Retorna a Resposta
// Permitindo mudar o TimeOut padrao //
Function EnviaComando( cmd : String; BytesResp, TimeOut : Integer) : String ; overload ;virtual ; abstract ; // Retorna a Resposta
end ;
Dopi
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)