MacOS indigo_prop_tool executable

Questions, bug reports, requests for enhancements, etc.
JohanB
Posts: 267
Joined: Thu Apr 21, 2016 5:55 pm

Re: MacOS indigo_prop_tool executable

Post by JohanB »

Hi,

Not sure what you want to accomplish and whether this is helpful, but with a script like the following you can get all property updates in real time, as they occur;

indigo_log("PROPERTY INSPECTOR, monitoring commences...");
indigo_event_handlers.MOUNT_handler = { devices: ["Mount Agent"],
on_update: function(property) { indigo_log("INSPECTOR - MOUNT - " + property.name + " - " + property.state); } };
indigo_event_handlers.GUIDER_handler = { devices: ["Guider Agent"],
on_update: function(property) { indigo_log("INSPECTOR - GUIDER - " + property.name + " - " + property.state); } };
indigo_event_handlers.IMAGER_handler = { devices: ["Imager Agent"],
on_update: function(property) { indigo_log("INSPECTOR - IMAGER - " + property.name + " - " + property.state); } };
indigo_event_handlers.ASTROMETRY_handler = { devices: ["Astrometry Agent"],
on_update: function(property) { indigo_log("INSPECTOR - ASTROM - " + property.name + " - " + property.state); } };

This script logs all property updates as they occur in the system log. So, it does not log the current value, unless it is changed. When you do a "tail -f <log> | grep INSPECTOR" you can isolate the log messages. I found it very helpful for writing other scripts, to understand the flow of things that happen in the system.

To kill the script, you can execute the following (other) script;

indigo_log("PROPERTY INSPECTOR, shutdown monitoring...");
delete indigo_event_handlers.MOUNT_handler;
delete indigo_event_handlers.IMAGER_handler;
delete indigo_event_handlers.GUIDER_handler;
delete indigo_event_handlers.ASTROMETRY_handler;

Regards, Johan
rumen
Posts: 133
Joined: Wed Feb 22, 2017 7:31 pm

Re: MacOS indigo_prop_tool executable

Post by rumen »

You can not make it return immediately.
The thing is that indigo is asynchronous. and changing one property may result in series of property updates over time.
For example you set CCD_EXPOSURE to 10s, you will receive CCD_IMAGE busy update and updates every second and at CCD_EXPOSURE = 0s you will receive CCD_IMAGE = OK update with the image data. And this will also happen with some delay as it takes time to download image and relay it to the client. indigo_prop_tool does not know which property update you are waiting for. I have been thinking of some sort of event waiting like set CCD_EXPOSURE=X and wait for CCD_IMAGE = OK update. But to be honest proptool is intended for debugging and some basic operations from the command line. There has never been a need for such a feature, and it is not so easy to implement. On top of that even now the syntax is quite complicated and adding this functionality for event waiting will make the syntax even more complicated.

BTW What do you want to achieve?
User avatar
elmore
Posts: 76
Joined: Tue Dec 04, 2018 2:34 am

Re: MacOS indigo_prop_tool executable

Post by elmore »

I wrote a shell script utilizing indigo_prop_tool to drive the mount to specified coordinates, select a filter, adjust the focuser for filter optical thickness and temperature, take a sequence of exposures, ...
It is slooow. I now know why, indigo_prop_tool is not intended for this purpose.

So, I need to translate what I wrote into Indigo Script Editor syntax. I have not gotten past square one writing an Indigo Script.

I tried writing a script by running AstroImager and entering a script in the Script Editor tool of Indigo Server within AstroImager. I got a script to say "hello from Astro Imager" on startup.
1. I wanted to add a second line to the script but could not figure out how to do that within the editor in AstroImager. I can only put one line into the script editor.
2. Next I want to go out to the web to pick up an automated SQM reading using wget and place the result into a FITS header. I have a command line tool to fetch and return the value, but I could not figure out how to call a command line executable from an Indigo Script. I expected that java script exec would work, but I got errors as if this were not available. So, I don't know what java script commands work within an Indigo Script and in particular how to do system calls and return values from Indigo Script. What language is an Indigo Script?

I'm sure this will just be a start in Indigo Script programming.
User avatar
Peter Polakovic
Posts: 2696
Joined: Thu Apr 21, 2016 9:38 am

Re: MacOS indigo_prop_tool executable

Post by Peter Polakovic »

So, I need to translate what I wrote into Indigo Script Editor syntax. I have not gotten past square one writing an Indigo Script.
Yep, it is the way to go now :)
1. I wanted to add a second line to the script but could not figure out how to do that within the editor in AstroImager. I can only put one line into the script editor.
Hm, I don't understand... how did you do it?

Screenshot 2021-06-24 at 18.06.46.jpg
Screenshot 2021-06-24 at 18.06.46.jpg (46.07 KiB) Viewed 187 times
User avatar
elmore
Posts: 76
Joined: Tue Dec 04, 2018 2:34 am

Re: MacOS indigo_prop_tool executable

Post by elmore »

I purchased and downloaded Indigo Script Editor.
Saving to a particular name, executing etc. is not at all obvious but I did paste Johan's Property Inspector script and ran it.

What is supposed to happen? Where is the system log file? Can this be adjusted? So much to learn ...

If I were to learn JavaScript, would those instructions run in Indigo Script?
JohanB
Posts: 267
Joined: Thu Apr 21, 2016 5:55 pm

Re: MacOS indigo_prop_tool executable

Post by JohanB »

What platform are you running on? Mac or RPi?
JohanB
Posts: 267
Joined: Thu Apr 21, 2016 5:55 pm

Re: MacOS indigo_prop_tool executable

Post by JohanB »

When you running locally on a Mac, the output of the script goes to the log of application you are running the script in.

Say you started the script in AI....
Screenshot 2021-06-25 at 07.52.32.png
Screenshot 2021-06-25 at 07.52.32.png (370.41 KiB) Viewed 177 times
then the log output of all property changes goes to the AI log, which you can save and inspect.
Screenshot 2021-06-25 at 07.53.02.png
Screenshot 2021-06-25 at 07.53.02.png (177.43 KiB) Viewed 177 times
Personally i run the server on the RPi, where you can find all output in the system log, with "tail -f /var/log/syslog | grep INSPECTOR", which will display the log lines in the terminal.

The purpose of the script is to log all property changes in the system in real-time. This is very handy when writing other, more complex scripts. It shows you what is happening in detail and is very helpful when designing or bug hunting.
JohanB
Posts: 267
Joined: Thu Apr 21, 2016 5:55 pm

Re: MacOS indigo_prop_tool executable

Post by JohanB »

Regarding scripting usage and syntax; it does take a bit of a learning curve to get going. It took me the better part of a weekend to get past the "Hello world" stage and get some basic syntax right. Made a proud post with some basic arithmetic and string functions after that :D

https://bb.cloudmakers.eu/viewtopic.php?f=18&t=613

To get at the Indigo properties of the various agents and object, it may be best to study some of the other scripts that are already on the forum. The good thing is, you can get at any property in the system that is visible in control panel, read its values, track its updates or change its value (for the read/write properties).

Once you get the hang of the basics, it becomes somewhat self-explanatory. One thing you may have to get used to (i had to...) is that all code execution is asynchronous, i.e. you can not wait in the code for something to happen. Once you executed some function or behaviour, you can not wait for the result in the same part of the code (while looping or sleeping), but you'll have to write another event_handler that triggers on the result of whatever it is you executed. The whole thing revolves around event handlers and timers.

Another important thing to know (to save you days of bug hunting...i found out the hard way... :D ), is that all the scripts operate in the same global namespace; when you re-use a variable name in multiple scripts and execute these scripts simultaneously, the scripts will interfere. So it is good practice to prefix your variable names with something script specific to make them unique.

Have fun and don't give up; it is really worth while to have the scripting capability. It allows you to do great and creative things in the system! I started at the same level as you are now and i could write the meridian flip script after a couple of weekends and evenings of playing around.
User avatar
Peter Polakovic
Posts: 2696
Joined: Thu Apr 21, 2016 9:38 am

Re: MacOS indigo_prop_tool executable

Post by Peter Polakovic »

Where is the system log file? Can this be adjusted?
On macOS it is in the server wrapper (e.g. AstroImager) memory. You can see it in the log panel or to save it to a file in Control > Save log. You can also make it more verbose in Preferences > INDIGO > Log level.
If I were to learn JavaScript, would those instructions run in Indigo Script?
Yes, more less :) The language used is "ECMA Script" (more less standardised JavaScript) without browser related features and with INDIGO related features. You can find the bindings here: https://github.com/indigo-astronomy/ind ... /README.md
User avatar
elmore
Posts: 76
Joined: Tue Dec 04, 2018 2:34 am

Re: MacOS indigo_prop_tool executable

Post by elmore »

Sorry I can't get past the first instruction I need to issue.
That is to execute a command line instruction of my own, 'powerup'. This is a script to perform a curl command to power up my devices on a remote PC.
There is an Ecma 'exec' command but I don't seem to be able to make it work from an Indigo Script.
Is this possible?
Post Reply