|
|
|
@ -40,55 +40,69 @@ void CRotatoDimmer::RotatoDimmerErrHandle(eAlarmType AlarmType,CString AddInfo,b
|
|
|
|
|
//初始化设备
|
|
|
|
|
bool CRotatoDimmer::InitK10CR1Dev()
|
|
|
|
|
{
|
|
|
|
|
CLogInfo LogInfo;
|
|
|
|
|
LogInfo.m_ClassName = "CRotatoDimmer";
|
|
|
|
|
LogInfo.m_FuncName = "InitK10CR1Dev";
|
|
|
|
|
LogInfo.m_LogMsg = "Start";
|
|
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
|
|
|
|
|
m_bOpenDev = false;
|
|
|
|
|
//int--->char[]
|
|
|
|
|
sprintf_s(m_DevSerialNo, "%d", m_SerialNoVal);
|
|
|
|
|
if (TLI_BuildDeviceList() == 0)
|
|
|
|
|
{
|
|
|
|
|
// get device list size
|
|
|
|
|
short n = TLI_GetDeviceListSize();
|
|
|
|
|
// get LTS serial numbers
|
|
|
|
|
char serialNos[100];
|
|
|
|
|
TLI_GetDeviceListByTypeExt(serialNos, 100, 55);
|
|
|
|
|
// output list of matching devices
|
|
|
|
|
{
|
|
|
|
|
char *searchContext = nullptr;
|
|
|
|
|
char *p = strtok_s(serialNos, ",", &searchContext);
|
|
|
|
|
while (p != nullptr)
|
|
|
|
|
{
|
|
|
|
|
TLI_DeviceInfo deviceInfo;
|
|
|
|
|
// get device info from device
|
|
|
|
|
TLI_GetDeviceInfo(p, &deviceInfo);
|
|
|
|
|
// get strings from device info structure
|
|
|
|
|
char desc[65];
|
|
|
|
|
strncpy_s(desc, deviceInfo.description, 64);
|
|
|
|
|
desc[64] = '\0';
|
|
|
|
|
char serialNo[9];
|
|
|
|
|
strncpy_s(serialNo, deviceInfo.serialNo, 8);
|
|
|
|
|
serialNo[8] = '\0';
|
|
|
|
|
// output
|
|
|
|
|
p = strtok_s(nullptr, ",", &searchContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ISC_Open(m_DevSerialNo) == 0)
|
|
|
|
|
{
|
|
|
|
|
LogInfo.m_LogMsg = "Succ";
|
|
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Alarm
|
|
|
|
|
eAlarmType AlarmType = _AlarmType_RotatoDimmer1_InitDevErr;
|
|
|
|
|
if(m_LaserDeviceType == _LaserDeviceType_MainLaser2)
|
|
|
|
|
AlarmType = _AlarmType_RotatoDimmer2_InitDevErr;
|
|
|
|
|
RotatoDimmerErrHandle(AlarmType,"Device Initialize Failed");
|
|
|
|
|
return false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CLogInfo LogInfo;
|
|
|
|
|
LogInfo.m_ClassName = "CRotatoDimmer";
|
|
|
|
|
LogInfo.m_FuncName = "InitK10CR1Dev";
|
|
|
|
|
LogInfo.m_LogMsg = "Start";
|
|
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
|
|
|
|
|
m_bOpenDev = false;
|
|
|
|
|
//int--->char[]
|
|
|
|
|
sprintf_s(m_DevSerialNo, "%d", m_SerialNoVal);
|
|
|
|
|
if (TLI_BuildDeviceList() == 0)
|
|
|
|
|
{
|
|
|
|
|
// get device list size
|
|
|
|
|
short n = TLI_GetDeviceListSize();
|
|
|
|
|
// get LTS serial numbers
|
|
|
|
|
char serialNos[100];
|
|
|
|
|
TLI_GetDeviceListByTypeExt(serialNos, 100, 55);
|
|
|
|
|
// output list of matching devices
|
|
|
|
|
{
|
|
|
|
|
char *searchContext = nullptr;
|
|
|
|
|
char *p = strtok_s(serialNos, ",", &searchContext);
|
|
|
|
|
while (p != nullptr)
|
|
|
|
|
{
|
|
|
|
|
TLI_DeviceInfo deviceInfo;
|
|
|
|
|
// get device info from device
|
|
|
|
|
TLI_GetDeviceInfo(p, &deviceInfo);
|
|
|
|
|
// get strings from device info structure
|
|
|
|
|
char desc[65];
|
|
|
|
|
strncpy_s(desc, deviceInfo.description, 64);
|
|
|
|
|
desc[64] = '\0';
|
|
|
|
|
char serialNo[9];
|
|
|
|
|
strncpy_s(serialNo, deviceInfo.serialNo, 8);
|
|
|
|
|
serialNo[8] = '\0';
|
|
|
|
|
// output
|
|
|
|
|
p = strtok_s(nullptr, ",", &searchContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static CCriticalSection sec;
|
|
|
|
|
CSingleLock slck(&sec, true);
|
|
|
|
|
if (ISC_Open(m_DevSerialNo) == 0)
|
|
|
|
|
{
|
|
|
|
|
LogInfo.m_LogMsg = "Succ";
|
|
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
//Alarm
|
|
|
|
|
eAlarmType AlarmType = _AlarmType_RotatoDimmer1_InitDevErr;
|
|
|
|
|
if (m_LaserDeviceType == _LaserDeviceType_MainLaser2)
|
|
|
|
|
AlarmType = _AlarmType_RotatoDimmer2_InitDevErr;
|
|
|
|
|
|
|
|
|
|
COperateAlarmPar OperateAlarmPar;
|
|
|
|
|
OperateAlarmPar.m_OperateAlarmType = _OperateAlarmType_SetAlarmOn;
|
|
|
|
|
OperateAlarmPar.m_AlarmType = AlarmType;
|
|
|
|
|
OperateAlarmPar.m_AlarmAddInfo = "打开衰减器异常.";
|
|
|
|
|
OperateAlarmPar.m_bThowException = false;
|
|
|
|
|
gWarningMgr->OperateAlarmState(OperateAlarmPar);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//移动到原点
|
|
|
|
|
void CRotatoDimmer::MoveHome()
|
|
|
|
@ -196,6 +210,7 @@ void CRotatoDimmer::WaitMoveToAngVal(double AngVal)
|
|
|
|
|
int CurDelay = 0;//当前的总延时
|
|
|
|
|
double PerPos = ISC_GetPosition(m_DevSerialNo);//上一个位置
|
|
|
|
|
int NoMoveTimes = 0;//没有移动的判断次数
|
|
|
|
|
int MoveEndTimes = 0;//移动到位的判断次数
|
|
|
|
|
bool bMoveErr = false;
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
@ -218,8 +233,15 @@ void CRotatoDimmer::WaitMoveToAngVal(double AngVal)
|
|
|
|
|
m_CurAng = PosToAngVal(m_CurPos);
|
|
|
|
|
if(IsTwoDbEqual(AngVal,m_CurAng,0.01))//执行完成
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
MoveEndTimes++;
|
|
|
|
|
|
|
|
|
|
if(MoveEndTimes>2)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MoveEndTimes = 0;
|
|
|
|
|
}
|
|
|
|
|
CurDelay += CheckDelay;
|
|
|
|
|
if(CurDelay>WaitDelay)//检测超时
|
|
|
|
|
{
|
|
|
|
@ -569,7 +591,10 @@ void CThorlabsRotatoMotorCtrlMgr::SetLastRotatoDimmerAng(eLaserDeviceType LaserD
|
|
|
|
|
LogInfo.m_LogMsg.Format(" Ang=%lf",Ang);
|
|
|
|
|
LogInfo.m_LogMsg = gLaser->GetLaserDeviceName(LaserDeviceType) + LogInfo.m_LogMsg;
|
|
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
|
|
|
|
|
if (Ang < 0.00001)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(LaserDeviceType==_LaserDeviceType_MainLaser1)
|
|
|
|
|
m_Laser1RotatoDimmerAng = Ang;
|
|
|
|
|
else
|
|
|
|
|