hexagon logo

Assign variable, PCdmis or Inspect running?

Hello!

Fast question! Is it possible to assign a variable that will let us know if it is run by pcdmis directly or through inspect (be 0 if run by inspect for example and 1 if run through pcdmis)? Thanks in advance!
  • Good day,

    what do you mean by "run" ? read or write? It doesn't really make a difference, you can't determine from which source a variable was written, you can only read out the content.

    It is also not possible to determine whether a measurement program was started by pcDMIS itself or by automation, if that's what you meant.

    You can maybe create a second variable and write it there if the first one was changed by automation, maybe that will help​.
  • Good day,

    what do you mean by "run" ? read or write? It doesn't really make a difference, you can't determine from which source a variable was written, you can only read out the content.

    It is also not possible to determine whether a measurement program was started by pcDMIS itself or by automation, if that's what you meant.

    You can maybe create a second variable and write it there if the first one was changed by automation, maybe that will help​.


    I want to have 2 applications to run our programs, Pcdmis in operator mode and Inspect. Depending which application is being used to run the program, I want a different outcome. Example (not really what I want it to do but just for reference), if pcdmis runs the routine I have a printed repport and a message to go to the printer and fetch it. If I run it through Inspect I will have a report saved as pdf in the network and a different message.

    To do this with logic commands I would like to have an assignment that recognizes the launcher (pcdmis, inspect, pcdmis in operator mode etc) as it does with the current pcdmis version, pcdmis directory etc.

    Ultimately, I want admins to run pcdmis and operators to run inspect, expecting different outcomes from the same program that "realizes" which app is running it
  • Inspect has an option (in the settings area) to create a temporary copy of the routine rather than run it directly. The temporary routines are saved in the following location...

    C:\Users\ account name\AppData\Local\Temp\Hexagon \Inspect\TempExecutionLocation

    If you turn that setting on, you should be able to use the the GETPROGRAMINFO("PARTPATH") function to distinguish between a routine which is being run from the temporary location and one that isn't. This would therefor provide a way for you to know if the routine was run from Inspect (temporary location) or from Operator mode (usual location). You would need to add something similar to this to each routine...

                ASSIGN/V1=GETPROGRAMINFO("PARTPATH")
                ASSIGN/V2=INDEX(V1,"TempExecutionLocation")
                ASSIGN/RUN_FROM_INSPECT="FALSE"
                IF/V2>0
                  ASSIGN/RUN_FROM_INSPECT="TRUE"
                END_IF/​
    



    This is the Inspect setting that you'd need to turn on...
  • Inspect has an option (in the settings area) to create a temporary copy of the routine rather than run it directly. The temporary routines are saved in the following location...

    C:\Users\ account name\AppData\Local\Temp\Hexagon \Inspect\TempExecutionLocation

    If you turn that setting on, you should be able to use the the GETPROGRAMINFO("PARTPATH") function to distinguish between a routine which is being run from the temporary location and one that isn't. This would therefor provide a way for you to know if the routine was run from Inspect (temporary location) or from Operator mode (usual location). You would need to add something similar to this to each routine...

    ASSIGN/V1=GETPROGRAMINFO("PARTPATH")
    ASSIGN/V2=INDEX(V1,"TempExecutionLocation")
    ASSIGN/RUN_FROM_INSPECT="FALSE"
    IF/V2>0
    ASSIGN/RUN_FROM_INSPECT="TRUE"
    END_IF/​
    



    This is the Inspect setting that you'd need to turn on...
    {"alt":"Click image for larger version Name:\tScreenshot 2022-10-04 110758.png Views:\t0 Size:\t422.8 KB ID:\t521345","data-align":"none","data-attachmentid":"521345","data-size":"custom","height":"539","title":"Screenshot 2022-10-04 110758.png","width":"958"}


    Wow this is indeed cleaver! A followup question if you could please answer me... I will be running this command from within an external subroutine. When inspect runs the copy, does it also do this temp copy for the subroutine?

    I am more interested actually to learn in general how toggling this on makes inspect behaves towards external subroutines
  • I'm not sure. Inspect should make a temporary copy of any routine that is run and all of it's dependent files that have the same name but a different extension. Your subroutine will have a different name than the routine it is being called from so I'm not sure how Inspect would handle that. You could test it out by adding the assignments and an operator comment that displays the RUN_FROM_INSPECT variable to your sub-routine and see what it displays when everything is is executed.
  • I could try this yes! For the moment I just took the "barbarian" route and show what happens to the temporary folder while running my whole program. The program is indeed copied there temporarily but not subroutine :P
  • Do you exit PCDmis when switching between inspect and operator mode? So you have two shortcuts that runs each software? If so, just modify the shortcuts into a script that writes to a text file a 0 when running the inspect shortcut or 1 when running operator mode and have your programs read it and behave accordingly.
  • Do you exit PCDmis when switching between inspect and operator mode? So you have two shortcuts that runs each software? If so, just modify the shortcuts into a script that writes to a text file a 0 when running the inspect shortcut or 1 when running operator mode and have your programs read it and behave accordingly.


    Can be a solution yes, although the less scripting the better due to validation and CSV procedures of my company. What neil.challinor proposed is what I was looking for, really ingenious and indirect method to approach this problem Slight smile