📄 cstatst32.cpp
字号:
// cstatst32.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "acs.h"
// changed by g.l. 12 february 98
//#include <csta.h>
#include "csta.h"
//#include "AlcPrivV2.h"
#include "alcatel_spec.h"
//#include "cstadefsV2.h"
#include "resource.h" // main symbols
//#include "recevent.h"
#include "cstatst32.h"
#include "ConsultationDlgV2.h"
#include "dialog.h"
#include "mdump.h"
#include "viola.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// Added by G.L. 12 february 98
//#ifndef ECMA2
//#define ECMA2
//#endif
//char recPrivateData[160];
char recPrivateData[SIZE_OF_ALCATEL_PRIVATE_DATA];
//extern StreamType_t my_streamType;
////////////////////////////////////////////////////////////////////////////
// CCstatst32App
BEGIN_MESSAGE_MAP(CCstatst32App, CWinApp)
//{{AFX_MSG_MAP(CCstatst32App)
ON_COMMAND(ID_ABOUT, OnAbout)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCstatst32App construction
unsigned long eventCountedByEsr;
BOOLEAN esrSetFlag = FALSE;
CCstatst32App::CCstatst32App()
{
m_bPhoneOn = FALSE;
my_streamType = ST_CSTA;
/*beginTime = 0;
endTime = 0;
diffTime = 0;*/
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCstatst32App object
CCstatst32App theApp;
/////////////////////////////////////////////////////////////////////////////
// CCstatst32App initialization
BOOL CCstatst32App::InitInstance()
{
/*
if (!AfxSocketInit())
{
AfxMessageBox("IDP_SOCKETS_INIT_FAILED");
return FALSE;
}
*/
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
/*
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
*/
m_pMainWindow = new CMainWind ();
char sMainCaption [] = {"CSTA Application. Not Connected"};
m_pMainWindow->Create ( NULL,
sMainCaption,
WS_OVERLAPPEDWINDOW,
m_pMainWindow->rectDefault,
NULL,
MAKEINTRESOURCE (IDR_SESSION_MENU));
m_pMainWindow->ActivateFrame ();
m_pMainWnd = m_pMainWindow;
CRect rc;
m_pMainWindow->GetClientRect (&rc);
m_pMainWindow->m_pEventList = new (CListBox);
m_pMainWindow->m_pEventList->Create (WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_BORDER | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
rc, m_pMainWindow, IDD_EVENT_LIST);
m_pMainWindow->m_pEventList->SetHorizontalExtent (3000);
m_pMainWindow->m_bEventListOn = TRUE;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Recuperation d informations sur la version etc
DWORD dwSizeVer, dwHandle;
LPVOID lpData=NULL;
char szNameExe[MAX_PATH]="";
::GetModuleFileName(AfxGetInstanceHandle(), szNameExe, MAX_PATH);
dwSizeVer=::GetFileVersionInfoSize(szNameExe, &dwHandle);
// Recuperation des infos de version
if ( (dwSizeVer!=0) && ((lpData=malloc(dwSizeVer))!=NULL) &&
(::GetFileVersionInfo(szNameExe, dwHandle, dwSizeVer, lpData)) )
{
// Recuperation des informations
char *pszTxt;
UINT nLu;
if ( ::VerQueryValue(lpData,
TEXT("\\StringFileInfo\\000004B0\\LegalCopyright"),
(void **)&pszTxt, &nLu) )
SetDlgItemText(IDC_COPYRIGHT, pszTxt);
if ( ::VerQueryValue(lpData,
TEXT("\\StringFileInfo\\000004B0\\ProductVersion"),
(void **)&pszTxt, &nLu) )
SetDlgItemText(IDC_VER, pszTxt);
if ( ::VerQueryValue(lpData,
TEXT("\\StringFileInfo\\000004B0\\ProductName"),
(void **)&pszTxt, &nLu) )
SetDlgItemText(IDC_NAME, pszTxt);
}
if ( lpData!=NULL ) free(lpData);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCstatst32App::OnAbout()
{
CAboutDlg my_aboutBox;
my_aboutBox.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CCstatst32App commands
/*
*
* DisplayUnsolictedEvent : this function add a cross reference ID to the
* string passed as parameter and then call the Display event function.
*
*/
void CMainWind::DisplayUnsolicitedEvent (CString eventStr) {
char crossRefID [20];
CString newStr;
if (m_bDisplayingSession) {
newStr.Empty ();
sprintf (crossRefID, "%d ", m_cstaEvent.event.cstaUnsolicited.monitorCrossRefId);
newStr = "Cross Ref ID:";
newStr += crossRefID;
newStr += eventStr;
DisplayEvent (newStr);
}
}
/*
*
* DisplayTheEvent : this function add the handle to the string passed as
* parameter and then call the Display event function.
*
*/
void CMainWind::DisplayTheEvent (CString eventStr) {
char handleStr [20];
CString newStr;
if (m_bDisplayingSession) {
newStr.Empty ();
sprintf (handleStr, "%d ", m_acsHandle);
newStr = handleStr;
newStr += eventStr;
DisplayEvent (newStr);
}
}
/*
*
* DisplayEvent : this function add the time to the string passed as parameter
* and then add the message to the list box.
*
*/
void CMainWind::DisplayEvent (CString eventStr) {
time_t osBinaryTime;
CString timeStr;
int data;
char ch;
if (m_bDisplayingSession) {
time (&osBinaryTime);
CTime cTime (osBinaryTime);
timeStr.Empty ();
data = cTime.GetHour ();
timeStr += (((ch = data % 100) / 10) + 0x30);
timeStr += ((ch = data % 10) + 0x30);
timeStr += ":";
data = cTime.GetMinute ();
timeStr += (((ch = data % 100) / 10) + 0x30);
timeStr += ((ch = data % 10) + 0x30);
timeStr += ":";
data = cTime.GetSecond ();
timeStr += (((ch = data % 100) / 10) + 0x30);
timeStr += ((ch = data % 10) + 0x30);
timeStr += " " + eventStr;
DisplayString (timeStr);
}
return;
}
void CMainWind::DisplayPrivateTitle (CString eventStr){
CString eventString;
eventString.Format (" ");
DisplayString (eventString);
DisplayString (eventStr);
return;
}
void CMainWind::DisplayEventTitle(CString eventStr){
CString eventString;
eventString = " ";
DisplayString (eventString);
eventString = "##############################################################################";
DisplayString (eventString);
DisplayTheEvent (eventStr);
}
/*
*
* DisplayString : this function add the message to the list box.
*
*/
void CMainWind::DisplayString (CString eventStr) {
FILE *fEvents;
if (m_bDisplayingSession) {
m_pEventList->InsertString (-1, eventStr);
int i = m_pEventList->GetCount ();
m_pEventList->SetCurSel (i - 1);
}
if (m_bEventFile) {
if ((fEvents = fopen("events.txt", "at+")) != NULL) {
fprintf (fEvents, eventStr.operator const char *());
fprintf (fEvents, "\n");
fclose (fEvents);
}
}
return;
}
/*
*
* MessageBoxError : this procedure is called each time there is an error
* returned by a ACS of CSTA primitive. It display the error messages in
* a dialog box.
*
*/
void CMainWind::MessageBoxError (char *errorTitle, RetCode_t rc) {
CErrorDlg errorDlg;
CString error;
CString errorInt;
errorInt.Format(" (%d)",rc);
switch (rc) {
case ACSERR_APIVERDENIED :
error = "api version denied";
break;
case ACSERR_BADPARAMETER :
error = "bad parameter";
break;
case ACSERR_DUPSTREAM :
error = "duplicated stream";
break;
case ACSERR_NODRIVER :
error = "no driver";
break;
case ACSERR_NOSERVER :
error = "no server";
break;
case ACSERR_NORESOURCE :
error = "no resource";
break;
case ACSERR_UBUFSMALL :
error = "buffer too small";
break;
case ACSERR_NOMESSAGE :
error = "no message";
break;
case ACSERR_UNKNOWN :
error = "unknown error";
break;
case ACSERR_BADHDL :
error = "bad Handle";
break;
case ACSERR_STREAM_FAILED :
error = "stream failed";
break;
case ACSERR_NOBUFFERS :
error = "no buffers";
break;
case ACSERR_QUEUE_FULL :
error = "send queue full";
break;
default :
error = "unknown error";
error += errorInt;
break;
}
errorDlg.m_sErrorTitle = errorTitle;
errorDlg.m_sError = error;
errorDlg.DoModal ();
return;
}
void FAR PASCAL SetEsrCallback (unsigned long param) {
eventCountedByEsr += param;
return;
};
BOOL CMainWind::AcsSetEsr() {
//FARPROC procEsr = MakeProcInstance ((FARPROC)SetEsrCallback,
// (HINSTANCE)pApp->m_hInstance);
CString eventString;
if( esrSetFlag == FALSE){
esrSetFlag = TRUE;
m_nRetCode = acsSetESR (m_acsHandle,
SetEsrCallback,
1,
TRUE);
eventString.Format(" ESR set ( eventCounter : %d)",eventCountedByEsr);
}else{
esrSetFlag = FALSE;
m_nRetCode = acsSetESR (m_acsHandle,
NULL,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -