Resolved Application. Autofocus

Discussion in 'Scripting and Programming' started by Igor Bednarek, Jul 9, 2018.

  1. Igor Bednarek

    Igor Bednarek Cyanogen Customer

    Joined:
    Jul 23, 2015
    Messages:
    33
    Hello,

    On an autosave sequence plus scripting, when Application.Autofocus failed (Application.AutofocusStatus=0), the script ends normally but the sequence stops.

    Is there any way to avoid this stop ?

    Thanks

    Regards

    Igor
     
  2. Igor Bednarek

    Igor Bednarek Cyanogen Customer

    Joined:
    Jul 23, 2015
    Messages:
    33
    Hi Doug,

    I did not get any reply on my previous request posted on July 9th :
    A : within a script called via autosave sequence, when Application.Autofocus failed (Application.AutofocusStatus=0), the script ends normally but the sequence stops
    is there any way to avoid this stop ?​

    Furthemre I have another question :
    B : within a script when you call Application. Autofocus, the filter used is the one set on the Exposure Settings dialog box.
    is there any way to change by Scripting the filter used for autofocus ?​

    Thanks for your replies.

    Regards

    Igor
     
  3. Owen Lawrence

    Owen Lawrence Retired Staff

    Joined:
    Oct 1, 2014
    Messages:
    1,397
    Hi Igor,

    A:
    1. Are you using the script within Autosave slots, or are you using it to run Autosave externally?
    2. What do you mean by "The script ends normally"?
    3. Can you please provide a zip archive of your Documents/MaxIm DL 6/Settings folder?
      As well, I'll need a copy of the script(s) you're using,
      and a zip of your MaxIm DL log file from the time the problem occurred.
    I didn't find any obvious reason why an Autosave sequence would stop if Autofocus failed; perhaps there is some other mechanism triggering it to abort that coincides with or caused the Autofocus failure.

    B:

    I didn't test this to be sure, but I believe the Autofocus function merely leaves the filter position alone. Whatever filter is in place at the time Autofocus begins is the filter that will be used. You can control the filter property through script via the CCDCamera object's Filter property. Within an Autosave sequence, the filter is set by the slot being used for the exposure.

    - Owen -
     
  4. Igor Bednarek

    Igor Bednarek Cyanogen Customer

    Joined:
    Jul 23, 2015
    Messages:
    33
    Hi Owen,

    A :

    I didn't find any obvious reason why an Autosave sequence would stop if Autofocus failed

    Yes I agree but this is a fact and what I observed.

    1. I used a script within Autosave slots
    2. The script goes on until the end without 'crashing'

    Please, try to use this part of this script as simple as that :

    [...]

    Application.Autofocus

    Do
    wscript.Sleep 1000
    Loop While Application.AutofocusStatus < 0

    If Application.AutofocusStatus = 0 Then
    MsgBox "WARNING Autofocus failed !"
    Focuser.Move FocuserPosition
    Else
    wscript.echo "AutoFocus Done" & vbCrLf
    End if

    [...]​

    Connect Camera, Telescope and Focuser simulators. Call the script within an Autosave slot in a sequence. The autofocus will fail because use of simulator will not change the shape of stars. You will see that the sequence will stop before the end. I tested that in Maxim DL 6.16, 6.17 and 6.18. Thanks to let me know if you observe the same by testing that.

    B:

    Please try to test as well. The Autofocus function moves filters as in the Exposure Options tab of Focus menu, whatever filter is in place before the autofocus function is called. Unfortunately in the Exposure Options Tab there is no choice to let the "current" filter in place. Thanks to let me know if you observe the same by testing that.

    Regards

    Igor
     
  5. Igor Bednarek

    Igor Bednarek Cyanogen Customer

    Joined:
    Jul 23, 2015
    Messages:
    33
    Hi Owen,

    I found a solution for B.

    In the Obervatory.txt in Settings folder, you must have FocuserFilter1 set to "" in order to autofocus with the current filter in place. If you change this value in the Exposure Options tab of Focus menu (ex. Luminance) you will not be able to change the value to "" in the Exposure Options tab. You will have to change the value in the Obervatory.txt file. I think that it could be a change in a future release of MaximDL : propose "Current" value in the Exposure Options tab in order not to change the current filter in place when autofocusing.

    Regards

    Igor
     
  6. Owen Lawrence

    Owen Lawrence Retired Staff

    Joined:
    Oct 1, 2014
    Messages:
    1,397
    Hi Igor,

    Well the short answer to your original question is, no, there is no way to avoid stopping the sequence on autofocus failure. The autofocus machinery issues a general camera Abort statement in reaction to quite a wide rage of errors. Unfortunately that Abort encompasses autosave exposures, too. It's kind of a reentrant situation, where autosave itself is considered to be a type of "exposure". It's using your script to launch more exposures. The autosave "exposure" gets caught in the cleanup when autofocus aborts what it thinks are its own exposures. I won't say this is desired behaviour, but it's the unintended consequence of a ten year old code structure being used in new sophisticated ways.

    (BTW, I always believed you. I just didn't find anything at first. I since looked harder and found the reason.)

    Not to be uncharitable, I consider your solution for B to be a hack, considering how you must tiptoe around the Exposure Options and edit a file manually. But well done for discovering it! I'll talk to Doug about accepting your enhancement request. There may be implications with filter offsets that we need to consider.

    - Owen -
     
  7. Igor Bednarek

    Igor Bednarek Cyanogen Customer

    Joined:
    Jul 23, 2015
    Messages:
    33
    Hi Owen,

    Thanks for your replies.

    It is a little bit a pity for sequence stop when autofocus failure but I understand the consequence of ten year old code structure being used in new sophisticated ways. I hope that it will change in the future with MaximDl v7 ou v8.

    Of course my proposed solution for B consisting of manually editing a file is a last-resort solution which allows to "restore" the Exposure Options with no specific filter selection.

    Regards

    Igor
     
  8. Owen Lawrence

    Owen Lawrence Retired Staff

    Joined:
    Oct 1, 2014
    Messages:
    1,397
    Hi Igor,

    I discussed both issues with Doug yesterday. Regarding the code structure, we continually improve it, but it's an incremental process that will take a long time. It is too big to simply replace with a new structure. Please accept that it does have our attention. What you're trying to do is not wrong. If you really need to pursue this now, you might be better off writing your own script to do the Autosave, or use a 3rd party product such as ACP and FocusMax.

    Regarding filter selection, in this case you're probably better off leveraging existing features. Generally focusing is done through a single filter (probably a clear filter), and then adjusted according to the table of focus offsets. You only have to go through the trouble of setting up your offsets once. MaxIm DL already takes care of employing them whenever a different filter is selected. In this case we recommend that you set up your Autofocus Exposure Options manually to use the most appropriate filter, set up your filter offsets, and let the system take care of the rest. I hope this makes sense.

    - Owen -
     
  9. Igor Bednarek

    Igor Bednarek Cyanogen Customer

    Joined:
    Jul 23, 2015
    Messages:
    33
    Hi Owen,

    Yes it makes sence :)

    Regards

    Igor
     
  10. WW Ron

    WW Ron Cyanogen Customer

    Joined:
    Nov 8, 2016
    Messages:
    10
    Igor,

    I've been looking for a script such as you have below. I understand there is an issue when the autofocus fails but I'm wondering is the script works when the autofocus is successful. I really have no experience with scripting and can not get your script to run at all as a copy and paste into a .vbs file. Any information would be helpful.

    Ron


    [...]

    Application.Autofocus

    Do
    wscript.Sleep 1000
    Loop While Application.AutofocusStatus < 0

    If Application.AutofocusStatus = 0 Then
    MsgBox "WARNING Autofocus failed !"
    Focuser.Move FocuserPosition
    Else
    wscript.echo "AutoFocus Done" & vbCrLf
    End if

    [...]​
     

Share This Page