Skip to content

Commit

Permalink
Daheng: Added Line Source properties. Should be able to fully control…
Browse files Browse the repository at this point in the history
… outputs and inputs now.
  • Loading branch information
nicost committed Dec 21, 2024
1 parent 6df339f commit a40df4b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 15 deletions.
88 changes: 73 additions & 15 deletions DeviceAdapters/DahengGalaxy/ClassGalaxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ ClassGalaxy::ClassGalaxy() :
{
// call the base class method to set-up default error codes/messages
InitializeDefaultErrorMessages();
//SetErrorText(ERR_SERIAL_NUMBER_REQUIRED, "Serial number is required");
//SetErrorText(ERR_SERIAL_NUMBER_NOT_FOUND, "No camera with the given serial number was found");
//SetErrorText(ERR_CANNOT_CONNECT, "Cannot connect to camera; it may be in use");
IGXFactory::GetInstance().Init();
SetErrorText(ERR_CAMERA_SDK, "Error while interacting with the Daheng Galaxy SDK");

IGXFactory::GetInstance().Init();
IGXFactory::GetInstance().UpdateDeviceList(1000, vectorDeviceInfo);

CreateStringProperty("SerialNumber", "Undefined", false, 0, true);
Expand Down Expand Up @@ -420,19 +418,34 @@ int ClassGalaxy::Initialize()
}
}
}
/*
emStatus = GXSetEnumValueByString(m_hDevice, "LineSelector", "Line0");
VERIFY_STATUS_RET(emStatus);
emStatus = GXSetEnumValueByString(m_hDevice, "LineMode", "Input");
VERIFY_STATUS_RET(emStatus);
GX_ENUM_VALUE stEnumValue;
emStatus = GXGetEnumValue(m_hDevice, "LineMode", &stEnumValue);
*/

CEnumFeaturePointer linesources = m_objFeatureControlPtr->GetEnumFeature("LineSource");
if (!linesources.IsNull())
{
gxstring_vector sourceentries = linesources->GetEnumEntryList();
if (sourceentries.size() > 0) {
CPropertyActionEx* pActEx = new CPropertyActionEx(this, &ClassGalaxy::OnLineSource, lineNr);
std::string propName = entry + "-Source";
CEnumFeaturePointer linemodes = m_objFeatureControlPtr->GetEnumFeature("LineMode");
if (linemodes.IsNull())
{
return ERR_CAMERA_SDK;
}
gxstring_vector modeentries = linemodes->GetEnumEntryList();
bool readOnly = false;
if (modeentries.size() == 1 && modeentries[0] == "Input")
readOnly = true;
ret = CreateProperty(propName.c_str(), sourceentries[0].c_str(), MM::String, readOnly, pActEx);
if (ret != DEVICE_OK)
return ret;
for (size_t j = 0; j < sourceentries.size(); j++)
{
AddAllowedValue(propName.c_str(), sourceentries[j].c_str());
}
}

}
}

// set line selector back
lineselector->SetValue(lineVal);
}
Expand Down Expand Up @@ -1492,6 +1505,51 @@ int ClassGalaxy::OnLineMode(MM::PropertyBase* pProp, MM::ActionType eAct, long i
return DEVICE_OK;
}

int ClassGalaxy::OnLineSource(MM::PropertyBase* pProp, MM::ActionType eAct, long i)
{
CEnumFeaturePointer lineselector = m_objFeatureControlPtr->GetEnumFeature("LineSelector");
if (lineselector.IsNull())
{
return ERR_CAMERA_SDK;
}
gxstring lineVal = lineselector->GetValue();
gxstring_vector entries = lineselector->GetEnumEntryList();
if (entries.size() == 0)
{
return ERR_CAMERA_SDK;
}
std::string entry(entries[0]);
std::string line = entry.substr(0, entry.size() - 1) + (std::to_string(i)).c_str();
lineselector->SetValue(line.c_str());
CEnumFeaturePointer linesources = m_objFeatureControlPtr->GetEnumFeature("LineSource");
if (linesources.IsNull())
{
return ERR_CAMERA_SDK;
}
gxstring_vector sourceentries = linesources->GetEnumEntryList();
if (sourceentries.size() == 0)
{
return ERR_CAMERA_SDK;
}

if (eAct == MM::BeforeGet)
{
gxstring lineSource = linesources->GetValue();
pProp->Set(lineSource.c_str());
}
else if (eAct == MM::AfterSet)
{
std::string linesource;
pProp->Get(linesource);
linesources->SetValue(linesource.c_str());
}

// return lineselector to its orginal value
lineselector->SetValue(lineVal);

return DEVICE_OK;
}

int ClassGalaxy::OnUserOutput(MM::PropertyBase* pProp, MM::ActionType eAct)
{
CEnumFeaturePointer userOutputFP = m_objFeatureControlPtr->GetEnumFeature("UserOutputSelector");
Expand Down
3 changes: 3 additions & 0 deletions DeviceAdapters/DahengGalaxy/ClassGalaxy.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
// disables warnings about dll interface incompatibility
#pragma warning( disable : 4251 )
#define _AFXDLL

#include "GalaxyException.h"
Expand Down Expand Up @@ -141,6 +143,7 @@ class MODULE_API ClassGalaxy : public CCameraBase<ClassGalaxy>
int OnTriggerFilterRaisingEdge(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnExposureTimeout(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnLineMode(MM::PropertyBase* pProp, MM::ActionType eAct, long i);
int OnLineSource(MM::PropertyBase* pProp, MM::ActionType eAct, long i);

//为了实现在采集类中使用
bool colorCamera_;
Expand Down

0 comments on commit a40df4b

Please sign in to comment.