From c3a57c4a4dd763d980c8da94c60290c59c625579 Mon Sep 17 00:00:00 2001 From: fandayu <57091941+fandayu@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:57:08 +0800 Subject: [PATCH] Update MMTUCam.cpp support aries 16 lt/fl 26bw/fl 9bw --- DeviceAdapters/TUCam/MMTUCam.cpp | 1556 ++++++++++++++++++++++++++---- 1 file changed, 1390 insertions(+), 166 deletions(-) diff --git a/DeviceAdapters/TUCam/MMTUCam.cpp b/DeviceAdapters/TUCam/MMTUCam.cpp index b54ca7cd1..f55059d08 100755 --- a/DeviceAdapters/TUCam/MMTUCam.cpp +++ b/DeviceAdapters/TUCam/MMTUCam.cpp @@ -8,9 +8,9 @@ // microscope devices and enables testing of the rest of the // system without the need to connect to the actual hardware. // -// AUTHOR: fandayu, fandayu@tucsen.com 2022 +// AUTHOR: fandayu, fandayu@tucsen.com 2024 // -// COPYRIGHT: Tucsen Photonics Co., Ltd., 2022 +// COPYRIGHT: Tucsen Photonics Co., Ltd., 2024 // LICENSE: This file is distributed under the BSD license. // License text is included with the source distribution. // @@ -70,11 +70,14 @@ const char* g_PropNameLED = "LEDMode"; const char* g_PropNameTEC = "TECMode"; const char* g_PropNamePI = "PIMode"; const char* g_PropNameDepth = "DepthMode"; +const char* g_PropNameShutter = "Shutter Mode"; const char* g_PropNameMdTgr = "Trigger Mode"; const char* g_PropNameMdExp = "Trigger Exposure Mode"; const char* g_PropNameMdEdg = "Trigger Edge Mode"; const char* g_PropNameMdDly = "Trigger Delay"; +const char* g_PropNameFilter= "Signal Filter"; const char* g_PropNameMdFrames = "Trigger Frames"; +const char* g_PropNameMdTFrames = "Trigger Total Frames"; const char* g_PropNameDoSFW = "Trigger Software Do"; const char* g_PropNameSharp = "Image Adjustment Sharpness"; const char* g_PropNameDPC = "Image Adjustment DPC"; @@ -97,6 +100,13 @@ const char* g_PropNameFrameRate = "Frame Rate"; const char* g_PropNameTestImg = "Test Image"; +const char* g_PropNameBrightness = "Targeting Level"; //"Brightness"; +const char* g_PropNamePixelRatio = "Metering Level"; //"Pixel Ratio"; +const char* g_PropNameImgMetadata= "Image Metadata"; +const char* g_PropNameATExpMode = "ATExposure Mode"; + +const char* g_PropNameBinningSum = "Binning Sum"; + const char* g_DeviceName = "Dhyana"; //"400Li" const char* g_SdkName = "TUCam"; //const char* g_SdkName = "CamCore"; @@ -148,6 +158,8 @@ const char* g_GLOBALRESET_ON = "Global Reset"; /// GlobalReset Hg const char* g_TRIGGER_OFF = "Off"; const char* g_TRIGGER_STD = "Standard"; +const char* g_TRIGGER_STDOVERLAP = "Standard(Overlap)"; +const char* g_TRIGGER_STDNONOVERLAP = "Standard(Non-Overlap)"; const char* g_TRIGGER_CC1 = "CC1"; const char* g_TRIGGER_SYN = "Synchronization"; const char* g_TRIGGER_GLB = "Global"; @@ -160,6 +172,7 @@ const char* g_TRIGGER_PORT3 = "3"; const char* g_TRIGGER_EXPSTART = "Exposure Start"; const char* g_TRIGGER_READEND = "Readout End"; const char* g_TRIGGER_GLBEXP = "Global Exposure"; +const char* g_TRIGGER_TRIREADY = "Trigger Ready"; const char* g_TRIGGER_LOW = "Low"; const char* g_TRIGGER_HIGH = "High"; @@ -292,6 +305,7 @@ CMMTUCam::CMMTUCam() : m_frame.ucFormatGet = TUFRM_FMT_USUAl; m_frame.pBuffer = NULL; + m_nZeroTemp = 50; m_nPID = 0; m_nBCD = 0; m_nIdxGain = 0; @@ -454,6 +468,13 @@ int CMMTUCam::Initialize() m_nBCD = valInfo.nValue; } + // Get Zero Temperature Value + valInfo.nID = TUIDI_ZEROTEMPERATURE_VALUE; + if (TUCAMRET_SUCCESS == TUCAM_Dev_GetInfo(m_opCam.hIdxTUCam, &valInfo)) + { + m_nZeroTemp = valInfo.nValue; + } + // Get camera type valInfo.nID = TUIDI_PRODUCT; if (TUCAMRET_SUCCESS == TUCAM_Dev_GetInfo(m_opCam.hIdxTUCam, &valInfo)) @@ -477,7 +498,7 @@ int CMMTUCam::Initialize() m_bTriEn = false; } - if (PID_FL_20BW == m_nPID || DHYANA_4040V2 == m_nPID || DHYANA_4040BSI == m_nPID || DHYANA_XF4040BSI == m_nPID) + if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID || PID_FL_26BW == m_nPID || PID_FL_20BW == m_nPID || DHYANA_4040V2 == m_nPID || DHYANA_4040BSI == m_nPID || DHYANA_XF4040BSI == m_nPID) { m_bOffsetEn = true; } @@ -519,16 +540,30 @@ int CMMTUCam::Initialize() if (nRet != DEVICE_OK) return nRet; + if (PID_FL_26BW == m_nPID) + { + // binning sum + pAct = new CPropertyAction(this, &CMMTUCam::OnBinningSum); + nRet = CreateProperty(g_PropNameBinningSum, "", MM::String, false, pAct); + assert(nRet == DEVICE_OK); + + nRet = SetAllowedBinningSum(); + if (nRet != DEVICE_OK) + return nRet; + } + // Bit depth capaAttr.idCapa = TUIDC_BITOFDEPTH; if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) { if(capaAttr.nValMax != capaAttr.nValMin && m_nPID != DHYANA_D95_X100) { - if (DHYANA_400DC_X100 == m_nPID || DHYANA_400DC_X45 == m_nPID) + if (capaAttr.nValMax > 8) { - TUCAM_Capa_SetValue(m_opCam.hIdxTUCam, TUIDC_BITOFDEPTH, 8); - } + if (DHYANA_400DC_X100 == m_nPID || DHYANA_400DC_X45 == m_nPID) + { + TUCAM_Capa_SetValue(m_opCam.hIdxTUCam, TUIDC_BITOFDEPTH, 8); + } pAct = new CPropertyAction (this, &CMMTUCam::OnBitDepth); nRet = CreateProperty(g_PropNameBODP, "8", MM::String, false, pAct); @@ -538,9 +573,18 @@ int CMMTUCam::Initialize() bitDepths.push_back("8"); bitDepths.push_back("16"); - nRet = SetAllowedValues(g_PropNameBODP, bitDepths); - if (nRet != DEVICE_OK) - return nRet; + nRet = SetAllowedValues(g_PropNameBODP, bitDepths); + if (nRet != DEVICE_OK) + return nRet; + } + else + { + pAct = new CPropertyAction(this, &CMMTUCam::OnBitDepthEum); + nRet = CreateProperty(g_PropNameBODP, "", MM::String, false, pAct); + SetAllowedDepth(); + if (nRet != DEVICE_OK) + return nRet; + } } } @@ -569,13 +613,30 @@ int CMMTUCam::Initialize() assert(nRet == DEVICE_OK); UpdateExpRange(); - /*exposureMaximum_ = propAttr.dbValMax; - exposureMinimum_ = propAttr.dbValMin; - if(m_nPID == PID_FL_20BW) - { - exposureMaximum_ = 3600000; - } - SetPropertyLimits(MM::g_Keyword_Exposure, exposureMinimum_, exposureMaximum_);*/ + } + + // Brightness + propAttr.nIdxChn = 0; + propAttr.idProp = TUIDP_BRIGHTNESS; + if (TUCAMRET_SUCCESS == TUCAM_Prop_GetAttr(m_opCam.hIdxTUCam, &propAttr)) + { + pAct = new CPropertyAction(this, &CMMTUCam::OnBrightness); + nRet = CreateProperty(g_PropNameBrightness, "0", MM::Integer, false, pAct); + assert(nRet == DEVICE_OK); + + SetPropertyLimits(g_PropNameBrightness, propAttr.dbValMin, propAttr.dbValMax); + } + + // PixelRatio + propAttr.nIdxChn = 0; + propAttr.idProp = TUIDP_PIXELRATIO; + if (TUCAMRET_SUCCESS == TUCAM_Prop_GetAttr(m_opCam.hIdxTUCam, &propAttr)) + { + pAct = new CPropertyAction(this, &CMMTUCam::OnPixelRatio); + nRet = CreateProperty(g_PropNamePixelRatio, "0", MM::Integer, false, pAct); + assert(nRet == DEVICE_OK); + + SetPropertyLimits(g_PropNamePixelRatio, propAttr.dbValMin, propAttr.dbValMax); } // Global Gain @@ -593,9 +654,38 @@ int CMMTUCam::Initialize() } else { - nRet = SetAllowedGainMode(); - if (nRet != DEVICE_OK) - return nRet; + if (m_nPID == PID_FL_9BW || PID_FL_9BW_LT == m_nPID || PID_FL_26BW == m_nPID || IsSupportAries16()) + { + int nCnt = (int)(propAttr.dbValMax - propAttr.dbValMin + 1); + + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + valText.nID = TUIDP_GLOBALGAIN; + + vector gainValues; + + for (int i = 0; i StampValues; + StampValues.push_back("FALSE"); + StampValues.push_back("TRUE"); + + nRet = SetAllowedValues(g_PropNameImgMetadata, StampValues); + if (nRet != DEVICE_OK) + return nRet; + } + } + // Sensor reset capaAttr.idCapa = TUIDC_SENSORRESET; if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) @@ -619,6 +729,17 @@ int CMMTUCam::Initialize() AddAllowedValue(g_PropNameReset, g_PropNameReset); } + // Auto Exposure Mode + capaAttr.idCapa = TUIDC_ATEXPOSURE_MODE; + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + pAct = new CPropertyAction(this, &CMMTUCam::OnATExpMode); + nRet = CreateProperty(g_PropNameATExpMode, "0", MM::Integer, false, pAct); + assert(nRet == DEVICE_OK); + + SetPropertyLimits(g_PropNameATExpMode, capaAttr.nValMin, capaAttr.nValMax); + } + // Auto Exposure capaAttr.idCapa = TUIDC_ATEXPOSURE; if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) @@ -669,7 +790,18 @@ int CMMTUCam::Initialize() if (nRet != DEVICE_OK) return nRet; } - + + // Shutter + if (PID_FL_26BW == m_nPID) + { + pAct = new CPropertyAction(this, &CMMTUCam::OnShutterMode); + nRet = CreateProperty(g_PropNameShutter, "", MM::String, false, pAct); + assert(nRet == DEVICE_OK); + + nRet = SetAllowedShutterMode(); + if (nRet != DEVICE_OK) + return nRet; + } // Gamma propAttr.nIdxChn= 0; @@ -796,12 +928,30 @@ int CMMTUCam::Initialize() if (TUCAMRET_SUCCESS == TUCAM_Prop_GetAttr(m_opCam.hIdxTUCam, &propAttr) && m_bTempEn) // For 401D 201D disable temperature { pAct = new CPropertyAction (this, &CMMTUCam::OnTemperature); - nRet = CreateProperty(g_PropNameTEMP, "0", MM::Integer, false, pAct); - m_nMidTemp = (int)((propAttr.dbValMax - propAttr.dbValMin) / 2); - SetPropertyLimits(g_PropNameTEMP, -m_nMidTemp, m_nMidTemp); - char sz[64] = { 0 }; + if (propAttr.dbValMax > 100) + { + m_fScaTemp = 10; + nRet = CreateProperty(g_PropNameTEMP, "0.0", MM::Float, false, pAct); + } + else + { + m_fScaTemp = 1; + nRet = CreateProperty(g_PropNameTEMP, "0", MM::Integer, false, pAct); + } + m_nMidTemp = m_nZeroTemp; + if (PID_FL_9BW_LT == m_nPID) + { + ///m_nMidTemp = 500; + SetPropertyLimits(g_PropNameTEMP, (propAttr.dbValMin - m_nMidTemp) / m_fScaTemp, (propAttr.dbValMax - m_nMidTemp) / m_fScaTemp); + } + else + { + SetPropertyLimits(g_PropNameTEMP, -m_nMidTemp / m_fScaTemp, m_nMidTemp / m_fScaTemp); + } + + char sz[64] = { 0 }; switch (m_nPID) { case PID_FL_20BW: @@ -812,8 +962,8 @@ int CMMTUCam::Initialize() SetProperty(g_PropNameTEMP, sz); } break; - case DHYANA_400BSIV2: - case DHYANA_400BSIV3: +// case DHYANA_400BSIV2: +// case DHYANA_400BSIV3: case DHYANA_D95_V2: case DHYANA_4040V2: case DHYANA_4040BSI: @@ -824,11 +974,21 @@ int CMMTUCam::Initialize() break; default: // Set default temperature - if (TUCAMRET_SUCCESS == TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_TEMPERATURE, 40.0f)) - { - sprintf(sz, "%d", -10); - SetProperty(g_PropNameTEMP, sz); - } + double dblTemp; + if (TUCAMRET_SUCCESS == TUCAM_Prop_GetValue(m_opCam.hIdxTUCam, TUIDP_TEMPERATURE_TARGET, &dblTemp)) + { + sprintf(sz, "%.1f", (dblTemp - m_nMidTemp) / m_fScaTemp); + SetProperty(g_PropNameTEMP, sz); + } + else + { + if (TUCAMRET_SUCCESS == TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_TEMPERATURE, 40.0f)) + { + sprintf(sz, "%d", -10); + SetProperty(g_PropNameTEMP, sz); + } + } + break; } @@ -875,11 +1035,17 @@ int CMMTUCam::Initialize() capaAttr.idCapa = TUIDC_IMGMODESELECT; if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) { - int nImgMode = capaAttr.nValMax - capaAttr.nValMin +1; - - if((nImgMode < 0x3) && (capaAttr.nValMax < 0x02)) - { - pAct = new CPropertyAction (this, &CMMTUCam::OnCMSMode); + if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID) + { + nRet = SetAllowedGainMode(); + } + else + { + int nImgMode = capaAttr.nValMax - capaAttr.nValMin + 1; + + if ((nImgMode < 0x3) && (capaAttr.nValMax < 0x02) && PID_FL_9BW != m_nPID && PID_FL_9BW_LT != m_nPID) + { + pAct = new CPropertyAction(this, &CMMTUCam::OnCMSMode); nRet = CreateProperty(g_PropNameCMS, g_CMS_ON, MM::String, false, pAct); assert(nRet == DEVICE_OK); @@ -888,9 +1054,11 @@ int CMMTUCam::Initialize() CMSValues.push_back(g_CMS_OFF); CMSValues.push_back(g_CMS_ON); - nRet = SetAllowedValues(g_PropNameCMS, CMSValues); + nRet = SetAllowedValues(g_PropNameCMS, CMSValues); + + } + } - } if (nRet != DEVICE_OK) return nRet; } @@ -1055,17 +1223,31 @@ int CMMTUCam::Initialize() vectorModTgrValues; ModTgrValues.push_back(g_TRIGGER_OFF); - ModTgrValues.push_back(g_TRIGGER_STD); + + if (IsSupport95V2New() || IsSupport401DNew() || IsSupport400BSIV3New()) + { + ModTgrValues.push_back(g_TRIGGER_STDOVERLAP); + ModTgrValues.push_back(g_TRIGGER_STDNONOVERLAP); + } + else + { + ModTgrValues.push_back(g_TRIGGER_STD); + } int nImgMode = 0; switch (m_nPID) { + case PID_FL_9BW: + case PID_FL_9BW_LT: + case PID_FL_26BW: case PID_FL_20BW: case DHYANA_401D: case DHYANA_201D: case DHYANA_4040V2: case DHYANA_4040BSI: case DHYANA_XF4040BSI: + case PID_ARIES16LT: + case PID_ARIES16: { if (TU_PHXCAMERALINK == m_nDriverType) { @@ -1130,7 +1312,25 @@ int CMMTUCam::Initialize() nRet = CreateProperty(g_PropNameMdDly, "0", MM::Integer, false, pAct); assert(nRet == DEVICE_OK); - SetPropertyLimits(g_PropNameMdDly, 0, 10000000); + // Trigger Filter + capaAttr.idCapa = TUIDC_SIGNALFILTER; + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + pAct = new CPropertyAction(this, &CMMTUCam::OnTriggerFilter); + nRet = CreateProperty(g_PropNameFilter, "0", MM::Integer, false, pAct); + assert(nRet == DEVICE_OK); + SetPropertyLimits(g_PropNameFilter, 1, 1000000); + } + + if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID || PID_FL_26BW == m_nPID) + { + // Trigger total frames + pAct = new CPropertyAction(this, &CMMTUCam::OnTriggerTotalFrames); + nRet = CreateProperty(g_PropNameMdTFrames, "1", MM::Integer, false, pAct); + assert(nRet == DEVICE_OK); + } + + SetPropertyLimits(g_PropNameMdTFrames, 1, 0xFFFF); if (TUCAMRET_SUCCESS == TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_ROLLINGSCANMODE, &m_rsPara.nMode)) { @@ -1139,7 +1339,7 @@ int CMMTUCam::Initialize() nRet = CreateProperty(g_PropNameMdFrames, "1", MM::Integer, false, pAct); assert(nRet == DEVICE_OK); - SetPropertyLimits(g_PropNameMdFrames, 1, 65535); + SetPropertyLimits(g_PropNameMdFrames, 1, 0xFFFF); } } } @@ -1324,6 +1524,10 @@ int CMMTUCam::Initialize() ModKindValues.push_back(g_TRIGGER_EXPSTART); ModKindValues.push_back(g_TRIGGER_READEND); ModKindValues.push_back(g_TRIGGER_GLBEXP); + if (IsSupport95V2New() || IsSupport401DNew() || IsSupport400BSIV3New()) + { + ModKindValues.push_back(g_TRIGGER_TRIREADY); + } ModKindValues.push_back(g_TRIGGER_LOW); ModKindValues.push_back(g_TRIGGER_HIGH); @@ -1524,10 +1728,12 @@ int CMMTUCam::SnapImage() StartCapture(); } + int nRet = DEVICE_ERR; + if (TUCCM_TRIGGER_SOFTWARE == m_tgrAttr.nTgrMode) { int nCnt = 0; - int nRet = DEVICE_ERR; + ///int nRet = DEVICE_ERR; do { @@ -1546,7 +1752,7 @@ int CMMTUCam::SnapImage() CDeviceUtils::SleepMs((long) exp); } ///TUDBG_PRINTF("SanpImage fastImage_ = %d",fastImage_); - WaitForFrame(img_); + nRet = WaitForFrame(img_); } } @@ -1557,7 +1763,7 @@ int CMMTUCam::SnapImage() StopCapture(); } - return DEVICE_OK; + return nRet/*DEVICE_OK*/; } @@ -1730,8 +1936,7 @@ int CMMTUCam::SetROI(unsigned x, unsigned y, unsigned xSize, unsigned ySize) roiY_ = y; m_bROI = true; - - StartCapture(); +// StartCapture(); ResizeImageBuffer(); Sleep(2); @@ -1782,7 +1987,7 @@ int CMMTUCam::ClearROI() roiY_ = 0; m_bROI = false; - StartCapture(); +// StartCapture(); ResizeImageBuffer(); return DEVICE_OK; @@ -2001,6 +2206,39 @@ int CMMTUCam::LineIntervalCal(int nVal, bool bExpChange) return nStep; } +int CMMTUCam::SetAllowedDepth() +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + TUCAM_CAPA_ATTR capaAttr; + capaAttr.idCapa = TUIDC_BITOFDEPTH; + + if (TUCAMRET_SUCCESS != TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + return DEVICE_NOT_SUPPORTED; + } + + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_BITOFDEPTH; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + vector depthValues; + int nCnt = capaAttr.nValMax - capaAttr.nValMin + 1; + + for (int i = 0; i binValues; + int nCnt = capaAttr.nValMax - capaAttr.nValMin + 1; + + for (int i = 0; i modeValues; + int nCnt = capaAttr.nValMax - capaAttr.nValMin + 1; + + for (int i = 0; i shutters; + + for (int i = 0; iIsStopped() && !returnToSoftwareTriggers_) - return DEVICE_OK; - + TUDBG_PRINTF("[StopSequenceAcquisition]:Enter \n"); + if (thd_->IsStopped() /*&& !returnToSoftwareTriggers_*/) + { + if (m_bLiving) + { + m_bAcquisition = false; + StopCapture(); + } + return DEVICE_OK; + } + m_bLiving = false; if (NULL == m_opCam.hIdxTUCam) @@ -2423,13 +2784,13 @@ int CMMTUCam::StopSequenceAcquisition() ReleaseBuffer(); // Switch back to software trigger mode if that is what the user used - if (returnToSoftwareTriggers_) + /*if (returnToSoftwareTriggers_) { TUCAM_Cap_GetTrigger(m_opCam.hIdxTUCam, &m_tgrAttr); m_tgrAttr.nTgrMode = TUCCM_TRIGGER_SOFTWARE; TUCAM_Cap_SetTrigger(m_opCam.hIdxTUCam, m_tgrAttr); returnToSoftwareTriggers_ = false; - } + }*/ m_bAcquisition = false; ///StartCapture(); // avoid wasting time in the SnapImage function @@ -2546,18 +2907,22 @@ int CMMTUCam::RunSequenceOnThread(MM::MMTime startTime) } ret = WaitForFrame(img_); + /* if (!fastImage_) { GenerateSyntheticImage(img_, GetSequenceExposure()); } */ - ret = InsertImage(); - - while (((double) (this->GetCurrentMMTime() - startTime).getMsec() / imageCounter_) < this->GetSequenceExposure()) + if (DEVICE_OK == ret) + { + ret = InsertImage(); + } + + /* while (((double) (this->GetCurrentMMTime() - startTime).getMsec() / imageCounter_) < this->GetSequenceExposure()) { CDeviceUtils::SleepMs(1); - } + }*/ if (ret != DEVICE_OK) { @@ -2730,9 +3095,10 @@ int CMMTUCam::OnBinning(MM::PropertyBase* pProp, MM::ActionType eAct) valText.nTextSize = 64; valText.pText = &szBuf[0]; + int i = 0; int nCnt = capaAttr.nValMax - capaAttr.nValMin + 1; - for (int i=0; iSet(valText.pText); + if (nIdx > 0) + { + valText.dbValue = nIdx; + valText.nID = TUIDC_BINNING_SUM; + + TUCAM_Capa_GetValueText(m_opCam.hIdxTUCam, &valText); + pProp->Set(valText.pText); + } + else + { + valText.dbValue = 0; + valText.nID = TUIDC_RESOLUTION; + + TUCAM_Capa_GetValueText(m_opCam.hIdxTUCam, &valText); + pProp->Set(valText.pText); + } + } + else + { + int nIdx = 0; + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_RESOLUTION, &nIdx); + + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_RESOLUTION; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + valText.dbValue = nIdx; + TUCAM_Capa_GetValueText(m_opCam.hIdxTUCam, &valText); + pProp->Set(valText.pText); + } + ret = DEVICE_OK; } break; @@ -2785,6 +3230,88 @@ int CMMTUCam::OnBinning(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +/** +* Handles "BinningSum" property. +*/ +int CMMTUCam::OnBinningSum(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + string val; + pProp->Get(val); + + if (val.length() != 0) + { + TUCAM_CAPA_ATTR capaAttr; + capaAttr.idCapa = TUIDC_BINNING_SUM; + + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_BINNING_SUM; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + int nCnt = (int)(capaAttr.nValMax - capaAttr.nValMin + 1); + + for (int i = 0; iSet(valText.pText); + + ret = DEVICE_OK; + } + break; + default: + break; + } + return ret; +} + /** * Handles "PixelClock" property. */ @@ -2912,6 +3439,84 @@ int CMMTUCam::OnExposure(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +/** +* Handles "Brightness" property. +*/ +int CMMTUCam::OnBrightness(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + double dbVal = 0.0f; + pProp->Get(dbVal); + + TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_BRIGHTNESS, dbVal); + + ret = DEVICE_OK; + } + break; + case MM::BeforeGet: + { + double dbVal = 0.0f; + + TUCAM_Prop_GetValue(m_opCam.hIdxTUCam, TUIDP_BRIGHTNESS, &dbVal); + + pProp->Set(dbVal); + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + +/** +* Handles "OnPixelRatio" property. +*/ +int CMMTUCam::OnPixelRatio(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + double dbVal = 0.0f; + pProp->Get(dbVal); + + TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_PIXELRATIO, dbVal); + + ret = DEVICE_OK; + } + break; + case MM::BeforeGet: + { + double dbVal = 0.0f; + + TUCAM_Prop_GetValue(m_opCam.hIdxTUCam, TUIDP_PIXELRATIO, &dbVal); + + pProp->Set(dbVal); + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + /** * Handles "GlobalGain" property. */ @@ -2963,20 +3568,20 @@ int CMMTUCam::OnFrameRate(MM::PropertyBase* pProp, MM::ActionType eAct) { case MM::AfterSet: { - double dblGain; - pProp->Get(dblGain); + double dblRate; + pProp->Get(dblRate); - TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_FRAME_RATE, dblGain); + TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_FRAME_RATE, dblRate); ret = DEVICE_OK; } break; case MM::BeforeGet: { - double dblGain = 0.0f; + double dblRate = 0.0f; - TUCAM_Prop_GetValue(m_opCam.hIdxTUCam, TUIDP_FRAME_RATE, &dblGain); - pProp->Set(dblGain); + TUCAM_Prop_GetValue(m_opCam.hIdxTUCam, TUIDP_FRAME_RATE, &dblRate); + pProp->Set(dblRate); ret = DEVICE_OK; } @@ -3812,6 +4417,94 @@ int CMMTUCam::OnTestImageMode(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +/** +* Handles "OnGlobalGainMode" property. +*/ +int CMMTUCam::OnGlobalGainMode(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + if (IsCapturing()) + return DEVICE_CAMERA_BUSY_ACQUIRING; + + // the user just set the new value for the property, so we have to + // apply this value to the 'hardware'. + + string val; + pProp->Get(val); + + if (val.length() != 0) + { + TUCAM_PROP_ATTR propAttr; + propAttr.nIdxChn = 0; + propAttr.idProp = TUIDP_GLOBALGAIN; + + if (TUCAMRET_SUCCESS == TUCAM_Prop_GetAttr(m_opCam.hIdxTUCam, &propAttr)) + { + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDP_GLOBALGAIN; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + int nCnt = (int)(propAttr.dbValMax - propAttr.dbValMin + 1); + + for (int i = 0; iSet(valText.pText); + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + /** * Handles "OnGAINMode" property. */ @@ -3825,42 +4518,88 @@ int CMMTUCam::OnGAINMode(MM::PropertyBase* pProp, MM::ActionType eAct) { case MM::AfterSet: { - int nVal = 0; - int nImgMode = 0; - int nGain = 0; - double dblExp = 0.0; - string val; - pProp->Get(val); - if (val.length() != 0) + if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID) { - if (TUCAMRET_SUCCESS == TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_IMGMODESELECT, &nVal)) - { - if (DHYANA_D95_V2 == m_nPID) - { - bool bLiving = m_bLiving; - if (0 == val.compare(g_HDRBIT_ON)) - { - nImgMode = 0; //HDR - nGain = 0; - } - else if(0 == val.compare(g_HIGHBIT_ON)) - { - nImgMode = 0; //HIGH - nGain = 1; - } - else if(0 == val.compare(g_LOWBIT_ON)) - { - nImgMode = 0; //LOW - nGain = 2; - } - else if(0 == val.compare(g_STDHIGH_ON)) - { - nImgMode = 1; //STDH - } - else if(0 == val.compare(g_STDLOW_ON)) - { - nImgMode = 2; //STDL - } + string val; + pProp->Get(val); + + if (val.length() != 0) + { + TUCAM_CAPA_ATTR capaAttr; + capaAttr.idCapa = TUIDC_IMGMODESELECT; + + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_IMGMODESELECT; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + int nCnt = capaAttr.nValMax - capaAttr.nValMin + 1; + + for (int i = 0; i < nCnt; i++) + { + valText.dbValue = i; + TUCAM_Capa_GetValueText(m_opCam.hIdxTUCam, &valText); + + if (0 == val.compare(valText.pText)) + { + TUCAM_Capa_SetValue(m_opCam.hIdxTUCam, TUIDC_IMGMODESELECT, i); + break; + } + } + } + + OnPropertyChanged(g_PropNameMode, val.c_str()); + + double val = 0; + TUCAM_Prop_GetValue(m_opCam.hIdxTUCam, TUIDP_GLOBALGAIN, &val); + SetProperty(g_PropNameGain, CDeviceUtils::ConvertToString((int)val)); + + UpdateExpRange(); + + ret = DEVICE_OK; + } + } + else + { + int nVal = 0; + int nImgMode = 0; + int nGain = 0; + double dblExp = 0.0; + string val; + pProp->Get(val); + if (val.length() != 0) + { + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_IMGMODESELECT, &nVal)) + { + if (DHYANA_D95_V2 == m_nPID) + { + bool bLiving = m_bLiving; + if (0 == val.compare(g_HDRBIT_ON)) + { + nImgMode = 0; //HDR + nGain = 0; + } + else if (0 == val.compare(g_HIGHBIT_ON)) + { + nImgMode = 0; //HIGH + nGain = 1; + } + else if (0 == val.compare(g_LOWBIT_ON)) + { + nImgMode = 0; //LOW + nGain = 2; + } + else if (0 == val.compare(g_STDHIGH_ON)) + { + nImgMode = 1; //STDH + } + else if (0 == val.compare(g_STDLOW_ON)) + { + nImgMode = 2; //STDL + } if (nImgMode != nVal) { @@ -3918,27 +4657,28 @@ int CMMTUCam::OnGAINMode(MM::PropertyBase* pProp, MM::ActionType eAct) UpdateExpRange(); - if ((DHYANA_400BSIV2 == m_nPID && m_nBCD > 0x04)) - { - vectorModTgrValues; - ModTgrValues.push_back(g_TRIGGER_OFF); - if (0 == val.compare(g_GRLOW_ON) || 0 == val.compare(g_GRHIGH_ON)) - { - ModTgrValues.push_back(g_TRIGGER_STD); - } - else - { - ModTgrValues.push_back(g_TRIGGER_STD); - ModTgrValues.push_back(g_TRIGGER_SYN); - } - ModTgrValues.push_back(g_TRIGGER_SWF); - ClearAllowedValues(g_PropNameMdTgr); - SetAllowedValues(g_PropNameMdTgr, ModTgrValues); - } - } - } - - ret = DEVICE_OK; + if ((DHYANA_400BSIV2 == m_nPID && m_nBCD > 0x04)) + { + vectorModTgrValues; + ModTgrValues.push_back(g_TRIGGER_OFF); + if (0 == val.compare(g_GRLOW_ON) || 0 == val.compare(g_GRHIGH_ON)) + { + ModTgrValues.push_back(g_TRIGGER_STD); + } + else + { + ModTgrValues.push_back(g_TRIGGER_STD); + ModTgrValues.push_back(g_TRIGGER_SYN); + } + ModTgrValues.push_back(g_TRIGGER_SWF); + ClearAllowedValues(g_PropNameMdTgr); + SetAllowedValues(g_PropNameMdTgr, ModTgrValues); + } + } + } + + ret = DEVICE_OK; + } } } break; @@ -3967,6 +4707,22 @@ int CMMTUCam::OnGAINMode(MM::PropertyBase* pProp, MM::ActionType eAct) pProp->Set(g_HDRBIT_ON); } } + else if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID) + { + int nIdx = 0; + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_IMGMODESELECT, &nIdx); + + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_IMGMODESELECT; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + valText.dbValue = nIdx; + TUCAM_Capa_GetValueText(m_opCam.hIdxTUCam, &valText); + + pProp->Set(valText.pText); + } else { if (1 == nVal) @@ -3997,6 +4753,82 @@ int CMMTUCam::OnGAINMode(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +/** +* Handles "OnShutterMode" property. +*/ +int CMMTUCam::OnShutterMode(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + string val; + pProp->Get(val); + + if (val.length() != 0) + { + TUCAM_CAPA_ATTR capaAttr; + capaAttr.idCapa = TUIDC_SHUTTER; + + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_SHUTTER; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + int nCnt = (int)(capaAttr.nValMax - capaAttr.nValMin + 1); + + for (int i = 0; iSet(valText.pText); + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + /** * Handles "OnModeSelect" property. */ @@ -4320,6 +5152,9 @@ int CMMTUCam::OnBitDepth(MM::PropertyBase* pProp, MM::ActionType eAct) if (NULL == m_opCam.hIdxTUCam) return DEVICE_NOT_CONNECTED; + if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID || PID_FL_26BW == m_nPID) + return DEVICE_OK; + int ret = DEVICE_ERR; switch(eAct) { @@ -4359,37 +5194,128 @@ int CMMTUCam::OnBitDepth(MM::PropertyBase* pProp, MM::ActionType eAct) SetProperty(MM::g_Keyword_PixelType, g_PixelType_8bit); } - if(m_nPID == PID_FL_20BW) + if (m_nPID == PID_FL_9BW || PID_FL_9BW_LT == m_nPID || m_nPID == PID_FL_20BW || m_nPID == PID_FL_26BW) { UpdateExpRange(); } - StartCapture(); +// StartCapture(); ResizeImageBuffer(); roiX_ = 0; roiY_ = 0; } - OnPropertyChanged(g_PropNameBODP, val.c_str()); + OnPropertyChanged(g_PropNameBODP, val.c_str()); + + ret = DEVICE_OK; + } + } + break; + case MM::BeforeGet: + { + int nVal = 0; + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_BITOFDEPTH, &nVal); + + if (16 == nVal) + { + pProp->Set("16"); + } + else + { + pProp->Set("8"); + } + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + +/** +* Handles "BitDepth" property. +*/ +int CMMTUCam::OnBitDepthEum(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + if (IsCapturing()) + return DEVICE_CAMERA_BUSY_ACQUIRING; + + // the user just set the new value for the property, so we have to + // apply this value to the 'hardware'. + string val; + pProp->Get(val); + if (val.length() != 0) + { + TUCAM_CAPA_ATTR capaAttr; + capaAttr.idCapa = TUIDC_BITOFDEPTH; + + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + m_bLiving = false; + TUCAM_Cap_Stop(m_opCam.hIdxTUCam); // Stop capture + ReleaseBuffer(); + + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_BITOFDEPTH; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + int i = 0; + int nCnt = capaAttr.nValMax - capaAttr.nValMin + 1; + + for (; iSet("16"); - } - else - { - pProp->Set("8"); - } + char szBuf[64] = { 0 }; + TUCAM_VALUE_TEXT valText; + valText.nID = TUIDC_BITOFDEPTH; + valText.nTextSize = 64; + valText.pText = &szBuf[0]; + + valText.dbValue = nIdx; + TUCAM_Capa_GetValueText(m_opCam.hIdxTUCam, &valText); + pProp->Set(valText.pText); ret = DEVICE_OK; } @@ -4907,6 +5833,45 @@ int CMMTUCam::OnBlueGain(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +/** +* Handles "OnATExpMode" property. +*/ +int CMMTUCam::OnATExpMode(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + long lVal = 0; + pProp->Get(lVal); + + TUCAM_Capa_SetValue(m_opCam.hIdxTUCam, TUIDC_ATEXPOSURE_MODE, (int)lVal); + + ret = DEVICE_OK; + } + break; + case MM::BeforeGet: + { + int nVal = 0; + + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_ATEXPOSURE_MODE, &nVal); + + pProp->Set((long)nVal); + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + /** * Handles "ATExposure" property. */ @@ -4969,6 +5934,68 @@ int CMMTUCam::OnATExposure(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +/** +* Handles "OnTimeStamp" property. +*/ +int CMMTUCam::OnTimeStamp(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + string val; + pProp->Get(val); + if (val.length() != 0) + { + TUCAM_CAPA_ATTR capaAttr; + capaAttr.idCapa = TUIDC_ENABLETIMESTAMP; + + if (TUCAMRET_SUCCESS == TUCAM_Capa_GetAttr(m_opCam.hIdxTUCam, &capaAttr)) + { + if (0 == val.compare("TRUE")) + { + TUCAM_Capa_SetValue(m_opCam.hIdxTUCam, TUIDC_ENABLETIMESTAMP, 1); + } + else + { + TUCAM_Capa_SetValue(m_opCam.hIdxTUCam, TUIDC_ENABLETIMESTAMP, 0); + } + } + + OnPropertyChanged(g_PropNameATEXP, val.c_str()); + + ret = DEVICE_OK; + } + } + break; + case MM::BeforeGet: + { + int nVal = 0; + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_ENABLETIMESTAMP, &nVal); + + if (1 == nVal) + { + pProp->Set("TRUE"); + } + else + { + pProp->Set("FALSE"); + } + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + /** * Handles "Temperature" property. */ @@ -4986,14 +6013,24 @@ int CMMTUCam::OnTemperature(MM::PropertyBase* pProp, MM::ActionType eAct) pProp->Get(dblTemp); m_fValTemp = (float)dblTemp; - TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_TEMPERATURE, (dblTemp + 50)); +// TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_TEMPERATURE, (dblTemp + m_nMidTemp)); + TUCAM_Prop_SetValue(m_opCam.hIdxTUCam, TUIDP_TEMPERATURE, (dblTemp * m_fScaTemp + m_nMidTemp)); ret = DEVICE_OK; } break; case MM::BeforeGet: { - pProp->Set(m_fValTemp); + double dblTemp; + if (TUCAMRET_SUCCESS == TUCAM_Prop_GetValue(m_opCam.hIdxTUCam, TUIDP_TEMPERATURE_TARGET, &dblTemp)) + { +// pProp->Set((dblTemp - 50)); + pProp->Set((dblTemp - m_nMidTemp) / m_fScaTemp); + } + else + { + pProp->Set(m_fValTemp); + } ret = DEVICE_OK; } @@ -5315,10 +6352,14 @@ int CMMTUCam::OnTriggerMode(MM::PropertyBase* pProp, MM::ActionType eAct) { m_tgrAttr.nTgrMode = TUCCM_SEQUENCE; } - else if (0 == val.compare(g_TRIGGER_STD)) + else if (0 == val.compare(g_TRIGGER_STD) || 0 == val.compare(g_TRIGGER_STDOVERLAP)) { m_tgrAttr.nTgrMode = TUCCM_TRIGGER_STANDARD; } + else if (0 == val.compare(g_TRIGGER_STDNONOVERLAP)) + { + m_tgrAttr.nTgrMode = TUCCM_TRIGGER_STANDARD_NONOVERLAP; + } else if (0 == val.compare(g_TRIGGER_SYN)) { m_tgrAttr.nTgrMode = TUCCM_TRIGGER_SYNCHRONOUS; @@ -5366,7 +6407,19 @@ int CMMTUCam::OnTriggerMode(MM::PropertyBase* pProp, MM::ActionType eAct) } else if (TUCCM_TRIGGER_STANDARD == m_tgrAttr.nTgrMode) { - pProp->Set(g_TRIGGER_STD); + if (IsSupport95V2New() || IsSupport401DNew() || IsSupport400BSIV3New()) + { + pProp->Set(g_TRIGGER_STDOVERLAP); + } + else + { + pProp->Set(g_TRIGGER_STD); + } + + } + else if (TUCCM_TRIGGER_STANDARD_NONOVERLAP == m_tgrAttr.nTgrMode) + { + pProp->Set(g_TRIGGER_STDNONOVERLAP); } else if (TUCCM_TRIGGER_SYNCHRONOUS == m_tgrAttr.nTgrMode) { @@ -5558,6 +6611,41 @@ int CMMTUCam::OnTriggerDelay(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +int CMMTUCam::OnTriggerFilter(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + long lVal = 0; + pProp->Get(lVal); + + TUCAM_Capa_SetValue(m_opCam.hIdxTUCam, TUIDC_SIGNALFILTER, lVal); + + ret = DEVICE_OK; + } + break; + case MM::BeforeGet: + { + int nVal = 0; + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_SIGNALFILTER, &nVal); + + pProp->Set((long)(nVal)); + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + int CMMTUCam::OnTriggerFrames(MM::PropertyBase* pProp, MM::ActionType eAct) { if (NULL == m_opCam.hIdxTUCam) @@ -5597,6 +6685,45 @@ int CMMTUCam::OnTriggerFrames(MM::PropertyBase* pProp, MM::ActionType eAct) return ret; } +int CMMTUCam::OnTriggerTotalFrames(MM::PropertyBase* pProp, MM::ActionType eAct) +{ + if (NULL == m_opCam.hIdxTUCam) + return DEVICE_NOT_CONNECTED; + + int ret = DEVICE_ERR; + switch (eAct) + { + case MM::AfterSet: + { + long lVal = 0; + pProp->Get(lVal); + + if (TUCCM_SEQUENCE < m_tgrAttr.nTgrMode && m_tgrAttr.nTgrMode < TUCCM_TRIGGER_SOFTWARE) + { + m_tgrAttr.nFrames = lVal; + } + + TUCAM_Cap_SetTrigger(m_opCam.hIdxTUCam, m_tgrAttr); + + ret = DEVICE_OK; + } + break; + case MM::BeforeGet: + { + TUCAM_Cap_GetTrigger(m_opCam.hIdxTUCam, &m_tgrAttr); + + pProp->Set((long)(m_tgrAttr.nFrames)); + + ret = DEVICE_OK; + } + break; + default: + break; + } + + return ret; +} + int CMMTUCam::OnTriggerDoSoftware(MM::PropertyBase* pProp, MM::ActionType eAct) { if (NULL == m_opCam.hIdxTUCam) @@ -5966,6 +7093,10 @@ int CMMTUCam::OnTrgOutKindMode(MM::PropertyBase* pProp, MM::ActionType eAct) { m_tgrOutAttr.nTgrOutMode = 4; } + else if (0 == val.compare(g_TRIGGER_TRIREADY)) + { + m_tgrOutAttr.nTgrOutMode = 6; + } else if (0 == val.compare(g_TRIGGER_LOW)) { m_tgrOutAttr.nTgrOutMode = 0; @@ -6033,6 +7164,10 @@ int CMMTUCam::OnTrgOutKindMode(MM::PropertyBase* pProp, MM::ActionType eAct) { pProp->Set(g_TRIGGER_READEND); } + else if (6 == m_tgrOutAttr.nTgrOutMode) + { + pProp->Set(g_TRIGGER_TRIREADY); + } ret = DEVICE_OK; } @@ -6575,6 +7710,15 @@ int CMMTUCam::ResizeImageBuffer() if (TUCAMRET_SUCCESS != TUCAM_Dev_GetInfo(m_opCam.hIdxTUCam, &valHeight)) return DEVICE_NATIVE_MODULE_FAILED; + if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID) + { + ResizeBinImageBufferFL9BW(valWidth.nValue, valHeight.nValue); + } + else if (PID_FL_26BW == m_nPID) + { + ResizeBinImageBufferFL26BW(valWidth.nValue, valHeight.nValue); + } + char sz[256] = {0}; sprintf(sz, "[ResizeImageBuffer]:Width:%d, Height:%d, BytesPerPixel:%d\n", valWidth.nValue, valHeight.nValue, m_frame.ucElemBytes * nChnnels); OutputDebugString(sz); @@ -6601,6 +7745,50 @@ int CMMTUCam::ResizeImageBuffer() return DEVICE_OK; } +void CMMTUCam::ResizeBinImageBufferFL9BW(int &width, int &height) +{ + int bin = 0; + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_BINNING_SUM, &bin); + + if (5 == bin) + bin = 8; + else if (4 == bin) + bin = 6; + else + bin += 1; + + if (!m_bROI) + { + int nMaxWid = width / bin; + int nMaxHei = height / bin; + + width = (nMaxWid >> 2) << 2; + height = (nMaxHei >> 2) << 2; + } +} + +void CMMTUCam::ResizeBinImageBufferFL26BW(int &width, int &height) +{ + int bin = 0; + TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_BINNING_SUM, &bin); + + if (6 == bin) + bin = 8; + else if (7 == bin) + bin = 16; + else + bin += 1; + + if (!m_bROI) + { + int nMaxWid = width / bin; + int nMaxHei = height / bin; + + width = (nMaxWid >> 2) << 2; + height = (nMaxHei >> 2) << 2; + } +} + void CMMTUCam::GenerateEmptyImage(ImgBuffer& img) { MMThreadGuard g(imgPixelsLock_); @@ -6978,7 +8166,7 @@ void CMMTUCam::RunTemperature() dw = GetTickCount(); - if (isSupportFanWaterCool()) // 400BSIV2 BCD = 0x05, 0x07, 0x09 不可调风扇相机 + if (isSupportSoftProtect()) // 400BSIV2 BCD = 0x05, 0x07, 0x09 ²»¿Éµ÷·çÉÈÏà»ú { int nFan = 0; TUCAM_Capa_GetValue(m_opCam.hIdxTUCam, TUIDC_FAN_GEAR, &nFan); @@ -7178,7 +8366,7 @@ int CMMTUCam::WaitForFrame(ImgBuffer& img) MMThreadGuard g(imgPixelsLock_); m_frame.ucFormatGet = TUFRM_FMT_USUAl; // Set usual format - if (TUCAMRET_SUCCESS == TUCAM_Buf_WaitForFrame(m_opCam.hIdxTUCam, &m_frame)) + if (TUCAMRET_SUCCESS == TUCAM_Buf_WaitForFrame(m_opCam.hIdxTUCam, &m_frame, 1000)) { if (img.Height() == 0 || img.Width() == 0 || img.Depth() == 0) return DEVICE_OUT_OF_MEMORY; @@ -7370,7 +8558,11 @@ bool CMMTUCam::isSupportFanCool() { bool bSupport = false; bSupport = isSupportFanWaterCool(); - if (PID_FL_20BW == m_nPID) + if (m_nPID == PID_FL_9BW || PID_FL_9BW_LT == m_nPID || PID_FL_20BW == m_nPID || m_nPID == PID_FL_26BW) + { + return true; + } + if (IsSupportAries16()) { return true; } @@ -7397,6 +8589,17 @@ bool CMMTUCam::isSupportFanWaterCool() return false; } +bool CMMTUCam::isSupportSoftProtect() +{ + bool bSupport = false; + bSupport = isSupportFanWaterCool(); + if (IsSupport400BSIV3New() || IsSupport95V2New()) + { + return false; + } + return bSupport; +} + void CMMTUCam::UpdateSlitHeightRange() { int nImgMode = 0; @@ -7434,7 +8637,7 @@ void CMMTUCam::UpdateExpRange() exposureMinimum_ = propAttr.dbValMin; exposureMaximum_ = propAttr.dbValMax; - if (PID_FL_20BW == m_nPID) + if (PID_FL_9BW == m_nPID || PID_FL_9BW_LT == m_nPID || PID_FL_20BW == m_nPID || PID_FL_26BW == m_nPID) { exposureMaximum_ = 3600000; } @@ -7446,3 +8649,24 @@ void CMMTUCam::UpdateExpRange() SetPropertyLimits(MM::g_Keyword_Exposure, exposureMinimum_, exposureMaximum_); } + +void CMMTUCam::UpdateLevelsRange() +{ + TUCAM_PROP_ATTR propAttr; + propAttr.nIdxChn = 0; + propAttr.idProp = TUIDP_LFTLEVELS; + if (TUCAMRET_SUCCESS == TUCAM_Prop_GetAttr(m_opCam.hIdxTUCam, &propAttr)) + { + SetPropertyLimits(g_PropNameLLev, (int)propAttr.dbValMin, (int)propAttr.dbValMax); + + SetProperty(g_PropNameLLev, CDeviceUtils::ConvertToString((int)propAttr.dbValMin)); + } + + propAttr.idProp = TUIDP_RGTLEVELS; + if (TUCAMRET_SUCCESS == TUCAM_Prop_GetAttr(m_opCam.hIdxTUCam, &propAttr)) + { + SetPropertyLimits(g_PropNameRLev, (int)propAttr.dbValMin, (int)propAttr.dbValMax); + + SetProperty(g_PropNameRLev, CDeviceUtils::ConvertToString((int)propAttr.dbValMax)); + } +}