From 02bf36fee642de229851494d0d6e7a0b415f4635 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 10:08:21 -0400 Subject: [PATCH 001/103] ENH: Initial commit. --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 141bab4a95ad2ce92ee0311ce178ae98791506d1 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 11:14:47 -0400 Subject: [PATCH 002/103] ENH: Add README --- README.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..0667ecb --- /dev/null +++ b/README.rst @@ -0,0 +1,4 @@ +IntersonSDKCxx +============== +C++ Wrapper for the Interson C# SDK +----------------------------------- From 43d7900780ad9e52a8652ea73c3d787e046466e1 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 11:15:54 -0400 Subject: [PATCH 003/103] ENH: IntersonClass skeleton. --- CMakeLists.txt | 14 ++++++++++++ include/IntersonCxxIntersonClass.h | 34 ++++++++++++++++++++++++++++++ src/CMakeLists.txt | 24 +++++++++++++++++++++ src/IntersonCxxIntersonClass.cxx | 33 +++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 include/IntersonCxxIntersonClass.h create mode 100644 src/CMakeLists.txt create mode 100644 src/IntersonCxxIntersonClass.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..aa68dcf --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required( VERSION 2.8 ) + +project( IntersonSDKCxx ) + +include_directories( ${PROJECT_SOURCE_DIR}/include ) +include_directories( ${PROJECT_BINARY_DIR}/include ) + +add_subdirectory( src ) + +include( CTest ) +if( BUILD_TESTING ) + enable_testing() + add_subdirectory( test ) +endif() diff --git a/include/IntersonCxxIntersonClass.h b/include/IntersonCxxIntersonClass.h new file mode 100644 index 0000000..b814136 --- /dev/null +++ b/include/IntersonCxxIntersonClass.h @@ -0,0 +1,34 @@ +#ifndef _IntersonCxxIntersonClass_h +#define _IntersonCxxIntersonClass_h + +#include "IntersonCxx_Export.h" + +#include + +#pragma unmanaged + +namespace IntersonCxx +{ + +class IntersonClassImpl; + +class IntersonCxx_EXPORT IntersonClass +{ +public: + IntersonClass(); + ~IntersonClass(); + + //std::string CompleteVersion(); + + //std::string Version(); + +private: + IntersonClass( const IntersonClass & ); + void operator=( const IntersonClass & ); + + IntersonClassImpl * Impl; +}; + +} // end namespace IntersonCxx + +#endif // _IntersonCxxIntersonClass_h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..fa493e0 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,24 @@ +if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") + string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") +endif() + +if(CMAKE_CXX_FLAGS MATCHES "/EHsc") + string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +endif() + +set( IntersonCxx_SRCS + IntersonCxxIntersonClass.cxx + IntersonCxxControlsHWControls.cxx + ) + +include( GenerateExportHeader ) +add_library( IntersonCxx SHARED + ${IntersonCxx_SRCS} + ) +generate_export_header( IntersonCxx + BASE_NAME IntersonCxx + EXPORT_MACRO_NAME IntersonCxx_EXPORT + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/IntersonCxx_Export.h + ) +set_target_properties( IntersonCxx PROPERTIES + COMPILE_FLAGS "/clr /EHa" ) diff --git a/src/IntersonCxxIntersonClass.cxx b/src/IntersonCxxIntersonClass.cxx new file mode 100644 index 0000000..34c351f --- /dev/null +++ b/src/IntersonCxxIntersonClass.cxx @@ -0,0 +1,33 @@ +#include "IntersonCxxIntersonClass.h" + +namespace IntersonCxx +{ + +#pragma managed + +class IntersonClassImpl +{ +public: + IntersonClassImpl() + { + } + +private: +}; + +#pragma unmanaged + +IntersonClass +::IntersonClass(): + Impl( new IntersonClassImpl() ) +{ +} + +IntersonClass +::~IntersonClass() +{ + delete Impl; +} + + +} // end namespace IntersonCxx From 1bfa9306765c44661673c84f584336e71d2dccb0 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 12:40:48 -0400 Subject: [PATCH 004/103] ENH: Add IntersonClass::Version. --- CMakeLists.txt | 7 +++++++ include/IntersonCxxIntersonClass.h | 4 +--- src/CMakeLists.txt | 16 +++++++++++++--- src/IntersonCxxIntersonClass.cxx | 26 +++++++++++++++++++++++--- test/CMakeLists.txt | 9 +++++++++ test/IntersonCxxIntersonClassTest.cxx | 12 ++++++++++++ 6 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 test/CMakeLists.txt create mode 100644 test/IntersonCxxIntersonClassTest.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index aa68dcf..2fc4546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,13 @@ project( IntersonSDKCxx ) include_directories( ${PROJECT_SOURCE_DIR}/include ) include_directories( ${PROJECT_BINARY_DIR}/include ) +find_path( IntersonSDK_DIR NAMES Libraries/Interson.dll + PATHS C:/IntersonSDK ) +if( NOT IntersonSDK_DIR ) + message( SEND_ERROR "Please specify the path to the IntersonSDK in + IntersonSDK_DIR" ) +endif() + add_subdirectory( src ) include( CTest ) diff --git a/include/IntersonCxxIntersonClass.h b/include/IntersonCxxIntersonClass.h index b814136..d56e87e 100644 --- a/include/IntersonCxxIntersonClass.h +++ b/include/IntersonCxxIntersonClass.h @@ -18,9 +18,7 @@ class IntersonCxx_EXPORT IntersonClass IntersonClass(); ~IntersonClass(); - //std::string CompleteVersion(); - - //std::string Version(); + std::string Version() const; private: IntersonClass( const IntersonClass & ); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa493e0..230da36 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,12 +13,22 @@ set( IntersonCxx_SRCS include( GenerateExportHeader ) add_library( IntersonCxx SHARED - ${IntersonCxx_SRCS} - ) + ${IntersonCxx_SRCS} + ) generate_export_header( IntersonCxx BASE_NAME IntersonCxx EXPORT_MACRO_NAME IntersonCxx_EXPORT EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/IntersonCxx_Export.h ) set_target_properties( IntersonCxx PROPERTIES - COMPILE_FLAGS "/clr /EHa" ) + COMPILE_FLAGS "/clr /EHa /AI${IntersonSDK_DIR}/Libraries" + ) +if( BUILD_TESTING ) + # For running tests + add_custom_command( TARGET IntersonCxx + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ "${PROJECT_BINARY_DIR}/test" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/test" + ) +endif() diff --git a/src/IntersonCxxIntersonClass.cxx b/src/IntersonCxxIntersonClass.cxx index 34c351f..1a0f930 100644 --- a/src/IntersonCxxIntersonClass.cxx +++ b/src/IntersonCxxIntersonClass.cxx @@ -1,10 +1,16 @@ +#pragma unmanaged #include "IntersonCxxIntersonClass.h" +#pragma managed + +#include +#include + +#using "Interson.dll" + namespace IntersonCxx { -#pragma managed - class IntersonClassImpl { public: @@ -12,9 +18,17 @@ class IntersonClassImpl { } + std::string Version() + { + std::string marshalled = msclr::interop::marshal_as< std::string >( + Interson::IntersonClass::Version ); + return marshalled; + } + private: }; + #pragma unmanaged IntersonClass @@ -29,5 +43,11 @@ IntersonClass delete Impl; } - +std::string +IntersonClass +::Version() const +{ + return Impl->Version(); +} + } // end namespace IntersonCxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..f7601bb --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,9 @@ +set( _tests + IntersonCxxIntersonClassTest + ) + +foreach( test ${_tests} ) + add_executable( ${test} ${test}.cxx ) + target_link_libraries( ${test} IntersonCxx ) + add_test( NAME ${test} COMMAND $ ) +endforeach() diff --git a/test/IntersonCxxIntersonClassTest.cxx b/test/IntersonCxxIntersonClassTest.cxx new file mode 100644 index 0000000..f4ae578 --- /dev/null +++ b/test/IntersonCxxIntersonClassTest.cxx @@ -0,0 +1,12 @@ +#include "IntersonCxxIntersonClass.h" + +#include +#include + +int main( int argc, char * argv[] ) +{ + IntersonCxx::IntersonClass intersonClass; + + std::cout << "Version: " << intersonClass.Version() << std::endl; + return EXIT_SUCCESS; +} From 5fbf1633318962531fb9244ef52cdef4a4e308ab Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 13:04:25 -0400 Subject: [PATCH 005/103] ENH: Add HWControls skeleton. --- include/IntersonCxxControlsHWControls.h | 47 ++++++++++++++++++++++ include/IntersonCxxIntersonClass.h | 2 - src/CMakeLists.txt | 2 +- src/IntersonCxxControlsHWControls.cxx | 46 +++++++++++++++++++++ test/CMakeLists.txt | 1 + test/IntersonCxxControlsHWControlsTest.cxx | 15 +++++++ 6 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 include/IntersonCxxControlsHWControls.h create mode 100644 src/IntersonCxxControlsHWControls.cxx create mode 100644 test/IntersonCxxControlsHWControlsTest.cxx diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h new file mode 100644 index 0000000..0b4986c --- /dev/null +++ b/include/IntersonCxxControlsHWControls.h @@ -0,0 +1,47 @@ +#ifndef _IntersonCxxControlsHWControls_h +#define _IntersonCxxControlsHWControls_h + +#include "IntersonCxx_Export.h" + +namespace IntersonCxx +{ + +namespace Controls +{ + +class HWControlsImpl; + +class IntersonCxx_EXPORT HWControls +{ +public: + HWControls(); + ~HWControls(); + + static const int DIG_GAIN_MIN = -127; + static const int DIG_GAIN_INIT = 0; + static const int DIG_GAIN_MAX = 127; + + static const int MAX_FREQ = 3; + + static const int ID_GP_3_5MHz = 1; + static const int ID_VC_7_5MHz = 2; + static const int ID_SP_7_5MHz = 3; + static const int ID_EC_7_5MHz = 4; + static const int ID_MV_12_MHz = 5; + static const int ID_GV_5_MHz = 6; + + static const unsigned short int EEOEMSpace = 4096; + +private: + HWControls( const HWControls & ); + void operator=( const HWControls & ); + + HWControlsImpl * Impl; +}; + +} // end namespace Controls + +} // end namespace IntersonCxx + + +#endif // _IntersonCxxControlsHWControls_h diff --git a/include/IntersonCxxIntersonClass.h b/include/IntersonCxxIntersonClass.h index d56e87e..8961a86 100644 --- a/include/IntersonCxxIntersonClass.h +++ b/include/IntersonCxxIntersonClass.h @@ -5,8 +5,6 @@ #include -#pragma unmanaged - namespace IntersonCxx { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 230da36..8d54af2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,6 +29,6 @@ if( BUILD_TESTING ) POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ "${PROJECT_BINARY_DIR}/test" COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/test" + "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/tesm" ) endif() diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx new file mode 100644 index 0000000..470d6e0 --- /dev/null +++ b/src/IntersonCxxControlsHWControls.cxx @@ -0,0 +1,46 @@ +#pragma unmanaged +#include "IntersonCxxControlsHWControls.h" + +#pragma managed + +#include +#include + +#using "Interson.dll" + +namespace IntersonCxx +{ + +namespace Controls +{ + +class HWControlsImpl +{ +public: + HWControlsImpl() + { + Wrapped = gcnew Interson::Controls::HWControls(); + } + +private: + gcroot< Interson::Controls::HWControls ^ > Wrapped; +}; + + +#pragma unmanaged + +HWControls +::HWControls(): + Impl( new HWControlsImpl() ) +{ +} + +HWControls +::~HWControls() +{ + delete Impl; +} + +} // end namespace Controls + +} // end namespace IntersonCxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f7601bb..e3baa27 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,6 @@ set( _tests IntersonCxxIntersonClassTest + IntersonCxxControlsHWControlsTest ) foreach( test ${_tests} ) diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx new file mode 100644 index 0000000..2970cdb --- /dev/null +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -0,0 +1,15 @@ +#include "IntersonCxxControlsHWControls.h" + +#include +#include + +int main( int argc, char * argv[] ) +{ + IntersonCxx::Controls::HWControls hwControls; + + std::cout << "ID_GP_3_5MHz: " << hwControls.ID_GP_3_5MHz << std::endl; + + + return EXIT_SUCCESS; +} + From 9983e4434a00bbaa300f51c08edf5238dceeeb69 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 13:12:37 -0400 Subject: [PATCH 006/103] ENH: HWControls::GetProbeID --- include/IntersonCxxControlsHWControls.h | 2 ++ src/IntersonCxxControlsHWControls.cxx | 12 ++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 1 + 3 files changed, 15 insertions(+) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 0b4986c..4ee4e79 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -32,6 +32,8 @@ class IntersonCxx_EXPORT HWControls static const unsigned short int EEOEMSpace = 4096; + unsigned char GetProbeID() const; + private: HWControls( const HWControls & ); void operator=( const HWControls & ); diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index 470d6e0..754ba1b 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -22,6 +22,11 @@ class HWControlsImpl Wrapped = gcnew Interson::Controls::HWControls(); } + unsigned char GetProbeID() + { + return Wrapped->GetProbeID(); + } + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -41,6 +46,13 @@ HWControls delete Impl; } +unsigned char +HWControls +::GetProbeID() const +{ + return Impl->GetProbeID(); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index 2970cdb..1c78f60 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -9,6 +9,7 @@ int main( int argc, char * argv[] ) std::cout << "ID_GP_3_5MHz: " << hwControls.ID_GP_3_5MHz << std::endl; + std::cout << "ProbeID: " << static_cast< int >( hwControls.GetProbeID() ) << std::endl; return EXIT_SUCCESS; } From fc842fa8cb6b49e68192afc9864b4ae656807c74 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 13:51:03 -0400 Subject: [PATCH 007/103] ENH: Find the probe. --- include/IntersonCxxControlsHWControls.h | 9 +++++ src/IntersonCxxControlsHWControls.cxx | 38 ++++++++++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 23 +++++++++++++ 3 files changed, 70 insertions(+) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 4ee4e79..1479891 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -3,6 +3,9 @@ #include "IntersonCxx_Export.h" +#include +#include + namespace IntersonCxx { @@ -14,6 +17,7 @@ class HWControlsImpl; class IntersonCxx_EXPORT HWControls { public: + typedef std::vector< std::string > FoundProbesType; HWControls(); ~HWControls(); @@ -34,6 +38,11 @@ class IntersonCxx_EXPORT HWControls unsigned char GetProbeID() const; + void FindAllProbes( FoundProbesType & foundProbes ); + + void FindMyProbe( int probeIndex ); + + private: HWControls( const HWControls & ); void operator=( const HWControls & ); diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index 754ba1b..15c111f 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -17,6 +17,8 @@ namespace Controls class HWControlsImpl { public: + typedef HWControls::FoundProbesType FoundProbesType; + HWControlsImpl() { Wrapped = gcnew Interson::Controls::HWControls(); @@ -27,6 +29,24 @@ class HWControlsImpl return Wrapped->GetProbeID(); } + void FindAllProbes( FoundProbesType & foundProbes ) + { + System::Collections::Specialized::StringCollection ^ managedProbes = + gcnew System::Collections::Specialized::StringCollection(); + Wrapped->FindAllProbes( managedProbes );; + foundProbes.resize( managedProbes->Count ); + for( int ii = 0; ii < managedProbes->Count; ++ii ) + { + foundProbes[ii] = msclr::interop::marshal_as< std::string >( + managedProbes[ii] ); + } + } + + void FindMyProbe( int probeIndex ) + { + Wrapped->FindMyProbe( probeIndex ); + } + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -40,12 +60,14 @@ ::HWControls(): { } + HWControls ::~HWControls() { delete Impl; } + unsigned char HWControls ::GetProbeID() const @@ -53,6 +75,22 @@ ::GetProbeID() const return Impl->GetProbeID(); } + +void +HWControls +::FindAllProbes( FoundProbesType & foundProbes ) +{ + Impl->FindAllProbes( foundProbes ); +} + + +void +HWControls +::FindMyProbe( int probeIndex ) +{ + Impl->FindMyProbe( probeIndex ); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index 1c78f60..dcbbde6 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -11,6 +11,29 @@ int main( int argc, char * argv[] ) std::cout << "ProbeID: " << static_cast< int >( hwControls.GetProbeID() ) << std::endl; + typedef IntersonCxx::Controls::HWControls::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + std::cout << "Found Probes: " << std::endl; + for( size_t ii = 0; ii < foundProbes.size(); ++ii ) + { + std::cout << " " << foundProbes[ii] << std::endl; + } + if( foundProbes.size() == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; } From 7fe6202101de30a22b5ef3dd043a14fd2867ac6b Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 20:50:03 -0400 Subject: [PATCH 008/103] ENH: Add SetFrequency. --- include/IntersonCxxControlsHWControls.h | 11 +++- src/IntersonCxxControlsHWControls.cxx | 61 +++++++++++++++++++++- test/IntersonCxxControlsHWControlsTest.cxx | 19 +++++++ 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 1479891..16ca04d 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -18,6 +18,7 @@ class IntersonCxx_EXPORT HWControls { public: typedef std::vector< std::string > FoundProbesType; + typedef std::vector< int > FrequenciesType; HWControls(); ~HWControls(); @@ -36,11 +37,17 @@ class IntersonCxx_EXPORT HWControls static const unsigned short int EEOEMSpace = 4096; + void FindAllProbes( FoundProbesType & foundProbes ) const; + void FindMyProbe( int probeIndex ); unsigned char GetProbeID() const; - void FindAllProbes( FoundProbesType & foundProbes ); + int ValidDepth( int depth ) const; + + /** Get the list of supported frequecies. */ + void GetFrequency( FrequenciesType & frequencies ) const; + + bool SetFrequency( int frequency ); - void FindMyProbe( int probeIndex ); private: diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index 15c111f..e7ceb42 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -18,6 +18,8 @@ class HWControlsImpl { public: typedef HWControls::FoundProbesType FoundProbesType; + typedef HWControls::FrequenciesType FrequenciesType; + HWControlsImpl() { @@ -47,6 +49,40 @@ class HWControlsImpl Wrapped->FindMyProbe( probeIndex ); } + int ValidDepth( int depth ) + { + return Wrapped->ValidDepth( depth ); + } + + void GetFrequency( FrequenciesType & frequencies ) + { + array< int > ^ managedFrequencies = Wrapped->GetFrequency(); + frequencies.resize( managedFrequencies->Length ); + for( int ii = 0; ii < managedFrequencies->Length; ++ii ) + { + frequencies[ii] = managedFrequencies[ii]; + } + } + + bool SetFrequency( int frequency ) + { + array< int > ^ managedFrequencies = Wrapped->GetFrequency(); + int frequencyIndex = -1; + for( int ii = 0; ii < managedFrequencies->Length; ++ii ) + { + if( frequency == managedFrequencies[ii] ) + { + frequencyIndex = ii; + break; + } + } + if( frequencyIndex == -1 ) + { + return false; + } + return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); + } + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -78,7 +114,7 @@ ::GetProbeID() const void HWControls -::FindAllProbes( FoundProbesType & foundProbes ) +::FindAllProbes( FoundProbesType & foundProbes ) const { Impl->FindAllProbes( foundProbes ); } @@ -91,6 +127,29 @@ ::FindMyProbe( int probeIndex ) Impl->FindMyProbe( probeIndex ); } +int +HWControls +::ValidDepth( int depth ) const +{ + return Impl->ValidDepth( depth ); +} + + +void +HWControls +::GetFrequency( FrequenciesType & frequencies ) const +{ + Impl->GetFrequency( frequencies ); +} + + +bool +HWControls +::SetFrequency( int frequency ) +{ + return Impl->SetFrequency( frequency ); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index dcbbde6..f8cd1ba 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -6,6 +6,7 @@ int main( int argc, char * argv[] ) { IntersonCxx::Controls::HWControls hwControls; + typedef IntersonCxx::Controls::HWControls HWControlsType; std::cout << "ID_GP_3_5MHz: " << hwControls.ID_GP_3_5MHz << std::endl; @@ -34,6 +35,24 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } + int depth = hwControls.ValidDepth( 3 ); + std::cout << "\nValidDepth( 3 ): " << depth << std::endl; + depth = hwControls.ValidDepth( 1000 ); + std::cout << "ValidDepth( 1000 ): " << depth << std::endl; + + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency( frequencies ); + std::cout << "\nFrequencies: " << std::endl; + for( size_t ii = 0; ii < frequencies.size(); ++ii ) + { + std::cout << " " << frequencies[ii] << std::endl; + } + if( !hwControls.SetFrequency( frequencies[0] ) ) + { + std::cerr << "Could not set the frequency." << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; } From fbd4e0a543401e0d180f7c55b087fc234c7d7177 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 25 Mar 2014 21:28:35 -0400 Subject: [PATCH 009/103] ENH: Add voltage controls. --- include/IntersonCxxControlsHWControls.h | 8 +++-- src/IntersonCxxControlsHWControls.cxx | 39 ++++++++++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 4 +++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 16ca04d..123f5fb 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -41,13 +41,17 @@ class IntersonCxx_EXPORT HWControls void FindMyProbe( int probeIndex ); unsigned char GetProbeID() const; + /** Units: mm */ int ValidDepth( int depth ) const; - /** Get the list of supported frequecies. */ + /** Get the list of supported frequencies. Units: Hz. */ void GetFrequency( FrequenciesType & frequencies ) const; - bool SetFrequency( int frequency ); + /** Units: Volts */ + bool SendHighVoltage( unsigned char voltage ); + bool EnableHighVoltage(); + bool DisableHighVoltage(); private: diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index e7ceb42..42c47dc 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -83,6 +83,21 @@ class HWControlsImpl return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); } + bool SendHighVoltage( unsigned char voltage ) + { + return Wrapped->SendHighVoltage( voltage ); + } + + bool EnableHighVoltage() + { + return Wrapped->EnableHighVoltage(); + } + + bool DisableHighVoltage() + { + return Wrapped->DisableHighVoltage(); + } + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -150,6 +165,30 @@ ::SetFrequency( int frequency ) return Impl->SetFrequency( frequency ); } + +bool +HWControls +::SendHighVoltage( unsigned char voltage ) +{ + return Impl->SendHighVoltage( voltage ); +} + + +bool +HWControls +::EnableHighVoltage() +{ + return Impl->EnableHighVoltage(); +} + + +bool +HWControls +::DisableHighVoltage() +{ + return Impl->DisableHighVoltage(); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index f8cd1ba..b41bf83 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -53,6 +53,10 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } + hwControls.SendHighVoltage( 50 ); + hwControls.EnableHighVoltage(); + hwControls.DisableHighVoltage(); + return EXIT_SUCCESS; } From 378a18a7db50bc2e306a01354c7a9ab426f20736 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 26 Mar 2014 14:20:51 -0400 Subject: [PATCH 010/103] ENH: SendDynamic and {Start,Stop} motor. --- include/IntersonCxxControlsHWControls.h | 4 +++ src/IntersonCxxControlsHWControls.cxx | 40 ++++++++++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 5 +++ 3 files changed, 49 insertions(+) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 123f5fb..00c9863 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -53,6 +53,10 @@ class IntersonCxx_EXPORT HWControls bool EnableHighVoltage(); bool DisableHighVoltage(); + bool SendDynamic( unsigned char dynamic ); + + bool StartMotor(); + bool StopMotor(); private: HWControls( const HWControls & ); diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index 42c47dc..f1cdaf7 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -98,6 +98,22 @@ class HWControlsImpl return Wrapped->DisableHighVoltage(); } + bool SendDynamic( unsigned char dynamic ) + { + return Wrapped->SendDynamic( dynamic ); + } + + bool StartMotor() + { + return Wrapped->StartMotor(); + } + + bool StopMotor() + { + return Wrapped->StopMotor(); + } + + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -189,6 +205,30 @@ ::DisableHighVoltage() return Impl->DisableHighVoltage(); } + +bool +HWControls +::SendDynamic( unsigned char dynamic ) +{ + return Impl->SendDynamic( dynamic ); +} + + +bool +HWControls +::StartMotor() +{ + return Impl->StartMotor(); +} + + +bool +HWControls +::StopMotor() +{ + return Impl->StopMotor(); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index b41bf83..bde3e73 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -57,6 +57,11 @@ int main( int argc, char * argv[] ) hwControls.EnableHighVoltage(); hwControls.DisableHighVoltage(); + hwControls.SendDynamic( 50 ); + + hwControls.StartMotor(); + hwControls.StopMotor(); + return EXIT_SUCCESS; } From 9466283aebe422e1428951c71ca51fa99a9bf6f5 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 26 Mar 2014 14:27:53 -0400 Subject: [PATCH 011/103] ENH: Hard button methods. --- include/IntersonCxxControlsHWControls.h | 4 +++ src/IntersonCxxControlsHWControls.cxx | 38 ++++++++++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 5 +++ 3 files changed, 47 insertions(+) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 00c9863..6b56e0a 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -58,6 +58,10 @@ class IntersonCxx_EXPORT HWControls bool StartMotor(); bool StopMotor(); + void EnableHardButton(); + void DisableHardButton(); + unsigned char ReadHardButton(); + private: HWControls( const HWControls & ); void operator=( const HWControls & ); diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index f1cdaf7..b9d75b9 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -113,6 +113,20 @@ class HWControlsImpl return Wrapped->StopMotor(); } + void EnableHardButton() + { + Wrapped->EnableHardButton(); + } + + void DisableHardButton() + { + Wrapped->DisableHardButton(); + } + + unsigned char ReadHardButton() + { + return Wrapped->ReadHardButton(); + } private: gcroot< Interson::Controls::HWControls ^ > Wrapped; @@ -229,6 +243,30 @@ ::StopMotor() return Impl->StopMotor(); } + +void +HWControls +::EnableHardButton() +{ + Impl->EnableHardButton(); +} + + +void +HWControls +::DisableHardButton() +{ + Impl->DisableHardButton(); +} + + +unsigned char +HWControls +::ReadHardButton() +{ + return Impl->ReadHardButton(); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index bde3e73..2f32514 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -62,6 +62,11 @@ int main( int argc, char * argv[] ) hwControls.StartMotor(); hwControls.StopMotor(); + hwControls.EnableHardButton(); + hwControls.DisableHardButton(); + const unsigned char button = hwControls.ReadHardButton(); + std::cout << "\nButton: " << static_cast< int >( button ) << std::endl; + return EXIT_SUCCESS; } From b97b10e03f174093c104e4a0d979571764788393 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 31 Mar 2014 23:39:46 -0400 Subject: [PATCH 012/103] ENH: Start/stop acquisition. --- include/IntersonCxxControlsHWControls.h | 4 +++ src/IntersonCxxControlsHWControls.cxx | 39 ++++++++++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 22 ++++++++++++ 3 files changed, 65 insertions(+) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 6b56e0a..faa8f3b 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -62,6 +62,10 @@ class IntersonCxx_EXPORT HWControls void DisableHardButton(); unsigned char ReadHardButton(); + bool StartBmode(); + bool StartRFmode(); + bool StopAcquisition(); + private: HWControls( const HWControls & ); void operator=( const HWControls & ); diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index b9d75b9..8ba2fc5 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -128,6 +128,21 @@ class HWControlsImpl return Wrapped->ReadHardButton(); } + bool StartBmode() + { + return Wrapped->StartBmode(); + } + + bool StartRFmode() + { + return Wrapped->StartRFmode(); + } + + bool StopAcquisition() + { + return Wrapped->StopAcquisition(); + } + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -267,6 +282,30 @@ ::ReadHardButton() return Impl->ReadHardButton(); } + +bool +HWControls +::StartBmode() +{ + return Impl->StartBmode(); +} + + +bool +HWControls +::StartRFmode() +{ + return Impl->StartRFmode(); +} + + +bool +HWControls +::StopAcquisition() +{ + return Impl->StopAcquisition(); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index 2f32514..93eea7c 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -67,6 +67,28 @@ int main( int argc, char * argv[] ) const unsigned char button = hwControls.ReadHardButton(); std::cout << "\nButton: " << static_cast< int >( button ) << std::endl; + std::cout << "\nStarting acquisition..." << std::endl; + if( !hwControls.StartBmode() ) + { + std::cerr << "Could not start B mode acquision." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.StopAcquisition() ) + { + std::cerr << "Could not stop acquision." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.StartRFmode() ) + { + std::cerr << "Could not start RF acquision." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.StopAcquisition() ) + { + std::cerr << "Could not stop acquision." << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; } From cfb53c3367f8bd27f0df47e911bb66b3eaddae1c Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 31 Mar 2014 23:54:01 -0400 Subject: [PATCH 013/103] ENH: Get frame rate, serial number, fpga version. --- include/IntersonCxxControlsHWControls.h | 4 +++ src/IntersonCxxControlsHWControls.cxx | 39 ++++++++++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 5 +++ 3 files changed, 48 insertions(+) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index faa8f3b..e0878bc 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -66,6 +66,10 @@ class IntersonCxx_EXPORT HWControls bool StartRFmode(); bool StopAcquisition(); + short GetProbeFrameRate( int depth ); + std::string GetProbeSerialNumber() const; + std::string ReadFPGAVersion() const; + private: HWControls( const HWControls & ); void operator=( const HWControls & ); diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index 8ba2fc5..f35f4f1 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -143,6 +143,21 @@ class HWControlsImpl return Wrapped->StopAcquisition(); } + short GetProbeFrameRate( int depth ) + { + return Wrapped->GetProbeFrameRate( depth ); + } + + std::string GetProbeSerialNumber() + { + return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); + } + + std::string ReadFPGAVersion() + { + return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); + } + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -306,6 +321,30 @@ ::StopAcquisition() return Impl->StopAcquisition(); } + +short +HWControls +::GetProbeFrameRate( int depth ) +{ + return Impl->GetProbeFrameRate( depth ); +} + + +std::string +HWControls +::GetProbeSerialNumber() const +{ + return Impl->GetProbeSerialNumber(); +} + + +std::string +HWControls +::ReadFPGAVersion() const +{ + return Impl->ReadFPGAVersion(); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index 93eea7c..b9cdc74 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -89,6 +89,11 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } + const short frameRate = hwControls.GetProbeFrameRate( 40 ); + std::cout << "Frame rate: " << frameRate << std::endl; + std::cout << "Serial number: " << hwControls.GetProbeSerialNumber() << std::endl; + std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() << std::endl; + return EXIT_SUCCESS; } From 124464f92d3051674eea302d0e2f371f68a5f10d Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 1 Apr 2014 10:48:53 -0400 Subject: [PATCH 014/103] ENH: Enable/Disable RF decimator. --- include/IntersonCxxControlsHWControls.h | 5 +++ src/IntersonCxxControlsHWControls.cxx | 52 ++++++++++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 15 ++++++- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index e0878bc..7e27654 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -69,6 +69,11 @@ class IntersonCxx_EXPORT HWControls short GetProbeFrameRate( int depth ); std::string GetProbeSerialNumber() const; std::string ReadFPGAVersion() const; + std::string GetOEMId() const; + std::string GetFilterId() const; + + bool EnableRFDecimator(); + bool DisableRFDecimator(); private: HWControls( const HWControls & ); diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index f35f4f1..a240e78 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -158,6 +158,26 @@ class HWControlsImpl return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); } + std::string GetOEMId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); + } + + std::string GetFilterId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); + } + + bool EnableRFDecimator() + { + return Wrapped->EnableRFDecimator(); + } + + bool DisableRFDecimator() + { + return Wrapped->DisableRFDecimator(); + } + private: gcroot< Interson::Controls::HWControls ^ > Wrapped; }; @@ -345,6 +365,38 @@ ::ReadFPGAVersion() const return Impl->ReadFPGAVersion(); } + +std::string +HWControls +::GetOEMId() const +{ + return Impl->GetOEMId(); +} + + +std::string +HWControls +::GetFilterId() const +{ + return Impl->GetFilterId(); +} + + +bool +HWControls +::EnableRFDecimator() +{ + return Impl->EnableRFDecimator(); +} + + +bool +HWControls +::DisableRFDecimator() +{ + return Impl->DisableRFDecimator(); +} + } // end namespace Controls } // end namespace IntersonCxx diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index b9cdc74..c19c79a 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -67,7 +67,7 @@ int main( int argc, char * argv[] ) const unsigned char button = hwControls.ReadHardButton(); std::cout << "\nButton: " << static_cast< int >( button ) << std::endl; - std::cout << "\nStarting acquisition..." << std::endl; + std::cout << "\nStarting acquisition...\n" << std::endl; if( !hwControls.StartBmode() ) { std::cerr << "Could not start B mode acquision." << std::endl; @@ -93,6 +93,19 @@ int main( int argc, char * argv[] ) std::cout << "Frame rate: " << frameRate << std::endl; std::cout << "Serial number: " << hwControls.GetProbeSerialNumber() << std::endl; std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() << std::endl; + std::cout << "OEM ID: " << hwControls.GetOEMId() << std::endl; + std::cout << "Filter ID: " << hwControls.GetFilterId() << std::endl; + + if( !hwControls.EnableRFDecimator() ) + { + std::cerr << "Could not enable the RF decimator." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.DisableRFDecimator() ) + { + std::cerr << "Could not disable the RF decimator." << std::endl; + return EXIT_FAILURE; + } return EXIT_SUCCESS; } From 10ecb1bb1a40bc890847c1c7c746c026a72b8cc0 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 1 Apr 2014 10:58:14 -0400 Subject: [PATCH 015/103] ENH: Add IntersonCxx::Imaging::Scan2DClass constructor. --- include/IntersonCxxImagingScan2DClass.h | 36 +++++++++++++++++ src/CMakeLists.txt | 1 + src/IntersonCxxImagingScan2DClass.cxx | 47 ++++++++++++++++++++++ test/CMakeLists.txt | 1 + test/IntersonCxxControlsHWControlsTest.cxx | 1 - test/IntersonCxxImagingScan2DClassTest.cxx | 12 ++++++ 6 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 include/IntersonCxxImagingScan2DClass.h create mode 100644 src/IntersonCxxImagingScan2DClass.cxx create mode 100644 test/IntersonCxxImagingScan2DClassTest.cxx diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h new file mode 100644 index 0000000..1dd453d --- /dev/null +++ b/include/IntersonCxxImagingScan2DClass.h @@ -0,0 +1,36 @@ +#ifndef _IntersonCxxImagingScan2DClass_h +#define _IntersonCxxImagingScan2DClass_h + +#include "IntersonCxx_Export.h" + +#include +#include + +namespace IntersonCxx +{ + +namespace Imaging +{ + +class Scan2DClassImpl; + +class IntersonCxx_EXPORT Scan2DClass +{ +public: + Scan2DClass(); + ~Scan2DClass(); + + +private: + Scan2DClass( const Scan2DClass & ); + void operator=( const Scan2DClass & ); + + Scan2DClassImpl * Impl; +}; + +} // end namespace Imaging + +} // end namespace IntersonCxx + + +#endif // _IntersonCxxImagingScan2DClass_h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d54af2..399fdc7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,7 @@ endif() set( IntersonCxx_SRCS IntersonCxxIntersonClass.cxx IntersonCxxControlsHWControls.cxx + IntersonCxxImagingScan2DClass.cxx ) include( GenerateExportHeader ) diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx new file mode 100644 index 0000000..452f649 --- /dev/null +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -0,0 +1,47 @@ +#pragma unmanaged +#include "IntersonCxxImagingScan2DClass.h" + +#pragma managed + +#include +#include + +#using "Interson.dll" + +namespace IntersonCxx +{ + +namespace Imaging +{ + +class Scan2DClassImpl +{ +public: + Scan2DClassImpl() + { + Wrapped = gcnew Interson::Imaging::Scan2DClass(); + } + +private: + gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; +}; + + +#pragma unmanaged + +Scan2DClass +::Scan2DClass(): + Impl( new Scan2DClassImpl() ) +{ +} + + +Scan2DClass +::~Scan2DClass() +{ + delete Impl; +} + +} // end namespace Imaging + +} // end namespace IntersonCxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e3baa27..7555709 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,7 @@ set( _tests IntersonCxxIntersonClassTest IntersonCxxControlsHWControlsTest + IntersonCxxImagingScan2DClassTest ) foreach( test ${_tests} ) diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index c19c79a..c7988dd 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -109,4 +109,3 @@ int main( int argc, char * argv[] ) return EXIT_SUCCESS; } - diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx new file mode 100644 index 0000000..b93a73e --- /dev/null +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -0,0 +1,12 @@ +#include "IntersonCxxImagingScan2DClass.h" + +#include +#include + +int main( int argc, char * argv[] ) +{ + IntersonCxx::Imaging::Scan2DClass scan2D; + typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + + return EXIT_SUCCESS; +} From 7ea268e73dab8156778d7b540ef3be360bf167d2 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 1 Apr 2014 11:47:43 -0400 Subject: [PATCH 016/103] ENH: Add Scan2D constants. --- include/IntersonCxxImagingScan2DClass.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 1dd453d..ee63e0f 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -20,6 +20,10 @@ class IntersonCxx_EXPORT Scan2DClass Scan2DClass(); ~Scan2DClass(); + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + static const int MAX_VECTORS = 241; + private: Scan2DClass( const Scan2DClass & ); From e51b696176eb238a9d42da2a660c2158d95ddead Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 1 Apr 2014 12:32:53 -0400 Subject: [PATCH 017/103] ENH: Scan2D RFData. --- include/IntersonCxxImagingScan2DClass.h | 4 +++ src/IntersonCxxImagingScan2DClass.cxx | 40 ++++++++++++++++++++++ test/IntersonCxxImagingScan2DClassTest.cxx | 13 ++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index ee63e0f..0680675 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -24,6 +24,10 @@ class IntersonCxx_EXPORT Scan2DClass static const int MAX_RFSAMPLES = 2048; static const int MAX_VECTORS = 241; + bool GetScanOn() const; + + bool GetRFData() const; + void SetRFData( bool transferOn ); private: Scan2DClass( const Scan2DClass & ); diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 452f649..67a9e4c 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -22,6 +22,22 @@ class Scan2DClassImpl Wrapped = gcnew Interson::Imaging::Scan2DClass(); } + bool GetScanOn() + { + return Wrapped->ScanOn; + } + + bool GetRFData() + { + return Wrapped->RFData; + } + + void SetRFData( bool transferOn ) + { + Wrapped->RFData = transferOn; + } + + private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; }; @@ -42,6 +58,30 @@ Scan2DClass delete Impl; } + +bool +Scan2DClass +::GetScanOn() const +{ + return Impl->GetScanOn(); +} + + +bool +Scan2DClass +::GetRFData() const +{ + return Impl->GetRFData(); +} + + +void +Scan2DClass +::SetRFData( bool transferOn ) +{ + Impl->SetRFData( transferOn ); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index b93a73e..9de055f 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -1,12 +1,23 @@ #include "IntersonCxxImagingScan2DClass.h" +#include "IntersonCxxControlsHWControls.h" #include #include int main( int argc, char * argv[] ) { + IntersonCxx::Controls::HWControls hwControls; IntersonCxx::Imaging::Scan2DClass scan2D; typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; - return EXIT_SUCCESS; + std::cout << "Scan is on: " << scan2D.GetScanOn() << std::endl; + std::cout << "RF Data transfer is on: " << scan2D.GetRFData() << std::endl; + + int ret = EXIT_SUCCESS; + + hwControls.StartMotor(); + + hwControls.StopMotor(); + + return ret; } From b0c75cbd21c9316144a337090d68737b341415db Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 1 Apr 2014 18:04:04 -0400 Subject: [PATCH 018/103] ENH: StartReadScan. --- include/IntersonCxxImagingScan2DClass.h | 3 ++ src/IntersonCxxImagingScan2DClass.cxx | 39 ++++++++++++++++++++++ test/IntersonCxxImagingScan2DClassTest.cxx | 7 ++++ 3 files changed, 49 insertions(+) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 0680675..bb0fe10 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -29,6 +29,9 @@ class IntersonCxx_EXPORT Scan2DClass bool GetRFData() const; void SetRFData( bool transferOn ); + void StartReadScan( unsigned char * buffer ); + void StopReadScan(); + private: Scan2DClass( const Scan2DClass & ); void operator=( const Scan2DClass & ); diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 67a9e4c..8af6c7d 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -7,6 +7,8 @@ #include #using "Interson.dll" +// For StartReadScan +#using "System.Drawing.dll" namespace IntersonCxx { @@ -17,9 +19,12 @@ namespace Imaging class Scan2DClassImpl { public: + typedef cli::array< byte, 2 > BmodeArrayType; + Scan2DClassImpl() { Wrapped = gcnew Interson::Imaging::Scan2DClass(); + BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); } bool GetScanOn() @@ -37,9 +42,27 @@ class Scan2DClassImpl Wrapped->RFData = transferOn; } + void StartReadScan( unsigned char * buffer ) + { + Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); + for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) + { + buffer[Scan2DClass::MAX_VECTORS * ii + jj] = BmodeBuffer[ii, jj]; + } + } + } + + void StopReadScan() + { + Wrapped->StopReadScan(); + } private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; + + gcroot< BmodeArrayType ^ > BmodeBuffer; }; @@ -82,6 +105,22 @@ ::SetRFData( bool transferOn ) Impl->SetRFData( transferOn ); } + +void +Scan2DClass +::StartReadScan( unsigned char * buffer ) +{ + Impl->StartReadScan( buffer ); +} + + +void +Scan2DClass +::StopReadScan() +{ + Impl->StopReadScan(); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index 9de055f..ebeb8ca 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -16,8 +16,15 @@ int main( int argc, char * argv[] ) int ret = EXIT_SUCCESS; hwControls.StartMotor(); + unsigned char * bModeBuffer = new unsigned char[Scan2DClassType::MAX_VECTORS * Scan2DClassType::MAX_SAMPLES]; + scan2D.StartReadScan( bModeBuffer ); + + hwControls.StopAcquisition(); + scan2D.StopReadScan(); hwControls.StopMotor(); + delete[] bModeBuffer; + return ret; } From b7cf83cde821d43778fa3e5d7504fd740fce1b1b Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 2 Apr 2014 19:53:54 -0400 Subject: [PATCH 019/103] ENH: Improvements to StartReadScan. Do not pass the buffer pointer -- it is used interally for image creation callback data. We will create our own callback system to bridge the managed event management system. --- include/IntersonCxxImagingScan2DClass.h | 4 ++- src/IntersonCxxImagingScan2DClass.cxx | 10 ++++--- test/IntersonCxxImagingScan2DClassTest.cxx | 33 ++++++++++++++++++---- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index bb0fe10..f223747 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -29,7 +29,7 @@ class IntersonCxx_EXPORT Scan2DClass bool GetRFData() const; void SetRFData( bool transferOn ); - void StartReadScan( unsigned char * buffer ); + void StartReadScan(); void StopReadScan(); private: @@ -37,6 +37,8 @@ class IntersonCxx_EXPORT Scan2DClass void operator=( const Scan2DClass & ); Scan2DClassImpl * Impl; + + unsigned char * BmodeBuffer; }; } // end namespace Imaging diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 8af6c7d..c461efa 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -49,7 +49,7 @@ class Scan2DClassImpl { for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) { - buffer[Scan2DClass::MAX_VECTORS * ii + jj] = BmodeBuffer[ii, jj]; + buffer[Scan2DClass::MAX_SAMPLES * ii + jj] = BmodeBuffer[ii, jj]; } } } @@ -70,7 +70,8 @@ class Scan2DClassImpl Scan2DClass ::Scan2DClass(): - Impl( new Scan2DClassImpl() ) + Impl( new Scan2DClassImpl() ), + BmodeBuffer( new unsigned char[MAX_SAMPLES * MAX_VECTORS] ) { } @@ -79,6 +80,7 @@ Scan2DClass ::~Scan2DClass() { delete Impl; + delete [] BmodeBuffer; } @@ -108,9 +110,9 @@ ::SetRFData( bool transferOn ) void Scan2DClass -::StartReadScan( unsigned char * buffer ) +::StartReadScan() { - Impl->StartReadScan( buffer ); + Impl->StartReadScan( BmodeBuffer ); } diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index ebeb8ca..3c6e7d8 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -3,6 +3,10 @@ #include #include +#include + +#include // Sleep + int main( int argc, char * argv[] ) { @@ -10,21 +14,38 @@ int main( int argc, char * argv[] ) IntersonCxx::Imaging::Scan2DClass scan2D; typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; - std::cout << "Scan is on: " << scan2D.GetScanOn() << std::endl; + typedef IntersonCxx::Controls::HWControls::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; std::cout << "RF Data transfer is on: " << scan2D.GetRFData() << std::endl; int ret = EXIT_SUCCESS; + + const int maxVectors = Scan2DClassType::MAX_VECTORS; + const int maxSamples = Scan2DClassType::MAX_SAMPLES; + const int maxPixels = maxVectors * maxSamples; hwControls.StartMotor(); - unsigned char * bModeBuffer = new unsigned char[Scan2DClassType::MAX_VECTORS * Scan2DClassType::MAX_SAMPLES]; - scan2D.StartReadScan( bModeBuffer ); + std::cout << "\nStarting BMode scanning..." << std::endl; + scan2D.StartReadScan(); + Sleep( 100 ); // "time to start" + hwControls.StartBmode(); + std::cout << "Scan is on: " << scan2D.GetScanOn() << std::endl; hwControls.StopAcquisition(); scan2D.StopReadScan(); - + Sleep( 100 ); // "time to stop" hwControls.StopMotor(); - delete[] bModeBuffer; - return ret; } From 0fdc05ede03b7bd11e8aca10cff4d07b9a7fe3b2 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 2 Apr 2014 20:07:46 -0400 Subject: [PATCH 020/103] ENH: DisposeScan(), AbortScan(). --- include/IntersonCxxImagingScan2DClass.h | 2 ++ src/IntersonCxxImagingScan2DClass.cxx | 26 ++++++++++++++++++++++ test/IntersonCxxImagingScan2DClassTest.cxx | 2 ++ 3 files changed, 30 insertions(+) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index f223747..41d631b 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -31,6 +31,8 @@ class IntersonCxx_EXPORT Scan2DClass void StartReadScan(); void StopReadScan(); + void DisposeScan(); + void AbortScan(); private: Scan2DClass( const Scan2DClass & ); diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index c461efa..48dfcf5 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -59,6 +59,16 @@ class Scan2DClassImpl Wrapped->StopReadScan(); } + void DisposeScan() + { + Wrapped->DisposeScan(); + } + + void AbortScan() + { + Wrapped->AbortScan(); + } + private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; @@ -123,6 +133,22 @@ ::StopReadScan() Impl->StopReadScan(); } + +void +Scan2DClass +::DisposeScan() +{ + Impl->DisposeScan(); +} + + +void +Scan2DClass +::AbortScan() +{ + Impl->AbortScan(); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index 3c6e7d8..84af565 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -35,6 +35,7 @@ int main( int argc, char * argv[] ) const int maxSamples = Scan2DClassType::MAX_SAMPLES; const int maxPixels = maxVectors * maxSamples; + scan2D.AbortScan(); hwControls.StartMotor(); std::cout << "\nStarting BMode scanning..." << std::endl; scan2D.StartReadScan(); @@ -45,6 +46,7 @@ int main( int argc, char * argv[] ) hwControls.StopAcquisition(); scan2D.StopReadScan(); Sleep( 100 ); // "time to stop" + scan2D.DisposeScan(); hwControls.StopMotor(); return ret; From 7cc2c91f9626054ee3037e04ce564605043d0864 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 7 Apr 2014 11:27:21 -0400 Subject: [PATCH 021/103] ENH: AcquireIntersonBMode app skeleton. --- CMakeLists.txt | 5 +++++ app/AcquireIntersonBMode.cxx | 12 ++++++++++++ app/AcquireIntersonBMode.xml | 19 +++++++++++++++++++ app/CMakeLists.txt | 19 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 app/AcquireIntersonBMode.cxx create mode 100644 app/AcquireIntersonBMode.xml create mode 100644 app/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fc4546..52d03a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,3 +19,8 @@ if( BUILD_TESTING ) enable_testing() add_subdirectory( test ) endif() + +option( BUILD_APPLICATIONS "Build applications" OFF ) +if( BUILD_APPLICATIONS ) + add_subdirectory( app ) +endif() diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx new file mode 100644 index 0000000..0c7052e --- /dev/null +++ b/app/AcquireIntersonBMode.cxx @@ -0,0 +1,12 @@ +#include "itkImageFileWriter.h" + +#include "AcquireIntersonBModeCLP.h" + +int main( int argc, char * argv[] ) +{ + PARSE_ARGS; + + const unsigned int Dimension = 3; + + return EXIT_SUCCESS; +} diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml new file mode 100644 index 0000000..5b0e76a --- /dev/null +++ b/app/AcquireIntersonBMode.xml @@ -0,0 +1,19 @@ + + + Ultrasound + Acquire Interson B Mode + Acquire multiple B-Mode frames with the Interson USB probe. + 0.1.0 + Apache 2.0 + Matt McCormick (Kitware) + This work is funded in part by a grant with InnerOptic/Kitware + + + outputImage + + output + 0 + Output image filename. + + + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt new file mode 100644 index 0000000..0e3ef3b --- /dev/null +++ b/app/CMakeLists.txt @@ -0,0 +1,19 @@ +find_package( SlicerExecutionModel REQUIRED ) +include( ${SlicerExecutionModel_USE_FILE} ) + +find_package( ITK REQUIRED ) +include( ${ITK_USE_FILE} ) + +SEMMacroBuildCLI( + NAME AcquireIntersonBMode + TARGET_LIBRARIES ${ITK_LIBRARIES} + INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ) + +if( BUILD_TESTING ) + add_test( NAME AcquireIntersonBModeTest + COMMAND $ + AcquireIntersonBModeTest.mha + ) +endif() From 1e396c658b20f205f896ddef883fc7ec57944022 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 7 Apr 2014 11:40:49 -0400 Subject: [PATCH 022/103] ENH: App uses the Interson .dll's. --- app/AcquireIntersonBMode.cxx | 28 ++++++++++++++++++++++++++++ app/CMakeLists.txt | 1 + src/CMakeLists.txt | 5 +++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index 0c7052e..d755010 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -1,5 +1,10 @@ +#include // Sleep + #include "itkImageFileWriter.h" +#include "IntersonCxxImagingScan2DClass.h" +#include "IntersonCxxControlsHWControls.h" + #include "AcquireIntersonBModeCLP.h" int main( int argc, char * argv[] ) @@ -7,6 +12,29 @@ int main( int argc, char * argv[] ) PARSE_ARGS; const unsigned int Dimension = 3; + typedef unsigned char PixelType; + typedef itk::Image< PixelType, Dimension > ImageType; + + typedef IntersonCxx::Controls::HWControls HWControlsType; + IntersonCxx::Controls::HWControls hwControls; + + typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + Scan2DClassType scan2D; + + typedef HWControlsType::FoundProbesType FoundProbesType; + + typedef itk::ImageFileWriter< ImageType > WriterType; + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName( outputImage ); + try + { + // writer->Update(); + } + catch( itk::ExceptionObject & error ) + { + std::cerr << "Error: " << error << std::endl; + return EXIT_FAILURE; + } return EXIT_SUCCESS; } diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 0e3ef3b..0ad386d 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -7,6 +7,7 @@ include( ${ITK_USE_FILE} ) SEMMacroBuildCLI( NAME AcquireIntersonBMode TARGET_LIBRARIES ${ITK_LIBRARIES} + IntersonCxx INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 399fdc7..d502513 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,7 +29,8 @@ if( BUILD_TESTING ) add_custom_command( TARGET IntersonCxx POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ "${PROJECT_BINARY_DIR}/test" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/tesm" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/test" + COMMAND ${CMAKE_COMMAND} -E copy $ "${PROJECT_BINARY_DIR}/app/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/app/bin" ) endif() From f673b27ff5fe806209798801f5d00fcb39bd3798 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 7 Apr 2014 11:45:56 -0400 Subject: [PATCH 023/103] BUG: Avoid exception when probe not connected. --- app/AcquireIntersonBMode.cxx | 15 +++++++++++++++ test/IntersonCxxControlsHWControlsTest.cxx | 2 +- test/IntersonCxxImagingScan2DClassTest.cxx | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index d755010..5129f14 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -22,6 +22,21 @@ int main( int argc, char * argv[] ) Scan2DClassType scan2D; typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } typedef itk::ImageFileWriter< ImageType > WriterType; WriterType::Pointer writer = WriterType::New(); diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonCxxControlsHWControlsTest.cxx index c7988dd..cf21a0b 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonCxxControlsHWControlsTest.cxx @@ -20,7 +20,7 @@ int main( int argc, char * argv[] ) { std::cout << " " << foundProbes[ii] << std::endl; } - if( foundProbes.size() == 0 ) + if( foundProbes.empty() ) { std::cerr << "Could not find the probe." << std::endl; return EXIT_FAILURE; diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index 84af565..fdbbf88 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -17,6 +17,11 @@ int main( int argc, char * argv[] ) typedef IntersonCxx::Controls::HWControls::FoundProbesType FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } hwControls.FindMyProbe( 0 ); const unsigned int probeId = hwControls.GetProbeID(); std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; From 5ea851020542cd7d84cbb2a846420af1ac155b07 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 7 Apr 2014 12:08:23 -0400 Subject: [PATCH 024/103] ENH: Start/stop app. --- app/AcquireIntersonBMode.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index 5129f14..d4ece71 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -31,13 +31,26 @@ int main( int argc, char * argv[] ) } hwControls.FindMyProbe( 0 ); const unsigned int probeId = hwControls.GetProbeID(); - std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; if( probeId == 0 ) { std::cerr << "Could not find the probe." << std::endl; return EXIT_FAILURE; } + int ret = EXIT_SUCCESS; + + scan2D.AbortScan(); + hwControls.StartMotor(); + scan2D.StartReadScan(); + Sleep( 100 ); // "time to start" + hwControls.StartBmode(); + + hwControls.StopAcquisition(); + scan2D.StopReadScan(); + Sleep( 100 ); // "time to stop" + scan2D.DisposeScan(); + hwControls.StopMotor(); + typedef itk::ImageFileWriter< ImageType > WriterType; WriterType::Pointer writer = WriterType::New(); writer->SetFileName( outputImage ); @@ -51,5 +64,5 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - return EXIT_SUCCESS; + return ret; } From 11c249c5bcc9d99691a7dd4dfab8a50b15150db0 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 7 Apr 2014 20:39:22 -0400 Subject: [PATCH 025/103] ENH: typedef NewBmodeImageCallback. --- include/IntersonCxxImagingScan2DClass.h | 5 +++++ src/IntersonCxxImagingScan2DClass.cxx | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 41d631b..a2b6490 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -34,6 +34,11 @@ class IntersonCxx_EXPORT Scan2DClass void DisposeScan(); void AbortScan(); + typedef void (__stdcall * NewBmodeImageCallbackType)( unsigned char * buffer, + void * clientData ); + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, + void * clientData = NULL ); + private: Scan2DClass( const Scan2DClass & ); void operator=( const Scan2DClass & ); diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 48dfcf5..78eea90 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -21,6 +21,8 @@ class Scan2DClassImpl public: typedef cli::array< byte, 2 > BmodeArrayType; + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + Scan2DClassImpl() { Wrapped = gcnew Interson::Imaging::Scan2DClass(); @@ -69,10 +71,20 @@ class Scan2DClassImpl Wrapped->AbortScan(); } + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = 0) + { + this->NewBmodeImageCallback = callback; + this->NewBmodeImageCallbackClientData = clientData; + } + private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; gcroot< BmodeArrayType ^ > BmodeBuffer; + + unsigned char * NativeBmodeBuffer; + NewBmodeImageCallbackType NewBmodeImageCallback; + void * NewBmodeImageCallbackClientData; }; @@ -83,9 +95,11 @@ ::Scan2DClass(): Impl( new Scan2DClassImpl() ), BmodeBuffer( new unsigned char[MAX_SAMPLES * MAX_VECTORS] ) { + //this->Impl->SetInterface( this ); } + Scan2DClass ::~Scan2DClass() { @@ -149,6 +163,15 @@ ::AbortScan() Impl->AbortScan(); } + +void +Scan2DClass +::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, + void * clientData ) +{ + Impl->SetNewBmodeImageCallback( callback, clientData ); +} + } // end namespace Imaging } // end namespace IntersonCxx From 73d46ffde2ba4fcac5890013853de2d0eb63826e Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 10:30:46 -0400 Subject: [PATCH 026/103] ENH: NewBmodeImageHandler --- src/IntersonCxxImagingScan2DClass.cxx | 87 ++++++++++++++++++++------- 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 78eea90..40dce09 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -8,7 +8,7 @@ #using "Interson.dll" // For StartReadScan -#using "System.Drawing.dll" +//#using "System.Drawing.dll" namespace IntersonCxx { @@ -16,6 +16,53 @@ namespace IntersonCxx namespace Imaging { +ref class NewBmodeImageHandler +{ +public: + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef cli::array< byte, 2 > BmodeArrayType; + + NewBmodeImageHandler( BmodeArrayType ^ managedBmodeBuffer ): + NewBmodeImageCallback( NULL ), + NewBmodeImageCallbackClientData( NULL ), + NativeBmodeBuffer( new unsigned char[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedBmodeBuffer( managedBmodeBuffer ) + { + } + + ~NewBmodeImageHandler() + { + delete [] NativeBmodeBuffer; + } + + void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) + { + if( this->NewBmodeImageCallback != NULL ) + { + for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) + { + this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = this->ManagedBmodeBuffer[ii, jj]; + } + } + this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); + } + } + + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData ) + { + this->NewBmodeImageCallback = callback; + this->NewBmodeImageCallbackClientData = clientData; + } + +private: + NewBmodeImageCallbackType NewBmodeImageCallback; + void * NewBmodeImageCallbackClientData; + unsigned char * NativeBmodeBuffer; + BmodeArrayType ^ ManagedBmodeBuffer; +}; + class Scan2DClassImpl { public: @@ -27,6 +74,12 @@ class Scan2DClassImpl { Wrapped = gcnew Interson::Imaging::Scan2DClass(); BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); + + BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); + Interson::Imaging::Scan2DClass::NewImageHandler ^ myHandler = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, + &NewBmodeImageHandler::HandleNewBmodeImage ); + Wrapped->NewImageTick += myHandler; } bool GetScanOn() @@ -44,16 +97,9 @@ class Scan2DClassImpl Wrapped->RFData = transferOn; } - void StartReadScan( unsigned char * buffer ) + void StartReadScan() { Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); - for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) - { - for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) - { - buffer[Scan2DClass::MAX_SAMPLES * ii + jj] = BmodeBuffer[ii, jj]; - } - } } void StopReadScan() @@ -71,20 +117,20 @@ class Scan2DClassImpl Wrapped->AbortScan(); } - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = 0) + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = 0 ) + { + this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); + } + + void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) { - this->NewBmodeImageCallback = callback; - this->NewBmodeImageCallbackClientData = clientData; } private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; + gcroot< BmodeArrayType ^ > BmodeBuffer; + gcroot< NewBmodeImageHandler ^ > BmodeHandler; - gcroot< BmodeArrayType ^ > BmodeBuffer; - - unsigned char * NativeBmodeBuffer; - NewBmodeImageCallbackType NewBmodeImageCallback; - void * NewBmodeImageCallbackClientData; }; @@ -92,10 +138,8 @@ class Scan2DClassImpl Scan2DClass ::Scan2DClass(): - Impl( new Scan2DClassImpl() ), - BmodeBuffer( new unsigned char[MAX_SAMPLES * MAX_VECTORS] ) + Impl( new Scan2DClassImpl() ) { - //this->Impl->SetInterface( this ); } @@ -104,7 +148,6 @@ Scan2DClass ::~Scan2DClass() { delete Impl; - delete [] BmodeBuffer; } @@ -136,7 +179,7 @@ void Scan2DClass ::StartReadScan() { - Impl->StartReadScan( BmodeBuffer ); + Impl->StartReadScan(); } From 5f06132b7824ccf9f01bc02fc0a7458bac2b6ec0 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 11:19:08 -0400 Subject: [PATCH 027/103] ENH: CLI callback. --- app/AcquireIntersonBMode.cxx | 28 +++++++++++++++++++--- src/IntersonCxxImagingScan2DClass.cxx | 14 ++++++----- test/IntersonCxxImagingScan2DClassTest.cxx | 1 - 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index d4ece71..4e0a68f 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -7,13 +7,27 @@ #include "AcquireIntersonBModeCLP.h" +const unsigned int Dimension = 3; +typedef unsigned char PixelType; +typedef itk::Image< PixelType, Dimension > ImageType; + +struct CallbackClientData +{ + ImageType * Image; + itk::SizeValueType FrameIndex; +}; + +void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) +{ + CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); + ++(callbackClientData->FrameIndex); + std::cout << "FrameIndex: " << callbackClientData->FrameIndex << std::endl; +} + int main( int argc, char * argv[] ) { PARSE_ARGS; - const unsigned int Dimension = 3; - typedef unsigned char PixelType; - typedef itk::Image< PixelType, Dimension > ImageType; typedef IntersonCxx::Controls::HWControls HWControlsType; IntersonCxx::Controls::HWControls hwControls; @@ -39,12 +53,20 @@ int main( int argc, char * argv[] ) int ret = EXIT_SUCCESS; + CallbackClientData clientData; + clientData.Image = NULL; + clientData.FrameIndex = 0; + + scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); + scan2D.AbortScan(); hwControls.StartMotor(); scan2D.StartReadScan(); Sleep( 100 ); // "time to start" hwControls.StartBmode(); + Sleep( 300 ); // "time to start" + hwControls.StopAcquisition(); scan2D.StopReadScan(); Sleep( 100 ); // "time to stop" diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 40dce09..3a8f641 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -1,6 +1,8 @@ #pragma unmanaged #include "IntersonCxxImagingScan2DClass.h" +#include + #pragma managed #include @@ -37,6 +39,7 @@ ref class NewBmodeImageHandler void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) { + std::cout << "calling callback!" << std::endl; if( this->NewBmodeImageCallback != NULL ) { for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) @@ -76,10 +79,12 @@ class Scan2DClassImpl BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); - Interson::Imaging::Scan2DClass::NewImageHandler ^ myHandler = gcnew + //Interson::Imaging::Scan2DClass::NewImageHandler ^ myHandler = gcnew + BmodeHandlerDelegate = gcnew Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, &NewBmodeImageHandler::HandleNewBmodeImage ); - Wrapped->NewImageTick += myHandler; + //Wrapped->NewImageTick += myHandler; + Wrapped->NewImageTick += BmodeHandlerDelegate; } bool GetScanOn() @@ -122,14 +127,11 @@ class Scan2DClassImpl this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); } - void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) - { - } - private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; gcroot< BmodeArrayType ^ > BmodeBuffer; gcroot< NewBmodeImageHandler ^ > BmodeHandler; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; }; diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index fdbbf88..a485488 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -7,7 +7,6 @@ #include // Sleep - int main( int argc, char * argv[] ) { IntersonCxx::Controls::HWControls hwControls; From 3ce565547c42950e3d56e1781e5b4fe3c859519e Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 12:19:52 -0400 Subject: [PATCH 028/103] ENH: Copy image buffer data in callback. --- app/AcquireIntersonBMode.cxx | 61 ++++++++++++++++++++++++--- app/CMakeLists.txt | 3 +- src/IntersonCxxImagingScan2DClass.cxx | 9 ++-- 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index 4e0a68f..a8a60ad 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -11,6 +11,8 @@ const unsigned int Dimension = 3; typedef unsigned char PixelType; typedef itk::Image< PixelType, Dimension > ImageType; +typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + struct CallbackClientData { ImageType * Image; @@ -20,6 +22,23 @@ struct CallbackClientData void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) { CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); + ImageType * image = callbackClientData->Image; + + const ImageType::RegionType & largestRegion = image->GetLargestPossibleRegion(); + const itk::SizeValueType imageFrames = largestRegion.GetSize()[2]; + if( callbackClientData->FrameIndex >= imageFrames ) + { + return; + } + + const int maxVectors = Scan2DClassType::MAX_VECTORS; + const int maxSamples = Scan2DClassType::MAX_SAMPLES; + const int framePixels = maxVectors * maxSamples; + + PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); + imageBuffer += framePixels * callbackClientData->FrameIndex; + std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); + ++(callbackClientData->FrameIndex); std::cout << "FrameIndex: " << callbackClientData->FrameIndex << std::endl; } @@ -32,7 +51,6 @@ int main( int argc, char * argv[] ) typedef IntersonCxx::Controls::HWControls HWControlsType; IntersonCxx::Controls::HWControls hwControls; - typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; Scan2DClassType scan2D; typedef HWControlsType::FoundProbesType FoundProbesType; @@ -53,19 +71,49 @@ int main( int argc, char * argv[] ) int ret = EXIT_SUCCESS; + // replace with command line option + const itk::SizeValueType framesToCollect = 1; + const int maxVectors = Scan2DClassType::MAX_VECTORS; + const int maxSamples = Scan2DClassType::MAX_SAMPLES; + + ImageType::Pointer image = ImageType::New(); + typedef ImageType::RegionType RegionType; + RegionType imageRegion; + ImageType::IndexType imageIndex; + imageIndex.Fill( 0 ); + imageRegion.SetIndex( imageIndex ); + ImageType::SizeType imageSize; + imageSize[0] = maxSamples; + imageSize[1] = maxVectors; + imageSize[2] = framesToCollect; + imageRegion.SetSize( imageSize ); + image->SetRegions( imageRegion ); + image->Allocate(); + + // TODO remove + image->FillBuffer( 7 ); + CallbackClientData clientData; - clientData.Image = NULL; + clientData.Image = image.GetPointer(); clientData.FrameIndex = 0; scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); scan2D.AbortScan(); - hwControls.StartMotor(); + if( !hwControls.StartMotor() ) + { + std::cerr << "Could not start motor." << std::endl; + return EXIT_FAILURE; + }; scan2D.StartReadScan(); Sleep( 100 ); // "time to start" - hwControls.StartBmode(); + if( !hwControls.StartBmode() ) + { + std::cerr << "Could not start B-mode collection." << std::endl; + return EXIT_FAILURE; + }; - Sleep( 300 ); // "time to start" + Sleep( 3000 ); hwControls.StopAcquisition(); scan2D.StopReadScan(); @@ -76,9 +124,10 @@ int main( int argc, char * argv[] ) typedef itk::ImageFileWriter< ImageType > WriterType; WriterType::Pointer writer = WriterType::New(); writer->SetFileName( outputImage ); + writer->SetInput( image ); try { - // writer->Update(); + writer->Update(); } catch( itk::ExceptionObject & error ) { diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 0ad386d..97a9672 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -13,8 +13,9 @@ SEMMacroBuildCLI( ) if( BUILD_TESTING ) + set( TEMP ${PROJECT_BINARY_DIR}/Testing/Temporary ) add_test( NAME AcquireIntersonBModeTest COMMAND $ - AcquireIntersonBModeTest.mha + ${TEMP}/AcquireIntersonBModeTest.mha ) endif() diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 3a8f641..aeb0069 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -49,8 +49,8 @@ ref class NewBmodeImageHandler this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = this->ManagedBmodeBuffer[ii, jj]; } } - this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); } + this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); } void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData ) @@ -79,14 +79,17 @@ class Scan2DClassImpl BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); - //Interson::Imaging::Scan2DClass::NewImageHandler ^ myHandler = gcnew BmodeHandlerDelegate = gcnew Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, &NewBmodeImageHandler::HandleNewBmodeImage ); - //Wrapped->NewImageTick += myHandler; Wrapped->NewImageTick += BmodeHandlerDelegate; } + ~Scan2DClassImpl() + { + Wrapped->NewImageTick -= BmodeHandlerDelegate; + } + bool GetScanOn() { return Wrapped->ScanOn; From 2b0f516ca0beba0ed4ffbcb8e332b2bc08aba28b Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 12:46:14 -0400 Subject: [PATCH 029/103] ENH: Set hardware settings before acquisition. Required for callback to be called??? --- app/AcquireIntersonBMode.cxx | 24 +++++++++++++++++++----- src/IntersonCxxImagingScan2DClass.cxx | 3 --- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index a8a60ad..26a2726 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -39,8 +39,8 @@ void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) imageBuffer += framePixels * callbackClientData->FrameIndex; std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); + std::cout << "Acquired frame: " << callbackClientData->FrameIndex << std::endl; ++(callbackClientData->FrameIndex); - std::cout << "FrameIndex: " << callbackClientData->FrameIndex << std::endl; } int main( int argc, char * argv[] ) @@ -90,15 +90,26 @@ int main( int argc, char * argv[] ) image->SetRegions( imageRegion ); image->Allocate(); - // TODO remove - image->FillBuffer( 7 ); - CallbackClientData clientData; clientData.Image = image.GetPointer(); clientData.FrameIndex = 0; scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency( frequencies ); + // TODO make CLI option + if( !hwControls.SetFrequency( frequencies[1] ) ) + { + std::cerr << "Could not set the frequency." << std::endl; + return EXIT_FAILURE; + } + // TODO make CLI option + hwControls.SendHighVoltage( 50 ); + hwControls.EnableHighVoltage(); + // TODO make CLI option + hwControls.SendDynamic( 50 ); + scan2D.AbortScan(); if( !hwControls.StartMotor() ) { @@ -113,7 +124,10 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; }; - Sleep( 3000 ); + while( clientData.FrameIndex < framesToCollect ) + { + Sleep( 100 ); + } hwControls.StopAcquisition(); scan2D.StopReadScan(); diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index aeb0069..4f6c4d6 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -1,8 +1,6 @@ #pragma unmanaged #include "IntersonCxxImagingScan2DClass.h" -#include - #pragma managed #include @@ -39,7 +37,6 @@ ref class NewBmodeImageHandler void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) { - std::cout << "calling callback!" << std::endl; if( this->NewBmodeImageCallback != NULL ) { for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) From 4f12555f1565ff2cf74ab4cb68e0d906053cb60c Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 12:56:45 -0400 Subject: [PATCH 030/103] ENH: Acquire multiple frames. --- app/AcquireIntersonBMode.cxx | 3 +-- app/AcquireIntersonBMode.xml | 7 +++++++ app/CMakeLists.txt | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index 26a2726..d1b8dd8 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -71,8 +71,7 @@ int main( int argc, char * argv[] ) int ret = EXIT_SUCCESS; - // replace with command line option - const itk::SizeValueType framesToCollect = 1; + const itk::SizeValueType framesToCollect = frames; const int maxVectors = Scan2DClassType::MAX_VECTORS; const int maxSamples = Scan2DClassType::MAX_SAMPLES; diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml index 5b0e76a..8827994 100644 --- a/app/AcquireIntersonBMode.xml +++ b/app/AcquireIntersonBMode.xml @@ -15,5 +15,12 @@ 0 Output image filename. + + frames + + Frames to collect. + frames + f + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 97a9672..fc065c5 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -14,8 +14,14 @@ SEMMacroBuildCLI( if( BUILD_TESTING ) set( TEMP ${PROJECT_BINARY_DIR}/Testing/Temporary ) + add_test( NAME AcquireIntersonBModeTest COMMAND $ ${TEMP}/AcquireIntersonBModeTest.mha - ) + ) + add_test( NAME AcquireIntersonBModeTest1 + COMMAND $ + --frames 5 + ${TEMP}/AcquireIntersonBModeTest1.mha + ) endif() From fdc2c2b039cb890a3fff0de6441f9ac0d4a5e72b Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 12:59:24 -0400 Subject: [PATCH 031/103] ENH: AcquireIntersonRF skeleton. --- app/AcquireIntersonRF.cxx | 152 ++++++++++++++++++++++++++++++++++++++ app/AcquireIntersonRF.xml | 26 +++++++ app/CMakeLists.txt | 8 ++ 3 files changed, 186 insertions(+) create mode 100644 app/AcquireIntersonRF.cxx create mode 100644 app/AcquireIntersonRF.xml diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx new file mode 100644 index 0000000..d1b8dd8 --- /dev/null +++ b/app/AcquireIntersonRF.cxx @@ -0,0 +1,152 @@ +#include // Sleep + +#include "itkImageFileWriter.h" + +#include "IntersonCxxImagingScan2DClass.h" +#include "IntersonCxxControlsHWControls.h" + +#include "AcquireIntersonBModeCLP.h" + +const unsigned int Dimension = 3; +typedef unsigned char PixelType; +typedef itk::Image< PixelType, Dimension > ImageType; + +typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + +struct CallbackClientData +{ + ImageType * Image; + itk::SizeValueType FrameIndex; +}; + +void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) +{ + CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); + ImageType * image = callbackClientData->Image; + + const ImageType::RegionType & largestRegion = image->GetLargestPossibleRegion(); + const itk::SizeValueType imageFrames = largestRegion.GetSize()[2]; + if( callbackClientData->FrameIndex >= imageFrames ) + { + return; + } + + const int maxVectors = Scan2DClassType::MAX_VECTORS; + const int maxSamples = Scan2DClassType::MAX_SAMPLES; + const int framePixels = maxVectors * maxSamples; + + PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); + imageBuffer += framePixels * callbackClientData->FrameIndex; + std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); + + std::cout << "Acquired frame: " << callbackClientData->FrameIndex << std::endl; + ++(callbackClientData->FrameIndex); +} + +int main( int argc, char * argv[] ) +{ + PARSE_ARGS; + + + typedef IntersonCxx::Controls::HWControls HWControlsType; + IntersonCxx::Controls::HWControls hwControls; + + Scan2DClassType scan2D; + + typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + int ret = EXIT_SUCCESS; + + const itk::SizeValueType framesToCollect = frames; + const int maxVectors = Scan2DClassType::MAX_VECTORS; + const int maxSamples = Scan2DClassType::MAX_SAMPLES; + + ImageType::Pointer image = ImageType::New(); + typedef ImageType::RegionType RegionType; + RegionType imageRegion; + ImageType::IndexType imageIndex; + imageIndex.Fill( 0 ); + imageRegion.SetIndex( imageIndex ); + ImageType::SizeType imageSize; + imageSize[0] = maxSamples; + imageSize[1] = maxVectors; + imageSize[2] = framesToCollect; + imageRegion.SetSize( imageSize ); + image->SetRegions( imageRegion ); + image->Allocate(); + + CallbackClientData clientData; + clientData.Image = image.GetPointer(); + clientData.FrameIndex = 0; + + scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); + + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency( frequencies ); + // TODO make CLI option + if( !hwControls.SetFrequency( frequencies[1] ) ) + { + std::cerr << "Could not set the frequency." << std::endl; + return EXIT_FAILURE; + } + // TODO make CLI option + hwControls.SendHighVoltage( 50 ); + hwControls.EnableHighVoltage(); + // TODO make CLI option + hwControls.SendDynamic( 50 ); + + scan2D.AbortScan(); + if( !hwControls.StartMotor() ) + { + std::cerr << "Could not start motor." << std::endl; + return EXIT_FAILURE; + }; + scan2D.StartReadScan(); + Sleep( 100 ); // "time to start" + if( !hwControls.StartBmode() ) + { + std::cerr << "Could not start B-mode collection." << std::endl; + return EXIT_FAILURE; + }; + + while( clientData.FrameIndex < framesToCollect ) + { + Sleep( 100 ); + } + + hwControls.StopAcquisition(); + scan2D.StopReadScan(); + Sleep( 100 ); // "time to stop" + scan2D.DisposeScan(); + hwControls.StopMotor(); + + typedef itk::ImageFileWriter< ImageType > WriterType; + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName( outputImage ); + writer->SetInput( image ); + try + { + writer->Update(); + } + catch( itk::ExceptionObject & error ) + { + std::cerr << "Error: " << error << std::endl; + return EXIT_FAILURE; + } + + return ret; +} diff --git a/app/AcquireIntersonRF.xml b/app/AcquireIntersonRF.xml new file mode 100644 index 0000000..5296a6d --- /dev/null +++ b/app/AcquireIntersonRF.xml @@ -0,0 +1,26 @@ + + + Ultrasound + Acquire Interson RF + Acquire multiple RF frames with the Interson USB probe. + 0.1.0 + Apache 2.0 + Matt McCormick (Kitware) + This work is funded in part by a grant with InnerOptic/Kitware + + + outputImage + + output + 0 + Output image filename. + + + frames + + Frames to collect. + frames + f + + + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index fc065c5..5a7ee25 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -12,6 +12,14 @@ SEMMacroBuildCLI( ${PROJECT_BINARY_DIR}/include ) +SEMMacroBuildCLI( + NAME AcquireIntersonRF + TARGET_LIBRARIES ${ITK_LIBRARIES} + IntersonCxx + INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ) + if( BUILD_TESTING ) set( TEMP ${PROJECT_BINARY_DIR}/Testing/Temporary ) From 66feb2f450f3e7c6305ab31195ef9a2c33c916b3 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 13:24:12 -0400 Subject: [PATCH 032/103] ENH: StartRFReadScan, RF callback. --- app/AcquireIntersonRF.cxx | 7 +- include/IntersonCxxImagingScan2DClass.h | 13 ++- src/IntersonCxxImagingScan2DClass.cxx | 108 ++++++++++++++++++++++-- 3 files changed, 113 insertions(+), 15 deletions(-) diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx index d1b8dd8..ddd5270 100644 --- a/app/AcquireIntersonRF.cxx +++ b/app/AcquireIntersonRF.cxx @@ -8,7 +8,7 @@ #include "AcquireIntersonBModeCLP.h" const unsigned int Dimension = 3; -typedef unsigned char PixelType; +typedef unsigned short PixelType; typedef itk::Image< PixelType, Dimension > ImageType; typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; @@ -93,7 +93,7 @@ int main( int argc, char * argv[] ) clientData.Image = image.GetPointer(); clientData.FrameIndex = 0; - scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); + scan2D.SetNewRFImageCallback( &pasteIntoImage, &clientData ); HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); @@ -110,12 +110,13 @@ int main( int argc, char * argv[] ) hwControls.SendDynamic( 50 ); scan2D.AbortScan(); + scan2D.SetRFData( true ); if( !hwControls.StartMotor() ) { std::cerr << "Could not start motor." << std::endl; return EXIT_FAILURE; }; - scan2D.StartReadScan(); + scan2D.StartRFReadScan(); Sleep( 100 ); // "time to start" if( !hwControls.StartBmode() ) { diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index a2b6490..fa00675 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -24,28 +24,35 @@ class IntersonCxx_EXPORT Scan2DClass static const int MAX_RFSAMPLES = 2048; static const int MAX_VECTORS = 241; + typedef unsigned char BmodePixelType; + typedef unsigned short RFPixelType; + bool GetScanOn() const; bool GetRFData() const; void SetRFData( bool transferOn ); void StartReadScan(); + void StartRFReadScan(); void StopReadScan(); void DisposeScan(); void AbortScan(); - typedef void (__stdcall * NewBmodeImageCallbackType)( unsigned char * buffer, + typedef void (__stdcall * NewBmodeImageCallbackType)( BmodePixelType * buffer, void * clientData ); void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = NULL ); + typedef void (__stdcall * NewRFImageCallbackType)( RFPixelType * buffer, + void * clientData ); + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void * clientData = NULL ); + private: Scan2DClass( const Scan2DClass & ); void operator=( const Scan2DClass & ); Scan2DClassImpl * Impl; - - unsigned char * BmodeBuffer; }; } // end namespace Imaging diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 4f6c4d6..ca920bc 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -16,16 +16,66 @@ namespace IntersonCxx namespace Imaging { +ref class NewRFImageHandler +{ +public: + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; + typedef cli::array< unsigned short, 2 > RFArrayType; + + NewRFImageHandler( RFArrayType ^ managedRFBuffer ): + NewRFImageCallback( NULL ), + NewRFImageCallbackClientData( NULL ), + NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedRFBuffer( managedRFBuffer ) + { + } + + ~NewRFImageHandler() + { + delete [] NativeRFBuffer; + } + + void HandleNewRFImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) + { + if( this->NewRFImageCallback != NULL ) + { + for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) + { + this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; + } + } + this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); + } + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData ) + { + this->NewRFImageCallback = callback; + this->NewRFImageCallbackClientData = clientData; + } + +private: + NewRFImageCallbackType NewRFImageCallback; + void * NewRFImageCallbackClientData; + RFPixelType * NativeRFBuffer; + RFArrayType ^ ManagedRFBuffer; +}; + + ref class NewBmodeImageHandler { public: - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef cli::array< byte, 2 > BmodeArrayType; + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; + typedef cli::array< byte, 2 > BmodeArrayType; NewBmodeImageHandler( BmodeArrayType ^ managedBmodeBuffer ): NewBmodeImageCallback( NULL ), NewBmodeImageCallbackClientData( NULL ), - NativeBmodeBuffer( new unsigned char[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), + NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), ManagedBmodeBuffer( managedBmodeBuffer ) { } @@ -46,8 +96,8 @@ ref class NewBmodeImageHandler this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = this->ManagedBmodeBuffer[ii, jj]; } } - } this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); + } } void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData ) @@ -59,32 +109,43 @@ ref class NewBmodeImageHandler private: NewBmodeImageCallbackType NewBmodeImageCallback; void * NewBmodeImageCallbackClientData; - unsigned char * NativeBmodeBuffer; + BmodePixelType * NativeBmodeBuffer; BmodeArrayType ^ ManagedBmodeBuffer; }; + class Scan2DClassImpl { public: - typedef cli::array< byte, 2 > BmodeArrayType; + typedef cli::array< byte, 2 > BmodeArrayType; + typedef cli::array< unsigned short, 2 > RFArrayType; typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; Scan2DClassImpl() { Wrapped = gcnew Interson::Imaging::Scan2DClass(); BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); + RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); BmodeHandlerDelegate = gcnew Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, &NewBmodeImageHandler::HandleNewBmodeImage ); Wrapped->NewImageTick += BmodeHandlerDelegate; + + RFHandler = gcnew NewRFImageHandler( RFBuffer ); + RFHandlerDelegate = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, + &NewRFImageHandler::HandleNewRFImage ); + Wrapped->NewImageTick += RFHandlerDelegate; } ~Scan2DClassImpl() { Wrapped->NewImageTick -= BmodeHandlerDelegate; + Wrapped->NewImageTick -= RFHandlerDelegate; } bool GetScanOn() @@ -107,6 +168,11 @@ class Scan2DClassImpl Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); } + void StartRFReadScan() + { + Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); + } + void StopReadScan() { Wrapped->StopReadScan(); @@ -127,11 +193,19 @@ class Scan2DClassImpl this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); } + void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData = 0 ) + { + this->RFHandler->SetNewRFImageCallback( callback, clientData ); + } + private: - gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; - gcroot< BmodeArrayType ^ > BmodeBuffer; - gcroot< NewBmodeImageHandler ^ > BmodeHandler; + gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; + gcroot< BmodeArrayType ^ > BmodeBuffer; + gcroot< RFArrayType ^ > RFBuffer; + gcroot< NewBmodeImageHandler ^ > BmodeHandler; + gcroot< NewRFImageHandler ^ > RFHandler; gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; }; @@ -185,6 +259,14 @@ ::StartReadScan() } +void +Scan2DClass +::StartRFReadScan() +{ + Impl->StartRFReadScan(); +} + + void Scan2DClass ::StopReadScan() @@ -217,6 +299,14 @@ ::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, Impl->SetNewBmodeImageCallback( callback, clientData ); } +void +Scan2DClass +::SetNewRFImageCallback( NewRFImageCallbackType callback, + void * clientData ) +{ + Impl->SetNewRFImageCallback( callback, clientData ); +} + } // end namespace Imaging } // end namespace IntersonCxx From 58c0eeb4634c2b93a4ba7507b49a091b4f193741 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 13:40:27 -0400 Subject: [PATCH 033/103] ENH: RF data tests. --- app/AcquireIntersonBMode.xml | 1 + app/AcquireIntersonRF.cxx | 15 +++++++++------ app/AcquireIntersonRF.xml | 1 + app/CMakeLists.txt | 10 ++++++++++ include/IntersonCxxImagingScan2DClass.h | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml index 8827994..16a63d3 100644 --- a/app/AcquireIntersonBMode.xml +++ b/app/AcquireIntersonBMode.xml @@ -21,6 +21,7 @@ Frames to collect. frames f + 1 diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx index ddd5270..2f04737 100644 --- a/app/AcquireIntersonRF.cxx +++ b/app/AcquireIntersonRF.cxx @@ -7,11 +7,12 @@ #include "AcquireIntersonBModeCLP.h" +typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + const unsigned int Dimension = 3; -typedef unsigned short PixelType; +typedef Scan2DClassType::RFPixelType PixelType; typedef itk::Image< PixelType, Dimension > ImageType; -typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; struct CallbackClientData { @@ -32,7 +33,7 @@ void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) } const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_SAMPLES; + const int maxSamples = Scan2DClassType::MAX_RFSAMPLES; const int framePixels = maxVectors * maxSamples; PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); @@ -73,7 +74,7 @@ int main( int argc, char * argv[] ) const itk::SizeValueType framesToCollect = frames; const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_SAMPLES; + const int maxSamples = Scan2DClassType::MAX_RFSAMPLES; ImageType::Pointer image = ImageType::New(); typedef ImageType::RegionType RegionType; @@ -108,6 +109,8 @@ int main( int argc, char * argv[] ) hwControls.EnableHighVoltage(); // TODO make CLI option hwControls.SendDynamic( 50 ); + // TODO make CLI option + hwControls.DisableRFDecimator(); scan2D.AbortScan(); scan2D.SetRFData( true ); @@ -118,9 +121,9 @@ int main( int argc, char * argv[] ) }; scan2D.StartRFReadScan(); Sleep( 100 ); // "time to start" - if( !hwControls.StartBmode() ) + if( !hwControls.StartRFmode() ) { - std::cerr << "Could not start B-mode collection." << std::endl; + std::cerr << "Could not start RF collection." << std::endl; return EXIT_FAILURE; }; diff --git a/app/AcquireIntersonRF.xml b/app/AcquireIntersonRF.xml index 5296a6d..998bc14 100644 --- a/app/AcquireIntersonRF.xml +++ b/app/AcquireIntersonRF.xml @@ -21,6 +21,7 @@ Frames to collect. frames f + 1 diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 5a7ee25..0d70c77 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -32,4 +32,14 @@ if( BUILD_TESTING ) --frames 5 ${TEMP}/AcquireIntersonBModeTest1.mha ) + + add_test( NAME AcquireIntersonRFTest + COMMAND $ + ${TEMP}/AcquireIntersonRFTest.mha + ) + add_test( NAME AcquireIntersonRFTest1 + COMMAND $ + --frames 5 + ${TEMP}/AcquireIntersonRFTest1.mha + ) endif() diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index fa00675..7306bd7 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -25,7 +25,7 @@ class IntersonCxx_EXPORT Scan2DClass static const int MAX_VECTORS = 241; typedef unsigned char BmodePixelType; - typedef unsigned short RFPixelType; + typedef short RFPixelType; bool GetScanOn() const; From f8bdcc341888fd1279e0dd5a82561ff7dbb4c21a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 17:02:17 -0400 Subject: [PATCH 034/103] ENH: Start PrintIntersonProbeInfo. --- app/AcquireIntersonRF.cxx | 2 +- app/CMakeLists.txt | 11 ++++ app/PrintIntersonProbeInfo.cxx | 99 ++++++++++++++++++++++++++++++++++ app/PrintIntersonProbeInfo.xml | 20 +++++++ 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 app/PrintIntersonProbeInfo.cxx create mode 100644 app/PrintIntersonProbeInfo.xml diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx index 2f04737..6da3084 100644 --- a/app/AcquireIntersonRF.cxx +++ b/app/AcquireIntersonRF.cxx @@ -5,7 +5,7 @@ #include "IntersonCxxImagingScan2DClass.h" #include "IntersonCxxControlsHWControls.h" -#include "AcquireIntersonBModeCLP.h" +#include "AcquireIntersonRFCLP.h" typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 0d70c77..17b9fa7 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -20,6 +20,13 @@ SEMMacroBuildCLI( ${PROJECT_BINARY_DIR}/include ) +SEMMacroBuildCLI( + NAME PrintIntersonProbeInfo + TARGET_LIBRARIES IntersonCxx + INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ) + if( BUILD_TESTING ) set( TEMP ${PROJECT_BINARY_DIR}/Testing/Temporary ) @@ -42,4 +49,8 @@ if( BUILD_TESTING ) --frames 5 ${TEMP}/AcquireIntersonRFTest1.mha ) + + add_test( NAME PrintIntersonProbeInfoTest + COMMAND $ + ) endif() diff --git a/app/PrintIntersonProbeInfo.cxx b/app/PrintIntersonProbeInfo.cxx new file mode 100644 index 0000000..0786805 --- /dev/null +++ b/app/PrintIntersonProbeInfo.cxx @@ -0,0 +1,99 @@ +#include "IntersonCxxImagingScan2DClass.h" +#include "IntersonCxxControlsHWControls.h" + +#include "PrintIntersonProbeInfoCLP.h" + +int main( int argc, char * argv[] ) +{ + PARSE_ARGS; + + typedef IntersonCxx::Controls::HWControls HWControlsType; + IntersonCxx::Controls::HWControls hwControls; + + typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + Scan2DClassType scan2D; + + typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + std::cout << "\nFound Probes: " << std::endl; + for( size_t ii = 0; ii < foundProbes.size(); ++ii ) + { + std::cout << " " << ii << ": " << foundProbes[ii] << std::endl; + } + if( probeIndex < 0 || probeIndex >= foundProbes.size() ) + { + std::cerr << "Invalid probe index." << std::endl; + return EXIT_FAILURE; + } + hwControls.FindMyProbe( probeIndex ); + const unsigned int probeId = hwControls.GetProbeID(); + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency( frequencies ); + // TODO make CLI option + std::cout << "\nFrequencies: [Hz]" << std::endl; + for( size_t ii = 0; ii < frequencies.size(); ++ii ) + { + std::cout << " " << ii << ": " << frequencies[ii] << std::endl; + } + /* + // TODO make CLI option + hwControls.SendHighVoltage( 50 ); + hwControls.EnableHighVoltage(); + // TODO make CLI option + hwControls.SendDynamic( 50 ); + + scan2D.AbortScan(); + if( !hwControls.StartMotor() ) + { + std::cerr << "Could not start motor." << std::endl; + return EXIT_FAILURE; + }; + scan2D.StartReadScan(); + Sleep( 100 ); // "time to start" + if( !hwControls.StartBmode() ) + { + std::cerr << "Could not start B-mode collection." << std::endl; + return EXIT_FAILURE; + }; + + while( clientData.FrameIndex < framesToCollect ) + { + Sleep( 100 ); + } + + hwControls.StopAcquisition(); + scan2D.StopReadScan(); + Sleep( 100 ); // "time to stop" + scan2D.DisposeScan(); + hwControls.StopMotor(); + + typedef itk::ImageFileWriter< ImageType > WriterType; + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName( outputImage ); + writer->SetInput( image ); + try + { + writer->Update(); + } + catch( itk::ExceptionObject & error ) + { + std::cerr << "Error: " << error << std::endl; + return EXIT_FAILURE; + } + + */ + return EXIT_SUCCESS; +} diff --git a/app/PrintIntersonProbeInfo.xml b/app/PrintIntersonProbeInfo.xml new file mode 100644 index 0000000..5f8db7e --- /dev/null +++ b/app/PrintIntersonProbeInfo.xml @@ -0,0 +1,20 @@ + + + Ultrasound + Print Interson Probe Info + Print properties of the connected Interson USB probe. + 0.1.0 + Apache 2.0 + Matt McCormick (Kitware) + This work is funded in part by a grant with InnerOptic/Kitware + + + probeIndex + + Index of the probe to examine. + probeIndex + i + 0 + + + From 329de6b22228bc040317c5a27967015a7a862ed9 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 21:36:06 -0400 Subject: [PATCH 035/103] ENH: frequencyIndex flag. --- app/AcquireIntersonBMode.cxx | 10 ++++++---- app/AcquireIntersonBMode.xml | 8 ++++++++ app/AcquireIntersonRF.cxx | 4 ++-- app/AcquireIntersonRF.xml | 8 ++++++++ app/CMakeLists.txt | 8 ++++---- app/PrintIntersonProbeInfo.cxx | 2 +- src/IntersonCxxImagingScan2DClass.cxx | 8 +++++--- 7 files changed, 34 insertions(+), 14 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index d1b8dd8..70d4e95 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -7,11 +7,12 @@ #include "AcquireIntersonBModeCLP.h" +typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + const unsigned int Dimension = 3; -typedef unsigned char PixelType; +typedef Scan2DClassType::BmodePixelType PixelType; typedef itk::Image< PixelType, Dimension > ImageType; -typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; struct CallbackClientData { @@ -97,8 +98,7 @@ int main( int argc, char * argv[] ) HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); - // TODO make CLI option - if( !hwControls.SetFrequency( frequencies[1] ) ) + if( !hwControls.SetFrequency( frequencies[frequencyIndex] ) ) { std::cerr << "Could not set the frequency." << std::endl; return EXIT_FAILURE; @@ -108,8 +108,10 @@ int main( int argc, char * argv[] ) hwControls.EnableHighVoltage(); // TODO make CLI option hwControls.SendDynamic( 50 ); + hwControls.DisableHardButton(); scan2D.AbortScan(); + scan2D.SetRFData( false ); if( !hwControls.StartMotor() ) { std::cerr << "Could not start motor." << std::endl; diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml index 16a63d3..5c28682 100644 --- a/app/AcquireIntersonBMode.xml +++ b/app/AcquireIntersonBMode.xml @@ -20,6 +20,14 @@ Frames to collect. frames + n + 1 + + + frequencyIndex + + Index of the frequency to examine. See the output of PrintIntersonProbeInfo. + frequencyIndex f 1 diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx index 6da3084..bcff0fa 100644 --- a/app/AcquireIntersonRF.cxx +++ b/app/AcquireIntersonRF.cxx @@ -98,8 +98,7 @@ int main( int argc, char * argv[] ) HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); - // TODO make CLI option - if( !hwControls.SetFrequency( frequencies[1] ) ) + if( !hwControls.SetFrequency( frequencies[frequencyIndex] ) ) { std::cerr << "Could not set the frequency." << std::endl; return EXIT_FAILURE; @@ -111,6 +110,7 @@ int main( int argc, char * argv[] ) hwControls.SendDynamic( 50 ); // TODO make CLI option hwControls.DisableRFDecimator(); + hwControls.DisableHardButton(); scan2D.AbortScan(); scan2D.SetRFData( true ); diff --git a/app/AcquireIntersonRF.xml b/app/AcquireIntersonRF.xml index 998bc14..babbab9 100644 --- a/app/AcquireIntersonRF.xml +++ b/app/AcquireIntersonRF.xml @@ -20,6 +20,14 @@ Frames to collect. frames + n + 1 + + + frequencyIndex + + Index of the frequency to examine. See the output of PrintIntersonProbeInfo. + frequencyIndex f 1 diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 17b9fa7..4ae47ec 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -34,20 +34,20 @@ if( BUILD_TESTING ) COMMAND $ ${TEMP}/AcquireIntersonBModeTest.mha ) - add_test( NAME AcquireIntersonBModeTest1 + add_test( NAME AcquireIntersonBModeTestFrames COMMAND $ --frames 5 - ${TEMP}/AcquireIntersonBModeTest1.mha + ${TEMP}/AcquireIntersonBModeTestFrames.mha ) add_test( NAME AcquireIntersonRFTest COMMAND $ ${TEMP}/AcquireIntersonRFTest.mha ) - add_test( NAME AcquireIntersonRFTest1 + add_test( NAME AcquireIntersonRFTestFrames COMMAND $ --frames 5 - ${TEMP}/AcquireIntersonRFTest1.mha + ${TEMP}/AcquireIntersonRFTestFrames.mha ) add_test( NAME PrintIntersonProbeInfoTest diff --git a/app/PrintIntersonProbeInfo.cxx b/app/PrintIntersonProbeInfo.cxx index 0786805..43f65c7 100644 --- a/app/PrintIntersonProbeInfo.cxx +++ b/app/PrintIntersonProbeInfo.cxx @@ -21,7 +21,7 @@ int main( int argc, char * argv[] ) std::cerr << "Could not find the probe." << std::endl; return EXIT_FAILURE; } - std::cout << "\nFound Probes: " << std::endl; + std::cout << "\nProbes Found: " << std::endl; for( size_t ii = 0; ii < foundProbes.size(); ++ii ) { std::cout << " " << ii << ": " << foundProbes[ii] << std::endl; diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index ca920bc..384c124 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -126,15 +126,16 @@ class Scan2DClassImpl Scan2DClassImpl() { Wrapped = gcnew Interson::Imaging::Scan2DClass(); - BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); - RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); + + BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); BmodeHandlerDelegate = gcnew Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, &NewBmodeImageHandler::HandleNewBmodeImage ); Wrapped->NewImageTick += BmodeHandlerDelegate; + RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); RFHandler = gcnew NewRFImageHandler( RFBuffer ); RFHandlerDelegate = gcnew Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, @@ -144,8 +145,8 @@ class Scan2DClassImpl ~Scan2DClassImpl() { - Wrapped->NewImageTick -= BmodeHandlerDelegate; Wrapped->NewImageTick -= RFHandlerDelegate; + Wrapped->NewImageTick -= BmodeHandlerDelegate; } bool GetScanOn() @@ -200,6 +201,7 @@ class Scan2DClassImpl private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; + gcroot< BmodeArrayType ^ > BmodeBuffer; gcroot< RFArrayType ^ > RFBuffer; gcroot< NewBmodeImageHandler ^ > BmodeHandler; From 85f2852ba238c487d1fc6789f4d4de091e28f3e5 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 21:47:38 -0400 Subject: [PATCH 036/103] ENH: Set/Get FrameAvg. --- include/IntersonCxxImagingScan2DClass.h | 3 +++ src/IntersonCxxImagingScan2DClass.cxx | 25 ++++++++++++++++++++++ test/IntersonCxxImagingScan2DClassTest.cxx | 3 +++ 3 files changed, 31 insertions(+) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 7306bd7..0d8bfb0 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -32,6 +32,9 @@ class IntersonCxx_EXPORT Scan2DClass bool GetRFData() const; void SetRFData( bool transferOn ); + bool GetFrameAvg() const; + void SetFrameAvg( bool doAveraging ); + void StartReadScan(); void StartRFReadScan(); void StopReadScan(); diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 384c124..5a32671 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -164,6 +164,16 @@ class Scan2DClassImpl Wrapped->RFData = transferOn; } + bool GetFrameAvg() + { + return Wrapped->FrameAvg; + } + + void SetFrameAvg( bool doAveraging ) + { + return Wrapped->FrameAvg = doAveraging; + } + void StartReadScan() { Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); @@ -253,6 +263,21 @@ ::SetRFData( bool transferOn ) } +bool +Scan2DClass +::GetFrameAvg() const +{ + return Impl->GetFrameAvg(); +} + +void +Scan2DClass +::SetFrameAvg( bool doAveraging ) +{ + Impl->SetFrameAvg( doAveraging ); +} + + void Scan2DClass ::StartReadScan() diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index a485488..abd145d 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -39,6 +39,9 @@ int main( int argc, char * argv[] ) const int maxSamples = Scan2DClassType::MAX_SAMPLES; const int maxPixels = maxVectors * maxSamples; + scan2D.SetFrameAvg( true ); + std::cout << "\nFrameAvg: " << scan2D.GetFrameAvg() << std::endl; + scan2D.AbortScan(); hwControls.StartMotor(); std::cout << "\nStarting BMode scanning..." << std::endl; From ef61c2883110fced40e82b0a447b64c783b45044 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 8 Apr 2014 21:58:58 -0400 Subject: [PATCH 037/103] ENH: GetTrueDepth. --- include/IntersonCxxImagingScan2DClass.h | 2 ++ src/IntersonCxxImagingScan2DClass.cxx | 14 ++++++++++++++ test/IntersonCxxImagingScan2DClassTest.cxx | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 0d8bfb0..1d64bb1 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -35,6 +35,8 @@ class IntersonCxx_EXPORT Scan2DClass bool GetFrameAvg() const; void SetFrameAvg( bool doAveraging ); + double GetTrueDepth() const; + void StartReadScan(); void StartRFReadScan(); void StopReadScan(); diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 5a32671..4909946 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -174,6 +174,11 @@ class Scan2DClassImpl return Wrapped->FrameAvg = doAveraging; } + double GetTrueDepth() + { + return Wrapped->TrueDepth; + } + void StartReadScan() { Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); @@ -209,6 +214,7 @@ class Scan2DClassImpl this->RFHandler->SetNewRFImageCallback( callback, clientData ); } + private: gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; @@ -334,6 +340,14 @@ ::SetNewRFImageCallback( NewRFImageCallbackType callback, Impl->SetNewRFImageCallback( callback, clientData ); } + +double +Scan2DClass +::GetTrueDepth() const +{ + return Impl->GetTrueDepth(); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index abd145d..0ed3a1e 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -48,7 +48,9 @@ int main( int argc, char * argv[] ) scan2D.StartReadScan(); Sleep( 100 ); // "time to start" hwControls.StartBmode(); - std::cout << "Scan is on: " << scan2D.GetScanOn() << std::endl; + std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; + + std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; hwControls.StopAcquisition(); scan2D.StopReadScan(); From 313c8259b657f1e85a799da99d2a542711077760 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 11:09:57 -0400 Subject: [PATCH 038/103] ENH: App set voltage. --- app/AcquireIntersonBMode.cxx | 15 ++++++++++++--- app/AcquireIntersonBMode.xml | 8 ++++++++ app/AcquireIntersonRF.cxx | 13 ++++++++++--- app/AcquireIntersonRF.xml | 8 ++++++++ app/CMakeLists.txt | 10 ++++++++++ app/PrintIntersonProbeInfo.cxx | 4 +--- 6 files changed, 49 insertions(+), 9 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index 70d4e95..9db6426 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -103,9 +103,18 @@ int main( int argc, char * argv[] ) std::cerr << "Could not set the frequency." << std::endl; return EXIT_FAILURE; } - // TODO make CLI option - hwControls.SendHighVoltage( 50 ); - hwControls.EnableHighVoltage(); + + if( !hwControls.SendHighVoltage( highVoltage ) ) + { + std::cerr << "Could not set the high voltage." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.EnableHighVoltage() ) + { + std::cerr << "Could not enable high voltage." << std::endl; + return EXIT_FAILURE; + } + // TODO make CLI option hwControls.SendDynamic( 50 ); hwControls.DisableHardButton(); diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml index 5c28682..a8f8be2 100644 --- a/app/AcquireIntersonBMode.xml +++ b/app/AcquireIntersonBMode.xml @@ -31,5 +31,13 @@ f 1 + + highVoltage + + Percentage of the high voltage for transducer excitation. + highVoltage + z + 50 + diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx index bcff0fa..7064bad 100644 --- a/app/AcquireIntersonRF.cxx +++ b/app/AcquireIntersonRF.cxx @@ -103,9 +103,16 @@ int main( int argc, char * argv[] ) std::cerr << "Could not set the frequency." << std::endl; return EXIT_FAILURE; } - // TODO make CLI option - hwControls.SendHighVoltage( 50 ); - hwControls.EnableHighVoltage(); + if( !hwControls.SendHighVoltage( highVoltage ) ) + { + std::cerr << "Could not set the high voltage." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.EnableHighVoltage() ) + { + std::cerr << "Could not enable high voltage." << std::endl; + return EXIT_FAILURE; + } // TODO make CLI option hwControls.SendDynamic( 50 ); // TODO make CLI option diff --git a/app/AcquireIntersonRF.xml b/app/AcquireIntersonRF.xml index babbab9..d16ab80 100644 --- a/app/AcquireIntersonRF.xml +++ b/app/AcquireIntersonRF.xml @@ -31,5 +31,13 @@ f 1 + + highVoltage + + Percentage of the high voltage for transducer excitation. + highVoltage + z + 50 + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 4ae47ec..018991f 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -39,6 +39,11 @@ if( BUILD_TESTING ) --frames 5 ${TEMP}/AcquireIntersonBModeTestFrames.mha ) + add_test( NAME AcquireIntersonBModeTestVoltage + COMMAND $ + --highVoltage 30 + ${TEMP}/AcquireIntersonBModeTestTestVoltage.mha + ) add_test( NAME AcquireIntersonRFTest COMMAND $ @@ -49,6 +54,11 @@ if( BUILD_TESTING ) --frames 5 ${TEMP}/AcquireIntersonRFTestFrames.mha ) + add_test( NAME AcquireIntersonRFTestVoltage + COMMAND $ + --highVoltage 30 + ${TEMP}/AcquireIntersonRFTestVoltage.mha + ) add_test( NAME PrintIntersonProbeInfoTest COMMAND $ diff --git a/app/PrintIntersonProbeInfo.cxx b/app/PrintIntersonProbeInfo.cxx index 43f65c7..86361c2 100644 --- a/app/PrintIntersonProbeInfo.cxx +++ b/app/PrintIntersonProbeInfo.cxx @@ -48,11 +48,9 @@ int main( int argc, char * argv[] ) { std::cout << " " << ii << ": " << frequencies[ii] << std::endl; } + /* // TODO make CLI option - hwControls.SendHighVoltage( 50 ); - hwControls.EnableHighVoltage(); - // TODO make CLI option hwControls.SendDynamic( 50 ); scan2D.AbortScan(); From 0c70301763f1696f7055495d801f2e63bf0cdd2e Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 13:33:11 -0400 Subject: [PATCH 039/103] ENH: Control "Dynamic" gain in BMode app. --- app/AcquireIntersonBMode.cxx | 7 +++++-- app/AcquireIntersonBMode.xml | 12 ++++++++++++ app/AcquireIntersonRF.cxx | 5 +++-- app/AcquireIntersonRF.xml | 12 ++++++++++++ app/CMakeLists.txt | 7 ++++++- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index 9db6426..ee60724 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -115,8 +115,11 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - // TODO make CLI option - hwControls.SendDynamic( 50 ); + if( !hwControls.SendDynamic( gain ) ) + { + std::cerr << "Could not set dynamic gain." << std::endl; + } + hwControls.DisableHardButton(); scan2D.AbortScan(); diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml index a8f8be2..e7aaeb0 100644 --- a/app/AcquireIntersonBMode.xml +++ b/app/AcquireIntersonBMode.xml @@ -38,6 +38,18 @@ highVoltage z 50 + 0 + 100 + + + gain + + Dynamic gain [dB]. + gain + g + 100 + 0 + 255 diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx index 7064bad..b96ea70 100644 --- a/app/AcquireIntersonRF.cxx +++ b/app/AcquireIntersonRF.cxx @@ -103,6 +103,7 @@ int main( int argc, char * argv[] ) std::cerr << "Could not set the frequency." << std::endl; return EXIT_FAILURE; } + if( !hwControls.SendHighVoltage( highVoltage ) ) { std::cerr << "Could not set the high voltage." << std::endl; @@ -113,10 +114,10 @@ int main( int argc, char * argv[] ) std::cerr << "Could not enable high voltage." << std::endl; return EXIT_FAILURE; } - // TODO make CLI option - hwControls.SendDynamic( 50 ); + // TODO make CLI option hwControls.DisableRFDecimator(); + hwControls.DisableHardButton(); scan2D.AbortScan(); diff --git a/app/AcquireIntersonRF.xml b/app/AcquireIntersonRF.xml index d16ab80..3804ca7 100644 --- a/app/AcquireIntersonRF.xml +++ b/app/AcquireIntersonRF.xml @@ -38,6 +38,18 @@ highVoltage z 50 + 0 + 100 + + + gain + + Dynamic gain [dB]. + gain + g + 100 + 0 + 255 diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 018991f..84b1cc3 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -42,7 +42,12 @@ if( BUILD_TESTING ) add_test( NAME AcquireIntersonBModeTestVoltage COMMAND $ --highVoltage 30 - ${TEMP}/AcquireIntersonBModeTestTestVoltage.mha + ${TEMP}/AcquireIntersonBModeTestVoltage.mha + ) + add_test( NAME AcquireIntersonBModeTestGain + COMMAND $ + --gain 50 + ${TEMP}/AcquireIntersonBModeTestGain.mha ) add_test( NAME AcquireIntersonRFTest From 45aa7a07e161e8ea08cb1c9f5d03f6251ba07f43 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 13:57:53 -0400 Subject: [PATCH 040/103] ENH: Add RF decimator flag. --- app/AcquireIntersonRF.cxx | 18 ++++++++++++++++-- app/AcquireIntersonRF.xml | 18 ++++++++---------- app/CMakeLists.txt | 5 +++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonRF.cxx index b96ea70..c5ee361 100644 --- a/app/AcquireIntersonRF.cxx +++ b/app/AcquireIntersonRF.cxx @@ -115,8 +115,22 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - // TODO make CLI option - hwControls.DisableRFDecimator(); + if( decimator ) + { + if( !hwControls.EnableRFDecimator() ) + { + std::cerr << "Could not enable RF decimator." << std::endl; + return EXIT_FAILURE; + } + } + else + { + if( !hwControls.DisableRFDecimator() ) + { + std::cerr << "Could not disable RF decimator." << std::endl; + return EXIT_FAILURE; + } + } hwControls.DisableHardButton(); diff --git a/app/AcquireIntersonRF.xml b/app/AcquireIntersonRF.xml index 3804ca7..fcff8db 100644 --- a/app/AcquireIntersonRF.xml +++ b/app/AcquireIntersonRF.xml @@ -41,15 +41,13 @@ 0 100 - - gain - - Dynamic gain [dB]. - gain - g - 100 - 0 - 255 - + + decimator + + For GV and GP (low frequency probes) sampling rate is 15 Msamples/sec with decimator off and with decimator on sampling rate is 7.5 Msamples/sec. For higher frequency probes sampling rate is 30 Ms/sec with decimator off and 15 Ms/sec with decimator on. + decimator + d + + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 84b1cc3..182dbf7 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -64,6 +64,11 @@ if( BUILD_TESTING ) --highVoltage 30 ${TEMP}/AcquireIntersonRFTestVoltage.mha ) + add_test( NAME AcquireIntersonRFTestDecimator + COMMAND $ + --decimator + ${TEMP}/AcquireIntersonRFTestDecimator.mha + ) add_test( NAME PrintIntersonProbeInfoTest COMMAND $ From 07f74304e4acaca88c43199a0df21a93d78bebb0 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 14:04:52 -0400 Subject: [PATCH 041/103] ENH: Output serial number, FPGA in ProbeInfo app. --- app/PrintIntersonProbeInfo.cxx | 48 +++------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/app/PrintIntersonProbeInfo.cxx b/app/PrintIntersonProbeInfo.cxx index 86361c2..2b69d30 100644 --- a/app/PrintIntersonProbeInfo.cxx +++ b/app/PrintIntersonProbeInfo.cxx @@ -42,56 +42,16 @@ int main( int argc, char * argv[] ) HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); - // TODO make CLI option std::cout << "\nFrequencies: [Hz]" << std::endl; for( size_t ii = 0; ii < frequencies.size(); ++ii ) { std::cout << " " << ii << ": " << frequencies[ii] << std::endl; } - /* - // TODO make CLI option - hwControls.SendDynamic( 50 ); + std::cout << "\nSerial number: " << hwControls.GetProbeSerialNumber() << std::endl; + std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() << std::endl; + std::cout << "OEM ID: " << hwControls.GetOEMId() << std::endl; + std::cout << "Filter ID: " << hwControls.GetFilterId() << std::endl; - scan2D.AbortScan(); - if( !hwControls.StartMotor() ) - { - std::cerr << "Could not start motor." << std::endl; - return EXIT_FAILURE; - }; - scan2D.StartReadScan(); - Sleep( 100 ); // "time to start" - if( !hwControls.StartBmode() ) - { - std::cerr << "Could not start B-mode collection." << std::endl; - return EXIT_FAILURE; - }; - - while( clientData.FrameIndex < framesToCollect ) - { - Sleep( 100 ); - } - - hwControls.StopAcquisition(); - scan2D.StopReadScan(); - Sleep( 100 ); // "time to stop" - scan2D.DisposeScan(); - hwControls.StopMotor(); - - typedef itk::ImageFileWriter< ImageType > WriterType; - WriterType::Pointer writer = WriterType::New(); - writer->SetFileName( outputImage ); - writer->SetInput( image ); - try - { - writer->Update(); - } - catch( itk::ExceptionObject & error ) - { - std::cerr << "Error: " << error << std::endl; - return EXIT_FAILURE; - } - - */ return EXIT_SUCCESS; } From 2539623f9bb599dbaa6dbb8e56aba80baa1d0b75 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 14:13:49 -0400 Subject: [PATCH 042/103] ENH: Print probe supported depths / frame rates. --- app/PrintIntersonProbeInfo.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/PrintIntersonProbeInfo.cxx b/app/PrintIntersonProbeInfo.cxx index 2b69d30..8ea5844 100644 --- a/app/PrintIntersonProbeInfo.cxx +++ b/app/PrintIntersonProbeInfo.cxx @@ -48,6 +48,15 @@ int main( int argc, char * argv[] ) std::cout << " " << ii << ": " << frequencies[ii] << std::endl; } + std::cout << "\nSupported Depth [mm]: FrameRate [fps]" << std::endl; + int depth = 20; + while( hwControls.ValidDepth( depth ) == depth ) + { + short frameRate = hwControls.GetProbeFrameRate( depth ); + std::cout << " " << depth << ":\t" << frameRate << std::endl; + depth += 20; + } + std::cout << "\nSerial number: " << hwControls.GetProbeSerialNumber() << std::endl; std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() << std::endl; std::cout << "OEM ID: " << hwControls.GetOEMId() << std::endl; From 70fde6d5ad12e01d0fe3c71e687654792ebb3c24 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 22:04:51 -0400 Subject: [PATCH 043/103] ENH: ScanConverter class skeleton. --- app/AcquireIntersonBMode.cxx | 8 +++ app/AcquireIntersonBMode.xml | 10 ++++ include/IntersonCxxImagingScanConverter.h | 37 +++++++++++++ src/CMakeLists.txt | 1 + src/IntersonCxxImagingScanConverter.cxx | 54 +++++++++++++++++++ test/CMakeLists.txt | 1 + test/IntersonCxxImagingScan2DClassTest.cxx | 8 +-- test/IntersonCxxImagingScanConverterTest.cxx | 57 ++++++++++++++++++++ 8 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 include/IntersonCxxImagingScanConverter.h create mode 100644 src/IntersonCxxImagingScanConverter.cxx create mode 100644 test/IntersonCxxImagingScanConverterTest.cxx diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index ee60724..1127aaa 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -122,6 +122,14 @@ int main( int argc, char * argv[] ) hwControls.DisableHardButton(); + if( hwControls.ValidDepth( depth ) == depth ) + { + } + else + { + std::cerr << "Invalid requested depth for probe." << std::endl; + } + scan2D.AbortScan(); scan2D.SetRFData( false ); if( !hwControls.StartMotor() ) diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml index e7aaeb0..9ada448 100644 --- a/app/AcquireIntersonBMode.xml +++ b/app/AcquireIntersonBMode.xml @@ -51,5 +51,15 @@ 0 255 + + depth + + Depth of acquisition [mm]. + depth + d + 100 + 0 + 200 + diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h new file mode 100644 index 0000000..b3fbd5e --- /dev/null +++ b/include/IntersonCxxImagingScanConverter.h @@ -0,0 +1,37 @@ +#ifndef _IntersonCxxImagingScanConverter_h +#define _IntersonCxxImagingScanConverter_h + +#include "IntersonCxx_Export.h" + +namespace IntersonCxx +{ + +namespace Imaging +{ + +class ScanConverterImpl; + +class IntersonCxx_EXPORT ScanConverter +{ +public: + ScanConverter(); + ~ScanConverter(); + + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + static const int MAX_VECTORS = 241; + + +private: + ScanConverter( const ScanConverter & ); + void operator=( const ScanConverter & ); + + ScanConverterImpl * Impl; +}; + +} // end namespace Imaging + +} // end namespace IntersonCxx + + +#endif // _IntersonCxxImagingScanConverter_h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d502513..4bbb4d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,7 @@ set( IntersonCxx_SRCS IntersonCxxIntersonClass.cxx IntersonCxxControlsHWControls.cxx IntersonCxxImagingScan2DClass.cxx + IntersonCxxImagingScanConverter.cxx ) include( GenerateExportHeader ) diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx new file mode 100644 index 0000000..d59587e --- /dev/null +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -0,0 +1,54 @@ +#pragma unmanaged +#include "IntersonCxxImagingScanConverter.h" + +#pragma managed + +#include +#include + +#using "Interson.dll" + +namespace IntersonCxx +{ + +namespace Imaging +{ + +class ScanConverterImpl +{ +public: + ScanConverterImpl() + { + Wrapped = gcnew Interson::Imaging::ScanConverter(); + } + + ~ScanConverterImpl() + { + } + + +private: + gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; + +}; + + +#pragma unmanaged + +ScanConverter +::ScanConverter(): + Impl( new ScanConverterImpl() ) +{ +} + + +ScanConverter +::~ScanConverter() +{ + delete Impl; +} + + +} // end namespace Imaging + +} // end namespace IntersonCxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7555709..f1b70c0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,6 +2,7 @@ set( _tests IntersonCxxIntersonClassTest IntersonCxxControlsHWControlsTest IntersonCxxImagingScan2DClassTest + IntersonCxxImagingScanConverterTest ) foreach( test ${_tests} ) diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx index 0ed3a1e..418d4b9 100644 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ b/test/IntersonCxxImagingScan2DClassTest.cxx @@ -9,11 +9,13 @@ int main( int argc, char * argv[] ) { - IntersonCxx::Controls::HWControls hwControls; - IntersonCxx::Imaging::Scan2DClass scan2D; + typedef IntersonCxx::Controls::HWControls HWControlsType; + HWControlsType hwControls; + typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + Scan2DClassType scan2D; - typedef IntersonCxx::Controls::HWControls::FoundProbesType FoundProbesType; + typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); if( foundProbes.empty() ) diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonCxxImagingScanConverterTest.cxx new file mode 100644 index 0000000..61684ff --- /dev/null +++ b/test/IntersonCxxImagingScanConverterTest.cxx @@ -0,0 +1,57 @@ +#include "IntersonCxxImagingScan2DClass.h" +#include "IntersonCxxControlsHWControls.h" +#include "IntersonCxxImagingScanConverter.h" + +#include +#include +#include + +#include // Sleep + +int main( int argc, char * argv[] ) +{ + typedef IntersonCxx::Controls::HWControls HWControlsType; + HWControlsType hwControls; + + typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; + Scan2DClassType scan2D; + + typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + const int maxVectors = Scan2DClassType::MAX_VECTORS; + const int maxSamples = Scan2DClassType::MAX_SAMPLES; + const int maxPixels = maxVectors * maxSamples; + + scan2D.AbortScan(); + hwControls.StartMotor(); + std::cout << "\nStarting BMode scanning..." << std::endl; + scan2D.StartReadScan(); + Sleep( 100 ); // "time to start" + hwControls.StartBmode(); + std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; + + std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; + + hwControls.StopAcquisition(); + scan2D.StopReadScan(); + Sleep( 100 ); // "time to stop" + scan2D.DisposeScan(); + hwControls.StopMotor(); + + return EXIT_SUCCESS; +} From 59dc20d5c0fbef996d60c46af96f5d8316ac6c1a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 22:10:22 -0400 Subject: [PATCH 044/103] ENH: Add ScanConverterError. --- include/IntersonCxxImagingScanConverter.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index b3fbd5e..e71b625 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -21,6 +21,17 @@ class IntersonCxx_EXPORT ScanConverter static const int MAX_RFSAMPLES = 2048; static const int MAX_VECTORS = 241; + // Error code of HardInitScanConverter and SoftInitScanConverter + enum ScanConverterError + { + SUCCESS = 1, + PROBE_NOT_INITIALIZED, // FindMyProbe has not been called + UNKNOWN_PROBE, // Probe Identity not valid + UNDER_LIMITS, // Width * Height over 10 * 10 + OVER_LIMITS, // Width * Height over 800 * 1000 + ERROR // other error + }; + private: ScanConverter( const ScanConverter & ); From 998f6b58825bf3bc720a618fca16edf57f4c2e98 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 22:49:28 -0400 Subject: [PATCH 045/103] ENH: GetHeightScan. --- include/IntersonCxxImagingScanConverter.h | 2 ++ src/IntersonCxxImagingScanConverter.cxx | 12 ++++++++++++ test/IntersonCxxImagingScanConverterTest.cxx | 6 +++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index e71b625..6bfc0ba 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -32,6 +32,8 @@ class IntersonCxx_EXPORT ScanConverter ERROR // other error }; + int GetHeightScan() const; + private: ScanConverter( const ScanConverter & ); diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx index d59587e..f590769 100644 --- a/src/IntersonCxxImagingScanConverter.cxx +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -26,6 +26,11 @@ class ScanConverterImpl { } + int GetHeightScan() + { + return Wrapped->HeightScan; + } + private: gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; @@ -49,6 +54,13 @@ ScanConverter } +int +ScanConverter +::GetHeightScan() const +{ + return Impl->GetHeightScan(); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonCxxImagingScanConverterTest.cxx index 61684ff..7ad54fa 100644 --- a/test/IntersonCxxImagingScanConverterTest.cxx +++ b/test/IntersonCxxImagingScanConverterTest.cxx @@ -16,6 +16,9 @@ int main( int argc, char * argv[] ) typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; Scan2DClassType scan2D; + typedef IntersonCxx::Imaging::ScanConverter ScanConverterType; + ScanConverterType scanConverter; + typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); @@ -43,9 +46,10 @@ int main( int argc, char * argv[] ) scan2D.StartReadScan(); Sleep( 100 ); // "time to start" hwControls.StartBmode(); - std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; + std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; + std::cout << "\nHeightScan: " << scanConverter.GetHeightScan() << std::endl; hwControls.StopAcquisition(); scan2D.StopReadScan(); From 8a2f27cbfa76a832bac6099e7db91ab9fa0bca0a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 22:50:57 -0400 Subject: [PATCH 046/103] ENH: GetWidthScan. --- include/IntersonCxxImagingScanConverter.h | 1 + src/IntersonCxxImagingScanConverter.cxx | 13 +++++++++++++ test/IntersonCxxImagingScanConverterTest.cxx | 1 + 3 files changed, 15 insertions(+) diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index 6bfc0ba..8de3b0d 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -33,6 +33,7 @@ class IntersonCxx_EXPORT ScanConverter }; int GetHeightScan() const; + int GetWidthScan() const; private: diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx index f590769..a968f08 100644 --- a/src/IntersonCxxImagingScanConverter.cxx +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -31,6 +31,11 @@ class ScanConverterImpl return Wrapped->HeightScan; } + int GetWidthScan() + { + return Wrapped->WidthScan; + } + private: gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; @@ -61,6 +66,14 @@ ::GetHeightScan() const return Impl->GetHeightScan(); } + +int +ScanConverter +::GetWidthScan() const +{ + return Impl->GetWidthScan(); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonCxxImagingScanConverterTest.cxx index 7ad54fa..633e6ee 100644 --- a/test/IntersonCxxImagingScanConverterTest.cxx +++ b/test/IntersonCxxImagingScanConverterTest.cxx @@ -50,6 +50,7 @@ int main( int argc, char * argv[] ) std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; std::cout << "\nHeightScan: " << scanConverter.GetHeightScan() << std::endl; + std::cout << "WidthScan: " << scanConverter.GetWidthScan() << std::endl; hwControls.StopAcquisition(); scan2D.StopReadScan(); From d8717b5be8f9e2569a2207dad1da26b3241e5007 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 22:55:43 -0400 Subject: [PATCH 047/103] ENH: Get{MmPerPixel, ZeroOfYScale}. --- include/IntersonCxxImagingScanConverter.h | 2 ++ src/IntersonCxxImagingScanConverter.cxx | 26 ++++++++++++++++++++ test/IntersonCxxImagingScanConverterTest.cxx | 2 ++ 3 files changed, 30 insertions(+) diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index 8de3b0d..7affab7 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -35,6 +35,8 @@ class IntersonCxx_EXPORT ScanConverter int GetHeightScan() const; int GetWidthScan() const; + float GetMmPerPixel() const; + int GetZeroOfYScale() const; private: ScanConverter( const ScanConverter & ); diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx index a968f08..f13c655 100644 --- a/src/IntersonCxxImagingScanConverter.cxx +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -36,6 +36,16 @@ class ScanConverterImpl return Wrapped->WidthScan; } + float GetMmPerPixel() + { + return Wrapped->MmPerPixel; + } + + int GetZeroOfYScale() + { + return Wrapped->ZeroOfYScale; + } + private: gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; @@ -74,6 +84,22 @@ ::GetWidthScan() const return Impl->GetWidthScan(); } + +float +ScanConverter +::GetMmPerPixel() const +{ + return Impl->GetMmPerPixel(); +} + + +int +ScanConverter +::GetZeroOfYScale() const +{ + return Impl->GetZeroOfYScale(); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonCxxImagingScanConverterTest.cxx index 633e6ee..f2e8e54 100644 --- a/test/IntersonCxxImagingScanConverterTest.cxx +++ b/test/IntersonCxxImagingScanConverterTest.cxx @@ -51,6 +51,8 @@ int main( int argc, char * argv[] ) std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; std::cout << "\nHeightScan: " << scanConverter.GetHeightScan() << std::endl; std::cout << "WidthScan: " << scanConverter.GetWidthScan() << std::endl; + std::cout << "\nMmPerPixel: " << scanConverter.GetMmPerPixel() << std::endl; + std::cout << "\nZeroOfYScale: " << scanConverter.GetZeroOfYScale() << std::endl; hwControls.StopAcquisition(); scan2D.StopReadScan(); From a8aa27eaf2bfbb79669d52bf17857987c5604130 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 23:23:28 -0400 Subject: [PATCH 048/103] ENH: HardInitScanConverter. --- include/IntersonCxxImagingScanConverter.h | 6 +++++ src/IntersonCxxImagingScanConverter.cxx | 25 +++++++++++++++++++ test/IntersonCxxImagingScanConverterTest.cxx | 26 +++++++++++++++++--- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index 7affab7..f309666 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -38,6 +38,12 @@ class IntersonCxx_EXPORT ScanConverter float GetMmPerPixel() const; int GetZeroOfYScale() const; + ScanConverterError HardInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan ); + private: ScanConverter( const ScanConverter & ); void operator=( const ScanConverter & ); diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx index f13c655..5cf6757 100644 --- a/src/IntersonCxxImagingScanConverter.cxx +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -46,6 +46,15 @@ class ScanConverterImpl return Wrapped->ZeroOfYScale; } + ScanConverter::ScanConverterError HardInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan ) + { + return static_cast< ScanConverter::ScanConverterError >( + Wrapped->HardInitScanConverter( depth, upDown, leftRight, widthScan, heightScan ) ); + } private: gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; @@ -100,6 +109,22 @@ ::GetZeroOfYScale() const return Impl->GetZeroOfYScale(); } + +ScanConverter::ScanConverterError +ScanConverter +::HardInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan ) +{ + return Impl->HardInitScanConverter( depth, + upDown, + leftRight, + widthScan, + heightScan ); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonCxxImagingScanConverterTest.cxx index f2e8e54..67f6d65 100644 --- a/test/IntersonCxxImagingScanConverterTest.cxx +++ b/test/IntersonCxxImagingScanConverterTest.cxx @@ -36,9 +36,29 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_SAMPLES; - const int maxPixels = maxVectors * maxSamples; + const int depth = 50; + if( hwControls.ValidDepth( depth ) != depth ) + { + std::cerr << "Did not request a valid depth" << std::endl; + return EXIT_SUCCESS; + } + const bool upDown = true; + const bool leftRight = true; + const int width = 776; + const int height = 512; + + ScanConverterType::ScanConverterError converterError = + scanConverter.HardInitScanConverter( depth, + upDown, + leftRight, + width, + height ); + if( converterError != ScanConverterType::SUCCESS ) + { + std::cerr << "Error during scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } scan2D.AbortScan(); hwControls.StartMotor(); From 8bc52e3fedaa4dcfd5e9965b0dad762235d3258a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 9 Apr 2014 23:36:21 -0400 Subject: [PATCH 049/103] ENH: IdleInitScanConverter. --- include/IntersonCxxImagingScanConverter.h | 7 +++++ src/IntersonCxxImagingScanConverter.cxx | 29 ++++++++++++++++++++ test/IntersonCxxImagingScanConverterTest.cxx | 15 +++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index f309666..c211439 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -44,6 +44,13 @@ class IntersonCxx_EXPORT ScanConverter int widthScan, int heightScan ); + ScanConverterError IdleInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan, + unsigned char probeId ); + private: ScanConverter( const ScanConverter & ); void operator=( const ScanConverter & ); diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx index 5cf6757..586ce5c 100644 --- a/src/IntersonCxxImagingScanConverter.cxx +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -56,6 +56,17 @@ class ScanConverterImpl Wrapped->HardInitScanConverter( depth, upDown, leftRight, widthScan, heightScan ) ); } + ScanConverter::ScanConverterError IdleInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan, + unsigned char probeId ) + { + return static_cast< ScanConverter::ScanConverterError >( + Wrapped->IdleInitScanConverter( depth, upDown, leftRight, widthScan, heightScan, probeId ) ); + } + private: gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; @@ -125,6 +136,24 @@ ::HardInitScanConverter( int depth, heightScan ); } + +ScanConverter::ScanConverterError +ScanConverter +::IdleInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan, + unsigned char probeId ) +{ + return Impl->IdleInitScanConverter( depth, + upDown, + leftRight, + widthScan, + heightScan, + probeId ); +} + } // end namespace Imaging } // end namespace IntersonCxx diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonCxxImagingScanConverterTest.cxx index 67f6d65..cf7b990 100644 --- a/test/IntersonCxxImagingScanConverterTest.cxx +++ b/test/IntersonCxxImagingScanConverterTest.cxx @@ -48,6 +48,19 @@ int main( int argc, char * argv[] ) const int height = 512; ScanConverterType::ScanConverterError converterError = + scanConverter.IdleInitScanConverter( depth, + upDown, + leftRight, + width, + height, + probeId ); + if( converterError != ScanConverterType::SUCCESS ) + { + std::cerr << "Error during idle scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } + converterError = scanConverter.HardInitScanConverter( depth, upDown, leftRight, @@ -55,7 +68,7 @@ int main( int argc, char * argv[] ) height ); if( converterError != ScanConverterType::SUCCESS ) { - std::cerr << "Error during scan converter initialization: " + std::cerr << "Error during hard scan converter initialization: " << converterError << std::endl; return EXIT_FAILURE; } From bfaed4f2ac4af1d760e945c09811f3599d838698 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Thu, 10 Apr 2014 00:52:47 -0400 Subject: [PATCH 050/103] ENH: NewScanConvertedBmodeImageCallback. --- include/IntersonCxxImagingScan2DClass.h | 7 ++ src/IntersonCxxImagingScan2DClass.cxx | 67 ++++++++++++++++++-- test/IntersonCxxImagingScanConverterTest.cxx | 2 +- 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 1d64bb1..1ad802c 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -48,6 +48,13 @@ class IntersonCxx_EXPORT Scan2DClass void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = NULL ); + typedef void (__stdcall * NewScanConvertedBmodeImageCallbackType)( BmodePixelType * buffer, + void * clientData ); + /** \warning The WidthScan and HeightScan must be initialized on the + * ScanConverter before calling this method. */ + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, + void * clientData = NULL ); + typedef void (__stdcall * NewRFImageCallbackType)( RFPixelType * buffer, void * clientData ); void SetNewRFImageCallback( NewRFImageCallbackType callback, diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 4909946..0b74b95 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -7,8 +7,8 @@ #include #using "Interson.dll" -// For StartReadScan -//#using "System.Drawing.dll" +// For Build2D Bitmap +#using "System.Drawing.dll" namespace IntersonCxx { @@ -69,6 +69,8 @@ ref class NewBmodeImageHandler { public: typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; typedef cli::array< byte, 2 > BmodeArrayType; @@ -76,13 +78,18 @@ ref class NewBmodeImageHandler NewBmodeImageCallback( NULL ), NewBmodeImageCallbackClientData( NULL ), NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedBmodeBuffer( managedBmodeBuffer ) + ManagedBmodeBuffer( managedBmodeBuffer ), + NewScanConvertedBmodeImageCallback( NULL ), + NewScanConvertedBmodeImageCallbackClientData( NULL ), + ScanConvertedBmodeBuffer( new BmodePixelType[0] ) { + ScanConverter = gcnew Interson::Imaging::ScanConverter(); } ~NewBmodeImageHandler() { delete [] NativeBmodeBuffer; + delete [] ScanConvertedBmodeBuffer; } void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) @@ -93,11 +100,26 @@ ref class NewBmodeImageHandler { for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) { - this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = this->ManagedBmodeBuffer[ii, jj]; + this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = + this->ManagedBmodeBuffer[ii, jj]; } } this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); } + if( this->NewScanConvertedBmodeImageCallback != NULL ) + { + scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); + for( int ii = 0; ii < ScanConvertedBmode->Width; ++ii ) + { + for( int jj = 0; jj < ScanConvertedBmode->Height; ++jj ) + { + // Assume it is grayscale, i.e. R = G = B + ScanConvertedBmodeBuffer[ScanConvertedBmode->Height * ii + jj] = + static_cast< BmodePixelType >( ScanConvertedBmode->GetPixel( ii, jj).B ); + } + } + this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); + } } void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData ) @@ -106,11 +128,29 @@ ref class NewBmodeImageHandler this->NewBmodeImageCallbackClientData = clientData; } + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData ) + { + this->NewScanConvertedBmodeImageCallback = callback; + this->NewScanConvertedBmodeImageCallbackClientData = clientData; + + ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, + ScanConverter->HeightScan, + System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); + delete [] ScanConvertedBmodeBuffer; + ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; + } + private: NewBmodeImageCallbackType NewBmodeImageCallback; void * NewBmodeImageCallbackClientData; BmodePixelType * NativeBmodeBuffer; BmodeArrayType ^ ManagedBmodeBuffer; + System::Drawing::Bitmap ^ ScanConvertedBmode; + + NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; + void * NewScanConvertedBmodeImageCallbackClientData; + Interson::Imaging::ScanConverter ^ ScanConverter; + BmodePixelType * ScanConvertedBmodeBuffer; }; @@ -121,13 +161,14 @@ class Scan2DClassImpl typedef cli::array< unsigned short, 2 > RFArrayType; typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; Scan2DClassImpl() { Wrapped = gcnew Interson::Imaging::Scan2DClass(); - BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); BmodeHandlerDelegate = gcnew @@ -209,6 +250,11 @@ class Scan2DClassImpl this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); } + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData = 0 ) + { + this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); + } + void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData = 0 ) { this->RFHandler->SetNewRFImageCallback( callback, clientData ); @@ -237,7 +283,6 @@ ::Scan2DClass(): } - Scan2DClass ::~Scan2DClass() { @@ -332,6 +377,16 @@ ::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, Impl->SetNewBmodeImageCallback( callback, clientData ); } + +void +Scan2DClass +::SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, + void * clientData ) +{ + Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); +} + + void Scan2DClass ::SetNewRFImageCallback( NewRFImageCallbackType callback, diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonCxxImagingScanConverterTest.cxx index cf7b990..ff9236f 100644 --- a/test/IntersonCxxImagingScanConverterTest.cxx +++ b/test/IntersonCxxImagingScanConverterTest.cxx @@ -83,7 +83,7 @@ int main( int argc, char * argv[] ) std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; std::cout << "\nHeightScan: " << scanConverter.GetHeightScan() << std::endl; - std::cout << "WidthScan: " << scanConverter.GetWidthScan() << std::endl; + std::cout << "WidthScan: " << scanConverter.GetWidthScan() << std::endl; std::cout << "\nMmPerPixel: " << scanConverter.GetMmPerPixel() << std::endl; std::cout << "\nZeroOfYScale: " << scanConverter.GetZeroOfYScale() << std::endl; From 333ee596816b50bb232a653f5784c5758b520137 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Thu, 10 Apr 2014 01:42:36 -0400 Subject: [PATCH 051/103] ENH: Bmode scan conversion. --- app/AcquireIntersonBMode.cxx | 93 +++++++++++++++++++---- app/AcquireIntersonBMode.xml | 9 ++- app/CMakeLists.txt | 13 ++++ include/IntersonCxxImagingScanConverter.h | 2 +- src/IntersonCxxImagingScan2DClass.cxx | 11 +-- 5 files changed, 105 insertions(+), 23 deletions(-) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonBMode.cxx index 1127aaa..8fbf32e 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonBMode.cxx @@ -2,8 +2,9 @@ #include "itkImageFileWriter.h" -#include "IntersonCxxImagingScan2DClass.h" #include "IntersonCxxControlsHWControls.h" +#include "IntersonCxxImagingScan2DClass.h" +#include "IntersonCxxImagingScanConverter.h" #include "AcquireIntersonBModeCLP.h" @@ -20,13 +21,15 @@ struct CallbackClientData itk::SizeValueType FrameIndex; }; + void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) { CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); ImageType * image = callbackClientData->Image; const ImageType::RegionType & largestRegion = image->GetLargestPossibleRegion(); - const itk::SizeValueType imageFrames = largestRegion.GetSize()[2]; + const ImageType::SizeType imageSize = largestRegion.GetSize(); + const itk::SizeValueType imageFrames = imageSize[2]; if( callbackClientData->FrameIndex >= imageFrames ) { return; @@ -44,16 +47,43 @@ void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) ++(callbackClientData->FrameIndex); } + +void __stdcall pasteIntoScanConvertedImage( PixelType * buffer, void * clientData ) +{ + CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); + ImageType * image = callbackClientData->Image; + + const ImageType::RegionType & largestRegion = image->GetLargestPossibleRegion(); + const ImageType::SizeType imageSize = largestRegion.GetSize(); + const itk::SizeValueType imageFrames = imageSize[2]; + if( callbackClientData->FrameIndex >= imageFrames ) + { + return; + } + + const int framePixels = imageSize[0] * imageSize[1]; + + PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); + imageBuffer += framePixels * callbackClientData->FrameIndex; + std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); + + std::cout << "Acquired frame: " << callbackClientData->FrameIndex << std::endl; + ++(callbackClientData->FrameIndex); +} + + int main( int argc, char * argv[] ) { PARSE_ARGS; - typedef IntersonCxx::Controls::HWControls HWControlsType; IntersonCxx::Controls::HWControls hwControls; Scan2DClassType scan2D; + typedef IntersonCxx::Imaging::ScanConverter ScanConverterType; + ScanConverterType scanConverter; + typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); @@ -70,7 +100,30 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - int ret = EXIT_SUCCESS; + const bool upDown = false; + const bool leftRight = false; + const int width = 1000; + const int height = 650; + if( hwControls.ValidDepth( depth ) == depth ) + { + ScanConverterType::ScanConverterError converterError = + scanConverter.HardInitScanConverter( depth, + upDown, + leftRight, + width, + height ); + if( converterError != ScanConverterType::SUCCESS ) + { + std::cerr << "Error during hard scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } + } + else + { + std::cerr << "Invalid requested depth for probe." << std::endl; + } + const itk::SizeValueType framesToCollect = frames; const int maxVectors = Scan2DClassType::MAX_VECTORS; @@ -83,18 +136,34 @@ int main( int argc, char * argv[] ) imageIndex.Fill( 0 ); imageRegion.SetIndex( imageIndex ); ImageType::SizeType imageSize; - imageSize[0] = maxSamples; - imageSize[1] = maxVectors; + if( scanConvert ) + { + imageSize[0] = width; + imageSize[1] = height; + } + else + { + imageSize[0] = maxSamples; + imageSize[1] = maxVectors; + } imageSize[2] = framesToCollect; imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); image->Allocate(); CallbackClientData clientData; + clientData.Image = image.GetPointer(); clientData.FrameIndex = 0; - scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); + if( scanConvert ) + { + scan2D.SetNewScanConvertedBmodeImageCallback( &pasteIntoScanConvertedImage, &clientData ); + } + else + { + scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); + } HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); @@ -122,14 +191,6 @@ int main( int argc, char * argv[] ) hwControls.DisableHardButton(); - if( hwControls.ValidDepth( depth ) == depth ) - { - } - else - { - std::cerr << "Invalid requested depth for probe." << std::endl; - } - scan2D.AbortScan(); scan2D.SetRFData( false ); if( !hwControls.StartMotor() ) @@ -170,5 +231,5 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - return ret; + return EXIT_SUCCESS; } diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonBMode.xml index 9ada448..c177b0b 100644 --- a/app/AcquireIntersonBMode.xml +++ b/app/AcquireIntersonBMode.xml @@ -54,12 +54,19 @@ depth - Depth of acquisition [mm]. + Depth of acquisition [mm]. Only relevant with scanConvert. depth d 100 0 200 + + scanConvert + + Do scan conversion. + scanConvert + s + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 182dbf7..dc498c3 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -49,6 +49,19 @@ if( BUILD_TESTING ) --gain 50 ${TEMP}/AcquireIntersonBModeTestGain.mha ) + add_test( NAME AcquireIntersonBModeTestScanConvert + COMMAND $ + --scanConvert + --gain 50 + ${TEMP}/AcquireIntersonBModeTestScanConvert.mha + ) + add_test( NAME AcquireIntersonBModeTestScanConvertFrames + COMMAND $ + -s + -n 4 + --gain 50 + ${TEMP}/AcquireIntersonBModeTestScanConvertFrames.mha + ) add_test( NAME AcquireIntersonRFTest COMMAND $ diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index c211439..c298f3b 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -29,7 +29,7 @@ class IntersonCxx_EXPORT ScanConverter UNKNOWN_PROBE, // Probe Identity not valid UNDER_LIMITS, // Width * Height over 10 * 10 OVER_LIMITS, // Width * Height over 800 * 1000 - ERROR // other error + OTHER_ERROR // other error }; int GetHeightScan() const; diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 0b74b95..6eaddee 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -7,7 +7,7 @@ #include #using "Interson.dll" -// For Build2D Bitmap +// for Bitmap #using "System.Drawing.dll" namespace IntersonCxx @@ -106,16 +106,17 @@ ref class NewBmodeImageHandler } this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); } + if( this->NewScanConvertedBmodeImageCallback != NULL ) { scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); - for( int ii = 0; ii < ScanConvertedBmode->Width; ++ii ) + for( int ii = 0; ii < ScanConvertedBmode->Height; ++ii ) { - for( int jj = 0; jj < ScanConvertedBmode->Height; ++jj ) + for( int jj = 0; jj < ScanConvertedBmode->Width; ++jj ) { // Assume it is grayscale, i.e. R = G = B - ScanConvertedBmodeBuffer[ScanConvertedBmode->Height * ii + jj] = - static_cast< BmodePixelType >( ScanConvertedBmode->GetPixel( ii, jj).B ); + this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * ii + jj] = + static_cast< BmodePixelType >( ScanConvertedBmode->GetPixel( jj, ii ).B ); } } this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); From ffa5382112f708a6087aa1896d7771b3e3f43053 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 2 May 2014 16:46:48 -0400 Subject: [PATCH 052/103] ENH: Generate IntersonSDKCxxConfig.cmake. --- CMakeLists.txt | 45 +++++++++++++++++++++++++++++++++-- IntersonSDKCxxConfig.cmake.in | 16 +++++++++++++ include/CMakeLists.txt | 10 ++++++++ src/CMakeLists.txt | 6 +++++ 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 IntersonSDKCxxConfig.cmake.in create mode 100644 include/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 52d03a3..a71f037 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,26 @@ cmake_minimum_required( VERSION 2.8 ) project( IntersonSDKCxx ) -include_directories( ${PROJECT_SOURCE_DIR}/include ) -include_directories( ${PROJECT_BINARY_DIR}/include ) +set( CONF_INCLUDE_DIRS + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ) +include_directories( ${CONF_INCLUDE_DIRS} ) +set( INSTALL_LIB_DIR lib ) +set( INSTALL_BIN_DIR bin ) +set( INSTALL_INCLUDE_DIR include ) +if( WIN32 AND NOT CYGWIN ) + set( DEF_INSTALL_CMAKE_DIR CMake ) +else() + set( DEF_INSTALL_CMAKE_DIR lib/CMake/FooBar ) +endif() +set( INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} ) +foreach( path LIB BIN INCLUDE CMAKE ) + set( var INSTALL_${path}_DIR ) + if( NOT IS_ABSOLUTE "${${var}}" ) + set( ${var} "${CMAKE_INSTALL_PREFIX}/${${var}}" ) + endif() +endforeach() find_path( IntersonSDK_DIR NAMES Libraries/Interson.dll PATHS C:/IntersonSDK ) @@ -12,6 +30,7 @@ if( NOT IntersonSDK_DIR ) IntersonSDK_DIR" ) endif() +add_subdirectory( include ) add_subdirectory( src ) include( CTest ) @@ -24,3 +43,25 @@ option( BUILD_APPLICATIONS "Build applications" OFF ) if( BUILD_APPLICATIONS ) add_subdirectory( app ) endif() + +export( TARGETS IntersonCxx + FILE "${PROJECT_BINARY_DIR}/IntersonSDKCxxTargets.cmake" + ) +export( PACKAGE IntersonSDKCxx ) +file( RELATIVE_PATH _relative_include_dir + "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}" ) +configure_file( IntersonSDKCxxConfig.cmake.in + "${PROJECT_BINARY_DIR}/IntersonSDKCxxConfig.cmake" @ONLY ) +set( CONF_INCLUDE_DIRS "\${IntersonSDKCxx_CMAKE_DIR}/${_relative_include_dir}" +) +configure_file( IntersonSDKCxxConfig.cmake.in + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonSDKCxxConfig.cmake" @ONLY ) + +install( FILES + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonSDKCxxConfig.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT Development + ) +install( EXPORT IntersonSDKCxxTargets DESTINATION + "${INSTALL_CMAKE_DIR}" + COMPONENT Development + ) diff --git a/IntersonSDKCxxConfig.cmake.in b/IntersonSDKCxxConfig.cmake.in new file mode 100644 index 0000000..e3ce038 --- /dev/null +++ b/IntersonSDKCxxConfig.cmake.in @@ -0,0 +1,16 @@ +# Config file for the IntersonSDKCxx library wrapper. +# +# It defines the following variables: +# IntersonSDKCxx_INCLUDE_DIRS - include directories for IntersonSDKCxx +# IntersonSDKCxx_LIBRARIES - libraries to link against +# IntersonSDK_DIR - Path to the IntersonSDK used to build this library. + +get_filename_component( IntersonSDKCxx_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" + PATH + ) + +set( IntersonSDKCxx_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@" ) + +set( IntersonSDKCxx_LIBRARIES IntersonCxx ) + +set( IntersonSDK_DIR "@IntersonSDK_DIR@" ) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..b86fd2c --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,10 @@ +set( IntersonCxx_HEADERS + IntersonCxxControlsHWControls.h + IntersonCxxImagingScan2DClass.h + IntersonCxxImagingScanConverter.h + IntersonCxxIntersonClass.h + ) +install( FILES + ${IntersonCxx_HEADERS} + DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT Development + ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4bbb4d8..c1a806d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,12 @@ generate_export_header( IntersonCxx set_target_properties( IntersonCxx PROPERTIES COMPILE_FLAGS "/clr /EHa /AI${IntersonSDK_DIR}/Libraries" ) + +install( TARGETS IntersonCxx + EXPORT IntersonSDKCxxTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT Runtime + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development + ) if( BUILD_TESTING ) # For running tests add_custom_command( TARGET IntersonCxx From 3b05acb6d61dd73c6e225b9a60fee2aa9ada401f Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sun, 4 May 2014 17:45:38 -0400 Subject: [PATCH 053/103] ENH: Print out SDK version in PrintIntersonProbeInfo. --- app/PrintIntersonProbeInfo.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/PrintIntersonProbeInfo.cxx b/app/PrintIntersonProbeInfo.cxx index 8ea5844..fe1f684 100644 --- a/app/PrintIntersonProbeInfo.cxx +++ b/app/PrintIntersonProbeInfo.cxx @@ -1,5 +1,6 @@ #include "IntersonCxxImagingScan2DClass.h" #include "IntersonCxxControlsHWControls.h" +#include "IntersonCxxIntersonClass.h" #include "PrintIntersonProbeInfoCLP.h" @@ -62,5 +63,8 @@ int main( int argc, char * argv[] ) std::cout << "OEM ID: " << hwControls.GetOEMId() << std::endl; std::cout << "Filter ID: " << hwControls.GetFilterId() << std::endl; + IntersonCxx::IntersonClass intersonClass; + std::cout << "SDK Version: " << intersonClass.Version() << std::endl; + return EXIT_SUCCESS; } From 0bd6e243ffb640b26f4073331e79a31a69dfd8fd Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 5 May 2014 10:24:20 -0400 Subject: [PATCH 054/103] BUG: IntersonSDKCxxConfig.cmake must include the Targets.cmake file. --- IntersonSDKCxxConfig.cmake.in | 4 ++++ include/IntersonCxxImagingScan2DClass.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/IntersonSDKCxxConfig.cmake.in b/IntersonSDKCxxConfig.cmake.in index e3ce038..0a5ab71 100644 --- a/IntersonSDKCxxConfig.cmake.in +++ b/IntersonSDKCxxConfig.cmake.in @@ -11,6 +11,10 @@ get_filename_component( IntersonSDKCxx_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" set( IntersonSDKCxx_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@" ) +if( NOT TARGET IntersonCxx AND NOT IntersonSDKCxx_BINARY_DIR ) + include( "${IntersonSDKCxx_CMAKE_DIR}/IntersonSDKCxxTargets.cmake" ) +endif() + set( IntersonSDKCxx_LIBRARIES IntersonCxx ) set( IntersonSDK_DIR "@IntersonSDK_DIR@" ) diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 1ad802c..7131989 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -25,7 +25,7 @@ class IntersonCxx_EXPORT Scan2DClass static const int MAX_VECTORS = 241; typedef unsigned char BmodePixelType; - typedef short RFPixelType; + typedef short RFPixelType; bool GetScanOn() const; From e8b6ace5f55e5f7416ab7e6d41e4c3dca3ce89d7 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 11 Jun 2014 20:13:31 -0400 Subject: [PATCH 055/103] DOC: Document dependencies. Including the Interson SDK version for #1. --- README.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.rst b/README.rst index 0667ecb..0fd51d8 100644 --- a/README.rst +++ b/README.rst @@ -2,3 +2,10 @@ IntersonSDKCxx ============== C++ Wrapper for the Interson C# SDK ----------------------------------- + +Dependencies +------------ + +- CMake +- Interson SDK >= 1.15 (Interson.dll >= 1.0.38.0) +- Visual Studio >= 2012 From 43f6b74f22f8f50b4a0a10c1dcd224e6364e2b9f Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 11 Jun 2014 22:05:14 -0400 Subject: [PATCH 056/103] ENH: Put built output into bin / lib. --- CMakeLists.txt | 10 ++++++++++ src/CMakeLists.txt | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a71f037..4212d2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,16 @@ cmake_minimum_required( VERSION 2.8 ) project( IntersonSDKCxx ) +if( NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IntersonSDKCxx_BINARY_DIR}/bin ) +endif() +if( NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IntersonSDKCxx_BINARY_DIR}/lib ) +endif() +if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IntersonSDKCxx_BINARY_DIR}/lib ) +endif() + set( CONF_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c1a806d..8e4cafe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,9 +35,6 @@ if( BUILD_TESTING ) # For running tests add_custom_command( TARGET IntersonCxx POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ "${PROJECT_BINARY_DIR}/test" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/test" - COMMAND ${CMAKE_COMMAND} -E copy $ "${PROJECT_BINARY_DIR}/app/bin" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/app/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/bin" ) endif() From 819d620052be7e9b232e12d8946793c15cfbf5a3 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 11 Jun 2014 23:15:28 -0400 Subject: [PATCH 057/103] ENH: Define IntersonSDKCxx_RUNTIME_LIBRARY_DIRS in Config.cmake. --- CMakeLists.txt | 3 +-- IntersonSDKCxxConfig.cmake.in | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4212d2d..02c033a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,8 +62,7 @@ file( RELATIVE_PATH _relative_include_dir "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}" ) configure_file( IntersonSDKCxxConfig.cmake.in "${PROJECT_BINARY_DIR}/IntersonSDKCxxConfig.cmake" @ONLY ) -set( CONF_INCLUDE_DIRS "\${IntersonSDKCxx_CMAKE_DIR}/${_relative_include_dir}" -) +set( CONF_INCLUDE_DIRS "\${IntersonSDKCxx_CMAKE_DIR}/${_relative_include_dir}" ) configure_file( IntersonSDKCxxConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonSDKCxxConfig.cmake" @ONLY ) diff --git a/IntersonSDKCxxConfig.cmake.in b/IntersonSDKCxxConfig.cmake.in index 0a5ab71..18197cc 100644 --- a/IntersonSDKCxxConfig.cmake.in +++ b/IntersonSDKCxxConfig.cmake.in @@ -2,12 +2,12 @@ # # It defines the following variables: # IntersonSDKCxx_INCLUDE_DIRS - include directories for IntersonSDKCxx +# IntersonSDKCxx_RUNTIME_LIBRARY_DIRS - directories that store the libraries +# needed for runtime execution # IntersonSDKCxx_LIBRARIES - libraries to link against # IntersonSDK_DIR - Path to the IntersonSDK used to build this library. -get_filename_component( IntersonSDKCxx_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" - PATH - ) +get_filename_component( IntersonSDKCxx_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) set( IntersonSDKCxx_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@" ) @@ -17,4 +17,14 @@ endif() set( IntersonSDKCxx_LIBRARIES IntersonCxx ) +set( IntersonCxx_RUNTIME_LIBRARY_DIRS ) +get_property( _configs TARGET IntersonCxx PROPERTY IMPORTED_CONFIGURATIONS ) +foreach( _config ${_configs} ) + get_property( _libloc TARGET IntersonCxx PROPERTY IMPORTED_LOCATION_${_config} ) + if( EXISTS "${_libloc}" ) + get_filename_component( _libpath "${_libloc}" PATH ) + list( APPEND IntersonCxx_RUNTIME_LIBRARY_DIRS "${_libpath}" ) + endif() +endforeach() + set( IntersonSDK_DIR "@IntersonSDK_DIR@" ) From 015dba4aa9f486c5a771dd61ec74b0858df16cdf Mon Sep 17 00:00:00 2001 From: marinetto Date: Wed, 15 Oct 2014 18:10:33 -0400 Subject: [PATCH 058/103] 1. Add Comments to the code using IntersonSDK 1.15v documentation 2. Add Functionality to work properly using the BUILD2D function from the SDK. 3. Fix bug of slow refreshing time to get the converted image --- include/IntersonCxxControlsHWControls.h | 192 +++-- include/IntersonCxxImagingScan2DClass.h | 150 ++-- include/IntersonCxxImagingScanConverter.h | 1 + include/IntersonCxxIntersonClass.h | 50 +- src/IntersonCxxControlsHWControls.cxx | 734 +++++++++---------- src/IntersonCxxImagingScan2DClass.cxx | 833 +++++++++++----------- src/IntersonCxxIntersonClass.cxx | 72 +- 7 files changed, 1056 insertions(+), 976 deletions(-) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 7e27654..0812991 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -1,88 +1,130 @@ #ifndef _IntersonCxxControlsHWControls_h #define _IntersonCxxControlsHWControls_h +// Export library, autogenerated using Cmake #include "IntersonCxx_Export.h" #include #include -namespace IntersonCxx -{ - -namespace Controls -{ - -class HWControlsImpl; +// Namespace similar to Interson Namespace from SDK -class IntersonCxx_EXPORT HWControls +/* +The library is organized via namespaces; the root is “Interson”, +then “Interson.Controls” to get the methods which access to the +USB probe controls, “Interson.Imaging” is the scan converter, to +build the 2D image B-Scan bitmap from the log-compressed A-Scan +vectors. +*/ +namespace IntersonCxx { -public: - typedef std::vector< std::string > FoundProbesType; - typedef std::vector< int > FrequenciesType; - HWControls(); - ~HWControls(); - - static const int DIG_GAIN_MIN = -127; - static const int DIG_GAIN_INIT = 0; - static const int DIG_GAIN_MAX = 127; - - static const int MAX_FREQ = 3; - - static const int ID_GP_3_5MHz = 1; - static const int ID_VC_7_5MHz = 2; - static const int ID_SP_7_5MHz = 3; - static const int ID_EC_7_5MHz = 4; - static const int ID_MV_12_MHz = 5; - static const int ID_GV_5_MHz = 6; - - static const unsigned short int EEOEMSpace = 4096; - - void FindAllProbes( FoundProbesType & foundProbes ) const; - void FindMyProbe( int probeIndex ); - unsigned char GetProbeID() const; - - /** Units: mm */ - int ValidDepth( int depth ) const; - - /** Get the list of supported frequencies. Units: Hz. */ - void GetFrequency( FrequenciesType & frequencies ) const; - bool SetFrequency( int frequency ); - - /** Units: Volts */ - bool SendHighVoltage( unsigned char voltage ); - bool EnableHighVoltage(); - bool DisableHighVoltage(); - - bool SendDynamic( unsigned char dynamic ); - - bool StartMotor(); - bool StopMotor(); - - void EnableHardButton(); - void DisableHardButton(); - unsigned char ReadHardButton(); - - bool StartBmode(); - bool StartRFmode(); - bool StopAcquisition(); - - short GetProbeFrameRate( int depth ); - std::string GetProbeSerialNumber() const; - std::string ReadFPGAVersion() const; - std::string GetOEMId() const; - std::string GetFilterId() const; - - bool EnableRFDecimator(); - bool DisableRFDecimator(); - -private: - HWControls( const HWControls & ); - void operator=( const HWControls & ); - - HWControlsImpl * Impl; -}; - -} // end namespace Controls + // Namespace similar to Interson.Controls Namespace from SDK + namespace Controls + { + // Wrapper Class for IntersonClass from SDK + class HWControlsImpl; + + // HWControls similar to IntersonClass from SDK + class IntersonCxx_EXPORT HWControls + { + public: + typedef std::vector< std::string > FoundProbesType; + typedef std::vector< int > FrequenciesType; + HWControls(); + ~HWControls(); + + static const int DIG_GAIN_MIN = -127; + static const int DIG_GAIN_INIT = 0; + static const int DIG_GAIN_MAX = 127; + + // Maximum number of frequencies + static const int MAX_FREQ = 3; + + // These are the valid Probe IDs. + static const int ID_GP_3_5MHz = 1; + static const int ID_VC_7_5MHz = 2; + static const int ID_SP_7_5MHz = 3; + static const int ID_EC_7_5MHz = 4; + static const int ID_MV_12_MHz = 5; + static const int ID_GV_5_MHz = 6; + + // Size of the OEM (Original equipment manufacturer) space in the Probe EEPROM number of frequencies. http://en.wikipedia.org/wiki/Original_equipment_manufacturer + static const unsigned short int EEOEMSpace = 4096; + + // String Vector with all probe names connected + void FindAllProbes( FoundProbesType & foundProbes ) const; + // Summary: To open a handle to the probe defined by the ProbeIndex. Parameters: " ProbeIndex ": Index in the mycolProbesName collection + void FindMyProbe( int probeIndex ); + //To get the ID of the probe + unsigned char GetProbeID() const; + + /** Units: mm */ + // To check if the chosen Depth is valid for the probe. Returns the same depth if in the max range, otherwise returns the max depth + int ValidDepth( int depth ) const; + + /** Get the list of supported frequencies. Units: Hz. */ + void GetFrequency( FrequenciesType & frequencies ) const; + bool SetFrequency( int frequency ); + + /** Units: Volts */ + //" voltage ": percentage of the maximum of the High Voltage. Returns whether the command succeeded (true) or failed (false) + bool SendHighVoltage( unsigned char voltage ); + bool EnableHighVoltage(); + bool DisableHighVoltage(); + + // To set the value of the dynamic and to calculate the value sent to the control. " bytDynamic ": value of the Dynamic (db). + // Returns: Returns whether the command succeeded (true) or failed (false) + bool SendDynamic( unsigned char dynamic ); + + //To start/stop the motor of the probe + bool StartMotor(); + bool StopMotor(); + + // To Start watching the Hardware Button to enable to raise the event “HWButtonTick” + void EnableHardButton(); + void DisableHardButton(); + unsigned char ReadHardButton(); + + bool StartBmode(); + bool StartRFmode(); + bool StopAcquisition(); + + //To get the Frame Rate of that probe according to the depth + //" iDepth ": current depth. Returns: Return the current Frame Rate + short GetProbeFrameRate( int depth ); + + // To get the Serial Number of the probe + std::string GetProbeSerialNumber() const; + + // To get the version of the software installed in the FPGA. + std::string ReadFPGAVersion() const; + + // To get the identification of the OEM + std::string GetOEMId() const; + + //To get the identification of the filter. + std::string GetFilterId() const; + + //To enable the RF Decimator. Returns: Returns whether the command succeeded (true) or failed (false) + /* + Note: For GV and GP (low frequency probes) sampling rate is 15 Msamples/sec with + decimator off and with decimator on sampling rate is 7.5 Msamples/sec. For higher + frequency probes sampling rate is 30 Ms/sec with decimator off and 15 Ms/sec with + decimator on. With the speed of ultrasound at 1540 m/sec in human tissue: 30 Ms/sec + is 0.1 mm/sample, 15 Ms/sec is 0.2 mm/sample, 7.5 Ms/sec is 0.4 mm/sample. Therfore + with 2048 samples, the depths are 5.25 cm, 10.5 cm and 21 cm. + */ + bool EnableRFDecimator(); + bool DisableRFDecimator(); + + private: + HWControls( const HWControls & ); + void operator=( const HWControls & ); + + HWControlsImpl * Impl; + }; + + } // end namespace Controls } // end namespace IntersonCxx diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 7131989..332af0a 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -1,75 +1,75 @@ -#ifndef _IntersonCxxImagingScan2DClass_h -#define _IntersonCxxImagingScan2DClass_h - -#include "IntersonCxx_Export.h" - -#include -#include - -namespace IntersonCxx -{ - -namespace Imaging -{ - -class Scan2DClassImpl; - -class IntersonCxx_EXPORT Scan2DClass -{ -public: - Scan2DClass(); - ~Scan2DClass(); - - static const int MAX_SAMPLES = 1024; - static const int MAX_RFSAMPLES = 2048; - static const int MAX_VECTORS = 241; - - typedef unsigned char BmodePixelType; - typedef short RFPixelType; - - bool GetScanOn() const; - - bool GetRFData() const; - void SetRFData( bool transferOn ); - - bool GetFrameAvg() const; - void SetFrameAvg( bool doAveraging ); - - double GetTrueDepth() const; - - void StartReadScan(); - void StartRFReadScan(); - void StopReadScan(); - void DisposeScan(); - void AbortScan(); - - typedef void (__stdcall * NewBmodeImageCallbackType)( BmodePixelType * buffer, - void * clientData ); - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, - void * clientData = NULL ); - - typedef void (__stdcall * NewScanConvertedBmodeImageCallbackType)( BmodePixelType * buffer, - void * clientData ); - /** \warning The WidthScan and HeightScan must be initialized on the - * ScanConverter before calling this method. */ - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void * clientData = NULL ); - - typedef void (__stdcall * NewRFImageCallbackType)( RFPixelType * buffer, - void * clientData ); - void SetNewRFImageCallback( NewRFImageCallbackType callback, - void * clientData = NULL ); - -private: - Scan2DClass( const Scan2DClass & ); - void operator=( const Scan2DClass & ); - - Scan2DClassImpl * Impl; -}; - -} // end namespace Imaging - -} // end namespace IntersonCxx - - -#endif // _IntersonCxxImagingScan2DClass_h +#ifndef _IntersonCxxImagingScan2DClass_h +#define _IntersonCxxImagingScan2DClass_h + +#include "IntersonCxx_Export.h" + +#include +#include + +namespace IntersonCxx +{ + +namespace Imaging +{ + +class Scan2DClassImpl; + +class IntersonCxx_EXPORT Scan2DClass +{ +public: + Scan2DClass(); + ~Scan2DClass(); + + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + static const int MAX_VECTORS = 241; + + typedef unsigned char BmodePixelType; + typedef short RFPixelType; + + bool GetScanOn() const; + + bool GetRFData() const; + void SetRFData( bool transferOn ); + + bool GetFrameAvg() const; + void SetFrameAvg( bool doAveraging ); + + double GetTrueDepth() const; + + void StartReadScan(); + void StartRFReadScan(); + void StopReadScan(); + void DisposeScan(); + void AbortScan(); + + typedef void (__stdcall * NewBmodeImageCallbackType)( BmodePixelType * buffer, + void * clientData ); + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, + void * clientData = NULL ); + + typedef void (__stdcall * NewScanConvertedBmodeImageCallbackType)( BmodePixelType * buffer, + void * clientData ); + /** \warning The WidthScan and HeightScan must be initialized on the + * ScanConverter before calling this method. */ + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, + void * clientData = NULL ); + + typedef void (__stdcall * NewRFImageCallbackType)( RFPixelType * buffer, + void * clientData ); + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void * clientData = NULL ); + +private: + Scan2DClass( const Scan2DClass & ); + void operator=( const Scan2DClass & ); + + Scan2DClassImpl * Impl; +}; + +} // end namespace Imaging + +} // end namespace IntersonCxx + + +#endif // _IntersonCxxImagingScan2DClass_h diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index c298f3b..3b840c8 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -38,6 +38,7 @@ class IntersonCxx_EXPORT ScanConverter float GetMmPerPixel() const; int GetZeroOfYScale() const; + // Optimal iHeightScan is 512. Optimal iWidthScan is 776 for 90 degree (GP, SP, EC) probes, and 590 for a 60 degree (VC) probe. ScanConverterError HardInitScanConverter( int depth, bool upDown, bool leftRight, diff --git a/include/IntersonCxxIntersonClass.h b/include/IntersonCxxIntersonClass.h index 8961a86..8697a3f 100644 --- a/include/IntersonCxxIntersonClass.h +++ b/include/IntersonCxxIntersonClass.h @@ -1,29 +1,45 @@ #ifndef _IntersonCxxIntersonClass_h #define _IntersonCxxIntersonClass_h +// Export library, autogenerated using Cmake #include "IntersonCxx_Export.h" #include -namespace IntersonCxx -{ +// Namespace similar to Interson Namespace from SDK -class IntersonClassImpl; - -class IntersonCxx_EXPORT IntersonClass +/* +The library is organized via namespaces; the root is “Interson”, +then “Interson.Controls” to get the methods which access to the +USB probe controls, “Interson.Imaging” is the scan converter, to +build the 2D image B-Scan bitmap from the log-compressed A-Scan +vectors. +*/ +namespace IntersonCxx { -public: - IntersonClass(); - ~IntersonClass(); - - std::string Version() const; - -private: - IntersonClass( const IntersonClass & ); - void operator=( const IntersonClass & ); - - IntersonClassImpl * Impl; -}; + // Wrapper Class for IntersonClass from SDK + class IntersonClassImpl; + + // IntersonClass similar to IntersonClass from SDK + class IntersonCxx_EXPORT IntersonClass + { + public: + IntersonClass(); + ~IntersonClass(); + + /* + Summary: To Get the version of Interson.dll + Returns: Returns the String of the version. + */ + std::string Version() const; + + private: + IntersonClass( const IntersonClass & ); + void operator=( const IntersonClass & ); + + // Add the wrapper to the main class to use dll function in C# + IntersonClassImpl * Impl; + }; } // end namespace IntersonCxx diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index a240e78..8c510c7 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -1,402 +1,408 @@ +// C++ #pragma unmanaged #include "IntersonCxxControlsHWControls.h" +// C# #pragma managed #include #include +// Add library from SDK #using "Interson.dll" namespace IntersonCxx { -namespace Controls -{ - -class HWControlsImpl -{ -public: - typedef HWControls::FoundProbesType FoundProbesType; - typedef HWControls::FrequenciesType FrequenciesType; - - - HWControlsImpl() - { - Wrapped = gcnew Interson::Controls::HWControls(); - } - - unsigned char GetProbeID() - { - return Wrapped->GetProbeID(); - } - - void FindAllProbes( FoundProbesType & foundProbes ) - { - System::Collections::Specialized::StringCollection ^ managedProbes = - gcnew System::Collections::Specialized::StringCollection(); - Wrapped->FindAllProbes( managedProbes );; - foundProbes.resize( managedProbes->Count ); - for( int ii = 0; ii < managedProbes->Count; ++ii ) - { - foundProbes[ii] = msclr::interop::marshal_as< std::string >( - managedProbes[ii] ); - } - } - - void FindMyProbe( int probeIndex ) - { - Wrapped->FindMyProbe( probeIndex ); - } - - int ValidDepth( int depth ) - { - return Wrapped->ValidDepth( depth ); - } - - void GetFrequency( FrequenciesType & frequencies ) - { - array< int > ^ managedFrequencies = Wrapped->GetFrequency(); - frequencies.resize( managedFrequencies->Length ); - for( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - frequencies[ii] = managedFrequencies[ii]; - } - } - - bool SetFrequency( int frequency ) - { - array< int > ^ managedFrequencies = Wrapped->GetFrequency(); - int frequencyIndex = -1; - for( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - if( frequency == managedFrequencies[ii] ) - { - frequencyIndex = ii; - break; - } - } - if( frequencyIndex == -1 ) - { - return false; - } - return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); - } - - bool SendHighVoltage( unsigned char voltage ) - { - return Wrapped->SendHighVoltage( voltage ); - } - - bool EnableHighVoltage() - { - return Wrapped->EnableHighVoltage(); - } - - bool DisableHighVoltage() - { - return Wrapped->DisableHighVoltage(); - } - - bool SendDynamic( unsigned char dynamic ) - { - return Wrapped->SendDynamic( dynamic ); - } - - bool StartMotor() - { - return Wrapped->StartMotor(); - } - - bool StopMotor() - { - return Wrapped->StopMotor(); - } - - void EnableHardButton() - { - Wrapped->EnableHardButton(); - } - - void DisableHardButton() - { - Wrapped->DisableHardButton(); - } - - unsigned char ReadHardButton() - { - return Wrapped->ReadHardButton(); - } - - bool StartBmode() - { - return Wrapped->StartBmode(); - } - - bool StartRFmode() - { - return Wrapped->StartRFmode(); - } - - bool StopAcquisition() - { - return Wrapped->StopAcquisition(); - } - - short GetProbeFrameRate( int depth ) - { - return Wrapped->GetProbeFrameRate( depth ); - } - - std::string GetProbeSerialNumber() - { - return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); - } + namespace Controls + { + // Wrapper Class for IntersonClass from SDK + class HWControlsImpl + { + public: + // New defininions look header file + typedef HWControls::FoundProbesType FoundProbesType; + typedef HWControls::FrequenciesType FrequenciesType; + + + HWControlsImpl() + { + // New method for managed code. Wrapped is data member or this class + Wrapped = gcnew Interson::Controls::HWControls(); + } + + unsigned char GetProbeID() + { + return Wrapped->GetProbeID(); + } + + void FindAllProbes( FoundProbesType & foundProbes ) + { + System::Collections::Specialized::StringCollection ^ managedProbes = + gcnew System::Collections::Specialized::StringCollection(); + Wrapped->FindAllProbes( managedProbes );; + foundProbes.resize( managedProbes->Count ); + // Copy all available probes to the C++ class + for( int ii = 0; ii < managedProbes->Count; ++ii ) + { + foundProbes[ii] = msclr::interop::marshal_as< std::string >( + managedProbes[ii] ); + } + } + + void FindMyProbe( int probeIndex ) + { + Wrapped->FindMyProbe( probeIndex ); + } + + int ValidDepth( int depth ) + { + return Wrapped->ValidDepth( depth ); + } + + void GetFrequency( FrequenciesType & frequencies ) + { + array< int > ^ managedFrequencies = Wrapped->GetFrequency(); + frequencies.resize( managedFrequencies->Length ); + for( int ii = 0; ii < managedFrequencies->Length; ++ii ) + { + frequencies[ii] = managedFrequencies[ii]; + } + } + + bool SetFrequency( int frequency ) + { + array< int > ^ managedFrequencies = Wrapped->GetFrequency(); + int frequencyIndex = -1; + for( int ii = 0; ii < managedFrequencies->Length; ++ii ) + { + if( frequency == managedFrequencies[ii] ) + { + frequencyIndex = ii; + break; + } + } + if( frequencyIndex == -1 ) + { + return false; + } + return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); + } + + bool SendHighVoltage( unsigned char voltage ) + { + return Wrapped->SendHighVoltage( voltage ); + } + + bool EnableHighVoltage() + { + return Wrapped->EnableHighVoltage(); + } + + bool DisableHighVoltage() + { + return Wrapped->DisableHighVoltage(); + } + + bool SendDynamic( unsigned char dynamic ) + { + return Wrapped->SendDynamic( dynamic ); + } + + bool StartMotor() + { + return Wrapped->StartMotor(); + } + + bool StopMotor() + { + return Wrapped->StopMotor(); + } + + void EnableHardButton() + { + Wrapped->EnableHardButton(); + } + + void DisableHardButton() + { + Wrapped->DisableHardButton(); + } + + unsigned char ReadHardButton() + { + return Wrapped->ReadHardButton(); + } + + bool StartBmode() + { + return Wrapped->StartBmode(); + } + + bool StartRFmode() + { + return Wrapped->StartRFmode(); + } + + bool StopAcquisition() + { + return Wrapped->StopAcquisition(); + } + + short GetProbeFrameRate( int depth ) + { + return Wrapped->GetProbeFrameRate( depth ); + } + + std::string GetProbeSerialNumber() + { + return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); + } - std::string ReadFPGAVersion() - { - return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); - } - - std::string GetOEMId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); - } - - std::string GetFilterId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); - } + std::string ReadFPGAVersion() + { + return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); + } + + std::string GetOEMId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); + } + + std::string GetFilterId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); + } + + bool EnableRFDecimator() + { + return Wrapped->EnableRFDecimator(); + } + + bool DisableRFDecimator() + { + return Wrapped->DisableRFDecimator(); + } + + private: + gcroot< Interson::Controls::HWControls ^ > Wrapped; + }; + + // C++ + #pragma unmanaged + + HWControls + ::HWControls(): + Impl( new HWControlsImpl() ) + { + } + + + HWControls + ::~HWControls() + { + delete Impl; + } + + + unsigned char + HWControls + ::GetProbeID() const + { + return Impl->GetProbeID(); + } + + + void + HWControls + ::FindAllProbes( FoundProbesType & foundProbes ) const + { + Impl->FindAllProbes( foundProbes ); + } + + + void + HWControls + ::FindMyProbe( int probeIndex ) + { + Impl->FindMyProbe( probeIndex ); + } + + int + HWControls + ::ValidDepth( int depth ) const + { + return Impl->ValidDepth( depth ); + } + + + void + HWControls + ::GetFrequency( FrequenciesType & frequencies ) const + { + Impl->GetFrequency( frequencies ); + } + + + bool + HWControls + ::SetFrequency( int frequency ) + { + return Impl->SetFrequency( frequency ); + } + + + bool + HWControls + ::SendHighVoltage( unsigned char voltage ) + { + return Impl->SendHighVoltage( voltage ); + } + + + bool + HWControls + ::EnableHighVoltage() + { + return Impl->EnableHighVoltage(); + } + + + bool + HWControls + ::DisableHighVoltage() + { + return Impl->DisableHighVoltage(); + } + + + bool + HWControls + ::SendDynamic( unsigned char dynamic ) + { + return Impl->SendDynamic( dynamic ); + } - bool EnableRFDecimator() - { - return Wrapped->EnableRFDecimator(); - } - bool DisableRFDecimator() - { - return Wrapped->DisableRFDecimator(); - } - -private: - gcroot< Interson::Controls::HWControls ^ > Wrapped; -}; - - -#pragma unmanaged + bool + HWControls + ::StartMotor() + { + return Impl->StartMotor(); + } -HWControls -::HWControls(): - Impl( new HWControlsImpl() ) -{ -} + + bool + HWControls + ::StopMotor() + { + return Impl->StopMotor(); + } + + + void + HWControls + ::EnableHardButton() + { + Impl->EnableHardButton(); + } + + + void + HWControls + ::DisableHardButton() + { + Impl->DisableHardButton(); + } + + + unsigned char + HWControls + ::ReadHardButton() + { + return Impl->ReadHardButton(); + } + + + bool + HWControls + ::StartBmode() + { + return Impl->StartBmode(); + } -HWControls -::~HWControls() -{ - delete Impl; -} + bool + HWControls + ::StartRFmode() + { + return Impl->StartRFmode(); + } -unsigned char -HWControls -::GetProbeID() const -{ - return Impl->GetProbeID(); -} + bool + HWControls + ::StopAcquisition() + { + return Impl->StopAcquisition(); + } -void -HWControls -::FindAllProbes( FoundProbesType & foundProbes ) const -{ - Impl->FindAllProbes( foundProbes ); -} + short + HWControls + ::GetProbeFrameRate( int depth ) + { + return Impl->GetProbeFrameRate( depth ); + } -void -HWControls -::FindMyProbe( int probeIndex ) -{ - Impl->FindMyProbe( probeIndex ); -} + std::string + HWControls + ::GetProbeSerialNumber() const + { + return Impl->GetProbeSerialNumber(); + } -int -HWControls -::ValidDepth( int depth ) const -{ - return Impl->ValidDepth( depth ); -} + std::string + HWControls + ::ReadFPGAVersion() const + { + return Impl->ReadFPGAVersion(); + } -void -HWControls -::GetFrequency( FrequenciesType & frequencies ) const -{ - Impl->GetFrequency( frequencies ); -} + std::string + HWControls + ::GetOEMId() const + { + return Impl->GetOEMId(); + } -bool -HWControls -::SetFrequency( int frequency ) -{ - return Impl->SetFrequency( frequency ); -} + std::string + HWControls + ::GetFilterId() const + { + return Impl->GetFilterId(); + } -bool -HWControls -::SendHighVoltage( unsigned char voltage ) -{ - return Impl->SendHighVoltage( voltage ); -} - -bool -HWControls -::EnableHighVoltage() -{ - return Impl->EnableHighVoltage(); -} - - -bool -HWControls -::DisableHighVoltage() -{ - return Impl->DisableHighVoltage(); -} - - -bool -HWControls -::SendDynamic( unsigned char dynamic ) -{ - return Impl->SendDynamic( dynamic ); -} - - -bool -HWControls -::StartMotor() -{ - return Impl->StartMotor(); -} - - -bool -HWControls -::StopMotor() -{ - return Impl->StopMotor(); -} - - -void -HWControls -::EnableHardButton() -{ - Impl->EnableHardButton(); -} + bool + HWControls + ::EnableRFDecimator() + { + return Impl->EnableRFDecimator(); + } -void -HWControls -::DisableHardButton() -{ - Impl->DisableHardButton(); -} - - -unsigned char -HWControls -::ReadHardButton() -{ - return Impl->ReadHardButton(); -} - - -bool -HWControls -::StartBmode() -{ - return Impl->StartBmode(); -} - - -bool -HWControls -::StartRFmode() -{ - return Impl->StartRFmode(); -} - - -bool -HWControls -::StopAcquisition() -{ - return Impl->StopAcquisition(); -} - - -short -HWControls -::GetProbeFrameRate( int depth ) -{ - return Impl->GetProbeFrameRate( depth ); -} - - -std::string -HWControls -::GetProbeSerialNumber() const -{ - return Impl->GetProbeSerialNumber(); -} - - -std::string -HWControls -::ReadFPGAVersion() const -{ - return Impl->ReadFPGAVersion(); -} - - -std::string -HWControls -::GetOEMId() const -{ - return Impl->GetOEMId(); -} - - -std::string -HWControls -::GetFilterId() const -{ - return Impl->GetFilterId(); -} - - -bool -HWControls -::EnableRFDecimator() -{ - return Impl->EnableRFDecimator(); -} - - -bool -HWControls -::DisableRFDecimator() -{ - return Impl->DisableRFDecimator(); -} + bool + HWControls + ::DisableRFDecimator() + { + return Impl->DisableRFDecimator(); + } -} // end namespace Controls + } // end namespace Controls } // end namespace IntersonCxx diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 6eaddee..8cd135d 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -1,409 +1,424 @@ -#pragma unmanaged -#include "IntersonCxxImagingScan2DClass.h" - -#pragma managed - -#include -#include - -#using "Interson.dll" -// for Bitmap -#using "System.Drawing.dll" - -namespace IntersonCxx -{ - -namespace Imaging -{ - -ref class NewRFImageHandler -{ -public: - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; - typedef cli::array< unsigned short, 2 > RFArrayType; - - NewRFImageHandler( RFArrayType ^ managedRFBuffer ): - NewRFImageCallback( NULL ), - NewRFImageCallbackClientData( NULL ), - NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedRFBuffer( managedRFBuffer ) - { - } - - ~NewRFImageHandler() - { - delete [] NativeRFBuffer; - } - - void HandleNewRFImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) - { - if( this->NewRFImageCallback != NULL ) - { - for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) - { - for( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) - { - this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; - } - } - this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); - } - } - - void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData ) - { - this->NewRFImageCallback = callback; - this->NewRFImageCallbackClientData = clientData; - } - -private: - NewRFImageCallbackType NewRFImageCallback; - void * NewRFImageCallbackClientData; - RFPixelType * NativeRFBuffer; - RFArrayType ^ ManagedRFBuffer; -}; - - -ref class NewBmodeImageHandler -{ -public: - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; - typedef cli::array< byte, 2 > BmodeArrayType; - - NewBmodeImageHandler( BmodeArrayType ^ managedBmodeBuffer ): - NewBmodeImageCallback( NULL ), - NewBmodeImageCallbackClientData( NULL ), - NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedBmodeBuffer( managedBmodeBuffer ), - NewScanConvertedBmodeImageCallback( NULL ), - NewScanConvertedBmodeImageCallbackClientData( NULL ), - ScanConvertedBmodeBuffer( new BmodePixelType[0] ) - { - ScanConverter = gcnew Interson::Imaging::ScanConverter(); - } - - ~NewBmodeImageHandler() - { - delete [] NativeBmodeBuffer; - delete [] ScanConvertedBmodeBuffer; - } - - void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) - { - if( this->NewBmodeImageCallback != NULL ) - { - for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) - { - for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) - { - this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = - this->ManagedBmodeBuffer[ii, jj]; - } - } - this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); - } - - if( this->NewScanConvertedBmodeImageCallback != NULL ) - { - scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); - for( int ii = 0; ii < ScanConvertedBmode->Height; ++ii ) - { - for( int jj = 0; jj < ScanConvertedBmode->Width; ++jj ) - { - // Assume it is grayscale, i.e. R = G = B - this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * ii + jj] = - static_cast< BmodePixelType >( ScanConvertedBmode->GetPixel( jj, ii ).B ); - } - } - this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); - } - } - - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData ) - { - this->NewBmodeImageCallback = callback; - this->NewBmodeImageCallbackClientData = clientData; - } - - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData ) - { - this->NewScanConvertedBmodeImageCallback = callback; - this->NewScanConvertedBmodeImageCallbackClientData = clientData; - - ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, - ScanConverter->HeightScan, - System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - delete [] ScanConvertedBmodeBuffer; - ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; - } - -private: - NewBmodeImageCallbackType NewBmodeImageCallback; - void * NewBmodeImageCallbackClientData; - BmodePixelType * NativeBmodeBuffer; - BmodeArrayType ^ ManagedBmodeBuffer; - System::Drawing::Bitmap ^ ScanConvertedBmode; - - NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; - void * NewScanConvertedBmodeImageCallbackClientData; - Interson::Imaging::ScanConverter ^ ScanConverter; - BmodePixelType * ScanConvertedBmodeBuffer; -}; - - -class Scan2DClassImpl -{ -public: - typedef cli::array< byte, 2 > BmodeArrayType; - typedef cli::array< unsigned short, 2 > RFArrayType; - - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - - Scan2DClassImpl() - { - Wrapped = gcnew Interson::Imaging::Scan2DClass(); - - BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_SAMPLES ); - BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); - BmodeHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, - &NewBmodeImageHandler::HandleNewBmodeImage ); - Wrapped->NewImageTick += BmodeHandlerDelegate; - - RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); - RFHandler = gcnew NewRFImageHandler( RFBuffer ); - RFHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, - &NewRFImageHandler::HandleNewRFImage ); - Wrapped->NewImageTick += RFHandlerDelegate; - } - - ~Scan2DClassImpl() - { - Wrapped->NewImageTick -= RFHandlerDelegate; - Wrapped->NewImageTick -= BmodeHandlerDelegate; - } - - bool GetScanOn() - { - return Wrapped->ScanOn; - } - - bool GetRFData() - { - return Wrapped->RFData; - } - - void SetRFData( bool transferOn ) - { - Wrapped->RFData = transferOn; - } - - bool GetFrameAvg() - { - return Wrapped->FrameAvg; - } - - void SetFrameAvg( bool doAveraging ) - { - return Wrapped->FrameAvg = doAveraging; - } - - double GetTrueDepth() - { - return Wrapped->TrueDepth; - } - - void StartReadScan() - { - Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); - } - - void StartRFReadScan() - { - Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); - } - - void StopReadScan() - { - Wrapped->StopReadScan(); - } - - void DisposeScan() - { - Wrapped->DisposeScan(); - } - - void AbortScan() - { - Wrapped->AbortScan(); - } - - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = 0 ) - { - this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); - } - - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData = 0 ) - { - this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); - } - - void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData = 0 ) - { - this->RFHandler->SetNewRFImageCallback( callback, clientData ); - } - - -private: - gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; - - gcroot< BmodeArrayType ^ > BmodeBuffer; - gcroot< RFArrayType ^ > RFBuffer; - gcroot< NewBmodeImageHandler ^ > BmodeHandler; - gcroot< NewRFImageHandler ^ > RFHandler; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; - -}; - - -#pragma unmanaged - -Scan2DClass -::Scan2DClass(): - Impl( new Scan2DClassImpl() ) -{ -} - - -Scan2DClass -::~Scan2DClass() -{ - delete Impl; -} - - -bool -Scan2DClass -::GetScanOn() const -{ - return Impl->GetScanOn(); -} - - -bool -Scan2DClass -::GetRFData() const -{ - return Impl->GetRFData(); -} - - -void -Scan2DClass -::SetRFData( bool transferOn ) -{ - Impl->SetRFData( transferOn ); -} - - -bool -Scan2DClass -::GetFrameAvg() const -{ - return Impl->GetFrameAvg(); -} - -void -Scan2DClass -::SetFrameAvg( bool doAveraging ) -{ - Impl->SetFrameAvg( doAveraging ); -} - - -void -Scan2DClass -::StartReadScan() -{ - Impl->StartReadScan(); -} - - -void -Scan2DClass -::StartRFReadScan() -{ - Impl->StartRFReadScan(); -} - - -void -Scan2DClass -::StopReadScan() -{ - Impl->StopReadScan(); -} - - -void -Scan2DClass -::DisposeScan() -{ - Impl->DisposeScan(); -} - - -void -Scan2DClass -::AbortScan() -{ - Impl->AbortScan(); -} - - -void -Scan2DClass -::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, - void * clientData ) -{ - Impl->SetNewBmodeImageCallback( callback, clientData ); -} - - -void -Scan2DClass -::SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void * clientData ) -{ - Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); -} - - -void -Scan2DClass -::SetNewRFImageCallback( NewRFImageCallbackType callback, - void * clientData ) -{ - Impl->SetNewRFImageCallback( callback, clientData ); -} - - -double -Scan2DClass -::GetTrueDepth() const -{ - return Impl->GetTrueDepth(); -} - -} // end namespace Imaging - -} // end namespace IntersonCxx +#pragma unmanaged +#include "IntersonCxxImagingScan2DClass.h" + +#pragma managed + +#include +#include + +#using "Interson.dll" +// for Bitmap +#using "System.Drawing.dll" + +namespace IntersonCxx +{ + +namespace Imaging +{ + +ref class NewRFImageHandler +{ +public: + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; + typedef cli::array< unsigned short, 2 > RFArrayType; + + NewRFImageHandler( RFArrayType ^ managedRFBuffer ): + NewRFImageCallback( NULL ), + NewRFImageCallbackClientData( NULL ), + NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedRFBuffer( managedRFBuffer ) + { + } + + ~NewRFImageHandler() + { + delete [] NativeRFBuffer; + } + + void HandleNewRFImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) + { + if( this->NewRFImageCallback != NULL ) + { + for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) + { + this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; + } + } + this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); + } + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData ) + { + this->NewRFImageCallback = callback; + this->NewRFImageCallbackClientData = clientData; + } + +private: + NewRFImageCallbackType NewRFImageCallback; + void * NewRFImageCallbackClientData; + RFPixelType * NativeRFBuffer; + RFArrayType ^ ManagedRFBuffer; +}; + + +ref class NewBmodeImageHandler +{ +public: + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; + typedef cli::array< byte, 2 > BmodeArrayType; + + NewBmodeImageHandler( BmodeArrayType ^ managedBmodeBuffer ): + NewBmodeImageCallback( NULL ), + NewBmodeImageCallbackClientData( NULL ), + NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedBmodeBuffer( managedBmodeBuffer ), + NewScanConvertedBmodeImageCallback( NULL ), + NewScanConvertedBmodeImageCallbackClientData( NULL ), + ScanConvertedBmodeBuffer( new BmodePixelType[0] ) + { + ScanConverter = gcnew Interson::Imaging::ScanConverter(); + } + + ~NewBmodeImageHandler() + { + delete [] NativeBmodeBuffer; + delete [] ScanConvertedBmodeBuffer; + } + + void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) + { + if( this->NewBmodeImageCallback != NULL ) + { + for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) + { + this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = + this->ManagedBmodeBuffer[ii, jj]; + } + } + this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); + } + + if( this->NewScanConvertedBmodeImageCallback != NULL ) + { + scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); + + System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, ScanConvertedBmode->Width, ScanConvertedBmode->Height); + System::Drawing::Imaging::BitmapData ^ bData = ScanConvertedBmode->LockBits( + rect , + System::Drawing::Imaging::ImageLockMode::ReadWrite, + System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); + + byte* scan0 = (byte*)bData->Scan0.ToPointer(); + + for (int i = 0; i < bData->Height; ++i) + { + for (int j = 0; j < bData->Width; ++j) + { + byte* data = scan0 + i * bData->Stride + j; + this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * i + j] = static_cast< BmodePixelType > (data[0]); + + } + } + + + + ScanConvertedBmode->UnlockBits(bData); + + this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); + } + } + + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData ) + { + this->NewBmodeImageCallback = callback; + this->NewBmodeImageCallbackClientData = clientData; + } + + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData ) + { + this->NewScanConvertedBmodeImageCallback = callback; + this->NewScanConvertedBmodeImageCallbackClientData = clientData; + + ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, + ScanConverter->HeightScan, + System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); + delete [] ScanConvertedBmodeBuffer; + ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; + } + +private: + NewBmodeImageCallbackType NewBmodeImageCallback; + void * NewBmodeImageCallbackClientData; + BmodePixelType * NativeBmodeBuffer; + BmodeArrayType ^ ManagedBmodeBuffer; + System::Drawing::Bitmap ^ ScanConvertedBmode; + + NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; + void * NewScanConvertedBmodeImageCallbackClientData; + Interson::Imaging::ScanConverter ^ ScanConverter; + BmodePixelType * ScanConvertedBmodeBuffer; +}; + + +class Scan2DClassImpl +{ +public: + typedef cli::array< byte, 2 > BmodeArrayType; + typedef cli::array< unsigned short, 2 > RFArrayType; + + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; + + Scan2DClassImpl() + { + Wrapped = gcnew Interson::Imaging::Scan2DClass(); + + BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS , Scan2DClass::MAX_SAMPLES); + BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); + BmodeHandlerDelegate = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, + &NewBmodeImageHandler::HandleNewBmodeImage ); + Wrapped->NewImageTick += BmodeHandlerDelegate; + + RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); + RFHandler = gcnew NewRFImageHandler( RFBuffer ); + RFHandlerDelegate = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, + &NewRFImageHandler::HandleNewRFImage ); + Wrapped->NewImageTick += RFHandlerDelegate; + + } + + ~Scan2DClassImpl() + { + Wrapped->NewImageTick -= RFHandlerDelegate; + Wrapped->NewImageTick -= BmodeHandlerDelegate; + } + + bool GetScanOn() + { + return Wrapped->ScanOn; + } + + bool GetRFData() + { + return Wrapped->RFData; + } + + void SetRFData( bool transferOn ) + { + Wrapped->RFData = transferOn; + } + + bool GetFrameAvg() + { + return Wrapped->FrameAvg; + } + + void SetFrameAvg( bool doAveraging ) + { + return Wrapped->FrameAvg = doAveraging; + } + + double GetTrueDepth() + { + return Wrapped->TrueDepth; + } + + void StartReadScan() + { + Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); + } + + void StartRFReadScan() + { + Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); + } + + void StopReadScan() + { + Wrapped->StopReadScan(); + } + + void DisposeScan() + { + Wrapped->DisposeScan(); + } + + void AbortScan() + { + Wrapped->AbortScan(); + } + + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = 0 ) + { + this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); + } + + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData = 0 ) + { + this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData = 0 ) + { + this->RFHandler->SetNewRFImageCallback( callback, clientData ); + } + + +private: + gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; + + gcroot< BmodeArrayType ^ > BmodeBuffer; + gcroot< RFArrayType ^ > RFBuffer; + gcroot< NewBmodeImageHandler ^ > BmodeHandler; + gcroot< NewRFImageHandler ^ > RFHandler; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; + +}; + + +#pragma unmanaged + +Scan2DClass +::Scan2DClass(): + Impl( new Scan2DClassImpl() ) +{ +} + + +Scan2DClass +::~Scan2DClass() +{ + delete Impl; +} + + +bool +Scan2DClass +::GetScanOn() const +{ + return Impl->GetScanOn(); +} + + +bool +Scan2DClass +::GetRFData() const +{ + return Impl->GetRFData(); +} + + +void +Scan2DClass +::SetRFData( bool transferOn ) +{ + Impl->SetRFData( transferOn ); +} + + +bool +Scan2DClass +::GetFrameAvg() const +{ + return Impl->GetFrameAvg(); +} + +void +Scan2DClass +::SetFrameAvg( bool doAveraging ) +{ + Impl->SetFrameAvg( doAveraging ); +} + + +void +Scan2DClass +::StartReadScan() +{ + Impl->StartReadScan(); +} + + +void +Scan2DClass +::StartRFReadScan() +{ + Impl->StartRFReadScan(); +} + + +void +Scan2DClass +::StopReadScan() +{ + Impl->StopReadScan(); +} + + +void +Scan2DClass +::DisposeScan() +{ + Impl->DisposeScan(); +} + + +void +Scan2DClass +::AbortScan() +{ + Impl->AbortScan(); +} + + +void +Scan2DClass +::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, + void * clientData ) +{ + Impl->SetNewBmodeImageCallback( callback, clientData ); +} + + +void +Scan2DClass +::SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, + void * clientData ) +{ + Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); +} + + +void +Scan2DClass +::SetNewRFImageCallback( NewRFImageCallbackType callback, + void * clientData ) +{ + Impl->SetNewRFImageCallback( callback, clientData ); +} + + +double +Scan2DClass +::GetTrueDepth() const +{ + return Impl->GetTrueDepth(); +} + +} // end namespace Imaging + +} // end namespace IntersonCxx diff --git a/src/IntersonCxxIntersonClass.cxx b/src/IntersonCxxIntersonClass.cxx index 1a0f930..743a61d 100644 --- a/src/IntersonCxxIntersonClass.cxx +++ b/src/IntersonCxxIntersonClass.cxx @@ -1,53 +1,53 @@ -#pragma unmanaged +// C++ +#pragma unmanaged #include "IntersonCxxIntersonClass.h" +// C# #pragma managed #include #include +// Add library from SDK #using "Interson.dll" namespace IntersonCxx { - -class IntersonClassImpl -{ -public: - IntersonClassImpl() - { - } - - std::string Version() - { - std::string marshalled = msclr::interop::marshal_as< std::string >( - Interson::IntersonClass::Version ); - return marshalled; - } - -private: -}; - - + // Wrapper Class for IntersonClass from SDK + class IntersonClassImpl + { + public: + IntersonClassImpl() + { + } + // Wrapped method for IntersonClass from SDK + std::string Version() + { + //This method converts data between native and managed environments. http://msdn.microsoft.com/en-us/library/bb384859.aspx + std::string marshalled = msclr::interop::marshal_as< std::string >(Interson::IntersonClass::Version ); + return marshalled; + } + + private: + }; + + +// C++ #pragma unmanaged -IntersonClass -::IntersonClass(): - Impl( new IntersonClassImpl() ) -{ -} + IntersonClass::IntersonClass(): + Impl( new IntersonClassImpl() ) + { + } -IntersonClass -::~IntersonClass() -{ - delete Impl; -} + IntersonClass::~IntersonClass() + { + delete Impl; + } -std::string -IntersonClass -::Version() const -{ - return Impl->Version(); -} + std::string IntersonClass::Version() const + { + return Impl->Version(); + } } // end namespace IntersonCxx From 7a4b9616b658212954f94a9f2624eb12c582aa4d Mon Sep 17 00:00:00 2001 From: marinetto Date: Thu, 16 Oct 2014 09:15:09 -0400 Subject: [PATCH 059/103] White Spaces deleted and UTF-8 formatting --- include/IntersonCxxControlsHWControls.h | 6 +- include/IntersonCxxImagingScan2DClass.h | 70 +- include/IntersonCxxImagingScanConverter.h | 64 +- include/IntersonCxxIntersonClass.h | 52 +- src/IntersonCxxControlsHWControls.cxx | 736 +++++++++++----------- src/IntersonCxxImagingScan2DClass.cxx | 356 +++++------ src/IntersonCxxImagingScanConverter.cxx | 88 +-- src/IntersonCxxIntersonClass.cxx | 60 +- 8 files changed, 716 insertions(+), 716 deletions(-) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index 0812991..f538a8e 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -10,9 +10,9 @@ // Namespace similar to Interson Namespace from SDK /* -The library is organized via namespaces; the root is “Interson”, -then “Interson.Controls” to get the methods which access to the -USB probe controls, “Interson.Imaging” is the scan converter, to +The library is organized via namespaces; the root is Interson, +then Interson.Controls to get the methods which access to the +USB probe controls, Interson.Imaging is the scan converter, to build the 2D image B-Scan bitmap from the log-compressed A-Scan vectors. */ diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index 332af0a..cf1314c 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -17,54 +17,54 @@ class Scan2DClassImpl; class IntersonCxx_EXPORT Scan2DClass { public: - Scan2DClass(); - ~Scan2DClass(); + Scan2DClass(); + ~Scan2DClass(); - static const int MAX_SAMPLES = 1024; - static const int MAX_RFSAMPLES = 2048; - static const int MAX_VECTORS = 241; + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + static const int MAX_VECTORS = 241; - typedef unsigned char BmodePixelType; - typedef short RFPixelType; + typedef unsigned char BmodePixelType; + typedef short RFPixelType; - bool GetScanOn() const; + bool GetScanOn() const; - bool GetRFData() const; - void SetRFData( bool transferOn ); + bool GetRFData() const; + void SetRFData( bool transferOn ); - bool GetFrameAvg() const; - void SetFrameAvg( bool doAveraging ); + bool GetFrameAvg() const; + void SetFrameAvg( bool doAveraging ); - double GetTrueDepth() const; + double GetTrueDepth() const; - void StartReadScan(); - void StartRFReadScan(); - void StopReadScan(); - void DisposeScan(); - void AbortScan(); + void StartReadScan(); + void StartRFReadScan(); + void StopReadScan(); + void DisposeScan(); + void AbortScan(); - typedef void (__stdcall * NewBmodeImageCallbackType)( BmodePixelType * buffer, - void * clientData ); - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, - void * clientData = NULL ); + typedef void (__stdcall *NewBmodeImageCallbackType)( BmodePixelType *buffer, + void *clientData ); + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, + void *clientData = NULL ); - typedef void (__stdcall * NewScanConvertedBmodeImageCallbackType)( BmodePixelType * buffer, - void * clientData ); - /** \warning The WidthScan and HeightScan must be initialized on the - * ScanConverter before calling this method. */ - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void * clientData = NULL ); + typedef void (__stdcall *NewScanConvertedBmodeImageCallbackType)( BmodePixelType *buffer, + void *clientData ); + /** \warning The WidthScan and HeightScan must be initialized on the + * ScanConverter before calling this method. */ + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, + void *clientData = NULL ); - typedef void (__stdcall * NewRFImageCallbackType)( RFPixelType * buffer, - void * clientData ); - void SetNewRFImageCallback( NewRFImageCallbackType callback, - void * clientData = NULL ); + typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, + void *clientData ); + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData = NULL ); private: - Scan2DClass( const Scan2DClass & ); - void operator=( const Scan2DClass & ); + Scan2DClass( const Scan2DClass &); + void operator=( const Scan2DClass &); - Scan2DClassImpl * Impl; + Scan2DClassImpl *Impl; }; } // end namespace Imaging diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h index 3b840c8..e488f49 100644 --- a/include/IntersonCxxImagingScanConverter.h +++ b/include/IntersonCxxImagingScanConverter.h @@ -14,49 +14,49 @@ class ScanConverterImpl; class IntersonCxx_EXPORT ScanConverter { public: - ScanConverter(); - ~ScanConverter(); + ScanConverter(); + ~ScanConverter(); - static const int MAX_SAMPLES = 1024; - static const int MAX_RFSAMPLES = 2048; - static const int MAX_VECTORS = 241; + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + static const int MAX_VECTORS = 241; - // Error code of HardInitScanConverter and SoftInitScanConverter - enum ScanConverterError + // Error code of HardInitScanConverter and SoftInitScanConverter + enum ScanConverterError { - SUCCESS = 1, - PROBE_NOT_INITIALIZED, // FindMyProbe has not been called - UNKNOWN_PROBE, // Probe Identity not valid - UNDER_LIMITS, // Width * Height over 10 * 10 - OVER_LIMITS, // Width * Height over 800 * 1000 - OTHER_ERROR // other error + SUCCESS = 1, + PROBE_NOT_INITIALIZED, // FindMyProbe has not been called + UNKNOWN_PROBE, // Probe Identity not valid + UNDER_LIMITS, // Width * Height over 10 * 10 + OVER_LIMITS, // Width * Height over 800 * 1000 + OTHER_ERROR // other error }; - int GetHeightScan() const; - int GetWidthScan() const; + int GetHeightScan() const; + int GetWidthScan() const; - float GetMmPerPixel() const; - int GetZeroOfYScale() const; + float GetMmPerPixel() const; + int GetZeroOfYScale() const; - // Optimal iHeightScan is 512. Optimal iWidthScan is 776 for 90 degree (GP, SP, EC) probes, and 590 for a 60 degree (VC) probe. - ScanConverterError HardInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan ); + // Optimal iHeightScan is 512. Optimal iWidthScan is 776 for 90 degree (GP, SP, EC) probes, and 590 for a 60 degree (VC) probe. + ScanConverterError HardInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan ); - ScanConverterError IdleInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan, - unsigned char probeId ); + ScanConverterError IdleInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan, + unsigned char probeId ); private: - ScanConverter( const ScanConverter & ); - void operator=( const ScanConverter & ); + ScanConverter( const ScanConverter &); + void operator=( const ScanConverter &); - ScanConverterImpl * Impl; + ScanConverterImpl *Impl; }; } // end namespace Imaging diff --git a/include/IntersonCxxIntersonClass.h b/include/IntersonCxxIntersonClass.h index 8697a3f..e8ca0cf 100644 --- a/include/IntersonCxxIntersonClass.h +++ b/include/IntersonCxxIntersonClass.h @@ -10,36 +10,36 @@ /* The library is organized via namespaces; the root is “Interson”, -then “Interson.Controls” to get the methods which access to the -USB probe controls, “Interson.Imaging” is the scan converter, to -build the 2D image B-Scan bitmap from the log-compressed A-Scan +then “Interson.Controls” to get the methods which access to the +USB probe controls, “Interson.Imaging” is the scan converter, to +build the 2D image B-Scan bitmap from the log-compressed A-Scan vectors. */ namespace IntersonCxx { - // Wrapper Class for IntersonClass from SDK - class IntersonClassImpl; - - // IntersonClass similar to IntersonClass from SDK - class IntersonCxx_EXPORT IntersonClass - { - public: - IntersonClass(); - ~IntersonClass(); - - /* - Summary: To Get the version of Interson.dll - Returns: Returns the String of the version. - */ - std::string Version() const; - - private: - IntersonClass( const IntersonClass & ); - void operator=( const IntersonClass & ); - - // Add the wrapper to the main class to use dll function in C# - IntersonClassImpl * Impl; - }; +// Wrapper Class for IntersonClass from SDK +class IntersonClassImpl; + +// IntersonClass similar to IntersonClass from SDK +class IntersonCxx_EXPORT IntersonClass +{ +public: + IntersonClass(); + ~IntersonClass(); + + /* + Summary: To Get the version of Interson.dll + Returns: Returns the String of the version. + */ + std::string Version() const; + +private: + IntersonClass( const IntersonClass &); + void operator=( const IntersonClass &); + + // Add the wrapper to the main class to use dll function in C# + IntersonClassImpl *Impl; +}; } // end namespace IntersonCxx diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index 8c510c7..c0ceaa4 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -14,395 +14,395 @@ namespace IntersonCxx { - namespace Controls - { - // Wrapper Class for IntersonClass from SDK - class HWControlsImpl - { - public: - // New defininions look header file - typedef HWControls::FoundProbesType FoundProbesType; - typedef HWControls::FrequenciesType FrequenciesType; - - - HWControlsImpl() - { - // New method for managed code. Wrapped is data member or this class - Wrapped = gcnew Interson::Controls::HWControls(); - } - - unsigned char GetProbeID() - { - return Wrapped->GetProbeID(); - } - - void FindAllProbes( FoundProbesType & foundProbes ) - { - System::Collections::Specialized::StringCollection ^ managedProbes = - gcnew System::Collections::Specialized::StringCollection(); - Wrapped->FindAllProbes( managedProbes );; - foundProbes.resize( managedProbes->Count ); - // Copy all available probes to the C++ class - for( int ii = 0; ii < managedProbes->Count; ++ii ) - { - foundProbes[ii] = msclr::interop::marshal_as< std::string >( - managedProbes[ii] ); - } - } - - void FindMyProbe( int probeIndex ) - { - Wrapped->FindMyProbe( probeIndex ); - } - - int ValidDepth( int depth ) - { - return Wrapped->ValidDepth( depth ); - } - - void GetFrequency( FrequenciesType & frequencies ) - { - array< int > ^ managedFrequencies = Wrapped->GetFrequency(); - frequencies.resize( managedFrequencies->Length ); - for( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - frequencies[ii] = managedFrequencies[ii]; - } - } - - bool SetFrequency( int frequency ) - { - array< int > ^ managedFrequencies = Wrapped->GetFrequency(); - int frequencyIndex = -1; - for( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - if( frequency == managedFrequencies[ii] ) - { - frequencyIndex = ii; - break; - } - } - if( frequencyIndex == -1 ) - { - return false; - } - return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); - } - - bool SendHighVoltage( unsigned char voltage ) - { - return Wrapped->SendHighVoltage( voltage ); - } - - bool EnableHighVoltage() - { - return Wrapped->EnableHighVoltage(); - } - - bool DisableHighVoltage() - { - return Wrapped->DisableHighVoltage(); - } - - bool SendDynamic( unsigned char dynamic ) - { - return Wrapped->SendDynamic( dynamic ); - } - - bool StartMotor() - { - return Wrapped->StartMotor(); - } - - bool StopMotor() - { - return Wrapped->StopMotor(); - } - - void EnableHardButton() - { - Wrapped->EnableHardButton(); - } - - void DisableHardButton() - { - Wrapped->DisableHardButton(); - } - - unsigned char ReadHardButton() - { - return Wrapped->ReadHardButton(); - } - - bool StartBmode() - { - return Wrapped->StartBmode(); - } - - bool StartRFmode() - { - return Wrapped->StartRFmode(); - } - - bool StopAcquisition() - { - return Wrapped->StopAcquisition(); - } - - short GetProbeFrameRate( int depth ) - { - return Wrapped->GetProbeFrameRate( depth ); - } - - std::string GetProbeSerialNumber() - { - return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); - } - - std::string ReadFPGAVersion() - { - return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); - } - - std::string GetOEMId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); - } - - std::string GetFilterId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); - } - - bool EnableRFDecimator() - { - return Wrapped->EnableRFDecimator(); - } - - bool DisableRFDecimator() - { - return Wrapped->DisableRFDecimator(); - } - - private: - gcroot< Interson::Controls::HWControls ^ > Wrapped; - }; - - // C++ - #pragma unmanaged - - HWControls - ::HWControls(): - Impl( new HWControlsImpl() ) - { - } - - - HWControls - ::~HWControls() - { - delete Impl; - } - - - unsigned char - HWControls - ::GetProbeID() const - { - return Impl->GetProbeID(); - } - - - void - HWControls - ::FindAllProbes( FoundProbesType & foundProbes ) const - { - Impl->FindAllProbes( foundProbes ); - } - - - void - HWControls - ::FindMyProbe( int probeIndex ) - { - Impl->FindMyProbe( probeIndex ); - } - - int - HWControls - ::ValidDepth( int depth ) const - { - return Impl->ValidDepth( depth ); - } - - - void - HWControls - ::GetFrequency( FrequenciesType & frequencies ) const - { - Impl->GetFrequency( frequencies ); - } - - - bool - HWControls - ::SetFrequency( int frequency ) - { - return Impl->SetFrequency( frequency ); - } - - - bool - HWControls - ::SendHighVoltage( unsigned char voltage ) - { - return Impl->SendHighVoltage( voltage ); - } - - - bool - HWControls - ::EnableHighVoltage() - { - return Impl->EnableHighVoltage(); - } - - - bool - HWControls - ::DisableHighVoltage() - { - return Impl->DisableHighVoltage(); - } - - - bool - HWControls - ::SendDynamic( unsigned char dynamic ) - { - return Impl->SendDynamic( dynamic ); - } +namespace Controls +{ +// Wrapper Class for IntersonClass from SDK +class HWControlsImpl +{ +public: + // New defininions look header file + typedef HWControls::FoundProbesType FoundProbesType; + typedef HWControls::FrequenciesType FrequenciesType; + + + HWControlsImpl() + { + // New method for managed code. Wrapped is data member or this class + Wrapped = gcnew Interson::Controls::HWControls(); + } + + unsigned char GetProbeID() + { + return Wrapped->GetProbeID(); + } + + void FindAllProbes( FoundProbesType &foundProbes ) + { + System::Collections::Specialized::StringCollection ^managedProbes = + gcnew System::Collections::Specialized::StringCollection(); + Wrapped->FindAllProbes( managedProbes );; + foundProbes.resize( managedProbes->Count ); + // Copy all available probes to the C++ class + for ( int ii = 0; ii < managedProbes->Count; ++ii ) + { + foundProbes[ii] = msclr::interop::marshal_as< std::string >( + managedProbes[ii] ); + } + } + + void FindMyProbe( int probeIndex ) + { + Wrapped->FindMyProbe( probeIndex ); + } + + int ValidDepth( int depth ) + { + return Wrapped->ValidDepth( depth ); + } + + void GetFrequency( FrequenciesType &frequencies ) + { + array< int > ^managedFrequencies = Wrapped->GetFrequency(); + frequencies.resize( managedFrequencies->Length ); + for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) + { + frequencies[ii] = managedFrequencies[ii]; + } + } + + bool SetFrequency( int frequency ) + { + array< int > ^managedFrequencies = Wrapped->GetFrequency(); + int frequencyIndex = -1; + for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) + { + if ( frequency == managedFrequencies[ii] ) + { + frequencyIndex = ii; + break; + } + } + if ( frequencyIndex == -1 ) + { + return false; + } + return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); + } + + bool SendHighVoltage( unsigned char voltage ) + { + return Wrapped->SendHighVoltage( voltage ); + } + + bool EnableHighVoltage() + { + return Wrapped->EnableHighVoltage(); + } + + bool DisableHighVoltage() + { + return Wrapped->DisableHighVoltage(); + } + + bool SendDynamic( unsigned char dynamic ) + { + return Wrapped->SendDynamic( dynamic ); + } + + bool StartMotor() + { + return Wrapped->StartMotor(); + } + + bool StopMotor() + { + return Wrapped->StopMotor(); + } + + void EnableHardButton() + { + Wrapped->EnableHardButton(); + } + + void DisableHardButton() + { + Wrapped->DisableHardButton(); + } + + unsigned char ReadHardButton() + { + return Wrapped->ReadHardButton(); + } + + bool StartBmode() + { + return Wrapped->StartBmode(); + } + + bool StartRFmode() + { + return Wrapped->StartRFmode(); + } + + bool StopAcquisition() + { + return Wrapped->StopAcquisition(); + } + + short GetProbeFrameRate( int depth ) + { + return Wrapped->GetProbeFrameRate( depth ); + } + + std::string GetProbeSerialNumber() + { + return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); + } + + std::string ReadFPGAVersion() + { + return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); + } + + std::string GetOEMId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); + } + + std::string GetFilterId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); + } + + bool EnableRFDecimator() + { + return Wrapped->EnableRFDecimator(); + } + + bool DisableRFDecimator() + { + return Wrapped->DisableRFDecimator(); + } + +private: + gcroot< Interson::Controls::HWControls ^ > Wrapped; +}; + +// C++ +#pragma unmanaged + +HWControls +::HWControls(): + Impl( new HWControlsImpl() ) +{ +} + + +HWControls +::~HWControls() +{ + delete Impl; +} + + +unsigned char +HWControls +::GetProbeID() const +{ + return Impl->GetProbeID(); +} + + +void +HWControls +::FindAllProbes( FoundProbesType &foundProbes ) const +{ + Impl->FindAllProbes( foundProbes ); +} - bool - HWControls - ::StartMotor() - { - return Impl->StartMotor(); - } +void +HWControls +::FindMyProbe( int probeIndex ) +{ + Impl->FindMyProbe( probeIndex ); +} + +int +HWControls +::ValidDepth( int depth ) const +{ + return Impl->ValidDepth( depth ); +} + - - bool - HWControls - ::StopMotor() - { - return Impl->StopMotor(); - } - - - void - HWControls - ::EnableHardButton() - { - Impl->EnableHardButton(); - } - - - void - HWControls - ::DisableHardButton() - { - Impl->DisableHardButton(); - } - - - unsigned char - HWControls - ::ReadHardButton() - { - return Impl->ReadHardButton(); - } - - - bool - HWControls - ::StartBmode() - { - return Impl->StartBmode(); - } +void +HWControls +::GetFrequency( FrequenciesType &frequencies ) const +{ + Impl->GetFrequency( frequencies ); +} + + +bool +HWControls +::SetFrequency( int frequency ) +{ + return Impl->SetFrequency( frequency ); +} - bool - HWControls - ::StartRFmode() - { - return Impl->StartRFmode(); - } +bool +HWControls +::SendHighVoltage( unsigned char voltage ) +{ + return Impl->SendHighVoltage( voltage ); +} - bool - HWControls - ::StopAcquisition() - { - return Impl->StopAcquisition(); - } +bool +HWControls +::EnableHighVoltage() +{ + return Impl->EnableHighVoltage(); +} - short - HWControls - ::GetProbeFrameRate( int depth ) - { - return Impl->GetProbeFrameRate( depth ); - } +bool +HWControls +::DisableHighVoltage() +{ + return Impl->DisableHighVoltage(); +} - std::string - HWControls - ::GetProbeSerialNumber() const - { - return Impl->GetProbeSerialNumber(); - } +bool +HWControls +::SendDynamic( unsigned char dynamic ) +{ + return Impl->SendDynamic( dynamic ); +} - std::string - HWControls - ::ReadFPGAVersion() const - { - return Impl->ReadFPGAVersion(); - } +bool +HWControls +::StartMotor() +{ + return Impl->StartMotor(); +} - std::string - HWControls - ::GetOEMId() const - { - return Impl->GetOEMId(); - } +bool +HWControls +::StopMotor() +{ + return Impl->StopMotor(); +} - std::string - HWControls - ::GetFilterId() const - { - return Impl->GetFilterId(); - } +void +HWControls +::EnableHardButton() +{ + Impl->EnableHardButton(); +} - bool - HWControls - ::EnableRFDecimator() - { - return Impl->EnableRFDecimator(); - } +void +HWControls +::DisableHardButton() +{ + Impl->DisableHardButton(); +} - bool - HWControls - ::DisableRFDecimator() - { - return Impl->DisableRFDecimator(); - } +unsigned char +HWControls +::ReadHardButton() +{ + return Impl->ReadHardButton(); +} + + +bool +HWControls +::StartBmode() +{ + return Impl->StartBmode(); +} + + +bool +HWControls +::StartRFmode() +{ + return Impl->StartRFmode(); +} + + +bool +HWControls +::StopAcquisition() +{ + return Impl->StopAcquisition(); +} + + +short +HWControls +::GetProbeFrameRate( int depth ) +{ + return Impl->GetProbeFrameRate( depth ); +} + + +std::string +HWControls +::GetProbeSerialNumber() const +{ + return Impl->GetProbeSerialNumber(); +} + + +std::string +HWControls +::ReadFPGAVersion() const +{ + return Impl->ReadFPGAVersion(); +} + + +std::string +HWControls +::GetOEMId() const +{ + return Impl->GetOEMId(); +} + + +std::string +HWControls +::GetFilterId() const +{ + return Impl->GetFilterId(); +} + + +bool +HWControls +::EnableRFDecimator() +{ + return Impl->EnableRFDecimator(); +} + + +bool +HWControls +::DisableRFDecimator() +{ + return Impl->DisableRFDecimator(); +} - } // end namespace Controls +} // end namespace Controls } // end namespace IntersonCxx diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 8cd135d..9d96fc0 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -19,273 +19,273 @@ namespace Imaging ref class NewRFImageHandler { public: - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; - typedef cli::array< unsigned short, 2 > RFArrayType; - - NewRFImageHandler( RFArrayType ^ managedRFBuffer ): - NewRFImageCallback( NULL ), - NewRFImageCallbackClientData( NULL ), - NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedRFBuffer( managedRFBuffer ) + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; + typedef cli::array< unsigned short, 2 > RFArrayType; + + NewRFImageHandler( RFArrayType ^managedRFBuffer ): + NewRFImageCallback( NULL ), + NewRFImageCallbackClientData( NULL ), + NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedRFBuffer( managedRFBuffer ) { } - ~NewRFImageHandler() + ~NewRFImageHandler() { - delete [] NativeRFBuffer; + delete [] NativeRFBuffer; } - void HandleNewRFImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) + void HandleNewRFImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) { - if( this->NewRFImageCallback != NULL ) - { - for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + if ( this->NewRFImageCallback != NULL ) { - for( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) - { - this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; - } + for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for ( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) + { + this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; + } + } + this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); } - this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); - } } - void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData ) + void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) { - this->NewRFImageCallback = callback; - this->NewRFImageCallbackClientData = clientData; + this->NewRFImageCallback = callback; + this->NewRFImageCallbackClientData = clientData; } private: - NewRFImageCallbackType NewRFImageCallback; - void * NewRFImageCallbackClientData; - RFPixelType * NativeRFBuffer; - RFArrayType ^ ManagedRFBuffer; + NewRFImageCallbackType NewRFImageCallback; + void *NewRFImageCallbackClientData; + RFPixelType *NativeRFBuffer; + RFArrayType ^ManagedRFBuffer; }; ref class NewBmodeImageHandler { public: - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; - typedef cli::array< byte, 2 > BmodeArrayType; - - NewBmodeImageHandler( BmodeArrayType ^ managedBmodeBuffer ): - NewBmodeImageCallback( NULL ), - NewBmodeImageCallbackClientData( NULL ), - NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedBmodeBuffer( managedBmodeBuffer ), - NewScanConvertedBmodeImageCallback( NULL ), - NewScanConvertedBmodeImageCallbackClientData( NULL ), - ScanConvertedBmodeBuffer( new BmodePixelType[0] ) + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; + typedef cli::array< byte, 2 > BmodeArrayType; + + NewBmodeImageHandler( BmodeArrayType ^managedBmodeBuffer ): + NewBmodeImageCallback( NULL ), + NewBmodeImageCallbackClientData( NULL ), + NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedBmodeBuffer( managedBmodeBuffer ), + NewScanConvertedBmodeImageCallback( NULL ), + NewScanConvertedBmodeImageCallbackClientData( NULL ), + ScanConvertedBmodeBuffer( new BmodePixelType[0] ) { - ScanConverter = gcnew Interson::Imaging::ScanConverter(); + ScanConverter = gcnew Interson::Imaging::ScanConverter(); } - ~NewBmodeImageHandler() + ~NewBmodeImageHandler() { - delete [] NativeBmodeBuffer; - delete [] ScanConvertedBmodeBuffer; + delete [] NativeBmodeBuffer; + delete [] ScanConvertedBmodeBuffer; } - void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^ scan2D, System::EventArgs ^ eventArgs ) + void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) { - if( this->NewBmodeImageCallback != NULL ) - { - for( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + if ( this->NewBmodeImageCallback != NULL ) { - for( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) - { - this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = - this->ManagedBmodeBuffer[ii, jj]; - } + for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for ( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) + { + this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = + this->ManagedBmodeBuffer[ii, jj]; + } + } + this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); } - this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); - } - if( this->NewScanConvertedBmodeImageCallback != NULL ) - { - scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); + if ( this->NewScanConvertedBmodeImageCallback != NULL ) + { + scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); - System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, ScanConvertedBmode->Width, ScanConvertedBmode->Height); - System::Drawing::Imaging::BitmapData ^ bData = ScanConvertedBmode->LockBits( - rect , - System::Drawing::Imaging::ImageLockMode::ReadWrite, - System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); + System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, ScanConvertedBmode->Width, ScanConvertedBmode->Height); + System::Drawing::Imaging::BitmapData ^bData = ScanConvertedBmode->LockBits( + rect , + System::Drawing::Imaging::ImageLockMode::ReadWrite, + System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - byte* scan0 = (byte*)bData->Scan0.ToPointer(); + byte *scan0 = (byte *)bData->Scan0.ToPointer(); - for (int i = 0; i < bData->Height; ++i) - { - for (int j = 0; j < bData->Width; ++j) - { - byte* data = scan0 + i * bData->Stride + j; - this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * i + j] = static_cast< BmodePixelType > (data[0]); + for (int i = 0; i < bData->Height; ++i) + { + for (int j = 0; j < bData->Width; ++j) + { + byte *data = scan0 + i * bData->Stride + j; + this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * i + j] = static_cast< BmodePixelType > (data[0]); - } - } + } + } - ScanConvertedBmode->UnlockBits(bData); + ScanConvertedBmode->UnlockBits(bData); - this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); - } + this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); + } } - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData ) + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData ) { - this->NewBmodeImageCallback = callback; - this->NewBmodeImageCallbackClientData = clientData; + this->NewBmodeImageCallback = callback; + this->NewBmodeImageCallbackClientData = clientData; } - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData ) + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData ) { - this->NewScanConvertedBmodeImageCallback = callback; - this->NewScanConvertedBmodeImageCallbackClientData = clientData; - - ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, - ScanConverter->HeightScan, - System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - delete [] ScanConvertedBmodeBuffer; - ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; + this->NewScanConvertedBmodeImageCallback = callback; + this->NewScanConvertedBmodeImageCallbackClientData = clientData; + + ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, + ScanConverter->HeightScan, + System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); + delete [] ScanConvertedBmodeBuffer; + ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; } private: - NewBmodeImageCallbackType NewBmodeImageCallback; - void * NewBmodeImageCallbackClientData; - BmodePixelType * NativeBmodeBuffer; - BmodeArrayType ^ ManagedBmodeBuffer; - System::Drawing::Bitmap ^ ScanConvertedBmode; - - NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; - void * NewScanConvertedBmodeImageCallbackClientData; - Interson::Imaging::ScanConverter ^ ScanConverter; - BmodePixelType * ScanConvertedBmodeBuffer; + NewBmodeImageCallbackType NewBmodeImageCallback; + void *NewBmodeImageCallbackClientData; + BmodePixelType *NativeBmodeBuffer; + BmodeArrayType ^ManagedBmodeBuffer; + System::Drawing::Bitmap ^ScanConvertedBmode; + + NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; + void *NewScanConvertedBmodeImageCallbackClientData; + Interson::Imaging::ScanConverter ^ScanConverter; + BmodePixelType *ScanConvertedBmodeBuffer; }; class Scan2DClassImpl { public: - typedef cli::array< byte, 2 > BmodeArrayType; - typedef cli::array< unsigned short, 2 > RFArrayType; + typedef cli::array< byte, 2 > BmodeArrayType; + typedef cli::array< unsigned short, 2 > RFArrayType; - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - Scan2DClassImpl() + Scan2DClassImpl() { - Wrapped = gcnew Interson::Imaging::Scan2DClass(); - - BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS , Scan2DClass::MAX_SAMPLES); - BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); - BmodeHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, - &NewBmodeImageHandler::HandleNewBmodeImage ); - Wrapped->NewImageTick += BmodeHandlerDelegate; - - RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); - RFHandler = gcnew NewRFImageHandler( RFBuffer ); - RFHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, - &NewRFImageHandler::HandleNewRFImage ); - Wrapped->NewImageTick += RFHandlerDelegate; + Wrapped = gcnew Interson::Imaging::Scan2DClass(); + + BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS , Scan2DClass::MAX_SAMPLES); + BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); + BmodeHandlerDelegate = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, + &NewBmodeImageHandler::HandleNewBmodeImage ); + Wrapped->NewImageTick += BmodeHandlerDelegate; + + RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); + RFHandler = gcnew NewRFImageHandler( RFBuffer ); + RFHandlerDelegate = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, + &NewRFImageHandler::HandleNewRFImage ); + Wrapped->NewImageTick += RFHandlerDelegate; } - ~Scan2DClassImpl() + ~Scan2DClassImpl() { - Wrapped->NewImageTick -= RFHandlerDelegate; - Wrapped->NewImageTick -= BmodeHandlerDelegate; + Wrapped->NewImageTick -= RFHandlerDelegate; + Wrapped->NewImageTick -= BmodeHandlerDelegate; } - bool GetScanOn() + bool GetScanOn() { - return Wrapped->ScanOn; + return Wrapped->ScanOn; } - bool GetRFData() + bool GetRFData() { - return Wrapped->RFData; + return Wrapped->RFData; } - void SetRFData( bool transferOn ) + void SetRFData( bool transferOn ) { - Wrapped->RFData = transferOn; + Wrapped->RFData = transferOn; } - bool GetFrameAvg() + bool GetFrameAvg() { - return Wrapped->FrameAvg; + return Wrapped->FrameAvg; } - void SetFrameAvg( bool doAveraging ) + void SetFrameAvg( bool doAveraging ) { - return Wrapped->FrameAvg = doAveraging; + return Wrapped->FrameAvg = doAveraging; } - double GetTrueDepth() + double GetTrueDepth() { - return Wrapped->TrueDepth; + return Wrapped->TrueDepth; } - void StartReadScan() + void StartReadScan() { - Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); + Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); } - void StartRFReadScan() + void StartRFReadScan() { - Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); + Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); } - void StopReadScan() + void StopReadScan() { - Wrapped->StopReadScan(); + Wrapped->StopReadScan(); } - void DisposeScan() + void DisposeScan() { - Wrapped->DisposeScan(); + Wrapped->DisposeScan(); } - void AbortScan() + void AbortScan() { - Wrapped->AbortScan(); + Wrapped->AbortScan(); } - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void * clientData = 0 ) + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData = 0 ) { - this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); + this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); } - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void * clientData = 0 ) + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData = 0 ) { - this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); + this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); } - void SetNewRFImageCallback( NewRFImageCallbackType callback, void * clientData = 0 ) + void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = 0 ) { - this->RFHandler->SetNewRFImageCallback( callback, clientData ); + this->RFHandler->SetNewRFImageCallback( callback, clientData ); } private: - gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; + gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; - gcroot< BmodeArrayType ^ > BmodeBuffer; - gcroot< RFArrayType ^ > RFBuffer; - gcroot< NewBmodeImageHandler ^ > BmodeHandler; - gcroot< NewRFImageHandler ^ > RFHandler; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; + gcroot< BmodeArrayType ^ > BmodeBuffer; + gcroot< RFArrayType ^ > RFBuffer; + gcroot< NewBmodeImageHandler ^ > BmodeHandler; + gcroot< NewRFImageHandler ^ > RFHandler; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; }; @@ -294,7 +294,7 @@ class Scan2DClassImpl Scan2DClass ::Scan2DClass(): - Impl( new Scan2DClassImpl() ) + Impl( new Scan2DClassImpl() ) { } @@ -302,7 +302,7 @@ ::Scan2DClass(): Scan2DClass ::~Scan2DClass() { - delete Impl; + delete Impl; } @@ -310,7 +310,7 @@ bool Scan2DClass ::GetScanOn() const { - return Impl->GetScanOn(); + return Impl->GetScanOn(); } @@ -318,7 +318,7 @@ bool Scan2DClass ::GetRFData() const { - return Impl->GetRFData(); + return Impl->GetRFData(); } @@ -326,7 +326,7 @@ void Scan2DClass ::SetRFData( bool transferOn ) { - Impl->SetRFData( transferOn ); + Impl->SetRFData( transferOn ); } @@ -334,14 +334,14 @@ bool Scan2DClass ::GetFrameAvg() const { - return Impl->GetFrameAvg(); + return Impl->GetFrameAvg(); } void Scan2DClass ::SetFrameAvg( bool doAveraging ) { - Impl->SetFrameAvg( doAveraging ); + Impl->SetFrameAvg( doAveraging ); } @@ -349,7 +349,7 @@ void Scan2DClass ::StartReadScan() { - Impl->StartReadScan(); + Impl->StartReadScan(); } @@ -357,7 +357,7 @@ void Scan2DClass ::StartRFReadScan() { - Impl->StartRFReadScan(); + Impl->StartRFReadScan(); } @@ -365,7 +365,7 @@ void Scan2DClass ::StopReadScan() { - Impl->StopReadScan(); + Impl->StopReadScan(); } @@ -373,7 +373,7 @@ void Scan2DClass ::DisposeScan() { - Impl->DisposeScan(); + Impl->DisposeScan(); } @@ -381,34 +381,34 @@ void Scan2DClass ::AbortScan() { - Impl->AbortScan(); + Impl->AbortScan(); } void Scan2DClass ::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, - void * clientData ) + void *clientData ) { - Impl->SetNewBmodeImageCallback( callback, clientData ); + Impl->SetNewBmodeImageCallback( callback, clientData ); } void Scan2DClass ::SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void * clientData ) + void *clientData ) { - Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); + Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); } void Scan2DClass ::SetNewRFImageCallback( NewRFImageCallbackType callback, - void * clientData ) + void *clientData ) { - Impl->SetNewRFImageCallback( callback, clientData ); + Impl->SetNewRFImageCallback( callback, clientData ); } @@ -416,7 +416,7 @@ double Scan2DClass ::GetTrueDepth() const { - return Impl->GetTrueDepth(); + return Impl->GetTrueDepth(); } } // end namespace Imaging diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx index 586ce5c..842c9cd 100644 --- a/src/IntersonCxxImagingScanConverter.cxx +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -17,58 +17,58 @@ namespace Imaging class ScanConverterImpl { public: - ScanConverterImpl() + ScanConverterImpl() { - Wrapped = gcnew Interson::Imaging::ScanConverter(); + Wrapped = gcnew Interson::Imaging::ScanConverter(); } - ~ScanConverterImpl() + ~ScanConverterImpl() { } - int GetHeightScan() + int GetHeightScan() { - return Wrapped->HeightScan; + return Wrapped->HeightScan; } - int GetWidthScan() + int GetWidthScan() { - return Wrapped->WidthScan; + return Wrapped->WidthScan; } - float GetMmPerPixel() + float GetMmPerPixel() { - return Wrapped->MmPerPixel; + return Wrapped->MmPerPixel; } - int GetZeroOfYScale() + int GetZeroOfYScale() { - return Wrapped->ZeroOfYScale; + return Wrapped->ZeroOfYScale; } - ScanConverter::ScanConverterError HardInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan ) + ScanConverter::ScanConverterError HardInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan ) { - return static_cast< ScanConverter::ScanConverterError >( - Wrapped->HardInitScanConverter( depth, upDown, leftRight, widthScan, heightScan ) ); + return static_cast< ScanConverter::ScanConverterError >( + Wrapped->HardInitScanConverter( depth, upDown, leftRight, widthScan, heightScan ) ); } - ScanConverter::ScanConverterError IdleInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan, - unsigned char probeId ) + ScanConverter::ScanConverterError IdleInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan, + unsigned char probeId ) { - return static_cast< ScanConverter::ScanConverterError >( - Wrapped->IdleInitScanConverter( depth, upDown, leftRight, widthScan, heightScan, probeId ) ); + return static_cast< ScanConverter::ScanConverterError >( + Wrapped->IdleInitScanConverter( depth, upDown, leftRight, widthScan, heightScan, probeId ) ); } private: - gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; + gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; }; @@ -77,7 +77,7 @@ class ScanConverterImpl ScanConverter ::ScanConverter(): - Impl( new ScanConverterImpl() ) + Impl( new ScanConverterImpl() ) { } @@ -85,7 +85,7 @@ ::ScanConverter(): ScanConverter ::~ScanConverter() { - delete Impl; + delete Impl; } @@ -93,7 +93,7 @@ int ScanConverter ::GetHeightScan() const { - return Impl->GetHeightScan(); + return Impl->GetHeightScan(); } @@ -101,7 +101,7 @@ int ScanConverter ::GetWidthScan() const { - return Impl->GetWidthScan(); + return Impl->GetWidthScan(); } @@ -109,7 +109,7 @@ float ScanConverter ::GetMmPerPixel() const { - return Impl->GetMmPerPixel(); + return Impl->GetMmPerPixel(); } @@ -117,7 +117,7 @@ int ScanConverter ::GetZeroOfYScale() const { - return Impl->GetZeroOfYScale(); + return Impl->GetZeroOfYScale(); } @@ -129,11 +129,11 @@ ::HardInitScanConverter( int depth, int widthScan, int heightScan ) { - return Impl->HardInitScanConverter( depth, - upDown, - leftRight, - widthScan, - heightScan ); + return Impl->HardInitScanConverter( depth, + upDown, + leftRight, + widthScan, + heightScan ); } @@ -146,12 +146,12 @@ ::IdleInitScanConverter( int depth, int heightScan, unsigned char probeId ) { - return Impl->IdleInitScanConverter( depth, - upDown, - leftRight, - widthScan, - heightScan, - probeId ); + return Impl->IdleInitScanConverter( depth, + upDown, + leftRight, + widthScan, + heightScan, + probeId ); } } // end namespace Imaging diff --git a/src/IntersonCxxIntersonClass.cxx b/src/IntersonCxxIntersonClass.cxx index 743a61d..278c5d0 100644 --- a/src/IntersonCxxIntersonClass.cxx +++ b/src/IntersonCxxIntersonClass.cxx @@ -1,5 +1,5 @@ // C++ -#pragma unmanaged +#pragma unmanaged #include "IntersonCxxIntersonClass.h" // C# @@ -13,41 +13,41 @@ namespace IntersonCxx { - // Wrapper Class for IntersonClass from SDK - class IntersonClassImpl - { - public: - IntersonClassImpl() - { - } - // Wrapped method for IntersonClass from SDK - std::string Version() - { - //This method converts data between native and managed environments. http://msdn.microsoft.com/en-us/library/bb384859.aspx - std::string marshalled = msclr::interop::marshal_as< std::string >(Interson::IntersonClass::Version ); - return marshalled; - } - - private: - }; +// Wrapper Class for IntersonClass from SDK +class IntersonClassImpl +{ +public: + IntersonClassImpl() + { + } + // Wrapped method for IntersonClass from SDK + std::string Version() + { + //This method converts data between native and managed environments. http://msdn.microsoft.com/en-us/library/bb384859.aspx + std::string marshalled = msclr::interop::marshal_as< std::string >(Interson::IntersonClass::Version ); + return marshalled; + } + +private: +}; // C++ #pragma unmanaged - IntersonClass::IntersonClass(): - Impl( new IntersonClassImpl() ) - { - } +IntersonClass::IntersonClass(): + Impl( new IntersonClassImpl() ) +{ +} - IntersonClass::~IntersonClass() - { - delete Impl; - } +IntersonClass::~IntersonClass() +{ + delete Impl; +} - std::string IntersonClass::Version() const - { - return Impl->Version(); - } +std::string IntersonClass::Version() const +{ + return Impl->Version(); +} } // end namespace IntersonCxx From 6b24d348c41ffbda4603c4b9ad1c4ff4de6afc78 Mon Sep 17 00:00:00 2001 From: nenetto Date: Fri, 17 Oct 2014 09:28:32 -0400 Subject: [PATCH 060/103] Indentation following rules from ITK indentation and style http://www.itk.org/Wiki/ITK/Coding_Style_Guide#Code_Layout_and_Indentation --- src/IntersonCxxControlsHWControls.cxx | 364 +++++++++--------- src/IntersonCxxImagingScan2DClass.cxx | 492 ++++++++++++------------ src/IntersonCxxImagingScanConverter.cxx | 134 +++---- 3 files changed, 495 insertions(+), 495 deletions(-) diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx index c0ceaa4..027ea35 100644 --- a/src/IntersonCxxControlsHWControls.cxx +++ b/src/IntersonCxxControlsHWControls.cxx @@ -20,172 +20,172 @@ namespace Controls class HWControlsImpl { public: - // New defininions look header file - typedef HWControls::FoundProbesType FoundProbesType; - typedef HWControls::FrequenciesType FrequenciesType; - - - HWControlsImpl() - { - // New method for managed code. Wrapped is data member or this class - Wrapped = gcnew Interson::Controls::HWControls(); - } - - unsigned char GetProbeID() - { - return Wrapped->GetProbeID(); - } - - void FindAllProbes( FoundProbesType &foundProbes ) - { - System::Collections::Specialized::StringCollection ^managedProbes = - gcnew System::Collections::Specialized::StringCollection(); - Wrapped->FindAllProbes( managedProbes );; - foundProbes.resize( managedProbes->Count ); - // Copy all available probes to the C++ class - for ( int ii = 0; ii < managedProbes->Count; ++ii ) - { - foundProbes[ii] = msclr::interop::marshal_as< std::string >( - managedProbes[ii] ); - } - } - - void FindMyProbe( int probeIndex ) - { - Wrapped->FindMyProbe( probeIndex ); - } - - int ValidDepth( int depth ) - { - return Wrapped->ValidDepth( depth ); - } - - void GetFrequency( FrequenciesType &frequencies ) - { - array< int > ^managedFrequencies = Wrapped->GetFrequency(); - frequencies.resize( managedFrequencies->Length ); - for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - frequencies[ii] = managedFrequencies[ii]; - } - } - - bool SetFrequency( int frequency ) - { - array< int > ^managedFrequencies = Wrapped->GetFrequency(); - int frequencyIndex = -1; - for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - if ( frequency == managedFrequencies[ii] ) - { - frequencyIndex = ii; - break; - } - } - if ( frequencyIndex == -1 ) - { - return false; - } - return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); - } - - bool SendHighVoltage( unsigned char voltage ) - { - return Wrapped->SendHighVoltage( voltage ); - } - - bool EnableHighVoltage() - { - return Wrapped->EnableHighVoltage(); - } - - bool DisableHighVoltage() - { - return Wrapped->DisableHighVoltage(); - } - - bool SendDynamic( unsigned char dynamic ) - { - return Wrapped->SendDynamic( dynamic ); - } - - bool StartMotor() + // New defininions look header file + typedef HWControls::FoundProbesType FoundProbesType; + typedef HWControls::FrequenciesType FrequenciesType; + + + HWControlsImpl() + { + // New method for managed code. Wrapped is data member or this class + Wrapped = gcnew Interson::Controls::HWControls(); + } + + unsigned char GetProbeID() + { + return Wrapped->GetProbeID(); + } + + void FindAllProbes( FoundProbesType &foundProbes ) + { + System::Collections::Specialized::StringCollection ^managedProbes = + gcnew System::Collections::Specialized::StringCollection(); + Wrapped->FindAllProbes( managedProbes );; + foundProbes.resize( managedProbes->Count ); + // Copy all available probes to the C++ class + for ( int ii = 0; ii < managedProbes->Count; ++ii ) { - return Wrapped->StartMotor(); + foundProbes[ii] = msclr::interop::marshal_as< std::string >( + managedProbes[ii] ); } - - bool StopMotor() - { - return Wrapped->StopMotor(); - } - - void EnableHardButton() - { - Wrapped->EnableHardButton(); - } - - void DisableHardButton() - { - Wrapped->DisableHardButton(); - } - - unsigned char ReadHardButton() + } + + void FindMyProbe( int probeIndex ) + { + Wrapped->FindMyProbe( probeIndex ); + } + + int ValidDepth( int depth ) + { + return Wrapped->ValidDepth( depth ); + } + + void GetFrequency( FrequenciesType &frequencies ) + { + array< int > ^managedFrequencies = Wrapped->GetFrequency(); + frequencies.resize( managedFrequencies->Length ); + for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) { - return Wrapped->ReadHardButton(); + frequencies[ii] = managedFrequencies[ii]; } + } - bool StartBmode() + bool SetFrequency( int frequency ) + { + array< int > ^managedFrequencies = Wrapped->GetFrequency(); + int frequencyIndex = -1; + for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) { - return Wrapped->StartBmode(); + if ( frequency == managedFrequencies[ii] ) + { + frequencyIndex = ii; + break; + } } - - bool StartRFmode() - { - return Wrapped->StartRFmode(); - } - - bool StopAcquisition() - { - return Wrapped->StopAcquisition(); - } - - short GetProbeFrameRate( int depth ) - { - return Wrapped->GetProbeFrameRate( depth ); - } - - std::string GetProbeSerialNumber() - { - return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); - } - - std::string ReadFPGAVersion() - { - return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); - } - - std::string GetOEMId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); - } - - std::string GetFilterId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); - } - - bool EnableRFDecimator() - { - return Wrapped->EnableRFDecimator(); - } - - bool DisableRFDecimator() + if ( frequencyIndex == -1 ) { - return Wrapped->DisableRFDecimator(); + return false; } + return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); + } + + bool SendHighVoltage( unsigned char voltage ) + { + return Wrapped->SendHighVoltage( voltage ); + } + + bool EnableHighVoltage() + { + return Wrapped->EnableHighVoltage(); + } + + bool DisableHighVoltage() + { + return Wrapped->DisableHighVoltage(); + } + + bool SendDynamic( unsigned char dynamic ) + { + return Wrapped->SendDynamic( dynamic ); + } + + bool StartMotor() + { + return Wrapped->StartMotor(); + } + + bool StopMotor() + { + return Wrapped->StopMotor(); + } + + void EnableHardButton() + { + Wrapped->EnableHardButton(); + } + + void DisableHardButton() + { + Wrapped->DisableHardButton(); + } + + unsigned char ReadHardButton() + { + return Wrapped->ReadHardButton(); + } + + bool StartBmode() + { + return Wrapped->StartBmode(); + } + + bool StartRFmode() + { + return Wrapped->StartRFmode(); + } + + bool StopAcquisition() + { + return Wrapped->StopAcquisition(); + } + + short GetProbeFrameRate( int depth ) + { + return Wrapped->GetProbeFrameRate( depth ); + } + + std::string GetProbeSerialNumber() + { + return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); + } + + std::string ReadFPGAVersion() + { + return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); + } + + std::string GetOEMId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); + } + + std::string GetFilterId() + { + return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); + } + + bool EnableRFDecimator() + { + return Wrapped->EnableRFDecimator(); + } + + bool DisableRFDecimator() + { + return Wrapped->DisableRFDecimator(); + } private: - gcroot< Interson::Controls::HWControls ^ > Wrapped; + gcroot< Interson::Controls::HWControls ^ > Wrapped; }; // C++ @@ -193,7 +193,7 @@ class HWControlsImpl HWControls ::HWControls(): - Impl( new HWControlsImpl() ) + Impl( new HWControlsImpl() ) { } @@ -201,7 +201,7 @@ ::HWControls(): HWControls ::~HWControls() { - delete Impl; + delete Impl; } @@ -209,7 +209,7 @@ unsigned char HWControls ::GetProbeID() const { - return Impl->GetProbeID(); + return Impl->GetProbeID(); } @@ -217,7 +217,7 @@ void HWControls ::FindAllProbes( FoundProbesType &foundProbes ) const { - Impl->FindAllProbes( foundProbes ); + Impl->FindAllProbes( foundProbes ); } @@ -225,14 +225,14 @@ void HWControls ::FindMyProbe( int probeIndex ) { - Impl->FindMyProbe( probeIndex ); + Impl->FindMyProbe( probeIndex ); } int HWControls ::ValidDepth( int depth ) const { - return Impl->ValidDepth( depth ); + return Impl->ValidDepth( depth ); } @@ -240,7 +240,7 @@ void HWControls ::GetFrequency( FrequenciesType &frequencies ) const { - Impl->GetFrequency( frequencies ); + Impl->GetFrequency( frequencies ); } @@ -248,7 +248,7 @@ bool HWControls ::SetFrequency( int frequency ) { - return Impl->SetFrequency( frequency ); + return Impl->SetFrequency( frequency ); } @@ -256,7 +256,7 @@ bool HWControls ::SendHighVoltage( unsigned char voltage ) { - return Impl->SendHighVoltage( voltage ); + return Impl->SendHighVoltage( voltage ); } @@ -264,7 +264,7 @@ bool HWControls ::EnableHighVoltage() { - return Impl->EnableHighVoltage(); + return Impl->EnableHighVoltage(); } @@ -272,7 +272,7 @@ bool HWControls ::DisableHighVoltage() { - return Impl->DisableHighVoltage(); + return Impl->DisableHighVoltage(); } @@ -280,7 +280,7 @@ bool HWControls ::SendDynamic( unsigned char dynamic ) { - return Impl->SendDynamic( dynamic ); + return Impl->SendDynamic( dynamic ); } @@ -288,7 +288,7 @@ bool HWControls ::StartMotor() { - return Impl->StartMotor(); + return Impl->StartMotor(); } @@ -296,7 +296,7 @@ bool HWControls ::StopMotor() { - return Impl->StopMotor(); + return Impl->StopMotor(); } @@ -304,7 +304,7 @@ void HWControls ::EnableHardButton() { - Impl->EnableHardButton(); + Impl->EnableHardButton(); } @@ -312,7 +312,7 @@ void HWControls ::DisableHardButton() { - Impl->DisableHardButton(); + Impl->DisableHardButton(); } @@ -320,7 +320,7 @@ unsigned char HWControls ::ReadHardButton() { - return Impl->ReadHardButton(); + return Impl->ReadHardButton(); } @@ -328,7 +328,7 @@ bool HWControls ::StartBmode() { - return Impl->StartBmode(); + return Impl->StartBmode(); } @@ -336,7 +336,7 @@ bool HWControls ::StartRFmode() { - return Impl->StartRFmode(); + return Impl->StartRFmode(); } @@ -344,7 +344,7 @@ bool HWControls ::StopAcquisition() { - return Impl->StopAcquisition(); + return Impl->StopAcquisition(); } @@ -352,7 +352,7 @@ short HWControls ::GetProbeFrameRate( int depth ) { - return Impl->GetProbeFrameRate( depth ); + return Impl->GetProbeFrameRate( depth ); } @@ -360,7 +360,7 @@ std::string HWControls ::GetProbeSerialNumber() const { - return Impl->GetProbeSerialNumber(); + return Impl->GetProbeSerialNumber(); } @@ -368,7 +368,7 @@ std::string HWControls ::ReadFPGAVersion() const { - return Impl->ReadFPGAVersion(); + return Impl->ReadFPGAVersion(); } @@ -376,7 +376,7 @@ std::string HWControls ::GetOEMId() const { - return Impl->GetOEMId(); + return Impl->GetOEMId(); } @@ -384,7 +384,7 @@ std::string HWControls ::GetFilterId() const { - return Impl->GetFilterId(); + return Impl->GetFilterId(); } @@ -392,7 +392,7 @@ bool HWControls ::EnableRFDecimator() { - return Impl->EnableRFDecimator(); + return Impl->EnableRFDecimator(); } @@ -400,7 +400,7 @@ bool HWControls ::DisableRFDecimator() { - return Impl->DisableRFDecimator(); + return Impl->DisableRFDecimator(); } } // end namespace Controls diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx index 9d96fc0..824c21c 100644 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ b/src/IntersonCxxImagingScan2DClass.cxx @@ -19,273 +19,273 @@ namespace Imaging ref class NewRFImageHandler { public: - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; - typedef cli::array< unsigned short, 2 > RFArrayType; - - NewRFImageHandler( RFArrayType ^managedRFBuffer ): - NewRFImageCallback( NULL ), - NewRFImageCallbackClientData( NULL ), - NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedRFBuffer( managedRFBuffer ) + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; + typedef cli::array< unsigned short, 2 > RFArrayType; + + NewRFImageHandler( RFArrayType ^managedRFBuffer ): + NewRFImageCallback( NULL ), + NewRFImageCallbackClientData( NULL ), + NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedRFBuffer( managedRFBuffer ) + { + } + + ~NewRFImageHandler() + { + delete [] NativeRFBuffer; + } + + void HandleNewRFImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) + { + if ( this->NewRFImageCallback != NULL ) { - } - - ~NewRFImageHandler() - { - delete [] NativeRFBuffer; - } - - void HandleNewRFImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) - { - if ( this->NewRFImageCallback != NULL ) + for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for ( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) { - for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) - { - for ( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) - { - this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; - } - } - this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); + this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; } + } + this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); } + } - void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) - { - this->NewRFImageCallback = callback; - this->NewRFImageCallbackClientData = clientData; - } + void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) + { + this->NewRFImageCallback = callback; + this->NewRFImageCallbackClientData = clientData; + } private: - NewRFImageCallbackType NewRFImageCallback; - void *NewRFImageCallbackClientData; - RFPixelType *NativeRFBuffer; - RFArrayType ^ManagedRFBuffer; + NewRFImageCallbackType NewRFImageCallback; + void *NewRFImageCallbackClientData; + RFPixelType *NativeRFBuffer; + RFArrayType ^ManagedRFBuffer; }; ref class NewBmodeImageHandler { public: - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; - typedef cli::array< byte, 2 > BmodeArrayType; - - NewBmodeImageHandler( BmodeArrayType ^managedBmodeBuffer ): - NewBmodeImageCallback( NULL ), - NewBmodeImageCallbackClientData( NULL ), - NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedBmodeBuffer( managedBmodeBuffer ), - NewScanConvertedBmodeImageCallback( NULL ), - NewScanConvertedBmodeImageCallbackClientData( NULL ), - ScanConvertedBmodeBuffer( new BmodePixelType[0] ) + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; + typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; + typedef cli::array< byte, 2 > BmodeArrayType; + + NewBmodeImageHandler( BmodeArrayType ^managedBmodeBuffer ): + NewBmodeImageCallback( NULL ), + NewBmodeImageCallbackClientData( NULL ), + NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), + ManagedBmodeBuffer( managedBmodeBuffer ), + NewScanConvertedBmodeImageCallback( NULL ), + NewScanConvertedBmodeImageCallbackClientData( NULL ), + ScanConvertedBmodeBuffer( new BmodePixelType[0] ) + { + ScanConverter = gcnew Interson::Imaging::ScanConverter(); + } + + ~NewBmodeImageHandler() + { + delete [] NativeBmodeBuffer; + delete [] ScanConvertedBmodeBuffer; + } + + void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) + { + if ( this->NewBmodeImageCallback != NULL ) { - ScanConverter = gcnew Interson::Imaging::ScanConverter(); - } - - ~NewBmodeImageHandler() - { - delete [] NativeBmodeBuffer; - delete [] ScanConvertedBmodeBuffer; - } - - void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) - { - if ( this->NewBmodeImageCallback != NULL ) + for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) + { + for ( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) { - for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) - { - for ( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) - { - this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = - this->ManagedBmodeBuffer[ii, jj]; - } - } - this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); + this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = + this->ManagedBmodeBuffer[ii, jj]; } + } + this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); + } - if ( this->NewScanConvertedBmodeImageCallback != NULL ) - { - scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); - - System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, ScanConvertedBmode->Width, ScanConvertedBmode->Height); - System::Drawing::Imaging::BitmapData ^bData = ScanConvertedBmode->LockBits( - rect , - System::Drawing::Imaging::ImageLockMode::ReadWrite, - System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - - byte *scan0 = (byte *)bData->Scan0.ToPointer(); + if ( this->NewScanConvertedBmodeImageCallback != NULL ) + { + scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); - for (int i = 0; i < bData->Height; ++i) - { - for (int j = 0; j < bData->Width; ++j) - { - byte *data = scan0 + i * bData->Stride + j; - this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * i + j] = static_cast< BmodePixelType > (data[0]); + System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, ScanConvertedBmode->Width, ScanConvertedBmode->Height); + System::Drawing::Imaging::BitmapData ^bData = ScanConvertedBmode->LockBits( + rect , + System::Drawing::Imaging::ImageLockMode::ReadWrite, + System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - } - } + byte *scan0 = (byte *)bData->Scan0.ToPointer(); + for (int i = 0; i < bData->Height; ++i) + { + for (int j = 0; j < bData->Width; ++j) + { + byte *data = scan0 + i * bData->Stride + j; + this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * i + j] = static_cast< BmodePixelType > (data[0]); + } + } - ScanConvertedBmode->UnlockBits(bData); - this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); - } - } - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData ) - { - this->NewBmodeImageCallback = callback; - this->NewBmodeImageCallbackClientData = clientData; - } + ScanConvertedBmode->UnlockBits(bData); - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData ) - { - this->NewScanConvertedBmodeImageCallback = callback; - this->NewScanConvertedBmodeImageCallbackClientData = clientData; - - ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, - ScanConverter->HeightScan, - System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - delete [] ScanConvertedBmodeBuffer; - ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; + this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); } + } + + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData ) + { + this->NewBmodeImageCallback = callback; + this->NewBmodeImageCallbackClientData = clientData; + } + + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData ) + { + this->NewScanConvertedBmodeImageCallback = callback; + this->NewScanConvertedBmodeImageCallbackClientData = clientData; + + ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, + ScanConverter->HeightScan, + System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); + delete [] ScanConvertedBmodeBuffer; + ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; + } private: - NewBmodeImageCallbackType NewBmodeImageCallback; - void *NewBmodeImageCallbackClientData; - BmodePixelType *NativeBmodeBuffer; - BmodeArrayType ^ManagedBmodeBuffer; - System::Drawing::Bitmap ^ScanConvertedBmode; - - NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; - void *NewScanConvertedBmodeImageCallbackClientData; - Interson::Imaging::ScanConverter ^ScanConverter; - BmodePixelType *ScanConvertedBmodeBuffer; + NewBmodeImageCallbackType NewBmodeImageCallback; + void *NewBmodeImageCallbackClientData; + BmodePixelType *NativeBmodeBuffer; + BmodeArrayType ^ManagedBmodeBuffer; + System::Drawing::Bitmap ^ScanConvertedBmode; + + NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; + void *NewScanConvertedBmodeImageCallbackClientData; + Interson::Imaging::ScanConverter ^ScanConverter; + BmodePixelType *ScanConvertedBmodeBuffer; }; class Scan2DClassImpl { public: - typedef cli::array< byte, 2 > BmodeArrayType; - typedef cli::array< unsigned short, 2 > RFArrayType; - - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - - Scan2DClassImpl() - { - Wrapped = gcnew Interson::Imaging::Scan2DClass(); - - BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS , Scan2DClass::MAX_SAMPLES); - BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); - BmodeHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, - &NewBmodeImageHandler::HandleNewBmodeImage ); - Wrapped->NewImageTick += BmodeHandlerDelegate; - - RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); - RFHandler = gcnew NewRFImageHandler( RFBuffer ); - RFHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, - &NewRFImageHandler::HandleNewRFImage ); - Wrapped->NewImageTick += RFHandlerDelegate; - - } - - ~Scan2DClassImpl() - { - Wrapped->NewImageTick -= RFHandlerDelegate; - Wrapped->NewImageTick -= BmodeHandlerDelegate; - } - - bool GetScanOn() - { - return Wrapped->ScanOn; - } - - bool GetRFData() - { - return Wrapped->RFData; - } - - void SetRFData( bool transferOn ) - { - Wrapped->RFData = transferOn; - } - - bool GetFrameAvg() - { - return Wrapped->FrameAvg; - } - - void SetFrameAvg( bool doAveraging ) - { - return Wrapped->FrameAvg = doAveraging; - } - - double GetTrueDepth() - { - return Wrapped->TrueDepth; - } - - void StartReadScan() - { - Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); - } - - void StartRFReadScan() - { - Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); - } - - void StopReadScan() - { - Wrapped->StopReadScan(); - } - - void DisposeScan() - { - Wrapped->DisposeScan(); - } - - void AbortScan() - { - Wrapped->AbortScan(); - } - - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData = 0 ) - { - this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); - } - - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData = 0 ) - { - this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); - } - - void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = 0 ) - { - this->RFHandler->SetNewRFImageCallback( callback, clientData ); - } + typedef cli::array< byte, 2 > BmodeArrayType; + typedef cli::array< unsigned short, 2 > RFArrayType; + + typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; + typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType + NewScanConvertedBmodeImageCallbackType; + typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; + + Scan2DClassImpl() + { + Wrapped = gcnew Interson::Imaging::Scan2DClass(); + + BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS , Scan2DClass::MAX_SAMPLES); + BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); + BmodeHandlerDelegate = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, + &NewBmodeImageHandler::HandleNewBmodeImage ); + Wrapped->NewImageTick += BmodeHandlerDelegate; + + RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); + RFHandler = gcnew NewRFImageHandler( RFBuffer ); + RFHandlerDelegate = gcnew + Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, + &NewRFImageHandler::HandleNewRFImage ); + Wrapped->NewImageTick += RFHandlerDelegate; + + } + + ~Scan2DClassImpl() + { + Wrapped->NewImageTick -= RFHandlerDelegate; + Wrapped->NewImageTick -= BmodeHandlerDelegate; + } + + bool GetScanOn() + { + return Wrapped->ScanOn; + } + + bool GetRFData() + { + return Wrapped->RFData; + } + + void SetRFData( bool transferOn ) + { + Wrapped->RFData = transferOn; + } + + bool GetFrameAvg() + { + return Wrapped->FrameAvg; + } + + void SetFrameAvg( bool doAveraging ) + { + return Wrapped->FrameAvg = doAveraging; + } + + double GetTrueDepth() + { + return Wrapped->TrueDepth; + } + + void StartReadScan() + { + Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); + } + + void StartRFReadScan() + { + Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); + } + + void StopReadScan() + { + Wrapped->StopReadScan(); + } + + void DisposeScan() + { + Wrapped->DisposeScan(); + } + + void AbortScan() + { + Wrapped->AbortScan(); + } + + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData = 0 ) + { + this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); + } + + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData = 0 ) + { + this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = 0 ) + { + this->RFHandler->SetNewRFImageCallback( callback, clientData ); + } private: - gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; + gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; - gcroot< BmodeArrayType ^ > BmodeBuffer; - gcroot< RFArrayType ^ > RFBuffer; - gcroot< NewBmodeImageHandler ^ > BmodeHandler; - gcroot< NewRFImageHandler ^ > RFHandler; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; + gcroot< BmodeArrayType ^ > BmodeBuffer; + gcroot< RFArrayType ^ > RFBuffer; + gcroot< NewBmodeImageHandler ^ > BmodeHandler; + gcroot< NewRFImageHandler ^ > RFHandler; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; + gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; }; @@ -294,7 +294,7 @@ class Scan2DClassImpl Scan2DClass ::Scan2DClass(): - Impl( new Scan2DClassImpl() ) + Impl( new Scan2DClassImpl() ) { } @@ -302,7 +302,7 @@ ::Scan2DClass(): Scan2DClass ::~Scan2DClass() { - delete Impl; + delete Impl; } @@ -310,7 +310,7 @@ bool Scan2DClass ::GetScanOn() const { - return Impl->GetScanOn(); + return Impl->GetScanOn(); } @@ -318,7 +318,7 @@ bool Scan2DClass ::GetRFData() const { - return Impl->GetRFData(); + return Impl->GetRFData(); } @@ -326,7 +326,7 @@ void Scan2DClass ::SetRFData( bool transferOn ) { - Impl->SetRFData( transferOn ); + Impl->SetRFData( transferOn ); } @@ -334,14 +334,14 @@ bool Scan2DClass ::GetFrameAvg() const { - return Impl->GetFrameAvg(); + return Impl->GetFrameAvg(); } void Scan2DClass ::SetFrameAvg( bool doAveraging ) { - Impl->SetFrameAvg( doAveraging ); + Impl->SetFrameAvg( doAveraging ); } @@ -349,7 +349,7 @@ void Scan2DClass ::StartReadScan() { - Impl->StartReadScan(); + Impl->StartReadScan(); } @@ -357,7 +357,7 @@ void Scan2DClass ::StartRFReadScan() { - Impl->StartRFReadScan(); + Impl->StartRFReadScan(); } @@ -365,7 +365,7 @@ void Scan2DClass ::StopReadScan() { - Impl->StopReadScan(); + Impl->StopReadScan(); } @@ -373,7 +373,7 @@ void Scan2DClass ::DisposeScan() { - Impl->DisposeScan(); + Impl->DisposeScan(); } @@ -381,7 +381,7 @@ void Scan2DClass ::AbortScan() { - Impl->AbortScan(); + Impl->AbortScan(); } @@ -390,16 +390,16 @@ Scan2DClass ::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData ) { - Impl->SetNewBmodeImageCallback( callback, clientData ); + Impl->SetNewBmodeImageCallback( callback, clientData ); } void Scan2DClass ::SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void *clientData ) + void *clientData ) { - Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); + Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); } @@ -408,7 +408,7 @@ Scan2DClass ::SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) { - Impl->SetNewRFImageCallback( callback, clientData ); + Impl->SetNewRFImageCallback( callback, clientData ); } @@ -416,7 +416,7 @@ double Scan2DClass ::GetTrueDepth() const { - return Impl->GetTrueDepth(); + return Impl->GetTrueDepth(); } } // end namespace Imaging diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx index 842c9cd..49b49ca 100644 --- a/src/IntersonCxxImagingScanConverter.cxx +++ b/src/IntersonCxxImagingScanConverter.cxx @@ -17,58 +17,58 @@ namespace Imaging class ScanConverterImpl { public: - ScanConverterImpl() - { - Wrapped = gcnew Interson::Imaging::ScanConverter(); - } - - ~ScanConverterImpl() - { - } - - int GetHeightScan() - { - return Wrapped->HeightScan; - } - - int GetWidthScan() - { - return Wrapped->WidthScan; - } - - float GetMmPerPixel() - { - return Wrapped->MmPerPixel; - } - - int GetZeroOfYScale() - { - return Wrapped->ZeroOfYScale; - } - - ScanConverter::ScanConverterError HardInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan ) - { - return static_cast< ScanConverter::ScanConverterError >( - Wrapped->HardInitScanConverter( depth, upDown, leftRight, widthScan, heightScan ) ); - } - - ScanConverter::ScanConverterError IdleInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan, - unsigned char probeId ) - { - return static_cast< ScanConverter::ScanConverterError >( - Wrapped->IdleInitScanConverter( depth, upDown, leftRight, widthScan, heightScan, probeId ) ); - } + ScanConverterImpl() + { + Wrapped = gcnew Interson::Imaging::ScanConverter(); + } + + ~ScanConverterImpl() + { + } + + int GetHeightScan() + { + return Wrapped->HeightScan; + } + + int GetWidthScan() + { + return Wrapped->WidthScan; + } + + float GetMmPerPixel() + { + return Wrapped->MmPerPixel; + } + + int GetZeroOfYScale() + { + return Wrapped->ZeroOfYScale; + } + + ScanConverter::ScanConverterError HardInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan ) + { + return static_cast< ScanConverter::ScanConverterError >( + Wrapped->HardInitScanConverter( depth, upDown, leftRight, widthScan, heightScan ) ); + } + + ScanConverter::ScanConverterError IdleInitScanConverter( int depth, + bool upDown, + bool leftRight, + int widthScan, + int heightScan, + unsigned char probeId ) + { + return static_cast< ScanConverter::ScanConverterError >( + Wrapped->IdleInitScanConverter( depth, upDown, leftRight, widthScan, heightScan, probeId ) ); + } private: - gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; + gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; }; @@ -77,7 +77,7 @@ class ScanConverterImpl ScanConverter ::ScanConverter(): - Impl( new ScanConverterImpl() ) + Impl( new ScanConverterImpl() ) { } @@ -85,7 +85,7 @@ ::ScanConverter(): ScanConverter ::~ScanConverter() { - delete Impl; + delete Impl; } @@ -93,7 +93,7 @@ int ScanConverter ::GetHeightScan() const { - return Impl->GetHeightScan(); + return Impl->GetHeightScan(); } @@ -101,7 +101,7 @@ int ScanConverter ::GetWidthScan() const { - return Impl->GetWidthScan(); + return Impl->GetWidthScan(); } @@ -109,7 +109,7 @@ float ScanConverter ::GetMmPerPixel() const { - return Impl->GetMmPerPixel(); + return Impl->GetMmPerPixel(); } @@ -117,7 +117,7 @@ int ScanConverter ::GetZeroOfYScale() const { - return Impl->GetZeroOfYScale(); + return Impl->GetZeroOfYScale(); } @@ -129,11 +129,11 @@ ::HardInitScanConverter( int depth, int widthScan, int heightScan ) { - return Impl->HardInitScanConverter( depth, - upDown, - leftRight, - widthScan, - heightScan ); + return Impl->HardInitScanConverter( depth, + upDown, + leftRight, + widthScan, + heightScan ); } @@ -146,12 +146,12 @@ ::IdleInitScanConverter( int depth, int heightScan, unsigned char probeId ) { - return Impl->IdleInitScanConverter( depth, - upDown, - leftRight, - widthScan, - heightScan, - probeId ); + return Impl->IdleInitScanConverter( depth, + upDown, + leftRight, + widthScan, + heightScan, + probeId ); } } // end namespace Imaging From c66c74ae1166a69fa735e161dd8ac4a450c2a48c Mon Sep 17 00:00:00 2001 From: nenetto Date: Fri, 17 Oct 2014 10:52:09 -0400 Subject: [PATCH 061/103] Indentation Problems --- include/IntersonCxxControlsHWControls.h | 220 ++++++++++++------------ include/IntersonCxxImagingScan2DClass.h | 70 ++++---- src/IntersonCxxIntersonClass.cxx | 26 +-- 3 files changed, 158 insertions(+), 158 deletions(-) diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h index f538a8e..b7dbea4 100644 --- a/include/IntersonCxxControlsHWControls.h +++ b/include/IntersonCxxControlsHWControls.h @@ -11,120 +11,120 @@ /* The library is organized via namespaces; the root is Interson, -then Interson.Controls to get the methods which access to the -USB probe controls, Interson.Imaging is the scan converter, to -build the 2D image B-Scan bitmap from the log-compressed A-Scan +then Interson.Controls to get the methods which access to the +USB probe controls, Interson.Imaging is the scan converter, to +build the 2D image B-Scan bitmap from the log-compressed A-Scan vectors. */ namespace IntersonCxx { - // Namespace similar to Interson.Controls Namespace from SDK - namespace Controls - { - // Wrapper Class for IntersonClass from SDK - class HWControlsImpl; - - // HWControls similar to IntersonClass from SDK - class IntersonCxx_EXPORT HWControls - { - public: - typedef std::vector< std::string > FoundProbesType; - typedef std::vector< int > FrequenciesType; - HWControls(); - ~HWControls(); - - static const int DIG_GAIN_MIN = -127; - static const int DIG_GAIN_INIT = 0; - static const int DIG_GAIN_MAX = 127; - - // Maximum number of frequencies - static const int MAX_FREQ = 3; - - // These are the valid Probe IDs. - static const int ID_GP_3_5MHz = 1; - static const int ID_VC_7_5MHz = 2; - static const int ID_SP_7_5MHz = 3; - static const int ID_EC_7_5MHz = 4; - static const int ID_MV_12_MHz = 5; - static const int ID_GV_5_MHz = 6; - - // Size of the OEM (Original equipment manufacturer) space in the Probe EEPROM number of frequencies. http://en.wikipedia.org/wiki/Original_equipment_manufacturer - static const unsigned short int EEOEMSpace = 4096; - - // String Vector with all probe names connected - void FindAllProbes( FoundProbesType & foundProbes ) const; - // Summary: To open a handle to the probe defined by the ProbeIndex. Parameters: " ProbeIndex ": Index in the mycolProbesName collection - void FindMyProbe( int probeIndex ); - //To get the ID of the probe - unsigned char GetProbeID() const; - - /** Units: mm */ - // To check if the chosen Depth is valid for the probe. Returns the same depth if in the max range, otherwise returns the max depth - int ValidDepth( int depth ) const; - - /** Get the list of supported frequencies. Units: Hz. */ - void GetFrequency( FrequenciesType & frequencies ) const; - bool SetFrequency( int frequency ); - - /** Units: Volts */ - //" voltage ": percentage of the maximum of the High Voltage. Returns whether the command succeeded (true) or failed (false) - bool SendHighVoltage( unsigned char voltage ); - bool EnableHighVoltage(); - bool DisableHighVoltage(); - - // To set the value of the dynamic and to calculate the value sent to the control. " bytDynamic ": value of the Dynamic (db). - // Returns: Returns whether the command succeeded (true) or failed (false) - bool SendDynamic( unsigned char dynamic ); - - //To start/stop the motor of the probe - bool StartMotor(); - bool StopMotor(); - - // To Start watching the Hardware Button to enable to raise the event “HWButtonTick” - void EnableHardButton(); - void DisableHardButton(); - unsigned char ReadHardButton(); - - bool StartBmode(); - bool StartRFmode(); - bool StopAcquisition(); - - //To get the Frame Rate of that probe according to the depth - //" iDepth ": current depth. Returns: Return the current Frame Rate - short GetProbeFrameRate( int depth ); - - // To get the Serial Number of the probe - std::string GetProbeSerialNumber() const; - - // To get the version of the software installed in the FPGA. - std::string ReadFPGAVersion() const; - - // To get the identification of the OEM - std::string GetOEMId() const; - - //To get the identification of the filter. - std::string GetFilterId() const; - - //To enable the RF Decimator. Returns: Returns whether the command succeeded (true) or failed (false) - /* - Note: For GV and GP (low frequency probes) sampling rate is 15 Msamples/sec with - decimator off and with decimator on sampling rate is 7.5 Msamples/sec. For higher - frequency probes sampling rate is 30 Ms/sec with decimator off and 15 Ms/sec with - decimator on. With the speed of ultrasound at 1540 m/sec in human tissue: 30 Ms/sec - is 0.1 mm/sample, 15 Ms/sec is 0.2 mm/sample, 7.5 Ms/sec is 0.4 mm/sample. Therfore - with 2048 samples, the depths are 5.25 cm, 10.5 cm and 21 cm. - */ - bool EnableRFDecimator(); - bool DisableRFDecimator(); - - private: - HWControls( const HWControls & ); - void operator=( const HWControls & ); - - HWControlsImpl * Impl; - }; - - } // end namespace Controls +// Namespace similar to Interson.Controls Namespace from SDK +namespace Controls +{ +// Wrapper Class for IntersonClass from SDK +class HWControlsImpl; + +// HWControls similar to IntersonClass from SDK +class IntersonCxx_EXPORT HWControls +{ +public: + typedef std::vector< std::string > FoundProbesType; + typedef std::vector< int > FrequenciesType; + HWControls(); + ~HWControls(); + + static const int DIG_GAIN_MIN = -127; + static const int DIG_GAIN_INIT = 0; + static const int DIG_GAIN_MAX = 127; + + // Maximum number of frequencies + static const int MAX_FREQ = 3; + + // These are the valid Probe IDs. + static const int ID_GP_3_5MHz = 1; + static const int ID_VC_7_5MHz = 2; + static const int ID_SP_7_5MHz = 3; + static const int ID_EC_7_5MHz = 4; + static const int ID_MV_12_MHz = 5; + static const int ID_GV_5_MHz = 6; + + // Size of the OEM (Original equipment manufacturer) space in the Probe EEPROM number of frequencies. http://en.wikipedia.org/wiki/Original_equipment_manufacturer + static const unsigned short int EEOEMSpace = 4096; + + // String Vector with all probe names connected + void FindAllProbes( FoundProbesType &foundProbes ) const; + // Summary: To open a handle to the probe defined by the ProbeIndex. Parameters: " ProbeIndex ": Index in the mycolProbesName collection + void FindMyProbe( int probeIndex ); + //To get the ID of the probe + unsigned char GetProbeID() const; + + /** Units: mm */ + // To check if the chosen Depth is valid for the probe. Returns the same depth if in the max range, otherwise returns the max depth + int ValidDepth( int depth ) const; + + /** Get the list of supported frequencies. Units: Hz. */ + void GetFrequency( FrequenciesType &frequencies ) const; + bool SetFrequency( int frequency ); + + /** Units: Volts */ + //" voltage ": percentage of the maximum of the High Voltage. Returns whether the command succeeded (true) or failed (false) + bool SendHighVoltage( unsigned char voltage ); + bool EnableHighVoltage(); + bool DisableHighVoltage(); + + // To set the value of the dynamic and to calculate the value sent to the control. " bytDynamic ": value of the Dynamic (db). + // Returns: Returns whether the command succeeded (true) or failed (false) + bool SendDynamic( unsigned char dynamic ); + + //To start/stop the motor of the probe + bool StartMotor(); + bool StopMotor(); + + // To Start watching the Hardware Button to enable to raise the event “HWButtonTick†+ void EnableHardButton(); + void DisableHardButton(); + unsigned char ReadHardButton(); + + bool StartBmode(); + bool StartRFmode(); + bool StopAcquisition(); + + //To get the Frame Rate of that probe according to the depth + //" iDepth ": current depth. Returns: Return the current Frame Rate + short GetProbeFrameRate( int depth ); + + // To get the Serial Number of the probe + std::string GetProbeSerialNumber() const; + + // To get the version of the software installed in the FPGA. + std::string ReadFPGAVersion() const; + + // To get the identification of the OEM + std::string GetOEMId() const; + + //To get the identification of the filter. + std::string GetFilterId() const; + + //To enable the RF Decimator. Returns: Returns whether the command succeeded (true) or failed (false) + /* + Note: For GV and GP (low frequency probes) sampling rate is 15 Msamples/sec with + decimator off and with decimator on sampling rate is 7.5 Msamples/sec. For higher + frequency probes sampling rate is 30 Ms/sec with decimator off and 15 Ms/sec with + decimator on. With the speed of ultrasound at 1540 m/sec in human tissue: 30 Ms/sec + is 0.1 mm/sample, 15 Ms/sec is 0.2 mm/sample, 7.5 Ms/sec is 0.4 mm/sample. Therfore + with 2048 samples, the depths are 5.25 cm, 10.5 cm and 21 cm. + */ + bool EnableRFDecimator(); + bool DisableRFDecimator(); + +private: + HWControls( const HWControls &); + void operator=( const HWControls &); + + HWControlsImpl *Impl; +}; + +} // end namespace Controls } // end namespace IntersonCxx diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h index cf1314c..9d05cf3 100644 --- a/include/IntersonCxxImagingScan2DClass.h +++ b/include/IntersonCxxImagingScan2DClass.h @@ -17,54 +17,54 @@ class Scan2DClassImpl; class IntersonCxx_EXPORT Scan2DClass { public: - Scan2DClass(); - ~Scan2DClass(); + Scan2DClass(); + ~Scan2DClass(); - static const int MAX_SAMPLES = 1024; - static const int MAX_RFSAMPLES = 2048; - static const int MAX_VECTORS = 241; + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + static const int MAX_VECTORS = 241; - typedef unsigned char BmodePixelType; - typedef short RFPixelType; + typedef unsigned char BmodePixelType; + typedef short RFPixelType; - bool GetScanOn() const; + bool GetScanOn() const; - bool GetRFData() const; - void SetRFData( bool transferOn ); + bool GetRFData() const; + void SetRFData( bool transferOn ); - bool GetFrameAvg() const; - void SetFrameAvg( bool doAveraging ); + bool GetFrameAvg() const; + void SetFrameAvg( bool doAveraging ); - double GetTrueDepth() const; + double GetTrueDepth() const; - void StartReadScan(); - void StartRFReadScan(); - void StopReadScan(); - void DisposeScan(); - void AbortScan(); + void StartReadScan(); + void StartRFReadScan(); + void StopReadScan(); + void DisposeScan(); + void AbortScan(); - typedef void (__stdcall *NewBmodeImageCallbackType)( BmodePixelType *buffer, - void *clientData ); - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, - void *clientData = NULL ); + typedef void (__stdcall *NewBmodeImageCallbackType)( BmodePixelType *buffer, + void *clientData ); + void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, + void *clientData = NULL ); - typedef void (__stdcall *NewScanConvertedBmodeImageCallbackType)( BmodePixelType *buffer, - void *clientData ); - /** \warning The WidthScan and HeightScan must be initialized on the - * ScanConverter before calling this method. */ - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void *clientData = NULL ); + typedef void (__stdcall *NewScanConvertedBmodeImageCallbackType)( BmodePixelType *buffer, + void *clientData ); + /** \warning The WidthScan and HeightScan must be initialized on the + * ScanConverter before calling this method. */ + void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, + void *clientData = NULL ); - typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, - void *clientData ); - void SetNewRFImageCallback( NewRFImageCallbackType callback, - void *clientData = NULL ); + typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, + void *clientData ); + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData = NULL ); private: - Scan2DClass( const Scan2DClass &); - void operator=( const Scan2DClass &); + Scan2DClass( const Scan2DClass &); + void operator=( const Scan2DClass &); - Scan2DClassImpl *Impl; + Scan2DClassImpl *Impl; }; } // end namespace Imaging diff --git a/src/IntersonCxxIntersonClass.cxx b/src/IntersonCxxIntersonClass.cxx index 278c5d0..164934b 100644 --- a/src/IntersonCxxIntersonClass.cxx +++ b/src/IntersonCxxIntersonClass.cxx @@ -17,16 +17,16 @@ namespace IntersonCxx class IntersonClassImpl { public: - IntersonClassImpl() - { - } - // Wrapped method for IntersonClass from SDK - std::string Version() - { - //This method converts data between native and managed environments. http://msdn.microsoft.com/en-us/library/bb384859.aspx - std::string marshalled = msclr::interop::marshal_as< std::string >(Interson::IntersonClass::Version ); - return marshalled; - } + IntersonClassImpl() + { + } + // Wrapped method for IntersonClass from SDK + std::string Version() + { + //This method converts data between native and managed environments. http://msdn.microsoft.com/en-us/library/bb384859.aspx + std::string marshalled = msclr::interop::marshal_as< std::string >(Interson::IntersonClass::Version ); + return marshalled; + } private: }; @@ -36,18 +36,18 @@ class IntersonClassImpl #pragma unmanaged IntersonClass::IntersonClass(): - Impl( new IntersonClassImpl() ) + Impl( new IntersonClassImpl() ) { } IntersonClass::~IntersonClass() { - delete Impl; + delete Impl; } std::string IntersonClass::Version() const { - return Impl->Version(); + return Impl->Version(); } } // end namespace IntersonCxx From 3ee81170932131dcd5f487785db79e279837ba0c Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Tue, 7 Mar 2017 20:54:59 -0500 Subject: [PATCH 062/103] ENH: Converted IntersonSDKWrapping to IntersonArraySDKWrapping The include, src, and test directories have been updated to use the linear array probe from Interson. The app directory has not been updated in this initial submission. All tests pass. --- CMakeLists.txt | 79 ++- IntersonArraySDKCxxConfig.cmake.in | 58 ++ IntersonSDKCxxConfig.cmake.in | 30 - ...Mode.cxx => AcquireIntersonArrayBMode.cxx} | 38 +- ...Mode.xml => AcquireIntersonArrayBMode.xml} | 0 ...ersonRF.cxx => AcquireIntersonArrayRF.cxx} | 0 ...ersonRF.xml => AcquireIntersonArrayRF.xml} | 0 app/CMakeLists.txt | 98 ++-- ...fo.cxx => PrintIntersonArrayProbeInfo.cxx} | 39 +- ...fo.xml => PrintIntersonArrayProbeInfo.xml} | 0 doc/CMakeLists.StandardHeader.txt | 22 + doc/IntersonArray.StandardHeader.txt | 22 + include/CMakeLists.txt | 35 +- include/IntersonArrayCxxControlsHWControls.h | 191 +++++++ include/IntersonArrayCxxImagingCapture.h | 90 +++ .../IntersonArrayCxxImagingImageBuilding.h | 62 +++ .../IntersonArrayCxxImagingScanConverter.h | 98 ++++ include/IntersonArrayCxxIntersonClass.h | 68 +++ include/IntersonCxxControlsHWControls.h | 132 ----- include/IntersonCxxImagingScan2DClass.h | 75 --- include/IntersonCxxImagingScanConverter.h | 67 --- include/IntersonCxxIntersonClass.h | 46 -- src/CMakeLists.txt | 78 ++- src/IntersonArrayCxxControlsHWControls.cxx | 521 ++++++++++++++++++ src/IntersonArrayCxxImagingCapture.cxx | 389 +++++++++++++ src/IntersonArrayCxxImagingImageBuilding.cxx | 111 ++++ src/IntersonArrayCxxImagingScanConverter.cxx | 245 ++++++++ src/IntersonArrayCxxIntersonClass.cxx | 78 +++ src/IntersonCxxControlsHWControls.cxx | 408 -------------- src/IntersonCxxImagingScan2DClass.cxx | 424 -------------- src/IntersonCxxImagingScanConverter.cxx | 159 ------ src/IntersonCxxIntersonClass.cxx | 53 -- test/CMakeLists.txt | 32 +- ...ntersonArrayCxxControlsHWControlsTest.cxx} | 73 ++- test/IntersonArrayCxxImagingCaptureTest.cxx | 91 +++ ...ersonArrayCxxImagingScanConverterTest.cxx} | 74 ++- test/IntersonArrayCxxIntersonClassTest.cxx | 34 ++ test/IntersonCxxImagingScan2DClassTest.cxx | 64 --- test/IntersonCxxIntersonClassTest.cxx | 12 - 39 files changed, 2453 insertions(+), 1643 deletions(-) create mode 100644 IntersonArraySDKCxxConfig.cmake.in delete mode 100644 IntersonSDKCxxConfig.cmake.in rename app/{AcquireIntersonBMode.cxx => AcquireIntersonArrayBMode.cxx} (83%) rename app/{AcquireIntersonBMode.xml => AcquireIntersonArrayBMode.xml} (100%) rename app/{AcquireIntersonRF.cxx => AcquireIntersonArrayRF.cxx} (100%) rename app/{AcquireIntersonRF.xml => AcquireIntersonArrayRF.xml} (100%) rename app/{PrintIntersonProbeInfo.cxx => PrintIntersonArrayProbeInfo.cxx} (62%) rename app/{PrintIntersonProbeInfo.xml => PrintIntersonArrayProbeInfo.xml} (100%) create mode 100644 doc/CMakeLists.StandardHeader.txt create mode 100644 doc/IntersonArray.StandardHeader.txt create mode 100644 include/IntersonArrayCxxControlsHWControls.h create mode 100644 include/IntersonArrayCxxImagingCapture.h create mode 100644 include/IntersonArrayCxxImagingImageBuilding.h create mode 100644 include/IntersonArrayCxxImagingScanConverter.h create mode 100644 include/IntersonArrayCxxIntersonClass.h delete mode 100644 include/IntersonCxxControlsHWControls.h delete mode 100644 include/IntersonCxxImagingScan2DClass.h delete mode 100644 include/IntersonCxxImagingScanConverter.h delete mode 100644 include/IntersonCxxIntersonClass.h create mode 100644 src/IntersonArrayCxxControlsHWControls.cxx create mode 100644 src/IntersonArrayCxxImagingCapture.cxx create mode 100644 src/IntersonArrayCxxImagingImageBuilding.cxx create mode 100644 src/IntersonArrayCxxImagingScanConverter.cxx create mode 100644 src/IntersonArrayCxxIntersonClass.cxx delete mode 100644 src/IntersonCxxControlsHWControls.cxx delete mode 100644 src/IntersonCxxImagingScan2DClass.cxx delete mode 100644 src/IntersonCxxImagingScanConverter.cxx delete mode 100644 src/IntersonCxxIntersonClass.cxx rename test/{IntersonCxxControlsHWControlsTest.cxx => IntersonArrayCxxControlsHWControlsTest.cxx} (58%) create mode 100644 test/IntersonArrayCxxImagingCaptureTest.cxx rename test/{IntersonCxxImagingScanConverterTest.cxx => IntersonArrayCxxImagingScanConverterTest.cxx} (51%) create mode 100644 test/IntersonArrayCxxIntersonClassTest.cxx delete mode 100644 test/IntersonCxxImagingScan2DClassTest.cxx delete mode 100644 test/IntersonCxxIntersonClassTest.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 02c033a..b1aa6fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,22 +1,48 @@ +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## cmake_minimum_required( VERSION 2.8 ) -project( IntersonSDKCxx ) +project( IntersonArraySDKCxx ) if( NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IntersonSDKCxx_BINARY_DIR}/bin ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/bin ) endif() if( NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IntersonSDKCxx_BINARY_DIR}/lib ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/lib ) endif() if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IntersonSDKCxx_BINARY_DIR}/lib ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/lib ) endif() -set( CONF_INCLUDE_DIRS +# Following removed because of use of duplicate variable +#set( CONF_INCLUDE_DIRS +# ${PROJECT_SOURCE_DIR}/include +# ${PROJECT_BINARY_DIR}/include ) +#include_directories( ${CONF_INCLUDE_DIRS} ) +include_directories( ${PROJECT_SOURCE_DIR}/include - ${PROJECT_BINARY_DIR}/include - ) -include_directories( ${CONF_INCLUDE_DIRS} ) + ${PROJECT_BINARY_DIR}/include ) + set( INSTALL_LIB_DIR lib ) set( INSTALL_BIN_DIR bin ) set( INSTALL_INCLUDE_DIR include ) @@ -26,6 +52,7 @@ else() set( DEF_INSTALL_CMAKE_DIR lib/CMake/FooBar ) endif() set( INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} ) + foreach( path LIB BIN INCLUDE CMAKE ) set( var INSTALL_${path}_DIR ) if( NOT IS_ABSOLUTE "${${var}}" ) @@ -33,11 +60,11 @@ foreach( path LIB BIN INCLUDE CMAKE ) endif() endforeach() -find_path( IntersonSDK_DIR NAMES Libraries/Interson.dll - PATHS C:/IntersonSDK ) -if( NOT IntersonSDK_DIR ) - message( SEND_ERROR "Please specify the path to the IntersonSDK in - IntersonSDK_DIR" ) +find_path( IntersonArraySDK_DIR NAMES Libraries/IntersonArray.dll + PATHS C:/IntersonArraySDK ) +if( NOT IntersonArraySDK_DIR ) + message( SEND_ERROR "Please specify the path to the IntersonArraySDK" + " in IntersonArraySDK_DIR" ) endif() add_subdirectory( include ) @@ -54,23 +81,27 @@ if( BUILD_APPLICATIONS ) add_subdirectory( app ) endif() -export( TARGETS IntersonCxx - FILE "${PROJECT_BINARY_DIR}/IntersonSDKCxxTargets.cmake" - ) -export( PACKAGE IntersonSDKCxx ) +export( TARGETS IntersonArrayCxx + FILE "${PROJECT_BINARY_DIR}/IntersonArraySDKCxxTargets.cmake" ) +export( PACKAGE IntersonArraySDKCxx ) + file( RELATIVE_PATH _relative_include_dir "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}" ) -configure_file( IntersonSDKCxxConfig.cmake.in - "${PROJECT_BINARY_DIR}/IntersonSDKCxxConfig.cmake" @ONLY ) -set( CONF_INCLUDE_DIRS "\${IntersonSDKCxx_CMAKE_DIR}/${_relative_include_dir}" ) -configure_file( IntersonSDKCxxConfig.cmake.in - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonSDKCxxConfig.cmake" @ONLY ) + +configure_file( IntersonArraySDKCxxConfig.cmake.in + "${PROJECT_BINARY_DIR}/IntersonArraySDKCxxConfig.cmake" @ONLY ) + +set( CONF_INCLUDE_DIRS + "\${IntersonArraySDKCxx_CMAKE_DIR}/${_relative_include_dir}" ) +configure_file( IntersonArraySDKCxxConfig.cmake.in + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonArraySDKCxxConfig.cmake" + @ONLY ) install( FILES - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonSDKCxxConfig.cmake" + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonArraySDKCxxConfig.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT Development ) -install( EXPORT IntersonSDKCxxTargets DESTINATION +install( EXPORT IntersonArraySDKCxxTargets DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT Development ) diff --git a/IntersonArraySDKCxxConfig.cmake.in b/IntersonArraySDKCxxConfig.cmake.in new file mode 100644 index 0000000..1d167a1 --- /dev/null +++ b/IntersonArraySDKCxxConfig.cmake.in @@ -0,0 +1,58 @@ +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## + +# Config file for the IntersonArraySDKCxx library wrapper. +# +# It defines the following variables: +# IntersonArraySDKCxx_INCLUDE_DIRS - include directories for +# IntersonArraySDKCxx +# IntersonArraySDKCxx_RUNTIME_LIBRARY_DIRS - directories that store the +# libraries needed for runtime execution +# IntersonArraySDKCxx_LIBRARIES - libraries to link against +# IntersonArraySDK_DIR - Path to the IntersonArraySDK used to +# build this library. + +get_filename_component( IntersonArraySDKCxx_CMAKE_DIR + "${CMAKE_CURRENT_LIST_FILE}" PATH ) + +set( IntersonArraySDKCxx_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@" ) + +if( NOT TARGET IntersonArrayCxx AND NOT IntersonArraySDKCxx_BINARY_DIR ) + include( "${IntersonArraySDKCxx_CMAKE_DIR}/IntersonArraySDKCxxTargets.cmake" ) +endif() + +set( IntersonArraySDKCxx_LIBRARIES IntersonArrayCxx ) + +set( IntersonArrayCxx_RUNTIME_LIBRARY_DIRS ) +get_property( _configs TARGET IntersonArrayCxx PROPERTY + IMPORTED_CONFIGURATIONS ) +foreach( _config ${_configs} ) + get_property( _libloc TARGET IntersonArrayCxx PROPERTY + IMPORTED_LOCATION_${_config} ) + if( EXISTS "${_libloc}" ) + get_filename_component( _libpath "${_libloc}" PATH ) + list( APPEND IntersonArrayCxx_RUNTIME_LIBRARY_DIRS "${_libpath}" ) + endif() +endforeach() + +set( IntersonArraySDK_DIR "@IntersonArraySDK_DIR@" ) diff --git a/IntersonSDKCxxConfig.cmake.in b/IntersonSDKCxxConfig.cmake.in deleted file mode 100644 index 18197cc..0000000 --- a/IntersonSDKCxxConfig.cmake.in +++ /dev/null @@ -1,30 +0,0 @@ -# Config file for the IntersonSDKCxx library wrapper. -# -# It defines the following variables: -# IntersonSDKCxx_INCLUDE_DIRS - include directories for IntersonSDKCxx -# IntersonSDKCxx_RUNTIME_LIBRARY_DIRS - directories that store the libraries -# needed for runtime execution -# IntersonSDKCxx_LIBRARIES - libraries to link against -# IntersonSDK_DIR - Path to the IntersonSDK used to build this library. - -get_filename_component( IntersonSDKCxx_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) - -set( IntersonSDKCxx_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@" ) - -if( NOT TARGET IntersonCxx AND NOT IntersonSDKCxx_BINARY_DIR ) - include( "${IntersonSDKCxx_CMAKE_DIR}/IntersonSDKCxxTargets.cmake" ) -endif() - -set( IntersonSDKCxx_LIBRARIES IntersonCxx ) - -set( IntersonCxx_RUNTIME_LIBRARY_DIRS ) -get_property( _configs TARGET IntersonCxx PROPERTY IMPORTED_CONFIGURATIONS ) -foreach( _config ${_configs} ) - get_property( _libloc TARGET IntersonCxx PROPERTY IMPORTED_LOCATION_${_config} ) - if( EXISTS "${_libloc}" ) - get_filename_component( _libpath "${_libloc}" PATH ) - list( APPEND IntersonCxx_RUNTIME_LIBRARY_DIRS "${_libpath}" ) - endif() -endforeach() - -set( IntersonSDK_DIR "@IntersonSDK_DIR@" ) diff --git a/app/AcquireIntersonBMode.cxx b/app/AcquireIntersonArrayBMode.cxx similarity index 83% rename from app/AcquireIntersonBMode.cxx rename to app/AcquireIntersonArrayBMode.cxx index 8fbf32e..a6a7a7e 100644 --- a/app/AcquireIntersonBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -1,14 +1,36 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ #include // Sleep #include "itkImageFileWriter.h" -#include "IntersonCxxControlsHWControls.h" -#include "IntersonCxxImagingScan2DClass.h" -#include "IntersonCxxImagingScanConverter.h" +#include "IntersonArrayCxxControlsHWControls.h" +#include "IntersonArrayCxxImagingCapture.h" +#include "IntersonArrayCxxImagingScanConverter.h" -#include "AcquireIntersonBModeCLP.h" +#include "AcquireIntersonArrayBModeCLP.h" -typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; +typedef IntersonArrayCxx::Imaging::Scan2DClass Scan2DClassType; const unsigned int Dimension = 3; typedef Scan2DClassType::BmodePixelType PixelType; @@ -76,12 +98,12 @@ int main( int argc, char * argv[] ) { PARSE_ARGS; - typedef IntersonCxx::Controls::HWControls HWControlsType; - IntersonCxx::Controls::HWControls hwControls; + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + IntersonArrayCxx::Controls::HWControls hwControls; Scan2DClassType scan2D; - typedef IntersonCxx::Imaging::ScanConverter ScanConverterType; + typedef IntersonArrayCxx::Imaging::ScanConverter ScanConverterType; ScanConverterType scanConverter; typedef HWControlsType::FoundProbesType FoundProbesType; diff --git a/app/AcquireIntersonBMode.xml b/app/AcquireIntersonArrayBMode.xml similarity index 100% rename from app/AcquireIntersonBMode.xml rename to app/AcquireIntersonArrayBMode.xml diff --git a/app/AcquireIntersonRF.cxx b/app/AcquireIntersonArrayRF.cxx similarity index 100% rename from app/AcquireIntersonRF.cxx rename to app/AcquireIntersonArrayRF.cxx diff --git a/app/AcquireIntersonRF.xml b/app/AcquireIntersonArrayRF.xml similarity index 100% rename from app/AcquireIntersonRF.xml rename to app/AcquireIntersonArrayRF.xml diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index dc498c3..9755170 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,3 +1,25 @@ +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## find_package( SlicerExecutionModel REQUIRED ) include( ${SlicerExecutionModel_USE_FILE} ) @@ -5,24 +27,24 @@ find_package( ITK REQUIRED ) include( ${ITK_USE_FILE} ) SEMMacroBuildCLI( - NAME AcquireIntersonBMode + NAME AcquireIntersonArrayBMode TARGET_LIBRARIES ${ITK_LIBRARIES} - IntersonCxx + IntersonArrayCxx INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) SEMMacroBuildCLI( - NAME AcquireIntersonRF + NAME AcquireIntersonArrayRF TARGET_LIBRARIES ${ITK_LIBRARIES} - IntersonCxx + IntersonArrayCxx INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) SEMMacroBuildCLI( - NAME PrintIntersonProbeInfo - TARGET_LIBRARIES IntersonCxx + NAME PrintIntersonArrayProbeInfo + TARGET_LIBRARIES IntersonArrayCxx INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) @@ -30,60 +52,60 @@ SEMMacroBuildCLI( if( BUILD_TESTING ) set( TEMP ${PROJECT_BINARY_DIR}/Testing/Temporary ) - add_test( NAME AcquireIntersonBModeTest - COMMAND $ - ${TEMP}/AcquireIntersonBModeTest.mha + add_test( NAME AcquireIntersonArrayBModeTest + COMMAND $ + ${TEMP}/AcquireIntersonArrayBModeTest.mha ) - add_test( NAME AcquireIntersonBModeTestFrames - COMMAND $ + add_test( NAME AcquireIntersonArrayBModeTestFrames + COMMAND $ --frames 5 - ${TEMP}/AcquireIntersonBModeTestFrames.mha + ${TEMP}/AcquireIntersonArrayBModeTestFrames.mha ) - add_test( NAME AcquireIntersonBModeTestVoltage - COMMAND $ + add_test( NAME AcquireIntersonArrayBModeTestVoltage + COMMAND $ --highVoltage 30 - ${TEMP}/AcquireIntersonBModeTestVoltage.mha + ${TEMP}/AcquireIntersonArrayBModeTestVoltage.mha ) - add_test( NAME AcquireIntersonBModeTestGain - COMMAND $ + add_test( NAME AcquireIntersonArrayBModeTestGain + COMMAND $ --gain 50 - ${TEMP}/AcquireIntersonBModeTestGain.mha + ${TEMP}/AcquireIntersonArrayBModeTestGain.mha ) - add_test( NAME AcquireIntersonBModeTestScanConvert - COMMAND $ + add_test( NAME AcquireIntersonArrayBModeTestScanConvert + COMMAND $ --scanConvert --gain 50 - ${TEMP}/AcquireIntersonBModeTestScanConvert.mha + ${TEMP}/AcquireIntersonArrayBModeTestScanConvert.mha ) - add_test( NAME AcquireIntersonBModeTestScanConvertFrames - COMMAND $ + add_test( NAME AcquireIntersonArrayBModeTestScanConvertFrames + COMMAND $ -s -n 4 --gain 50 - ${TEMP}/AcquireIntersonBModeTestScanConvertFrames.mha + ${TEMP}/AcquireIntersonArrayBModeTestScanConvertFrames.mha ) - add_test( NAME AcquireIntersonRFTest - COMMAND $ - ${TEMP}/AcquireIntersonRFTest.mha + add_test( NAME AcquireIntersonArrayRFTest + COMMAND $ + ${TEMP}/AcquireIntersonArrayRFTest.mha ) - add_test( NAME AcquireIntersonRFTestFrames - COMMAND $ + add_test( NAME AcquireIntersonArrayRFTestFrames + COMMAND $ --frames 5 - ${TEMP}/AcquireIntersonRFTestFrames.mha + ${TEMP}/AcquireIntersonArrayRFTestFrames.mha ) - add_test( NAME AcquireIntersonRFTestVoltage - COMMAND $ + add_test( NAME AcquireIntersonArrayRFTestVoltage + COMMAND $ --highVoltage 30 - ${TEMP}/AcquireIntersonRFTestVoltage.mha + ${TEMP}/AcquireIntersonArrayRFTestVoltage.mha ) - add_test( NAME AcquireIntersonRFTestDecimator - COMMAND $ + add_test( NAME AcquireIntersonArrayRFTestDecimator + COMMAND $ --decimator - ${TEMP}/AcquireIntersonRFTestDecimator.mha + ${TEMP}/AcquireIntersonArrayRFTestDecimator.mha ) - add_test( NAME PrintIntersonProbeInfoTest - COMMAND $ + add_test( NAME PrintIntersonArrayProbeInfoTest + COMMAND $ ) endif() diff --git a/app/PrintIntersonProbeInfo.cxx b/app/PrintIntersonArrayProbeInfo.cxx similarity index 62% rename from app/PrintIntersonProbeInfo.cxx rename to app/PrintIntersonArrayProbeInfo.cxx index fe1f684..b6a24e2 100644 --- a/app/PrintIntersonProbeInfo.cxx +++ b/app/PrintIntersonArrayProbeInfo.cxx @@ -1,18 +1,36 @@ -#include "IntersonCxxImagingScan2DClass.h" -#include "IntersonCxxControlsHWControls.h" -#include "IntersonCxxIntersonClass.h" +/*========================================================================= -#include "PrintIntersonProbeInfoCLP.h" +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include "IntersonArrayCxxControlsHWControls.h" +#include "IntersonArrayCxxIntersonClass.h" + +#include "PrintIntersonArrayProbeInfoCLP.h" int main( int argc, char * argv[] ) { PARSE_ARGS; - typedef IntersonCxx::Controls::HWControls HWControlsType; - IntersonCxx::Controls::HWControls hwControls; - - typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; - Scan2DClassType scan2D; + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + IntersonArrayCxx::Controls::HWControls hwControls; typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; @@ -40,7 +58,6 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); std::cout << "\nFrequencies: [Hz]" << std::endl; @@ -63,7 +80,7 @@ int main( int argc, char * argv[] ) std::cout << "OEM ID: " << hwControls.GetOEMId() << std::endl; std::cout << "Filter ID: " << hwControls.GetFilterId() << std::endl; - IntersonCxx::IntersonClass intersonClass; + IntersonArrayCxx::IntersonClass intersonClass; std::cout << "SDK Version: " << intersonClass.Version() << std::endl; return EXIT_SUCCESS; diff --git a/app/PrintIntersonProbeInfo.xml b/app/PrintIntersonArrayProbeInfo.xml similarity index 100% rename from app/PrintIntersonProbeInfo.xml rename to app/PrintIntersonArrayProbeInfo.xml diff --git a/doc/CMakeLists.StandardHeader.txt b/doc/CMakeLists.StandardHeader.txt new file mode 100644 index 0000000..f0c11ce --- /dev/null +++ b/doc/CMakeLists.StandardHeader.txt @@ -0,0 +1,22 @@ +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## diff --git a/doc/IntersonArray.StandardHeader.txt b/doc/IntersonArray.StandardHeader.txt new file mode 100644 index 0000000..0c5a20d --- /dev/null +++ b/doc/IntersonArray.StandardHeader.txt @@ -0,0 +1,22 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index b86fd2c..4be57aa 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,10 +1,33 @@ -set( IntersonCxx_HEADERS - IntersonCxxControlsHWControls.h - IntersonCxxImagingScan2DClass.h - IntersonCxxImagingScanConverter.h - IntersonCxxIntersonClass.h +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## +set( IntersonArrayCxx_HEADERS + IntersonArrayCxxControlsHWControls.h + IntersonArrayCxxImagingCapture.h + IntersonArrayCxxImagingImageBuilding.h + IntersonArrayCxxImagingScanConverter.h + IntersonArrayCxxIntersonArrayClass.h ) install( FILES - ${IntersonCxx_HEADERS} + ${IntersonArrayCxx_HEADERS} DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT Development ) diff --git a/include/IntersonArrayCxxControlsHWControls.h b/include/IntersonArrayCxxControlsHWControls.h new file mode 100644 index 0000000..d4d8d79 --- /dev/null +++ b/include/IntersonArrayCxxControlsHWControls.h @@ -0,0 +1,191 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#ifndef _IntersonArrayCxxControlsHWControls_h +#define _IntersonArrayCxxControlsHWControls_h + +// Export library, autogenerated using Cmake +#include "IntersonArrayCxx_Export.h" + +#include +#include + +// Namespace similar to IntersonArray Namespace from SDK + +/* +The library is organized via namespaces; the root is IntersonArray, +then IntersonArray.Controls to get the methods which access to the +USB probe controls, IntersonArray.Imaging is the scan converter, to +build the 2D image B-Scan bitmap from the log-compressed A-Scan +vectors. +*/ +namespace IntersonArrayCxx +{ +// Namespace similar to IntersonArray.Controls Namespace from SDK +namespace Controls +{ +// Wrapper Class for IntersonArrayClass from SDK +class HWControlsImpl; + +// HWControls similar to IntersonArrayClass from SDK +class IntersonArrayCxx_EXPORT HWControls +{ +public: + typedef std::vector< std::string > FoundProbesType; + typedef std::vector< int > FrequenciesType; + typedef std::vector< int > FocusType; + + HWControls(); + ~HWControls(); + + static const int DIG_GAIN_MIN = -127; + static const int DIG_GAIN_INIT = 0; + static const int DIG_GAIN_MAX = 127; + + // Maximum number of frequencies + static const int MAX_FREQ = 3; + + // Maximum focus + static const int MAX_FOCUS = 3; + + // Maximum stgeering angle + static const int MAX_STERING_ANGLE = 30; + + // These are the valid Probe IDs. + static const int ID_A_7_5MHz = 256; + static const int ID_CA_5_0MHz = 512; + static const int ID_CA_OP_10MHz = 768; + static const int ID_A_OP_10MHz = 1024; + static const int ID_A_OP_12MHz = 1280; + + // Size of the OEM (Original equipment manufacturer) space in the Probe + // EEPROM number of frequencies. + // http://en.wikipedia.org/wiki/Original_equipment_manufacturer + static const unsigned short int EEOEMSpace = 6144; + + // Compound Angle Functions + int GetCompoundAngle() const; + bool EnableCompound(); + bool DisableCompound(); + + // Doubler Functions + bool EnableDoubler(); + bool DisableDoubler(); + + // To get the ID of the probe + short GetProbeID() const; + + // String Vector with all probe names connected + void FindAllProbes( FoundProbesType &foundProbes ) const; + + // Summary: To open a handle to the probe defined by the ProbeIndex. + // Parameters: " ProbeIndex ": Index in the mycolProbesName collection + void FindMyProbe( int probeIndex ); + + // Angle + float GetArrayAngle() const; + + // Radius + float GetArrayRadius() const; + + // Width + float GetArrayWidth() const; + + // Focus + void GetFocus( FocusType & focus ) const; + + // To check if the chosen Depth is valid for the probe. Returns the same + // depth if in the max range, otherwise returns the max depth + int ValidDepth( int depth ) const; + + // Get/Set the list of supported frequencies. Units: Hz. + void GetFrequency( FrequenciesType &frequencies ) const; + bool SetFrequencyAndFocus( unsigned char frequency, unsigned char focus, + int steering ); + + // Lines per array + unsigned int GetLinesPerArray() const; + + //" voltage ": percentage of the maximum of the High Voltage. Returns + //whether the command succeeded (true) or failed (false) + bool SendHighVoltage( unsigned char voltage, unsigned char voltageCfm ); + bool EnableHighVoltage(); + bool DisableHighVoltage(); + + // To set the value of the dynamic and to calculate the value sent to + // the control. " bytDynamic ": value of the Dynamic (db). + // Returns: Returns whether the command succeeded (true) or failed (false) + bool SendDynamic( unsigned char dynamic ); + + // To Start watching the Hardware Button to enable to raise the event + // HWButtonTick + void EnableHardButton(); + void DisableHardButton(); + unsigned char ReadHardButton(); + + typedef void (__stdcall *NewHardButtonCallbackType)( void *clientData ); + void SetNewHardButtonCallback( NewHardButtonCallbackType callback, + void *clientData = NULL ); + + bool StartBmode(); + bool StartRFmode(); + bool StopAcquisition(); + + //To get the Frame Rate of that probe according to the depth + //" iDepth ": current depth. Returns: Return the current Frame Rate + short GetProbeFrameRate() const; + + // To get the Serial Number of the probe + std::string GetProbeSerialNumber() const; + + // To get the version of the software installed in the FPGA. + std::string ReadFPGAVersion() const; + + // To get the identification of the OEM + std::string GetOEMId() const; + + // To get the identification of 3D + std::string Get3DId() const; + + //To get the identification of the filter. + std::string GetFilterId() const; + + bool DoReadOEMEEPROM( unsigned char & bytDataStage, unsigned short addr, + unsigned short length ); + + bool DoWriteOEMEEPROM( unsigned char & bytDataStage, unsigned short addr, + unsigned short length ); + + +private: + HWControls( const HWControls &); + void operator=( const HWControls &); + + HWControlsImpl *Impl; +}; + +} // end namespace Controls + +} // end namespace IntersonArrayCxx + + +#endif // _IntersonArrayCxxControlsHWControls_h diff --git a/include/IntersonArrayCxxImagingCapture.h b/include/IntersonArrayCxxImagingCapture.h new file mode 100644 index 0000000..78a8ffb --- /dev/null +++ b/include/IntersonArrayCxxImagingCapture.h @@ -0,0 +1,90 @@ +/*========================================================================= + +Library: IntersonArraySDKCxx + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#ifndef _IntersonArrayCxxImagingCapture_h +#define _IntersonArrayCxxImagingCapture_h + +#include "IntersonArrayCxx_Export.h" + +#include +#include + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +class CaptureImpl; + +class IntersonArrayCxx_EXPORT Capture +{ +public: + Capture(); + ~Capture(); + + typedef unsigned char PixelType; + typedef unsigned short RFPixelType; + + bool GetRFData(); + + void SetRFData( bool value ); + + bool GetFrameAvg(); + + void SetFrameAvg( bool value ); + + bool GetScanOn() const; + + void AbortScan(); + + void DisposeScan(); + + void StartReadScan(); + + void StartRFReadScan(); + + void StopReadScan(); + + typedef void (__stdcall *NewImageCallbackType)( PixelType *buffer, + void *clientData ); + void SetNewImageCallback( NewImageCallbackType callback, + void *clientData = NULL ); + + typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, + void *clientData ); + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData = NULL ); + +private: + Capture( const Capture &); + void operator=( const Capture &); + + CaptureImpl *Impl; +}; + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx + + +#endif // _IntersonArrayCxxImagingCapture_h diff --git a/include/IntersonArrayCxxImagingImageBuilding.h b/include/IntersonArrayCxxImagingImageBuilding.h new file mode 100644 index 0000000..bed056b --- /dev/null +++ b/include/IntersonArrayCxxImagingImageBuilding.h @@ -0,0 +1,62 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#ifndef _IntersonArrayCxxImagingImageBuilding_h +#define _IntersonArrayCxxImagingImageBuilding_h + +#include "IntersonArrayCxx_Export.h" + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +class ImageBuildingImpl; + +class ScanConverter; + +class IntersonArrayCxx_EXPORT ImageBuilding +{ +public: + ImageBuilding(); + ~ImageBuilding(); + + void Build2D( unsigned char * bmpDest, unsigned char * byteRaw, + ScanConverter & scanConverter ); + + void Build2D( unsigned char * bmpDest, unsigned char * byteRawCurrent, + unsigned char * byteRawPrevious, ScanConverter & scanConverter ); + +private: + ImageBuilding( const ImageBuilding &); + void operator=( const ImageBuilding &); + + ImageBuildingImpl *Impl; +}; + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx + + +#endif // _IntersonArrayCxxImagingImageBuilding_h diff --git a/include/IntersonArrayCxxImagingScanConverter.h b/include/IntersonArrayCxxImagingScanConverter.h new file mode 100644 index 0000000..34dbe10 --- /dev/null +++ b/include/IntersonArrayCxxImagingScanConverter.h @@ -0,0 +1,98 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#ifndef _IntersonArrayCxxImagingScanConverter_h +#define _IntersonArrayCxxImagingScanConverter_h + +#include "IntersonArrayCxx_Export.h" +#include "IntersonArrayCxxImagingCapture.h" +#include "IntersonArrayCxxImagingImageBuilding.h" + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +class ScanConverterImpl; + +class IntersonArrayCxx_EXPORT ScanConverter +{ +public: + ScanConverter(); + ~ScanConverter(); + + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + + bool GetCompound(); + + void SetCompound( bool value ); + + bool GetDoubler(); + + void SetDoubler( bool value ); + + int GetHeightScan() const; + + float GetMmPerPixel() const; + + double GetTrueDepth() const; + + int GetWidthScan() const; + + int GetZeroOfYScale() const; + + // Error code of HardInitScanConverter and SoftInitScanConverter + enum ScanConverterError + { + SUCCESS = 1, + PROBE_NOT_INITIALIZED, // FindMyProbe has not been called + UNKNOWN_PROBE, // Probe Identity not valid + UNDER_LIMITS, // Width * Height over 10 * 10 + OVER_LIMITS, // Width * Height over 800 * 1000 + WRONG_FORMAT, // other error + ERROR + }; + + ScanConverterError HardInitScanConverter( int depth, int widthScan, + int heightScan, int steering, Capture & capture, + ImageBuilding & imageBuilding ); + + ScanConverterError IdleInitScanConverter( int depth, int width, + int height, short idleId, int idleSteering, bool idleDoubler, + bool idleCompound, int idleCompoundAngle, ImageBuilding & + imageBuilding ); + +private: + ScanConverter( const ScanConverter &); + void operator=( const ScanConverter &); + + ScanConverterImpl *Impl; +}; + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx + + +#endif // _IntersonArrayCxxImagingScanConverter_h diff --git a/include/IntersonArrayCxxIntersonClass.h b/include/IntersonArrayCxxIntersonClass.h new file mode 100644 index 0000000..b012438 --- /dev/null +++ b/include/IntersonArrayCxxIntersonClass.h @@ -0,0 +1,68 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#ifndef _IntersonArrayCxxIntersonClass_h +#define _IntersonArrayCxxIntersonClass_h + +// Export library, autogenerated using Cmake +#include "IntersonArrayCxx_Export.h" + +#include + +// Namespace similar to IntersonArray Namespace from SDK + +/* +The library is organized via namespaces; the root is “IntersonArray”, +then “IntersonArray.Controls” to get the methods which access to the +USB probe controls, “IntersonArray.Imaging” is the scan converter, to +build the 2D image B-Scan bitmap from the log-compressed A-Scan +vectors. +*/ +namespace IntersonArrayCxx +{ +// Wrapper Class for IntersonClass from SDK +class IntersonClassImpl; + +// IntersonClass similar to IntersonClass from SDK +class IntersonArrayCxx_EXPORT IntersonClass +{ +public: + IntersonClass(); + ~IntersonClass(); + + /* + Summary: To Get the version of IntersonArray.dll + Returns: Returns the String of the version. + */ + std::string Version() const; + +private: + IntersonClass( const IntersonClass &); + void operator=( const IntersonClass &); + + // Add the wrapper to the main class to use dll function in C# + IntersonClassImpl *Impl; +}; + +} // end namespace IntersonArrayCxx + +#endif // _IntersonArrayCxxIntersonClass_h diff --git a/include/IntersonCxxControlsHWControls.h b/include/IntersonCxxControlsHWControls.h deleted file mode 100644 index b7dbea4..0000000 --- a/include/IntersonCxxControlsHWControls.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef _IntersonCxxControlsHWControls_h -#define _IntersonCxxControlsHWControls_h - -// Export library, autogenerated using Cmake -#include "IntersonCxx_Export.h" - -#include -#include - -// Namespace similar to Interson Namespace from SDK - -/* -The library is organized via namespaces; the root is Interson, -then Interson.Controls to get the methods which access to the -USB probe controls, Interson.Imaging is the scan converter, to -build the 2D image B-Scan bitmap from the log-compressed A-Scan -vectors. -*/ -namespace IntersonCxx -{ -// Namespace similar to Interson.Controls Namespace from SDK -namespace Controls -{ -// Wrapper Class for IntersonClass from SDK -class HWControlsImpl; - -// HWControls similar to IntersonClass from SDK -class IntersonCxx_EXPORT HWControls -{ -public: - typedef std::vector< std::string > FoundProbesType; - typedef std::vector< int > FrequenciesType; - HWControls(); - ~HWControls(); - - static const int DIG_GAIN_MIN = -127; - static const int DIG_GAIN_INIT = 0; - static const int DIG_GAIN_MAX = 127; - - // Maximum number of frequencies - static const int MAX_FREQ = 3; - - // These are the valid Probe IDs. - static const int ID_GP_3_5MHz = 1; - static const int ID_VC_7_5MHz = 2; - static const int ID_SP_7_5MHz = 3; - static const int ID_EC_7_5MHz = 4; - static const int ID_MV_12_MHz = 5; - static const int ID_GV_5_MHz = 6; - - // Size of the OEM (Original equipment manufacturer) space in the Probe EEPROM number of frequencies. http://en.wikipedia.org/wiki/Original_equipment_manufacturer - static const unsigned short int EEOEMSpace = 4096; - - // String Vector with all probe names connected - void FindAllProbes( FoundProbesType &foundProbes ) const; - // Summary: To open a handle to the probe defined by the ProbeIndex. Parameters: " ProbeIndex ": Index in the mycolProbesName collection - void FindMyProbe( int probeIndex ); - //To get the ID of the probe - unsigned char GetProbeID() const; - - /** Units: mm */ - // To check if the chosen Depth is valid for the probe. Returns the same depth if in the max range, otherwise returns the max depth - int ValidDepth( int depth ) const; - - /** Get the list of supported frequencies. Units: Hz. */ - void GetFrequency( FrequenciesType &frequencies ) const; - bool SetFrequency( int frequency ); - - /** Units: Volts */ - //" voltage ": percentage of the maximum of the High Voltage. Returns whether the command succeeded (true) or failed (false) - bool SendHighVoltage( unsigned char voltage ); - bool EnableHighVoltage(); - bool DisableHighVoltage(); - - // To set the value of the dynamic and to calculate the value sent to the control. " bytDynamic ": value of the Dynamic (db). - // Returns: Returns whether the command succeeded (true) or failed (false) - bool SendDynamic( unsigned char dynamic ); - - //To start/stop the motor of the probe - bool StartMotor(); - bool StopMotor(); - - // To Start watching the Hardware Button to enable to raise the event “HWButtonTick†- void EnableHardButton(); - void DisableHardButton(); - unsigned char ReadHardButton(); - - bool StartBmode(); - bool StartRFmode(); - bool StopAcquisition(); - - //To get the Frame Rate of that probe according to the depth - //" iDepth ": current depth. Returns: Return the current Frame Rate - short GetProbeFrameRate( int depth ); - - // To get the Serial Number of the probe - std::string GetProbeSerialNumber() const; - - // To get the version of the software installed in the FPGA. - std::string ReadFPGAVersion() const; - - // To get the identification of the OEM - std::string GetOEMId() const; - - //To get the identification of the filter. - std::string GetFilterId() const; - - //To enable the RF Decimator. Returns: Returns whether the command succeeded (true) or failed (false) - /* - Note: For GV and GP (low frequency probes) sampling rate is 15 Msamples/sec with - decimator off and with decimator on sampling rate is 7.5 Msamples/sec. For higher - frequency probes sampling rate is 30 Ms/sec with decimator off and 15 Ms/sec with - decimator on. With the speed of ultrasound at 1540 m/sec in human tissue: 30 Ms/sec - is 0.1 mm/sample, 15 Ms/sec is 0.2 mm/sample, 7.5 Ms/sec is 0.4 mm/sample. Therfore - with 2048 samples, the depths are 5.25 cm, 10.5 cm and 21 cm. - */ - bool EnableRFDecimator(); - bool DisableRFDecimator(); - -private: - HWControls( const HWControls &); - void operator=( const HWControls &); - - HWControlsImpl *Impl; -}; - -} // end namespace Controls - -} // end namespace IntersonCxx - - -#endif // _IntersonCxxControlsHWControls_h diff --git a/include/IntersonCxxImagingScan2DClass.h b/include/IntersonCxxImagingScan2DClass.h deleted file mode 100644 index 9d05cf3..0000000 --- a/include/IntersonCxxImagingScan2DClass.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef _IntersonCxxImagingScan2DClass_h -#define _IntersonCxxImagingScan2DClass_h - -#include "IntersonCxx_Export.h" - -#include -#include - -namespace IntersonCxx -{ - -namespace Imaging -{ - -class Scan2DClassImpl; - -class IntersonCxx_EXPORT Scan2DClass -{ -public: - Scan2DClass(); - ~Scan2DClass(); - - static const int MAX_SAMPLES = 1024; - static const int MAX_RFSAMPLES = 2048; - static const int MAX_VECTORS = 241; - - typedef unsigned char BmodePixelType; - typedef short RFPixelType; - - bool GetScanOn() const; - - bool GetRFData() const; - void SetRFData( bool transferOn ); - - bool GetFrameAvg() const; - void SetFrameAvg( bool doAveraging ); - - double GetTrueDepth() const; - - void StartReadScan(); - void StartRFReadScan(); - void StopReadScan(); - void DisposeScan(); - void AbortScan(); - - typedef void (__stdcall *NewBmodeImageCallbackType)( BmodePixelType *buffer, - void *clientData ); - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, - void *clientData = NULL ); - - typedef void (__stdcall *NewScanConvertedBmodeImageCallbackType)( BmodePixelType *buffer, - void *clientData ); - /** \warning The WidthScan and HeightScan must be initialized on the - * ScanConverter before calling this method. */ - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void *clientData = NULL ); - - typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, - void *clientData ); - void SetNewRFImageCallback( NewRFImageCallbackType callback, - void *clientData = NULL ); - -private: - Scan2DClass( const Scan2DClass &); - void operator=( const Scan2DClass &); - - Scan2DClassImpl *Impl; -}; - -} // end namespace Imaging - -} // end namespace IntersonCxx - - -#endif // _IntersonCxxImagingScan2DClass_h diff --git a/include/IntersonCxxImagingScanConverter.h b/include/IntersonCxxImagingScanConverter.h deleted file mode 100644 index e488f49..0000000 --- a/include/IntersonCxxImagingScanConverter.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _IntersonCxxImagingScanConverter_h -#define _IntersonCxxImagingScanConverter_h - -#include "IntersonCxx_Export.h" - -namespace IntersonCxx -{ - -namespace Imaging -{ - -class ScanConverterImpl; - -class IntersonCxx_EXPORT ScanConverter -{ -public: - ScanConverter(); - ~ScanConverter(); - - static const int MAX_SAMPLES = 1024; - static const int MAX_RFSAMPLES = 2048; - static const int MAX_VECTORS = 241; - - // Error code of HardInitScanConverter and SoftInitScanConverter - enum ScanConverterError - { - SUCCESS = 1, - PROBE_NOT_INITIALIZED, // FindMyProbe has not been called - UNKNOWN_PROBE, // Probe Identity not valid - UNDER_LIMITS, // Width * Height over 10 * 10 - OVER_LIMITS, // Width * Height over 800 * 1000 - OTHER_ERROR // other error - }; - - int GetHeightScan() const; - int GetWidthScan() const; - - float GetMmPerPixel() const; - int GetZeroOfYScale() const; - - // Optimal iHeightScan is 512. Optimal iWidthScan is 776 for 90 degree (GP, SP, EC) probes, and 590 for a 60 degree (VC) probe. - ScanConverterError HardInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan ); - - ScanConverterError IdleInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan, - unsigned char probeId ); - -private: - ScanConverter( const ScanConverter &); - void operator=( const ScanConverter &); - - ScanConverterImpl *Impl; -}; - -} // end namespace Imaging - -} // end namespace IntersonCxx - - -#endif // _IntersonCxxImagingScanConverter_h diff --git a/include/IntersonCxxIntersonClass.h b/include/IntersonCxxIntersonClass.h deleted file mode 100644 index e8ca0cf..0000000 --- a/include/IntersonCxxIntersonClass.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _IntersonCxxIntersonClass_h -#define _IntersonCxxIntersonClass_h - -// Export library, autogenerated using Cmake -#include "IntersonCxx_Export.h" - -#include - -// Namespace similar to Interson Namespace from SDK - -/* -The library is organized via namespaces; the root is “Interson”, -then “Interson.Controls” to get the methods which access to the -USB probe controls, “Interson.Imaging” is the scan converter, to -build the 2D image B-Scan bitmap from the log-compressed A-Scan -vectors. -*/ -namespace IntersonCxx -{ -// Wrapper Class for IntersonClass from SDK -class IntersonClassImpl; - -// IntersonClass similar to IntersonClass from SDK -class IntersonCxx_EXPORT IntersonClass -{ -public: - IntersonClass(); - ~IntersonClass(); - - /* - Summary: To Get the version of Interson.dll - Returns: Returns the String of the version. - */ - std::string Version() const; - -private: - IntersonClass( const IntersonClass &); - void operator=( const IntersonClass &); - - // Add the wrapper to the main class to use dll function in C# - IntersonClassImpl *Impl; -}; - -} // end namespace IntersonCxx - -#endif // _IntersonCxxIntersonClass_h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e4cafe..88f8785 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,40 +1,66 @@ -if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") - string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") -endif() - -if(CMAKE_CXX_FLAGS MATCHES "/EHsc") - string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -endif() +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## +#if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") + #string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") +#endif() +# +#if(CMAKE_CXX_FLAGS MATCHES "/EHsc") + #string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +#endif() +set( CMAKE_CXX_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" ) +set( COMPILE_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" ) -set( IntersonCxx_SRCS - IntersonCxxIntersonClass.cxx - IntersonCxxControlsHWControls.cxx - IntersonCxxImagingScan2DClass.cxx - IntersonCxxImagingScanConverter.cxx +set( IntersonArrayCxx_SRCS + IntersonArrayCxxControlsHWControls.cxx + IntersonArrayCxxImagingCapture.cxx + IntersonArrayCxxImagingImageBuilding.cxx + IntersonArrayCxxImagingScanConverter.cxx + IntersonArrayCxxIntersonClass.cxx ) include( GenerateExportHeader ) -add_library( IntersonCxx SHARED - ${IntersonCxx_SRCS} - ) -generate_export_header( IntersonCxx - BASE_NAME IntersonCxx - EXPORT_MACRO_NAME IntersonCxx_EXPORT - EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/IntersonCxx_Export.h - ) -set_target_properties( IntersonCxx PROPERTIES - COMPILE_FLAGS "/clr /EHa /AI${IntersonSDK_DIR}/Libraries" +add_library( IntersonArrayCxx SHARED + ${IntersonArrayCxx_SRCS} ) + +generate_export_header( IntersonArrayCxx + BASE_NAME IntersonArrayCxx + EXPORT_MACRO_NAME IntersonArrayCxx_EXPORT + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/IntersonArrayCxx_Export.h ) +#set_target_properties( IntersonArrayCxx PROPERTIES + #CMAKE_CXX_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" + #) + # COMPILE_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" -install( TARGETS IntersonCxx - EXPORT IntersonSDKCxxTargets +install( TARGETS IntersonArrayCxx + EXPORT IntersonArraySDKCxxTargets RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT Runtime LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development ) if( BUILD_TESTING ) # For running tests - add_custom_command( TARGET IntersonCxx + add_custom_command( TARGET IntersonArrayCxx POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonSDK_DIR}/Libraries/Interson.dll" "${PROJECT_BINARY_DIR}/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin" ) endif() diff --git a/src/IntersonArrayCxxControlsHWControls.cxx b/src/IntersonArrayCxxControlsHWControls.cxx new file mode 100644 index 0000000..49dab67 --- /dev/null +++ b/src/IntersonArrayCxxControlsHWControls.cxx @@ -0,0 +1,521 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +// C++ +#pragma unmanaged +#include "IntersonArrayCxxControlsHWControls.h" + +// C# +#pragma managed + +#include +#include + +// Add library from SDK +#using "IntersonArray.dll" + +namespace IntersonArrayCxx +{ + +namespace Controls +{ + +ref class NewHardButtonHandler +{ +public: + typedef HWControls::NewHardButtonCallbackType NewHardButtonCallbackType; + + NewHardButtonHandler(): + NewHardButtonCallback( NULL ), + NewHardButtonCallbackClientData( NULL ) + { + } + + ~NewHardButtonHandler() + { + } + + void HandleNewHardButton( IntersonArray::Controls::HWControls ^controls, + System::EventArgs ^eventArgs ) + { + if ( this->NewHardButtonCallback != NULL ) + { + this->NewHardButtonCallback( this->NewHardButtonCallbackClientData ); + } + } + + void SetNewHardButtonCallback( NewHardButtonCallbackType callback, + void *clientData ) + { + this->NewHardButtonCallback = callback; + this->NewHardButtonCallbackClientData = clientData; + } + +private: + NewHardButtonCallbackType NewHardButtonCallback; + void *NewHardButtonCallbackClientData; +}; + +// Wrapper Class for IntersonArrayClass from SDK +class HWControlsImpl +{ +public: + // New defininions look header file + typedef HWControls::FoundProbesType FoundProbesType; + typedef HWControls::FrequenciesType FrequenciesType; + typedef HWControls::FocusType FocusType; + + + HWControlsImpl() + { + // New method for managed code. Wrapped is data member or this class + Wrapped = gcnew IntersonArray::Controls::HWControls(); + + HardButtonHandler = gcnew NewHardButtonHandler(); + HardButtonHandlerDelegate = gcnew + IntersonArray::Controls::HWControls::HWButtonHandler( + HardButtonHandler, &NewHardButtonHandler::HandleNewHardButton ); + Wrapped->HWButtonTick += HardButtonHandlerDelegate; + } + + ~HWControlsImpl() + { + Wrapped->HWButtonTick -= HardButtonHandlerDelegate; + } + + // Compound Angle Functions + int GetCompoundAngle() const + { + return Wrapped->CompoundAngle; + } + + bool EnableCompound() + { + return Wrapped->EnableCompound(); + } + + bool DisableCompound() + { + return Wrapped->DisableCompound(); + } + + // Doubler Functions + bool EnableDoubler() + { + return Wrapped->EnableDoubler(); + } + + bool DisableDoubler() + { + return Wrapped->DisableDoubler(); + } + + + // Probe ID Functions + short GetProbeID() const + { + return Wrapped->GetProbeID(); + } + + void FindAllProbes( FoundProbesType &foundProbes ) const + { + System::Collections::Specialized::StringCollection ^managedProbes = + gcnew System::Collections::Specialized::StringCollection(); + Wrapped->FindAllProbes( managedProbes );; + foundProbes.resize( managedProbes->Count ); + // Copy all available probes to the C++ class + for ( int ii = 0; ii < managedProbes->Count; ++ii ) + { + foundProbes[ii] = msclr::interop::marshal_as< std::string >( + managedProbes[ii] ); + } + } + + void FindMyProbe( int probeIndex ) const + { + Wrapped->FindMyProbe( probeIndex ); + } + + // Angle + float GetArrayAngle() const + { + return Wrapped->GetArrayAngle(); + } + + // Radius + float GetArrayRadius() const + { + return Wrapped->GetArrayRadius(); + } + + // Width + float GetArrayWidth() const + { + return Wrapped->GetArrayWidth(); + } + + // Focus + void GetFocus( FocusType & focus ) const + { + array< int > ^managedFocus = Wrapped->GetFocus(); + focus.resize( managedFocus->Length ); + for ( int ii = 0; ii < managedFocus->Length; ++ii ) + { + focus[ii] = managedFocus[ii]; + } + } + + // To check if the chosen Depth is valid for the probe. Returns the same + // depth if in the max range, otherwise returns the max depth + int ValidDepth( int depth ) const + { + return Wrapped->ValidDepth( depth ); + } + + // Get the list of supported frequencies. Units: Hz. + void GetFrequency( FrequenciesType &frequencies ) const + { + array< int > ^managedFrequencies = Wrapped->GetFrequency(); + frequencies.resize( managedFrequencies->Length ); + for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) + { + frequencies[ii] = managedFrequencies[ii]; + } + } + + // Set the list of supported frequencies. Units: Hz. + bool SetFrequencyAndFocus( unsigned char frequency, unsigned char focus, + int steering ) + { + return Wrapped->SetFrequencyAndFocus( frequency, focus, steering ); + } + + // Lines Per Array + unsigned int GetLinesPerArray() const + { + return Wrapped->GetLinesPerArray(); + } + + //" voltage ": percentage of the maximum of the High Voltage. Returns + //whether the command succeeded (true) or failed (false) + bool SendHighVoltage( unsigned char voltage, unsigned char voltageCfm ) + { + return Wrapped->SendHighVoltage( voltage, voltageCfm ); + } + + bool EnableHighVoltage() + { + return Wrapped->EnableHighVoltage(); + } + + bool DisableHighVoltage() + { + return Wrapped->DisableHighVoltage(); + } + + // To set the value of the dynamic and to calculate the value sent to + // the control. " bytDynamic ": value of the Dynamic (db). + // Returns: Returns whether the command succeeded (true) or failed (false) + bool SendDynamic( unsigned char dynamic ) + { + return Wrapped->SendDynamic( dynamic ); + } + + // To Start watching the Hardware Button to enable to raise the event + // HWButtonTick + void EnableHardButton() + { + Wrapped->EnableHardButton(); + } + + void DisableHardButton() + { + Wrapped->DisableHardButton(); + } + + unsigned char ReadHardButton() const + { + return Wrapped->ReadHardButton(); + } + + void SetNewHardButtonCallback( HWControls::NewHardButtonCallbackType + callback, void *clientData = 0 ) + { + this->HardButtonHandler->SetNewHardButtonCallback( callback, + clientData ); + } + + bool StartBmode() + { + return Wrapped->StartBmode(); + } + + bool StartRFmode() + { + return Wrapped->StartRFmode(); + } + + bool StopAcquisition() + { + return Wrapped->StopAcquisition(); + } + + short GetProbeFrameRate() const + { + return Wrapped->GetProbeFrameRate(); + } + + std::string GetProbeSerialNumber() const + { + return msclr::interop::marshal_as< std::string >( + Wrapped->GetProbeSerialNumber() ); + } + + std::string ReadFPGAVersion() const + { + return msclr::interop::marshal_as< std::string >( + Wrapped->ReadFPGAVersion() ); + } + + std::string GetOEMId() const + { + return msclr::interop::marshal_as< std::string >( + IntersonArray::Controls::HWControls::GetOEMId() ); + } + + std::string Get3DId() const + { + return msclr::interop::marshal_as< std::string >( + IntersonArray::Controls::HWControls::Get3DId() ); + } + + std::string GetFilterId() + { + return msclr::interop::marshal_as< std::string >( + IntersonArray::Controls::HWControls::GetFilterId() ); + } + + +private: + + gcroot< IntersonArray::Controls::HWControls ^ > Wrapped; + gcroot< NewHardButtonHandler ^ > HardButtonHandler; + gcroot< IntersonArray::Controls::HWControls::HWButtonHandler ^ > + HardButtonHandlerDelegate; + +}; + +// C++ +#pragma unmanaged + +HWControls +::HWControls(): + Impl( new HWControlsImpl() ) +{ +} + + +HWControls +::~HWControls() +{ + delete Impl; +} + + +short +HWControls +::GetProbeID() const +{ + return Impl->GetProbeID(); +} + + +void +HWControls +::FindAllProbes( FoundProbesType &foundProbes ) const +{ + Impl->FindAllProbes( foundProbes ); +} + + +void +HWControls +::FindMyProbe( int probeIndex ) +{ + Impl->FindMyProbe( probeIndex ); +} + +int +HWControls +::ValidDepth( int depth ) const +{ + return Impl->ValidDepth( depth ); +} + + +void +HWControls +::GetFrequency( FrequenciesType &frequencies ) const +{ + Impl->GetFrequency( frequencies ); +} + + +void +HWControls +::GetFocus( FocusType &focus ) const +{ + Impl->GetFocus( focus ); +} + + +bool +HWControls +::SetFrequencyAndFocus( unsigned char frequency, unsigned char focus, + int steering ) +{ + return Impl->SetFrequencyAndFocus( frequency, focus, steering ); +} + + +bool +HWControls +::SendHighVoltage( unsigned char voltage, unsigned char voltageCfm ) +{ + return Impl->SendHighVoltage( voltage, voltageCfm ); +} + + +bool +HWControls +::EnableHighVoltage() +{ + return Impl->EnableHighVoltage(); +} + + +bool +HWControls +::DisableHighVoltage() +{ + return Impl->DisableHighVoltage(); +} + + +bool +HWControls +::SendDynamic( unsigned char dynamic ) +{ + return Impl->SendDynamic( dynamic ); +} + + +void +HWControls +::EnableHardButton() +{ + Impl->EnableHardButton(); +} + + +void +HWControls +::DisableHardButton() +{ + Impl->DisableHardButton(); +} + + +unsigned char +HWControls +::ReadHardButton() +{ + return Impl->ReadHardButton(); +} + + +bool +HWControls +::StartBmode() +{ + return Impl->StartBmode(); +} + + +bool +HWControls +::StartRFmode() +{ + return Impl->StartRFmode(); +} + + +bool +HWControls +::StopAcquisition() +{ + return Impl->StopAcquisition(); +} + + +short +HWControls +::GetProbeFrameRate() const +{ + return Impl->GetProbeFrameRate(); +} + + +std::string +HWControls +::GetProbeSerialNumber() const +{ + return Impl->GetProbeSerialNumber(); +} + + +std::string +HWControls +::ReadFPGAVersion() const +{ + return Impl->ReadFPGAVersion(); +} + + +std::string +HWControls +::GetOEMId() const +{ + return Impl->GetOEMId(); +} + + +std::string +HWControls +::GetFilterId() const +{ + return Impl->GetFilterId(); +} + +} // end namespace Controls + +} // end namespace IntersonArrayCxx diff --git a/src/IntersonArrayCxxImagingCapture.cxx b/src/IntersonArrayCxxImagingCapture.cxx new file mode 100644 index 0000000..22ac8df --- /dev/null +++ b/src/IntersonArrayCxxImagingCapture.cxx @@ -0,0 +1,389 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#pragma unmanaged +#include "IntersonArrayCxxImagingCapture.h" +#include "IntersonArrayCxxImagingScanConverter.h" +#pragma managed + +#include +#include + +#using "IntersonArray.dll" + +// for Bitmap +#using "System.Drawing.dll" + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +ref class NewRFImageHandler +{ +public: + + typedef Capture::NewRFImageCallbackType NewRFImageCallbackType; + + typedef IntersonArrayCxx::Imaging::Capture::RFPixelType RFPixelType; + typedef cli::array< RFPixelType, 2 > RFArrayType; + + NewRFImageHandler( RFArrayType ^managedRFBuffer ): + NewRFImageCallback( NULL ), + NewRFImageCallbackClientData( NULL ), + NativeRFBuffer( new RFPixelType[ScanConverter::MAX_RFSAMPLES + * 512] ), + //* ScanConverter::MAX_VECTORS] + ManagedRFBuffer( managedRFBuffer ) + { + } + + ~NewRFImageHandler() + { + delete [] NativeRFBuffer; + } + + void HandleNewRFImage( IntersonArray::Imaging::Capture ^scan2D, + System::EventArgs ^eventArgs ) + { + if ( this->NewRFImageCallback != NULL ) + { + //for ( int ii = 0; ii < ScanConverter::MAX_VECTORS; ++ii ) + for ( int ii = 0; ii < 512; ++ii ) + { + for ( int jj = 0; jj < ScanConverter::MAX_RFSAMPLES; ++jj ) + { + this->NativeRFBuffer[ScanConverter::MAX_RFSAMPLES * ii + jj] = + this->ManagedRFBuffer[ii, jj]; + } + } + this->NewRFImageCallback( this->NativeRFBuffer, + this->NewRFImageCallbackClientData ); + } + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData ) + { + this->NewRFImageCallback = callback; + this->NewRFImageCallbackClientData = clientData; + } + +private: + NewRFImageCallbackType NewRFImageCallback; + void * NewRFImageCallbackClientData; + RFPixelType * NativeRFBuffer; + RFArrayType ^ManagedRFBuffer; +}; + + +ref class NewImageHandler +{ +public: + typedef Capture::NewImageCallbackType NewImageCallbackType; + + typedef IntersonArrayCxx::Imaging::Capture::PixelType PixelType; + typedef cli::array< byte, 2 > ArrayType; + + NewImageHandler( ArrayType ^managedBuffer ): + NewImageCallback( NULL ), + NewImageCallbackClientData( NULL ), + NativeBuffer( new PixelType[ScanConverter::MAX_SAMPLES * + 512] ), + //ScanConverter::MAX_VECTORS] ), + ManagedBuffer( managedBuffer ) + { + } + + ~NewImageHandler() + { + delete [] NativeBuffer; + } + + void HandleNewImage( IntersonArray::Imaging::Capture ^scan2D, + System::EventArgs ^eventArgs ) + { + if ( this->NewImageCallback != NULL ) + { + for ( int ii = 0; ii < 512; ++ii ) + //for ( int ii = 0; ii < ScanConverter::MAX_VECTORS; ++ii ) + { + for ( int jj = 0; jj < ScanConverter::MAX_SAMPLES; ++jj ) + { + this->NativeBuffer[ScanConverter::MAX_SAMPLES * ii + jj] = + this->ManagedBuffer[ii, jj]; + } + } + this->NewImageCallback( this->NativeBuffer, + this->NewImageCallbackClientData ); + } + } + + void SetNewImageCallback( NewImageCallbackType callback, + void *clientData ) + { + this->NewImageCallback = callback; + this->NewImageCallbackClientData = clientData; + } + +private: + NewImageCallbackType NewImageCallback; + void * NewImageCallbackClientData; + PixelType * NativeBuffer; + ArrayType ^ManagedBuffer; +}; + + +class CaptureImpl +{ +public: + typedef cli::array< Capture::PixelType, 2 > ArrayType; + typedef cli::array< Capture::RFPixelType, 2 > RFArrayType; + + typedef Capture::NewImageCallbackType NewImageCallbackType; + typedef Capture::NewRFImageCallbackType NewRFImageCallbackType; + + CaptureImpl() + { + Wrapped = gcnew IntersonArray::Imaging::Capture(); + + //Buffer = gcnew ArrayType( ScanConverter::MAX_VECTORS, + Buffer = gcnew ArrayType( 512, + ScanConverter::MAX_SAMPLES); + Handler = gcnew NewImageHandler( Buffer ); + HandlerDelegate = gcnew + IntersonArray::Imaging::Capture::NewImageHandler( Handler, + & NewImageHandler::HandleNewImage ); + Wrapped->NewImageTick += HandlerDelegate; + + //RFBuffer = gcnew RFArrayType( ScanConverter::MAX_VECTORS, + RFBuffer = gcnew RFArrayType( 512, + ScanConverter::MAX_RFSAMPLES ); + RFHandler = gcnew NewRFImageHandler( RFBuffer ); + RFHandlerDelegate = gcnew + IntersonArray::Imaging::Capture::NewImageHandler( RFHandler, + & NewRFImageHandler::HandleNewRFImage ); + Wrapped->NewImageTick += RFHandlerDelegate; + + } + + ~CaptureImpl() + { + Wrapped->NewImageTick -= RFHandlerDelegate; + Wrapped->NewImageTick -= HandlerDelegate; + } + + bool GetFrameAvg() + { + return Wrapped->FrameAvg; + } + + void SetFrameAvg( bool value) + { + Wrapped->FrameAvg = value; + } + + bool GetRFData() + { + return Wrapped->RFData; + } + + void SetRFData( bool value ) + { + Wrapped->RFData = value; + } + + double GetScanOn() + { + return Wrapped->ScanOn; + } + + void AbortScan() + { + Wrapped->AbortScan(); + } + + void DisposeScan() + { + Wrapped->DisposeScan(); + } + + void StartReadScan() + { + Wrapped->StartReadScan( (ArrayType ^)Buffer ); + } + + void StartRFReadScan() + { + Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); + } + + void StopReadScan() + { + Wrapped->StopReadScan(); + } + + void SetNewImageCallback( NewImageCallbackType callback, + void *clientData = 0 ) + { + this->Handler->SetNewImageCallback( callback, clientData ); + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData = 0 ) + { + this->RFHandler->SetNewRFImageCallback( callback, clientData ); + } + + +private: + gcroot< IntersonArray::Imaging::Capture ^ > Wrapped; + + gcroot< ArrayType ^ > Buffer; + gcroot< RFArrayType ^ > RFBuffer; + gcroot< NewImageHandler ^ > Handler; + gcroot< NewRFImageHandler ^ > RFHandler; + + gcroot< IntersonArray::Imaging::Capture::NewImageHandler ^ > + HandlerDelegate; + gcroot< IntersonArray::Imaging::Capture::NewImageHandler ^ > + RFHandlerDelegate; + +}; + +#pragma unmanaged + +Capture +::Capture(): + Impl( new CaptureImpl() ) +{ +} + + +Capture +::~Capture() +{ + delete Impl; +} + + +bool +Capture +::GetRFData() +{ + return Impl->GetRFData(); +} + + +void +Capture +::SetRFData( bool transferOn ) +{ + Impl->SetRFData( transferOn ); +} + + +bool +Capture +::GetFrameAvg() +{ + return Impl->GetFrameAvg(); +} + +void +Capture +::SetFrameAvg( bool doAveraging ) +{ + Impl->SetFrameAvg( doAveraging ); +} + + +bool +Capture +::GetScanOn() const +{ + return Impl->GetScanOn(); +} + + +void +Capture +::AbortScan() +{ + Impl->AbortScan(); +} + + +void +Capture +::DisposeScan() +{ + Impl->DisposeScan(); +} + + +void +Capture +::StartReadScan() +{ + Impl->StartReadScan(); +} + + +void +Capture +::StartRFReadScan() +{ + Impl->StartRFReadScan(); +} + + +void +Capture +::StopReadScan() +{ + Impl->StopReadScan(); +} + + +void +Capture +::SetNewImageCallback( NewImageCallbackType callback, + void *clientData ) +{ + Impl->SetNewImageCallback( callback, clientData ); +} + + +void +Capture +::SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData ) +{ + Impl->SetNewRFImageCallback( callback, clientData ); +} + + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx diff --git a/src/IntersonArrayCxxImagingImageBuilding.cxx b/src/IntersonArrayCxxImagingImageBuilding.cxx new file mode 100644 index 0000000..904660c --- /dev/null +++ b/src/IntersonArrayCxxImagingImageBuilding.cxx @@ -0,0 +1,111 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#pragma unmanaged +#include "IntersonArrayCxxImagingImageBuilding.h" +#include +#pragma managed + +#include +#include + +#using "System.Drawing.dll" + +#using "IntersonArray.dll" + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +class ImageBuildingImpl +{ +public: + ImageBuildingImpl() + { + Wrapped = gcnew IntersonArray::Imaging::ImageBuilding(); + } + + ~ImageBuildingImpl() + { + } + + void Build2D( unsigned char * bmpDest, unsigned char * byteRaw, + ScanConverter & scanConverter ) + { + std::cerr << "ERROR: Call to ImageBuilding.Build2D - not implemented" + << std::endl; + //Wrapped->Build2D( bmpDest, byteRaw, scanConverter ); + } + + void Build2D( unsigned char * bmpDest, unsigned char * byteRawCurrent, + unsigned char * byteRawPrevious, ScanConverter & scanConverter ) + { + std::cerr << "ERROR: Call to ImageBuilding.Build2D.2 - not implemented" + << std::endl; + //Wrapped->Build2D( bmpDest, byteRawCurrent, byteRawPrevious, + //scanConverter ); + } + +private: + gcroot< IntersonArray::Imaging::ImageBuilding ^ > Wrapped; + +}; + + +#pragma unmanaged + +ImageBuilding +::ImageBuilding(): + Impl( new ImageBuildingImpl() ) +{ +} + + +ImageBuilding +::~ImageBuilding() +{ + delete Impl; +} + + +void +ImageBuilding +::Build2D( unsigned char * bmpDest, unsigned char * byteRaw, + ScanConverter & scanConverter ) +{ + return Impl->Build2D( bmpDest, byteRaw, scanConverter ); +} + +void +ImageBuilding +::Build2D( unsigned char * bmpDest, unsigned char * byteRawCurrent, + unsigned char * byteRawPrevious, ScanConverter & scanConverter ) +{ + return Impl->Build2D( bmpDest, byteRawCurrent, byteRawPrevious, + scanConverter ); +} + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx diff --git a/src/IntersonArrayCxxImagingScanConverter.cxx b/src/IntersonArrayCxxImagingScanConverter.cxx new file mode 100644 index 0000000..e18bbd2 --- /dev/null +++ b/src/IntersonArrayCxxImagingScanConverter.cxx @@ -0,0 +1,245 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#pragma unmanaged +#include "IntersonArrayCxxImagingScanConverter.h" +#pragma managed + +#include +#include +#include + +#using "IntersonArray.dll" + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +class ScanConverterImpl +{ +public: + ScanConverterImpl() + { + Wrapped = gcnew IntersonArray::Imaging::ScanConverter(); + } + + ~ScanConverterImpl() + { + } + + bool GetCompound() + { + return Wrapped->Compound; + } + + void SetCompound( bool value ) + { + Wrapped->Compound = value; + } + + bool GetDoubler() + { + return Wrapped->Doubler; + } + + void SetDoubler( bool value ) + { + Wrapped->Doubler = value; + } + + int GetHeightScan() const + { + return Wrapped->HeightScan; + } + + float GetMmPerPixel() const + { + return Wrapped->MmPerPixel; + } + + double GetTrueDepth() const + { + return Wrapped->TrueDepth; + } + + int GetWidthScan() const + { + return Wrapped->WidthScan; + } + + int GetZeroOfYScale() const + { + return Wrapped->ZeroOfYScale; + } + + ScanConverter::ScanConverterError HardInitScanConverter( int depth, + int widthScan, int heightScan, int steering, Capture & capture, + ImageBuilding & imageBuilding ) + { + msclr::auto_gcroot< IntersonArray::Imaging::Capture ^ > + captureWrapped; + captureWrapped = gcnew IntersonArray::Imaging::Capture(); + captureWrapped->RFData = capture.GetRFData(); + captureWrapped->FrameAvg = capture.GetFrameAvg(); + + msclr::auto_gcroot< IntersonArray::Imaging::ImageBuilding ^ > + imageWrapped; + imageWrapped = gcnew IntersonArray::Imaging::ImageBuilding(); + return static_cast< ScanConverter::ScanConverterError >( Wrapped-> + HardInitScanConverter( depth, widthScan, heightScan, steering, + captureWrapped.get(), imageWrapped.get() ) ); + } + + ScanConverter::ScanConverterError IdleInitScanConverter( int depth, + int widthScan, int heightScan, short idleId, int idleSteering, + bool idleDoubler, bool idleCompound, int idleCompoundAngle, + ImageBuilding & imageBuilding ) + { + msclr::auto_gcroot< IntersonArray::Imaging::ImageBuilding ^ > + imageWrapped; + imageWrapped = gcnew IntersonArray::Imaging::ImageBuilding(); + return static_cast< ScanConverter::ScanConverterError >( Wrapped-> + IdleInitScanConverter( depth, widthScan, heightScan, idleId, + idleSteering, idleDoubler, idleCompound, idleCompoundAngle, + imageWrapped.get() ) ); + } + +private: + gcroot< IntersonArray::Imaging::ScanConverter ^ > + Wrapped; +}; + + +#pragma unmanaged + +ScanConverter +::ScanConverter(): + Impl( new ScanConverterImpl() ) +{ +} + + +ScanConverter +::~ScanConverter() +{ + delete Impl; +} + + +bool +ScanConverter +::GetCompound() +{ + return Impl->GetCompound(); +} + + +void +ScanConverter +::SetCompound( bool value ) +{ + Impl->SetCompound( value ); +} + + +bool +ScanConverter +::GetDoubler() +{ + return Impl->GetDoubler(); +} + + +void +ScanConverter +::SetDoubler( bool value ) +{ + Impl->SetDoubler( value ); +} + + +int +ScanConverter +::GetHeightScan() const +{ + return Impl->GetHeightScan(); +} + + +float +ScanConverter +::GetMmPerPixel() const +{ + return Impl->GetMmPerPixel(); +} + + +double +ScanConverter +::GetTrueDepth() const +{ + return Impl->GetMmPerPixel(); +} + + +int +ScanConverter +::GetWidthScan() const +{ + return Impl->GetWidthScan(); +} + + +int +ScanConverter +::GetZeroOfYScale() const +{ + return Impl->GetZeroOfYScale(); +} + + +ScanConverter::ScanConverterError +ScanConverter +::HardInitScanConverter( int depth, int widthScan, int heightScan, + int steering, Capture & capture, ImageBuilding & imageBuilding ) +{ + return Impl->HardInitScanConverter( depth, widthScan, heightScan, + steering, capture, imageBuilding ); +} + + +ScanConverter::ScanConverterError +ScanConverter +::IdleInitScanConverter( int depth, int width, int height, short idleId, + int idleSteering, bool idleDoubler, bool idleCompound, + int idleCompoundAngle, ImageBuilding & imageBuilding ) +{ + return Impl->IdleInitScanConverter( depth, width, height, idleId, + idleSteering, idleDoubler, idleCompound, idleCompoundAngle, + imageBuilding ); +} + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx diff --git a/src/IntersonArrayCxxIntersonClass.cxx b/src/IntersonArrayCxxIntersonClass.cxx new file mode 100644 index 0000000..2f71e6c --- /dev/null +++ b/src/IntersonArrayCxxIntersonClass.cxx @@ -0,0 +1,78 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +// C++ +#pragma unmanaged +#include "IntersonArrayCxxIntersonClass.h" + +// C# +#pragma managed + +#include +#include + +// Add library from SDK +#using "IntersonArray.dll" + +namespace IntersonArrayCxx +{ +// Wrapper Class for IntersonClass from SDK +class IntersonClassImpl +{ +public: + IntersonClassImpl() + { + } + + // Wrapped method for IntersonClass from SDK + std::string Version() + { + // This method converts data between native and managed environments. + // http://msdn.microsoft.com/en-us/library/bb384859.aspx + std::string marshalled = msclr::interop::marshal_as< std::string >( + IntersonArray::IntersonClass::Version ); + return marshalled; + } + +private: +}; + + +// C++ +#pragma unmanaged + +IntersonClass::IntersonClass(): + Impl( new IntersonClassImpl() ) +{ +} + +IntersonClass::~IntersonClass() +{ + delete Impl; +} + +std::string IntersonClass::Version() const +{ + return Impl->Version(); +} + +} // end namespace IntersonArrayCxx diff --git a/src/IntersonCxxControlsHWControls.cxx b/src/IntersonCxxControlsHWControls.cxx deleted file mode 100644 index 027ea35..0000000 --- a/src/IntersonCxxControlsHWControls.cxx +++ /dev/null @@ -1,408 +0,0 @@ -// C++ -#pragma unmanaged -#include "IntersonCxxControlsHWControls.h" - -// C# -#pragma managed - -#include -#include - -// Add library from SDK -#using "Interson.dll" - -namespace IntersonCxx -{ - -namespace Controls -{ -// Wrapper Class for IntersonClass from SDK -class HWControlsImpl -{ -public: - // New defininions look header file - typedef HWControls::FoundProbesType FoundProbesType; - typedef HWControls::FrequenciesType FrequenciesType; - - - HWControlsImpl() - { - // New method for managed code. Wrapped is data member or this class - Wrapped = gcnew Interson::Controls::HWControls(); - } - - unsigned char GetProbeID() - { - return Wrapped->GetProbeID(); - } - - void FindAllProbes( FoundProbesType &foundProbes ) - { - System::Collections::Specialized::StringCollection ^managedProbes = - gcnew System::Collections::Specialized::StringCollection(); - Wrapped->FindAllProbes( managedProbes );; - foundProbes.resize( managedProbes->Count ); - // Copy all available probes to the C++ class - for ( int ii = 0; ii < managedProbes->Count; ++ii ) - { - foundProbes[ii] = msclr::interop::marshal_as< std::string >( - managedProbes[ii] ); - } - } - - void FindMyProbe( int probeIndex ) - { - Wrapped->FindMyProbe( probeIndex ); - } - - int ValidDepth( int depth ) - { - return Wrapped->ValidDepth( depth ); - } - - void GetFrequency( FrequenciesType &frequencies ) - { - array< int > ^managedFrequencies = Wrapped->GetFrequency(); - frequencies.resize( managedFrequencies->Length ); - for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - frequencies[ii] = managedFrequencies[ii]; - } - } - - bool SetFrequency( int frequency ) - { - array< int > ^managedFrequencies = Wrapped->GetFrequency(); - int frequencyIndex = -1; - for ( int ii = 0; ii < managedFrequencies->Length; ++ii ) - { - if ( frequency == managedFrequencies[ii] ) - { - frequencyIndex = ii; - break; - } - } - if ( frequencyIndex == -1 ) - { - return false; - } - return Wrapped->SetFrequency( frequencyIndex, managedFrequencies[frequencyIndex] ); - } - - bool SendHighVoltage( unsigned char voltage ) - { - return Wrapped->SendHighVoltage( voltage ); - } - - bool EnableHighVoltage() - { - return Wrapped->EnableHighVoltage(); - } - - bool DisableHighVoltage() - { - return Wrapped->DisableHighVoltage(); - } - - bool SendDynamic( unsigned char dynamic ) - { - return Wrapped->SendDynamic( dynamic ); - } - - bool StartMotor() - { - return Wrapped->StartMotor(); - } - - bool StopMotor() - { - return Wrapped->StopMotor(); - } - - void EnableHardButton() - { - Wrapped->EnableHardButton(); - } - - void DisableHardButton() - { - Wrapped->DisableHardButton(); - } - - unsigned char ReadHardButton() - { - return Wrapped->ReadHardButton(); - } - - bool StartBmode() - { - return Wrapped->StartBmode(); - } - - bool StartRFmode() - { - return Wrapped->StartRFmode(); - } - - bool StopAcquisition() - { - return Wrapped->StopAcquisition(); - } - - short GetProbeFrameRate( int depth ) - { - return Wrapped->GetProbeFrameRate( depth ); - } - - std::string GetProbeSerialNumber() - { - return msclr::interop::marshal_as< std::string >( Wrapped->GetProbeSerialNumber() ); - } - - std::string ReadFPGAVersion() - { - return msclr::interop::marshal_as< std::string >( Wrapped->ReadFPGAVersion() ); - } - - std::string GetOEMId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetOEMId() ); - } - - std::string GetFilterId() - { - return msclr::interop::marshal_as< std::string >( Interson::Controls::HWControls::GetFilterId() ); - } - - bool EnableRFDecimator() - { - return Wrapped->EnableRFDecimator(); - } - - bool DisableRFDecimator() - { - return Wrapped->DisableRFDecimator(); - } - -private: - gcroot< Interson::Controls::HWControls ^ > Wrapped; -}; - -// C++ -#pragma unmanaged - -HWControls -::HWControls(): - Impl( new HWControlsImpl() ) -{ -} - - -HWControls -::~HWControls() -{ - delete Impl; -} - - -unsigned char -HWControls -::GetProbeID() const -{ - return Impl->GetProbeID(); -} - - -void -HWControls -::FindAllProbes( FoundProbesType &foundProbes ) const -{ - Impl->FindAllProbes( foundProbes ); -} - - -void -HWControls -::FindMyProbe( int probeIndex ) -{ - Impl->FindMyProbe( probeIndex ); -} - -int -HWControls -::ValidDepth( int depth ) const -{ - return Impl->ValidDepth( depth ); -} - - -void -HWControls -::GetFrequency( FrequenciesType &frequencies ) const -{ - Impl->GetFrequency( frequencies ); -} - - -bool -HWControls -::SetFrequency( int frequency ) -{ - return Impl->SetFrequency( frequency ); -} - - -bool -HWControls -::SendHighVoltage( unsigned char voltage ) -{ - return Impl->SendHighVoltage( voltage ); -} - - -bool -HWControls -::EnableHighVoltage() -{ - return Impl->EnableHighVoltage(); -} - - -bool -HWControls -::DisableHighVoltage() -{ - return Impl->DisableHighVoltage(); -} - - -bool -HWControls -::SendDynamic( unsigned char dynamic ) -{ - return Impl->SendDynamic( dynamic ); -} - - -bool -HWControls -::StartMotor() -{ - return Impl->StartMotor(); -} - - -bool -HWControls -::StopMotor() -{ - return Impl->StopMotor(); -} - - -void -HWControls -::EnableHardButton() -{ - Impl->EnableHardButton(); -} - - -void -HWControls -::DisableHardButton() -{ - Impl->DisableHardButton(); -} - - -unsigned char -HWControls -::ReadHardButton() -{ - return Impl->ReadHardButton(); -} - - -bool -HWControls -::StartBmode() -{ - return Impl->StartBmode(); -} - - -bool -HWControls -::StartRFmode() -{ - return Impl->StartRFmode(); -} - - -bool -HWControls -::StopAcquisition() -{ - return Impl->StopAcquisition(); -} - - -short -HWControls -::GetProbeFrameRate( int depth ) -{ - return Impl->GetProbeFrameRate( depth ); -} - - -std::string -HWControls -::GetProbeSerialNumber() const -{ - return Impl->GetProbeSerialNumber(); -} - - -std::string -HWControls -::ReadFPGAVersion() const -{ - return Impl->ReadFPGAVersion(); -} - - -std::string -HWControls -::GetOEMId() const -{ - return Impl->GetOEMId(); -} - - -std::string -HWControls -::GetFilterId() const -{ - return Impl->GetFilterId(); -} - - -bool -HWControls -::EnableRFDecimator() -{ - return Impl->EnableRFDecimator(); -} - - -bool -HWControls -::DisableRFDecimator() -{ - return Impl->DisableRFDecimator(); -} - -} // end namespace Controls - -} // end namespace IntersonCxx diff --git a/src/IntersonCxxImagingScan2DClass.cxx b/src/IntersonCxxImagingScan2DClass.cxx deleted file mode 100644 index 824c21c..0000000 --- a/src/IntersonCxxImagingScan2DClass.cxx +++ /dev/null @@ -1,424 +0,0 @@ -#pragma unmanaged -#include "IntersonCxxImagingScan2DClass.h" - -#pragma managed - -#include -#include - -#using "Interson.dll" -// for Bitmap -#using "System.Drawing.dll" - -namespace IntersonCxx -{ - -namespace Imaging -{ - -ref class NewRFImageHandler -{ -public: - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::RFPixelType RFPixelType; - typedef cli::array< unsigned short, 2 > RFArrayType; - - NewRFImageHandler( RFArrayType ^managedRFBuffer ): - NewRFImageCallback( NULL ), - NewRFImageCallbackClientData( NULL ), - NativeRFBuffer( new RFPixelType[Scan2DClass::MAX_RFSAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedRFBuffer( managedRFBuffer ) - { - } - - ~NewRFImageHandler() - { - delete [] NativeRFBuffer; - } - - void HandleNewRFImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) - { - if ( this->NewRFImageCallback != NULL ) - { - for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) - { - for ( int jj = 0; jj < Scan2DClass::MAX_RFSAMPLES; ++jj ) - { - this->NativeRFBuffer[Scan2DClass::MAX_RFSAMPLES * ii + jj] = this->ManagedRFBuffer[ii, jj]; - } - } - this->NewRFImageCallback( this->NativeRFBuffer, this->NewRFImageCallbackClientData ); - } - } - - void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) - { - this->NewRFImageCallback = callback; - this->NewRFImageCallbackClientData = clientData; - } - -private: - NewRFImageCallbackType NewRFImageCallback; - void *NewRFImageCallbackClientData; - RFPixelType *NativeRFBuffer; - RFArrayType ^ManagedRFBuffer; -}; - - -ref class NewBmodeImageHandler -{ -public: - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef IntersonCxx::Imaging::Scan2DClass::BmodePixelType BmodePixelType; - typedef cli::array< byte, 2 > BmodeArrayType; - - NewBmodeImageHandler( BmodeArrayType ^managedBmodeBuffer ): - NewBmodeImageCallback( NULL ), - NewBmodeImageCallbackClientData( NULL ), - NativeBmodeBuffer( new BmodePixelType[Scan2DClass::MAX_SAMPLES * Scan2DClass::MAX_VECTORS] ), - ManagedBmodeBuffer( managedBmodeBuffer ), - NewScanConvertedBmodeImageCallback( NULL ), - NewScanConvertedBmodeImageCallbackClientData( NULL ), - ScanConvertedBmodeBuffer( new BmodePixelType[0] ) - { - ScanConverter = gcnew Interson::Imaging::ScanConverter(); - } - - ~NewBmodeImageHandler() - { - delete [] NativeBmodeBuffer; - delete [] ScanConvertedBmodeBuffer; - } - - void HandleNewBmodeImage( Interson::Imaging::Scan2DClass ^scan2D, System::EventArgs ^eventArgs ) - { - if ( this->NewBmodeImageCallback != NULL ) - { - for ( int ii = 0; ii < Scan2DClass::MAX_VECTORS; ++ii ) - { - for ( int jj = 0; jj < Scan2DClass::MAX_SAMPLES; ++jj ) - { - this->NativeBmodeBuffer[Scan2DClass::MAX_SAMPLES * ii + jj] = - this->ManagedBmodeBuffer[ii, jj]; - } - } - this->NewBmodeImageCallback( this->NativeBmodeBuffer, this->NewBmodeImageCallbackClientData ); - } - - if ( this->NewScanConvertedBmodeImageCallback != NULL ) - { - scan2D->Build2D( ScanConvertedBmode, ManagedBmodeBuffer ); - - System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, ScanConvertedBmode->Width, ScanConvertedBmode->Height); - System::Drawing::Imaging::BitmapData ^bData = ScanConvertedBmode->LockBits( - rect , - System::Drawing::Imaging::ImageLockMode::ReadWrite, - System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - - byte *scan0 = (byte *)bData->Scan0.ToPointer(); - - for (int i = 0; i < bData->Height; ++i) - { - for (int j = 0; j < bData->Width; ++j) - { - byte *data = scan0 + i * bData->Stride + j; - this->ScanConvertedBmodeBuffer[ScanConvertedBmode->Width * i + j] = static_cast< BmodePixelType > (data[0]); - - } - } - - - - ScanConvertedBmode->UnlockBits(bData); - - this->NewScanConvertedBmodeImageCallback( this->ScanConvertedBmodeBuffer, this->NewScanConvertedBmodeImageCallbackClientData ); - } - } - - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData ) - { - this->NewBmodeImageCallback = callback; - this->NewBmodeImageCallbackClientData = clientData; - } - - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData ) - { - this->NewScanConvertedBmodeImageCallback = callback; - this->NewScanConvertedBmodeImageCallbackClientData = clientData; - - ScanConvertedBmode = gcnew System::Drawing::Bitmap( ScanConverter->WidthScan, - ScanConverter->HeightScan, - System::Drawing::Imaging::PixelFormat::Format8bppIndexed ); - delete [] ScanConvertedBmodeBuffer; - ScanConvertedBmodeBuffer = new BmodePixelType[ScanConverter->WidthScan * ScanConverter->HeightScan]; - } - -private: - NewBmodeImageCallbackType NewBmodeImageCallback; - void *NewBmodeImageCallbackClientData; - BmodePixelType *NativeBmodeBuffer; - BmodeArrayType ^ManagedBmodeBuffer; - System::Drawing::Bitmap ^ScanConvertedBmode; - - NewScanConvertedBmodeImageCallbackType NewScanConvertedBmodeImageCallback; - void *NewScanConvertedBmodeImageCallbackClientData; - Interson::Imaging::ScanConverter ^ScanConverter; - BmodePixelType *ScanConvertedBmodeBuffer; -}; - - -class Scan2DClassImpl -{ -public: - typedef cli::array< byte, 2 > BmodeArrayType; - typedef cli::array< unsigned short, 2 > RFArrayType; - - typedef Scan2DClass::NewBmodeImageCallbackType NewBmodeImageCallbackType; - typedef Scan2DClass::NewScanConvertedBmodeImageCallbackType - NewScanConvertedBmodeImageCallbackType; - typedef Scan2DClass::NewRFImageCallbackType NewRFImageCallbackType; - - Scan2DClassImpl() - { - Wrapped = gcnew Interson::Imaging::Scan2DClass(); - - BmodeBuffer = gcnew BmodeArrayType( Scan2DClass::MAX_VECTORS , Scan2DClass::MAX_SAMPLES); - BmodeHandler = gcnew NewBmodeImageHandler( BmodeBuffer ); - BmodeHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(BmodeHandler, - &NewBmodeImageHandler::HandleNewBmodeImage ); - Wrapped->NewImageTick += BmodeHandlerDelegate; - - RFBuffer = gcnew RFArrayType( Scan2DClass::MAX_VECTORS, Scan2DClass::MAX_RFSAMPLES ); - RFHandler = gcnew NewRFImageHandler( RFBuffer ); - RFHandlerDelegate = gcnew - Interson::Imaging::Scan2DClass::NewImageHandler(RFHandler, - &NewRFImageHandler::HandleNewRFImage ); - Wrapped->NewImageTick += RFHandlerDelegate; - - } - - ~Scan2DClassImpl() - { - Wrapped->NewImageTick -= RFHandlerDelegate; - Wrapped->NewImageTick -= BmodeHandlerDelegate; - } - - bool GetScanOn() - { - return Wrapped->ScanOn; - } - - bool GetRFData() - { - return Wrapped->RFData; - } - - void SetRFData( bool transferOn ) - { - Wrapped->RFData = transferOn; - } - - bool GetFrameAvg() - { - return Wrapped->FrameAvg; - } - - void SetFrameAvg( bool doAveraging ) - { - return Wrapped->FrameAvg = doAveraging; - } - - double GetTrueDepth() - { - return Wrapped->TrueDepth; - } - - void StartReadScan() - { - Wrapped->StartReadScan( (BmodeArrayType ^)BmodeBuffer ); - } - - void StartRFReadScan() - { - Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); - } - - void StopReadScan() - { - Wrapped->StopReadScan(); - } - - void DisposeScan() - { - Wrapped->DisposeScan(); - } - - void AbortScan() - { - Wrapped->AbortScan(); - } - - void SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, void *clientData = 0 ) - { - this->BmodeHandler->SetNewBmodeImageCallback( callback, clientData ); - } - - void SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, void *clientData = 0 ) - { - this->BmodeHandler->SetNewScanConvertedBmodeImageCallback( callback, clientData ); - } - - void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = 0 ) - { - this->RFHandler->SetNewRFImageCallback( callback, clientData ); - } - - -private: - gcroot< Interson::Imaging::Scan2DClass ^ > Wrapped; - - gcroot< BmodeArrayType ^ > BmodeBuffer; - gcroot< RFArrayType ^ > RFBuffer; - gcroot< NewBmodeImageHandler ^ > BmodeHandler; - gcroot< NewRFImageHandler ^ > RFHandler; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > BmodeHandlerDelegate; - gcroot< Interson::Imaging::Scan2DClass::NewImageHandler ^ > RFHandlerDelegate; - -}; - - -#pragma unmanaged - -Scan2DClass -::Scan2DClass(): - Impl( new Scan2DClassImpl() ) -{ -} - - -Scan2DClass -::~Scan2DClass() -{ - delete Impl; -} - - -bool -Scan2DClass -::GetScanOn() const -{ - return Impl->GetScanOn(); -} - - -bool -Scan2DClass -::GetRFData() const -{ - return Impl->GetRFData(); -} - - -void -Scan2DClass -::SetRFData( bool transferOn ) -{ - Impl->SetRFData( transferOn ); -} - - -bool -Scan2DClass -::GetFrameAvg() const -{ - return Impl->GetFrameAvg(); -} - -void -Scan2DClass -::SetFrameAvg( bool doAveraging ) -{ - Impl->SetFrameAvg( doAveraging ); -} - - -void -Scan2DClass -::StartReadScan() -{ - Impl->StartReadScan(); -} - - -void -Scan2DClass -::StartRFReadScan() -{ - Impl->StartRFReadScan(); -} - - -void -Scan2DClass -::StopReadScan() -{ - Impl->StopReadScan(); -} - - -void -Scan2DClass -::DisposeScan() -{ - Impl->DisposeScan(); -} - - -void -Scan2DClass -::AbortScan() -{ - Impl->AbortScan(); -} - - -void -Scan2DClass -::SetNewBmodeImageCallback( NewBmodeImageCallbackType callback, - void *clientData ) -{ - Impl->SetNewBmodeImageCallback( callback, clientData ); -} - - -void -Scan2DClass -::SetNewScanConvertedBmodeImageCallback( NewScanConvertedBmodeImageCallbackType callback, - void *clientData ) -{ - Impl->SetNewScanConvertedBmodeImageCallback( callback, clientData ); -} - - -void -Scan2DClass -::SetNewRFImageCallback( NewRFImageCallbackType callback, - void *clientData ) -{ - Impl->SetNewRFImageCallback( callback, clientData ); -} - - -double -Scan2DClass -::GetTrueDepth() const -{ - return Impl->GetTrueDepth(); -} - -} // end namespace Imaging - -} // end namespace IntersonCxx diff --git a/src/IntersonCxxImagingScanConverter.cxx b/src/IntersonCxxImagingScanConverter.cxx deleted file mode 100644 index 49b49ca..0000000 --- a/src/IntersonCxxImagingScanConverter.cxx +++ /dev/null @@ -1,159 +0,0 @@ -#pragma unmanaged -#include "IntersonCxxImagingScanConverter.h" - -#pragma managed - -#include -#include - -#using "Interson.dll" - -namespace IntersonCxx -{ - -namespace Imaging -{ - -class ScanConverterImpl -{ -public: - ScanConverterImpl() - { - Wrapped = gcnew Interson::Imaging::ScanConverter(); - } - - ~ScanConverterImpl() - { - } - - int GetHeightScan() - { - return Wrapped->HeightScan; - } - - int GetWidthScan() - { - return Wrapped->WidthScan; - } - - float GetMmPerPixel() - { - return Wrapped->MmPerPixel; - } - - int GetZeroOfYScale() - { - return Wrapped->ZeroOfYScale; - } - - ScanConverter::ScanConverterError HardInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan ) - { - return static_cast< ScanConverter::ScanConverterError >( - Wrapped->HardInitScanConverter( depth, upDown, leftRight, widthScan, heightScan ) ); - } - - ScanConverter::ScanConverterError IdleInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan, - unsigned char probeId ) - { - return static_cast< ScanConverter::ScanConverterError >( - Wrapped->IdleInitScanConverter( depth, upDown, leftRight, widthScan, heightScan, probeId ) ); - } - -private: - gcroot< Interson::Imaging::ScanConverter ^ > Wrapped; - -}; - - -#pragma unmanaged - -ScanConverter -::ScanConverter(): - Impl( new ScanConverterImpl() ) -{ -} - - -ScanConverter -::~ScanConverter() -{ - delete Impl; -} - - -int -ScanConverter -::GetHeightScan() const -{ - return Impl->GetHeightScan(); -} - - -int -ScanConverter -::GetWidthScan() const -{ - return Impl->GetWidthScan(); -} - - -float -ScanConverter -::GetMmPerPixel() const -{ - return Impl->GetMmPerPixel(); -} - - -int -ScanConverter -::GetZeroOfYScale() const -{ - return Impl->GetZeroOfYScale(); -} - - -ScanConverter::ScanConverterError -ScanConverter -::HardInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan ) -{ - return Impl->HardInitScanConverter( depth, - upDown, - leftRight, - widthScan, - heightScan ); -} - - -ScanConverter::ScanConverterError -ScanConverter -::IdleInitScanConverter( int depth, - bool upDown, - bool leftRight, - int widthScan, - int heightScan, - unsigned char probeId ) -{ - return Impl->IdleInitScanConverter( depth, - upDown, - leftRight, - widthScan, - heightScan, - probeId ); -} - -} // end namespace Imaging - -} // end namespace IntersonCxx diff --git a/src/IntersonCxxIntersonClass.cxx b/src/IntersonCxxIntersonClass.cxx deleted file mode 100644 index 164934b..0000000 --- a/src/IntersonCxxIntersonClass.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// C++ -#pragma unmanaged -#include "IntersonCxxIntersonClass.h" - -// C# -#pragma managed - -#include -#include - -// Add library from SDK -#using "Interson.dll" - -namespace IntersonCxx -{ -// Wrapper Class for IntersonClass from SDK -class IntersonClassImpl -{ -public: - IntersonClassImpl() - { - } - // Wrapped method for IntersonClass from SDK - std::string Version() - { - //This method converts data between native and managed environments. http://msdn.microsoft.com/en-us/library/bb384859.aspx - std::string marshalled = msclr::interop::marshal_as< std::string >(Interson::IntersonClass::Version ); - return marshalled; - } - -private: -}; - - -// C++ -#pragma unmanaged - -IntersonClass::IntersonClass(): - Impl( new IntersonClassImpl() ) -{ -} - -IntersonClass::~IntersonClass() -{ - delete Impl; -} - -std::string IntersonClass::Version() const -{ - return Impl->Version(); -} - -} // end namespace IntersonCxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f1b70c0..d5edb07 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,12 +1,34 @@ +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## set( _tests - IntersonCxxIntersonClassTest - IntersonCxxControlsHWControlsTest - IntersonCxxImagingScan2DClassTest - IntersonCxxImagingScanConverterTest + IntersonArrayCxxIntersonClassTest + IntersonArrayCxxControlsHWControlsTest + IntersonArrayCxxImagingCaptureTest + IntersonArrayCxxImagingScanConverterTest ) foreach( test ${_tests} ) add_executable( ${test} ${test}.cxx ) - target_link_libraries( ${test} IntersonCxx ) + target_link_libraries( ${test} IntersonArrayCxx ) add_test( NAME ${test} COMMAND $ ) endforeach() diff --git a/test/IntersonCxxControlsHWControlsTest.cxx b/test/IntersonArrayCxxControlsHWControlsTest.cxx similarity index 58% rename from test/IntersonCxxControlsHWControlsTest.cxx rename to test/IntersonArrayCxxControlsHWControlsTest.cxx index cf21a0b..b6f8f50 100644 --- a/test/IntersonCxxControlsHWControlsTest.cxx +++ b/test/IntersonArrayCxxControlsHWControlsTest.cxx @@ -1,18 +1,44 @@ -#include "IntersonCxxControlsHWControls.h" +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include "IntersonArrayCxxControlsHWControls.h" #include #include int main( int argc, char * argv[] ) { - IntersonCxx::Controls::HWControls hwControls; - typedef IntersonCxx::Controls::HWControls HWControlsType; + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + + HWControlsType hwControls; - std::cout << "ID_GP_3_5MHz: " << hwControls.ID_GP_3_5MHz << std::endl; - std::cout << "ProbeID: " << static_cast< int >( hwControls.GetProbeID() ) << std::endl; + std::cout << "ID_CA_OP_10MHz: " << hwControls.ID_CA_OP_10MHz << std::endl; - typedef IntersonCxx::Controls::HWControls::FoundProbesType FoundProbesType; + std::cout << "ProbeID: " << static_cast< int >( + hwControls.GetProbeID() ) << std::endl; + + typedef IntersonArrayCxx::Controls::HWControls::FoundProbesType + FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); std::cout << "Found Probes: " << std::endl; @@ -27,7 +53,7 @@ int main( int argc, char * argv[] ) } hwControls.FindMyProbe( 0 ); - const unsigned int probeId = hwControls.GetProbeID(); + const short probeId = hwControls.GetProbeID(); std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; if( probeId == 0 ) { @@ -47,21 +73,25 @@ int main( int argc, char * argv[] ) { std::cout << " " << frequencies[ii] << std::endl; } - if( !hwControls.SetFrequency( frequencies[0] ) ) + HWControlsType::FocusType focus; + hwControls.GetFocus( focus ); + std::cout << "\nFocus: " << std::endl; + for( size_t ii = 0; ii < focus.size(); ++ii ) + { + std::cout << " " << focus[ii] << std::endl; + } + if( !hwControls.SetFrequencyAndFocus( 0, 0, 0 ) ) { std::cerr << "Could not set the frequency." << std::endl; return EXIT_FAILURE; } - hwControls.SendHighVoltage( 50 ); + hwControls.SendHighVoltage( 50, 50 ); hwControls.EnableHighVoltage(); hwControls.DisableHighVoltage(); hwControls.SendDynamic( 50 ); - hwControls.StartMotor(); - hwControls.StopMotor(); - hwControls.EnableHardButton(); hwControls.DisableHardButton(); const unsigned char button = hwControls.ReadHardButton(); @@ -89,23 +119,14 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - const short frameRate = hwControls.GetProbeFrameRate( 40 ); + const short frameRate = hwControls.GetProbeFrameRate(); std::cout << "Frame rate: " << frameRate << std::endl; - std::cout << "Serial number: " << hwControls.GetProbeSerialNumber() << std::endl; - std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() << std::endl; + std::cout << "Serial number: " << hwControls.GetProbeSerialNumber() + << std::endl; + std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() + << std::endl; std::cout << "OEM ID: " << hwControls.GetOEMId() << std::endl; std::cout << "Filter ID: " << hwControls.GetFilterId() << std::endl; - if( !hwControls.EnableRFDecimator() ) - { - std::cerr << "Could not enable the RF decimator." << std::endl; - return EXIT_FAILURE; - } - if( !hwControls.DisableRFDecimator() ) - { - std::cerr << "Could not disable the RF decimator." << std::endl; - return EXIT_FAILURE; - } - return EXIT_SUCCESS; } diff --git a/test/IntersonArrayCxxImagingCaptureTest.cxx b/test/IntersonArrayCxxImagingCaptureTest.cxx new file mode 100644 index 0000000..d1b5be5 --- /dev/null +++ b/test/IntersonArrayCxxImagingCaptureTest.cxx @@ -0,0 +1,91 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include "IntersonArrayCxxImagingCapture.h" +#include "IntersonArrayCxxImagingScanConverter.h" +#include "IntersonArrayCxxControlsHWControls.h" + +#include +#include +#include + +#include // Sleep + +int main( int argc, char * argv[] ) +{ + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + HWControlsType hwControls; + + typedef IntersonArrayCxx::Imaging::Capture CaptureType; + CaptureType capture; + + typedef IntersonArrayCxx::Imaging::ScanConverter ScanConverterType; + ScanConverterType scanConverter; + + + typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + std::cout << "\nScan is on: " << capture.GetScanOn() << std::endl; + std::cout << "RF Data transfer is on: " << capture.GetRFData() + << std::endl; + + int ret = EXIT_SUCCESS; + + const int maxVectors = 512; //ScanConverterType::MAX_VECTORS; + const int maxSamples = ScanConverterType::MAX_SAMPLES; + const int maxPixels = maxVectors * maxSamples; + + capture.SetFrameAvg( true ); + std::cout << "\nFrameAvg: " << capture.GetFrameAvg() << std::endl; + + capture.AbortScan(); + std::cout << "\nStarting BMode scanning..." << std::endl; + capture.StartReadScan(); + Sleep( 100 ); // "time to start" + hwControls.StartBmode(); + std::cout << "\nScan is on: " << capture.GetScanOn() << std::endl; + + std::cout << "\nTrueDepth: " << scanConverter.GetTrueDepth() << std::endl; + + hwControls.StopAcquisition(); + capture.StopReadScan(); + Sleep( 100 ); // "time to stop" + capture.DisposeScan(); + + return ret; +} diff --git a/test/IntersonCxxImagingScanConverterTest.cxx b/test/IntersonArrayCxxImagingScanConverterTest.cxx similarity index 51% rename from test/IntersonCxxImagingScanConverterTest.cxx rename to test/IntersonArrayCxxImagingScanConverterTest.cxx index ff9236f..6cc9dfd 100644 --- a/test/IntersonCxxImagingScanConverterTest.cxx +++ b/test/IntersonArrayCxxImagingScanConverterTest.cxx @@ -1,6 +1,29 @@ -#include "IntersonCxxImagingScan2DClass.h" -#include "IntersonCxxControlsHWControls.h" -#include "IntersonCxxImagingScanConverter.h" +/*========================================================================= + +Library: IntersonArrayArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include "IntersonArrayCxxImagingCapture.h" +#include "IntersonArrayCxxControlsHWControls.h" +#include "IntersonArrayCxxImagingScanConverter.h" +#include "IntersonArrayCxxImagingImageBuilding.h" #include #include @@ -10,13 +33,16 @@ int main( int argc, char * argv[] ) { - typedef IntersonCxx::Controls::HWControls HWControlsType; + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; HWControlsType hwControls; - typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; - Scan2DClassType scan2D; + typedef IntersonArrayCxx::Imaging::Capture CaptureType; + CaptureType capture; - typedef IntersonCxx::Imaging::ScanConverter ScanConverterType; + typedef IntersonArrayCxx::Imaging::ImageBuilding ImageBuildingType; + ImageBuildingType imageBuilding; + + typedef IntersonArrayCxx::Imaging::ScanConverter ScanConverterType; ScanConverterType scanConverter; typedef HWControlsType::FoundProbesType FoundProbesType; @@ -27,6 +53,7 @@ int main( int argc, char * argv[] ) std::cerr << "Could not find the probe." << std::endl; return EXIT_FAILURE; } + hwControls.FindMyProbe( 0 ); const unsigned int probeId = hwControls.GetProbeID(); std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; @@ -42,30 +69,21 @@ int main( int argc, char * argv[] ) std::cerr << "Did not request a valid depth" << std::endl; return EXIT_SUCCESS; } - const bool upDown = true; - const bool leftRight = true; const int width = 776; const int height = 512; + int steering = 0; ScanConverterType::ScanConverterError converterError = - scanConverter.IdleInitScanConverter( depth, - upDown, - leftRight, - width, - height, - probeId ); + scanConverter.IdleInitScanConverter( depth, width, height, probeId, + steering, false, false, 0, imageBuilding ); if( converterError != ScanConverterType::SUCCESS ) { std::cerr << "Error during idle scan converter initialization: " << converterError << std::endl; return EXIT_FAILURE; } - converterError = - scanConverter.HardInitScanConverter( depth, - upDown, - leftRight, - width, - height ); + converterError = scanConverter.HardInitScanConverter( depth, width, + height, steering, capture, imageBuilding ); if( converterError != ScanConverterType::SUCCESS ) { std::cerr << "Error during hard scan converter initialization: " @@ -73,25 +91,23 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - scan2D.AbortScan(); - hwControls.StartMotor(); + capture.AbortScan(); std::cout << "\nStarting BMode scanning..." << std::endl; - scan2D.StartReadScan(); + capture.StartReadScan(); Sleep( 100 ); // "time to start" hwControls.StartBmode(); - std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; - std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; + std::cout << "\nScan is on: " << capture.GetScanOn() << std::endl; + std::cout << "\nTrueDepth: " << scanConverter.GetTrueDepth() << std::endl; std::cout << "\nHeightScan: " << scanConverter.GetHeightScan() << std::endl; std::cout << "WidthScan: " << scanConverter.GetWidthScan() << std::endl; std::cout << "\nMmPerPixel: " << scanConverter.GetMmPerPixel() << std::endl; std::cout << "\nZeroOfYScale: " << scanConverter.GetZeroOfYScale() << std::endl; hwControls.StopAcquisition(); - scan2D.StopReadScan(); + capture.StopReadScan(); Sleep( 100 ); // "time to stop" - scan2D.DisposeScan(); - hwControls.StopMotor(); + capture.DisposeScan(); return EXIT_SUCCESS; } diff --git a/test/IntersonArrayCxxIntersonClassTest.cxx b/test/IntersonArrayCxxIntersonClassTest.cxx new file mode 100644 index 0000000..3040883 --- /dev/null +++ b/test/IntersonArrayCxxIntersonClassTest.cxx @@ -0,0 +1,34 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include "IntersonArrayCxxIntersonClass.h" + +#include +#include + +int main( int argc, char * argv[] ) +{ + IntersonArrayCxx::IntersonClass intersonClass; + + std::cout << "Version: " << intersonClass.Version() << std::endl; + return EXIT_SUCCESS; +} diff --git a/test/IntersonCxxImagingScan2DClassTest.cxx b/test/IntersonCxxImagingScan2DClassTest.cxx deleted file mode 100644 index 418d4b9..0000000 --- a/test/IntersonCxxImagingScan2DClassTest.cxx +++ /dev/null @@ -1,64 +0,0 @@ -#include "IntersonCxxImagingScan2DClass.h" -#include "IntersonCxxControlsHWControls.h" - -#include -#include -#include - -#include // Sleep - -int main( int argc, char * argv[] ) -{ - typedef IntersonCxx::Controls::HWControls HWControlsType; - HWControlsType hwControls; - - typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; - Scan2DClassType scan2D; - - typedef HWControlsType::FoundProbesType FoundProbesType; - FoundProbesType foundProbes; - hwControls.FindAllProbes( foundProbes ); - if( foundProbes.empty() ) - { - std::cerr << "Could not find the probe." << std::endl; - return EXIT_FAILURE; - } - hwControls.FindMyProbe( 0 ); - const unsigned int probeId = hwControls.GetProbeID(); - std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; - if( probeId == 0 ) - { - std::cerr << "Could not find the probe." << std::endl; - return EXIT_FAILURE; - } - - std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; - std::cout << "RF Data transfer is on: " << scan2D.GetRFData() << std::endl; - - int ret = EXIT_SUCCESS; - - const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_SAMPLES; - const int maxPixels = maxVectors * maxSamples; - - scan2D.SetFrameAvg( true ); - std::cout << "\nFrameAvg: " << scan2D.GetFrameAvg() << std::endl; - - scan2D.AbortScan(); - hwControls.StartMotor(); - std::cout << "\nStarting BMode scanning..." << std::endl; - scan2D.StartReadScan(); - Sleep( 100 ); // "time to start" - hwControls.StartBmode(); - std::cout << "\nScan is on: " << scan2D.GetScanOn() << std::endl; - - std::cout << "\nTrueDepth: " << scan2D.GetTrueDepth() << std::endl; - - hwControls.StopAcquisition(); - scan2D.StopReadScan(); - Sleep( 100 ); // "time to stop" - scan2D.DisposeScan(); - hwControls.StopMotor(); - - return ret; -} diff --git a/test/IntersonCxxIntersonClassTest.cxx b/test/IntersonCxxIntersonClassTest.cxx deleted file mode 100644 index f4ae578..0000000 --- a/test/IntersonCxxIntersonClassTest.cxx +++ /dev/null @@ -1,12 +0,0 @@ -#include "IntersonCxxIntersonClass.h" - -#include -#include - -int main( int argc, char * argv[] ) -{ - IntersonCxx::IntersonClass intersonClass; - - std::cout << "Version: " << intersonClass.Version() << std::endl; - return EXIT_SUCCESS; -} From 06e2728bb7ab0b0ac0d7a31270ba9d0f5d706185 Mon Sep 17 00:00:00 2001 From: "Stephen R. Aylward" Date: Tue, 7 Mar 2017 22:26:31 -0500 Subject: [PATCH 063/103] Update README.rst --- README.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 0fd51d8..a402f2d 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,12 @@ -IntersonSDKCxx -============== -C++ Wrapper for the Interson C# SDK ------------------------------------ +IntersonArraySDKCxx +=================== + +C++ Wrapper for the C# SDK for Interson's Linear Array Probe +------------------------------------------------------------- Dependencies ------------ - CMake -- Interson SDK >= 1.15 (Interson.dll >= 1.0.38.0) +- Interson Array SDK - Visual Studio >= 2012 From 4706fdb2e24f639f207f528ddb6a34f4d92ec7c8 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 8 Mar 2017 10:52:55 -0500 Subject: [PATCH 064/103] DOC: Update the required Visual Studio version to 2015 --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a402f2d..e530e6f 100644 --- a/README.rst +++ b/README.rst @@ -9,4 +9,4 @@ Dependencies - CMake - Interson Array SDK -- Visual Studio >= 2012 +- Visual Studio >= 2015 From b6050e7fba13881a521c74e92f8f5d7c3568f1f6 Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Wed, 8 Mar 2017 22:52:05 -0500 Subject: [PATCH 065/103] ENH: Create a single container class for Imaging's subclasses This merger of subclasses allows us to avoid having to pass instances of subclasses to one another - which isn't possible because it would require mixing managed and unmanaged code. The IntersonArrayCxxImagingContainer class now supercedes ImagingCapture ImagingImageBuilding ImagingScanConverter Apps and tests have been updated accordingly. --- app/AcquireIntersonArrayBMode.cxx | 127 ++-- app/AcquireIntersonArrayBMode.xml | 15 +- app/AcquireIntersonArrayRF.cxx | 156 +++-- app/AcquireIntersonArrayRF.xml | 23 +- app/CMakeLists.txt | 19 - app/PrintIntersonArrayProbeInfo.cxx | 41 +- include/CMakeLists.txt | 1 + include/IntersonArrayCxxControlsHWControls.h | 4 +- include/IntersonArrayCxxImagingContainer.h | 134 +++++ src/CMakeLists.txt | 11 + src/IntersonArrayCxxControlsHWControls.cxx | 149 ++++- src/IntersonArrayCxxImagingCapture.cxx | 32 +- src/IntersonArrayCxxImagingContainer.cxx | 556 ++++++++++++++++++ test/CMakeLists.txt | 1 + ...IntersonArrayCxxControlsHWControlsTest.cxx | 3 - test/IntersonArrayCxxImagingContainerTest.cxx | 105 ++++ 16 files changed, 1170 insertions(+), 207 deletions(-) create mode 100644 include/IntersonArrayCxxImagingContainer.h create mode 100644 src/IntersonArrayCxxImagingContainer.cxx create mode 100644 test/IntersonArrayCxxImagingContainerTest.cxx diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index a6a7a7e..8b70956 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -25,15 +25,14 @@ limitations under the License. #include "itkImageFileWriter.h" #include "IntersonArrayCxxControlsHWControls.h" -#include "IntersonArrayCxxImagingCapture.h" -#include "IntersonArrayCxxImagingScanConverter.h" +#include "IntersonArrayCxxImagingContainer.h" #include "AcquireIntersonArrayBModeCLP.h" -typedef IntersonArrayCxx::Imaging::Scan2DClass Scan2DClassType; +typedef IntersonArrayCxx::Imaging::Container ContainerType; const unsigned int Dimension = 3; -typedef Scan2DClassType::BmodePixelType PixelType; +typedef ContainerType::PixelType PixelType; typedef itk::Image< PixelType, Dimension > ImageType; @@ -46,36 +45,12 @@ struct CallbackClientData void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) { - CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); + CallbackClientData * callbackClientData = + static_cast< CallbackClientData * >( clientData ); ImageType * image = callbackClientData->Image; - const ImageType::RegionType & largestRegion = image->GetLargestPossibleRegion(); - const ImageType::SizeType imageSize = largestRegion.GetSize(); - const itk::SizeValueType imageFrames = imageSize[2]; - if( callbackClientData->FrameIndex >= imageFrames ) - { - return; - } - - const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_SAMPLES; - const int framePixels = maxVectors * maxSamples; - - PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); - imageBuffer += framePixels * callbackClientData->FrameIndex; - std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); - - std::cout << "Acquired frame: " << callbackClientData->FrameIndex << std::endl; - ++(callbackClientData->FrameIndex); -} - - -void __stdcall pasteIntoScanConvertedImage( PixelType * buffer, void * clientData ) -{ - CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); - ImageType * image = callbackClientData->Image; - - const ImageType::RegionType & largestRegion = image->GetLargestPossibleRegion(); + const ImageType::RegionType & largestRegion = + image->GetLargestPossibleRegion(); const ImageType::SizeType imageSize = largestRegion.GetSize(); const itk::SizeValueType imageFrames = imageSize[2]; if( callbackClientData->FrameIndex >= imageFrames ) @@ -89,7 +64,8 @@ void __stdcall pasteIntoScanConvertedImage( PixelType * buffer, void * clientDat imageBuffer += framePixels * callbackClientData->FrameIndex; std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); - std::cout << "Acquired frame: " << callbackClientData->FrameIndex << std::endl; + std::cout << "Acquired frame: " << callbackClientData->FrameIndex + << std::endl; ++(callbackClientData->FrameIndex); } @@ -99,12 +75,9 @@ int main( int argc, char * argv[] ) PARSE_ARGS; typedef IntersonArrayCxx::Controls::HWControls HWControlsType; - IntersonArrayCxx::Controls::HWControls hwControls; - - Scan2DClassType scan2D; + HWControlsType hwControls; - typedef IntersonArrayCxx::Imaging::ScanConverter ScanConverterType; - ScanConverterType scanConverter; + ContainerType container; typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; @@ -122,19 +95,21 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - const bool upDown = false; - const bool leftRight = false; - const int width = 1000; - const int height = 650; + const int width = hwControls.GetLinesPerArray(); + const int height = container.MAX_SAMPLES; + const int scanWidth = container.GetWidthScan(); + const int scanHeight = container.GetHeightScan(); + std::cout << "Width = " << width << std::endl; + std::cout << "Height = " << height << std::endl; + std::cout << "ScanWidth = " << scanWidth << std::endl; + std::cout << "ScanHeight = " << scanHeight << std::endl; + std::cout << "MM per Pixel = " << container.GetMmPerPixel() << std::endl; + const int steering = 0; if( hwControls.ValidDepth( depth ) == depth ) { - ScanConverterType::ScanConverterError converterError = - scanConverter.HardInitScanConverter( depth, - upDown, - leftRight, - width, - height ); - if( converterError != ScanConverterType::SUCCESS ) + ContainerType::ScanConverterError converterError = + container.HardInitScanConverter( depth, width, height, steering ); + if( converterError != ContainerType::SUCCESS ) { std::cerr << "Error during hard scan converter initialization: " << converterError << std::endl; @@ -148,8 +123,8 @@ int main( int argc, char * argv[] ) const itk::SizeValueType framesToCollect = frames; - const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_SAMPLES; + const int maxVectors = hwControls.GetLinesPerArray(); + const int maxSamples = ContainerType::MAX_SAMPLES; ImageType::Pointer image = ImageType::New(); typedef ImageType::RegionType RegionType; @@ -158,44 +133,29 @@ int main( int argc, char * argv[] ) imageIndex.Fill( 0 ); imageRegion.SetIndex( imageIndex ); ImageType::SizeType imageSize; - if( scanConvert ) - { - imageSize[0] = width; - imageSize[1] = height; - } - else - { - imageSize[0] = maxSamples; - imageSize[1] = maxVectors; - } + imageSize[0] = maxSamples; + imageSize[1] = maxVectors; imageSize[2] = framesToCollect; imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); image->Allocate(); CallbackClientData clientData; - clientData.Image = image.GetPointer(); clientData.FrameIndex = 0; - if( scanConvert ) - { - scan2D.SetNewScanConvertedBmodeImageCallback( &pasteIntoScanConvertedImage, &clientData ); - } - else - { - scan2D.SetNewBmodeImageCallback( &pasteIntoImage, &clientData ); - } + container.SetNewImageCallback( &pasteIntoImage, &clientData ); HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); - if( !hwControls.SetFrequency( frequencies[frequencyIndex] ) ) + if( !hwControls.SetFrequencyAndFocus( frequencyIndex, focusIndex, + steering ) ) { std::cerr << "Could not set the frequency." << std::endl; return EXIT_FAILURE; } - if( !hwControls.SendHighVoltage( highVoltage ) ) + if( !hwControls.SendHighVoltage( highVoltage, highVoltage ) ) { std::cerr << "Could not set the high voltage." << std::endl; return EXIT_FAILURE; @@ -213,14 +173,9 @@ int main( int argc, char * argv[] ) hwControls.DisableHardButton(); - scan2D.AbortScan(); - scan2D.SetRFData( false ); - if( !hwControls.StartMotor() ) - { - std::cerr << "Could not start motor." << std::endl; - return EXIT_FAILURE; - }; - scan2D.StartReadScan(); + container.AbortScan(); + container.SetRFData( false ); + container.StartReadScan(); Sleep( 100 ); // "time to start" if( !hwControls.StartBmode() ) { @@ -228,16 +183,20 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; }; - while( clientData.FrameIndex < framesToCollect ) + int c = 0; + while( clientData.FrameIndex < framesToCollect && c < 100 ) { + std::cout << clientData.FrameIndex << " of " << framesToCollect + << std::endl; + std::cout << c << " of 100" << std::endl; Sleep( 100 ); + ++c; } hwControls.StopAcquisition(); - scan2D.StopReadScan(); + container.StopReadScan(); Sleep( 100 ); // "time to stop" - scan2D.DisposeScan(); - hwControls.StopMotor(); + container.DisposeScan(); typedef itk::ImageFileWriter< ImageType > WriterType; WriterType::Pointer writer = WriterType::New(); diff --git a/app/AcquireIntersonArrayBMode.xml b/app/AcquireIntersonArrayBMode.xml index c177b0b..90cfe53 100644 --- a/app/AcquireIntersonArrayBMode.xml +++ b/app/AcquireIntersonArrayBMode.xml @@ -31,6 +31,14 @@ f 1 + + focusIndex + + Index of the focus to examine. See the output of PrintIntersonProbeInfo. + focusIndex + F + 0 + highVoltage @@ -61,12 +69,5 @@ 0 200 - - scanConvert - - Do scan conversion. - scanConvert - s - diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index c5ee361..38ce611 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -1,16 +1,38 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ #include // Sleep #include "itkImageFileWriter.h" -#include "IntersonCxxImagingScan2DClass.h" -#include "IntersonCxxControlsHWControls.h" +#include "IntersonArrayCxxImagingContainer.h" +#include "IntersonArrayCxxControlsHWControls.h" -#include "AcquireIntersonRFCLP.h" +#include "AcquireIntersonArrayRFCLP.h" -typedef IntersonCxx::Imaging::Scan2DClass Scan2DClassType; +typedef IntersonArrayCxx::Imaging::Container ContainerType; const unsigned int Dimension = 3; -typedef Scan2DClassType::RFPixelType PixelType; +typedef ContainerType::RFPixelType PixelType; typedef itk::Image< PixelType, Dimension > ImageType; @@ -22,25 +44,29 @@ struct CallbackClientData void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) { - CallbackClientData * callbackClientData = static_cast< CallbackClientData * >( clientData ); - ImageType * image = callbackClientData->Image; - - const ImageType::RegionType & largestRegion = image->GetLargestPossibleRegion(); + CallbackClientData * callbackClientData = + static_cast< CallbackClientData * >( clientData ); + ImageType * image = + callbackClientData->Image; + + const ImageType::RegionType & largestRegion = + image->GetLargestPossibleRegion(); + const ImageType::SizeType imageSize = largestRegion.GetSize(); const itk::SizeValueType imageFrames = largestRegion.GetSize()[2]; if( callbackClientData->FrameIndex >= imageFrames ) { return; } - const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_RFSAMPLES; - const int framePixels = maxVectors * maxSamples; + const int framePixels = imageSize[0] * imageSize[1]; + std::cout << "frame pixels = " << framePixels << std::endl; PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); imageBuffer += framePixels * callbackClientData->FrameIndex; std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); - std::cout << "Acquired frame: " << callbackClientData->FrameIndex << std::endl; + std::cout << "Acquired frame: " << callbackClientData->FrameIndex + << std::endl; ++(callbackClientData->FrameIndex); } @@ -48,11 +74,10 @@ int main( int argc, char * argv[] ) { PARSE_ARGS; + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + IntersonArrayCxx::Controls::HWControls hwControls; - typedef IntersonCxx::Controls::HWControls HWControlsType; - IntersonCxx::Controls::HWControls hwControls; - - Scan2DClassType scan2D; + ContainerType container; typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; @@ -72,9 +97,29 @@ int main( int argc, char * argv[] ) int ret = EXIT_SUCCESS; + int steering = 0; + + const int width = hwControls.GetLinesPerArray(); + const int height = ContainerType::MAX_RFSAMPLES; + if( hwControls.ValidDepth( depth ) == depth ) + { + ContainerType::ScanConverterError converterError = + container.HardInitScanConverter( depth, width, height, steering ); + if( converterError != ContainerType::SUCCESS ) + { + std::cerr << "Error during hard scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } + } + else + { + std::cerr << "Invalid requested depth for probe." << std::endl; + } + const itk::SizeValueType framesToCollect = frames; - const int maxVectors = Scan2DClassType::MAX_VECTORS; - const int maxSamples = Scan2DClassType::MAX_RFSAMPLES; + const int maxVectors = hwControls.GetLinesPerArray(); + const int maxSamples = ContainerType::MAX_RFSAMPLES; ImageType::Pointer image = ImageType::New(); typedef ImageType::RegionType RegionType; @@ -94,17 +139,16 @@ int main( int argc, char * argv[] ) clientData.Image = image.GetPointer(); clientData.FrameIndex = 0; - scan2D.SetNewRFImageCallback( &pasteIntoImage, &clientData ); - HWControlsType::FrequenciesType frequencies; hwControls.GetFrequency( frequencies ); - if( !hwControls.SetFrequency( frequencies[frequencyIndex] ) ) + if( !hwControls.SetFrequencyAndFocus( frequencyIndex, focusIndex, + steering ) ) { - std::cerr << "Could not set the frequency." << std::endl; + std::cerr << "Could not set the frequency and focus." << std::endl; return EXIT_FAILURE; } - if( !hwControls.SendHighVoltage( highVoltage ) ) + if( !hwControls.SendHighVoltage( highVoltage, highVoltage ) ) { std::cerr << "Could not set the high voltage." << std::endl; return EXIT_FAILURE; @@ -115,50 +159,58 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - if( decimator ) - { - if( !hwControls.EnableRFDecimator() ) - { - std::cerr << "Could not enable RF decimator." << std::endl; - return EXIT_FAILURE; - } - } - else - { - if( !hwControls.DisableRFDecimator() ) - { - std::cerr << "Could not disable RF decimator." << std::endl; - return EXIT_FAILURE; - } - } - hwControls.DisableHardButton(); - scan2D.AbortScan(); - scan2D.SetRFData( true ); - if( !hwControls.StartMotor() ) + std::cout << "Acquire 1 bmode image" << std::endl; + container.AbortScan(); + container.SetRFData( false ); + container.StartReadScan(); + if( !hwControls.StartBmode() ) { - std::cerr << "Could not start motor." << std::endl; + std::cerr << "Could not start RF collection." << std::endl; return EXIT_FAILURE; - }; - scan2D.StartRFReadScan(); + } + Sleep( 100 ); + Sleep( 100 ); + Sleep( 100 ); + Sleep( 100 ); + std::cout << "StopAcquisition" << std::endl; + hwControls.StopAcquisition(); + container.StopReadScan(); + Sleep( 100 ); // "time to stop" + container.DisposeScan(); + + container.SetNewRFImageCallback( &pasteIntoImage, &clientData ); + + std::cout << "SetRFData" << std::endl; + container.SetRFData( true ); + std::cout << "StartRFReadScan" << std::endl; + container.StartRFReadScan(); Sleep( 100 ); // "time to start" + std::cout << "StartRFmode" << std::endl; if( !hwControls.StartRFmode() ) { std::cerr << "Could not start RF collection." << std::endl; return EXIT_FAILURE; - }; + } - while( clientData.FrameIndex < framesToCollect ) + /* BUG: FrameIndex never changes, since callback + * never happens with RF data. */ + int c = 0; + while( clientData.FrameIndex < framesToCollect && c < 100 ) { + std::cout << clientData.FrameIndex << " of " << framesToCollect + << std::endl; + std::cout << c << " of 100" << std::endl; Sleep( 100 ); + ++c; } + std::cout << "StopAcquisition" << std::endl; hwControls.StopAcquisition(); - scan2D.StopReadScan(); + container.StopReadScan(); Sleep( 100 ); // "time to stop" - scan2D.DisposeScan(); - hwControls.StopMotor(); + container.DisposeScan(); typedef itk::ImageFileWriter< ImageType > WriterType; WriterType::Pointer writer = WriterType::New(); diff --git a/app/AcquireIntersonArrayRF.xml b/app/AcquireIntersonArrayRF.xml index fcff8db..67f36a2 100644 --- a/app/AcquireIntersonArrayRF.xml +++ b/app/AcquireIntersonArrayRF.xml @@ -31,6 +31,14 @@ f 1 + + focusIndex + + Index of the focus to examine. See the output of PrintIntersonProbeInfo. + focusIndex + F + 0 + highVoltage @@ -41,13 +49,16 @@ 0 100 - - decimator - - For GV and GP (low frequency probes) sampling rate is 15 Msamples/sec with decimator off and with decimator on sampling rate is 7.5 Msamples/sec. For higher frequency probes sampling rate is 30 Ms/sec with decimator off and 15 Ms/sec with decimator on. - decimator + + depth + + Depth of acquisition [mm]. Only relevant with scanConvert. + depth d - + 40 + 0 + 200 + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 9755170..3c241e8 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -71,19 +71,6 @@ if( BUILD_TESTING ) --gain 50 ${TEMP}/AcquireIntersonArrayBModeTestGain.mha ) - add_test( NAME AcquireIntersonArrayBModeTestScanConvert - COMMAND $ - --scanConvert - --gain 50 - ${TEMP}/AcquireIntersonArrayBModeTestScanConvert.mha - ) - add_test( NAME AcquireIntersonArrayBModeTestScanConvertFrames - COMMAND $ - -s - -n 4 - --gain 50 - ${TEMP}/AcquireIntersonArrayBModeTestScanConvertFrames.mha - ) add_test( NAME AcquireIntersonArrayRFTest COMMAND $ @@ -99,12 +86,6 @@ if( BUILD_TESTING ) --highVoltage 30 ${TEMP}/AcquireIntersonArrayRFTestVoltage.mha ) - add_test( NAME AcquireIntersonArrayRFTestDecimator - COMMAND $ - --decimator - ${TEMP}/AcquireIntersonArrayRFTestDecimator.mha - ) - add_test( NAME PrintIntersonArrayProbeInfoTest COMMAND $ ) diff --git a/app/PrintIntersonArrayProbeInfo.cxx b/app/PrintIntersonArrayProbeInfo.cxx index b6a24e2..0ebc745 100644 --- a/app/PrintIntersonArrayProbeInfo.cxx +++ b/app/PrintIntersonArrayProbeInfo.cxx @@ -21,7 +21,9 @@ limitations under the License. =========================================================================*/ #include "IntersonArrayCxxControlsHWControls.h" -#include "IntersonArrayCxxIntersonClass.h" + +#include +#include #include "PrintIntersonArrayProbeInfoCLP.h" @@ -29,8 +31,13 @@ int main( int argc, char * argv[] ) { PARSE_ARGS; + std::cout << "Start---" << std::endl; typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + IntersonArrayCxx::Controls::HWControls hwControls; + + std::cout << "ProbeID: " << static_cast< int >( + hwControls.GetProbeID() ) << std::endl; typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; @@ -40,7 +47,7 @@ int main( int argc, char * argv[] ) std::cerr << "Could not find the probe." << std::endl; return EXIT_FAILURE; } - std::cout << "\nProbes Found: " << std::endl; + std::cout << "Probes Found: " << std::endl; for( size_t ii = 0; ii < foundProbes.size(); ++ii ) { std::cout << " " << ii << ": " << foundProbes[ii] << std::endl; @@ -66,22 +73,40 @@ int main( int argc, char * argv[] ) std::cout << " " << ii << ": " << frequencies[ii] << std::endl; } + HWControlsType::FocusType focus; + hwControls.GetFocus( focus ); + std::cout << "\nFocus: [mm]" << std::endl; + for( size_t ii = 0; ii < focus.size(); ++ii ) + { + std::cout << " " << ii << ": " << focus[ii] << std::endl; + } + std::cout << "\nSupported Depth [mm]: FrameRate [fps]" << std::endl; int depth = 20; while( hwControls.ValidDepth( depth ) == depth ) { - short frameRate = hwControls.GetProbeFrameRate( depth ); + short frameRate = hwControls.GetProbeFrameRate(); std::cout << " " << depth << ":\t" << frameRate << std::endl; depth += 20; } - std::cout << "\nSerial number: " << hwControls.GetProbeSerialNumber() << std::endl; - std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() << std::endl; + std::cout << "Lines per array = " << hwControls.GetLinesPerArray() + << std::endl; + std::cout << "Array CompoundAngle = " << hwControls.GetCompoundAngle() + << std::endl; + std::cout << "Array Radius = " << hwControls.GetArrayRadius() + << std::endl; + std::cout << "Array Angle = " << hwControls.GetArrayAngle() + << std::endl; + std::cout << "Array Width = " << hwControls.GetArrayWidth() + << std::endl; + + std::cout << "\nSerial number: " << hwControls.GetProbeSerialNumber() + << std::endl; + std::cout << "FPGA Version: " << hwControls.ReadFPGAVersion() + << std::endl; std::cout << "OEM ID: " << hwControls.GetOEMId() << std::endl; std::cout << "Filter ID: " << hwControls.GetFilterId() << std::endl; - IntersonArrayCxx::IntersonClass intersonClass; - std::cout << "SDK Version: " << intersonClass.Version() << std::endl; - return EXIT_SUCCESS; } diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 4be57aa..6037f9d 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,6 +22,7 @@ ############################################################################## set( IntersonArrayCxx_HEADERS IntersonArrayCxxControlsHWControls.h + IntersonArrayCxxImagingContainer.h IntersonArrayCxxImagingCapture.h IntersonArrayCxxImagingImageBuilding.h IntersonArrayCxxImagingScanConverter.h diff --git a/include/IntersonArrayCxxControlsHWControls.h b/include/IntersonArrayCxxControlsHWControls.h index d4d8d79..5079e8a 100644 --- a/include/IntersonArrayCxxControlsHWControls.h +++ b/include/IntersonArrayCxxControlsHWControls.h @@ -169,10 +169,10 @@ class IntersonArrayCxx_EXPORT HWControls //To get the identification of the filter. std::string GetFilterId() const; - bool DoReadOEMEEPROM( unsigned char & bytDataStage, unsigned short addr, + bool DoReadOEMEEPROM( unsigned char * bytDataStage, unsigned short addr, unsigned short length ); - bool DoWriteOEMEEPROM( unsigned char & bytDataStage, unsigned short addr, + bool DoWriteOEMEEPROM( unsigned char * bytDataStage, unsigned short addr, unsigned short length ); diff --git a/include/IntersonArrayCxxImagingContainer.h b/include/IntersonArrayCxxImagingContainer.h new file mode 100644 index 0000000..0f7d4e1 --- /dev/null +++ b/include/IntersonArrayCxxImagingContainer.h @@ -0,0 +1,134 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#ifndef _IntersonArrayCxxImagingContainer_h +#define _IntersonArrayCxxImagingContainer_h + +#include "IntersonArrayCxx_Export.h" + +#include +#include + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +class ContainerImpl; + +class IntersonArrayCxx_EXPORT Container +{ +public: + Container(); + ~Container(); + + typedef unsigned char PixelType; + typedef unsigned short RFPixelType; + + static const int MAX_SAMPLES = 1024; + static const int MAX_RFSAMPLES = 2048; + + bool GetCompound(); + + void SetCompound( bool value ); + + bool GetDoubler(); + + void SetDoubler( bool value ); + + int GetHeightScan() const; + + float GetMmPerPixel() const; + + double GetTrueDepth() const; + + int GetWidthScan() const; + + int GetZeroOfYScale() const; + + // Error code of HardInitScanConverter and SoftInitScanConverter + enum ScanConverterError + { + SUCCESS = 1, + PROBE_NOT_INITIALIZED, // FindMyProbe has not been called + UNKNOWN_PROBE, // Probe Identity not valid + UNDER_LIMITS, // Width * Height over 10 * 10 + OVER_LIMITS, // Width * Height over 800 * 1000 + WRONG_FORMAT, // other error + OTHER_ERROR + }; + + ScanConverterError HardInitScanConverter( int depth, int widthScan, + int heightScan, int steering ); + + ScanConverterError IdleInitScanConverter( int depth, int width, + int height, short idleId, int idleSteering, bool idleDoubler, + bool idleCompound, int idleCompoundAngle ); + + // + // Begin Capture Methods + // + bool GetRFData(); + + void SetRFData( bool value ); + + bool GetFrameAvg(); + + void SetFrameAvg( bool value ); + + bool GetScanOn() const; + + void AbortScan(); + + void DisposeScan(); + + void StartReadScan(); + + void StartRFReadScan(); + + void StopReadScan(); + + typedef void (__stdcall *NewImageCallbackType)( PixelType *buffer, + void *clientData ); + void SetNewImageCallback( NewImageCallbackType callback, + void *clientData = NULL ); + + typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, + void *clientData ); + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData = NULL ); + +private: + + Container( const Container &); + void operator=( const Container &); + + ContainerImpl *Impl; +}; + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx + + +#endif // _IntersonArrayCxxImagingContainer_h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 88f8785..94d4752 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ set( COMPILE_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" ) set( IntersonArrayCxx_SRCS IntersonArrayCxxControlsHWControls.cxx + IntersonArrayCxxImagingContainer.cxx IntersonArrayCxxImagingCapture.cxx IntersonArrayCxxImagingImageBuilding.cxx IntersonArrayCxxImagingScanConverter.cxx @@ -64,3 +65,13 @@ if( BUILD_TESTING ) COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin" ) endif() +if( BUILD_APPLICATIONS ) + add_custom_command( TARGET IntersonArrayCxx + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin" + ) + add_custom_command( TARGET IntersonArrayCxx + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/bin/IntersonArrayCxx.dll" "${PROJECT_BINARY_DIR}/app/bin" + ) +endif() diff --git a/src/IntersonArrayCxxControlsHWControls.cxx b/src/IntersonArrayCxxControlsHWControls.cxx index 49dab67..5f44303 100644 --- a/src/IntersonArrayCxxControlsHWControls.cxx +++ b/src/IntersonArrayCxxControlsHWControls.cxx @@ -314,6 +314,38 @@ class HWControlsImpl IntersonArray::Controls::HWControls::GetFilterId() ); } + bool DoReadOEMEEPROM( unsigned char * bytDataStage, unsigned short addr, + unsigned short length ) + { + typedef cli::array< unsigned char, 1 > DataType; + DataType ^ managedData; + + if( Wrapped->DoReadOEMEEPROM( managedData, addr, length ) ) + { + bytDataStage = new unsigned char[ length ]; + for( unsigned int ii=0; ii DataType; + DataType ^ managedData; + + for( unsigned int ii=0; iiDoWriteOEMEEPROM( managedData, addr, length ); + } + private: @@ -341,6 +373,46 @@ HWControls } +int +HWControls +::GetCompoundAngle() const +{ + return Impl->GetCompoundAngle(); +} + + +bool +HWControls +::EnableCompound() +{ + return Impl->EnableCompound(); +} + + +bool +HWControls +::DisableCompound() +{ + return Impl->DisableCompound(); +} + + +bool +HWControls +::EnableDoubler() +{ + return Impl->EnableDoubler(); +} + + +bool +HWControls +::DisableDoubler() +{ + return Impl->DisableDoubler(); +} + + short HWControls ::GetProbeID() const @@ -364,19 +436,28 @@ ::FindMyProbe( int probeIndex ) Impl->FindMyProbe( probeIndex ); } -int + +float HWControls -::ValidDepth( int depth ) const +::GetArrayAngle() const { - return Impl->ValidDepth( depth ); + return Impl->GetArrayAngle(); } -void +float HWControls -::GetFrequency( FrequenciesType &frequencies ) const +::GetArrayRadius() const { - Impl->GetFrequency( frequencies ); + return Impl->GetArrayRadius(); +} + + +float +HWControls +::GetArrayWidth() const +{ + return Impl->GetArrayWidth(); } @@ -388,6 +469,22 @@ ::GetFocus( FocusType &focus ) const } +int +HWControls +::ValidDepth( int depth ) const +{ + return Impl->ValidDepth( depth ); +} + + +void +HWControls +::GetFrequency( FrequenciesType &frequencies ) const +{ + Impl->GetFrequency( frequencies ); +} + + bool HWControls ::SetFrequencyAndFocus( unsigned char frequency, unsigned char focus, @@ -397,6 +494,14 @@ ::SetFrequencyAndFocus( unsigned char frequency, unsigned char focus, } +unsigned int +HWControls +::GetLinesPerArray() const +{ + return Impl->GetLinesPerArray(); +} + + bool HWControls ::SendHighVoltage( unsigned char voltage, unsigned char voltageCfm ) @@ -452,6 +557,13 @@ ::ReadHardButton() return Impl->ReadHardButton(); } +void +HWControls +::SetNewHardButtonCallback( HWControls::NewHardButtonCallbackType callback, + void * clientData ) +{ + Impl->SetNewHardButtonCallback( callback, clientData ); +} bool HWControls @@ -509,6 +621,14 @@ ::GetOEMId() const } +std::string +HWControls +::Get3DId() const +{ + return Impl->Get3DId(); +} + + std::string HWControls ::GetFilterId() const @@ -516,6 +636,23 @@ ::GetFilterId() const return Impl->GetFilterId(); } + +bool +HWControls +::DoReadOEMEEPROM( unsigned char * bytDataStage, unsigned short addr, + unsigned short length ) +{ + return Impl->DoReadOEMEEPROM( bytDataStage, addr, length ); +} + +bool +HWControls +::DoWriteOEMEEPROM( unsigned char * bytDataStage, unsigned short addr, + unsigned short length ) +{ + return Impl->DoWriteOEMEEPROM( bytDataStage, addr, length ); +} + } // end namespace Controls } // end namespace IntersonArrayCxx diff --git a/src/IntersonArrayCxxImagingCapture.cxx b/src/IntersonArrayCxxImagingCapture.cxx index 22ac8df..6ec3fa2 100644 --- a/src/IntersonArrayCxxImagingCapture.cxx +++ b/src/IntersonArrayCxxImagingCapture.cxx @@ -23,6 +23,7 @@ limitations under the License. #pragma unmanaged #include "IntersonArrayCxxImagingCapture.h" #include "IntersonArrayCxxImagingScanConverter.h" +#include "IntersonArrayCxxControlsHWControls.h" #pragma managed #include @@ -30,9 +31,6 @@ limitations under the License. #using "IntersonArray.dll" -// for Bitmap -#using "System.Drawing.dll" - namespace IntersonArrayCxx { @@ -52,8 +50,7 @@ ref class NewRFImageHandler NewRFImageCallback( NULL ), NewRFImageCallbackClientData( NULL ), NativeRFBuffer( new RFPixelType[ScanConverter::MAX_RFSAMPLES - * 512] ), - //* ScanConverter::MAX_VECTORS] + * ScanConverter::MAX_RFSAMPLES] ), ManagedRFBuffer( managedRFBuffer ) { } @@ -68,8 +65,7 @@ ref class NewRFImageHandler { if ( this->NewRFImageCallback != NULL ) { - //for ( int ii = 0; ii < ScanConverter::MAX_VECTORS; ++ii ) - for ( int ii = 0; ii < 512; ++ii ) + for ( int ii = 0; ii < ScanConverter::MAX_RFSAMPLES; ++ii ) { for ( int jj = 0; jj < ScanConverter::MAX_RFSAMPLES; ++jj ) { @@ -93,7 +89,7 @@ ref class NewRFImageHandler NewRFImageCallbackType NewRFImageCallback; void * NewRFImageCallbackClientData; RFPixelType * NativeRFBuffer; - RFArrayType ^ManagedRFBuffer; + RFArrayType ^ ManagedRFBuffer; }; @@ -109,8 +105,7 @@ ref class NewImageHandler NewImageCallback( NULL ), NewImageCallbackClientData( NULL ), NativeBuffer( new PixelType[ScanConverter::MAX_SAMPLES * - 512] ), - //ScanConverter::MAX_VECTORS] ), + ScanConverter::MAX_SAMPLES] ), ManagedBuffer( managedBuffer ) { } @@ -125,12 +120,11 @@ ref class NewImageHandler { if ( this->NewImageCallback != NULL ) { - for ( int ii = 0; ii < 512; ++ii ) - //for ( int ii = 0; ii < ScanConverter::MAX_VECTORS; ++ii ) + for ( int ii = 0; ii < ScanConverter::MAX_RFSAMPLES; ++ii ) { - for ( int jj = 0; jj < ScanConverter::MAX_SAMPLES; ++jj ) + for ( int jj = 0; jj < ScanConverter::MAX_RFSAMPLES; ++jj ) { - this->NativeBuffer[ScanConverter::MAX_SAMPLES * ii + jj] = + this->NativeBuffer[ScanConverter::MAX_RFSAMPLES * ii + jj] = this->ManagedBuffer[ii, jj]; } } @@ -150,7 +144,7 @@ ref class NewImageHandler NewImageCallbackType NewImageCallback; void * NewImageCallbackClientData; PixelType * NativeBuffer; - ArrayType ^ManagedBuffer; + ArrayType ^ ManagedBuffer; }; @@ -167,17 +161,15 @@ class CaptureImpl { Wrapped = gcnew IntersonArray::Imaging::Capture(); - //Buffer = gcnew ArrayType( ScanConverter::MAX_VECTORS, - Buffer = gcnew ArrayType( 512, - ScanConverter::MAX_SAMPLES); + Buffer = gcnew ArrayType( ScanConverter::MAX_SAMPLES, + ScanConverter::MAX_SAMPLES ); Handler = gcnew NewImageHandler( Buffer ); HandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( Handler, & NewImageHandler::HandleNewImage ); Wrapped->NewImageTick += HandlerDelegate; - //RFBuffer = gcnew RFArrayType( ScanConverter::MAX_VECTORS, - RFBuffer = gcnew RFArrayType( 512, + RFBuffer = gcnew RFArrayType( ScanConverter::MAX_RFSAMPLES, ScanConverter::MAX_RFSAMPLES ); RFHandler = gcnew NewRFImageHandler( RFBuffer ); RFHandlerDelegate = gcnew diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx new file mode 100644 index 0000000..c43e2ba --- /dev/null +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -0,0 +1,556 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#pragma unmanaged +#include "IntersonArrayCxxImagingContainer.h" +#include +#pragma managed + +#include +#include +#include + +#using "IntersonArray.dll" + +namespace IntersonArrayCxx +{ + +namespace Imaging +{ + +// +// Begin Capture +// +ref class NewRFImageHandler +{ +public: + + typedef Container::NewRFImageCallbackType NewRFImageCallbackType; + + typedef IntersonArrayCxx::Imaging::Container::RFPixelType RFPixelType; + typedef cli::array< RFPixelType, 2 > RFArrayType; + + NewRFImageHandler( RFArrayType ^managedRFBuffer ): + NewRFImageCallback( NULL ), + NewRFImageCallbackClientData( NULL ), + NativeRFBuffer( new RFPixelType[Container::MAX_RFSAMPLES + * Container::MAX_RFSAMPLES] ), + ManagedRFBuffer( managedRFBuffer ) + { + } + + ~NewRFImageHandler() + { + delete [] NativeRFBuffer; + } + + void HandleNewRFImage( IntersonArray::Imaging::Capture ^scan2D, + System::EventArgs ^eventArgs ) + { + if ( this->NewRFImageCallback != NULL ) + { + for ( int ii = 0; ii < Container::MAX_RFSAMPLES; ++ii ) + { + for ( int jj = 0; jj < Container::MAX_RFSAMPLES; ++jj ) + { + this->NativeRFBuffer[Container::MAX_RFSAMPLES * ii + jj] = + this->ManagedRFBuffer[ii, jj]; + } + } + this->NewRFImageCallback( this->NativeRFBuffer, + this->NewRFImageCallbackClientData ); + } + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData ) + { + this->NewRFImageCallback = callback; + this->NewRFImageCallbackClientData = clientData; + } + +private: + NewRFImageCallbackType NewRFImageCallback; + void * NewRFImageCallbackClientData; + RFPixelType * NativeRFBuffer; + RFArrayType ^ ManagedRFBuffer; +}; + + +ref class NewImageHandler +{ +public: + typedef Container::NewImageCallbackType NewImageCallbackType; + + typedef IntersonArrayCxx::Imaging::Container::PixelType PixelType; + typedef cli::array< byte, 2 > ArrayType; + + NewImageHandler( ArrayType ^managedBuffer ): + NewImageCallback( NULL ), + NewImageCallbackClientData( NULL ), + NativeBuffer( new PixelType[Container::MAX_SAMPLES * + Container::MAX_SAMPLES] ), + ManagedBuffer( managedBuffer ) + { + } + + ~NewImageHandler() + { + delete [] NativeBuffer; + } + + void HandleNewImage( IntersonArray::Imaging::Capture ^scan2D, + System::EventArgs ^eventArgs ) + { + if ( this->NewImageCallback != NULL ) + { + for ( int ii = 0; ii < Container::MAX_SAMPLES; ++ii ) + { + for ( int jj = 0; jj < Container::MAX_SAMPLES; ++jj ) + { + this->NativeBuffer[Container::MAX_SAMPLES * ii + jj] = + this->ManagedBuffer[ii, jj]; + } + } + this->NewImageCallback( this->NativeBuffer, + this->NewImageCallbackClientData ); + } + } + + void SetNewImageCallback( NewImageCallbackType callback, + void *clientData ) + { + this->NewImageCallback = callback; + this->NewImageCallbackClientData = clientData; + } + +private: + NewImageCallbackType NewImageCallback; + void * NewImageCallbackClientData; + PixelType * NativeBuffer; + ArrayType ^ ManagedBuffer; +}; + +// End Capture + +class ContainerImpl +{ +public: + typedef cli::array< Container::PixelType, 2 > ArrayType; + typedef cli::array< Container::RFPixelType, 2 > RFArrayType; + + typedef Container::NewImageCallbackType NewImageCallbackType; + typedef Container::NewRFImageCallbackType NewRFImageCallbackType; + + ContainerImpl() + { + WrappedScanConverter = gcnew IntersonArray::Imaging::ScanConverter(); + WrappedImageBuilding = gcnew IntersonArray::Imaging::ImageBuilding(); + WrappedCapture = gcnew IntersonArray::Imaging::Capture(); + + Buffer = gcnew ArrayType( Container::MAX_SAMPLES, + Container::MAX_SAMPLES); + Handler = gcnew NewImageHandler( Buffer ); + HandlerDelegate = gcnew + IntersonArray::Imaging::Capture::NewImageHandler( Handler, + & NewImageHandler::HandleNewImage ); + WrappedCapture->NewImageTick += HandlerDelegate; + + RFBuffer = gcnew RFArrayType( Container::MAX_RFSAMPLES, + Container::MAX_RFSAMPLES ); + RFHandler = gcnew NewRFImageHandler( RFBuffer ); + RFHandlerDelegate = gcnew + IntersonArray::Imaging::Capture::NewImageHandler( RFHandler, + & NewRFImageHandler::HandleNewRFImage ); + WrappedCapture->NewImageTick += RFHandlerDelegate; + + } + + ~ContainerImpl() + { + WrappedCapture->NewImageTick -= RFHandlerDelegate; + WrappedCapture->NewImageTick -= HandlerDelegate; + } + + bool GetCompound() + { + return WrappedScanConverter->Compound; + } + + void SetCompound( bool value ) + { + WrappedScanConverter->Compound = value; + } + + bool GetDoubler() + { + return WrappedScanConverter->Doubler; + } + + void SetDoubler( bool value ) + { + WrappedScanConverter->Doubler = value; + } + + int GetHeightScan() const + { + return WrappedScanConverter->HeightScan; + } + + float GetMmPerPixel() const + { + return WrappedScanConverter->MmPerPixel; + } + + double GetTrueDepth() const + { + return WrappedScanConverter->TrueDepth; + } + + int GetWidthScan() const + { + return WrappedScanConverter->WidthScan; + } + + int GetZeroOfYScale() const + { + return WrappedScanConverter->ZeroOfYScale; + } + + Container::ScanConverterError HardInitScanConverter( int depth, + int widthScan, int heightScan, int steering ) + { + return static_cast< Container::ScanConverterError >( + WrappedScanConverter->HardInitScanConverter( depth, widthScan, + heightScan, steering, WrappedCapture.get(), + WrappedImageBuilding.get() ) ); + } + + Container::ScanConverterError IdleInitScanConverter( int depth, + int widthScan, int heightScan, short idleId, int idleSteering, + bool idleDoubler, bool idleCompound, int idleCompoundAngle ) + { + return static_cast< Container::ScanConverterError >( + WrappedScanConverter->IdleInitScanConverter( depth, widthScan, + heightScan, idleId, idleSteering, idleDoubler, idleCompound, + idleCompoundAngle, WrappedImageBuilding.get() ) ); + } + + // + // Begin Capture + // + bool GetFrameAvg() + { + return WrappedCapture->FrameAvg; + } + + void SetFrameAvg( bool value) + { + WrappedCapture->FrameAvg = value; + } + + bool GetRFData() + { + return WrappedCapture->RFData; + } + + void SetRFData( bool value ) + { + WrappedCapture->RFData = value; + } + + double GetScanOn() + { + return WrappedCapture->ScanOn; + } + + void AbortScan() + { + WrappedCapture->AbortScan(); + } + + void DisposeScan() + { + WrappedCapture->DisposeScan(); + } + + void StartReadScan() + { + WrappedCapture->StartReadScan( (ArrayType ^)Buffer ); + } + + void StartRFReadScan() + { + WrappedCapture->StartRFReadScan( (RFArrayType ^)RFBuffer ); + } + + void StopReadScan() + { + WrappedCapture->StopReadScan(); + } + + void SetNewImageCallback( NewImageCallbackType callback, + void *clientData = 0 ) + { + this->Handler->SetNewImageCallback( callback, clientData ); + } + + void SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData = 0 ) + { + this->RFHandler->SetNewRFImageCallback( callback, clientData ); + } + + // + // Begin Wrapped ImageBuilding + // + +private: + msclr::auto_gcroot< IntersonArray::Imaging::ScanConverter ^ > + WrappedScanConverter; + msclr::auto_gcroot< IntersonArray::Imaging::ImageBuilding ^ > + WrappedImageBuilding; + msclr::auto_gcroot< IntersonArray::Imaging::Capture ^ > + WrappedCapture; + + gcroot< ArrayType ^ > Buffer; + gcroot< RFArrayType ^ > RFBuffer; + gcroot< NewImageHandler ^ > Handler; + gcroot< NewRFImageHandler ^ > RFHandler; + + gcroot< IntersonArray::Imaging::Capture::NewImageHandler ^ > + HandlerDelegate; + gcroot< IntersonArray::Imaging::Capture::NewImageHandler ^ > + RFHandlerDelegate; + +}; + + +#pragma unmanaged + +Container +::Container(): + Impl( new ContainerImpl() ) +{ +} + + +Container +::~Container() +{ + delete Impl; +} + + +bool +Container +::GetCompound() +{ + return Impl->GetCompound(); +} + + +void +Container +::SetCompound( bool value ) +{ + Impl->SetCompound( value ); +} + + +bool +Container +::GetDoubler() +{ + return Impl->GetDoubler(); +} + + +void +Container +::SetDoubler( bool value ) +{ + Impl->SetDoubler( value ); +} + + +int +Container +::GetHeightScan() const +{ + return Impl->GetHeightScan(); +} + + +float +Container +::GetMmPerPixel() const +{ + return Impl->GetMmPerPixel(); +} + + +double +Container +::GetTrueDepth() const +{ + return Impl->GetMmPerPixel(); +} + + +int +Container +::GetWidthScan() const +{ + return Impl->GetWidthScan(); +} + + +int +Container +::GetZeroOfYScale() const +{ + return Impl->GetZeroOfYScale(); +} + + +Container::ScanConverterError +Container +::HardInitScanConverter( int depth, int widthScan, int heightScan, + int steering ) +{ + return Impl->HardInitScanConverter( depth, widthScan, heightScan, + steering ); +} + + +Container::ScanConverterError +Container +::IdleInitScanConverter( int depth, int width, int height, short idleId, + int idleSteering, bool idleDoubler, bool idleCompound, + int idleCompoundAngle ) +{ + return Impl->IdleInitScanConverter( depth, width, height, idleId, + idleSteering, idleDoubler, idleCompound, idleCompoundAngle ); +} + +// +// Begin Capture +// +bool +Container +::GetRFData() +{ + return Impl->GetRFData(); +} + +void +Container +::SetRFData( bool transferOn ) +{ + Impl->SetRFData( transferOn ); +} + + +bool +Container +::GetFrameAvg() +{ + return Impl->GetFrameAvg(); +} + +void +Container +::SetFrameAvg( bool doAveraging ) +{ + Impl->SetFrameAvg( doAveraging ); +} + + +bool +Container +::GetScanOn() const +{ + return Impl->GetScanOn(); +} + + +void +Container +::AbortScan() +{ + Impl->AbortScan(); +} + + +void +Container +::DisposeScan() +{ + Impl->DisposeScan(); +} + + +void +Container +::StartReadScan() +{ + Impl->StartReadScan(); +} + + +void +Container +::StartRFReadScan() +{ + Impl->StartRFReadScan(); +} + + +void +Container +::StopReadScan() +{ + Impl->StopReadScan(); +} + + +void +Container +::SetNewImageCallback( NewImageCallbackType callback, + void *clientData ) +{ + Impl->SetNewImageCallback( callback, clientData ); +} + + +void +Container +::SetNewRFImageCallback( NewRFImageCallbackType callback, + void *clientData ) +{ + Impl->SetNewRFImageCallback( callback, clientData ); +} + +} // end namespace Imaging + +} // end namespace IntersonArrayCxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d5edb07..46e0820 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,6 +23,7 @@ set( _tests IntersonArrayCxxIntersonClassTest IntersonArrayCxxControlsHWControlsTest + IntersonArrayCxxImagingContainerTest IntersonArrayCxxImagingCaptureTest IntersonArrayCxxImagingScanConverterTest ) diff --git a/test/IntersonArrayCxxControlsHWControlsTest.cxx b/test/IntersonArrayCxxControlsHWControlsTest.cxx index b6f8f50..cc1bdac 100644 --- a/test/IntersonArrayCxxControlsHWControlsTest.cxx +++ b/test/IntersonArrayCxxControlsHWControlsTest.cxx @@ -31,9 +31,6 @@ int main( int argc, char * argv[] ) HWControlsType hwControls; - - std::cout << "ID_CA_OP_10MHz: " << hwControls.ID_CA_OP_10MHz << std::endl; - std::cout << "ProbeID: " << static_cast< int >( hwControls.GetProbeID() ) << std::endl; diff --git a/test/IntersonArrayCxxImagingContainerTest.cxx b/test/IntersonArrayCxxImagingContainerTest.cxx new file mode 100644 index 0000000..9c4f04a --- /dev/null +++ b/test/IntersonArrayCxxImagingContainerTest.cxx @@ -0,0 +1,105 @@ +/*========================================================================= + +Library: IntersonArrayArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include "IntersonArrayCxxImagingContainer.h" +#include "IntersonArrayCxxControlsHWControls.h" + +#include +#include +#include + +#include // Sleep + +int main( int argc, char * argv[] ) +{ + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + HWControlsType hwControls; + + typedef IntersonArrayCxx::Imaging::Container ContainerType; + ContainerType container; + + typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + const int depth = 50; + if( hwControls.ValidDepth( depth ) != depth ) + { + std::cerr << "Did not request a valid depth" << std::endl; + return EXIT_SUCCESS; + } + const int width = 776; + const int height = 512; + + int steering = 0; + ContainerType::ScanConverterError converterError = + container.IdleInitScanConverter( depth, width, height, probeId, + steering, false, false, 0 ); + if( converterError != ContainerType::SUCCESS ) + { + std::cerr << "Error during idle scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } + converterError = container.HardInitScanConverter( depth, width, + height, steering ); + if( converterError != ContainerType::SUCCESS ) + { + std::cerr << "Error during hard scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } + + container.AbortScan(); + std::cout << "\nStarting BMode scanning..." << std::endl; + container.StartReadScan(); + Sleep( 100 ); // "time to start" + hwControls.StartBmode(); + + std::cout << "\nScan is on: " << container.GetScanOn() << std::endl; + std::cout << "\nTrueDepth: " << container.GetTrueDepth() << std::endl; + std::cout << "\nHeightScan: " << container.GetHeightScan() << std::endl; + std::cout << "WidthScan: " << container.GetWidthScan() << std::endl; + std::cout << "\nMmPerPixel: " << container.GetMmPerPixel() << std::endl; + std::cout << "\nZeroOfYScale: " << container.GetZeroOfYScale() << std::endl; + + hwControls.StopAcquisition(); + container.StopReadScan(); + Sleep( 100 ); // "time to stop" + container.DisposeScan(); + + return EXIT_SUCCESS; +} From 33353873f180282d4b17a5f6130f3db7602f23f0 Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Fri, 10 Mar 2017 14:24:14 -0500 Subject: [PATCH 066/103] ENH: Removed unused class wrappings. With the introduction of the Imaging::Container to hold the Imaging::ImageBuilding Imaging::Capture Imaging::ScanConverter classes, the wrappers for those individual classes can be removed. --- include/CMakeLists.txt | 3 - include/IntersonArrayCxxImagingCapture.h | 90 ----- .../IntersonArrayCxxImagingImageBuilding.h | 62 --- .../IntersonArrayCxxImagingScanConverter.h | 98 ----- src/CMakeLists.txt | 3 - src/IntersonArrayCxxImagingCapture.cxx | 381 ------------------ src/IntersonArrayCxxImagingImageBuilding.cxx | 111 ----- src/IntersonArrayCxxImagingScanConverter.cxx | 245 ----------- test/CMakeLists.txt | 2 - test/IntersonArrayCxxImagingCaptureTest.cxx | 91 ----- ...tersonArrayCxxImagingScanConverterTest.cxx | 113 ------ 11 files changed, 1199 deletions(-) delete mode 100644 include/IntersonArrayCxxImagingCapture.h delete mode 100644 include/IntersonArrayCxxImagingImageBuilding.h delete mode 100644 include/IntersonArrayCxxImagingScanConverter.h delete mode 100644 src/IntersonArrayCxxImagingCapture.cxx delete mode 100644 src/IntersonArrayCxxImagingImageBuilding.cxx delete mode 100644 src/IntersonArrayCxxImagingScanConverter.cxx delete mode 100644 test/IntersonArrayCxxImagingCaptureTest.cxx delete mode 100644 test/IntersonArrayCxxImagingScanConverterTest.cxx diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 6037f9d..6935f3a 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -23,9 +23,6 @@ set( IntersonArrayCxx_HEADERS IntersonArrayCxxControlsHWControls.h IntersonArrayCxxImagingContainer.h - IntersonArrayCxxImagingCapture.h - IntersonArrayCxxImagingImageBuilding.h - IntersonArrayCxxImagingScanConverter.h IntersonArrayCxxIntersonArrayClass.h ) install( FILES diff --git a/include/IntersonArrayCxxImagingCapture.h b/include/IntersonArrayCxxImagingCapture.h deleted file mode 100644 index 78a8ffb..0000000 --- a/include/IntersonArrayCxxImagingCapture.h +++ /dev/null @@ -1,90 +0,0 @@ -/*========================================================================= - -Library: IntersonArraySDKCxx - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#ifndef _IntersonArrayCxxImagingCapture_h -#define _IntersonArrayCxxImagingCapture_h - -#include "IntersonArrayCxx_Export.h" - -#include -#include - -namespace IntersonArrayCxx -{ - -namespace Imaging -{ - -class CaptureImpl; - -class IntersonArrayCxx_EXPORT Capture -{ -public: - Capture(); - ~Capture(); - - typedef unsigned char PixelType; - typedef unsigned short RFPixelType; - - bool GetRFData(); - - void SetRFData( bool value ); - - bool GetFrameAvg(); - - void SetFrameAvg( bool value ); - - bool GetScanOn() const; - - void AbortScan(); - - void DisposeScan(); - - void StartReadScan(); - - void StartRFReadScan(); - - void StopReadScan(); - - typedef void (__stdcall *NewImageCallbackType)( PixelType *buffer, - void *clientData ); - void SetNewImageCallback( NewImageCallbackType callback, - void *clientData = NULL ); - - typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, - void *clientData ); - void SetNewRFImageCallback( NewRFImageCallbackType callback, - void *clientData = NULL ); - -private: - Capture( const Capture &); - void operator=( const Capture &); - - CaptureImpl *Impl; -}; - -} // end namespace Imaging - -} // end namespace IntersonArrayCxx - - -#endif // _IntersonArrayCxxImagingCapture_h diff --git a/include/IntersonArrayCxxImagingImageBuilding.h b/include/IntersonArrayCxxImagingImageBuilding.h deleted file mode 100644 index bed056b..0000000 --- a/include/IntersonArrayCxxImagingImageBuilding.h +++ /dev/null @@ -1,62 +0,0 @@ -/*========================================================================= - -Library: IntersonArray - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#ifndef _IntersonArrayCxxImagingImageBuilding_h -#define _IntersonArrayCxxImagingImageBuilding_h - -#include "IntersonArrayCxx_Export.h" - -namespace IntersonArrayCxx -{ - -namespace Imaging -{ - -class ImageBuildingImpl; - -class ScanConverter; - -class IntersonArrayCxx_EXPORT ImageBuilding -{ -public: - ImageBuilding(); - ~ImageBuilding(); - - void Build2D( unsigned char * bmpDest, unsigned char * byteRaw, - ScanConverter & scanConverter ); - - void Build2D( unsigned char * bmpDest, unsigned char * byteRawCurrent, - unsigned char * byteRawPrevious, ScanConverter & scanConverter ); - -private: - ImageBuilding( const ImageBuilding &); - void operator=( const ImageBuilding &); - - ImageBuildingImpl *Impl; -}; - -} // end namespace Imaging - -} // end namespace IntersonArrayCxx - - -#endif // _IntersonArrayCxxImagingImageBuilding_h diff --git a/include/IntersonArrayCxxImagingScanConverter.h b/include/IntersonArrayCxxImagingScanConverter.h deleted file mode 100644 index 34dbe10..0000000 --- a/include/IntersonArrayCxxImagingScanConverter.h +++ /dev/null @@ -1,98 +0,0 @@ -/*========================================================================= - -Library: IntersonArray - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#ifndef _IntersonArrayCxxImagingScanConverter_h -#define _IntersonArrayCxxImagingScanConverter_h - -#include "IntersonArrayCxx_Export.h" -#include "IntersonArrayCxxImagingCapture.h" -#include "IntersonArrayCxxImagingImageBuilding.h" - -namespace IntersonArrayCxx -{ - -namespace Imaging -{ - -class ScanConverterImpl; - -class IntersonArrayCxx_EXPORT ScanConverter -{ -public: - ScanConverter(); - ~ScanConverter(); - - static const int MAX_SAMPLES = 1024; - static const int MAX_RFSAMPLES = 2048; - - bool GetCompound(); - - void SetCompound( bool value ); - - bool GetDoubler(); - - void SetDoubler( bool value ); - - int GetHeightScan() const; - - float GetMmPerPixel() const; - - double GetTrueDepth() const; - - int GetWidthScan() const; - - int GetZeroOfYScale() const; - - // Error code of HardInitScanConverter and SoftInitScanConverter - enum ScanConverterError - { - SUCCESS = 1, - PROBE_NOT_INITIALIZED, // FindMyProbe has not been called - UNKNOWN_PROBE, // Probe Identity not valid - UNDER_LIMITS, // Width * Height over 10 * 10 - OVER_LIMITS, // Width * Height over 800 * 1000 - WRONG_FORMAT, // other error - ERROR - }; - - ScanConverterError HardInitScanConverter( int depth, int widthScan, - int heightScan, int steering, Capture & capture, - ImageBuilding & imageBuilding ); - - ScanConverterError IdleInitScanConverter( int depth, int width, - int height, short idleId, int idleSteering, bool idleDoubler, - bool idleCompound, int idleCompoundAngle, ImageBuilding & - imageBuilding ); - -private: - ScanConverter( const ScanConverter &); - void operator=( const ScanConverter &); - - ScanConverterImpl *Impl; -}; - -} // end namespace Imaging - -} // end namespace IntersonArrayCxx - - -#endif // _IntersonArrayCxxImagingScanConverter_h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 94d4752..d9abbbb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,9 +33,6 @@ set( COMPILE_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" ) set( IntersonArrayCxx_SRCS IntersonArrayCxxControlsHWControls.cxx IntersonArrayCxxImagingContainer.cxx - IntersonArrayCxxImagingCapture.cxx - IntersonArrayCxxImagingImageBuilding.cxx - IntersonArrayCxxImagingScanConverter.cxx IntersonArrayCxxIntersonClass.cxx ) diff --git a/src/IntersonArrayCxxImagingCapture.cxx b/src/IntersonArrayCxxImagingCapture.cxx deleted file mode 100644 index 6ec3fa2..0000000 --- a/src/IntersonArrayCxxImagingCapture.cxx +++ /dev/null @@ -1,381 +0,0 @@ -/*========================================================================= - -Library: IntersonArray - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#pragma unmanaged -#include "IntersonArrayCxxImagingCapture.h" -#include "IntersonArrayCxxImagingScanConverter.h" -#include "IntersonArrayCxxControlsHWControls.h" -#pragma managed - -#include -#include - -#using "IntersonArray.dll" - -namespace IntersonArrayCxx -{ - -namespace Imaging -{ - -ref class NewRFImageHandler -{ -public: - - typedef Capture::NewRFImageCallbackType NewRFImageCallbackType; - - typedef IntersonArrayCxx::Imaging::Capture::RFPixelType RFPixelType; - typedef cli::array< RFPixelType, 2 > RFArrayType; - - NewRFImageHandler( RFArrayType ^managedRFBuffer ): - NewRFImageCallback( NULL ), - NewRFImageCallbackClientData( NULL ), - NativeRFBuffer( new RFPixelType[ScanConverter::MAX_RFSAMPLES - * ScanConverter::MAX_RFSAMPLES] ), - ManagedRFBuffer( managedRFBuffer ) - { - } - - ~NewRFImageHandler() - { - delete [] NativeRFBuffer; - } - - void HandleNewRFImage( IntersonArray::Imaging::Capture ^scan2D, - System::EventArgs ^eventArgs ) - { - if ( this->NewRFImageCallback != NULL ) - { - for ( int ii = 0; ii < ScanConverter::MAX_RFSAMPLES; ++ii ) - { - for ( int jj = 0; jj < ScanConverter::MAX_RFSAMPLES; ++jj ) - { - this->NativeRFBuffer[ScanConverter::MAX_RFSAMPLES * ii + jj] = - this->ManagedRFBuffer[ii, jj]; - } - } - this->NewRFImageCallback( this->NativeRFBuffer, - this->NewRFImageCallbackClientData ); - } - } - - void SetNewRFImageCallback( NewRFImageCallbackType callback, - void *clientData ) - { - this->NewRFImageCallback = callback; - this->NewRFImageCallbackClientData = clientData; - } - -private: - NewRFImageCallbackType NewRFImageCallback; - void * NewRFImageCallbackClientData; - RFPixelType * NativeRFBuffer; - RFArrayType ^ ManagedRFBuffer; -}; - - -ref class NewImageHandler -{ -public: - typedef Capture::NewImageCallbackType NewImageCallbackType; - - typedef IntersonArrayCxx::Imaging::Capture::PixelType PixelType; - typedef cli::array< byte, 2 > ArrayType; - - NewImageHandler( ArrayType ^managedBuffer ): - NewImageCallback( NULL ), - NewImageCallbackClientData( NULL ), - NativeBuffer( new PixelType[ScanConverter::MAX_SAMPLES * - ScanConverter::MAX_SAMPLES] ), - ManagedBuffer( managedBuffer ) - { - } - - ~NewImageHandler() - { - delete [] NativeBuffer; - } - - void HandleNewImage( IntersonArray::Imaging::Capture ^scan2D, - System::EventArgs ^eventArgs ) - { - if ( this->NewImageCallback != NULL ) - { - for ( int ii = 0; ii < ScanConverter::MAX_RFSAMPLES; ++ii ) - { - for ( int jj = 0; jj < ScanConverter::MAX_RFSAMPLES; ++jj ) - { - this->NativeBuffer[ScanConverter::MAX_RFSAMPLES * ii + jj] = - this->ManagedBuffer[ii, jj]; - } - } - this->NewImageCallback( this->NativeBuffer, - this->NewImageCallbackClientData ); - } - } - - void SetNewImageCallback( NewImageCallbackType callback, - void *clientData ) - { - this->NewImageCallback = callback; - this->NewImageCallbackClientData = clientData; - } - -private: - NewImageCallbackType NewImageCallback; - void * NewImageCallbackClientData; - PixelType * NativeBuffer; - ArrayType ^ ManagedBuffer; -}; - - -class CaptureImpl -{ -public: - typedef cli::array< Capture::PixelType, 2 > ArrayType; - typedef cli::array< Capture::RFPixelType, 2 > RFArrayType; - - typedef Capture::NewImageCallbackType NewImageCallbackType; - typedef Capture::NewRFImageCallbackType NewRFImageCallbackType; - - CaptureImpl() - { - Wrapped = gcnew IntersonArray::Imaging::Capture(); - - Buffer = gcnew ArrayType( ScanConverter::MAX_SAMPLES, - ScanConverter::MAX_SAMPLES ); - Handler = gcnew NewImageHandler( Buffer ); - HandlerDelegate = gcnew - IntersonArray::Imaging::Capture::NewImageHandler( Handler, - & NewImageHandler::HandleNewImage ); - Wrapped->NewImageTick += HandlerDelegate; - - RFBuffer = gcnew RFArrayType( ScanConverter::MAX_RFSAMPLES, - ScanConverter::MAX_RFSAMPLES ); - RFHandler = gcnew NewRFImageHandler( RFBuffer ); - RFHandlerDelegate = gcnew - IntersonArray::Imaging::Capture::NewImageHandler( RFHandler, - & NewRFImageHandler::HandleNewRFImage ); - Wrapped->NewImageTick += RFHandlerDelegate; - - } - - ~CaptureImpl() - { - Wrapped->NewImageTick -= RFHandlerDelegate; - Wrapped->NewImageTick -= HandlerDelegate; - } - - bool GetFrameAvg() - { - return Wrapped->FrameAvg; - } - - void SetFrameAvg( bool value) - { - Wrapped->FrameAvg = value; - } - - bool GetRFData() - { - return Wrapped->RFData; - } - - void SetRFData( bool value ) - { - Wrapped->RFData = value; - } - - double GetScanOn() - { - return Wrapped->ScanOn; - } - - void AbortScan() - { - Wrapped->AbortScan(); - } - - void DisposeScan() - { - Wrapped->DisposeScan(); - } - - void StartReadScan() - { - Wrapped->StartReadScan( (ArrayType ^)Buffer ); - } - - void StartRFReadScan() - { - Wrapped->StartRFReadScan( (RFArrayType ^)RFBuffer ); - } - - void StopReadScan() - { - Wrapped->StopReadScan(); - } - - void SetNewImageCallback( NewImageCallbackType callback, - void *clientData = 0 ) - { - this->Handler->SetNewImageCallback( callback, clientData ); - } - - void SetNewRFImageCallback( NewRFImageCallbackType callback, - void *clientData = 0 ) - { - this->RFHandler->SetNewRFImageCallback( callback, clientData ); - } - - -private: - gcroot< IntersonArray::Imaging::Capture ^ > Wrapped; - - gcroot< ArrayType ^ > Buffer; - gcroot< RFArrayType ^ > RFBuffer; - gcroot< NewImageHandler ^ > Handler; - gcroot< NewRFImageHandler ^ > RFHandler; - - gcroot< IntersonArray::Imaging::Capture::NewImageHandler ^ > - HandlerDelegate; - gcroot< IntersonArray::Imaging::Capture::NewImageHandler ^ > - RFHandlerDelegate; - -}; - -#pragma unmanaged - -Capture -::Capture(): - Impl( new CaptureImpl() ) -{ -} - - -Capture -::~Capture() -{ - delete Impl; -} - - -bool -Capture -::GetRFData() -{ - return Impl->GetRFData(); -} - - -void -Capture -::SetRFData( bool transferOn ) -{ - Impl->SetRFData( transferOn ); -} - - -bool -Capture -::GetFrameAvg() -{ - return Impl->GetFrameAvg(); -} - -void -Capture -::SetFrameAvg( bool doAveraging ) -{ - Impl->SetFrameAvg( doAveraging ); -} - - -bool -Capture -::GetScanOn() const -{ - return Impl->GetScanOn(); -} - - -void -Capture -::AbortScan() -{ - Impl->AbortScan(); -} - - -void -Capture -::DisposeScan() -{ - Impl->DisposeScan(); -} - - -void -Capture -::StartReadScan() -{ - Impl->StartReadScan(); -} - - -void -Capture -::StartRFReadScan() -{ - Impl->StartRFReadScan(); -} - - -void -Capture -::StopReadScan() -{ - Impl->StopReadScan(); -} - - -void -Capture -::SetNewImageCallback( NewImageCallbackType callback, - void *clientData ) -{ - Impl->SetNewImageCallback( callback, clientData ); -} - - -void -Capture -::SetNewRFImageCallback( NewRFImageCallbackType callback, - void *clientData ) -{ - Impl->SetNewRFImageCallback( callback, clientData ); -} - - -} // end namespace Imaging - -} // end namespace IntersonArrayCxx diff --git a/src/IntersonArrayCxxImagingImageBuilding.cxx b/src/IntersonArrayCxxImagingImageBuilding.cxx deleted file mode 100644 index 904660c..0000000 --- a/src/IntersonArrayCxxImagingImageBuilding.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/*========================================================================= - -Library: IntersonArray - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#pragma unmanaged -#include "IntersonArrayCxxImagingImageBuilding.h" -#include -#pragma managed - -#include -#include - -#using "System.Drawing.dll" - -#using "IntersonArray.dll" - -namespace IntersonArrayCxx -{ - -namespace Imaging -{ - -class ImageBuildingImpl -{ -public: - ImageBuildingImpl() - { - Wrapped = gcnew IntersonArray::Imaging::ImageBuilding(); - } - - ~ImageBuildingImpl() - { - } - - void Build2D( unsigned char * bmpDest, unsigned char * byteRaw, - ScanConverter & scanConverter ) - { - std::cerr << "ERROR: Call to ImageBuilding.Build2D - not implemented" - << std::endl; - //Wrapped->Build2D( bmpDest, byteRaw, scanConverter ); - } - - void Build2D( unsigned char * bmpDest, unsigned char * byteRawCurrent, - unsigned char * byteRawPrevious, ScanConverter & scanConverter ) - { - std::cerr << "ERROR: Call to ImageBuilding.Build2D.2 - not implemented" - << std::endl; - //Wrapped->Build2D( bmpDest, byteRawCurrent, byteRawPrevious, - //scanConverter ); - } - -private: - gcroot< IntersonArray::Imaging::ImageBuilding ^ > Wrapped; - -}; - - -#pragma unmanaged - -ImageBuilding -::ImageBuilding(): - Impl( new ImageBuildingImpl() ) -{ -} - - -ImageBuilding -::~ImageBuilding() -{ - delete Impl; -} - - -void -ImageBuilding -::Build2D( unsigned char * bmpDest, unsigned char * byteRaw, - ScanConverter & scanConverter ) -{ - return Impl->Build2D( bmpDest, byteRaw, scanConverter ); -} - -void -ImageBuilding -::Build2D( unsigned char * bmpDest, unsigned char * byteRawCurrent, - unsigned char * byteRawPrevious, ScanConverter & scanConverter ) -{ - return Impl->Build2D( bmpDest, byteRawCurrent, byteRawPrevious, - scanConverter ); -} - -} // end namespace Imaging - -} // end namespace IntersonArrayCxx diff --git a/src/IntersonArrayCxxImagingScanConverter.cxx b/src/IntersonArrayCxxImagingScanConverter.cxx deleted file mode 100644 index e18bbd2..0000000 --- a/src/IntersonArrayCxxImagingScanConverter.cxx +++ /dev/null @@ -1,245 +0,0 @@ -/*========================================================================= - -Library: IntersonArray - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#pragma unmanaged -#include "IntersonArrayCxxImagingScanConverter.h" -#pragma managed - -#include -#include -#include - -#using "IntersonArray.dll" - -namespace IntersonArrayCxx -{ - -namespace Imaging -{ - -class ScanConverterImpl -{ -public: - ScanConverterImpl() - { - Wrapped = gcnew IntersonArray::Imaging::ScanConverter(); - } - - ~ScanConverterImpl() - { - } - - bool GetCompound() - { - return Wrapped->Compound; - } - - void SetCompound( bool value ) - { - Wrapped->Compound = value; - } - - bool GetDoubler() - { - return Wrapped->Doubler; - } - - void SetDoubler( bool value ) - { - Wrapped->Doubler = value; - } - - int GetHeightScan() const - { - return Wrapped->HeightScan; - } - - float GetMmPerPixel() const - { - return Wrapped->MmPerPixel; - } - - double GetTrueDepth() const - { - return Wrapped->TrueDepth; - } - - int GetWidthScan() const - { - return Wrapped->WidthScan; - } - - int GetZeroOfYScale() const - { - return Wrapped->ZeroOfYScale; - } - - ScanConverter::ScanConverterError HardInitScanConverter( int depth, - int widthScan, int heightScan, int steering, Capture & capture, - ImageBuilding & imageBuilding ) - { - msclr::auto_gcroot< IntersonArray::Imaging::Capture ^ > - captureWrapped; - captureWrapped = gcnew IntersonArray::Imaging::Capture(); - captureWrapped->RFData = capture.GetRFData(); - captureWrapped->FrameAvg = capture.GetFrameAvg(); - - msclr::auto_gcroot< IntersonArray::Imaging::ImageBuilding ^ > - imageWrapped; - imageWrapped = gcnew IntersonArray::Imaging::ImageBuilding(); - return static_cast< ScanConverter::ScanConverterError >( Wrapped-> - HardInitScanConverter( depth, widthScan, heightScan, steering, - captureWrapped.get(), imageWrapped.get() ) ); - } - - ScanConverter::ScanConverterError IdleInitScanConverter( int depth, - int widthScan, int heightScan, short idleId, int idleSteering, - bool idleDoubler, bool idleCompound, int idleCompoundAngle, - ImageBuilding & imageBuilding ) - { - msclr::auto_gcroot< IntersonArray::Imaging::ImageBuilding ^ > - imageWrapped; - imageWrapped = gcnew IntersonArray::Imaging::ImageBuilding(); - return static_cast< ScanConverter::ScanConverterError >( Wrapped-> - IdleInitScanConverter( depth, widthScan, heightScan, idleId, - idleSteering, idleDoubler, idleCompound, idleCompoundAngle, - imageWrapped.get() ) ); - } - -private: - gcroot< IntersonArray::Imaging::ScanConverter ^ > - Wrapped; -}; - - -#pragma unmanaged - -ScanConverter -::ScanConverter(): - Impl( new ScanConverterImpl() ) -{ -} - - -ScanConverter -::~ScanConverter() -{ - delete Impl; -} - - -bool -ScanConverter -::GetCompound() -{ - return Impl->GetCompound(); -} - - -void -ScanConverter -::SetCompound( bool value ) -{ - Impl->SetCompound( value ); -} - - -bool -ScanConverter -::GetDoubler() -{ - return Impl->GetDoubler(); -} - - -void -ScanConverter -::SetDoubler( bool value ) -{ - Impl->SetDoubler( value ); -} - - -int -ScanConverter -::GetHeightScan() const -{ - return Impl->GetHeightScan(); -} - - -float -ScanConverter -::GetMmPerPixel() const -{ - return Impl->GetMmPerPixel(); -} - - -double -ScanConverter -::GetTrueDepth() const -{ - return Impl->GetMmPerPixel(); -} - - -int -ScanConverter -::GetWidthScan() const -{ - return Impl->GetWidthScan(); -} - - -int -ScanConverter -::GetZeroOfYScale() const -{ - return Impl->GetZeroOfYScale(); -} - - -ScanConverter::ScanConverterError -ScanConverter -::HardInitScanConverter( int depth, int widthScan, int heightScan, - int steering, Capture & capture, ImageBuilding & imageBuilding ) -{ - return Impl->HardInitScanConverter( depth, widthScan, heightScan, - steering, capture, imageBuilding ); -} - - -ScanConverter::ScanConverterError -ScanConverter -::IdleInitScanConverter( int depth, int width, int height, short idleId, - int idleSteering, bool idleDoubler, bool idleCompound, - int idleCompoundAngle, ImageBuilding & imageBuilding ) -{ - return Impl->IdleInitScanConverter( depth, width, height, idleId, - idleSteering, idleDoubler, idleCompound, idleCompoundAngle, - imageBuilding ); -} - -} // end namespace Imaging - -} // end namespace IntersonArrayCxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 46e0820..99db988 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,8 +24,6 @@ set( _tests IntersonArrayCxxIntersonClassTest IntersonArrayCxxControlsHWControlsTest IntersonArrayCxxImagingContainerTest - IntersonArrayCxxImagingCaptureTest - IntersonArrayCxxImagingScanConverterTest ) foreach( test ${_tests} ) diff --git a/test/IntersonArrayCxxImagingCaptureTest.cxx b/test/IntersonArrayCxxImagingCaptureTest.cxx deleted file mode 100644 index d1b5be5..0000000 --- a/test/IntersonArrayCxxImagingCaptureTest.cxx +++ /dev/null @@ -1,91 +0,0 @@ -/*========================================================================= - -Library: IntersonArray - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#include "IntersonArrayCxxImagingCapture.h" -#include "IntersonArrayCxxImagingScanConverter.h" -#include "IntersonArrayCxxControlsHWControls.h" - -#include -#include -#include - -#include // Sleep - -int main( int argc, char * argv[] ) -{ - typedef IntersonArrayCxx::Controls::HWControls HWControlsType; - HWControlsType hwControls; - - typedef IntersonArrayCxx::Imaging::Capture CaptureType; - CaptureType capture; - - typedef IntersonArrayCxx::Imaging::ScanConverter ScanConverterType; - ScanConverterType scanConverter; - - - typedef HWControlsType::FoundProbesType FoundProbesType; - FoundProbesType foundProbes; - hwControls.FindAllProbes( foundProbes ); - if( foundProbes.empty() ) - { - std::cerr << "Could not find the probe." << std::endl; - return EXIT_FAILURE; - } - - hwControls.FindMyProbe( 0 ); - const unsigned int probeId = hwControls.GetProbeID(); - std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; - if( probeId == 0 ) - { - std::cerr << "Could not find the probe." << std::endl; - return EXIT_FAILURE; - } - - std::cout << "\nScan is on: " << capture.GetScanOn() << std::endl; - std::cout << "RF Data transfer is on: " << capture.GetRFData() - << std::endl; - - int ret = EXIT_SUCCESS; - - const int maxVectors = 512; //ScanConverterType::MAX_VECTORS; - const int maxSamples = ScanConverterType::MAX_SAMPLES; - const int maxPixels = maxVectors * maxSamples; - - capture.SetFrameAvg( true ); - std::cout << "\nFrameAvg: " << capture.GetFrameAvg() << std::endl; - - capture.AbortScan(); - std::cout << "\nStarting BMode scanning..." << std::endl; - capture.StartReadScan(); - Sleep( 100 ); // "time to start" - hwControls.StartBmode(); - std::cout << "\nScan is on: " << capture.GetScanOn() << std::endl; - - std::cout << "\nTrueDepth: " << scanConverter.GetTrueDepth() << std::endl; - - hwControls.StopAcquisition(); - capture.StopReadScan(); - Sleep( 100 ); // "time to stop" - capture.DisposeScan(); - - return ret; -} diff --git a/test/IntersonArrayCxxImagingScanConverterTest.cxx b/test/IntersonArrayCxxImagingScanConverterTest.cxx deleted file mode 100644 index 6cc9dfd..0000000 --- a/test/IntersonArrayCxxImagingScanConverterTest.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/*========================================================================= - -Library: IntersonArrayArray - -Copyright Kitware Inc. 28 Corporate Drive, -Clifton Park, NY, 12065, USA. - -All rights reserved. - -Licensed under the Apache License, Version 2.0 ( the "License" ); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -=========================================================================*/ -#include "IntersonArrayCxxImagingCapture.h" -#include "IntersonArrayCxxControlsHWControls.h" -#include "IntersonArrayCxxImagingScanConverter.h" -#include "IntersonArrayCxxImagingImageBuilding.h" - -#include -#include -#include - -#include // Sleep - -int main( int argc, char * argv[] ) -{ - typedef IntersonArrayCxx::Controls::HWControls HWControlsType; - HWControlsType hwControls; - - typedef IntersonArrayCxx::Imaging::Capture CaptureType; - CaptureType capture; - - typedef IntersonArrayCxx::Imaging::ImageBuilding ImageBuildingType; - ImageBuildingType imageBuilding; - - typedef IntersonArrayCxx::Imaging::ScanConverter ScanConverterType; - ScanConverterType scanConverter; - - typedef HWControlsType::FoundProbesType FoundProbesType; - FoundProbesType foundProbes; - hwControls.FindAllProbes( foundProbes ); - if( foundProbes.empty() ) - { - std::cerr << "Could not find the probe." << std::endl; - return EXIT_FAILURE; - } - - hwControls.FindMyProbe( 0 ); - const unsigned int probeId = hwControls.GetProbeID(); - std::cout << "ProbeID after FindMyProbe: " << probeId << std::endl; - if( probeId == 0 ) - { - std::cerr << "Could not find the probe." << std::endl; - return EXIT_FAILURE; - } - - const int depth = 50; - if( hwControls.ValidDepth( depth ) != depth ) - { - std::cerr << "Did not request a valid depth" << std::endl; - return EXIT_SUCCESS; - } - const int width = 776; - const int height = 512; - - int steering = 0; - ScanConverterType::ScanConverterError converterError = - scanConverter.IdleInitScanConverter( depth, width, height, probeId, - steering, false, false, 0, imageBuilding ); - if( converterError != ScanConverterType::SUCCESS ) - { - std::cerr << "Error during idle scan converter initialization: " - << converterError << std::endl; - return EXIT_FAILURE; - } - converterError = scanConverter.HardInitScanConverter( depth, width, - height, steering, capture, imageBuilding ); - if( converterError != ScanConverterType::SUCCESS ) - { - std::cerr << "Error during hard scan converter initialization: " - << converterError << std::endl; - return EXIT_FAILURE; - } - - capture.AbortScan(); - std::cout << "\nStarting BMode scanning..." << std::endl; - capture.StartReadScan(); - Sleep( 100 ); // "time to start" - hwControls.StartBmode(); - - std::cout << "\nScan is on: " << capture.GetScanOn() << std::endl; - std::cout << "\nTrueDepth: " << scanConverter.GetTrueDepth() << std::endl; - std::cout << "\nHeightScan: " << scanConverter.GetHeightScan() << std::endl; - std::cout << "WidthScan: " << scanConverter.GetWidthScan() << std::endl; - std::cout << "\nMmPerPixel: " << scanConverter.GetMmPerPixel() << std::endl; - std::cout << "\nZeroOfYScale: " << scanConverter.GetZeroOfYScale() << std::endl; - - hwControls.StopAcquisition(); - capture.StopReadScan(); - Sleep( 100 ); // "time to stop" - capture.DisposeScan(); - - return EXIT_SUCCESS; -} From 865cdc88c15514d88bfa944db16f47d1add6d477 Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Mon, 13 Mar 2017 15:57:58 -0400 Subject: [PATCH 067/103] COMP: Clean up code - order of calls, etc simplified. RF scanning still does not work. --- app/AcquireIntersonArrayBMode.cxx | 92 +++++++++++----------- app/AcquireIntersonArrayRF.cxx | 97 +++++++++++++----------- app/AcquireIntersonArrayRF.xml | 2 +- src/IntersonArrayCxxImagingContainer.cxx | 41 ++++++++-- 4 files changed, 132 insertions(+), 100 deletions(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index 8b70956..b8ca100 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -77,8 +77,7 @@ int main( int argc, char * argv[] ) typedef IntersonArrayCxx::Controls::HWControls HWControlsType; HWControlsType hwControls; - ContainerType container; - + const int steering = 0; typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); @@ -95,18 +94,44 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - const int width = hwControls.GetLinesPerArray(); - const int height = container.MAX_SAMPLES; - const int scanWidth = container.GetWidthScan(); - const int scanHeight = container.GetHeightScan(); - std::cout << "Width = " << width << std::endl; - std::cout << "Height = " << height << std::endl; - std::cout << "ScanWidth = " << scanWidth << std::endl; - std::cout << "ScanHeight = " << scanHeight << std::endl; - std::cout << "MM per Pixel = " << container.GetMmPerPixel() << std::endl; - const int steering = 0; + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency( frequencies ); + if( !hwControls.SetFrequencyAndFocus( frequencyIndex, focusIndex, + steering ) ) + { + std::cerr << "Could not set the frequency." << std::endl; + return EXIT_FAILURE; + } + + if( !hwControls.SendHighVoltage( highVoltage, highVoltage ) ) + { + std::cerr << "Could not set the high voltage." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.EnableHighVoltage() ) + { + std::cerr << "Could not enable high voltage." << std::endl; + return EXIT_FAILURE; + } + + if( !hwControls.SendDynamic( gain ) ) + { + std::cerr << "Could not set dynamic gain." << std::endl; + } + + hwControls.DisableHardButton(); + + ContainerType container; + container.AbortScan(); + container.SetRFData( false ); + + const int height = hwControls.GetLinesPerArray(); + const int width = 512; //container.MAX_SAMPLES; if( hwControls.ValidDepth( depth ) == depth ) { + ContainerType::ScanConverterError converterErrorIdle = + container.IdleInitScanConverter( depth, width, height, probeId, + steering, false, false, 0 ); ContainerType::ScanConverterError converterError = container.HardInitScanConverter( depth, width, height, steering ); if( converterError != ContainerType::SUCCESS ) @@ -121,10 +146,15 @@ int main( int argc, char * argv[] ) std::cerr << "Invalid requested depth for probe." << std::endl; } + const int scanWidth = container.GetWidthScan(); + const int scanHeight = container.GetHeightScan(); + std::cout << "Width = " << width << std::endl; + std::cout << "Height = " << height << std::endl; + std::cout << "ScanWidth = " << scanWidth << std::endl; + std::cout << "ScanHeight = " << scanHeight << std::endl; + std::cout << "MM per Pixel = " << container.GetMmPerPixel() << std::endl; const itk::SizeValueType framesToCollect = frames; - const int maxVectors = hwControls.GetLinesPerArray(); - const int maxSamples = ContainerType::MAX_SAMPLES; ImageType::Pointer image = ImageType::New(); typedef ImageType::RegionType RegionType; @@ -133,8 +163,8 @@ int main( int argc, char * argv[] ) imageIndex.Fill( 0 ); imageRegion.SetIndex( imageIndex ); ImageType::SizeType imageSize; - imageSize[0] = maxSamples; - imageSize[1] = maxVectors; + imageSize[0] = width; + imageSize[1] = height; imageSize[2] = framesToCollect; imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); @@ -145,36 +175,6 @@ int main( int argc, char * argv[] ) clientData.FrameIndex = 0; container.SetNewImageCallback( &pasteIntoImage, &clientData ); - - HWControlsType::FrequenciesType frequencies; - hwControls.GetFrequency( frequencies ); - if( !hwControls.SetFrequencyAndFocus( frequencyIndex, focusIndex, - steering ) ) - { - std::cerr << "Could not set the frequency." << std::endl; - return EXIT_FAILURE; - } - - if( !hwControls.SendHighVoltage( highVoltage, highVoltage ) ) - { - std::cerr << "Could not set the high voltage." << std::endl; - return EXIT_FAILURE; - } - if( !hwControls.EnableHighVoltage() ) - { - std::cerr << "Could not enable high voltage." << std::endl; - return EXIT_FAILURE; - } - - if( !hwControls.SendDynamic( gain ) ) - { - std::cerr << "Could not set dynamic gain." << std::endl; - } - - hwControls.DisableHardButton(); - - container.AbortScan(); - container.SetRFData( false ); container.StartReadScan(); Sleep( 100 ); // "time to start" if( !hwControls.StartBmode() ) diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 38ce611..9e545df 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -77,8 +77,9 @@ int main( int argc, char * argv[] ) typedef IntersonArrayCxx::Controls::HWControls HWControlsType; IntersonArrayCxx::Controls::HWControls hwControls; - ContainerType container; + int ret = EXIT_SUCCESS; + int steering = 0; typedef HWControlsType::FoundProbesType FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); @@ -95,31 +96,43 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - int ret = EXIT_SUCCESS; - - int steering = 0; + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency( frequencies ); + if( !hwControls.SetFrequencyAndFocus( frequencyIndex, focusIndex, + steering ) ) + { + std::cerr << "Could not set the frequency and focus." << std::endl; + return EXIT_FAILURE; + } - const int width = hwControls.GetLinesPerArray(); - const int height = ContainerType::MAX_RFSAMPLES; - if( hwControls.ValidDepth( depth ) == depth ) + if( !hwControls.SendHighVoltage( highVoltage, highVoltage ) ) { - ContainerType::ScanConverterError converterError = - container.HardInitScanConverter( depth, width, height, steering ); - if( converterError != ContainerType::SUCCESS ) - { - std::cerr << "Error during hard scan converter initialization: " - << converterError << std::endl; - return EXIT_FAILURE; - } + std::cerr << "Could not set the high voltage." << std::endl; + return EXIT_FAILURE; } - else + if( !hwControls.EnableHighVoltage() ) { - std::cerr << "Invalid requested depth for probe." << std::endl; + std::cerr << "Could not enable high voltage." << std::endl; + return EXIT_FAILURE; } + hwControls.DisableHardButton(); + + ContainerType container; + + const int height = hwControls.GetLinesPerArray(); + const int width = ContainerType::MAX_RFSAMPLES; const itk::SizeValueType framesToCollect = frames; - const int maxVectors = hwControls.GetLinesPerArray(); - const int maxSamples = ContainerType::MAX_RFSAMPLES; + + container.AbortScan(); + container.SetRFData( true ); + + if( hwControls.ValidDepth( depth ) != depth ) + { + container.IdleInitScanConverter( depth, width, height, probeId, + steering, false, false, 0 ); + container.HardInitScanConverter( depth, width, height, steering ); + } ImageType::Pointer image = ImageType::New(); typedef ImageType::RegionType RegionType; @@ -128,8 +141,8 @@ int main( int argc, char * argv[] ) imageIndex.Fill( 0 ); imageRegion.SetIndex( imageIndex ); ImageType::SizeType imageSize; - imageSize[0] = maxSamples; - imageSize[1] = maxVectors; + imageSize[0] = width; + imageSize[1] = height; imageSize[2] = framesToCollect; imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); @@ -139,32 +152,12 @@ int main( int argc, char * argv[] ) clientData.Image = image.GetPointer(); clientData.FrameIndex = 0; - HWControlsType::FrequenciesType frequencies; - hwControls.GetFrequency( frequencies ); - if( !hwControls.SetFrequencyAndFocus( frequencyIndex, focusIndex, - steering ) ) - { - std::cerr << "Could not set the frequency and focus." << std::endl; - return EXIT_FAILURE; - } - - if( !hwControls.SendHighVoltage( highVoltage, highVoltage ) ) - { - std::cerr << "Could not set the high voltage." << std::endl; - return EXIT_FAILURE; - } - if( !hwControls.EnableHighVoltage() ) - { - std::cerr << "Could not enable high voltage." << std::endl; - return EXIT_FAILURE; - } - - hwControls.DisableHardButton(); + container.SetNewRFImageCallback( &pasteIntoImage, &clientData ); + /* Begin theoretically unnecessary yet definitely necessary lines...*/ std::cout << "Acquire 1 bmode image" << std::endl; - container.AbortScan(); - container.SetRFData( false ); container.StartReadScan(); + Sleep( 100 ); if( !hwControls.StartBmode() ) { std::cerr << "Could not start RF collection." << std::endl; @@ -179,11 +172,23 @@ int main( int argc, char * argv[] ) container.StopReadScan(); Sleep( 100 ); // "time to stop" container.DisposeScan(); - - container.SetNewRFImageCallback( &pasteIntoImage, &clientData ); + Sleep( 100 ); // "time to stop" std::cout << "SetRFData" << std::endl; container.SetRFData( true ); + + // Sequent to init a scan, after above variables are set + std::cout << "HardInitScanConverter" << std::endl; + ContainerType::ScanConverterError converterError = + container.HardInitScanConverter( depth, width, height, steering ); + if( converterError != ContainerType::SUCCESS ) + { + std::cerr << "Error during hard scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } + /* ...end necessary lines. */ + std::cout << "StartRFReadScan" << std::endl; container.StartRFReadScan(); Sleep( 100 ); // "time to start" diff --git a/app/AcquireIntersonArrayRF.xml b/app/AcquireIntersonArrayRF.xml index 67f36a2..9909874 100644 --- a/app/AcquireIntersonArrayRF.xml +++ b/app/AcquireIntersonArrayRF.xml @@ -55,7 +55,7 @@ Depth of acquisition [mm]. Only relevant with scanConvert. depth d - 40 + 100 0 200 diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index c43e2ba..1b0d0d3 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -52,6 +52,8 @@ ref class NewRFImageHandler NewRFImageHandler( RFArrayType ^managedRFBuffer ): NewRFImageCallback( NULL ), NewRFImageCallbackClientData( NULL ), + bufferWidth( Container::MAX_RFSAMPLES ), + bufferHeight( Container::MAX_RFSAMPLES ), NativeRFBuffer( new RFPixelType[Container::MAX_RFSAMPLES * Container::MAX_RFSAMPLES] ), ManagedRFBuffer( managedRFBuffer ) @@ -68,11 +70,11 @@ ref class NewRFImageHandler { if ( this->NewRFImageCallback != NULL ) { - for ( int ii = 0; ii < Container::MAX_RFSAMPLES; ++ii ) + for ( int ii = 0; ii < bufferHeight; ++ii ) { - for ( int jj = 0; jj < Container::MAX_RFSAMPLES; ++jj ) + for ( int jj = 0; jj < bufferWidth; ++jj ) { - this->NativeRFBuffer[Container::MAX_RFSAMPLES * ii + jj] = + this->NativeRFBuffer[bufferWidth * ii + jj] = this->ManagedRFBuffer[ii, jj]; } } @@ -81,6 +83,12 @@ ref class NewRFImageHandler } } + void SetImageSize( int width, int height ) + { + bufferWidth = width; + bufferHeight = height; + } + void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) { @@ -93,6 +101,8 @@ ref class NewRFImageHandler void * NewRFImageCallbackClientData; RFPixelType * NativeRFBuffer; RFArrayType ^ ManagedRFBuffer; + int bufferWidth; + int bufferHeight; }; @@ -107,6 +117,8 @@ ref class NewImageHandler NewImageHandler( ArrayType ^managedBuffer ): NewImageCallback( NULL ), NewImageCallbackClientData( NULL ), + bufferWidth( Container::MAX_SAMPLES ), + bufferHeight( Container::MAX_SAMPLES ), NativeBuffer( new PixelType[Container::MAX_SAMPLES * Container::MAX_SAMPLES] ), ManagedBuffer( managedBuffer ) @@ -123,11 +135,11 @@ ref class NewImageHandler { if ( this->NewImageCallback != NULL ) { - for ( int ii = 0; ii < Container::MAX_SAMPLES; ++ii ) + for ( int ii = 0; ii < bufferHeight; ++ii ) { - for ( int jj = 0; jj < Container::MAX_SAMPLES; ++jj ) + for ( int jj = 0; jj < bufferWidth; ++jj ) { - this->NativeBuffer[Container::MAX_SAMPLES * ii + jj] = + this->NativeBuffer[bufferWidth * ii + jj] = this->ManagedBuffer[ii, jj]; } } @@ -136,6 +148,12 @@ ref class NewImageHandler } } + void SetImageSize( int width, int height ) + { + bufferWidth = width; + bufferHeight = height; + } + void SetNewImageCallback( NewImageCallbackType callback, void *clientData ) { @@ -148,6 +166,8 @@ ref class NewImageHandler void * NewImageCallbackClientData; PixelType * NativeBuffer; ArrayType ^ ManagedBuffer; + int bufferWidth; + int bufferHeight; }; // End Capture @@ -182,7 +202,6 @@ class ContainerImpl IntersonArray::Imaging::Capture::NewImageHandler( RFHandler, & NewRFImageHandler::HandleNewRFImage ); WrappedCapture->NewImageTick += RFHandlerDelegate; - } ~ContainerImpl() @@ -312,12 +331,20 @@ class ContainerImpl void *clientData = 0 ) { this->Handler->SetNewImageCallback( callback, clientData ); + std::cout << "Callback width = " << this->GetWidthScan() << std::endl; + std::cout << " heidth = " << this->GetHeightScan() << std::endl; + this->Handler->SetImageSize( this->GetWidthScan(), + this->GetHeightScan() ); } void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = 0 ) { this->RFHandler->SetNewRFImageCallback( callback, clientData ); + std::cout << "Callback width = " << this->GetWidthScan() << std::endl; + std::cout << " heidth = " << this->GetHeightScan() << std::endl; + this->RFHandler->SetImageSize( this->GetWidthScan(), + this->GetHeightScan() ); } // From 4b1918e3a656d9764a76ce4a3ee89679c86d5ef9 Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Mon, 13 Mar 2017 16:01:44 -0400 Subject: [PATCH 068/103] STYLE: Fix spelling mistake in output --- src/IntersonArrayCxxImagingContainer.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 1b0d0d3..6aca50d 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -332,7 +332,7 @@ class ContainerImpl { this->Handler->SetNewImageCallback( callback, clientData ); std::cout << "Callback width = " << this->GetWidthScan() << std::endl; - std::cout << " heidth = " << this->GetHeightScan() << std::endl; + std::cout << " height = " << this->GetHeightScan() << std::endl; this->Handler->SetImageSize( this->GetWidthScan(), this->GetHeightScan() ); } @@ -342,7 +342,7 @@ class ContainerImpl { this->RFHandler->SetNewRFImageCallback( callback, clientData ); std::cout << "Callback width = " << this->GetWidthScan() << std::endl; - std::cout << " heidth = " << this->GetHeightScan() << std::endl; + std::cout << " height = " << this->GetHeightScan() << std::endl; this->RFHandler->SetImageSize( this->GetWidthScan(), this->GetHeightScan() ); } From 733830d7908e6fd2c72e41d378c9145e4c919408 Mon Sep 17 00:00:00 2001 From: Sam Horvath Date: Fri, 24 Mar 2017 12:48:31 -0400 Subject: [PATCH 069/103] BUG: RF data was not enabled ReadFPGAVersion() must be successfully called in order to enable RF mode. Also contains fixes for handlers and RF buffer allocation --- app/AcquireIntersonArrayRF.cxx | 66 +++++----------------- include/IntersonArrayCxxImagingContainer.h | 8 ++- src/IntersonArrayCxxImagingContainer.cxx | 48 +++++++++++----- 3 files changed, 54 insertions(+), 68 deletions(-) diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 9e545df..c052ed6 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -32,7 +32,7 @@ limitations under the License. typedef IntersonArrayCxx::Imaging::Container ContainerType; const unsigned int Dimension = 3; -typedef ContainerType::RFPixelType PixelType; +typedef ContainerType::RFImagePixelType PixelType; typedef itk::Image< PixelType, Dimension > ImageType; @@ -59,13 +59,13 @@ void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) } const int framePixels = imageSize[0] * imageSize[1]; - std::cout << "frame pixels = " << framePixels << std::endl; + std::cout << "frame pixels RF = " << framePixels << std::endl; PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); imageBuffer += framePixels * callbackClientData->FrameIndex; std::memcpy( imageBuffer, buffer, framePixels * sizeof( PixelType ) ); - std::cout << "Acquired frame: " << callbackClientData->FrameIndex + std::cout << "Acquired frame RF: " << callbackClientData->FrameIndex << std::endl; ++(callbackClientData->FrameIndex); } @@ -119,20 +119,20 @@ int main( int argc, char * argv[] ) hwControls.DisableHardButton(); ContainerType container; + container.SetHWControls(&hwControls); - const int height = hwControls.GetLinesPerArray(); - const int width = ContainerType::MAX_RFSAMPLES; + const int height_lines = hwControls.GetLinesPerArray(); + std::cout << "Lines per array: " << height_lines << std::endl; + const int width_samples = ContainerType::MAX_RFSAMPLES; + std::cout << "Max RF samples: " << width_samples << std::endl; const itk::SizeValueType framesToCollect = frames; container.AbortScan(); container.SetRFData( true ); - if( hwControls.ValidDepth( depth ) != depth ) - { - container.IdleInitScanConverter( depth, width, height, probeId, + container.IdleInitScanConverter( depth, width_samples, height_lines, probeId, steering, false, false, 0 ); - container.HardInitScanConverter( depth, width, height, steering ); - } + container.HardInitScanConverter( depth, width_samples, height_lines, steering ); ImageType::Pointer image = ImageType::New(); typedef ImageType::RegionType RegionType; @@ -141,8 +141,8 @@ int main( int argc, char * argv[] ) imageIndex.Fill( 0 ); imageRegion.SetIndex( imageIndex ); ImageType::SizeType imageSize; - imageSize[0] = width; - imageSize[1] = height; + imageSize[0] = width_samples; + imageSize[1] = height_lines; imageSize[2] = framesToCollect; imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); @@ -154,41 +154,6 @@ int main( int argc, char * argv[] ) container.SetNewRFImageCallback( &pasteIntoImage, &clientData ); - /* Begin theoretically unnecessary yet definitely necessary lines...*/ - std::cout << "Acquire 1 bmode image" << std::endl; - container.StartReadScan(); - Sleep( 100 ); - if( !hwControls.StartBmode() ) - { - std::cerr << "Could not start RF collection." << std::endl; - return EXIT_FAILURE; - } - Sleep( 100 ); - Sleep( 100 ); - Sleep( 100 ); - Sleep( 100 ); - std::cout << "StopAcquisition" << std::endl; - hwControls.StopAcquisition(); - container.StopReadScan(); - Sleep( 100 ); // "time to stop" - container.DisposeScan(); - Sleep( 100 ); // "time to stop" - - std::cout << "SetRFData" << std::endl; - container.SetRFData( true ); - - // Sequent to init a scan, after above variables are set - std::cout << "HardInitScanConverter" << std::endl; - ContainerType::ScanConverterError converterError = - container.HardInitScanConverter( depth, width, height, steering ); - if( converterError != ContainerType::SUCCESS ) - { - std::cerr << "Error during hard scan converter initialization: " - << converterError << std::endl; - return EXIT_FAILURE; - } - /* ...end necessary lines. */ - std::cout << "StartRFReadScan" << std::endl; container.StartRFReadScan(); Sleep( 100 ); // "time to start" @@ -199,14 +164,12 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - /* BUG: FrameIndex never changes, since callback - * never happens with RF data. */ int c = 0; - while( clientData.FrameIndex < framesToCollect && c < 100 ) + while( clientData.FrameIndex < framesToCollect && c < 10 ) { std::cout << clientData.FrameIndex << " of " << framesToCollect << std::endl; - std::cout << c << " of 100" << std::endl; + std::cout << c << " of 10" << std::endl; Sleep( 100 ); ++c; } @@ -221,6 +184,7 @@ int main( int argc, char * argv[] ) WriterType::Pointer writer = WriterType::New(); writer->SetFileName( outputImage ); writer->SetInput( image ); + try { writer->Update(); diff --git a/include/IntersonArrayCxxImagingContainer.h b/include/IntersonArrayCxxImagingContainer.h index 0f7d4e1..7e6d721 100644 --- a/include/IntersonArrayCxxImagingContainer.h +++ b/include/IntersonArrayCxxImagingContainer.h @@ -24,7 +24,7 @@ limitations under the License. #define _IntersonArrayCxxImagingContainer_h #include "IntersonArrayCxx_Export.h" - +#include "IntersonArrayCxxControlsHWControls.h" #include #include @@ -44,9 +44,11 @@ class IntersonArrayCxx_EXPORT Container typedef unsigned char PixelType; typedef unsigned short RFPixelType; + typedef short RFImagePixelType; static const int MAX_SAMPLES = 1024; static const int MAX_RFSAMPLES = 2048; + static const int NBOFLINES = 127; bool GetCompound(); @@ -113,11 +115,13 @@ class IntersonArrayCxx_EXPORT Container void SetNewImageCallback( NewImageCallbackType callback, void *clientData = NULL ); - typedef void (__stdcall *NewRFImageCallbackType)( RFPixelType *buffer, + typedef void (__stdcall *NewRFImageCallbackType)( RFImagePixelType *buffer, void *clientData ); void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = NULL ); + void SetHWControls(IntersonArrayCxx::Controls::HWControls * controls); + private: Container( const Container &); diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 6aca50d..5b4ab82 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -46,16 +46,17 @@ ref class NewRFImageHandler typedef Container::NewRFImageCallbackType NewRFImageCallbackType; - typedef IntersonArrayCxx::Imaging::Container::RFPixelType RFPixelType; - typedef cli::array< RFPixelType, 2 > RFArrayType; + typedef IntersonArrayCxx::Imaging::Container::RFPixelType RFPixelType; + typedef IntersonArrayCxx::Imaging::Container::RFImagePixelType RFImagePixelType; + typedef cli::array< RFPixelType, 2 > RFArrayType; NewRFImageHandler( RFArrayType ^managedRFBuffer ): NewRFImageCallback( NULL ), NewRFImageCallbackClientData( NULL ), bufferWidth( Container::MAX_RFSAMPLES ), bufferHeight( Container::MAX_RFSAMPLES ), - NativeRFBuffer( new RFPixelType[Container::MAX_RFSAMPLES - * Container::MAX_RFSAMPLES] ), + NativeRFBuffer(new RFImagePixelType[Container::MAX_RFSAMPLES + * Container::NBOFLINES] ), ManagedRFBuffer( managedRFBuffer ) { } @@ -74,7 +75,7 @@ ref class NewRFImageHandler { for ( int jj = 0; jj < bufferWidth; ++jj ) { - this->NativeRFBuffer[bufferWidth * ii + jj] = + this->NativeRFBuffer[bufferWidth * ii + jj] = (short) this->ManagedRFBuffer[ii, jj]; } } @@ -99,7 +100,7 @@ ref class NewRFImageHandler private: NewRFImageCallbackType NewRFImageCallback; void * NewRFImageCallbackClientData; - RFPixelType * NativeRFBuffer; + RFImagePixelType * NativeRFBuffer; RFArrayType ^ ManagedRFBuffer; int bufferWidth; int bufferHeight; @@ -195,13 +196,11 @@ class ContainerImpl & NewImageHandler::HandleNewImage ); WrappedCapture->NewImageTick += HandlerDelegate; - RFBuffer = gcnew RFArrayType( Container::MAX_RFSAMPLES, - Container::MAX_RFSAMPLES ); + RFBuffer = gcnew RFArrayType(Container::NBOFLINES , Container::MAX_RFSAMPLES); RFHandler = gcnew NewRFImageHandler( RFBuffer ); RFHandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( RFHandler, & NewRFImageHandler::HandleNewRFImage ); - WrappedCapture->NewImageTick += RFHandlerDelegate; } ~ContainerImpl() @@ -294,7 +293,19 @@ class ContainerImpl void SetRFData( bool value ) { + if (value){ + this->hwControls->ReadFPGAVersion(); + } WrappedCapture->RFData = value; + //Set correct image handler + if (value){ + WrappedCapture->NewImageTick -= HandlerDelegate; + WrappedCapture->NewImageTick += RFHandlerDelegate; + } + else{ + WrappedCapture->NewImageTick -= RFHandlerDelegate; + WrappedCapture->NewImageTick += HandlerDelegate; + } } double GetScanOn() @@ -331,8 +342,6 @@ class ContainerImpl void *clientData = 0 ) { this->Handler->SetNewImageCallback( callback, clientData ); - std::cout << "Callback width = " << this->GetWidthScan() << std::endl; - std::cout << " height = " << this->GetHeightScan() << std::endl; this->Handler->SetImageSize( this->GetWidthScan(), this->GetHeightScan() ); } @@ -341,10 +350,11 @@ class ContainerImpl void *clientData = 0 ) { this->RFHandler->SetNewRFImageCallback( callback, clientData ); - std::cout << "Callback width = " << this->GetWidthScan() << std::endl; - std::cout << " height = " << this->GetHeightScan() << std::endl; - this->RFHandler->SetImageSize( this->GetWidthScan(), - this->GetHeightScan() ); + this->RFHandler->SetImageSize(Container::MAX_RFSAMPLES, Container::NBOFLINES); + } + void SetHWControls(IntersonArrayCxx::Controls::HWControls * controls) + { + this->hwControls = controls; } // @@ -352,6 +362,7 @@ class ContainerImpl // private: + IntersonArrayCxx::Controls::HWControls * hwControls; msclr::auto_gcroot< IntersonArray::Imaging::ScanConverter ^ > WrappedScanConverter; msclr::auto_gcroot< IntersonArray::Imaging::ImageBuilding ^ > @@ -578,6 +589,13 @@ ::SetNewRFImageCallback( NewRFImageCallbackType callback, Impl->SetNewRFImageCallback( callback, clientData ); } +void +Container +::SetHWControls(IntersonArrayCxx::Controls::HWControls * controls) +{ + Impl->SetHWControls(controls); +} + } // end namespace Imaging } // end namespace IntersonArrayCxx From d755787a11cc90099213bd0bc8d549711c358282 Mon Sep 17 00:00:00 2001 From: Maeliss Jallais Date: Tue, 28 Mar 2017 14:46:57 -0400 Subject: [PATCH 070/103] COMP: Fix compilation error with /RTC1 --- src/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d9abbbb..2ae12c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,10 +20,10 @@ # limitations under the License. # ############################################################################## -#if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") - #string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") -#endif() -# +if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") + string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") +endif() + #if(CMAKE_CXX_FLAGS MATCHES "/EHsc") #string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") #endif() From 2788ee1499ab163c2d2f26ca6d515608494cd79f Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Fri, 14 Apr 2017 14:58:41 -0400 Subject: [PATCH 071/103] BUG: Wrong .h filename in install directive --- CMakeLists.txt | 10 +++------- include/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1aa6fb..4a193b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,14 +34,10 @@ if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/lib ) endif() -# Following removed because of use of duplicate variable -#set( CONF_INCLUDE_DIRS -# ${PROJECT_SOURCE_DIR}/include -# ${PROJECT_BINARY_DIR}/include ) -#include_directories( ${CONF_INCLUDE_DIRS} ) -include_directories( +set( CONF_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) +include_directories( ${CONF_INCLUDE_DIRS} ) set( INSTALL_LIB_DIR lib ) set( INSTALL_BIN_DIR bin ) @@ -92,7 +88,7 @@ configure_file( IntersonArraySDKCxxConfig.cmake.in "${PROJECT_BINARY_DIR}/IntersonArraySDKCxxConfig.cmake" @ONLY ) set( CONF_INCLUDE_DIRS - "\${IntersonArraySDKCxx_CMAKE_DIR}/${_relative_include_dir}" ) + "\${IntersonArraySDKCxx_CMAKE_DIR}/${_relative_include_dir} ${CONF_INCLUDE_DIRS}" ) configure_file( IntersonArraySDKCxxConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonArraySDKCxxConfig.cmake" @ONLY ) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 6935f3a..787faa5 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -23,7 +23,7 @@ set( IntersonArrayCxx_HEADERS IntersonArrayCxxControlsHWControls.h IntersonArrayCxxImagingContainer.h - IntersonArrayCxxIntersonArrayClass.h + IntersonArrayCxxIntersonClass.h ) install( FILES ${IntersonArrayCxx_HEADERS} From 5ea27d15f1ce24af3efd84ee28ebefd82e44c5ac Mon Sep 17 00:00:00 2001 From: Maeliss Jallais Date: Fri, 21 Apr 2017 14:03:03 -0400 Subject: [PATCH 072/103] ENH: Improve configuration export for build or install tree This commit updates the buildsystem to allow other projects to include "IntersonArraySDKCxx" using either its build or install tree. This means that configuring a project Foo with -DIntersonArraySDKCxx_DIR:PATH:/path/to/IntersonArraySDKCxx-build-Release or -DIntersonArraySDKCxx_DIR:PATH:/path/to/IntersonArraySDKCxx-install will allow find_package(IntersonArraySDKCxx REQUIRED) to work as expected within Foo CMakeLists.txt. --- CMakeLists.txt | 119 +++++++++++++++-------------- IntersonArraySDKCxxConfig.cmake.in | 30 ++------ src/CMakeLists.txt | 35 ++++++--- 3 files changed, 90 insertions(+), 94 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a193b3..6623467 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,84 +20,89 @@ # limitations under the License. # ############################################################################## -cmake_minimum_required( VERSION 2.8 ) + +cmake_minimum_required( VERSION 3.6 ) project( IntersonArraySDKCxx ) -if( NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/bin ) -endif() -if( NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/lib ) -endif() -if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/lib ) -endif() +# CMake modules +include( CMakePackageConfigHelpers ) +include( CTest ) + +# Options +option( BUILD_APPLICATIONS "Build applications" OFF ) -set( CONF_INCLUDE_DIRS - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_BINARY_DIR}/include ) -include_directories( ${CONF_INCLUDE_DIRS} ) +# External dependencies +find_path( IntersonArraySDK_DIR + NAMES Libraries/IntersonArray.dll + PATHS C:/IntersonArraySDK + ) +if( NOT IntersonArraySDK_DIR ) + message( FATAL_ERROR "Please specify the path to the IntersonArraySDK" + " in IntersonArraySDK_DIR" ) +endif() +# Install relative directories set( INSTALL_LIB_DIR lib ) set( INSTALL_BIN_DIR bin ) set( INSTALL_INCLUDE_DIR include ) -if( WIN32 AND NOT CYGWIN ) - set( DEF_INSTALL_CMAKE_DIR CMake ) -else() - set( DEF_INSTALL_CMAKE_DIR lib/CMake/FooBar ) -endif() -set( INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} ) - -foreach( path LIB BIN INCLUDE CMAKE ) - set( var INSTALL_${path}_DIR ) - if( NOT IS_ABSOLUTE "${${var}}" ) - set( ${var} "${CMAKE_INSTALL_PREFIX}/${${var}}" ) - endif() -endforeach() +set( INSTALL_CMAKE_DIR cmake ) -find_path( IntersonArraySDK_DIR NAMES Libraries/IntersonArray.dll - PATHS C:/IntersonArraySDK ) -if( NOT IntersonArraySDK_DIR ) - message( SEND_ERROR "Please specify the path to the IntersonArraySDK" - " in IntersonArraySDK_DIR" ) +# Output directories +if( NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/${INSTALL_BIN_DIR} ) +endif() +if( NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/${INSTALL_LIB_DIR} ) +endif() +if( NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IntersonArraySDKCxx_BINARY_DIR}/${INSTALL_LIB_DIR} ) endif() +# Add subdirectories add_subdirectory( include ) add_subdirectory( src ) - -include( CTest ) if( BUILD_TESTING ) - enable_testing() add_subdirectory( test ) endif() - -option( BUILD_APPLICATIONS "Build applications" OFF ) if( BUILD_APPLICATIONS ) add_subdirectory( app ) endif() -export( TARGETS IntersonArrayCxx - FILE "${PROJECT_BINARY_DIR}/IntersonArraySDKCxxTargets.cmake" ) -export( PACKAGE IntersonArraySDKCxx ) - -file( RELATIVE_PATH _relative_include_dir - "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}" ) - -configure_file( IntersonArraySDKCxxConfig.cmake.in - "${PROJECT_BINARY_DIR}/IntersonArraySDKCxxConfig.cmake" @ONLY ) - -set( CONF_INCLUDE_DIRS - "\${IntersonArraySDKCxx_CMAKE_DIR}/${_relative_include_dir} ${CONF_INCLUDE_DIRS}" ) -configure_file( IntersonArraySDKCxxConfig.cmake.in - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonArraySDKCxxConfig.cmake" - @ONLY ) +# Configure 'IntersonArraySDKCxxConfig.cmake' for a build tree +set(CONFIG_DIR_CONFIG ${PROJECT_BINARY_DIR}) +set(intersonArraySDKCxx_config ${PROJECT_BINARY_DIR}/IntersonArraySDKCxxConfig.cmake) +configure_package_config_file( + IntersonArraySDKCxxConfig.cmake.in + ${intersonArraySDKCxx_config} + INSTALL_DESTINATION ${PROJECT_BINARY_DIR} + PATH_VARS CONFIG_DIR_CONFIG + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) + +# Configure 'IntersonArraySDKCxxConfig.cmake' for an install tree +set(CONFIG_DIR_CONFIG ${INSTALL_CMAKE_DIR}) +set( intersonArraySDKCxx_install_config ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonArraySDKCxxConfig.cmake ) +configure_package_config_file( + IntersonArraySDKCxxConfig.cmake.in + ${intersonArraySDKCxx_install_config} + INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR} + PATH_VARS CONFIG_DIR_CONFIG + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) +install( + FILES ${intersonArraySDKCxx_install_config} + DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT Development + ) -install( FILES - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonArraySDKCxxConfig.cmake" - DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT Development +# Configure 'IntersonArraySDKCxxTargets.cmake' +export( TARGETS IntersonArrayCxx + FILE ${PROJECT_BINARY_DIR}/IntersonArraySDKCxxTargets.cmake ) -install( EXPORT IntersonArraySDKCxxTargets DESTINATION - "${INSTALL_CMAKE_DIR}" + +# Install 'IntersonArraySDKCxxTargets.cmake' and 'IntersonArraySDKCxxConfig.cmake' +install( EXPORT IntersonArraySDKCxxTargets + FILE IntersonArraySDKCxxTargets.cmake + DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT Development ) diff --git a/IntersonArraySDKCxxConfig.cmake.in b/IntersonArraySDKCxxConfig.cmake.in index 1d167a1..43b0b1c 100644 --- a/IntersonArraySDKCxxConfig.cmake.in +++ b/IntersonArraySDKCxxConfig.cmake.in @@ -24,35 +24,15 @@ # Config file for the IntersonArraySDKCxx library wrapper. # # It defines the following variables: -# IntersonArraySDKCxx_INCLUDE_DIRS - include directories for -# IntersonArraySDKCxx -# IntersonArraySDKCxx_RUNTIME_LIBRARY_DIRS - directories that store the -# libraries needed for runtime execution # IntersonArraySDKCxx_LIBRARIES - libraries to link against -# IntersonArraySDK_DIR - Path to the IntersonArraySDK used to -# build this library. -get_filename_component( IntersonArraySDKCxx_CMAKE_DIR - "${CMAKE_CURRENT_LIST_FILE}" PATH ) +@PACKAGE_INIT@ -set( IntersonArraySDKCxx_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@" ) +set_and_check( IntersonArraySDKCxx_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/IntersonArraySDKCxxTargets.cmake" ) -if( NOT TARGET IntersonArrayCxx AND NOT IntersonArraySDKCxx_BINARY_DIR ) - include( "${IntersonArraySDKCxx_CMAKE_DIR}/IntersonArraySDKCxxTargets.cmake" ) +if( NOT IntersonArraySDKCxx_TARGETS_IMPORTED ) + set( IntersonArraySDKCxx_TARGETS_IMPORTED 1 ) + include( ${IntersonArraySDKCxx_TARGETS} ) endif() set( IntersonArraySDKCxx_LIBRARIES IntersonArrayCxx ) - -set( IntersonArrayCxx_RUNTIME_LIBRARY_DIRS ) -get_property( _configs TARGET IntersonArrayCxx PROPERTY - IMPORTED_CONFIGURATIONS ) -foreach( _config ${_configs} ) - get_property( _libloc TARGET IntersonArrayCxx PROPERTY - IMPORTED_LOCATION_${_config} ) - if( EXISTS "${_libloc}" ) - get_filename_component( _libpath "${_libloc}" PATH ) - list( APPEND IntersonArrayCxx_RUNTIME_LIBRARY_DIRS "${_libpath}" ) - endif() -endforeach() - -set( IntersonArraySDK_DIR "@IntersonArraySDK_DIR@" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ae12c0..7c94f63 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,6 +20,9 @@ # limitations under the License. # ############################################################################## + +# XXX (Maeliss, Jc) Ideally, these flags should probably be associated with the +# targets using target_compile_options command. if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") endif() @@ -28,7 +31,6 @@ endif() #string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") #endif() set( CMAKE_CXX_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" ) -set( COMPILE_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" ) set( IntersonArrayCxx_SRCS IntersonArrayCxxControlsHWControls.cxx @@ -36,27 +38,39 @@ set( IntersonArrayCxx_SRCS IntersonArrayCxxIntersonClass.cxx ) -include( GenerateExportHeader ) add_library( IntersonArrayCxx SHARED ${IntersonArrayCxx_SRCS} ) +target_include_directories( IntersonArrayCxx PUBLIC + $ + $ + $ + ) + +# Generate and install export header +include( GenerateExportHeader ) +set(export_header ${PROJECT_BINARY_DIR}/include/IntersonArrayCxx_Export.h) generate_export_header( IntersonArrayCxx BASE_NAME IntersonArrayCxx EXPORT_MACRO_NAME IntersonArrayCxx_EXPORT - EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/IntersonArrayCxx_Export.h + EXPORT_FILE_NAME ${export_header} + ) +install( + FILES ${export_header} + DESTINATION include COMPONENT Development ) -#set_target_properties( IntersonArrayCxx PROPERTIES - #CMAKE_CXX_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" - #) - # COMPILE_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" -install( TARGETS IntersonArrayCxx +# Install library +install( + TARGETS IntersonArrayCxx EXPORT IntersonArraySDKCxxTargets RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT Runtime LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development ) + +# Copy "IntersonArray.dll" and "IntersonArrayCxx.dll" to allow tests and applications to be executed from the build directory if( BUILD_TESTING ) - # For running tests add_custom_command( TARGET IntersonArrayCxx POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin" @@ -66,9 +80,6 @@ if( BUILD_APPLICATIONS ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin" - ) - add_custom_command( TARGET IntersonArrayCxx - POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/bin/IntersonArrayCxx.dll" "${PROJECT_BINARY_DIR}/app/bin" ) endif() From fc740d11667cd7bf4ff0c47e8be6454cf15a1c87 Mon Sep 17 00:00:00 2001 From: Maeliss Jallais Date: Tue, 9 May 2017 16:14:31 -0400 Subject: [PATCH 073/103] COMP: Copy "IntersonArray.dll" and "IntersonArrayCxx.dll" in the appropriate config directories --- src/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c94f63..f0e9019 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,13 +73,14 @@ install( if( BUILD_TESTING ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin/$" ) endif() if( BUILD_APPLICATIONS ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/bin/IntersonArrayCxx.dll" "${PROJECT_BINARY_DIR}/app/bin" + COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/app/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/bin/$/IntersonArrayCxx.dll" "${PROJECT_BINARY_DIR}/app/bin/$" ) endif() From 4a6546b1d5e58de6cd3b3ee6d54264771d906165 Mon Sep 17 00:00:00 2001 From: Maeliss Jallais Date: Wed, 10 May 2017 12:07:26 -0400 Subject: [PATCH 074/103] COMP: Add IntersonArraySDK_DIR, necessary to build Plus --- IntersonArraySDKCxxConfig.cmake.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/IntersonArraySDKCxxConfig.cmake.in b/IntersonArraySDKCxxConfig.cmake.in index 43b0b1c..7a5dad3 100644 --- a/IntersonArraySDKCxxConfig.cmake.in +++ b/IntersonArraySDKCxxConfig.cmake.in @@ -25,6 +25,8 @@ # # It defines the following variables: # IntersonArraySDKCxx_LIBRARIES - libraries to link against +# IntersonArraySDK_DIR - Path to the IntersonArraySDK used to +# build this library. @PACKAGE_INIT@ @@ -36,3 +38,4 @@ if( NOT IntersonArraySDKCxx_TARGETS_IMPORTED ) endif() set( IntersonArraySDKCxx_LIBRARIES IntersonArrayCxx ) +set( IntersonArraySDK_DIR "@IntersonArraySDK_DIR@" ) From 6b14bc39cb294198cfe83f2095458282eaaebff9 Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Fri, 12 May 2017 18:10:45 -0400 Subject: [PATCH 075/103] Updating cmake list for packing dlls etc --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6623467..7f555b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ # ############################################################################## -cmake_minimum_required( VERSION 3.6 ) +cmake_minimum_required( VERSION 3.5 ) project( IntersonArraySDKCxx ) From 6e9d026f4d9144fb711e96bab5587e627fb22b98 Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Tue, 16 May 2017 15:28:01 -0400 Subject: [PATCH 076/103] cmake: Add install rule for Internson shared library Co-authored-by: Jean-Christophe Fillion-Robin --- CMakeLists.txt | 9 +++++++++ src/CMakeLists.txt | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f555b7..8cefb9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,10 @@ if( NOT IntersonArraySDK_DIR ) message( FATAL_ERROR "Please specify the path to the IntersonArraySDK" " in IntersonArraySDK_DIR" ) endif() +set( IntersonArraySDK_LIBRARY "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" ) +if( NOT EXISTS ${IntersonArraySDK_LIBRARY} ) + message( FATAL_ERROR "Interson library is missing [${IntersonArraySDK_LIBRARY}]" ) +endif() # Install relative directories set( INSTALL_LIB_DIR lib ) @@ -69,6 +73,11 @@ if( BUILD_APPLICATIONS ) add_subdirectory( app ) endif() +# Install Interson libraries +install( FILES ${IntersonArraySDK_LIBRARY} + DESTINATION ${INSTALL_BIN_DIR} COMPONENT Runtime + ) + # Configure 'IntersonArraySDKCxxConfig.cmake' for a build tree set(CONFIG_DIR_CONFIG ${PROJECT_BINARY_DIR}) set(intersonArraySDKCxx_config ${PROJECT_BINARY_DIR}/IntersonArraySDKCxxConfig.cmake) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f0e9019..6557da7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,14 +73,14 @@ install( if( BUILD_TESTING ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_LIBRARY}" "${PROJECT_BINARY_DIR}/bin/$" ) endif() if( BUILD_APPLICATIONS ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/app/bin/$" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_LIBRARY}" "${PROJECT_BINARY_DIR}/app/bin/$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/bin/$/IntersonArrayCxx.dll" "${PROJECT_BINARY_DIR}/app/bin/$" ) endif() From 61aa7b79613705d677ab4008bc7ce5c1f21194b2 Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Tue, 23 May 2017 09:55:50 -0400 Subject: [PATCH 077/103] Fix Buffer Size The buffer size in the Bmode image was to large. The buffer size is unaffacted by scanWidth and scanHeight in the ScanConverter and appers to have a fixed size of NBOLINES x MAX_SAMPLES. Now teh BMode images is received at full depth and the image size does not ahve to be set to MAX_SMAPLES/2. --- src/IntersonArrayCxxImagingContainer.cxx | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 5b4ab82..6e83c4f 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -54,7 +54,7 @@ ref class NewRFImageHandler NewRFImageCallback( NULL ), NewRFImageCallbackClientData( NULL ), bufferWidth( Container::MAX_RFSAMPLES ), - bufferHeight( Container::MAX_RFSAMPLES ), + bufferHeight( Container::NBOFLINES ), NativeRFBuffer(new RFImagePixelType[Container::MAX_RFSAMPLES * Container::NBOFLINES] ), ManagedRFBuffer( managedRFBuffer ) @@ -86,8 +86,8 @@ ref class NewRFImageHandler void SetImageSize( int width, int height ) { - bufferWidth = width; - bufferHeight = height; + //bufferWidth = width; + //bufferHeight = height; } void SetNewRFImageCallback( NewRFImageCallbackType callback, @@ -119,11 +119,13 @@ ref class NewImageHandler NewImageCallback( NULL ), NewImageCallbackClientData( NULL ), bufferWidth( Container::MAX_SAMPLES ), - bufferHeight( Container::MAX_SAMPLES ), + bufferHeight( Container::NBOFLINES ), NativeBuffer( new PixelType[Container::MAX_SAMPLES * - Container::MAX_SAMPLES] ), + Container::NBOFLINES ] ), ManagedBuffer( managedBuffer ) { + std::cout << "Conatiner NBOFLINES: " << Container::NBOFLINES << std::endl; + } ~NewImageHandler() @@ -151,8 +153,8 @@ ref class NewImageHandler void SetImageSize( int width, int height ) { - bufferWidth = width; - bufferHeight = height; + // bufferWidth = width; + // bufferHeight = height; } void SetNewImageCallback( NewImageCallbackType callback, @@ -188,8 +190,7 @@ class ContainerImpl WrappedImageBuilding = gcnew IntersonArray::Imaging::ImageBuilding(); WrappedCapture = gcnew IntersonArray::Imaging::Capture(); - Buffer = gcnew ArrayType( Container::MAX_SAMPLES, - Container::MAX_SAMPLES); + Buffer = gcnew ArrayType( Container::NBOFLINES, Container::MAX_SAMPLES ); Handler = gcnew NewImageHandler( Buffer ); HandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( Handler, @@ -257,6 +258,7 @@ class ContainerImpl Container::ScanConverterError HardInitScanConverter( int depth, int widthScan, int heightScan, int steering ) { + return static_cast< Container::ScanConverterError >( WrappedScanConverter->HardInitScanConverter( depth, widthScan, heightScan, steering, WrappedCapture.get(), @@ -342,8 +344,9 @@ class ContainerImpl void *clientData = 0 ) { this->Handler->SetNewImageCallback( callback, clientData ); - this->Handler->SetImageSize( this->GetWidthScan(), - this->GetHeightScan() ); + + //this->Handler->SetImageSize( this->GetWidthScan(), + // this->GetHeightScan() ); } void SetNewRFImageCallback( NewRFImageCallbackType callback, From 29a5c97c3d1183cefcd68946a9c192e9da02aed9 Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Tue, 23 May 2017 10:01:20 -0400 Subject: [PATCH 078/103] Updated AquireBmode app to corret buffer size --- app/AcquireIntersonArrayBMode.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index b8ca100..77c216b 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -126,7 +126,7 @@ int main( int argc, char * argv[] ) container.SetRFData( false ); const int height = hwControls.GetLinesPerArray(); - const int width = 512; //container.MAX_SAMPLES; + const int width = container.MAX_SAMPLES; if( hwControls.ValidDepth( depth ) == depth ) { ContainerType::ScanConverterError converterErrorIdle = From 14e05475bc9f2d924dc40da2301a620dabc251da Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Tue, 23 May 2017 14:59:33 -0400 Subject: [PATCH 079/103] Cleanup --- src/IntersonArrayCxxImagingContainer.cxx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 6e83c4f..92e8564 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -84,12 +84,6 @@ ref class NewRFImageHandler } } - void SetImageSize( int width, int height ) - { - //bufferWidth = width; - //bufferHeight = height; - } - void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) { @@ -124,8 +118,6 @@ ref class NewImageHandler Container::NBOFLINES ] ), ManagedBuffer( managedBuffer ) { - std::cout << "Conatiner NBOFLINES: " << Container::NBOFLINES << std::endl; - } ~NewImageHandler() @@ -151,11 +143,6 @@ ref class NewImageHandler } } - void SetImageSize( int width, int height ) - { - // bufferWidth = width; - // bufferHeight = height; - } void SetNewImageCallback( NewImageCallbackType callback, void *clientData ) @@ -344,16 +331,12 @@ class ContainerImpl void *clientData = 0 ) { this->Handler->SetNewImageCallback( callback, clientData ); - - //this->Handler->SetImageSize( this->GetWidthScan(), - // this->GetHeightScan() ); } void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = 0 ) { this->RFHandler->SetNewRFImageCallback( callback, clientData ); - this->RFHandler->SetImageSize(Container::MAX_RFSAMPLES, Container::NBOFLINES); } void SetHWControls(IntersonArrayCxx::Controls::HWControls * controls) { From 8a21e77eb8a1c7cfbd284d3f471a102918668d91 Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Tue, 23 May 2017 09:55:50 -0400 Subject: [PATCH 080/103] Fix Buffer Size The buffer size in the Bmode image was to large. The buffer size is unaffacted by scanWidth and scanHeight in the ScanConverter and appers to have a fixed size of NBOLINES x MAX_SAMPLES. Now teh BMode images is received at full depth and the image size does not ahve to be set to MAX_SMAPLES/2. --- src/IntersonArrayCxxImagingContainer.cxx | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 5b4ab82..6e83c4f 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -54,7 +54,7 @@ ref class NewRFImageHandler NewRFImageCallback( NULL ), NewRFImageCallbackClientData( NULL ), bufferWidth( Container::MAX_RFSAMPLES ), - bufferHeight( Container::MAX_RFSAMPLES ), + bufferHeight( Container::NBOFLINES ), NativeRFBuffer(new RFImagePixelType[Container::MAX_RFSAMPLES * Container::NBOFLINES] ), ManagedRFBuffer( managedRFBuffer ) @@ -86,8 +86,8 @@ ref class NewRFImageHandler void SetImageSize( int width, int height ) { - bufferWidth = width; - bufferHeight = height; + //bufferWidth = width; + //bufferHeight = height; } void SetNewRFImageCallback( NewRFImageCallbackType callback, @@ -119,11 +119,13 @@ ref class NewImageHandler NewImageCallback( NULL ), NewImageCallbackClientData( NULL ), bufferWidth( Container::MAX_SAMPLES ), - bufferHeight( Container::MAX_SAMPLES ), + bufferHeight( Container::NBOFLINES ), NativeBuffer( new PixelType[Container::MAX_SAMPLES * - Container::MAX_SAMPLES] ), + Container::NBOFLINES ] ), ManagedBuffer( managedBuffer ) { + std::cout << "Conatiner NBOFLINES: " << Container::NBOFLINES << std::endl; + } ~NewImageHandler() @@ -151,8 +153,8 @@ ref class NewImageHandler void SetImageSize( int width, int height ) { - bufferWidth = width; - bufferHeight = height; + // bufferWidth = width; + // bufferHeight = height; } void SetNewImageCallback( NewImageCallbackType callback, @@ -188,8 +190,7 @@ class ContainerImpl WrappedImageBuilding = gcnew IntersonArray::Imaging::ImageBuilding(); WrappedCapture = gcnew IntersonArray::Imaging::Capture(); - Buffer = gcnew ArrayType( Container::MAX_SAMPLES, - Container::MAX_SAMPLES); + Buffer = gcnew ArrayType( Container::NBOFLINES, Container::MAX_SAMPLES ); Handler = gcnew NewImageHandler( Buffer ); HandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( Handler, @@ -257,6 +258,7 @@ class ContainerImpl Container::ScanConverterError HardInitScanConverter( int depth, int widthScan, int heightScan, int steering ) { + return static_cast< Container::ScanConverterError >( WrappedScanConverter->HardInitScanConverter( depth, widthScan, heightScan, steering, WrappedCapture.get(), @@ -342,8 +344,9 @@ class ContainerImpl void *clientData = 0 ) { this->Handler->SetNewImageCallback( callback, clientData ); - this->Handler->SetImageSize( this->GetWidthScan(), - this->GetHeightScan() ); + + //this->Handler->SetImageSize( this->GetWidthScan(), + // this->GetHeightScan() ); } void SetNewRFImageCallback( NewRFImageCallbackType callback, From ac642e3d1e8a7487900b5256154979f31e0e8ac7 Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Tue, 23 May 2017 10:01:20 -0400 Subject: [PATCH 081/103] Updated AquireBmode app to corret buffer size --- app/AcquireIntersonArrayBMode.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index b8ca100..77c216b 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -126,7 +126,7 @@ int main( int argc, char * argv[] ) container.SetRFData( false ); const int height = hwControls.GetLinesPerArray(); - const int width = 512; //container.MAX_SAMPLES; + const int width = container.MAX_SAMPLES; if( hwControls.ValidDepth( depth ) == depth ) { ContainerType::ScanConverterError converterErrorIdle = From 592d10a9ad136624dc286a8ce7f5976d56a2fb7e Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Tue, 23 May 2017 14:59:33 -0400 Subject: [PATCH 082/103] Cleanup --- src/IntersonArrayCxxImagingContainer.cxx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 6e83c4f..92e8564 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -84,12 +84,6 @@ ref class NewRFImageHandler } } - void SetImageSize( int width, int height ) - { - //bufferWidth = width; - //bufferHeight = height; - } - void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData ) { @@ -124,8 +118,6 @@ ref class NewImageHandler Container::NBOFLINES ] ), ManagedBuffer( managedBuffer ) { - std::cout << "Conatiner NBOFLINES: " << Container::NBOFLINES << std::endl; - } ~NewImageHandler() @@ -151,11 +143,6 @@ ref class NewImageHandler } } - void SetImageSize( int width, int height ) - { - // bufferWidth = width; - // bufferHeight = height; - } void SetNewImageCallback( NewImageCallbackType callback, void *clientData ) @@ -344,16 +331,12 @@ class ContainerImpl void *clientData = 0 ) { this->Handler->SetNewImageCallback( callback, clientData ); - - //this->Handler->SetImageSize( this->GetWidthScan(), - // this->GetHeightScan() ); } void SetNewRFImageCallback( NewRFImageCallbackType callback, void *clientData = 0 ) { this->RFHandler->SetNewRFImageCallback( callback, clientData ); - this->RFHandler->SetImageSize(Container::MAX_RFSAMPLES, Container::NBOFLINES); } void SetHWControls(IntersonArrayCxx::Controls::HWControls * controls) { From c0f53723c6a39c9dec1516530e42218a20201672 Mon Sep 17 00:00:00 2001 From: Maeliss Jallais Date: Thu, 20 Apr 2017 14:02:50 -0400 Subject: [PATCH 083/103] COMP: Remove depth variable from the XML file to avoid confusion --- app/AcquireIntersonArrayBMode.cxx | 1 + app/AcquireIntersonArrayBMode.xml | 10 ---------- app/AcquireIntersonArrayRF.cxx | 1 + app/AcquireIntersonArrayRF.xml | 11 ----------- 4 files changed, 2 insertions(+), 21 deletions(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index 77c216b..912af32 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -127,6 +127,7 @@ int main( int argc, char * argv[] ) const int height = hwControls.GetLinesPerArray(); const int width = container.MAX_SAMPLES; + const int depth = 100; if( hwControls.ValidDepth( depth ) == depth ) { ContainerType::ScanConverterError converterErrorIdle = diff --git a/app/AcquireIntersonArrayBMode.xml b/app/AcquireIntersonArrayBMode.xml index 90cfe53..c578091 100644 --- a/app/AcquireIntersonArrayBMode.xml +++ b/app/AcquireIntersonArrayBMode.xml @@ -59,15 +59,5 @@ 0 255 - - depth - - Depth of acquisition [mm]. Only relevant with scanConvert. - depth - d - 100 - 0 - 200 - diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index c052ed6..9c10720 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -130,6 +130,7 @@ int main( int argc, char * argv[] ) container.AbortScan(); container.SetRFData( true ); + const int depth = 100; // Depth of acquisition [mm] container.IdleInitScanConverter( depth, width_samples, height_lines, probeId, steering, false, false, 0 ); container.HardInitScanConverter( depth, width_samples, height_lines, steering ); diff --git a/app/AcquireIntersonArrayRF.xml b/app/AcquireIntersonArrayRF.xml index 9909874..d5bdb95 100644 --- a/app/AcquireIntersonArrayRF.xml +++ b/app/AcquireIntersonArrayRF.xml @@ -49,16 +49,5 @@ 0 100 - - depth - - Depth of acquisition [mm]. Only relevant with scanConvert. - depth - d - 100 - 0 - 200 - - From 8ddb8ef1bd4cbc86d5558a2af7270ddf2ca06d81 Mon Sep 17 00:00:00 2001 From: Maeliss Jallais Date: Thu, 20 Apr 2017 15:48:42 -0400 Subject: [PATCH 084/103] ENH: Set spacing in the output image --- app/AcquireIntersonArrayBMode.cxx | 6 ++++++ app/AcquireIntersonArrayRF.cxx | 10 ++++++++++ app/AcquireIntersonArrayRF.xml | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index 912af32..791eb94 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -154,6 +154,7 @@ int main( int argc, char * argv[] ) std::cout << "ScanWidth = " << scanWidth << std::endl; std::cout << "ScanHeight = " << scanHeight << std::endl; std::cout << "MM per Pixel = " << container.GetMmPerPixel() << std::endl; + std::cout << "Depth: " << depth << "mm" << std::endl; const itk::SizeValueType framesToCollect = frames; @@ -169,6 +170,11 @@ int main( int argc, char * argv[] ) imageSize[2] = framesToCollect; imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); + ImageType::SpacingType imageSpacing; + imageSpacing[ 0 ] = container.GetMmPerPixel(); + imageSpacing[ 1 ] = 38.0 / (height - 1); + imageSpacing[ 2 ] = 1; + image->SetSpacing( imageSpacing ); image->Allocate(); CallbackClientData clientData; diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 9c10720..1c10ed8 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -127,6 +127,11 @@ int main( int argc, char * argv[] ) std::cout << "Max RF samples: " << width_samples << std::endl; const itk::SizeValueType framesToCollect = frames; + const double ns = ContainerType::MAX_RFSAMPLES; // number of samples + const double fs = 30000; // [kHz]=[samples/ms] - sampling frequency + const double depth = sos * ( ns - 1 ) / ( 2 * fs ); + std::cout << "Depth: " << depth << "mm" << std::endl; + container.AbortScan(); container.SetRFData( true ); @@ -147,6 +152,11 @@ int main( int argc, char * argv[] ) imageSize[2] = framesToCollect; imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); + ImageType::SpacingType imageSpacing; + imageSpacing[ 0 ] = sos / ( 2 * fs ); + imageSpacing[ 1 ] = 38.0 / ( height_lines - 1 ); + imageSpacing[ 2 ] = 1; + image->SetSpacing( imageSpacing ); image->Allocate(); CallbackClientData clientData; diff --git a/app/AcquireIntersonArrayRF.xml b/app/AcquireIntersonArrayRF.xml index d5bdb95..19e37ba 100644 --- a/app/AcquireIntersonArrayRF.xml +++ b/app/AcquireIntersonArrayRF.xml @@ -49,5 +49,12 @@ 0 100 + + sos + + Assumed speed of sound in the crossed medium in mm/ms. + sos + 1540 + From 353778f9740e97e224fac4e85d0783c36a819e15 Mon Sep 17 00:00:00 2001 From: Samuel Gerber Date: Fri, 12 Jan 2018 10:29:00 -0500 Subject: [PATCH 085/103] Fix Managed Code (#16) Managed code #pragama caused compile errors with Visual Studio 15 2017 due to being used before includes --- src/IntersonArrayCxxControlsHWControls.cxx | 4 ++-- src/IntersonArrayCxxImagingContainer.cxx | 4 ++-- src/IntersonArrayCxxIntersonClass.cxx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/IntersonArrayCxxControlsHWControls.cxx b/src/IntersonArrayCxxControlsHWControls.cxx index 5f44303..daa4c38 100644 --- a/src/IntersonArrayCxxControlsHWControls.cxx +++ b/src/IntersonArrayCxxControlsHWControls.cxx @@ -21,11 +21,9 @@ limitations under the License. =========================================================================*/ // C++ -#pragma unmanaged #include "IntersonArrayCxxControlsHWControls.h" // C# -#pragma managed #include #include @@ -33,6 +31,8 @@ limitations under the License. // Add library from SDK #using "IntersonArray.dll" +#pragma managed + namespace IntersonArrayCxx { diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 92e8564..de0ed55 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -20,10 +20,8 @@ See the License for the specific language governing permissions and limitations under the License. =========================================================================*/ -#pragma unmanaged #include "IntersonArrayCxxImagingContainer.h" #include -#pragma managed #include #include @@ -31,6 +29,8 @@ limitations under the License. #using "IntersonArray.dll" +#pragma managed + namespace IntersonArrayCxx { diff --git a/src/IntersonArrayCxxIntersonClass.cxx b/src/IntersonArrayCxxIntersonClass.cxx index 2f71e6c..1f386ae 100644 --- a/src/IntersonArrayCxxIntersonClass.cxx +++ b/src/IntersonArrayCxxIntersonClass.cxx @@ -21,11 +21,9 @@ limitations under the License. =========================================================================*/ // C++ -#pragma unmanaged #include "IntersonArrayCxxIntersonClass.h" // C# -#pragma managed #include #include @@ -33,6 +31,8 @@ limitations under the License. // Add library from SDK #using "IntersonArray.dll" +#pragma managed + namespace IntersonArrayCxx { // Wrapper Class for IntersonClass from SDK From b1ef58c8118925182bcffc73db07b12465df92dd Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Fri, 9 Feb 2018 23:43:43 -0500 Subject: [PATCH 086/103] ENH: Now supports ninja build Ninja does not write libs/exec to $ (e.g., Release or Debug) subdirs in the bin or libs directories. So, these changes updates the copy commands to use proper source and target files and directories for ninja and visual studios. --- src/CMakeLists.txt | 5 ++++- src/IntersonArrayCxxImagingContainer.cxx | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f0e9019..0c9c64f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -74,6 +74,7 @@ if( BUILD_TESTING ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin" ) endif() if( BUILD_APPLICATIONS ) @@ -81,6 +82,8 @@ if( BUILD_APPLICATIONS ) POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/app/bin/$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin/$" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/bin/$/IntersonArrayCxx.dll" "${PROJECT_BINARY_DIR}/app/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/app/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/app/bin" ) endif() diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 5b4ab82..c94ddec 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -54,7 +54,7 @@ ref class NewRFImageHandler NewRFImageCallback( NULL ), NewRFImageCallbackClientData( NULL ), bufferWidth( Container::MAX_RFSAMPLES ), - bufferHeight( Container::MAX_RFSAMPLES ), + bufferHeight( Container::NBOFLINES ), NativeRFBuffer(new RFImagePixelType[Container::MAX_RFSAMPLES * Container::NBOFLINES] ), ManagedRFBuffer( managedRFBuffer ) @@ -191,13 +191,16 @@ class ContainerImpl Buffer = gcnew ArrayType( Container::MAX_SAMPLES, Container::MAX_SAMPLES); Handler = gcnew NewImageHandler( Buffer ); + Handler->SetImageSize( Container::MAX_SAMPLES, Container::MAX_SAMPLES ); HandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( Handler, & NewImageHandler::HandleNewImage ); WrappedCapture->NewImageTick += HandlerDelegate; - RFBuffer = gcnew RFArrayType(Container::NBOFLINES , Container::MAX_RFSAMPLES); + RFBuffer = gcnew RFArrayType( Container::NBOFLINES, + Container::MAX_RFSAMPLES ); RFHandler = gcnew NewRFImageHandler( RFBuffer ); + RFHandler->SetImageSize( Container::MAX_RFSAMPLES, Container::NBOFLINES ); RFHandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( RFHandler, & NewRFImageHandler::HandleNewRFImage ); From fec57782cdd785fee7200f4d9e3b9920643f7af2 Mon Sep 17 00:00:00 2001 From: Stephen Aylward Date: Sun, 11 Feb 2018 11:33:36 -0500 Subject: [PATCH 087/103] BUG: Merge of commits produced inconsistencies. Eliminated double declaration of depth in RF acquisition app. Eliminated calls to SetImageSize in Image and RF Handlers in src. - size is provided by global Container. --- app/AcquireIntersonArrayRF.cxx | 1 - src/IntersonArrayCxxImagingContainer.cxx | 3 --- 2 files changed, 4 deletions(-) diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 1c10ed8..681097a 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -135,7 +135,6 @@ int main( int argc, char * argv[] ) container.AbortScan(); container.SetRFData( true ); - const int depth = 100; // Depth of acquisition [mm] container.IdleInitScanConverter( depth, width_samples, height_lines, probeId, steering, false, false, 0 ); container.HardInitScanConverter( depth, width_samples, height_lines, steering ); diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 410d949..317b5ee 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -143,7 +143,6 @@ ref class NewImageHandler } } - void SetNewImageCallback( NewImageCallbackType callback, void *clientData ) { @@ -179,7 +178,6 @@ class ContainerImpl Buffer = gcnew ArrayType( Container::NBOFLINES, Container::MAX_SAMPLES ); Handler = gcnew NewImageHandler( Buffer ); - Handler->SetImageSize( Container::MAX_SAMPLES, Container::MAX_SAMPLES ); HandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( Handler, & NewImageHandler::HandleNewImage ); @@ -188,7 +186,6 @@ class ContainerImpl RFBuffer = gcnew RFArrayType( Container::NBOFLINES, Container::MAX_RFSAMPLES ); RFHandler = gcnew NewRFImageHandler( RFBuffer ); - RFHandler->SetImageSize( Container::MAX_RFSAMPLES, Container::NBOFLINES ); RFHandlerDelegate = gcnew IntersonArray::Imaging::Capture::NewImageHandler( RFHandler, & NewRFImageHandler::HandleNewRFImage ); From 482a2e2f910df0056b6a75caa132a9a4f72ba7d7 Mon Sep 17 00:00:00 2001 From: "Stephen R. Aylward" Date: Tue, 13 Feb 2018 11:55:03 -0500 Subject: [PATCH 088/103] ENH: Change API to support ArraySDK2.12 (#19) --- app/AcquireIntersonArrayBMode.cxx | 8 +-- app/AcquireIntersonArrayRF.cxx | 8 +-- include/IntersonArrayCxxImagingContainer.h | 10 ++-- src/IntersonArrayCxxImagingContainer.cxx | 49 +++++-------------- ...IntersonArrayCxxControlsHWControlsTest.cxx | 12 +++-- test/IntersonArrayCxxImagingContainerTest.cxx | 7 ++- 6 files changed, 33 insertions(+), 61 deletions(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index 791eb94..c7822a1 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -122,19 +122,20 @@ int main( int argc, char * argv[] ) hwControls.DisableHardButton(); ContainerType container; - container.AbortScan(); container.SetRFData( false ); const int height = hwControls.GetLinesPerArray(); const int width = container.MAX_SAMPLES; const int depth = 100; + const int depthCfm = 50; if( hwControls.ValidDepth( depth ) == depth ) { ContainerType::ScanConverterError converterErrorIdle = container.IdleInitScanConverter( depth, width, height, probeId, - steering, false, false, 0 ); + steering, depthCfm, false, false, 0, false ); ContainerType::ScanConverterError converterError = - container.HardInitScanConverter( depth, width, height, steering ); + container.HardInitScanConverter( depth, width, height, steering, + depthCfm ); if( converterError != ContainerType::SUCCESS ) { std::cerr << "Error during hard scan converter initialization: " @@ -203,7 +204,6 @@ int main( int argc, char * argv[] ) hwControls.StopAcquisition(); container.StopReadScan(); Sleep( 100 ); // "time to stop" - container.DisposeScan(); typedef itk::ImageFileWriter< ImageType > WriterType; WriterType::Pointer writer = WriterType::New(); diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 681097a..12d76bc 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -130,14 +130,15 @@ int main( int argc, char * argv[] ) const double ns = ContainerType::MAX_RFSAMPLES; // number of samples const double fs = 30000; // [kHz]=[samples/ms] - sampling frequency const double depth = sos * ( ns - 1 ) / ( 2 * fs ); + const double depthCfm = depth/2; std::cout << "Depth: " << depth << "mm" << std::endl; - container.AbortScan(); container.SetRFData( true ); container.IdleInitScanConverter( depth, width_samples, height_lines, probeId, - steering, false, false, 0 ); - container.HardInitScanConverter( depth, width_samples, height_lines, steering ); + steering, depthCfm, false, false, 0, false ); + container.HardInitScanConverter( depth, width_samples, height_lines, steering, + depthCfm ); ImageType::Pointer image = ImageType::New(); typedef ImageType::RegionType RegionType; @@ -188,7 +189,6 @@ int main( int argc, char * argv[] ) hwControls.StopAcquisition(); container.StopReadScan(); Sleep( 100 ); // "time to stop" - container.DisposeScan(); typedef itk::ImageFileWriter< ImageType > WriterType; WriterType::Pointer writer = WriterType::New(); diff --git a/include/IntersonArrayCxxImagingContainer.h b/include/IntersonArrayCxxImagingContainer.h index 7e6d721..905c530 100644 --- a/include/IntersonArrayCxxImagingContainer.h +++ b/include/IntersonArrayCxxImagingContainer.h @@ -81,11 +81,11 @@ class IntersonArrayCxx_EXPORT Container }; ScanConverterError HardInitScanConverter( int depth, int widthScan, - int heightScan, int steering ); + int heightScan, int steering, int depthCfm ); ScanConverterError IdleInitScanConverter( int depth, int width, - int height, short idleId, int idleSteering, bool idleDoubler, - bool idleCompound, int idleCompoundAngle ); + int height, short idleId, int idleSteering, int depthCfm, bool idleDoubler, + bool idleCompound, int idleCompoundAngle, bool idleCfm ); // // Begin Capture Methods @@ -100,10 +100,6 @@ class IntersonArrayCxx_EXPORT Container bool GetScanOn() const; - void AbortScan(); - - void DisposeScan(); - void StartReadScan(); void StartRFReadScan(); diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 317b5ee..924d183 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -243,23 +243,23 @@ class ContainerImpl } Container::ScanConverterError HardInitScanConverter( int depth, - int widthScan, int heightScan, int steering ) + int widthScan, int heightScan, int steering, int depthCfm ) { return static_cast< Container::ScanConverterError >( WrappedScanConverter->HardInitScanConverter( depth, widthScan, - heightScan, steering, WrappedCapture.get(), + heightScan, steering, depthCfm, WrappedCapture.get(), WrappedImageBuilding.get() ) ); } Container::ScanConverterError IdleInitScanConverter( int depth, - int widthScan, int heightScan, short idleId, int idleSteering, - bool idleDoubler, bool idleCompound, int idleCompoundAngle ) + int widthScan, int heightScan, short idleId, int idleSteering, int depthCfm, + bool idleDoubler, bool idleCompound, int idleCompoundAngle, bool idleCfm ) { return static_cast< Container::ScanConverterError >( WrappedScanConverter->IdleInitScanConverter( depth, widthScan, - heightScan, idleId, idleSteering, idleDoubler, idleCompound, - idleCompoundAngle, WrappedImageBuilding.get() ) ); + heightScan, idleId, idleSteering, depthCfm, idleDoubler, idleCompound, + idleCompoundAngle, idleCfm, WrappedImageBuilding.get() ) ); } // @@ -302,16 +302,6 @@ class ContainerImpl return WrappedCapture->ScanOn; } - void AbortScan() - { - WrappedCapture->AbortScan(); - } - - void DisposeScan() - { - WrappedCapture->DisposeScan(); - } - void StartReadScan() { WrappedCapture->StartReadScan( (ArrayType ^)Buffer ); @@ -460,21 +450,22 @@ ::GetZeroOfYScale() const Container::ScanConverterError Container ::HardInitScanConverter( int depth, int widthScan, int heightScan, - int steering ) + int steering, int depthCfm ) { return Impl->HardInitScanConverter( depth, widthScan, heightScan, - steering ); + steering, depthCfm ); } Container::ScanConverterError Container ::IdleInitScanConverter( int depth, int width, int height, short idleId, - int idleSteering, bool idleDoubler, bool idleCompound, - int idleCompoundAngle ) + int idleSteering, int depthCfm, bool idleDoubler, bool idleCompound, + int idleCompoundAngle, bool idleCfm ) { return Impl->IdleInitScanConverter( depth, width, height, idleId, - idleSteering, idleDoubler, idleCompound, idleCompoundAngle ); + idleSteering, depthCfm, idleDoubler, idleCompound, idleCompoundAngle, + idleCfm ); } // @@ -518,22 +509,6 @@ ::GetScanOn() const } -void -Container -::AbortScan() -{ - Impl->AbortScan(); -} - - -void -Container -::DisposeScan() -{ - Impl->DisposeScan(); -} - - void Container ::StartReadScan() diff --git a/test/IntersonArrayCxxControlsHWControlsTest.cxx b/test/IntersonArrayCxxControlsHWControlsTest.cxx index cc1bdac..dd04caa 100644 --- a/test/IntersonArrayCxxControlsHWControlsTest.cxx +++ b/test/IntersonArrayCxxControlsHWControlsTest.cxx @@ -38,16 +38,18 @@ int main( int argc, char * argv[] ) FoundProbesType; FoundProbesType foundProbes; hwControls.FindAllProbes( foundProbes ); + std::cout << "Number of probes = " << foundProbes.size() << std::endl; + if( foundProbes.empty() ) + { + std::cerr << "No probes found. Please connect a probe for tests." + << std::endl; + return EXIT_FAILURE; + } std::cout << "Found Probes: " << std::endl; for( size_t ii = 0; ii < foundProbes.size(); ++ii ) { std::cout << " " << foundProbes[ii] << std::endl; } - if( foundProbes.empty() ) - { - std::cerr << "Could not find the probe." << std::endl; - return EXIT_FAILURE; - } hwControls.FindMyProbe( 0 ); const short probeId = hwControls.GetProbeID(); diff --git a/test/IntersonArrayCxxImagingContainerTest.cxx b/test/IntersonArrayCxxImagingContainerTest.cxx index 9c4f04a..3a33444 100644 --- a/test/IntersonArrayCxxImagingContainerTest.cxx +++ b/test/IntersonArrayCxxImagingContainerTest.cxx @@ -65,9 +65,10 @@ int main( int argc, char * argv[] ) const int height = 512; int steering = 0; + int depthCfm = 50; ContainerType::ScanConverterError converterError = container.IdleInitScanConverter( depth, width, height, probeId, - steering, false, false, 0 ); + steering, depthCfm, false, false, 0, false ); if( converterError != ContainerType::SUCCESS ) { std::cerr << "Error during idle scan converter initialization: " @@ -75,7 +76,7 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } converterError = container.HardInitScanConverter( depth, width, - height, steering ); + height, steering, depthCfm ); if( converterError != ContainerType::SUCCESS ) { std::cerr << "Error during hard scan converter initialization: " @@ -83,7 +84,6 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - container.AbortScan(); std::cout << "\nStarting BMode scanning..." << std::endl; container.StartReadScan(); Sleep( 100 ); // "time to start" @@ -99,7 +99,6 @@ int main( int argc, char * argv[] ) hwControls.StopAcquisition(); container.StopReadScan(); Sleep( 100 ); // "time to stop" - container.DisposeScan(); return EXIT_SUCCESS; } From c6bd625fed0317dbfbcc17e4c2e741e244f152f6 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 9 Apr 2018 19:36:58 -0400 Subject: [PATCH 089/103] COMP: Help the build find MSCOREE.lib Addresses: LINK : fatal error LNK1104: cannot open file 'MSCOREE.lib' --- src/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9fc5470..327dda5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,6 +47,14 @@ target_include_directories( IntersonArrayCxx PUBLIC $ ) +find_library(MSCOREE_LIBRARY + NAMES MSCOREE mscoree + PATHS "C:/Program Files (x86)/Common Files/Microsoft/Visual C++ for Python/9.0/WinSDK/Lib/" + ) +if(MSCOREE_LIBRARY) + target_link_libraries(IntersonArrayCxx ${MSCOREE_LIBRARY}) +endif() + # Generate and install export header include( GenerateExportHeader ) set(export_header ${PROJECT_BINARY_DIR}/include/IntersonArrayCxx_Export.h) @@ -88,4 +96,4 @@ if( BUILD_APPLICATIONS ) COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/app/bin" ) -endif() \ No newline at end of file +endif() From 2619f4b506333b5f856ff06915017bd7805ba736 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 17 Apr 2018 12:53:53 -0400 Subject: [PATCH 090/103] DOC: Note that the x86 compiler is required --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index e530e6f..51e55fd 100644 --- a/README.rst +++ b/README.rst @@ -8,5 +8,5 @@ Dependencies ------------ - CMake -- Interson Array SDK -- Visual Studio >= 2015 +- Interson Array SDK +- Visual Studio, VC x86 Compiler >= 2015 From 856febae89a90dbc62d3eb6c6bddb05506d39ee4 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 12:56:59 -0400 Subject: [PATCH 091/103] ENH: Set the default focusIndex to 1 This is a better default value. --- CMakeLists.txt | 2 +- app/AcquireIntersonArrayBMode.xml | 12 ++++++------ app/AcquireIntersonArrayRF.xml | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cefb9d..e604f76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,7 @@ configure_package_config_file( PATH_VARS CONFIG_DIR_CONFIG NO_CHECK_REQUIRED_COMPONENTS_MACRO ) - + # Configure 'IntersonArraySDKCxxConfig.cmake' for an install tree set(CONFIG_DIR_CONFIG ${INSTALL_CMAKE_DIR}) set( intersonArraySDKCxx_install_config ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/IntersonArraySDKCxxConfig.cmake ) diff --git a/app/AcquireIntersonArrayBMode.xml b/app/AcquireIntersonArrayBMode.xml index c578091..ba6e7f7 100644 --- a/app/AcquireIntersonArrayBMode.xml +++ b/app/AcquireIntersonArrayBMode.xml @@ -20,7 +20,7 @@ Frames to collect. frames - n + n 1 @@ -28,7 +28,7 @@ Index of the frequency to examine. See the output of PrintIntersonProbeInfo. frequencyIndex - f + f 1 @@ -36,15 +36,15 @@ Index of the focus to examine. See the output of PrintIntersonProbeInfo. focusIndex - F - 0 + F + 1 highVoltage Percentage of the high voltage for transducer excitation. highVoltage - z + z 50 0 100 @@ -54,7 +54,7 @@ Dynamic gain [dB]. gain - g + g 100 0 255 diff --git a/app/AcquireIntersonArrayRF.xml b/app/AcquireIntersonArrayRF.xml index 19e37ba..db90c5c 100644 --- a/app/AcquireIntersonArrayRF.xml +++ b/app/AcquireIntersonArrayRF.xml @@ -20,7 +20,7 @@ Frames to collect. frames - n + n 1 @@ -28,7 +28,7 @@ Index of the frequency to examine. See the output of PrintIntersonProbeInfo. frequencyIndex - f + f 1 @@ -36,15 +36,15 @@ Index of the focus to examine. See the output of PrintIntersonProbeInfo. focusIndex - F - 0 + F + 1 highVoltage Percentage of the high voltage for transducer excitation. highVoltage - z + z 50 0 100 From ec23fb1370f257cd3d71c36dc3003e7c9d5c475b Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 16:12:05 -0400 Subject: [PATCH 092/103] BUG: Add correct Direction and Axial spacing for AcquireIntersonArrayBMode --- app/AcquireIntersonArrayBMode.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index c7822a1..bd6ba71 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -172,10 +172,18 @@ int main( int argc, char * argv[] ) imageRegion.SetSize( imageSize ); image->SetRegions( imageRegion ); ImageType::SpacingType imageSpacing; - imageSpacing[ 0 ] = container.GetMmPerPixel(); + imageSpacing[ 0 ] = container.GetMmPerPixel() / 10.; imageSpacing[ 1 ] = 38.0 / (height - 1); imageSpacing[ 2 ] = 1; image->SetSpacing( imageSpacing ); + ImageType::DirectionType direction; + direction.SetIdentity(); + ImageType::DirectionType::InternalMatrixType & vnlDirection = direction.GetVnlMatrix(); + vnlDirection.put(0, 0, 0.0); + vnlDirection.put(0, 1, -1.0); + vnlDirection.put(1, 0, 1.0); + vnlDirection.put(1, 1, 0.0); + image->SetDirection( direction ); image->Allocate(); CallbackClientData clientData; From e4b3a5be037e859c3dc1775c6205974c4872953b Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 16:18:37 -0400 Subject: [PATCH 093/103] ENH: Set BMode spacing based on the frame rate --- app/AcquireIntersonArrayBMode.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index bd6ba71..66de2ab 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -174,7 +174,8 @@ int main( int argc, char * argv[] ) ImageType::SpacingType imageSpacing; imageSpacing[ 0 ] = container.GetMmPerPixel() / 10.; imageSpacing[ 1 ] = 38.0 / (height - 1); - imageSpacing[ 2 ] = 1; + const short frameRate = hwControls.GetProbeFrameRate(); + imageSpacing[ 2 ] = 1.0 / frameRate; image->SetSpacing( imageSpacing ); ImageType::DirectionType direction; direction.SetIdentity(); From 282d63c867f0ab7836e85e0628e24ac99099019d Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 16:26:37 -0400 Subject: [PATCH 094/103] STYLE: BMode console output tweaks --- app/AcquireIntersonArrayBMode.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index 66de2ab..8344779 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -156,6 +156,7 @@ int main( int argc, char * argv[] ) std::cout << "ScanHeight = " << scanHeight << std::endl; std::cout << "MM per Pixel = " << container.GetMmPerPixel() << std::endl; std::cout << "Depth: " << depth << "mm" << std::endl; + std::cout << std::endl; const itk::SizeValueType framesToCollect = frames; @@ -201,11 +202,10 @@ int main( int argc, char * argv[] ) }; int c = 0; - while( clientData.FrameIndex < framesToCollect && c < 100 ) + while( clientData.FrameIndex < framesToCollect && c < 1000 ) { - std::cout << clientData.FrameIndex << " of " << framesToCollect + std::cout << "Frames to collect: " << clientData.FrameIndex << " of " << framesToCollect << std::endl; - std::cout << c << " of 100" << std::endl; Sleep( 100 ); ++c; } From 6d81d48eea56bbf198533fd3aa6f7b7c2eefbcfe Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 16:38:34 -0400 Subject: [PATCH 095/103] ENH: Add Direction to RF data --- app/AcquireIntersonArrayRF.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 12d76bc..4202919 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -157,6 +157,14 @@ int main( int argc, char * argv[] ) imageSpacing[ 1 ] = 38.0 / ( height_lines - 1 ); imageSpacing[ 2 ] = 1; image->SetSpacing( imageSpacing ); + ImageType::DirectionType direction; + direction.SetIdentity(); + ImageType::DirectionType::InternalMatrixType & vnlDirection = direction.GetVnlMatrix(); + vnlDirection.put(0, 0, 0.0); + vnlDirection.put(0, 1, -1.0); + vnlDirection.put(1, 0, 1.0); + vnlDirection.put(1, 1, 0.0); + image->SetDirection( direction ); image->Allocate(); CallbackClientData clientData; From f0f4c3d1c67380e5881b1393e6253722817c8def Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 16:52:20 -0400 Subject: [PATCH 096/103] BUG: Increase the number of allowed RF frames to collect --- app/AcquireIntersonArrayBMode.cxx | 2 +- app/AcquireIntersonArrayRF.cxx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index 8344779..d284f22 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -202,7 +202,7 @@ int main( int argc, char * argv[] ) }; int c = 0; - while( clientData.FrameIndex < framesToCollect && c < 1000 ) + while( clientData.FrameIndex < framesToCollect && c < 10000 ) { std::cout << "Frames to collect: " << clientData.FrameIndex << " of " << framesToCollect << std::endl; diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 4202919..69ae8b5 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -132,6 +132,7 @@ int main( int argc, char * argv[] ) const double depth = sos * ( ns - 1 ) / ( 2 * fs ); const double depthCfm = depth/2; std::cout << "Depth: " << depth << "mm" << std::endl; + std::cout << std::endl; container.SetRFData( true ); @@ -184,11 +185,11 @@ int main( int argc, char * argv[] ) } int c = 0; - while( clientData.FrameIndex < framesToCollect && c < 10 ) + while( clientData.FrameIndex < framesToCollect && c < 10000 ) { + std::cout << "Frames to collect: " << clientData.FrameIndex << " of " << framesToCollect << std::endl; std::cout << clientData.FrameIndex << " of " << framesToCollect << std::endl; - std::cout << c << " of 10" << std::endl; Sleep( 100 ); ++c; } From 0f0992548dfffc1789cd401fb9a64c847ba59b95 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 16:54:05 -0400 Subject: [PATCH 097/103] BUG: Remove debug code --- app/AcquireIntersonArrayRF.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 69ae8b5..61cd44c 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -59,7 +59,6 @@ void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) } const int framePixels = imageSize[0] * imageSize[1]; - std::cout << "frame pixels RF = " << framePixels << std::endl; PixelType * imageBuffer = image->GetPixelContainer()->GetBufferPointer(); imageBuffer += framePixels * callbackClientData->FrameIndex; @@ -194,7 +193,6 @@ int main( int argc, char * argv[] ) ++c; } - std::cout << "StopAcquisition" << std::endl; hwControls.StopAcquisition(); container.StopReadScan(); Sleep( 100 ); // "time to stop" From 3235ab8e73a4a9695d7261e7dbaf0813fe2d8897 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 27 Apr 2018 17:00:27 -0400 Subject: [PATCH 098/103] ENH: Set RF Spacing based on frame rate --- app/AcquireIntersonArrayRF.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index 61cd44c..b3d6b88 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -155,7 +155,8 @@ int main( int argc, char * argv[] ) ImageType::SpacingType imageSpacing; imageSpacing[ 0 ] = sos / ( 2 * fs ); imageSpacing[ 1 ] = 38.0 / ( height_lines - 1 ); - imageSpacing[ 2 ] = 1; + const short frameRate = hwControls.GetProbeFrameRate(); + imageSpacing[ 2 ] = 1.0 / frameRate; image->SetSpacing( imageSpacing ); ImageType::DirectionType direction; direction.SetIdentity(); From d4c85f0be20db55124570558a23692f19dcb1c10 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 1 May 2018 17:58:39 -0400 Subject: [PATCH 099/103] ENH: Flip app images left-right forward-backward This now has the same orientation as the Interson app output. --- app/AcquireIntersonArrayBMode.cxx | 3 ++- app/AcquireIntersonArrayRF.cxx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/AcquireIntersonArrayBMode.cxx b/app/AcquireIntersonArrayBMode.cxx index d284f22..d4bd7ad 100644 --- a/app/AcquireIntersonArrayBMode.cxx +++ b/app/AcquireIntersonArrayBMode.cxx @@ -182,9 +182,10 @@ int main( int argc, char * argv[] ) direction.SetIdentity(); ImageType::DirectionType::InternalMatrixType & vnlDirection = direction.GetVnlMatrix(); vnlDirection.put(0, 0, 0.0); - vnlDirection.put(0, 1, -1.0); + vnlDirection.put(0, 1, 1.0); vnlDirection.put(1, 0, 1.0); vnlDirection.put(1, 1, 0.0); + vnlDirection.put(2, 2, -1.0); image->SetDirection( direction ); image->Allocate(); diff --git a/app/AcquireIntersonArrayRF.cxx b/app/AcquireIntersonArrayRF.cxx index b3d6b88..a99745a 100644 --- a/app/AcquireIntersonArrayRF.cxx +++ b/app/AcquireIntersonArrayRF.cxx @@ -162,9 +162,10 @@ int main( int argc, char * argv[] ) direction.SetIdentity(); ImageType::DirectionType::InternalMatrixType & vnlDirection = direction.GetVnlMatrix(); vnlDirection.put(0, 0, 0.0); - vnlDirection.put(0, 1, -1.0); + vnlDirection.put(0, 1, 1.0); vnlDirection.put(1, 0, 1.0); vnlDirection.put(1, 1, 0.0); + vnlDirection.put(2, 2, -1.0); image->SetDirection( direction ); image->Allocate(); From e8ab82f0d2b49e60cd850881e17d88bb25cf91fe Mon Sep 17 00:00:00 2001 From: Sam Horvath Date: Tue, 28 Aug 2018 18:03:47 -0400 Subject: [PATCH 100/103] ENH: Adds an option to build an OpenIGTLink server for RF data This has been created as an alternative to the Plus implementation, which currently does not return all of the RF data --- CMakeLists.txt | 5 + openigtlink/CMakeLists.txt | 38 ++++ openigtlink/IntersonArrayServerRF.cxx | 258 ++++++++++++++++++++++++++ openigtlink/IntersonArrayServerRF.xml | 53 ++++++ src/CMakeLists.txt | 11 ++ 5 files changed, 365 insertions(+) create mode 100644 openigtlink/CMakeLists.txt create mode 100644 openigtlink/IntersonArrayServerRF.cxx create mode 100644 openigtlink/IntersonArrayServerRF.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index e604f76..d4736de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ include( CTest ) # Options option( BUILD_APPLICATIONS "Build applications" OFF ) +option( BUILD_SERVERS "Build OpenIGTLink Servers" OFF) # External dependencies find_path( IntersonArraySDK_DIR @@ -73,6 +74,10 @@ if( BUILD_APPLICATIONS ) add_subdirectory( app ) endif() +if( BUILD_SERVERS ) + add_subdirectory( openigtlink ) +endif() + # Install Interson libraries install( FILES ${IntersonArraySDK_LIBRARY} DESTINATION ${INSTALL_BIN_DIR} COMPONENT Runtime diff --git a/openigtlink/CMakeLists.txt b/openigtlink/CMakeLists.txt new file mode 100644 index 0000000..4e463ec --- /dev/null +++ b/openigtlink/CMakeLists.txt @@ -0,0 +1,38 @@ +############################################################################## +# +# Library: IntersonArraySDK +# +# Copyright Kitware Inc. 28 Corporate Drive, +# Clifton Park, NY, 12065, USA. +# +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## +find_package( SlicerExecutionModel REQUIRED ) +include( ${SlicerExecutionModel_USE_FILE} ) + +find_package(OpenIGTLink REQUIRED) +include(${OpenIGTLink_USE_FILE}) + + +SEMMacroBuildCLI( + NAME IntersonArrayServerRF + TARGET_LIBRARIES ${ITK_LIBRARIES} + IntersonArrayCxx + OpenIGTLink + INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ) + diff --git a/openigtlink/IntersonArrayServerRF.cxx b/openigtlink/IntersonArrayServerRF.cxx new file mode 100644 index 0000000..1c48679 --- /dev/null +++ b/openigtlink/IntersonArrayServerRF.cxx @@ -0,0 +1,258 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include // Sleep + +#include "IntersonArrayCxxImagingContainer.h" +#include "IntersonArrayCxxControlsHWControls.h" +#include "igtlImageMessage.h" +#include "igtlServerSocket.h" + +#include "IntersonArrayServerRFCLP.h" + +typedef IntersonArrayCxx::Imaging::Container ContainerType; +typedef ContainerType::RFImagePixelType PixelType; +bool running; + +BOOL WINAPI consoleHandler(DWORD signal) { + + if (signal == CTRL_C_EVENT) + { + running = false; + } + + return TRUE; +} + +struct CallbackClientData +{ + int FrameIndex; + igtl::Socket * socket; + igtl::ImageMessage * imgMsg; + igtl::TimeStamp * ts; +}; + +void __stdcall pasteIntoImage( PixelType * buffer, void * clientData ) +{ + CallbackClientData * callbackClientData = + static_cast< CallbackClientData * >( clientData ); + + igtl::ImageMessage * message = callbackClientData->imgMsg; + igtl::Socket * socket = callbackClientData->socket; + igtl::TimeStamp * ts = callbackClientData->ts; + + const int framePixels = ContainerType::MAX_RFSAMPLES * ContainerType::NBOFLINES; + ++(callbackClientData->FrameIndex); + + message->SetMessageID(callbackClientData->FrameIndex); + ts->GetTime(); + igtlUint32 sec; + igtlUint32 nsec; + ts->GetTimeStamp(&sec, &nsec); + message->SetTimeStamp(sec, nsec); + + std::memcpy(message->GetScalarPointer(), buffer, framePixels * sizeof(PixelType)); + + if (!socket) + { + return; + } + + message->Pack(); + socket->Send(message->GetPackPointer(), message->GetPackSize()); +} + +int main( int argc, char * argv[] ) +{ + PARSE_ARGS; + + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + IntersonArrayCxx::Controls::HWControls hwControls; + + int ret = EXIT_SUCCESS; + + int steering = 0; + typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes( foundProbes ); + if( foundProbes.empty() ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + hwControls.FindMyProbe( 0 ); + const unsigned int probeId = hwControls.GetProbeID(); + if( probeId == 0 ) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency( frequencies ); + + HWControlsType::FocusType focuses; + hwControls.GetFocus(focuses); + + if( !hwControls.SetFrequencyAndFocus( frequencyIndex, focusIndex, + steering ) ) + { + std::cerr << "Could not set the frequency and focus." << std::endl; + return EXIT_FAILURE; + } + + if( !hwControls.SendHighVoltage( highVoltage, highVoltage ) ) + { + std::cerr << "Could not set the high voltage." << std::endl; + return EXIT_FAILURE; + } + if( !hwControls.EnableHighVoltage() ) + { + std::cerr << "Could not enable high voltage." << std::endl; + return EXIT_FAILURE; + } + + hwControls.DisableHardButton(); + ContainerType container; + container.SetHWControls(&hwControls); + + const int height_lines = hwControls.GetLinesPerArray(); + std::cout << "Lines per array: " << height_lines << std::endl; + const int width_samples = ContainerType::MAX_RFSAMPLES; + std::cout << "Max RF samples: " << width_samples << std::endl; + const double ns = ContainerType::MAX_RFSAMPLES; // number of samples + const double fs = 30000; // [kHz]=[samples/ms] - sampling frequency + const double depth = sos * ( ns - 1 ) / ( 2 * fs ); + const double depthCfm = depth/2; + std::cout << "Depth: " << depth << "mm" << std::endl; + std::cout << std::endl; + + container.SetRFData( true ); + container.IdleInitScanConverter( depth, width_samples, height_lines, probeId, + steering, depthCfm, false, false, 0, false ); + container.HardInitScanConverter( depth, width_samples, height_lines, steering, + depthCfm ); + + CallbackClientData clientData; + clientData.FrameIndex = 0; + + // size parameters + const short frameRate = hwControls.GetProbeFrameRate(); + int size[] = { ContainerType::MAX_RFSAMPLES, ContainerType::NBOFLINES, 1 }; // image dimension + float spacing[] = { sos / (2 * fs), 38.0 / (height_lines - 1), 1.0 / frameRate }; // spacing (mm/pixel) + int svsize[] = { ContainerType::MAX_RFSAMPLES, ContainerType::NBOFLINES, 1 }; // sub-volume size + int svoffset[] = { 0, 0, 0 }; // sub-volume offset + int scalarType = igtl::ImageMessage::TYPE_INT16;// scalar type + + //------------------------------------------------------------ + // Create a new IMAGE type message + igtl::ImageMessage::Pointer imgMsg = igtl::ImageMessage::New(); + imgMsg->SetDimensions(size); + imgMsg->SetSpacing(spacing); + imgMsg->SetScalarType(scalarType); + imgMsg->SetDeviceName("IntersonRF"); + imgMsg->SetSubVolume(svsize, svoffset); + imgMsg->SetHeaderVersion(IGTL_HEADER_VERSION_2); + IANA_ENCODING_TYPE codingScheme = IANA_TYPE_US_ASCII; + + //Add meta data here + imgMsg->SetMetaDataElement("Frequency (MHz)", codingScheme, std::to_string(frequencies[frequencyIndex])); + imgMsg->SetMetaDataElement("Focus (mm)", codingScheme, std::to_string(focuses[focusIndex])); + imgMsg->SetMetaDataElement("High voltage", codingScheme, std::to_string(highVoltage)); + imgMsg->SetMetaDataElement("SOS", codingScheme, std::to_string(sos)); + imgMsg->SetMetaDataElement("FPS", codingScheme, std::to_string(frameRate)); + imgMsg->SetMetaDataElement("Steering", codingScheme, std::to_string(steering)); + imgMsg->SetMetaDataElement("Image Type", codingScheme, "RF"); + imgMsg->SetMetaDataElement("Timestamp seconds", codingScheme, "0"); + imgMsg->SetMetaDataElement("Timestamp nseconds", codingScheme, "0"); + + imgMsg->AllocateScalars(); + imgMsg->SetEndian(igtl::ImageMessage::ENDIAN_LITTLE); + igtl::Matrix4x4 matrix; + matrix[0][0] = 0.0; matrix[1][0] = -1.0; matrix[2][0] = 0.0; matrix[3][0] = 0.0; + matrix[0][1] = 1.0; matrix[1][1] = 0.0; matrix[2][1] = 0.0; matrix[3][1] = 0.0; + matrix[0][2] = 0.0; matrix[1][2] = 0.0; matrix[2][2] = 1.0; matrix[3][2] = 0.0; + matrix[0][3] = 0.0; matrix[1][3] = 0.0; matrix[2][3] = 0.0; matrix[3][3] = 1.0; + imgMsg->SetMatrix(matrix); + igtl::TimeStamp::Pointer ts = igtl::TimeStamp::New(); + clientData.ts = ts.GetPointer(); + clientData.imgMsg = imgMsg.GetPointer(); + + //socket setup + igtl::ServerSocket::Pointer serverSocket; + serverSocket = igtl::ServerSocket::New(); + int r = serverSocket->CreateServer(port); + + if (r < 0) + { + std::cerr << "Cannot create a server socket." << std::endl; + exit(0); + } + std::cerr << "Created Server socket." << std::endl; + + + igtl::Socket::Pointer socket; + clientData.socket = socket; + + container.SetNewRFImageCallback( &pasteIntoImage, &clientData ); + + std::cout << "StartRFReadScan" << std::endl; + container.StartRFReadScan(); + Sleep( 100 ); // "time to start" + std::cout << "StartRFmode" << std::endl; + if( !hwControls.StartRFmode() ) + { + std::cerr << "Could not start RF collection." << std::endl; + return EXIT_FAILURE; + } + + if (!SetConsoleCtrlHandler(consoleHandler, TRUE)) + { + std::cout << "Could not set control handler" << std::endl; + return 1; + } + running = true; + std::cout << "Server is running, use Ctrl-C to stop" << std::endl; + while( running ) + { + //------------------------------------------------------------ + // Waiting for Connection + socket = serverSocket->WaitForConnection(1000); + clientData.socket = socket.GetPointer(); + if (socket.IsNotNull()) // if client connected + { + Sleep(10000); //chill for a bit + } + + } + + std::cout << "Shutting down" << std::endl; + hwControls.StopAcquisition(); + container.StopReadScan(); + if (socket) + { + socket->CloseSocket(); + } + + Sleep( 100 ); // "time to stop" + return ret; +} diff --git a/openigtlink/IntersonArrayServerRF.xml b/openigtlink/IntersonArrayServerRF.xml new file mode 100644 index 0000000..072831a --- /dev/null +++ b/openigtlink/IntersonArrayServerRF.xml @@ -0,0 +1,53 @@ + + + Ultrasound + Interson RF OpenIGTLink Server + Braodcast RF images over OpenIGTLink. + 0.1.0 + Apache 2.0 + Sam Horvath (Kitware), Matt McCormick (Kitware) + This work is funded in part by a grant with InnerOptic/Kitware + + + port + + Port for OpenIGTLink Server. + port + p + 18944 + + + frequencyIndex + + Index of the frequency to examine. See the output of PrintIntersonProbeInfo. + frequencyIndex + f + 1 + + + focusIndex + + Index of the focus to examine. See the output of PrintIntersonProbeInfo. + focusIndex + F + 1 + + + highVoltage + + Percentage of the high voltage for transducer excitation. + highVoltage + z + 50 + 0 + 100 + + + sos + + Assumed speed of sound in the crossed medium in mm/ms. + sos + 1540 + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 327dda5..a191087 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -97,3 +97,14 @@ if( BUILD_APPLICATIONS ) COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/app/bin" ) endif() + +if( BUILD_SERVERS ) + add_custom_command( TARGET IntersonArrayCxx + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/openigtlink/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/openigtlink/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/openigtlink/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/openigtlink/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/openigtlink/bin" + ) +endif() From 2298e517abbdf8e4f196d5c66e3e69aeb12c7af2 Mon Sep 17 00:00:00 2001 From: Luv Kohli Date: Tue, 22 Jan 2019 18:08:10 -0500 Subject: [PATCH 101/103] BUG: Corret GetTrueDepth function call --- src/IntersonArrayCxxImagingContainer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/src/IntersonArrayCxxImagingContainer.cxx index 924d183..d313c3b 100644 --- a/src/IntersonArrayCxxImagingContainer.cxx +++ b/src/IntersonArrayCxxImagingContainer.cxx @@ -427,7 +427,7 @@ double Container ::GetTrueDepth() const { - return Impl->GetMmPerPixel(); + return Impl->GetTrueDepth(); } From 8857d9951ebe5fae868806f70246a9bdb9c06964 Mon Sep 17 00:00:00 2001 From: "Brad T. Moore" Date: Wed, 23 Jun 2021 17:07:28 -0400 Subject: [PATCH 102/103] ENH: Update for Interson SDK version 2.21 I modified the value of IntersonArraySDK_DIR to point to the actual folder containing the DLLs, not a parent folder a couple of steps up. The folder structure is different in the latest version of the SDK. I changed the HWButtonTick (updated to new class names) handling to work with the new/replacement Release event in this version of the SDK. Added IntersonArrayServerBMode. Fixed typo in IntersonArrayServerRF.xml. --- CMakeLists.txt | 2 +- openigtlink/CMakeLists.txt | 11 + openigtlink/IntersonArrayServerBMode.cxx | 309 +++++++++++++++++++++ openigtlink/IntersonArrayServerBMode.xml | 64 +++++ openigtlink/IntersonArrayServerRF.xml | 2 +- src/CMakeLists.txt | 14 +- src/IntersonArrayCxxControlsHWControls.cxx | 8 +- 7 files changed, 397 insertions(+), 13 deletions(-) create mode 100644 openigtlink/IntersonArrayServerBMode.cxx create mode 100644 openigtlink/IntersonArrayServerBMode.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index d4736de..c77915d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if( NOT IntersonArraySDK_DIR ) message( FATAL_ERROR "Please specify the path to the IntersonArraySDK" " in IntersonArraySDK_DIR" ) endif() -set( IntersonArraySDK_LIBRARY "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" ) +set( IntersonArraySDK_LIBRARY "${IntersonArraySDK_DIR}/IntersonArray.dll" ) if( NOT EXISTS ${IntersonArraySDK_LIBRARY} ) message( FATAL_ERROR "Interson library is missing [${IntersonArraySDK_LIBRARY}]" ) endif() diff --git a/openigtlink/CMakeLists.txt b/openigtlink/CMakeLists.txt index 4e463ec..b2ad8a5 100644 --- a/openigtlink/CMakeLists.txt +++ b/openigtlink/CMakeLists.txt @@ -26,6 +26,8 @@ include( ${SlicerExecutionModel_USE_FILE} ) find_package(OpenIGTLink REQUIRED) include(${OpenIGTLink_USE_FILE}) +find_package( ITK REQUIRED ) +include( ${ITK_USE_FILE} ) SEMMacroBuildCLI( NAME IntersonArrayServerRF @@ -35,4 +37,13 @@ SEMMacroBuildCLI( INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ) + +SEMMacroBuildCLI( + NAME IntersonArrayServerBMode + TARGET_LIBRARIES ${ITK_LIBRARIES} + IntersonArrayCxx + OpenIGTLink + INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include +) diff --git a/openigtlink/IntersonArrayServerBMode.cxx b/openigtlink/IntersonArrayServerBMode.cxx new file mode 100644 index 0000000..4a5c97c --- /dev/null +++ b/openigtlink/IntersonArrayServerBMode.cxx @@ -0,0 +1,309 @@ +/*========================================================================= + +Library: IntersonArray + +Copyright Kitware Inc. 28 Corporate Drive, +Clifton Park, NY, 12065, USA. + +All rights reserved. + +Licensed under the Apache License, Version 2.0 ( the "License" ); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=========================================================================*/ +#include // Sleep + +#include "itkImageFileWriter.h" + +#include "IntersonArrayCxxControlsHWControls.h" +#include "IntersonArrayCxxImagingContainer.h" + +#include "igtlImageMessage.h" +#include "igtlServerSocket.h" + +#include "IntersonArrayServerBModeCLP.h" + +bool running; + +typedef IntersonArrayCxx::Imaging::Container ContainerType; + +const unsigned int Dimension = 3; +typedef ContainerType::PixelType PixelType; +typedef itk::Image< PixelType, Dimension > ImageType; + +BOOL WINAPI consoleHandler(DWORD signal) { + + if (signal == CTRL_C_EVENT) + { + running = false; + } + + return TRUE; +} + +struct CallbackClientData +{ + itk::SizeValueType FrameIndex; + igtl::Socket* socket; + igtl::ImageMessage* imgMsg; + igtl::TimeStamp* ts; + int width; + int height; +}; + + +void __stdcall pasteIntoImage(PixelType* buffer, void* clientData) +{ + CallbackClientData* callbackClientData = + static_cast(clientData); + + std::cout << "Acquired frame: " << callbackClientData->FrameIndex + << std::endl; + ++(callbackClientData->FrameIndex); + + // sending to openigtlink + igtl::ImageMessage* message = callbackClientData->imgMsg; + igtl::Socket* socket = callbackClientData->socket; + igtl::TimeStamp* ts = callbackClientData->ts; + + int framePixels = callbackClientData->width * callbackClientData->height; + + message->SetMessageID(callbackClientData->FrameIndex); + ts->GetTime(); + igtlUint32 sec; + igtlUint32 nsec; + ts->GetTimeStamp(&sec, &nsec); + message->SetTimeStamp(sec, nsec); + + std::memcpy(message->GetScalarPointer(), buffer, framePixels * sizeof(PixelType)); + + if (!socket) + { + return; + } + + message->Pack(); + socket->Send(message->GetPackPointer(), message->GetPackSize()); +} + + +int main(int argc, char* argv[]) +{ + PARSE_ARGS; + + typedef IntersonArrayCxx::Controls::HWControls HWControlsType; + HWControlsType hwControls; + + const int steering = 0; + typedef HWControlsType::FoundProbesType FoundProbesType; + FoundProbesType foundProbes; + hwControls.FindAllProbes(foundProbes); + if (foundProbes.empty()) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + hwControls.FindMyProbe(0); + const unsigned int probeId = hwControls.GetProbeID(); + if (probeId == 0) + { + std::cerr << "Could not find the probe." << std::endl; + return EXIT_FAILURE; + } + + HWControlsType::FrequenciesType frequencies; + hwControls.GetFrequency(frequencies); + + HWControlsType::FocusType focuses; + hwControls.GetFocus(focuses); + + if (!hwControls.SetFrequencyAndFocus(frequencyIndex, focusIndex, + steering)) + { + std::cerr << "Could not set the frequency." << std::endl; + return EXIT_FAILURE; + } + + if (!hwControls.SendHighVoltage(highVoltage, highVoltage)) + { + std::cerr << "Could not set the high voltage." << std::endl; + return EXIT_FAILURE; + } + if (!hwControls.EnableHighVoltage()) + { + std::cerr << "Could not enable high voltage." << std::endl; + return EXIT_FAILURE; + } + + if (!hwControls.SendDynamic(gain)) + { + std::cerr << "Could not set dynamic gain." << std::endl; + } + + hwControls.DisableHardButton(); + + ContainerType container; + container.SetRFData(false); + + const int height = hwControls.GetLinesPerArray(); + const int width = container.MAX_SAMPLES; + const int depth = 100; + const int depthCfm = 50; + if (hwControls.ValidDepth(depth) == depth) + { + ContainerType::ScanConverterError converterErrorIdle = + container.IdleInitScanConverter(depth, width, height, probeId, + steering, depthCfm, false, false, 0, false); + ContainerType::ScanConverterError converterError = + container.HardInitScanConverter(depth, width, height, steering, + depthCfm); + if (converterError != ContainerType::SUCCESS) + { + std::cerr << "Error during hard scan converter initialization: " + << converterError << std::endl; + return EXIT_FAILURE; + } + } + else + { + std::cerr << "Invalid requested depth for probe." << std::endl; + } + + const int scanWidth = container.GetWidthScan(); + const int scanHeight = container.GetHeightScan(); + std::cout << "Width = " << width << std::endl; + std::cout << "Height = " << height << std::endl; + std::cout << "ScanWidth = " << scanWidth << std::endl; + std::cout << "ScanHeight = " << scanHeight << std::endl; + std::cout << "MM per Pixel = " << container.GetMmPerPixel() << std::endl; + std::cout << "Depth: " << depth << "mm" << std::endl; + std::cout << std::endl; + + int imageSize[3]; + imageSize[0] = width; + imageSize[1] = height; + imageSize[2] = 1; + + float imageSpacing[3]; + imageSpacing[0] = container.GetMmPerPixel() / 10.; + imageSpacing[1] = 38.0 / (height - 1); + const short frameRate = hwControls.GetProbeFrameRate(); + imageSpacing[2] = 1.0 / frameRate; + + //------------------------------------------------------------ + // Create a new IMAGE type message + igtl::ImageMessage::Pointer imgMsg = igtl::ImageMessage::New(); + imgMsg->SetDimensions(imageSize); + imgMsg->SetSpacing(imageSpacing); + imgMsg->SetScalarType(igtl::ImageMessage::TYPE_UINT8); + imgMsg->SetDeviceName("IntersonBMode"); + + int svsize[] = { imageSize[0], imageSize[1], 1 }; // sub-volume size + int svoffset[] = { 0, 0, 0 }; + + imgMsg->SetSubVolume(svsize, svoffset); + imgMsg->SetHeaderVersion(IGTL_HEADER_VERSION_2); + IANA_ENCODING_TYPE codingScheme = IANA_TYPE_US_ASCII; + + //Add meta data here + imgMsg->SetMetaDataElement("Frequency (MHz)", codingScheme, std::to_string(frequencies[frequencyIndex])); + imgMsg->SetMetaDataElement("Focus (mm)", codingScheme, std::to_string(focuses[focusIndex])); + imgMsg->SetMetaDataElement("High voltage", codingScheme, std::to_string(highVoltage)); + imgMsg->SetMetaDataElement("FPS", codingScheme, std::to_string(frameRate)); + imgMsg->SetMetaDataElement("Steering", codingScheme, std::to_string(steering)); + imgMsg->SetMetaDataElement("Image Type", codingScheme, "RF"); + imgMsg->SetMetaDataElement("Timestamp seconds", codingScheme, "0"); + imgMsg->SetMetaDataElement("Timestamp nseconds", codingScheme, "0"); + + imgMsg->AllocateScalars(); + imgMsg->SetEndian(igtl::ImageMessage::ENDIAN_LITTLE); + imgMsg->SetCoordinateSystem(igtl::ImageMessage::COORDINATE_LPS); // LPS + igtl::Matrix4x4 matrix; + matrix[0][0] = 0.0; matrix[1][0] = -1.0; matrix[2][0] = 0.0; matrix[3][0] = 0.0; + matrix[0][1] = 1.0; matrix[1][1] = 0.0; matrix[2][1] = 0.0; matrix[3][1] = 0.0; + matrix[0][2] = 0.0; matrix[1][2] = 0.0; matrix[2][2] = 1.0; matrix[3][2] = 0.0; + matrix[0][3] = 0.0; matrix[1][3] = 0.0; matrix[2][3] = 0.0; matrix[3][3] = 1.0; + /*igtl::Matrix4x4 matrix; + matrix[0][0] = 0.0; matrix[0][1] = 1.0; matrix[0][2] = 0.0; matrix[0][3] = 0.0; + matrix[1][2] = -1.0; matrix[1][2] = 0.0; matrix[1][2] = 0.0; matrix[1][3] = 0.0; + matrix[2][2] = 0.0; matrix[2][2] = 0.0; matrix[2][2] = 1.0; matrix[2][3] = 0.0; + matrix[3][2] = 0.0; matrix[3][2] = 0.0; matrix[3][2] = 0.0; matrix[3][3] = 1.0;*/ + + +// matrix[0][0] = -1.0; matrix[0][1] = 0.0; matrix[0][2] = 0.0; matrix[0][3] = 0.0; +// matrix[1][2] = 0.0; matrix[1][2] = 1.0; matrix[1][2] = 0.0; matrix[1][3] = 0.0; +// matrix[2][2] = 0.0; matrix[2][2] = 0.0; matrix[2][2] = 1.0; matrix[2][3] = 0.0; +// matrix[3][2] = 0.0; matrix[3][2] = 0.0; matrix[3][2] = 0.0; matrix[3][3] = 1.0; + imgMsg->SetMatrix(matrix); + igtl::TimeStamp::Pointer ts = igtl::TimeStamp::New(); + + CallbackClientData clientData; + clientData.ts = ts.GetPointer(); + clientData.imgMsg = imgMsg.GetPointer(); + clientData.FrameIndex = 0; + clientData.width = imageSize[0]; + clientData.height = imageSize[1]; + + //socket setup + igtl::ServerSocket::Pointer serverSocket; + serverSocket = igtl::ServerSocket::New(); + int r = serverSocket->CreateServer(port); + + if (r < 0) + { + std::cerr << "Cannot create a server socket." << std::endl; + exit(0); + } + std::cerr << "Created Server socket." << std::endl; + igtl::Socket::Pointer socket; + clientData.socket = socket; + + container.SetNewImageCallback(&pasteIntoImage, &clientData); + container.StartReadScan(); + Sleep(100); // "time to start" + if (!hwControls.StartBmode()) + { + std::cerr << "Could not start B-mode collection." << std::endl; + return EXIT_FAILURE; + }; + + if (!SetConsoleCtrlHandler(consoleHandler, TRUE)) + { + std::cout << "Could not set control handler" << std::endl; + return 1; + } + running = true; + std::cout << "Server is running, use Ctrl-C to stop" << std::endl; + while (running) + { + //------------------------------------------------------------ + // Waiting for Connection + socket = serverSocket->WaitForConnection(1000); + clientData.socket = socket.GetPointer(); + if (socket.IsNotNull()) // if client connected + { + Sleep(10000); //chill for a bit + } + + } + + std::cout << "Shutting down" << std::endl; + hwControls.StopAcquisition(); + container.StopReadScan(); + if (socket) + { + socket->CloseSocket(); + } + + Sleep(100); // "time to stop" + return EXIT_SUCCESS; +} diff --git a/openigtlink/IntersonArrayServerBMode.xml b/openigtlink/IntersonArrayServerBMode.xml new file mode 100644 index 0000000..f5aa15a --- /dev/null +++ b/openigtlink/IntersonArrayServerBMode.xml @@ -0,0 +1,64 @@ + + + Ultrasound + Acquire Interson B Mode + Acquire multiple B-Mode frames with the Interson USB probe. + 0.1.0 + Apache 2.0 + Brad T. Moore (Kitware) + This effort was sponsored by the U.S. Government under Other Transactions Number W81XWH-15-9-0001/W81XWH-19-9-0015 (MTEC 19-08-MuLTI-0079). + + + port + + Port for OpenIGTLink Server. + port + p + 18944 + + + frames + + Frames to collect. + frames + n + 1 + + + frequencyIndex + + Index of the frequency to examine. See the output of PrintIntersonProbeInfo. + frequencyIndex + f + 1 + + + focusIndex + + Index of the focus to examine. See the output of PrintIntersonProbeInfo. + focusIndex + F + 1 + + + highVoltage + + Percentage of the high voltage for transducer excitation. + highVoltage + z + 50 + 0 + 100 + + + gain + + Dynamic gain [dB]. + gain + g + 100 + 0 + 255 + + + diff --git a/openigtlink/IntersonArrayServerRF.xml b/openigtlink/IntersonArrayServerRF.xml index 072831a..d987e0b 100644 --- a/openigtlink/IntersonArrayServerRF.xml +++ b/openigtlink/IntersonArrayServerRF.xml @@ -2,7 +2,7 @@ Ultrasound Interson RF OpenIGTLink Server - Braodcast RF images over OpenIGTLink. + Broadcast RF images over OpenIGTLink. 0.1.0 Apache 2.0 Sam Horvath (Kitware), Matt McCormick (Kitware) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a191087..2f379d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,7 @@ endif() #if(CMAKE_CXX_FLAGS MATCHES "/EHsc") #string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") #endif() -set( CMAKE_CXX_FLAGS "/clr /EHa /AI${IntersonArraySDK_DIR}/Libraries" ) +set( CMAKE_CXX_FLAGS "/clr /EHa /AI\"${IntersonArraySDK_DIR}\"" ) set( IntersonArrayCxx_SRCS IntersonArrayCxxControlsHWControls.cxx @@ -81,8 +81,8 @@ install( if( BUILD_TESTING ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin/$" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/IntersonArray.dll" "${PROJECT_BINARY_DIR}/bin" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/bin/$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/bin/" ) @@ -91,9 +91,9 @@ if( BUILD_APPLICATIONS ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/app/bin/$" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin/$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/app/bin/$" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/IntersonArray.dll" "${PROJECT_BINARY_DIR}/app/bin" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/app/bin" ) endif() @@ -102,9 +102,9 @@ if( BUILD_SERVERS ) add_custom_command( TARGET IntersonArrayCxx POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/openigtlink/bin/$" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/openigtlink/bin/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/IntersonArray.dll" "${PROJECT_BINARY_DIR}/openigtlink/bin/$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/openigtlink/bin/$" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/Libraries/IntersonArray.dll" "${PROJECT_BINARY_DIR}/openigtlink/bin" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${IntersonArraySDK_DIR}/IntersonArray.dll" "${PROJECT_BINARY_DIR}/openigtlink/bin" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${PROJECT_BINARY_DIR}/openigtlink/bin" ) endif() diff --git a/src/IntersonArrayCxxControlsHWControls.cxx b/src/IntersonArrayCxxControlsHWControls.cxx index daa4c38..b75e97c 100644 --- a/src/IntersonArrayCxxControlsHWControls.cxx +++ b/src/IntersonArrayCxxControlsHWControls.cxx @@ -92,14 +92,14 @@ class HWControlsImpl HardButtonHandler = gcnew NewHardButtonHandler(); HardButtonHandlerDelegate = gcnew - IntersonArray::Controls::HWControls::HWButtonHandler( + IntersonArray::Controls::HWControls::HWButtonHandlerReleased( HardButtonHandler, &NewHardButtonHandler::HandleNewHardButton ); - Wrapped->HWButtonTick += HardButtonHandlerDelegate; + Wrapped->HWButtonTickReleased += HardButtonHandlerDelegate; } ~HWControlsImpl() { - Wrapped->HWButtonTick -= HardButtonHandlerDelegate; + Wrapped->HWButtonTickReleased -= HardButtonHandlerDelegate; } // Compound Angle Functions @@ -351,7 +351,7 @@ class HWControlsImpl gcroot< IntersonArray::Controls::HWControls ^ > Wrapped; gcroot< NewHardButtonHandler ^ > HardButtonHandler; - gcroot< IntersonArray::Controls::HWControls::HWButtonHandler ^ > + gcroot< IntersonArray::Controls::HWControls::HWButtonHandlerReleased ^ > HardButtonHandlerDelegate; }; From 0294b02d844753a1ec27eaa09cfd87e57ba1e159 Mon Sep 17 00:00:00 2001 From: "Brad T. Moore" Date: Fri, 29 Oct 2021 15:35:08 -0400 Subject: [PATCH 103/103] ENH: Moved IntersonArraySDKCxx to appropriate subfolder --- CMakeLists.txt => Interson/IntersonArraySDKCxx/CMakeLists.txt | 0 .../IntersonArraySDKCxx/IntersonArraySDKCxxConfig.cmake.in | 0 Interson/{ => IntersonArraySDKCxx}/README.md | 0 README.rst => Interson/IntersonArraySDKCxx/README.rst | 0 .../IntersonArraySDKCxx/app}/AcquireIntersonArrayBMode.cxx | 0 .../IntersonArraySDKCxx/app}/AcquireIntersonArrayBMode.xml | 0 .../IntersonArraySDKCxx/app}/AcquireIntersonArrayRF.cxx | 0 .../IntersonArraySDKCxx/app}/AcquireIntersonArrayRF.xml | 0 {app => Interson/IntersonArraySDKCxx/app}/CMakeLists.txt | 0 .../IntersonArraySDKCxx/app}/PrintIntersonArrayProbeInfo.cxx | 0 .../IntersonArraySDKCxx/app}/PrintIntersonArrayProbeInfo.xml | 0 .../IntersonArraySDKCxx/doc}/CMakeLists.StandardHeader.txt | 0 .../IntersonArraySDKCxx/doc}/IntersonArray.StandardHeader.txt | 0 {include => Interson/IntersonArraySDKCxx/include}/CMakeLists.txt | 0 .../include}/IntersonArrayCxxControlsHWControls.h | 0 .../include}/IntersonArrayCxxImagingContainer.h | 0 .../IntersonArraySDKCxx/include}/IntersonArrayCxxIntersonClass.h | 0 .../IntersonArraySDKCxx/openigtlink}/CMakeLists.txt | 0 .../IntersonArraySDKCxx/openigtlink}/IntersonArrayServerBMode.cxx | 0 .../IntersonArraySDKCxx/openigtlink}/IntersonArrayServerBMode.xml | 0 .../IntersonArraySDKCxx/openigtlink}/IntersonArrayServerRF.cxx | 0 .../IntersonArraySDKCxx/openigtlink}/IntersonArrayServerRF.xml | 0 {src => Interson/IntersonArraySDKCxx/src}/CMakeLists.txt | 0 .../src}/IntersonArrayCxxControlsHWControls.cxx | 0 .../IntersonArraySDKCxx/src}/IntersonArrayCxxImagingContainer.cxx | 0 .../IntersonArraySDKCxx/src}/IntersonArrayCxxIntersonClass.cxx | 0 {test => Interson/IntersonArraySDKCxx/test}/CMakeLists.txt | 0 .../test}/IntersonArrayCxxControlsHWControlsTest.cxx | 0 .../test}/IntersonArrayCxxImagingContainerTest.cxx | 0 .../test}/IntersonArrayCxxIntersonClassTest.cxx | 0 30 files changed, 0 insertions(+), 0 deletions(-) rename CMakeLists.txt => Interson/IntersonArraySDKCxx/CMakeLists.txt (100%) rename IntersonArraySDKCxxConfig.cmake.in => Interson/IntersonArraySDKCxx/IntersonArraySDKCxxConfig.cmake.in (100%) rename Interson/{ => IntersonArraySDKCxx}/README.md (100%) rename README.rst => Interson/IntersonArraySDKCxx/README.rst (100%) rename {app => Interson/IntersonArraySDKCxx/app}/AcquireIntersonArrayBMode.cxx (100%) rename {app => Interson/IntersonArraySDKCxx/app}/AcquireIntersonArrayBMode.xml (100%) rename {app => Interson/IntersonArraySDKCxx/app}/AcquireIntersonArrayRF.cxx (100%) rename {app => Interson/IntersonArraySDKCxx/app}/AcquireIntersonArrayRF.xml (100%) rename {app => Interson/IntersonArraySDKCxx/app}/CMakeLists.txt (100%) rename {app => Interson/IntersonArraySDKCxx/app}/PrintIntersonArrayProbeInfo.cxx (100%) rename {app => Interson/IntersonArraySDKCxx/app}/PrintIntersonArrayProbeInfo.xml (100%) rename {doc => Interson/IntersonArraySDKCxx/doc}/CMakeLists.StandardHeader.txt (100%) rename {doc => Interson/IntersonArraySDKCxx/doc}/IntersonArray.StandardHeader.txt (100%) rename {include => Interson/IntersonArraySDKCxx/include}/CMakeLists.txt (100%) rename {include => Interson/IntersonArraySDKCxx/include}/IntersonArrayCxxControlsHWControls.h (100%) rename {include => Interson/IntersonArraySDKCxx/include}/IntersonArrayCxxImagingContainer.h (100%) rename {include => Interson/IntersonArraySDKCxx/include}/IntersonArrayCxxIntersonClass.h (100%) rename {openigtlink => Interson/IntersonArraySDKCxx/openigtlink}/CMakeLists.txt (100%) rename {openigtlink => Interson/IntersonArraySDKCxx/openigtlink}/IntersonArrayServerBMode.cxx (100%) rename {openigtlink => Interson/IntersonArraySDKCxx/openigtlink}/IntersonArrayServerBMode.xml (100%) rename {openigtlink => Interson/IntersonArraySDKCxx/openigtlink}/IntersonArrayServerRF.cxx (100%) rename {openigtlink => Interson/IntersonArraySDKCxx/openigtlink}/IntersonArrayServerRF.xml (100%) rename {src => Interson/IntersonArraySDKCxx/src}/CMakeLists.txt (100%) rename {src => Interson/IntersonArraySDKCxx/src}/IntersonArrayCxxControlsHWControls.cxx (100%) rename {src => Interson/IntersonArraySDKCxx/src}/IntersonArrayCxxImagingContainer.cxx (100%) rename {src => Interson/IntersonArraySDKCxx/src}/IntersonArrayCxxIntersonClass.cxx (100%) rename {test => Interson/IntersonArraySDKCxx/test}/CMakeLists.txt (100%) rename {test => Interson/IntersonArraySDKCxx/test}/IntersonArrayCxxControlsHWControlsTest.cxx (100%) rename {test => Interson/IntersonArraySDKCxx/test}/IntersonArrayCxxImagingContainerTest.cxx (100%) rename {test => Interson/IntersonArraySDKCxx/test}/IntersonArrayCxxIntersonClassTest.cxx (100%) diff --git a/CMakeLists.txt b/Interson/IntersonArraySDKCxx/CMakeLists.txt similarity index 100% rename from CMakeLists.txt rename to Interson/IntersonArraySDKCxx/CMakeLists.txt diff --git a/IntersonArraySDKCxxConfig.cmake.in b/Interson/IntersonArraySDKCxx/IntersonArraySDKCxxConfig.cmake.in similarity index 100% rename from IntersonArraySDKCxxConfig.cmake.in rename to Interson/IntersonArraySDKCxx/IntersonArraySDKCxxConfig.cmake.in diff --git a/Interson/README.md b/Interson/IntersonArraySDKCxx/README.md similarity index 100% rename from Interson/README.md rename to Interson/IntersonArraySDKCxx/README.md diff --git a/README.rst b/Interson/IntersonArraySDKCxx/README.rst similarity index 100% rename from README.rst rename to Interson/IntersonArraySDKCxx/README.rst diff --git a/app/AcquireIntersonArrayBMode.cxx b/Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayBMode.cxx similarity index 100% rename from app/AcquireIntersonArrayBMode.cxx rename to Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayBMode.cxx diff --git a/app/AcquireIntersonArrayBMode.xml b/Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayBMode.xml similarity index 100% rename from app/AcquireIntersonArrayBMode.xml rename to Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayBMode.xml diff --git a/app/AcquireIntersonArrayRF.cxx b/Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayRF.cxx similarity index 100% rename from app/AcquireIntersonArrayRF.cxx rename to Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayRF.cxx diff --git a/app/AcquireIntersonArrayRF.xml b/Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayRF.xml similarity index 100% rename from app/AcquireIntersonArrayRF.xml rename to Interson/IntersonArraySDKCxx/app/AcquireIntersonArrayRF.xml diff --git a/app/CMakeLists.txt b/Interson/IntersonArraySDKCxx/app/CMakeLists.txt similarity index 100% rename from app/CMakeLists.txt rename to Interson/IntersonArraySDKCxx/app/CMakeLists.txt diff --git a/app/PrintIntersonArrayProbeInfo.cxx b/Interson/IntersonArraySDKCxx/app/PrintIntersonArrayProbeInfo.cxx similarity index 100% rename from app/PrintIntersonArrayProbeInfo.cxx rename to Interson/IntersonArraySDKCxx/app/PrintIntersonArrayProbeInfo.cxx diff --git a/app/PrintIntersonArrayProbeInfo.xml b/Interson/IntersonArraySDKCxx/app/PrintIntersonArrayProbeInfo.xml similarity index 100% rename from app/PrintIntersonArrayProbeInfo.xml rename to Interson/IntersonArraySDKCxx/app/PrintIntersonArrayProbeInfo.xml diff --git a/doc/CMakeLists.StandardHeader.txt b/Interson/IntersonArraySDKCxx/doc/CMakeLists.StandardHeader.txt similarity index 100% rename from doc/CMakeLists.StandardHeader.txt rename to Interson/IntersonArraySDKCxx/doc/CMakeLists.StandardHeader.txt diff --git a/doc/IntersonArray.StandardHeader.txt b/Interson/IntersonArraySDKCxx/doc/IntersonArray.StandardHeader.txt similarity index 100% rename from doc/IntersonArray.StandardHeader.txt rename to Interson/IntersonArraySDKCxx/doc/IntersonArray.StandardHeader.txt diff --git a/include/CMakeLists.txt b/Interson/IntersonArraySDKCxx/include/CMakeLists.txt similarity index 100% rename from include/CMakeLists.txt rename to Interson/IntersonArraySDKCxx/include/CMakeLists.txt diff --git a/include/IntersonArrayCxxControlsHWControls.h b/Interson/IntersonArraySDKCxx/include/IntersonArrayCxxControlsHWControls.h similarity index 100% rename from include/IntersonArrayCxxControlsHWControls.h rename to Interson/IntersonArraySDKCxx/include/IntersonArrayCxxControlsHWControls.h diff --git a/include/IntersonArrayCxxImagingContainer.h b/Interson/IntersonArraySDKCxx/include/IntersonArrayCxxImagingContainer.h similarity index 100% rename from include/IntersonArrayCxxImagingContainer.h rename to Interson/IntersonArraySDKCxx/include/IntersonArrayCxxImagingContainer.h diff --git a/include/IntersonArrayCxxIntersonClass.h b/Interson/IntersonArraySDKCxx/include/IntersonArrayCxxIntersonClass.h similarity index 100% rename from include/IntersonArrayCxxIntersonClass.h rename to Interson/IntersonArraySDKCxx/include/IntersonArrayCxxIntersonClass.h diff --git a/openigtlink/CMakeLists.txt b/Interson/IntersonArraySDKCxx/openigtlink/CMakeLists.txt similarity index 100% rename from openigtlink/CMakeLists.txt rename to Interson/IntersonArraySDKCxx/openigtlink/CMakeLists.txt diff --git a/openigtlink/IntersonArrayServerBMode.cxx b/Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerBMode.cxx similarity index 100% rename from openigtlink/IntersonArrayServerBMode.cxx rename to Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerBMode.cxx diff --git a/openigtlink/IntersonArrayServerBMode.xml b/Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerBMode.xml similarity index 100% rename from openigtlink/IntersonArrayServerBMode.xml rename to Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerBMode.xml diff --git a/openigtlink/IntersonArrayServerRF.cxx b/Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerRF.cxx similarity index 100% rename from openigtlink/IntersonArrayServerRF.cxx rename to Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerRF.cxx diff --git a/openigtlink/IntersonArrayServerRF.xml b/Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerRF.xml similarity index 100% rename from openigtlink/IntersonArrayServerRF.xml rename to Interson/IntersonArraySDKCxx/openigtlink/IntersonArrayServerRF.xml diff --git a/src/CMakeLists.txt b/Interson/IntersonArraySDKCxx/src/CMakeLists.txt similarity index 100% rename from src/CMakeLists.txt rename to Interson/IntersonArraySDKCxx/src/CMakeLists.txt diff --git a/src/IntersonArrayCxxControlsHWControls.cxx b/Interson/IntersonArraySDKCxx/src/IntersonArrayCxxControlsHWControls.cxx similarity index 100% rename from src/IntersonArrayCxxControlsHWControls.cxx rename to Interson/IntersonArraySDKCxx/src/IntersonArrayCxxControlsHWControls.cxx diff --git a/src/IntersonArrayCxxImagingContainer.cxx b/Interson/IntersonArraySDKCxx/src/IntersonArrayCxxImagingContainer.cxx similarity index 100% rename from src/IntersonArrayCxxImagingContainer.cxx rename to Interson/IntersonArraySDKCxx/src/IntersonArrayCxxImagingContainer.cxx diff --git a/src/IntersonArrayCxxIntersonClass.cxx b/Interson/IntersonArraySDKCxx/src/IntersonArrayCxxIntersonClass.cxx similarity index 100% rename from src/IntersonArrayCxxIntersonClass.cxx rename to Interson/IntersonArraySDKCxx/src/IntersonArrayCxxIntersonClass.cxx diff --git a/test/CMakeLists.txt b/Interson/IntersonArraySDKCxx/test/CMakeLists.txt similarity index 100% rename from test/CMakeLists.txt rename to Interson/IntersonArraySDKCxx/test/CMakeLists.txt diff --git a/test/IntersonArrayCxxControlsHWControlsTest.cxx b/Interson/IntersonArraySDKCxx/test/IntersonArrayCxxControlsHWControlsTest.cxx similarity index 100% rename from test/IntersonArrayCxxControlsHWControlsTest.cxx rename to Interson/IntersonArraySDKCxx/test/IntersonArrayCxxControlsHWControlsTest.cxx diff --git a/test/IntersonArrayCxxImagingContainerTest.cxx b/Interson/IntersonArraySDKCxx/test/IntersonArrayCxxImagingContainerTest.cxx similarity index 100% rename from test/IntersonArrayCxxImagingContainerTest.cxx rename to Interson/IntersonArraySDKCxx/test/IntersonArrayCxxImagingContainerTest.cxx diff --git a/test/IntersonArrayCxxIntersonClassTest.cxx b/Interson/IntersonArraySDKCxx/test/IntersonArrayCxxIntersonClassTest.cxx similarity index 100% rename from test/IntersonArrayCxxIntersonClassTest.cxx rename to Interson/IntersonArraySDKCxx/test/IntersonArrayCxxIntersonClassTest.cxx