Software Bisque

Take a virtual tour of the Software Bisque campus Watch Steve Bisque discuss the Paramount mount with S&T's Dennis Di Cicco Read the Paramount MYT Review Read about the Paramount Software Suite

New Scripting Hotness
Richard S. Wright Jr.'s Blog

There is a whole bucket of goodness in the new 10.5 update of TheSkyX, and the latest daily build has a new feature that is near and dear to my heart. It's something I've been wanting in TheSkyX myself for quite a while, and a customer came up to me at NEAIC/NEAF this year and asked for it. That was all the impetus I needed to follow through with my threats (to myself) to add this feature to our scripting engine. So here it is:

You can now read/write text files from JavaScript from within TheSkyX!.

But, as the late night TV man says, "But WAIT! There's MORE!"

You can also spit things out to the script result pane while the script is running. No more waiting until the script completes to see the output.

My favorite script is of course my dithering script for when you're doing unguided imaging. All it does is nudge the mount a tiny bit between each exposure (this also provides a free meridian flip between exposures), and it works fantastic with DSLR's when you don't need to guide (either because your exposure lengths are short enough, or when your using ProTrack on a Paramount). I've modified both the OSC version, and one that changes filters for you to incorporate these new capabilities, and they are now distributed with TheSkyX as example scripts (look in /Resources/Common/User/Java Scripts): UnguidedDitherOSC.js and UnguidedDitherWFilters.js. 

These new features are exposed via two new objects in the scripting engine, TextFile, and RunJavaScriptOutput.

Output to the script result pane is trivial. Just call writeLine("some text here"), for example:

RunJavaScriptOutput.writeLine("Starting to do something long and complicated...");

Each call to writeLine() will be a new line of text in the script result pane.

There are a few rules for accessing text files... we had to take some security concerns into consideration, as allowing TCP/IP access to a machine and then giving it access to the hard drive is... well, not always the best of ideas. One must tread carefully. Here's the lowdown:

1. Script output files are always .txt. In fact, .txt is automatically appended to the file name.
2. Script output files cannot be more than 4MB, at which point you simply can't keep appending to them.
3. Script file names can only contain alphanumeric characters.
3. You can only open one file at a time for reading or writing.
4. Script input and output files will only be created in, or read from the folder /ScriptFiles, which is located in your /MyDocuments/TheSkyX Professional Edition (or /Library/Application Support/Software Bisque/TheSkyX Professional Edition on Mac OS X & Linux/Raspberry Pi).

The methods on ScriptedLog are pretty self explanatory (I hope):

bool TextFile.createNew(string);
bool TextFile.openForAppend(string);
bool TextFile.openForRead(string);
string TextFile.readLine(); 
string TextFile.readAll();
bool TextFile.write(string);
void TextFile.close();

For example, the following would open a file called "output.txt", and write some data to it. If the file can't be opened, an error message is displayed in the output pane.

if(!TextFile.createNew("output"))
   RunJavaScriptOutput.writeLine("Could not open output.txt");
else
   {
   TextFile.write("Here's some text\r\n");
   TextFile.close();
   } 

Take a look at the two example scripts for a more elaborate example of using these new features. Until Orchestrate X is completed... this is my favorite way to image!

Oh, and one more thing... Matt and I collaborated a bit to keep the naming consistant with the other scripting objects, and he's made these available to the VB/COM guys on Windows too. Of course JavaScript works everywhere ;-)

Richard

 


Posted 05-29-2016 9:43 AM by Richard Wright

Comments

R.bak wrote re: New Scripting Hotness
on 07-31-2016 10:07 AM

When the update TheSkyX Serious Astronomer?

   

© 2017 Software Bisque, Inc. 862 Brickyard Circle, Golden, CO 80403-8058 USA - phone: +1 303 278 4478 fax: +1 303 278 0045
Google+