You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TwoLaserHead-PushJig/LaiPuLaser/SinglechipCardMgr.cpp

110 lines
4.0 KiB
C++

#include "StdAfx.h"
#include "SinglechipCardMgr.h"
#include "Propertie.h"
#include "PropertieMgr.h"
#include "AuthorityMgr.h"
#include "BitOperation.h"
#define MAX_CARD_CNT 10//最多支持的脱机卡数量
CSinglechipCardMgr *gSinglechipCardMgr = new CSinglechipCardMgr;
CSinglechipCardMgr::CSinglechipCardMgr(void)
{
m_CardCnt = 1;//当前使用的拖机卡数量
for(int i=0;i<MAX_CARD_CNT;i++)
{
CSinglechipCard card;
m_CardVec.push_back(card);
}
}
CSinglechipCardMgr::~CSinglechipCardMgr(void)
{
}
#if 1//属性设置
CMFCPropertyGridProperty *CSinglechipCardMgr::CreatGridProperty()
{
CString PropertyName;//属性名称
CString Description;//描述
CString Path = _T("SinglechipCard");;//存储路径
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("脱机控制卡");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
if(gAuthorityMgr->CheckAuthority(_FACTORY))
{
{
//添加属性变量映射
Name = _T("m_CardCnt");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_CardCnt);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("脱机卡数量");
Description = _T("当前设备使用脱机卡的个数,修改后需要重启软件");
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_CardCnt, Description);
pGroup->AddSubItem(p);
gDevicePropertieMgr.Insert(p, pPropertie);
}
for(int i=0;i<m_CardCnt;i++)
{
CString Idx;
Idx.Format("%ld",i+1);
PropertyName = "脱机卡" + Idx;
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(PropertyName);
{
//添加属性变量映射
Name = "m_CardVec_Com_" + Idx;//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&(m_CardVec[i].m_ComPort));
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("串口号");
Description = _T("拖机卡使用的串口号");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CardVec[i].m_ComPort, Description);
pGroup1->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
pGroup->AddSubItem(pGroup1);
}
}
//-------------------------------------------------------------------------------//
return pGroup;
}
void CSinglechipCardMgr::ExportPar(ofstream *pFile)
{
(*pFile)<<"[模块] [CSinglechipCardMgr]------------------------------------------------"<<endl;
for(int i=0;i<m_CardCnt;i++)
{
(*pFile)<<"[拖机卡]"<<i<<endl;
(*pFile)<<"[串口号]"<<m_CardVec[i].m_ComPort<<endl;
}
}
#endif
//获得拖机卡的com 端口号(idx 从0 开始)
//129 打开com 口1 (10000001) //第八位表示打开
//130 打开com 口2 (10000010) //第八位表示打开
//131 打开com 口3 (10000011) //第八位表示打开
BYTE CSinglechipCardMgr::GetCardCom(int idx)
{
if((idx+1)>m_CardCnt)
return 0;
int com = m_CardVec[idx].m_ComPort;
BYTE ret = (BYTE)com;
ret = SetBitOn(ret,7);//高位置1
return ret;
}