#include "MagDevice.h"
#ifdef _WIN64
#pragma comment(lib, "ThermoGroupSDKLib_x64.lib")
#else
#pragma comment(lib, "ThermoGroupSDKLib.lib")
#endif
#define MAX_CHANNELINDEX (128)
CMagDevice::CMagDevice(HWND hWndMsg) :
m_hWndMsg(hWndMsg)
,m_bInitialized(FALSE)
,m_intChannelIndex(-1)
,m_bIsRecordingAvi(FALSE)
,m_bIsRecordingMGS(FALSE)
,m_bIsRecordingLocalAvi(FALSE)
,m_bIsRecordingLocalMgs(FALSE)
,m_bIsPlayingLocalMgs(FALSE)
,m_intCamIPAddr(0)
{
memset(&m_CamInfo, 0, sizeof(m_CamInfo));
memset(&m_RegContent, 0, sizeof(m_RegContent));
Initialize();
}
CMagDevice::~CMagDevice()
{
if (MAG_IsProcessingImage(m_intChannelIndex))
{
MAG_StopProcessImage(m_intChannelIndex);
}
if (MAG_IsLinked(m_intChannelIndex))
{
DisLinkCamera();//include stop sd storage
}
if (MAG_IsInitialized(m_intChannelIndex))
{
MAG_Free(m_intChannelIndex);
m_bInitialized = FALSE;
}
if (MAG_IsChannelAvailable(m_intChannelIndex))
{
MAG_DelChannel(m_intChannelIndex);
m_intChannelIndex = -1;
}
}
BOOL CMagDevice::Initialize()
{
if (m_bInitialized)
{
return TRUE;
}
if (m_intChannelIndex<=0 || m_intChannelIndex>MAX_CHANNELINDEX)
{
for (int i=1; i<=MAX_CHANNELINDEX; i++)
{
if (!MAG_IsChannelAvailable(i))//find an unused channel
{
BOOL bSuccess = MAG_NewChannel(i);
//ASSERT(bSuccess);
m_intChannelIndex = i;
break;
}
}
}
if (m_intChannelIndex>0 && m_intChannelIndex<=MAX_CHANNELINDEX)
{
m_bInitialized = MAG_Initialize(m_intChannelIndex, m_hWndMsg);
}
return m_bInitialized;
}
BOOL CMagDevice::IsLinked()
{
return MAG_IsLinked(m_intChannelIndex);
}
BOOL CMagDevice::LinkCamera(const char * charIp, UINT intTimeoutMS)
{
return LinkCamera(inet_addr(charIp), intTimeoutMS);
}
BOOL CMagDevice::LinkCameraEx(const char * charIp, USHORT shortCmdPort, USHORT shortImgPort, const char * charCloudUser, const char * charCloudPwd, UINT intCamSN, const char * charCamUser, const char * charCamPwd, UINT intTimeoutMS)
{
return LinkCameraEx(inet_addr(charIp), shortCmdPort, shortImgPort, charCloudUser, charCloudPwd, intCamSN, charCamUser, charCamPwd, intTimeoutMS);
}
BOOL CMagDevice::LinkCamera(UINT intIP, UINT intTimeoutMS)
{
if (MAG_LinkCamera(m_intChannelIndex, intIP, intTimeoutMS))
{
m_intCamIPAddr = intIP;
MAG_GetCamInfo(m_intChannelIndex, &m_CamInfo, sizeof(m_CamInfo));
MAG_ReadCameraRegContent(m_intChannelIndex, &m_RegContent, MAG_DEFAULT_TIMEOUT, FALSE);
return TRUE;
}
else
{
return FALSE;
}
}
BOOL CMagDevice::LinkCameraEx(UINT intIP, USHORT shortCmdPort, USHORT shortImgPort, const char * charCloudUser, const char * charCloudPwd, UINT intCamSN, const char * charCamUser, const char * charCamPwd, UINT intTimeoutMS)
{
#ifdef MAG_Linux_Not_Implemented
return LinkCamera(intIP, intTimeoutMS);
#else
if (MAG_LinkCameraEx(m_intChannelIndex, intIP, shortCmdPort, shortImgPort,
charCloudUser, charCloudPwd, intCamSN, charCamUser, charCamPwd, intTimeoutMS))
{
m_intCamIPAddr = intIP;
MAG_GetCamInfo(m_intChannelIndex, &m_CamInfo, sizeof(m_CamInfo));
MAG_ReadCameraRegContent(m_intChannelIndex, &m_RegContent, MAG_DEFAULT_TIMEOUT, FALSE);
return TRUE;
}
else
{
return FALSE;
}
#endif
}
void CMagDevice::DisLinkCamera()
{
//remember to stop sd storage before dislink
if (m_bIsRecordingMGS)
{
SDCardStorage(SDFileMGS, 0);
}
if (m_bIsRecordingAvi)
{
SDCardStorage(SDFileAVI, 0);
}
m_intCamIPAddr = 0;
MAG_DisLinkCamera(m_intChannelIndex);
}
const struct_CamInfoEx * CMagDevice::GetCamInfoEx()
{
#ifdef MAG_Linux_Not_Implemented
return NULL;
#else
MAG_GetCamInfoEx(m_intChannelIndex, &m_CamInfoEx, sizeof(m_CamInfoEx));
return &m_CamInfoEx;
#endif
}
UINT CMagDevice::GetRecentHeartBeat()
{
return MAG_GetRecentHeartBeat(m_intChannelIndex);
}
BOOL CMagDevice::SetReConnectCallBack(MAG_RECONNECTCALLBACK pCallBack, void * pUserData)
{
return MAG_SetReConnectCallBack(m_intChannelIndex, pCallBack, pUserData);
}
BOOL CMagDevice::ResetCamera()
{
//the user should stop image process before reset
//if you forget, the sdk will call MAG_StopProcessImage()
//remember to stop sd storage before reset
if (m_bIsRecordingMGS)
{
SDCardStorage(SDFileMGS, 0);
}
if (m_bIsRecordingAvi)
{
SDCardStorage(SDFileAVI, 0);
}
if (MAG_ResetCamera(m_intChannelIndex))
{
//MAG_ResetCamera() will call MAG_Free() and MAG_DelChannel()
//so the channel is invalid now
m_bInitialized = FALSE;
m_intChannelIndex = -1;
//this object is reusable after call Initialize()
return TRUE;
}
else
{
return FALSE;
}
}
BOOL CMagDevice::TriggerFFC()
{
return MAG_TriggerFFC(m_intChannelIndex);
}
BOOL CMagDevice::AutoFocus()
{
return MAG_SetPTZCmd(m_intChannelIndex, PTZFocusAuto, 0);
}
BOOL CMagDevice::SetIoAlarmState(BOOL bAlarm)
{
return MAG_SetIoAlarmState(m_intChannelIndex, bAlarm);
}
BOOL CMagDevice::SetPTZCmd(enum PTZCmd cmd, DWORD dwPara)
{
return MAG_SetPTZCmd(m_intChannelIndex, cmd, dwPara);
}
BOOL CMagDevice::QueryPTZState(enum PTZQuery query, int * intValue, UINT intTimeoutMS)
{
return MAG_QueryPTZState(m_intChannelIndex, query, intValue, intTimeoutMS);
}
BOOL CMagDevice::SetSerialCmd(const BYTE * buffer, UINT intBufferLen)
{
return MAG_SetSerialCmd(m_intChannelIndex, buffer, intBufferLen);
}
BOOL CMagDevice::SetSerialCallBack(MAG_SERIALCALLBACK pCallBack, void * pUserData)
{
return MAG_SetSerialCallBack(m_intChannelIndex, pCallBack, pUserData);
}
BOOL CMagDevice::GetCameraTemperature(int intT[4], UINT intTimeoutMS)
{
return MAG_GetCameraTemperature(m_intChannelIndex, intT, intTimeoutMS);
}
BOOL CMagDevice::SetCameraRegContent(const struct_CeRegContent * pContent)
{
if (MAG_SetCameraRegContent(m_intChannelIndex, pContent))
{
MAG_ReadCameraRegContent(m_intChannelIndex, &m_RegContent, 1000 + MAG_DEFAULT_TIMEOUT, FALSE);//we need more time here
return TRUE;
}
else
{
return FALSE;
}
}
BOOL CMagDevice::ReadCameraRegContent2(struct_CfgPara * pContent, UINT intTimeoutM)
{
return MAG_ReadCameraRegContent2(m_intChannelIndex, pContent, intTimeoutM);
}
BOOL CMagDevice::SetCameraRegContent2(const struct_CfgPara * pContent)
{
return MAG_SetCameraRegContent2(m_intChannelIndex, pContent);
}
BOOL CMagDevice::SetUserROIs(const struct_UserROIs * pROI)
{
return MAG_SetUserROIs(m_intChannelIndex, pROI);
}
BOOL CMagDevice::SetUserROIsEx(const struct_RectROI * pROIs, UINT intROINum)
{
return MAG_SetUserROIsEx(m_intChannelIndex, pROIs, intROINum);
}
BOOL CMagDevice::SetIrregularROIs(const struct_IrregularROI * pROIs, UINT intROINum)
{
return MAG_SetIrregularROIs(m_intChannelIndex, pROIs, intROINum);
}
BOOL CMagDevice::SetROIReportCallBack(MAG_ROICALLBACK pCallBack, void * pUserData)
{
return MAG_SetROIReportCallBack(m_intChannelIndex, pCallBack, pUserData);
}
BOOL CMagDevice::SetIrregularROIReportCallBack(MAG_ROICALLBACK pCallBack, void * pUserData)
{
return MAG_SetIrregularROIReportCallBack(m_intChannelIndex, pCallBack, pUserData);
}
BOOL CMagDevice::SetIrregularROIReportExCallBack(MAG_IRREGULARROICALLBACK pCallBack, void * pUserData)
{
return MAG_SetIrregularROIReportExCallBack(m_intChannelIndex, pCallBack, pUserData);
}
BOOL CMagDevice::IsProcessingImage()
{
return MAG_IsProcessingImage(m_intChannelIndex);
}
BOOL CMagDevice::StartProcessImage(const OutputPara * paraOut, MAG_FRAMECALLBACK funcFrame, DWORD dwStreamType, void * pUserData)
{
return MAG_StartProcessImage(m_intChannelIndex, paraOut, funcFrame, dwStreamType, pUserData);
}
BOOL CMagDevice::StartProcessPulseImage(const OutputPara * paraOut, MAG_FRAMECALLBACK funcFrame, DWORD dwStreamType, void * pUserData)
{
return MAG_StartProcessPulseImage(m_intChannelIndex, paraOut, funcFrame, dwStreamType, pUserData);
}
BOOL CMagDevice::TransferPulseImage()
{
return MAG_TransferPulseImage(m_intChannelIndex);
}
void CMagDevice::StopProcessImage()
{
if (m_bIsRecordingLocalAvi)
{
LocalStorageAviStop();
}
if (m_bIsRecordingLocalMgs)
{
LocalStorageMgsStop();
}
MAG_StopProcessImage(m_intChannelIndex);
}
void C
.whl
- 粉丝: 3960
- 资源: 4908
最新资源
- 多微网优化模型matlab 采用粒子群算法分析两个微网的优化调度,得到蓄电池,发电机以及微网间功率传输,程序有参考资料
- 潮流计算程序matlab 牛拉法 采用matlab对9节点进行潮流计算,采用牛拉法,程序运行可靠
- 微网优化调度matlab 采用matlab+yalmip编制含分布式和储能的微网优化模型,程序采用15分钟为采集节点,利用cplex求解,程序考虑发电机的启停约束,程序运行可靠
- PMSM永磁同步电机仿真三电平SVPWM矢量控制matlab PMSM双环矢量控制传统三电平
- 路径规划人工势场法以及改进人工势场法matlab代码,包含了
- MobaXterm 是一款功能强大且实用的终端仿真器软件.docx
- 三菱FX3U底层源码,PLSR源码 总体功能和指令可能支持在RUN中下载程序,支持注释的写入和读取,支持脉冲输出与定位指令(包括PLSY PWM PLSR PLSV DRVI DRVA 等指令
- Oracle Database Gateways for Win32-11gR2
- python071基于RSA加密算法软件的研究设计
- 成熟量产低压无刷伺服驱动 方案 全套软硬件资料 源码 原理图 需要的直接拿 基于28035平台
- 欧姆龙PLC ST语言6轴伺服RS232C通讯板CP1W-C IF0 真实项目程序,ST语言写的FB块 PLC用是两台CP1H-X40DT-D配置4块RS232C通讯板CP1W-CIF01 触摸屏是N
- 欧姆龙CP1H与力士乐VFC-x610变频器通讯程序功能:原创程序,可直接用于现场程序 欧姆龙CP1H的CIF11通讯板,实现对力士乐VFC-x610变频器 设定频率,控制正反转,读取实际频率,读取
- 级联型电力电子变压器,高压直流MMC控制系统,级联数可选,调 制方式有移相载波,nlm及混合调制,拥有冒泡排序,递归排序等方法,可控制三相不平衡与环流
- 西门子PLC双轴定位算法电池焊接控制程序-S7-1200 +威纶通触摸屏 S7-1200PLC做的电池焊接程序,电池包里面有n*m行列个电池 程序设计灵活SCL语言+梯形图,采用了位置试教与定位路径规
- 变压器副边突然短路simulink仿真
- MATLAB代码:基于模型预测控制的楼宇负荷需求响应研究 关键词:楼宇负荷 空调 模型预测控制 需求响应 仿真平台:MATLAB+CVX平台 主要内容:代码主要做的是一个建筑楼宇的需求响应问题,首
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈