📄 mp_apdlg.cpp
字号:
GetPrivateProfileString(chSection,"Server_Model",NULL,g_Channel_Info[i].chServer_Type,sizeof(g_Channel_Info[i].chServer_Type),chINIPath);
GetPrivateProfileString(chSection,"UserUrl",NULL,g_Channel_Info[i].szUserUrl,sizeof(g_Channel_Info[i].szUserUrl),chINIPath);
GetPrivateProfileString(chSection,"UserParameters",NULL,g_Channel_Info[i].szUserUrlExtra,sizeof(g_Channel_Info[i].szUserUrlExtra),chINIPath);
g_Channel_Info[i].dwHTTPPort=(DWORD)GetPrivateProfileInt(chSection,"HTTP_Port",80,chINIPath);
g_Channel_Info[i].dwCtrlPort=(DWORD)GetPrivateProfileInt(chSection,"RTSP_Port",554,chINIPath);
g_Channel_Info[i].dwProtocol=(DWORD)GetPrivateProfileInt(chSection,"Protocol",1,chINIPath);
g_Channel_Info[i].dwCamera=(DWORD)GetPrivateProfileInt(chSection,"Camera",1,chINIPath);
g_Channel_Info[i].dwVolume=(DWORD)GetPrivateProfileInt(chSection,"Volume",5000,chINIPath);
DWORD dwTemp = (DWORD)GetPrivateProfileInt(chSection, "NetPacketCallback",0, chINIPath );
if (dwTemp != 0)
g_Channel_Info[i].bNetPacketCallback = TRUE;
g_Channel_Info[i].dwWantMedia = (DWORD)GetPrivateProfileInt(chSection, "MediaType",0, chINIPath );
if (g_Channel_Info[i].dwWantMedia == 0)
{
if (g_Channel_Info[i].chServer_Type[2])
{
if (g_Channel_Info[i].chServer_Type[2] > '2' &&
strncmp(g_Channel_Info[i].chServer_Type, "IP31x1-TLFN", 11) != 0)
g_Channel_Info[i].dwWantMedia = 3;
else
g_Channel_Info[i].dwWantMedia = 1;
}
}
g_Channel_Info[i].bConnecting=FALSE;
g_Channel_Info[i].bRecording=FALSE;
}
}
void WriteParameters()
{
// get mp_ap.ini path
char chINIPath[MAX_PATH];
GetModuleFileName( AfxGetInstanceHandle(),chINIPath,sizeof(chINIPath) );
char *a,*b;
a = b = chINIPath;
while(b)
{
b=strchr(a+1,'.');
if(b) a=b;
}
strcpy((a+1),"ini");
// read parameters from mp_ap.ini
char chValue[64];
sprintf(chValue,"%s",g_chDBPath);
WritePrivateProfileString("System","DB_PATH",chValue,chINIPath);
//g_iFocus=4;
sprintf(chValue,"%d",g_iFocus);
WritePrivateProfileString("System","Focus_Channel",chValue,chINIPath);
sprintf(chValue,"%d",g_SynTime);
WritePrivateProfileString("System","Sync",chValue,chINIPath);
char chSection[16];
for ( int i=0; i < g_nMaxChannel ; i++ )
{
sprintf(chSection,"Channel_%d",i+1);
WritePrivateProfileString(chSection,"Host_IP",g_Channel_Info[i].chHostIP,chINIPath);
WritePrivateProfileString(chSection,"User_Name",g_Channel_Info[i].chUserName,chINIPath);
WritePrivateProfileString(chSection,"Password",g_Channel_Info[i].chPassword,chINIPath);
WritePrivateProfileString(chSection,"Server_Model",g_Channel_Info[i].chServer_Type,chINIPath);
sprintf(chValue, "%d", g_Channel_Info[i].dwWantMedia);
WritePrivateProfileString(chSection,"MediaType", chValue, chINIPath);
sprintf(chValue,"%d",g_Channel_Info[i].dwHTTPPort);
WritePrivateProfileString(chSection,"HTTP_Port",chValue,chINIPath);
sprintf(chValue,"%d",g_Channel_Info[i].dwProtocol);
WritePrivateProfileString(chSection,"Protocol",chValue,chINIPath);
sprintf(chValue,"%d",g_Channel_Info[i].dwVolume);
WritePrivateProfileString(chSection,"Volume",chValue,chINIPath);
sprintf(chValue,"%d",g_Channel_Info[i].dwCamera);
WritePrivateProfileString(chSection,"Camera",chValue,chINIPath);
}
}
#if defined(CHECK_DI) && !defined(_SERVERUTL_ASYNC)
DWORD DIPollingProc(LPVOID lpParam)
{
CMP_APDlg *pDlg = (CMP_APDlg*)lpParam;
CString str, strTmp;
HWND hWnd;
int ndidoIndex;
int i, j;
while(1)
{
for (i=0; i<g_nMaxChannel; i++)
{
DWORD dwWaitResult = WaitForSingleObject(pDlg->m_hStopEvent, 0);
if (dwWaitResult == WAIT_OBJECT_0) // stop thread event
return 0;
str = "";
// check DI status
if (g_Channel_Info[i].bConnecting)
{
char lpszModelName[64];
DIDOSTATUS adidoStatus[4];
for (j=0; j<4; j++)
adidoStatus[j] = DIDO_HIGH;
//pDlg->CheckChannelServerUtlHandle(i, TRUE);
if (g_Channel_Info[i].hSrvDev == NULL)
{
TSERVERUTL_DEV_PROPERTY tDevProperty;
ZeroMemory(&tDevProperty, sizeof(tDevProperty));
tDevProperty.lpszHost=g_Channel_Info[i].chHostIP;
tDevProperty.lpszPassword=g_Channel_Info[i].chPassword;
tDevProperty.lpszUserName=g_Channel_Info[i].chUserName;
tDevProperty.dwHttpPort = g_Channel_Info[i].dwHTTPPort;
tDevProperty.lpszServerType = g_Channel_Info[i].chServer_Type;
#define OLD
#ifdef OLD
ServerUtl_CreateDevice(pDlg->m_hServUtil,&g_Channel_Info[i].hSrvDev);
if (ServerUtl_SetDeviceProperty(g_Channel_Info[i].hSrvDev, tDevProperty, FALSE) != S_OK)
{
ServerUtl_DeleteDevice(g_Channel_Info[i].hSrvDev);
g_Channel_Info[i].hSrvDev = NULL;
}
else
{
ServerUtl_GetDeviceModel(g_Channel_Info[i].hSrvDev, lpszModelName);
ServerUtl_OpenDevice(g_Channel_Info[i].hSrvDev, lpszModelName);
}
#else
ServerUtl_CreateDevice(pDlg->m_hServUtil,&g_Channel_Info[i].hSrvDev);
if (ServerUtl_SetDevicePropertyLite(g_Channel_Info[i].hSrvDev, tDevProperty) != S_OK)
{
ServerUtl_DeleteDevice(g_Channel_Info[i].hSrvDev);
g_Channel_Info[i].hSrvDev = NULL;
}
#endif // OLD
}
if (g_Channel_Info[i].hSrvDev)
{
#ifdef OLD
ServerUtl_GetDeviceModel(g_Channel_Info[i].hSrvDev, lpszModelName);
TSrvDepResource_ServerInfo srvInfo;
SrvDepResource_GetParamForServer(lpszModelName, &srvInfo);
#else
TSrvDepResource_ServerInfo srvInfo;
SrvDepResource_GetParamForServerByFriendlyName(g_Channel_Info[i].chServer_Type, &srvInfo);
#endif // OLD
ServerUtl_GetDIStatus(g_Channel_Info[i].hSrvDev, &adidoStatus[0], &adidoStatus[1], &adidoStatus[2], &adidoStatus[3], FALSE);
for (int nCnt = 0; nCnt < (int) srvInfo.dwDiNum; nCnt++)
{
if (adidoStatus[nCnt] == DIDO_HIGH)
strTmp = "H";
else
strTmp = "L";
if (nCnt > 0)
str += "\n";
str += strTmp;
}
strTmp.Format("%s", str);
g_Channel_Info[i].bUpper = !g_Channel_Info[i].bUpper;
if (!g_Channel_Info[i].bUpper)
{
strTmp.MakeLower();
}
str = strTmp;
//pDlg->m_DIVal.SetWindowText(str4);
hWnd = GetDlgItem(pDlg->m_hWnd, IDC_STATIC_DIVAL1 + i);
SetWindowText(hWnd, str);
}
}
else
{
hWnd = GetDlgItem(pDlg->m_hWnd, IDC_STATIC_DIVAL1 + i);
SetWindowText(hWnd, str);
}
}
Sleep(100);
}
return 0;
}
#endif // CHECK_DI && !_SERVERUTL_ASYNC
// CMP_APDlg dialog
CMP_APDlg::~CMP_APDlg()
{
#if defined(CHECK_DI) && !defined(_SERVERUTL_ASYNC)
if (WaitForSingleObject(m_hPollingThread, 0) != WAIT_OBJECT_0)
{
SetEvent(m_hStopEvent);
if (WaitForSingleObject(m_hPollingThread, 500) != WAIT_OBJECT_0)
{
DWORD dwExitCode;
GetExitCodeThread(m_hPollingThread, &dwExitCode);
TerminateThread(m_hPollingThread, dwExitCode);
}
CloseHandle(m_hPollingThread);
}
CloseHandle(m_hStopEvent);
#endif // CHECK_DI && !_SERVERUTL_ASYNC
for ( int i=0 ; i < g_nMaxChannel ; i ++ )
{
DeleteCriticalSection(&g_CS[i]);
}
if (g_hBMP)
::DeleteObject(g_hBMP);
if (m_hUpgradeThread)
CloseHandle(m_hUpgradeThread);
#ifdef _LOG_MSG
DeleteCriticalSection(&g_tLogCS);
#endif // _LOG_MSG
DeleteCriticalSection(&m_CS);
}
CMP_APDlg::CMP_APDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMP_APDlg::IDD, pParent)
//, m_Selected_CH(0)
{
#ifdef _LOG_MSG
InitializeCriticalSection(&g_tLogCS);
#endif // _LOG_MSG
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_hServUtil = NULL;
m_bExit = FALSE;
m_nFRCount = 0;
m_hUpgradeThread = NULL;
m_bNoAudio = FALSE;
m_hAudioCapCh = NULL;
m_hPacketMaker = NULL;
m_bCapturing = FALSE;
InitializeCriticalSection(&m_CS);
}
void CMP_APDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_STATIC_SCREEN, CStatic_Screen);
DDX_Control(pDX, IDC_STATIC_DISPLAY1, CStatic_Display1);
DDX_Control(pDX, IDC_STATIC_DISPLAY2, CStatic_Display2);
DDX_Control(pDX, IDC_STATIC_DISPLAY3, CStatic_Display3);
DDX_Control(pDX, IDC_STATIC_DISPLAY4, CStatic_Display4);
DDX_Radio(pDX,IDC_RADIO_CH1,g_iFocus);//m_Selected_CH);
DDX_Control(pDX, IDC_BUTTON_CH_SETTING, CButton_CH_Setting);
DDX_Control(pDX, IDC_SLIDER_VOLUME, CSliderCtrl_Volume);
DDX_Control(pDX, IDC_BUTTON_CONNECT, CButton_Connect);
DDX_Control(pDX, IDC_BUTTON_RECORD, CButton_Record);
DDX_Control(pDX, IDC_BUTTON_SNAP, CButton_Snap);
// Bill,2004/10/01
DDX_Control(pDX, IDC_SLIDER_RANGE, CSliderCtrl_Range);
DDX_Control(pDX, IDC_BUTTON_PAUSE, CButton_Pause);
DDX_Control(pDX, IDC_BUTTON_PLAY, CButton_Play);
DDX_Control(pDX, IDC_STATIC_CONNECT, CSTatic_Connect);
DDX_Control(pDX, IDC_STATIC_STATUS, m_STATIC_STATUS);
DDX_Control(pDX, IDC_STATIC_DI, m_DIPrompt);
DDX_Control(pDX, IDC_STATIC_DIVAL1, m_DIVal);
DDX_Control(pDX, IDC_STATIC_URL_CMD, m_StaticUrlCmd);
DDX_Control(pDX, IDC_EDIT_URL_CMD, m_editUrlCmd);
DDX_Control(pDX, IDC_BUTTON_POST, m_butPost);
DDX_Control(pDX, IDC_BUTTON_GET, m_butGet);
DDX_Control(pDX, IDC_BUTTON1, CButton_SetDO1);
DDX_Control(pDX, IDC_EDIT1, CEdit_DO1Val);
DDX_Control(pDX, IDC_ENLARGE_WND, CButton_EnlargeWnd);
DDX_Control(pDX, IDC_CHECK_DISPLAY, CButton_ChDisplay);
DDX_Control(pDX, IDC_CONNECT_ALL, m_butConnectAll);
DDX_Control(pDX, IDC_CHECK_EVENTRECORD, m_btnEventDrivenRec);
DDX_Control(pDX, IDC_SHRINK_WND, m_btnShrinkWnd);
DDX_Control(pDX, IDC_EDIT_UART2, m_UartWriteCmd);
DDX_Control(pDX, IDC_BUTTON_GETSYS, m_btnGetSys);
DDX_Control(pDX, IDC_STATIC_FRLAB, m_stcFRPrompt);
DDX_Control(pDX, IDC_BUT_TX, m_btnTx);
DDX_Control(pDX, IDC_EDIT_TXFNAME, m_editTxFileName);
DDX_Control(pDX, IDC_BUT_TX_BROWSE, m_btnTxBrowse);
}
BEGIN_MESSAGE_MAP(CMP_APDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDC_RADIO_CH1, OnBnClickedRadioCh1)
ON_BN_CLICKED(IDC_RADIO_CH2, OnBnClickedRadioCh2)
ON_BN_CLICKED(IDC_RADIO_CH3, OnBnClickedRadioCh3)
ON_BN_CLICKED(IDC_RADIO_CH4, OnBnClickedRadioCh4)
ON_BN_CLICKED(IDC_BUTTON_CH_SETTING, OnBnClickedButtonChSetting)
ON_BN_CLICKED(IDC_BUTTON_CONNECT, OnBnClickedButtonConnect)
ON_BN_CLICKED(IDC_BUTTON_RECORD, OnBnClickedButtonRecord)
ON_WM_TIMER()
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_VOLUME, OnNMReleasedcaptureSliderVolume)
// Bill,2004/10/01
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_RANGE, OnNMReleasedcaptureSliderRange)
ON_BN_CLICKED(IDC_BUTTON_SNAP, OnBnClickedButtonSnap)
ON_BN_CLICKED(IDC_BUTTON_POST, OnBnClickedButtonPost)
ON_BN_CLICKED(IDC_BUTTON_GET, OnBnClickedButtonGet)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedSetDO)
ON_BN_CLICKED(IDC_CONNECT_ALL, OnBnClickedButton2)
ON_BN_CLICKED(IDC_ENLARGE_WND, OnBnClickedButton3)
ON_BN_CLICKED(IDC_READ_UART, OnBnClickedUartRead)
ON_BN_CLICKED(IDC_RADIO_CH5, OnBnClickedRadioCh5)
ON_BN_CLICKED(IDC_RADIO_CH6, OnBnClickedRadioCh6)
ON_BN_CLICKED(IDC_RADIO_CH7, OnBnClickedRadioCh7)
ON_BN_CLICKED(IDC_RADIO_CH8, OnBnClickedRadioCh8)
ON_BN_CLICKED(IDC_RADIO_CH9, OnBnClickedRadioCh9)
ON_BN_CLICKED(IDC_RADIO_CH10, OnBnClickedRadioCh10)
ON_BN_CLICKED(IDC_RADIO_CH11, OnBnClickedRadioCh11)
ON_BN_CLICKED(IDC_RADIO_CH12, OnBnClickedRadioCh12)
ON_BN_CLICKED(IDC_RADIO_CH13, OnBnClickedRadioCh13)
ON_BN_CLICKED(IDC_RADIO_CH14, OnBnClickedRadioCh14)
ON_BN_CLICKED(IDC_RADIO_CH15, OnBnClickedRadioCh15)
ON_BN_CLICKED(IDC_RADIO_CH16, OnBnClickedRadioCh16)
ON_BN_CLICKED(IDC_CHECK_DISPLAY, OnBnClickedCheckDisplay)
ON_BN_CLICKED(IDC_CHECK_EVENTRECORD, OnBnClickedCheckEventrecord)
ON_BN_CLICKED(IDC_SHRINK_WND, OnBnClickedShrinkWnd)
ON_BN_CLICKED(IDC_WRITE_UART, OnBnClickedWriteUart)
ON_BN_CLICKED(IDC_BUTTON_GETSYS, OnBnClickedButtonGetsys)
ON_BN_CLICKED(IDC_CHECK_SWAP12, OnBnClickedCheckSwap12)
ON_BN_CLICKED(IDC_BUT_TX, OnBnClickedButTx)
ON_BN_CLICKED(IDC_BUT_TX_BROWSE, OnBnClickedButTxBrowse)
ON_BN_CLICKED(IDC_CHECK_NOBORDER, OnBnClickedCheckNoborder)
ON_BN_CLICKED(IDC_BUTTON_SETPARAM, OnBnClickedButtonSetparam)
ON_BN_CLICKED(IDC_BUTTON_UPGRADE, OnBnClickedButtonUpgrade)
ON_BN_CLICKED(IDC_BUTTON_GET_SECENTRY, OnBnClickedButtonGetSecentry)
ON_BN_CLICKED(IDC_BUTTON_UPD_REMOTE, OnBnClickedButtonUpdRemote)
ON_BN_CLICKED(IDC_BUTTON_GETMD, OnBnClickedButtonGetmd)
ON_BN_CLICKED(IDC_BUTTON_SETMD, OnBnClickedButtonSetmd)
ON_BN_CLICKED(IDC_BUTTON_TALK, OnBnClickedButtonTalk)
ON_MESSAGE(WM_CLOSE_CHANNEL, OnCloseChannel)
ON_MESSAGE(WM_CONNECT_ERROR, OnConnectError)
ON_MESSAGE(WM_SIGNAL_CHANGED, OnSignalChanged)
ON_MESSAGE(WM_CHECK_UI, OnCallCheckUI)
ON_MESSAGE(WM_DELETE_CONNECTION, OnDeleteDataBrokerConn)
ON_MESSAGE(WM_UPDATE_DIDO, OnUpdateDIDO)
ON_MESSAGE(WM_SHOW_ERROR, OnShowError)
ON_MESSAGE(WM_TALK_EVENT, OnTalkEvent)
ON_MESSAGE(WM_TALK_CLEAN, OnTalkClean)
ON_MESSAGE(WM_SHOW_I_ARRIVE, OnChannelIArrive)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BUTTON_PAUSE, OnBnClickedButtonPause)
ON_BN_CLICKED(IDC_BUTTON_PLAY, OnBnClickedButtonPlay)
ON_WM_MOUSEMOVE()
ON_BN_CLICKED(IDC_CHECK_NON_YUV, OnBnClickedCheckNonYuv)
END_MESSAGE_MAP()
// CMP_APDlg message handlers
BOOL CMP_APDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -