Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions DeviceAdapters/LightSheetManager/LightSheetDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@

#include "LightSheetDeviceManager.h"

LightSheetDeviceManager::LightSheetDeviceManager() :
initialized_(false),
geometryType_("SCAPE"),
lightSheetType_("Static"),
numImagingPaths_(1),
numIlluminationPaths_(1),
numSimultaneousCameras_(1) {
namespace {
namespace Properties {
constexpr char IlluminationPaths[] = "IlluminationPaths";
constexpr char ImagingPaths[] = "ImagingPaths";
constexpr char LightSheetType[] = "LightSheetType";
constexpr char MicroscopeGeometry[] = "MicroscopeGeometry";
constexpr char SimultaneousCameras[] = "SimultaneousCameras";
} // namespace Properties
namespace Props = Properties;
} // namespace

// call the base class method to setup default error codes/messages
LightSheetDeviceManager::LightSheetDeviceManager() {
// call the base method to setup default errors
InitializeDefaultErrorMessages();

// Create pre-init properties
// create pre-init properties
CreateNumIlluminationPathsProperty();
CreateNumImagingPathsProperty();
CreateLightSheetTypeProperty();
Expand All @@ -35,12 +39,11 @@ void LightSheetDeviceManager::GetName(char* name) const {
}

int LightSheetDeviceManager::Shutdown() {
if (initialized_) {
initialized_ = false;
}
initialized_ = false;
return DEVICE_OK;
}

// Return false, this "device" can never be busy.
bool LightSheetDeviceManager::Busy() {
return false;
}
Expand Down Expand Up @@ -91,10 +94,10 @@ void LightSheetDeviceManager::CreateDeviceProperties(const std::map<std::string,
}

// create properties based on the property name prefix
if (numImagingPaths_ > 1 && StringStartsWith(propertyName, gImagingPrefix)) {
if (numImagingPaths_ > 1 && StartsWith(propertyName, gImagingPrefix)) {
// create multiple properties => "Imaging1, Imaging2, ... ImagingN"
CreatePrefixProperties(propertyName, gImagingPrefix, numImagingPaths_, deviceType);
} else if (numIlluminationPaths_ > 1 && StringStartsWith(propertyName, gIllumPrefix)) {
} else if (numIlluminationPaths_ > 1 && StartsWith(propertyName, gIllumPrefix)) {
// create multiple properties => "Illum1, Illum2, ... IllumN"
CreatePrefixProperties(propertyName, gIllumPrefix, numIlluminationPaths_, deviceType);
} else {
Expand Down Expand Up @@ -139,7 +142,7 @@ void LightSheetDeviceManager::CreateCameraProperties() {
}

// TODO: use rfind for now: use starts_with when we have C++20 support
bool LightSheetDeviceManager::StringStartsWith(const std::string& str, const std::string& searchTerm) const {
bool LightSheetDeviceManager::StartsWith(const std::string& str, const std::string& searchTerm) const {
return str.rfind(searchTerm, 0) == 0;
}

Expand Down Expand Up @@ -190,13 +193,12 @@ void LightSheetDeviceManager::CreateNumImagingPathsProperty() {
}),
true
);
SetPropertyLimits(propertyName.c_str(), 1, 8);
SetPropertyLimits(propertyName.c_str(), 1, 4);
}

void LightSheetDeviceManager::CreateNumIlluminationPathsProperty() {
const std::string propertyName = "IlluminationPaths";
CreateIntegerProperty(
propertyName.c_str(), numIlluminationPaths_, false,
Props::IlluminationPaths, numIlluminationPaths_, false,
new MM::ActionLambda([this](MM::PropertyBase* pProp, MM::ActionType eAct) {
if (eAct == MM::BeforeGet) {
pProp->Set(numIlluminationPaths_);
Expand All @@ -209,13 +211,12 @@ void LightSheetDeviceManager::CreateNumIlluminationPathsProperty() {
}),
true
);
SetPropertyLimits(propertyName.c_str(), 1, 8);
SetPropertyLimits(Props::IlluminationPaths, 1, 4);
}

void LightSheetDeviceManager::CreateLightSheetTypeProperty() {
const std::string propertyName = "LightSheetType";
CreateStringProperty(
propertyName.c_str(), lightSheetType_.c_str(), false,
Props::LightSheetType, lightSheetType_.c_str(), false,
new MM::ActionLambda([this](MM::PropertyBase* pProp, MM::ActionType eAct) {
if (eAct == MM::BeforeGet) {
pProp->Set(lightSheetType_.c_str());
Expand All @@ -228,14 +229,13 @@ void LightSheetDeviceManager::CreateLightSheetTypeProperty() {
}),
true
);
AddAllowedValue(propertyName.c_str(), gLightSheetTypeScanned);
AddAllowedValue(propertyName.c_str(), gLightSheetTypeStatic);
AddAllowedValue(Props::LightSheetType, gLightSheetTypeScanned);
AddAllowedValue(Props::LightSheetType, gLightSheetTypeStatic);
}

void LightSheetDeviceManager::CreateMicroscopeGeometryProperty() {
const std::string propertyName = "MicroscopeGeometry";
CreateStringProperty(
propertyName.c_str(), geometryType_.c_str(), false,
Props::MicroscopeGeometry, geometryType_.c_str(), false,
new MM::ActionLambda([this](MM::PropertyBase* pProp, MM::ActionType eAct) {
if (eAct == MM::BeforeGet) {
pProp->Set(geometryType_.c_str());
Expand All @@ -249,13 +249,12 @@ void LightSheetDeviceManager::CreateMicroscopeGeometryProperty() {
true
);
std::vector<std::string> allowedValues = geometry_.GetGeometryTypes();
SetAllowedValues(propertyName.c_str(), allowedValues);
SetAllowedValues(Props::MicroscopeGeometry, allowedValues);
}

void LightSheetDeviceManager::CreateNumSimultaneousCamerasProperty() {
const std::string propertyName = "SimultaneousCameras";
CreateIntegerProperty(
propertyName.c_str(), numSimultaneousCameras_, false,
Props::SimultaneousCameras, numSimultaneousCameras_, false,
new MM::ActionLambda([this](MM::PropertyBase* pProp, MM::ActionType eAct) {
if (eAct == MM::BeforeGet) {
pProp->Set(numSimultaneousCameras_);
Expand All @@ -268,5 +267,5 @@ void LightSheetDeviceManager::CreateNumSimultaneousCamerasProperty() {
}),
true
);
SetPropertyLimits(propertyName.c_str(), 1, 8);
SetPropertyLimits(Props::SimultaneousCameras, 1, 4);
}
23 changes: 10 additions & 13 deletions DeviceAdapters/LightSheetManager/LightSheetDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* Copyright (c) 2022, Applied Scientific Instrumentation
*/

#ifndef LIGHTSHEET_DEVICE_MANAGER_H
#define LIGHTSHEET_DEVICE_MANAGER_H
#pragma once

#include "MMDevice.h"
#include "DeviceBase.h"
Expand Down Expand Up @@ -35,7 +34,7 @@ class LightSheetDeviceManager : public CGenericBase<LightSheetDeviceManager> {
void CreateCameraProperties();

// Returns true if the string starts with the search term.
bool StringStartsWith(const std::string& str, const std::string& searchTerm) const;
bool StartsWith(const std::string& str, const std::string& searchTerm) const;

// Returns the device names of all devices of MM::DeviceType loaded in the hardware configuration as strings.
std::vector<std::string> GetLoadedDevicesOfType(const MM::DeviceType deviceType);
Expand All @@ -51,16 +50,14 @@ class LightSheetDeviceManager : public CGenericBase<LightSheetDeviceManager> {
void CreateMicroscopeGeometryProperty();
void CreateNumSimultaneousCamerasProperty();

std::map<MM::DeviceType, std::vector<std::string>> devices_;
MicroscopeGeometry geometry_;
bool initialized_;
std::map<MM::DeviceType, std::vector<std::string>> devices_{};
MicroscopeGeometry geometry_{};
bool initialized_ = false;

// pre-init properties
std::string geometryType_; // type of microscope geometry
std::string lightSheetType_; // scanned or static sheet
long numImagingPaths_;
long numIlluminationPaths_;
long numSimultaneousCameras_;
std::string geometryType_ = "SCAPE"; // type of microscope geometry
std::string lightSheetType_ = "Static"; // scanned or static sheet
long numImagingPaths_ = 1;
long numIlluminationPaths_ = 1;
long numSimultaneousCameras_ = 1;
};

#endif // LIGHTSHEET_DEVICE_MANAGER_H
4 changes: 1 addition & 3 deletions DeviceAdapters/LightSheetManager/LightSheetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* Copyright (c) 2022, Applied Scientific Instrumentation
*/

#ifndef LIGHTSHEET_MANAGER_H
#define LIGHTSHEET_MANAGER_H
#pragma once

#include "MMDevice.h"
#include "DeviceBase.h"
Expand Down Expand Up @@ -35,4 +34,3 @@ const char* const gLightSheetTypeScanned = "Scanned";
// no device selected
const char* const gUndefined = "Undefined";

#endif // LIGHTSHEET_MANAGER_H
9 changes: 3 additions & 6 deletions DeviceAdapters/LightSheetManager/MicroscopeGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* Copyright (c) 2022, Applied Scientific Instrumentation
*/

#ifndef MICROSCOPE_GEOMETRY_H
#define MICROSCOPE_GEOMETRY_H
#pragma once

#include "MMDevice.h"
#include "DeviceBase.h"
Expand Down Expand Up @@ -46,8 +45,6 @@ class MicroscopeGeometry {
// Creates the list of microscope geometry types based on the device map.
void CreateGeometryTypes();

std::map<std::string, std::map<std::string, MM::DeviceType>> deviceMap_;
std::vector<std::string> geometryTypes_;
std::map<std::string, std::map<std::string, MM::DeviceType>> deviceMap_{};
std::vector<std::string> geometryTypes_{};
};

#endif // MICROSCOPE_GEOMETRY_H
Loading