Author Topic: PCL Modules, PJSR language binding: Output parameters, additional Methods  (Read 2936 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2129
    • View Profile
Juan,

- is it possible to write PI Modules that when used from PJSR have more methods than just the constructor and those inherited from Instance?
- is it possible to define read only properties (in PJSR, the parameters show up as RW properties). I would like to be able to produce results that not just the views to which the module has been applied.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2173
  • Join the dark side... we have cookies
    • View Profile
    • http://www.astrophoto.cl
Hi George

What are you trying to do? :)
Since I have no idea about PJSR, I cannot help you with these questions, but maybe I could give you a hint from the PCL side :P
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2129
    • View Profile
Hi Carlos,

I am trying to write a PCL module that does more than just manipulate views. It produces other results as well. And I would like to be able to see them from PJSR.

Take for example the statistics module. Using it from PJSR would be something like:
Code: [Select]
var pStatistics=new Statistics;
pStatististics.executeOn(currentView);
var mean=pStatistics.?????;  //there is no way to get results like the median...

There is no way to access the results produced by the Statistics module from PJSR. I do know there are other ways to compute statistical data. The point I want to make: There is no way for PCL modules (that become usable in PJSR once they are loaded) to deliver results apart from changed images. And for a module that I am currently writing (and then intend to use from PJSR), that would be very handy.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 508
    • View Profile
Hi,

I am not sure I see the issue. I have some code like:
   var targetImage = data.targetView.image;
   var statistics = new ImageStatistics(targetImage);

   ...  statistics.mean ...
   ... statistics.stdDev ...

using the ImageStatistics, that seems to do what you need.

-- bitli







Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2129
    • View Profile
Hi Bitli,


...   var statistics = new ImageStatistics(targetImage);

Yes, this is the "normal" way to do it, with Core JavaScript Objects. My code is trying to do it via one of  the "External Objects" that basically are the normal PI Processing Modules (such as DynamicBackgroundExtraction etc.). BTW, the external object I am trying to use this way is described in http://pixinsight.com/forum/index.php?topic=1791.0. I would like to be able to access the output of the command I exeuted, but there seems to be no way to do this with the output or any other result variable. 

The issue described here is basically the same for any loadable PI module, even the standard processing modules delivered with PI.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2173
  • Join the dark side... we have cookies
    • View Profile
    • http://www.astrophoto.cl
Maybe I'm wrong... if you can initialize the instance of a process, then this object inherits the variables and functions that have been defined there. For example, if there is a function float Median() { return instance.median }, then (using your example) pStatistics.Median() should do the trick. This is a wild shot, since I'm not aware how this have been implemented, just guessing.

Anyway, this may not be the case, since parameters are defined not only as variables in Instance, but also in Process and Instance... so accesing functions could be more tricky.

I'll take a look at that this sunday... please post if you make any experiment :)
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2129
    • View Profile
Carlos,

your advice would be welcome  :). I just dont see how it can be done, for example there is no pcl::MetaParameter subclass that allows to declare "readOnly" parameters, or methods/functions. I am looking forward to your results.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2173
  • Join the dark side... we have cookies
    • View Profile
    • http://www.astrophoto.cl
Geor, if the PJSC has access to Instance's functions, then there is a way to establish read-only parameters. The key is to declare them as private and modify (or call) their values through auxiliary functions. Again, I'll take a look tomorrow at how this is done (today I'm going out of town).
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 6690
    • View Profile
    • http://pixinsight.com/
Hi Georg,

Right now an external process (a process defined in an external module) cannot define custom methods. This is going to change very soon, when I release the next version 1.1 of PCL (the PCL version that ships with 1.6.0 is a transitional release while I finish PCL 1.1).

Custom process methods will be accessible from the JavaScript runtime, just as you have described them, that is just as methods are accessible for core JavaScript objects.

You can however use the current process parameter support to implement custom process properties. Just define one or more parameters that you can use to communicate with your scripts. All process parameters are automatically exposed to PJSR before and after executeOn() and executeGlobal(). Naturally, if you change the values of your instance's parameters in your C++ implementation, the updated values will be visible from JavaScript.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/