Loading devices - Demo camera why doesn't the plugin take a snap?

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

Loading devices - Demo camera why doesn't the plugin take a snap?

SaralaT

Hi all,


I am currently trying to load and initialize the Demo camera on micromanager as a plugin and take a snap shot. I followed the instructions on https://micro-manager.org/wiki/Micro-Manager_Programming_Guide. My code is as below. The plugin runs fine, but goes to the catch section. Why is it that my camera does not take a snap shot? Is there something I am missing? 


Some help is much appreciated! Thanks a a lot!





package SPT_DemoCam_1;


//import libraries here///////////////////
import ij.IJ;
import mmcorej.CMMCore;
import org.micromanager.api.MMPlugin;
import org.micromanager.api.ScriptInterface;

/**
 *
 * @author Sarala
 */
public class SPT_DemoCam_1 implements MMPlugin{
    //do all initializations here//////////////
    CMMCore core = new CMMCore();
          

    @Override
    public void dispose() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setApp(ScriptInterface si) {
        //write code here///////////////////////////////////////////////////
        try {
         core.loadDevice("Camera", "DemoCamera", "DCam");
         IJ.log("load device step done");
         core.initializeDevice("Camera");
         IJ.log("load initialize step done");

         core.setExposure(50);
         core.snapImage();
         if (core.getBytesPerPixel() == 1) {
            // 8-bit grayscale pixels
            byte[] img = (byte[])core.getImage();
            IJ.log("Image snapped, " + img.length + " pixels total, 8 bits each.");
            IJ.log("Pixel [0,0] value = " + img[0]);
         } else if (core.getBytesPerPixel() == 2){
            // 16-bit grayscale pixels
            short[] img = (short[])core.getImage();
            IJ.log("Image snapped, " + img.length + " pixels total, 16 bits each.");
            IJ.log("Pixel [0,0] value = " + img[0]);             
         } else {
            IJ.log("Dont' know how to handle images with " +
                  core.getBytesPerPixel() + " byte pixels.");             
         }
      } catch (Exception e) {
         //System.out.println(e.getMessage());
         IJ.log("Went into catch!");
         ////System.exit(1);
     }      
                
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void show() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getDescription() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getInfo() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getVersion() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getCopyright() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}


Best Regards,

Sarala


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

Kyle Douglass
Hi Sarala,


On 10/06/2017 09:18 AM, Sarala Neomi Tantirimudalige wrote:
> The plugin runs fine, but goes to the catch section. Why is it that my
> camera does not take a snap shot?

Did you check the Micro-Manager log file for the error message? This
might indicate what the problem is.

See one of my previous e-mails about enabling logging.

Cheers,
Kyle

--
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

SaralaT

Hi Kyle,


I tried to enable the log by going to Tools>options> and then ticked the enable debug log


But still I do not seem to see a log on what is going on when I run the plugin. Still the plugin goes into catch statement and does not take a snap shot as required..


How can I get the log active?


Thanks a lot!


Best Regards,

Sarala


From: Kyle Douglass <[hidden email]>
Sent: Friday, October 6, 2017 9:15:28 PM
To: [hidden email]
Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
 
Hi Sarala,


On 10/06/2017 09:18 AM, Sarala Neomi Tantirimudalige wrote:
> The plugin runs fine, but goes to the catch section. Why is it that my
> camera does not take a snap shot?

Did you check the Micro-Manager log file for the error message? This
might indicate what the problem is.

See one of my previous e-mails about enabling logging.

Cheers,
Kyle

--
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

Kyle Douglass

Hi Sarala,


But still I do not seem to see a log on what is going on when I run the plugin. Still the plugin goes into catch statement and does not take a snap shot as required..

How can I get the log active?


The logs are text files that are stored in the Micro-Manager root directory. On my Windows machine using Micro-Manager 2.0, they are stored in:

C:\Program Files\Micro-Manager-2.0beta\CoreLogs

Try looking in a similar directory on your machine for the core logs. I cannot guarantee that it will be easy to find the relevant error messages because everything gets dumped into the logs, but if you know the approximate time that the error occurred, then you should be able to find it with a little bit of work.

Cheers,
Kyle
-- 
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

SaralaT
In reply to this post by SaralaT



> Hi Kyle,
>
>
> I figured it out! Okay so I took a look at the CoreLog files inside Micromanager CoreLogs folder. Currently my micromanager starts up using cfg file which has the Demo camera loaded onto micromanager.
> Then I go on to activate the plugin (the Java code is in my very first email).
> The complete CoreLog is attached in this email. (i couldn't attach as it was deemed too big..)

> I do not know what the error is yet, but is this the problem area..? Would be great if you could help me identify what's wrong!
> <a href="tel:2017-10-10">2017-10-10T13:29:<a href="tel:28.497677">28.497677 tid7296 [IFO,App] Plugin command: SPT DemoCam 1
>
> <a href="tel:2017-10-10">2017-10-10T13:29:<a href="tel:28.537625">28.537625 tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with uncaught exception
>
> <a href="tel:2017-10-10">2017-10-10T13:29:<a href="tel:28.537625">28.537625 tid7296 [IFO,App] java.lang.UnsupportedOperationException: Not supported yet.
>
> <a href="tel:2017-10-10">2017-10-10T13:29:<a href="tel:28.537625">28.537625 tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show(SPT_DemoCam_1.java:75)
>
>
> Thanks a lot!
>
>
>
> Best Regards,
>
> Sarala
>
> From: Sarala Neomi Tantirimudalige
> Sent: Tuesday, October 10, 2017 11:06:23 AM
> To: [hidden email]
> Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
>
>  Hi Kyle,
>
>
> I tried to enable the log by going to Tools>options> and then ticked the enable debug log
>
>
> But still I do not seem to see a log on what is going on when I run the plugin. Still the plugin goes into catch statement and does not take a snap shot as required..
>
>
> How can I get the log active?
>
>
> Thanks a lot!
>
>
> Best Regards,
>
> Sarala
>
> From: Kyle Douglass <[hidden email]>
> Sent: Friday, October 6, 2017 9:15:28 PM
> To: [hidden email]
> Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
>
>  Hi Sarala,
>
>
> On 10/06/2017 09:18 AM, Sarala Neomi Tantirimudalige wrote:
> > The plugin runs fine, but goes to the catch section. Why is it that my
> > camera does not take a snap shot?
>
> Did you check the Micro-Manager log file for the error message? This
> might indicate what the problem is.
>
> See one of my previous e-mails about enabling logging.
>
> Cheers,
> Kyle
>
> --
> Kyle M. Douglass, PhD
> Post-doctoral researcher
> The Laboratory of Experimental Biophysics
> EPFL, Lausanne, Switzerland
> http://kmdouglass.github.io
> http://leb.epfl.ch
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

Hi Kyle,


I figured it out! Okay so I took a look at the CoreLog files inside Micromanager CoreLogs folder. Currently my micromanager starts up using cfg file which has the Demo camera loaded onto micromanager. 


Then I go on to activate the plugin (the Java code is in my very first email). 


The complete CoreLog is attached in this email. 


I do not know what the error is yet, but is this the problem area..? Would be great if you could help me identify what's wrong! 


2017-10-10T13:29:28.497677 tid7296 [IFO,App] Plugin command: SPT DemoCam 1
2017-10-10T13:29:28.537625 tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with uncaught exception
2017-10-10T13:29:28.537625 tid7296 [IFO,App] java.lang.UnsupportedOperationException: Not supported yet.
2017-10-10T13:29:28.537625 tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show(SPT_DemoCam_1.java:75)

Thanks a lot!



Best Regards,

Sarala


From: Sarala Neomi Tantirimudalige
Sent: Tuesday, October 10, 2017 11:06:23 AM
To: [hidden email]
Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
 

Hi Kyle,


I tried to enable the log by going to Tools>options> and then ticked the enable debug log


But still I do not seem to see a log on what is going on when I run the plugin. Still the plugin goes into catch statement and does not take a snap shot as required..


How can I get the log active?


Thanks a lot!


Best Regards,

Sarala


From: Kyle Douglass <[hidden email]>
Sent: Friday, October 6, 2017 9:15:28 PM
To: [hidden email]
Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
 
Hi Sarala,


On 10/06/2017 09:18 AM, Sarala Neomi Tantirimudalige wrote:
> The plugin runs fine, but goes to the catch section. Why is it that my
> camera does not take a snap shot?

Did you check the Micro-Manager log file for the error message? This
might indicate what the problem is.

See one of my previous e-mails about enabling logging.

Cheers,
Kyle

--
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

Kyle Douglass
Hi Sarala,


I do not know what the error is yet, but is this the problem area..? Would be great if you could help me identify what's wrong! 

2017-10-10T13:29:28.497677 tid7296 [IFO,App] Plugin command: SPT DemoCam 1
2017-10-10T13:29:28.537625 tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with uncaught exception
2017-10-10T13:29:28.537625 tid7296 [IFO,App] java.lang.UnsupportedOperationException: Not supported yet.
2017-10-10T13:29:28.537625 tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show(SPT_DemoCam_1.java:75)


Unfortunately I do not know what the problem is. I think that from here you might need to do some investigating since you are more familiar with your code and what you are trying to do than I am. Here are some strategies that I often use to try to solve problems like these (in case you haven't tried one of them yet):

1. Google the error messages. For example, what sorts of errors raise the "java.lang.UnsupportedOperationException"? Is it possible that your code is causing the same error? You would be surprised how much of a programmer's time is spent on Google or Stack Overflow :)

2. Try to remove everything from your code little-by-little until it compiles and works. Then, add back the parts that you want until it breaks. This might help you isolate the location of the problem.

3. What IDE are you using? Netbeans? If so, read or watch a tutorial on how its debugger works, then use it to step through your plugin's execution line-by-line until you find the line that raises the error.

I can't guarantee any of these strategies will work, but they might at least help you better identify the cause of the problem so you can write a more specific question. In my experience, the more specific the question, the more likely it is to get answered on the help list.

A really great resource on crafting a good question for the list is from Stack Overflow: https://stackoverflow.com/help/how-to-ask

I'm sorry that I can't provide a more direct response to your problem. Don't be afraid to write back to the list once you've done a bit of investigating!

Cheers,
Kyle

-- 
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

SaralaT
Hi Kyle,

Thanks a lot for your response! I will try investigating a bit more! :) and get back to you. Thanks for the tips amd motivation

Sarala

Sent from my Sony Xperia™ smartphone

---- Kyle Douglass wrote ----

Hi Sarala,


I do not know what the error is yet, but is this the problem area..? Would be great if you could help me identify what's wrong! 

2017-10-10T13:29:28.497677 tid7296 [IFO,App] Plugin command: SPT DemoCam 1
2017-10-10T13:29:28.537625 tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with uncaught exception
2017-10-10T13:29:28.537625 tid7296 [IFO,App] java.lang.UnsupportedOperationException: Not supported yet.
2017-10-10T13:29:28.537625 tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show(SPT_DemoCam_1.java:75)


Unfortunately I do not know what the problem is. I think that from here you might need to do some investigating since you are more familiar with your code and what you are trying to do than I am. Here are some strategies that I often use to try to solve problems like these (in case you haven't tried one of them yet):

1. Google the error messages. For example, what sorts of errors raise the "java.lang.UnsupportedOperationException"? Is it possible that your code is causing the same error? You would be surprised how much of a programmer's time is spent on Google or Stack Overflow :)

2. Try to remove everything from your code little-by-little until it compiles and works. Then, add back the parts that you want until it breaks. This might help you isolate the location of the problem.

3. What IDE are you using? Netbeans? If so, read or watch a tutorial on how its debugger works, then use it to step through your plugin's execution line-by-line until you find the line that raises the error.

I can't guarantee any of these strategies will work, but they might at least help you better identify the cause of the problem so you can write a more specific question. In my experience, the more specific the question, the more likely it is to get answered on the help list.

A really great resource on crafting a good question for the list is from Stack Overflow: https://stackoverflow.com/help/how-to-ask

I'm sorry that I can't provide a more direct response to your problem. Don't be afraid to write back to the list once you've done a bit of investigating!

Cheers,
Kyle

-- 
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

Nico Stuurman-2
In reply to this post by SaralaT


On 10/9/2017 11:22 PM, Sarala Neomi Tantirimudalige wrote:
> I do not know what the error is yet, but is this the problem area..? Would be great if you could help me identify what's wrong!
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.497677">28.497677 tid7296 [IFO,App] Plugin command: SPT DemoCam 1
>
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.537625">28.537625 tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with uncaught exception
>
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.537625">28.537625 tid7296 [IFO,App] java.lang.UnsupportedOperationException: Not supported yet.
>
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.537625">28.537625 tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show(SPT_DemoCam_1.java:75)

So, look at line 75 of your SPT_DemoCam code.  Most likely, one of the functions defined in the interface was called, and you have not changed the boilerplate code yet.

Best,

Nico


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

SaralaT

Hi Nico and Kyle,


So I went line by line and changed some code, now the following works without going to catch. But when I run the plugin, shouln't the democam get switched on and come in a separate window and  take a snap? (Like what would happen if I pressed "snap" button on micromanager window?)


Am I missing something important in my code?


Would be great to get some feed back! Thanks a lot!





package DemoCam_snap_1;

import org.micromanager.api.MMPlugin;
import org.micromanager.api.ScriptInterface;
import mmcorej.CMMCore;
import ij.IJ;


public class DemoCam_snap_1 implements MMPlugin {
    
    CMMCore core = new CMMCore();
    
   // Provides access to the Micro-Manager Java API (for GUI control and high-
   // level functions).
   private ScriptInterface app_;
   
    @Override
    public void dispose() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setApp(ScriptInterface app) {
        
       
        IJ.log("about to go into the try loop");
        app_ = app;

        try {            
            
         core.loadDevice("Camera", "DemoCamera", "DCam");
         IJ.log("loadDevice done");
         core.initializeDevice("Camera");
         IJ.log("initializeDevice done");
         
         
         core.setProperty("Camera", "Exposure", 20);
         IJ.log("Exposure time set done");
         
         app_.getMMCore().snapImage();
         //core.snapImage();
         IJ.log("snap done");
         
         //At this point shouldn't I see the democam activated on MM as a new window and take a snap? The output on log comes as below;
         //             about to go into the try loop
         //             loadDevice done
         //             initializeDevice done
         //             Exposure time set done
         //             snap done




      } 
       
      catch (Exception e) {
         IJ.log("Went to catch");
         
      }
                
        
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void show() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getDescription() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getInfo() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getVersion() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getCopyright() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
  
    
    
}



Best Regards,

Sarala


From: Nico Stuurman <[hidden email]>
Sent: Tuesday, October 10, 2017 11:07:39 PM
To: Micro-Manager General
Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
 


On 10/9/2017 11:22 PM, Sarala Neomi Tantirimudalige wrote:
> I do not know what the error is yet, but is this the problem area..? Would be great if you could help me identify what's wrong!
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.497677">28.497677 tid7296 [IFO,App] Plugin command: SPT DemoCam 1
>
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.537625">28.537625 tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with uncaught exception
>
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.537625">28.537625 tid7296 [IFO,App] java.lang.UnsupportedOperationException: Not supported yet.
>
> <a moz-do-not-send="true" href="tel:2017-10-10">2017-10-10T13:29:<a moz-do-not-send="true" href="tel:28.537625">28.537625 tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show(SPT_DemoCam_1.java:75)

So, look at line 75 of your SPT_DemoCam code.  Most likely, one of the functions defined in the interface was called, and you have not changed the boilerplate code yet.

Best,

Nico


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

Mahesh Kakuturu
Seems like you created new CMMCore object and loaded device on this object.

CMMCore core = new CMMCore(); // not required

assign the CMMCore object from your ScriptInterface object

CMMCore core;
app_ = app;
core = app.getMMCore();

This is just an idea. If I am wrong Micro-Manager people might help you.

On Wed, Oct 11, 2017 at 2:05 AM, Sarala Neomi Tantirimudalige <[hidden email]> wrote:

Hi Nico and Kyle,


So I went line by line and changed some code, now the following works without going to catch. But when I run the plugin, shouln't the democam get switched on and come in a separate window and  take a snap? (Like what would happen if I pressed "snap" button on micromanager window?)


Am I missing something important in my code?


Would be great to get some feed back! Thanks a lot!





package DemoCam_snap_1;

import org.micromanager.api.MMPlugin;
import org.micromanager.api.ScriptInterface;
import mmcorej.CMMCore;
import ij.IJ;


public class DemoCam_snap_1 implements MMPlugin {
    
    CMMCore core = new CMMCore();
    
   // Provides access to the Micro-Manager Java API (for GUI control and high-
   // level functions).
   private ScriptInterface app_;
   
    @Override
    public void dispose() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setApp(ScriptInterface app) {
        
       
        IJ.log("about to go into the try loop");
        app_ = app;

        try {            
            
         core.loadDevice("Camera", "DemoCamera", "DCam");
         IJ.log("loadDevice done");
         core.initializeDevice("Camera");
         IJ.log("initializeDevice done");
         
         
         core.setProperty("Camera", "Exposure", 20);
         IJ.log("Exposure time set done");
         
         app_.getMMCore().snapImage();
         //core.snapImage();
         IJ.log("snap done");
         
         //At this point shouldn't I see the democam activated on MM as a new window and take a snap? The output on log comes as below;
         //             about to go into the try loop
         //             loadDevice done
         //             initializeDevice done
         //             Exposure time set done
         //             snap done




      } 
       
      catch (Exception e) {
         IJ.log("Went to catch");
         
      }
                
        
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void show() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getDescription() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getInfo() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getVersion() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getCopyright() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
  
    
    
}



Best Regards,

Sarala


From: Nico Stuurman <[hidden email]>
Sent: Tuesday, October 10, 2017 11:07:39 PM
To: Micro-Manager General
Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
 


On 10/9/2017 11:22 PM, Sarala Neomi Tantirimudalige wrote:
> I do not know what the error is yet, but is this the problem area..? Would be great if you could help me identify what's wrong!
> <a href="tel:2017-10-10" target="_blank">2017-10-10T13:29:<a href="tel:28.497677" target="_blank">28.497677 tid7296 [IFO,App] Plugin command: SPT DemoCam 1
>
> <a href="tel:2017-10-10" target="_blank">2017-10-10T13:29:<a href="tel:28.537625" target="_blank">28.537625 tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with uncaught exception
>
> <a href="tel:2017-10-10" target="_blank">2017-10-10T13:29:<a href="tel:28.537625" target="_blank">28.537625 tid7296 [IFO,App] java.lang.UnsupportedOperationException: Not supported yet.
>
> <a href="tel:2017-10-10" target="_blank">2017-10-10T13:29:<a href="tel:28.537625" target="_blank">28.537625 tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show(SPT_DemoCam_1.java:75)

So, look at line 75 of your SPT_DemoCam code.  Most likely, one of the functions defined in the interface was called, and you have not changed the boilerplate code yet.

Best,

Nico


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general




--
Best Regards,
Mahesh Kakuturu
Sr. Software Engineer
Angstrom Science, Inc.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

Nico Stuurman-2
Hi all,

OK, I am an old guy who like to respond in-line, but you are  making
that quite difficult for me...

>
>     So I went line by line and changed some code, now the following
>     works without going to catch. But when I run the plugin, shouln't
>     the democam get switched on and come in a separate window and 
>     take a snap? (Like what would happen if I pressed "snap" button on
>     micromanager window?)
>
>     Am I missing something important in my code?
>
>     Would be great to get some feed back! Thanks a lot!
>
>

> Seems like you created new CMMCore object and loaded device on this
> object.
>
> CMMCore core = new CMMCore(); // not required
>
> assign the CMMCore object from your ScriptInterface object
>
> CMMCore core;
> app_ = app;
> core = app.getMMCore();
>
> This is just an idea. If I am wrong Micro-Manager people might help you.


I agree with Mahesh.  You never want to create a second MMCore object. 
Craziness will ensue.  Just get the core using:

MMCore core = app_.getMMCore();

Also, if you snap an image using the Core, you will need to take the
resulting image and place it in a Window to be displayed yourself. If
you want all that to be taken care of for you, then use the
ScriptInterface, not the core, i.e.:

app_.snapSingleImage();

Best,

Nico



>     package DemoCam_snap_1;
>
>     import org.micromanager.api.MMPlugin;
>     import org.micromanager.api.ScriptInterface;
>     import mmcorej.CMMCore;
>     import ij.IJ;
>
>
>     public class DemoCam_snap_1 implements MMPlugin {
>
>       CMMCore core = new CMMCore();
>
>      // Provides access to the Micro-Manager Java API (for GUI control
>     and high-
>      // level functions).
>      private ScriptInterface app_;
>
>      @Override
>       public void dispose() {
>           throw new UnsupportedOperationException("Not supported
>     yet."); //To change body of generated methods, choose Tools |
>     Templates.
>       }
>
>       @Override
>     public void setApp(ScriptInterface app) {
>
>
>         IJ.log("about to go into the try loop");
>     app_ = app;
>
>           try {
>
>            core.loadDevice("Camera", "DemoCamera", "DCam");
>          IJ.log("loadDevice done");
>          core.initializeDevice("Camera");
>          IJ.log("initializeDevice done");
>
>
>          core.setProperty("Camera", "Exposure", 20);
>          IJ.log("Exposure time set done");
>
>          app_.getMMCore().snapImage();
>          //core.snapImage();
>          IJ.log("snap done");
>
>     //At this point shouldn't I see the democam activated on MM as a
>     new window and take a snap? The output on log comes as below;
>              //             about to go into the try loop
>              //             loadDevice done
>              //             initializeDevice done
>              //             Exposure time set done
>              //             snap done
>
>
>
>
>       }
>
>       catch (Exception e) {
>          IJ.log("Went to catch");
>
>         }
>
>
>           //throw new UnsupportedOperationException("Not supported
>     yet."); //To change body of generated methods, choose Tools |
>     Templates.
>       }
>
>       @Override
>       public void show() {
>           throw new UnsupportedOperationException("Not supported
>     yet."); //To change body of generated methods, choose Tools |
>     Templates.
>       }
>
>       @Override
>       public String getDescription() {
>           throw new UnsupportedOperationException("Not supported
>     yet."); //To change body of generated methods, choose Tools |
>     Templates.
>       }
>
>       @Override
>       public String getInfo() {
>           throw new UnsupportedOperationException("Not supported
>     yet."); //To change body of generated methods, choose Tools |
>     Templates.
>       }
>
>       @Override
>       public String getVersion() {
>           throw new UnsupportedOperationException("Not supported
>     yet."); //To change body of generated methods, choose Tools |
>     Templates.
>       }
>
>       @Override
>       public String getCopyright() {
>           throw new UnsupportedOperationException("Not supported
>     yet."); //To change body of generated methods, choose Tools |
>     Templates.
>       }
>
>
>
>
>     }
>
>
>
>     Best Regards,
>
>     Sarala
>
>     ------------------------------------------------------------------------
>     *From:* Nico Stuurman <[hidden email]
>     <mailto:[hidden email]>>
>     *Sent:* Tuesday, October 10, 2017 11:07:39 PM
>     *To:* Micro-Manager General
>     *Subject:* Re: [micro-manager-general] Loading devices - Demo
>     camera why doesn't the plugin take a snap?
>
>
>     On 10/9/2017 11:22 PM, Sarala Neomi Tantirimudalige wrote:
>>     > I do not know what the error is yet, but is this the problem
>>     area..? Would be great if you could help me identify what's wrong!
>>     > 2017-10-10 <tel:2017-10-10>T13:29:28.497677 <tel:28.497677>
>>     tid7296 [IFO,App] Plugin command: SPT DemoCam 1
>>     >
>>     > 2017-10-10 <tel:2017-10-10>T13:29:28.537625 <tel:28.537625>
>>     tid7296 [IFO,App] Thread 18 (AWT-EventQueue-0) terminated with
>>     uncaught exception
>>     >
>>     > 2017-10-10 <tel:2017-10-10>T13:29:28.537625 <tel:28.537625>
>>     tid7296 [IFO,App] java.lang.UnsupportedOperationException
>>     <http://java.lang.UnsupportedOperationException>: Not supported yet.
>>     >
>>     > 2017-10-10 <tel:2017-10-10>T13:29:28.537625 <tel:28.537625>
>>     tid7296 [IFO,App]   at SPT_DemoCam_1.SPT_DemoCam_1.show
>>     <http://1.show>(SPT_DemoCam_1.java:75 <http://1.java:75>)
>
>     So, look at line 75 of your SPT_DemoCam code. Most likely, one of
>     the functions defined in the interface was called, and you have
>     not changed the boilerplate code yet.
>
>     Best,
>
>     Nico
>
>
>     ------------------------------------------------------------------------------
>     Check out the vibrant tech community on one of the world's most
>     engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>     _______________________________________________
>     micro-manager-general mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/micro-manager-general
>     <https://lists.sourceforge.net/lists/listinfo/micro-manager-general>
>
>
>
>
> --
> Best Regards,
> Mahesh Kakuturu
> Sr. Software Engineer
> Angstrom Science, Inc.
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

--
Nico Stuurman
Vale lab, UCSF/HHMI
Genentech Hall, N316, MC2200
600 - 16th Street
San Francisco, CA 94158-2517
415 707 9488
[hidden email]


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

Karl Bellve-3


On Wed, Oct 11, 2017 at 2:13 PM Nico Stuurman <[hidden email]> wrote:
Hi all,

OK, I am an old guy who like to respond in-line, but you are  making
that quite difficult for me...


That made me chuckle. 

1) Old Guy...sorry, but that is me. :D 

2) In the past, I think you would have ranted against top posting. This was a mild rebuke in comparison.  :D 


Cheers Karl



Karl Bellvé
Biomedical Imaging Group
Molecular Medicine
University of Massachusetts Medical School


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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: Loading devices - Demo camera why doesn't the plugin take a snap?

SaralaT

Hi Nico, Kyle and Mahesh,


Thanks a lot for the ideas and help! I finally got the demo camera to take a snap! It so happens that since I am using the cfg with the democamera initialized, i don't need to do the loading or initialization at all! So now my code is as follow (to help other newbies like my self if they are stuck); 



package DemoCam_snap_1;

import org.micromanager.api.MMPlugin;
import org.micromanager.api.ScriptInterface;
import mmcorej.CMMCore;
import ij.IJ;


public class DemoCam_snap_1 implements MMPlugin {
    
   
   // Provides access to the Micro-Manager Java API (for GUI control and high-
   // level functions).
   private ScriptInterface app_;
   // Provides access to the Micro-Manager Core API (for direct hardware
   // control)
   private CMMCore core_;
    

    @Override
    public void dispose() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setApp(ScriptInterface app) {
        
             
      app_ = app;
      core_ = app.getMMCore();
             
        IJ.log("about to go into the try loop");
        
        try {  
         
         core_.setProperty("Camera", "Exposure", 20);
         IJ.log("Exposure time set done");  
         
         app_.snapSingleImage();        
         IJ.log("snap done");
         
         
      } 
       
      catch (Exception e) {
         IJ.log("Went to catch");
         //System.out.println(e.getMessage());
         //System.exit(1);
      }
        
        
        
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void show() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getDescription() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getInfo() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getVersion() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String getCopyright() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }  
}



Okay! Now to the next steps  :)  Thanks again guys!



Best Regards,

Sarala


From: Karl Bellve <[hidden email]>
Sent: Thursday, October 12, 2017 2:40:27 AM
To: Micro-Manager General
Subject: Re: [micro-manager-general] Loading devices - Demo camera why doesn't the plugin take a snap?
 


On Wed, Oct 11, 2017 at 2:13 PM Nico Stuurman <[hidden email]> wrote:
Hi all,

OK, I am an old guy who like to respond in-line, but you are  making
that quite difficult for me...


That made me chuckle. 

1) Old Guy...sorry, but that is me. :D 

2) In the past, I think you would have ranted against top posting. This was a mild rebuke in comparison.  :D 


Cheers Karl



Karl Bellvé
Biomedical Imaging Group
Molecular Medicine
University of Massachusetts Medical School


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general