LabVIEW C++ MM wrapper for Nikon Ti2 microscope development

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

LabVIEW C++ MM wrapper for Nikon Ti2 microscope development

nadanai263
Hi Yong,
I'm just wondering how much progress you've made with your C++ wrapper: I'm also interested in the same thing (we control all our scopes using labview and recently got a Ti2 which doesn't work). I'd be happy to help contribute ideas and testing (although my C++ experience is limited). Currently I'm at the same stage as you initially I think: we can control the scope using micromanager, but I cannot make any calls to mmgr_dal_NikonTi2.dll in Labview as I don't know the signature of the functions.

Happy to discuss more if you like.

Best,
Nadanai



<quote author='Micro-Manager mailing list'>
Hi, folks,

I have a project need to control the Nikon Ti2 microscope via LabVIEW
software, and integrated with our lab-made program. Now, I can control the
Ti2 microscope with Micro-Manager (as Fig. 1), and try to write a C++
wrapper program as DLL file to control the Ti2 microscope. I  have already
do some survey and study the information form the Micro-Manager website
(https://micro-manager.org/), and try to figure out how to start. I also
download the latest "micromanager2" and "3rdpartypublic" Micro-Manager
Source Code (https://micro-manager.org/wiki/Micro-Manager_Source_Code).
However, still have some questions want to confirm before I start. I have
list questions as following and want to know are these concept correct or
not, thanks.

*Q1: *
I'm try to write a C++ wrapper program as DLL file to control the Ti2 stage
as the flow chart (*LabVIEW → my dll → mmgr_dal_NikonTi2.dll(Ti2 adapter for
micro-manager) → Ti2_Mic_Driver.dll → Ti2 microscope hardware*). Is this
concept right?

*Q2: *
As shown in Fig. 2, can I write the C++ wrapper project only base on  these
two folders, "MMCore" and "MMDevice", in micromanager2 source code, thanks?

*Q3: *
Based on last question, I only found this website
"https://valelab4.ucsf.edu/~MM/doc/MMCore/html/annotated.html" to illustrate
the above ".cpp" and ".h" files. Is there have any way can find more
information, thanks?

*Q4: *
As shown in Fig. 3. I also can load the "mmgr_dal_NikonTi2.dll(Ti2 adapter
for micro-manager, I guess)" into LabVIEW. Is these means it's feasible to
control the Ti2 directly.

Above are some questions just want to be make sure, thanks.

Fig. 1
<http://micro-manager.3463995.n2.nabble.com/file/t397284/%E5%9C%96%E7%89%872.png>

Fig. 2
<http://micro-manager.3463995.n2.nabble.com/file/t397284/fig2.png>

Fig.3
<http://micro-manager.3463995.n2.nabble.com/file/t397284/fig3.png>



Best,
Yong




--
Sent from: http://micro-manager.3463995.n2.nabble.com/


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

</quote>
Quoted from:
http://micro-manager.3463995.n2.nabble.com/LabVIEW-C-MM-wrapper-for-Nikon-Ti2-microscope-development-tp7589984.html


_____________________________________
Sent from http://micro-manager.3463995.n2.nabble.com



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: LabVIEW C++ MM wrapper for Nikon Ti2 microscope development

Micro-Manager mailing list
Hi, Nadanai,

I'm glad to share my experience about Nikon Ti2 control. There are two wary
I tried so far.

1. One is write the C++ wrapper. To build the development environment and
***.lib file, you have to compile the MMCore.cpp to get MMCore.lib. Then
build your own ***wrapper.dll project to include the MMCore.lib. You also
have to install boost library for vector data type. I write the following
code to load and use the object from mmgr_dal_NikonTi2.dll adaptor. So far,
I only successfully get the adapter name as following figure.

I put the library I used in this project here for your reference.
RL: https://drive.google.com/open?id=1I-IzHcqZSG82ruHAjCg_8NouhpGyLZHa

This way is very complex and coat enormous amounts of time, so I try another
way.

=========================================================
#include "stdafx.h"
#include "MMCore_mywrap.h"

#include <windows.h>
#include <stdio.h>
#include <MMCore.h>
#include <MMDevice.h>



//#include <Error.h>
#include <vector>
//#include <algorithm>
//#include <fstream>
#include <iostream>
//#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include "PluginManager.h"
#include <string.h>
#include <cstring>

using namespace std;

#define EXPORT __declspec (dllexport)

MMCORE_MYWRAP_API int nMMCore_mywrap=0;

MMCORE_MYWRAP_API int fnMMCore_mywrap(void)
{
        return 42;
}

CMMCore_mywrap::CMMCore_mywrap()
{
        return;
}

EXPORT int getDevice_dll(char* input_string, int max_input_string_size )
{
        std::vector<std::string> modules;
        try {
                //if getDeviceAdapterNames was declared as a static member
function
                //modules = CMMCore().getDeviceAdapterNames();

                //if non static member function:
                modules = CMMCore().getDeviceAdapterNames();

        }catch( CMMError ){  //CMMError &e
                //handle the error here
                return -1; //error DEVICE_DUPLICATE_LIBRARY
        }

        string strOutput;

        //change this if your application use other separator(e.g : "\r\n"
or "," or "|")
        string strSeparator(";");
        for(size_t i = 0; i < modules.size(); i++ )
                {
                strOutput += modules[i] + strSeparator;
        }
        //rncpy( input_string, strOutput.c_str() , sizeof(strOutput));
       
strncpy_s(input_string,strlen(input_string),strOutput.c_str(),sizeof(strOutput));
        return strlen(input_string);
}
=========================================================
<http://micro-manager.3463995.n2.nabble.com/file/t397284/1546424359874.png>

2. The other way is join Nikon community, and then applied an account.
URL: http://www.nisdk.net/nisdk?strUserName=Evangelion0130

Once you are approved you can download the SDK. The SDK (Ti2 SDK ver.
1.0.0.68 32bit and Ti SDK ver. 1.0.0.68 64bit) can be found in the Files
section.

Following is my example.
<http://micro-manager.3463995.n2.nabble.com/file/t397284/NikonGUI1.png>

Hope above information can help you. Wish you luck.

Best,
Yong




--
Sent from: http://micro-manager.3463995.n2.nabble.com/


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: LabVIEW C++ MM wrapper for Nikon Ti2 microscope development

nadanai263
In reply to this post by nadanai263
Hi Yong,
Thanks very much for your message, and thanks for sharing your code. Nikon also replied to my request for an SDK, and so I will be able to access those.

In the end, I developed my own workaround as well, which was to call Matlab scripts from Labview. The Matlab code calls MMCore functions. So far this also works well and the interface seems stable enough. But I think the SDK/C++ approach is more direct.

Cheers,
Nadanai


<quote author='Micro-Manager mailing list'>
Hi, Nadanai,

I'm glad to share my experience about Nikon Ti2 control. There are two wary
I tried so far.

1. One is write the C++ wrapper. To build the development environment and
***.lib file, you have to compile the MMCore.cpp to get MMCore.lib. Then
build your own ***wrapper.dll project to include the MMCore.lib. You also
have to install boost library for vector data type. I write the following
code to load and use the object from mmgr_dal_NikonTi2.dll adaptor. So far,
I only successfully get the adapter name as following figure.

I put the library I used in this project here for your reference.
RL: https://drive.google.com/open?id=1I-IzHcqZSG82ruHAjCg_8NouhpGyLZHa

This way is very complex and coat enormous amounts of time, so I try another
way.

=========================================================
#include "stdafx.h"
#include "MMCore_mywrap.h"

#include <windows.h>
#include <stdio.h>
#include <MMCore.h>
#include <MMDevice.h>



//#include <Error.h>
#include <vector>
//#include <algorithm>
//#include <fstream>
#include <iostream>
//#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include "PluginManager.h"
#include <string.h>
#include <cstring>

using namespace std;

#define EXPORT __declspec (dllexport)

MMCORE_MYWRAP_API int nMMCore_mywrap=0;

MMCORE_MYWRAP_API int fnMMCore_mywrap(void)
{
        return 42;
}

CMMCore_mywrap::CMMCore_mywrap()
{
        return;
}

EXPORT int getDevice_dll(char* input_string, int max_input_string_size )
{
        std::vector<std::string> modules;
        try {
                //if getDeviceAdapterNames was declared as a static member
function
                //modules = CMMCore().getDeviceAdapterNames();

                //if non static member function:
                modules = CMMCore().getDeviceAdapterNames();

        }catch( CMMError ){  //CMMError &e
                //handle the error here
                return -1; //error DEVICE_DUPLICATE_LIBRARY
        }

        string strOutput;

        //change this if your application use other separator(e.g : "\r\n"
or "," or "|")
        string strSeparator(";");
        for(size_t i = 0; i < modules.size(); i++ )
                {
                strOutput += modules[i] + strSeparator;
        }
        //rncpy( input_string, strOutput.c_str() , sizeof(strOutput));
       
strncpy_s(input_string,strlen(input_string),strOutput.c_str(),sizeof(strOutput));
        return strlen(input_string);
}
=========================================================
<http://micro-manager.3463995.n2.nabble.com/file/t397284/1546424359874.png>

2. The other way is join Nikon community, and then applied an account.
URL: http://www.nisdk.net/nisdk?strUserName=Evangelion0130

Once you are approved you can download the SDK. The SDK (Ti2 SDK ver.
1.0.0.68 32bit and Ti SDK ver. 1.0.0.68 64bit) can be found in the Files
section.

Following is my example.
<http://micro-manager.3463995.n2.nabble.com/file/t397284/NikonGUI1.png>

Hope above information can help you. Wish you luck.

Best,
Yong




--
Sent from: http://micro-manager.3463995.n2.nabble.com/


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

</quote>
Quoted from:
http://micro-manager.3463995.n2.nabble.com/LabVIEW-C-MM-wrapper-for-Nikon-Ti2-microscope-development-tp7590190p7590192.html


_____________________________________
Sent from http://micro-manager.3463995.n2.nabble.com



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: LabVIEW C++ MM wrapper for Nikon Ti2 microscope development

Micro-Manager mailing list
Hi, Nadanai,

Thanks for your information about Matlab experience and notify.

Best,
Yong



--
Sent from: http://micro-manager.3463995.n2.nabble.com/


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general