From df24d1edd6c86bf85ed26c793f04719934ec6a97 Mon Sep 17 00:00:00 2001 From: samdrea <69533601+samdrea@users.noreply.github.com> Date: Sat, 31 Aug 2024 11:33:28 -0700 Subject: [PATCH 1/4] Added license to OpenFlexure.h --- DeviceAdapters/OpenFlexure/OpenFlexure.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/DeviceAdapters/OpenFlexure/OpenFlexure.h b/DeviceAdapters/OpenFlexure/OpenFlexure.h index fd779168e..69090db46 100644 --- a/DeviceAdapters/OpenFlexure/OpenFlexure.h +++ b/DeviceAdapters/OpenFlexure/OpenFlexure.h @@ -1,13 +1,27 @@ -////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // 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. +// +// AUTHOR: Samdrea Hsu, samdreahsu@gmail.com, 06/22/2024 +// +// Karl Hoover (stuff such as programmable CCD size & the various image processors) +// Arther Edelstein ( equipment error simulation) // // COPYRIGHT: Samdrea Hsu // -// AUTHOR: Samdrea Hsu, samdreahsu@gmail.com, 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. // ////////////////////////////////////////////////////////////////////////////// From 42000b5630cff1bd5429ff99b6c9fa12d3859057 Mon Sep 17 00:00:00 2001 From: samdrea <69533601+samdrea@users.noreply.github.com> Date: Sat, 31 Aug 2024 11:33:58 -0700 Subject: [PATCH 2/4] Added license to OpenFlexure.cpp --- DeviceAdapters/OpenFlexure/OpenFlexure.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/DeviceAdapters/OpenFlexure/OpenFlexure.cpp b/DeviceAdapters/OpenFlexure/OpenFlexure.cpp index d9e98e6f6..4c607bed4 100644 --- a/DeviceAdapters/OpenFlexure/OpenFlexure.cpp +++ b/DeviceAdapters/OpenFlexure/OpenFlexure.cpp @@ -1,13 +1,27 @@ -////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // 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. +// +// AUTHOR: Samdrea Hsu, samdreahsu@gmail.com, 06/22/2024 +// +// Karl Hoover (stuff such as programmable CCD size & the various image processors) +// Arther Edelstein ( equipment error simulation) // // COPYRIGHT: Samdrea Hsu // -// AUTHOR: Samdrea Hsu, samdreahsu@gmail.com, 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. // ////////////////////////////////////////////////////////////////////////////// @@ -940,4 +954,4 @@ int LEDIllumination::SetBrightness() pHub->SendCommand(cmd, _serial_answer); return DEVICE_OK; -} \ No newline at end of file +} From 50be5caeb5a86a3f224452107563949fc45bf4d9 Mon Sep 17 00:00:00 2001 From: Samdrea Hsu Date: Mon, 23 Sep 2024 08:29:14 -0700 Subject: [PATCH 3/4] added board test during initialization --- DeviceAdapters/OpenFlexure/OpenFlexure.cpp | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/DeviceAdapters/OpenFlexure/OpenFlexure.cpp b/DeviceAdapters/OpenFlexure/OpenFlexure.cpp index d9e98e6f6..e808c3028 100644 --- a/DeviceAdapters/OpenFlexure/OpenFlexure.cpp +++ b/DeviceAdapters/OpenFlexure/OpenFlexure.cpp @@ -72,7 +72,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,16 +83,25 @@ 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(); @@ -99,7 +109,7 @@ int SangaBoardHub::Initialize() // 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 +119,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 +128,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 +331,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 +458,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 +664,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 From 86716b5fb9ed5d83b5bb83943c5da9a854f8fcd8 Mon Sep 17 00:00:00 2001 From: Samdrea Hsu Date: Mon, 23 Sep 2024 08:39:02 -0700 Subject: [PATCH 4/4] fixed license and added board test during initialization --- DeviceAdapters/OpenFlexure/OpenFlexure.cpp | 6 ++---- DeviceAdapters/OpenFlexure/OpenFlexure.h | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/DeviceAdapters/OpenFlexure/OpenFlexure.cpp b/DeviceAdapters/OpenFlexure/OpenFlexure.cpp index 47936de44..ab36480df 100644 --- a/DeviceAdapters/OpenFlexure/OpenFlexure.cpp +++ b/DeviceAdapters/OpenFlexure/OpenFlexure.cpp @@ -4,11 +4,9 @@ // SUBSYSTEM: DeviceAdapters //----------------------------------------------------------------------------- // 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, samdreahsu@gmail.com, 06/22/2024 -// -// Karl Hoover (stuff such as programmable CCD size & the various image processors) -// Arther Edelstein ( equipment error simulation) +// AUTHOR: Samdrea Hsu, samdreahsu@gmail.com, 09/23/2024 // // COPYRIGHT: Samdrea Hsu // diff --git a/DeviceAdapters/OpenFlexure/OpenFlexure.h b/DeviceAdapters/OpenFlexure/OpenFlexure.h index 69090db46..c72e8bd81 100644 --- a/DeviceAdapters/OpenFlexure/OpenFlexure.h +++ b/DeviceAdapters/OpenFlexure/OpenFlexure.h @@ -4,11 +4,9 @@ // SUBSYSTEM: DeviceAdapters //----------------------------------------------------------------------------- // 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, samdreahsu@gmail.com, 06/22/2024 -// -// Karl Hoover (stuff such as programmable CCD size & the various image processors) -// Arther Edelstein ( equipment error simulation) +// AUTHOR: Samdrea Hsu, samdreahsu@gmail.com, 09/23/2024 // // COPYRIGHT: Samdrea Hsu //