GetProcessInfo

Release:

…  • 4.6 •  5.0 •  5.1 •  5.2 •  5.3 •  5.4 •  6.0 •  6.1 •  6.2 •  6.3 •  6.4 •  6.5 •   •  6.6 •  7.0 •  7.1 •  7.2

GetProcessInfo can give you information about the current Analytica or ADE process, such as the user name, the computer name, memory in use, the number of processors available, the number of objects in the model, the operating system it is running on, and a whole lot more.

Types of information

GetProcessInfo returns information about the current Analytica or ADE process from the Windows operating system, according to which of these texts you pass as the «item» parameter:

"Process ID" -- returns the Process ID, or Pid, for the current process.
"Thread ID" -- returns the Id of the Analytica/ADE thread.
"Priority" -- returns the priority of the Analytica/ADE thread. The following values are possible (defined by the Windows operating system):
  • -15 : Idle only
  • -2 : lowest priority
  • -1 : below normal
  • 0 : normal priority
  • 1 : Above normal
  • 2 : Highest priority
  • 15: Critical priority
  • 31: Real-time priority
"Computer Name": The name of this computer. In an Analytica Cloud Platform session, this is the name of the session's container (pod).
"User Name": The login name of the account running the process: the Windows login name, or the Linux user in an Analytica Cloud Platform Linux session.
"User Identity": User name in ACP, or Windows login name in DTA.
"Windows Version"
"Windows SP"
"Windows Build"
"OS Display Name": A full description of the operating system, for diagnostics, e.g. 'Windows 11 Pro edition 10.0 (build 26200)'.
"Host OS": The operating system this process is really running on: 'Windows', or 'Linux' (or 'macOS') when the Windows engine is running under Wine, as it does in an Analytica Cloud Platform Linux session. The AnalyticaPlatform system variable adds the architecture, e.g. 'Linux x64'.
"Host OS Version": A human-readable name for that operating system, e.g. 'Windows 11 Pro edition 10.0 (build 26200)' or 'Debian GNU/Linux 12 (bookworm)'.
"Kernel Version": The operating system kernel version as text, e.g. '10.0.26200' on Windows or '6.6.87' on Linux.
"Wine Version": The Wine version, e.g. '11.0', when the engine is running under Wine, or Null on real Windows. "Windows Version", "Windows SP" and "Windows Build" then describe the Windows that Wine emulates, not the host, and "OS Display Name" names the host, its kernel, the Wine version and the Windows version being emulated. See Which operating system? below.
"Abort Event Object" { ADE only }. Name of global Event object for ADE project that can be used to send ADE a break signal to abort the current computation.
"ENV:«name»": Retrieves the value for the environment variable «name»
"Environment Variables": List of all Environment variables
"Command Line"
"Command line:«option»": The value of a single option from the command line. See the example below.
"Command line parameters": A list of the -- options that appeared on the command line.
"Analytica Path": Full file path to the Analytica.exe, Ade.exe, or Ade.dll file being run.
"Working Set Size"
"Working Set Max"
"Working Set Min"
"Working Set Flags"
"Working Set Peak"
"Private Bytes"
"Total RAM"
"Free RAM"
"Total Virtual"
"Max Address Space"
"Memory Load"
"Total Free Memory"
"Page Fault Count"
"Avail Virtual"
"Processor #": On a multi-core computer, the processor currently running the current evaluation. This changes with time.
"Affinity Mask": A list of which processors the operating system will allow Analytica's evaluation to run on.
"Num Processors": The number of processors the Analytica process is allowed to run on.
"Num Sys Processors": The total number of processors on this computer in the current processor group. Always <=64.
"Num cores": The total number of processors on this computer in all processor groups. (Typically the same as "Num Sys Processors" on computers with 64 cores or less, but can be greater than 64 on very high-end servers).
"User Objects": Number of objects in use (variable nodes, local indexes, etc) by a model
"Total Objects": Number of objects in use including both user objects and built-in system objects.
"Free Objects": Number of free "slots" still available for additional objects.
'UI Language': Returns the language used for the Analytica user interface, "en"=English, "es"=Spanish, etc.
"Application Rect": Returns width, height, top, left, as 4 return values, describing the screen coordinates of the desktop Analytica application window. Returns Null in ADE.
"Desk Rect": Returns width, height, x,y, as 4 return values, describing the rectangle within the desktop application where MDI windows can be. This rectangle starts below the toolbar, and does not include application boundaries.
"Python Environments": returns a list of all discovered Python/conda environment paths
"Python Installations": returns just the base Python installations
"Screenshot": Returns an image of the Analytica desktop application window (at the time the function call is evaluated).
"Current Monitor Rect": Returns width, height, x, y, as 4 return values, describing the screen coordinates of the monitor that the Analytica application window is currently on. Returns Null in ADE.
"Current Monitor Work Rect": Returns width, height, x, y, as 4 return values, describing the work area (excluding taskbar) of the monitor that the Analytica application window is currently on. Returns Null in ADE.
"Number of Monitors": The number of monitors connected to the system.
"Monitor N Rect": Returns width, height, x, y, as 4 return values, describing the screen coordinates of the Nth monitor (1-based). Replace N with any integer from 1 to the value of "Number of Monitors". For example, GetProcessInfo("Monitor 2 Rect") returns the rectangle of the 2nd monitor.
"Monitor N Work Rect": Like "Monitor N Rect" but returns the work area (excluding taskbar) of the Nth monitor. For example, GetProcessInfo("Monitor 1 Work Rect").
"Installed fonts": A list of the names of the fonts installed on this computer -- the same names, in the same order, as on the Font pulldown menu of Set Diagram Style... and Set Node Style.... Also spelled "Fonts" or "Font names". See Which fonts are installed? below.

Examples

Process ID

Knowing the Process ID makes it possible to differentiate between multiple instances of Analytica or ADE in the Windows Task Manager.

GetProcessInfo("Process ID") → 4117

Reading the command line

GetProcessInfo("Command Line") → '"C:\Program Files\Lumina\Analytica.exe" "C:\My Models\Costs.ana"'

See Analytica Command Line for a list of valid command line parameters recognized by Analytica.

Reading a command line option

new in Analytica 7.2

GetProcessInfo("Command line:«option»") returns the value of one option from the command line, so that you do not have to parse the whole command line yourself. Any option that begins with a double minus, --, and that Analytica does not itself recognize, is accepted without an Unrecognized command line parameter warning, so that a library can define command line options of its own. After launching:

Analytica.exe --AssistaURL:"https://aaia.analytica.com/staging" --OpenAssista MyModel.ana

these read as:

GetProcessInfo("Command line:--AssistaURL") → 'https://aaia.analytica.com/staging'
GetProcessInfo("Command line:--OpenAssista") → True
GetProcessInfo("Command line:--NotGiven") → Null
GetProcessInfo("Command line parameters") → ['--AssistaURL', '--OpenAssista']

The value is the text following the option's colon or equal sign. An option present with no value returns True, and an option that is not on the command line returns Null, so a library can distinguish not given from given with no value and from given an empty text. A value is always returned as text, even when it looks like a number, so use ParseNumber when you want a number. When an option is repeated, the last occurrence is reported. The option name is not case-sensitive, and its leading -- (or - or /) can be omitted when you read it.

GetProcessInfo("Command line parameters") returns the list of -- options that were actually present. Since a misspelled -- option is silently ignored rather than reported, this is the way for a launcher or library to confirm that it was passed what it expected.

See Analytica Command Line for the options that Analytica itself recognizes.

Which operating system?

new in Analytica 7.2

In an Analytica Cloud Platform Linux session the Analytica engine runs under Wine, which presents itself to the engine as Windows. The Windows-specific items therefore describe the emulated Windows, while these items describe the real host:

GetProcessInfo("Host OS") → 'Linux'
GetProcessInfo("Host OS Version") → 'Debian GNU/Linux 12 (bookworm)'
GetProcessInfo("Kernel Version") → '6.12.94+'
GetProcessInfo("Wine Version") → '11.0'
GetProcessInfo("Windows Version") → 10
GetProcessInfo("OS Display Name") → 'Debian GNU/Linux 12 (bookworm), kernel 6.12.94+, Wine 11.0 emulating Windows 10 Pro Professional edition 10.0 (build 19045)'

On Windows itself, "Host OS" is 'Windows' and "Wine Version" is Null. A model with a pathway that exists on only one platform can test the AnalyticaPlatform system variable (e.g. AnalyticaPlatform = 'Linux x64'), or GetProcessInfo("Host OS") when the architecture does not matter.

Which fonts are installed?

new in Analytica 7.2

GetProcessInfo("Installed fonts") returns the names of the fonts installed on this computer, as a list of text values:

GetProcessInfo("Installed fonts") → ['@DengXian Light', '@FangSong', …, 'Agency FB', 'Algerian', 'Arial', 'Arial Black', …]

These are the same names, in the same order, that appear on the Font pulldown menu of the Set Diagram Style… and Set Node Style… dialogs, so any of them can be used wherever Analytica expects a font name. The list is sorted alphabetically, ignoring case, and it includes every font the operating system reports — among them symbol fonts such as 'Wingdings', and the vertical (top-to-bottom) variants of East Asian fonts, whose names begin with @.

To test whether a particular font is available:

Local fonts := GetProcessInfo("Installed fonts");
Sum(fonts = 'Cambria') > 0 → True

The item also works in ADE, where it reports the fonts installed on the server.

Reading Environment Variables

Obtain a list of all environment variables:

Index EnvVarName := GetProcessInfo("Environment Variables");
GetProcessInfo("Env:"&EnvVarName)

Getting PID from ADE (C#)

CAEngine ade = new CAEngine();
CAObject V = ade.CreateObject("V", "variable");
V.SetAttribute("definition", "GetProcessInfo(\"Process ID\")");
string pInfoResult = V.Result().ToString();

Aborting an in-progress evaluation in ADE

To abort a computation in ADE, your program must obtain a HANDLE to the abort event object. In order to obtain this, you need to obtain the name of this object from ADE. You get this by calling GetProcessInfo("Abort Event Object"). You then use the Windows Platform SDK routine OpenEvent to get the handle to this object. When you want to abort an in-process computation, you set this event. Generally your application that uses ADE will need to be multi-threaded, so that one thread calls ADE, the other thread detects the signal to abort the computation (the signal might be a user pressing Ctrl+Break, for example).

C++ example:

    /* From first application thread, which uses ADE: */
    #include <windows.h>
    #import "ADE.exe"
    using namespace ADE4;
    ...
    GLOBAL HEVENT hAbort;
    ...
    void main() 
    {
        ...
        CAEngine* pAde = new CAEngine();
        pAde->SendCommand("GetProcessInfo('Abort Event Object')");
        _bstr_t abortObjName = pAde->get_OutputBuffer();
        hAbort = OpenEvent(EVENT_MODIFY_STATE,/*bInherit*/FALSE,abortObjName);
        ...
        CreateThread(..., MonitorForBreak,... );
        CTable* pResult = pAde->Get("X")->ResultTable();  /* Initiate a very long computation */
        if (pAde->get_ErrorCode() == 78) {
             /* The computation was aborted before completion */
             ...
        }
        ...
    }
    
    DWORD WINAPI MonitorForBreak( LPVOID )
    {
         /* This routine detects a signal to break the computation.  Maybe it is a user-keypress,
          * or other UI interaction. */
         if (DetectUserWantsToAbort()) {
             SetEvent(hAbort);                   /* Causes the abort */
         }
    }

Memory Information

The Analytica process that evaluates your model may end up using a lot of memory. The operating system keeps some of that memory in RAM, and swaps some of it out to virtual memory. Accessing RAM is fast, while accessing virtual memory is much slower. Windows makes various tradeoffs with what other programs are running on your computer to decide how much of the Analytica process to keep in RAM. The amount of RAM to devote to Analytica is called its working set. When the working set is much smaller that the available RAM, other applications on your computer will respond well (since they can use that RAM), but Analytica may run slowly. If the working set is close to the amount of available RAM, then Analytica gets to make more use of fast RAM, but other applications, and the Windows UI, may get very slow, since they will then need to switch in and out of memory.

GetProcessInfo("Working Set Max") and GetProcessInfo("Working set Min") return the minimum and maximum working set size, in bytes, currently imposed by Windows on the Analytica process. GetProcessInfo("Working Set Flags") returns an integer containing flags, indicating whether Windows is allowed to alter these limits as the process uses more or less memory. The flags are the following numbers added together:

  • 1 = Analytica is guaranteed at least the minimum working set.
  • 2 = Windows may reduce Analytica's working set below the minimum value when memory demands are high
  • 4 = Windows will not allocate more than the indicated working set max.
  • 8 = Windows may give Analytica more than the Working Set Max when memory demands from other applications is low.

The "Avail Virtual" option returns the number that Windows reports as the theoretical maximum amount of memory available to all processes running on the operating system, including both RAM and page file space. However, the number isn't very meaningful or reliable, as Windows often reports a number that far exceeds the amount of available hard disk space (for example, in Windows x64, a number of 8.8 TeraBytes is reported), and in 32-bit processes on Windows x64, the huge number seems to be wrap at 4GB, resulting in a nonesense (and often very small) number.

Application window coordinates

new in Analytica 6.5

Local (width, height, left, top) := GetProcessInfo( 'Application Rect');

This gets the rectangle, in screen coordinates, of the desktop application. From ADE, or ACP when there is no dual desktop UI running, returns Null.

Local(width, height) := GetProcessInfo('Desk Rect');

This gets the size of the desk, the rectangle within the application where diagram windows, object window, result windows, the outliner, Assista window, etc. reside. This desk rectangle starts below the toolbar. You can also get the location:

Local(width, height, x, y) := GetProcessInfo('Desk Rect');

The x,y location coordinate is relative to the application window.

History

This function was introduced in Analytica 4.0.

See Also

Comments
Loading comments...