ClassOne.h
上传用户:glass0516
上传日期:2010-01-11
资源大小:104k
文件大小:5k
- /*****************************************************************************
- * RelayFax Open Source Project
- * Copyright 1996-2004 Alt-N Technologies, Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the RelayFax Open
- * Source License. A copy of this license is available in file LICENSE
- * in the top-level directory of the distribution.
- *
- * RelayFax is a registered trademark of Alt-N Technologies, Ltd.
- *
- * Individual files and/or contributed packages may be copyright by
- * other parties and subject to additional restrictions.
- *****************************************************************************/
- ////////////////////////////////////////////////////////////////////////////////
- //
- // The purpose of CClassOne is contain the protocol specifics of EIA
- // fax modem class 1
- //
- ////////////////////////////////////////////////////////////////////////////////
- #ifndef CLASSONE_H
- #define CLASSONE_H
- #include "Modem.h"
- class CClassOne : public CModem
- {
- public:
- enum PhaseBStates { STATE_WAIT_FOR_DIS, // sending states
- STATE_SEND_TIS,
- STATE_SEND_DCS,
- STATE_SEND_SILENCE_BEFORE_TRAINING,
- STATE_SEND_TRAINING_DATA,
- STATE_SEND_TRAINING,
- STATE_WAIT_FOR_CFR,
- STATE_SEND_SILENCE_BEFORE_DATA,
- STATE_SEND_CSI, // receiving states
- STATE_SEND_DIS,
- STATE_DIS_SENT,
- STATE_WAIT_FOR_DCS,
- STATE_RECEIVE_TRAINING_DATA,
- STATE_RECEIVE_TRAINING,
- STATE_SEND_CFR,
- STATE_SEND_RECV_DATA,
- STATE_SENT_FTT,
- STATE_SENT_FTT_WAIT_FOR_DCS };
- enum PhaseDStates { STATE_SEND_SILENCE_BEFORE_PAGE_FINISHED,
- STATE_SEND_PAGE_FINISHED,
- STATE_PAGE_FINISHED_SENT,
- STATE_WAIT_FOR_MCF,
- STATE_SEND_SILENCE_BEFORE_PHASE_C,
- STATE_WAIT_FOR_EOP,
- STATE_SEND_MCF,
- STATE_MCF_SENT,
- STATE_SEND_RR,
- STATE_SEND_CTC,
- STATE_CTC_SENT,
- STATE_WAIT_FOR_CTR,
- STATE_WAIT_FOR_CTC,
- STATE_SEND_CTR };
- enum PhaseEStates { STATE_WAIT_FOR_OK,
- STATE_SEND_DCN,
- STATE_DCN_SENT,
- STATE_RECEIVE_DCN };
- CClassOne();
- virtual ~CClassOne();
- virtual bool OnWaitTimeout( void );
- // methods overridden from CCommPort
- virtual void OnConnect(void);
- virtual bool OnDisconnect(void);
- virtual void OnWrite(void);
- virtual void OnReadLine(void);
- // methods overridden from CModem
- virtual void OnSendFaxMsg(MSG* pMsg);
- virtual void OnRecvFaxMsg(MSG* pMsg);
- virtual void OnAbortFaxMsg(void);
- virtual void OnHDLCFrame(void);
- virtual void OnPartialHDLCFrame(void);
- virtual void OnTimer( UINT nID );
- virtual void Abort( bool bUserCancelled );
- virtual void CheckTimeouts( DWORD dwInActive );
- protected:
- void SetState( int nNewState, int nNewPhaseState = 0 );
- void PhaseInit(void);
- void PhaseIdle(void);
- void PhaseRinging(void);
- void PhaseA(void);
- void PhaseB(void);
- void PhaseC(void);
- void PhaseD(void);
- void PhaseE(void);
- void OnDIS(void);
- void OnCSI(void);
- void OnCFR(void);
- void OnMCF(void);
- void OnRTP(void);
- void OnRTN(void);
- void OnFTT(void);
- void OnDCS(void);
- void OnEOP(void);
- void OnEOM(void);
- void OnMPS(void);
- void OnDCN(void);
- void OnPPS(void);
- void OnPPR(void);
- void OnRNR(void);
- void OnRR(void);
- void OnCRP(void);
- void OnNSF(void);
- void OnCTC(void);
- void OnCTR(void);
- void OnEOR(void);
- void OnERR(void);
- void SendID(unsigned char octet);
- void SendDCS(void);
- void SendEOP(void);
- void SendDCN(void);
- void SendDIS(void);
- void SendCFR(void);
- void SendFTT(void);
- void SendMCF(void);
- void SendPPR(void);
- void SendCTR(void);
- void SendCTC(void);
- void SendSimpleHDLCFrame( unsigned char nFCF );
- void SendPPSHDLCFrame( unsigned char nFCF );
- void HDLCFrameStart(void);
- void HDLCFrameAddByte( unsigned char nOctet );
- void HDLCFrameWrite(void);
- void SendTraining(void);
- void SendHDLCFrame(void) { SendFormattedCommand( "FTH", 3 ); };
- void RecvHDLCFrame(void);
- void SendLongTraining(void) { SendFormattedCommand( "FTM", cls1Speeds[m_nClass1Speed].ModStr1 ); };
- void SendShortTraining(void) { SendFormattedCommand( "FTM", cls1Speeds[m_nClass1Speed].ModStr2 ); };
- void RecvLongTraining(void) { SendFormattedCommand( "FRM", cls1Speeds[m_nClass1Speed].ModStr1 ); };
- void RecvShortTraining(void) { SendFormattedCommand( "FRM", cls1Speeds[m_nClass1Speed].ModStr2 ); };
- unsigned char GetFCF( unsigned char nFCF ) { return (m_bReceiving) ? RCV_FCF(nFCF) : XMT_FCF(nFCF); };
- void SendFormattedCommand( char* szCMD, int nParam );
- void DecrementSpeed( void );
- bool m_bGotCFR;
- bool m_bGotDIS;
- bool m_bGotDCS;
- bool m_bGotEOP;
- bool m_bGotMPS;
- bool m_bGotEOM;
- bool m_bGotPPR;
- unsigned char m_ECMFrameCount;
- bool m_bSendPPR;
- bool m_bGotMCF;
- bool m_bGotRNR;
- bool m_bGotCRP;
- bool m_bGotEOR;
- bool m_bGotCTC;
- bool m_bGotDCN;
- bool m_bGotRTP;
- bool m_bGotRTN;
- int m_nPhaseState;
- // Info from DIS
- int m_nClass1Speed;
- WORD m_wScanTimeMs;
- bool m_b2D;
- bool m_bT6Encoding;
- bool m_bECM;
- WORD m_wMinLineChars;
- int m_nCorrect;
- int m_nLoopCtr;
- int m_nPPRCtr;
- bool m_bRecvHDLCError;
- DWORD m_dwTrainingStart;
- DWORD m_dwEOPWaitStart;
- DWORD m_dwRNRStart;
- };
- #endif // CLASSONE_H