forked from micro-manager/mmCoreAndDevices
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request micro-manager#487 from samdrea/pr
Added license to OpenFlexure project
- Loading branch information
Showing
2 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// FILE: OpenFlexure.cpp | ||
// PROJECT: Micro-Manager | ||
// SUBSYSTEM: DeviceAdapters | ||
//----------------------------------------------------------------------------- | ||
// DESCRIPTION: Adapter for the OpenFlexure Microscope. This adapter is used on the v5 Sangaboard. | ||
// DESCRIPTION: Adapter for the OpenFlexure Microscope. This adapter is used on the v5 Sangaboard. | ||
// - Tested with Sangaboard Firmware v1.0.1-dev || Sangaboard v0.5.x | ||
// | ||
// AUTHOR: Samdrea Hsu, [email protected], 09/23/2024 | ||
// | ||
// COPYRIGHT: Samdrea Hsu | ||
// | ||
// AUTHOR: Samdrea Hsu, [email protected], 06/22/2024 | ||
// LICENSE: This file is distributed under the BSD license. | ||
// License text is included with the source distribution. | ||
// | ||
// This file is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty | ||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. | ||
// | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
@@ -72,7 +84,8 @@ SangaBoardHub::SangaBoardHub() : initialized_(false), port_("Undefined"), portAv | |
|
||
// Pre-initialization property: port name | ||
CPropertyAction* pAct = new CPropertyAction(this, &SangaBoardHub::OnPort); | ||
CreateProperty(MM::g_Keyword_Port, "Undefined", MM::String, false, pAct, true); | ||
int ret = CreateProperty(MM::g_Keyword_Port, "Undefined", MM::String, false, pAct, true); | ||
|
||
} | ||
|
||
SangaBoardHub::~SangaBoardHub() | ||
|
@@ -82,24 +95,33 @@ SangaBoardHub::~SangaBoardHub() | |
|
||
int SangaBoardHub::Initialize() | ||
{ | ||
// Send a command to check if Sangaboard is connected | ||
SendCommand("version", _serial_answer); // Example response is "Sangaboard v0.5.x" | ||
|
||
// Check if the response contains "Sangaboard" | ||
if (_serial_answer.find("Sangaboard") == std::string::npos) { | ||
// If not found, return an error code | ||
return DEVICE_NOT_CONNECTED; | ||
} | ||
|
||
initialized_ = true; | ||
|
||
// Set up Manual Command Interface to send command directly to SangaBoard | ||
CPropertyAction* pCommand = new CPropertyAction(this, &SangaBoardHub::OnManualCommand); | ||
int ret = CreateProperty(g_Keyword_Command, "", MM::String, false, pCommand); | ||
assert(DEVICE_OK == ret); | ||
if (DEVICE_OK != ret) return DEVICE_CAN_NOT_SET_PROPERTY; | ||
|
||
// Set up property to display most recent serial response (read-only) | ||
ret = CreateProperty(g_Keyword_Response, "", MM::String, false); | ||
assert(DEVICE_OK == ret); | ||
if (DEVICE_OK != ret) return DEVICE_CAN_NOT_SET_PROPERTY; | ||
|
||
// Initialize the cache values to the current values stored on hardware | ||
this->SyncState(); | ||
|
||
// Set up Step Delay property for changing velocity | ||
CPropertyAction* pStepDel = new CPropertyAction(this, &SangaBoardHub::OnStepDelay); | ||
ret = CreateIntegerProperty(g_Keyword_StepDelay, step_delay_, false, pStepDel); | ||
assert(DEVICE_OK == ret); | ||
if (DEVICE_OK != ret) return DEVICE_CAN_NOT_SET_PROPERTY; | ||
AddAllowedValue(g_Keyword_StepDelay, "1000"); | ||
AddAllowedValue(g_Keyword_StepDelay, "2000"); | ||
AddAllowedValue(g_Keyword_StepDelay, "3000"); | ||
|
@@ -109,7 +131,7 @@ int SangaBoardHub::Initialize() | |
// Set up Ramp Time property for changing acceleration | ||
CPropertyAction* pRampTime = new CPropertyAction(this, &SangaBoardHub::OnRampTime); | ||
ret = CreateIntegerProperty(g_Keyword_RampTime, ramp_time_, false, pRampTime); | ||
assert(DEVICE_OK == ret); | ||
if (DEVICE_OK != ret) return DEVICE_CAN_NOT_SET_PROPERTY; | ||
AddAllowedValue(g_Keyword_RampTime, "0", 0); | ||
AddAllowedValue(g_Keyword_RampTime, "100000"); // Not really sure if these values really do much for acceleration... | ||
AddAllowedValue(g_Keyword_RampTime, "200000"); | ||
|
@@ -118,7 +140,7 @@ int SangaBoardHub::Initialize() | |
// Set up extra functions drop down menu | ||
CPropertyAction* pExtras= new CPropertyAction(this, &SangaBoardHub::OnExtraCommands); | ||
ret = CreateStringProperty(g_Keyword_Extras, g_Keyword_None, false, pExtras); | ||
assert(DEVICE_OK == ret); | ||
if (DEVICE_OK != ret) return DEVICE_CAN_NOT_SET_PROPERTY; | ||
AddAllowedValue(g_Keyword_Extras, g_ExtraCommand_Stop); | ||
AddAllowedValue(g_Keyword_Extras, g_ExtraCommand_Zero); | ||
AddAllowedValue(g_Keyword_Extras, g_ExtraCommand_Release); | ||
|
@@ -321,7 +343,8 @@ int SangaBoardHub::SendCommand(std::string cmd, std::string& ans) | |
} | ||
|
||
// Reflect the command in the serial response property | ||
SetProperty(g_Keyword_Response, ans.c_str()); | ||
ret = SetProperty(g_Keyword_Response, ans.c_str()); | ||
if (DEVICE_OK != ret) return DEVICE_CAN_NOT_SET_PROPERTY; | ||
|
||
return DEVICE_OK; | ||
|
||
|
@@ -447,7 +470,7 @@ int XYStage::Initialize() | |
std::string cmd = "blocking_moves false"; | ||
pHub->SendCommand(cmd, _serial_answer); | ||
if (_serial_answer.find("done") == -1) { | ||
return DEVICE_ERR; | ||
return DEVICE_SERIAL_INVALID_RESPONSE; | ||
} | ||
|
||
// Set the current stage position | ||
|
@@ -653,7 +676,7 @@ int ZStage::Initialize() | |
std::string cmd = "blocking_moves false"; | ||
pHub->SendCommand(cmd, _serial_answer); | ||
if (_serial_answer.find("done") == -1) { | ||
return DEVICE_ERR; | ||
return DEVICE_SERIAL_INVALID_RESPONSE; | ||
} | ||
|
||
// Set the current stagePosition | ||
|
@@ -940,4 +963,4 @@ int LEDIllumination::SetBrightness() | |
pHub->SendCommand(cmd, _serial_answer); | ||
|
||
return DEVICE_OK; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// FILE: OpenFlexure.h | ||
// PROJECT: Micro-Manager | ||
// SUBSYSTEM: DeviceAdapters | ||
//----------------------------------------------------------------------------- | ||
// DESCRIPTION: Adapter for the OpenFlexure Microscope. This adapter is used on the v5 Sangaboard. | ||
// DESCRIPTION: Adapter for the OpenFlexure Microscope. This adapter is used on the v5 Sangaboard. | ||
// - Tested with Sangaboard Firmware v1.0.1-dev || Sangaboard v0.5.x | ||
// | ||
// AUTHOR: Samdrea Hsu, [email protected], 09/23/2024 | ||
// | ||
// COPYRIGHT: Samdrea Hsu | ||
// | ||
// AUTHOR: Samdrea Hsu, [email protected], 06/22/2024 | ||
// LICENSE: This file is distributed under the BSD license. | ||
// License text is included with the source distribution. | ||
// | ||
// This file is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty | ||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. | ||
// | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
|