Difference between revisions of "CAEngine"
m |
|||
(15 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:ADE Classes]] | [[Category:ADE Classes]] | ||
− | << [[ | + | [[Category:ADE User Guide]] |
+ | <languages /> | ||
+ | <translate> | ||
+ | <!--T:1--> | ||
+ | [[ADE User Guide]] > [[ADE Server Class Reference]] > | ||
− | = class CAEngine (ADE) = | + | = class CAEngine (ADE) = <!--T:2--> |
− | = In-Process and Out-of-Process Instantiations = | + | = In-Process and Out-of-Process Instantiations = <!--T:3--> |
− | = Creation = | + | = Creation = <!--T:4--> |
+ | Use of ADE really starts with the creation of a CAEngine object, from which all else flows. If you are using the ADEW.dll in-process server, you can only create and use one CAEngine instance. If you are using the ADE.exe out-of-process server, you may create as many CAEngine instances as you desire, each one running as a separate process. In web-based applications, a separate CAEngine instance is typically created for each user session. Each CAEngine instance can have one model loaded at a time. | ||
− | === C# === | + | You can either create a CAEngine instance directly, or by calling [[CALicense::NewCAEngine]](). The later method requires you to first create a [[CALicense]] instance, but has the advantage that you can obtain further information about the cause of failure when creation fails. Direct creation of CAEngine will fail if the license to use ADE on the given computer is invalid, expired, etc. |
+ | === C# === <!--T:5--> | ||
− | === Visual Basic.NET === | + | === Visual Basic.NET === <!--T:6--> |
− | === C++ === | + | === C++ === <!--T:7--> |
− | === VBScript === | + | === VBScript === <!--T:8--> |
− | =Properties= | + | =Properties= <!--T:9--> |
− | === {get,put} string [[CAEngine::Command|Command]] === | + | === {get,put} string [[CAEngine::Command|Command]] === <!--T:10--> |
+ | <!--T:11--> | ||
Holds a typescript command that gets executed when the [[CAEngine::Send|Send]]() method is called. | Holds a typescript command that gets executed when the [[CAEngine::Send|Send]]() method is called. | ||
− | === {get,put} [[CAObject]] [[CAEngine::CurrentModule|CurrentModule]] === | + | === {get,put} [[CAObject]] [[CAEngine::CurrentModule|CurrentModule]] === <!--T:12--> |
+ | <!--T:13--> | ||
Newly created objects are placed into [[CurrentModule]]; so, you should set [[CurrentModule]] before | Newly created objects are placed into [[CurrentModule]]; so, you should set [[CurrentModule]] before | ||
creating any new objects. Setting <code>[[CurrentModule]] = Nothing</code> means that no module is open, | creating any new objects. Setting <code>[[CurrentModule]] = Nothing</code> means that no module is open, | ||
so all new objects are created in the top-level Module or Model of the currently opened model. | so all new objects are created in the top-level Module or Model of the currently opened model. | ||
− | === {get,put} [[CARenderingStyle]] [[CAEngine::DefaultDefTableRenderingStyle|DefaultDefTableRenderingStyle]] === | + | === {get,put} [[CARenderingStyle]] [[CAEngine::DefaultDefTableRenderingStyle|DefaultDefTableRenderingStyle]] === <!--T:14--> |
+ | <!--T:15--> | ||
The default rendering style controlling how definition table values are transferred to and from | The default rendering style controlling how definition table values are transferred to and from | ||
ADE. All definition tables returned from [[CAObject::DefTable]] inherits these settings when they | ADE. All definition tables returned from [[CAObject::DefTable]] inherits these settings when they | ||
are first created. | are first created. | ||
− | === {get,put} | + | === {get,put} long [[CAEngine::DefaultEvaluationTimeLimit|DefaultEvaluationTimeLimit]] === <!--T:16--> |
+ | <!--T:17--> | ||
+ | The maximum time limit in milliseconds imposed on evaluations from methods in [[CAEngine]], i.e., [[CAEngine::SendCommand|SendCommand]], [[CAEngine::Send|Send]], [[CAEngine::OpenModel|OpenModel]], and [[CAEngine::AddModule|AddModule]], as well as the default value for [[CAObject::MethodEvaluationTimeLimit]] for any [[CAObject]]s instantiated. A value of zero indicates no time limit. | ||
+ | |||
+ | === {get,put} [[CARenderingStyle]] [[CAEngine::DefaultRenderingStyle|DefaultRenderingStyle]] === <!--T:18--> | ||
+ | |||
+ | <!--T:19--> | ||
The default rendering style controlling how result values are returned from ADE. All [[CAObject]] | The default rendering style controlling how result values are returned from ADE. All [[CAObject]] | ||
instances inherit this rendering style when they are created. | instances inherit this rendering style when they are created. | ||
− | === {get} short int [[CAEngine::ErrorCode|ErrorCode]] === | + | === {get} short int [[CAEngine::ErrorCode|ErrorCode]] === <!--T:20--> |
+ | <!--T:21--> | ||
Returns the error code generated by the last communication with the Analytica Decision Engine | Returns the error code generated by the last communication with the Analytica Decision Engine | ||
Server. The property [[ErrorCode]] should be checked after setting and retrieving critical [[CAEngine]] | Server. The property [[ErrorCode]] should be checked after setting and retrieving critical [[CAEngine]] | ||
Line 46: | Line 62: | ||
successful. | successful. | ||
− | === {get} string [[CAEngine::ErrorText|ErrorText]] === | + | === {get} string [[CAEngine::ErrorText|ErrorText]] === <!--T:22--> |
+ | <!--T:23--> | ||
Short text explanation of error from [[ErrorCode]]. | Short text explanation of error from [[ErrorCode]]. | ||
− | === {get} | + | === {get,put} unsigned long [[CAEngine::Flags|Flags]] === <!--T:24--> |
+ | |||
+ | <!--T:25--> | ||
+ | A bit field of flags that control certain behaviors within ADE. | ||
+ | === {get} string [[CAEngine::Log|Log]] === <!--T:26--> | ||
+ | |||
+ | <!--T:27--> | ||
A record of all commands sent to the ADE typescript and the results received from those commands, | A record of all commands sent to the ADE typescript and the results received from those commands, | ||
when the Photo property is true. | when the Photo property is true. | ||
− | === {get} | + | === {get,put} [[CAEngine::MaxMemoryLimit]] === |
+ | A limit on the amount of total memory usage, in MegaBytes, that the ADE process is allowed to use during computations, or 0 when not set. When exceeded, the computation aborts. | ||
+ | |||
+ | === {get} string [[CAEngine::OutputBuffer|OutputBuffer]] === <!--T:28--> | ||
+ | |||
+ | <!--T:29--> | ||
A text string buffer that contains the result of the last typescript (i.e., using the Command property | A text string buffer that contains the result of the last typescript (i.e., using the Command property | ||
and Send method) interaction with the ADE. | and Send method) interaction with the ADE. | ||
− | === {get,put} bool [[CAEngine::Photo|Photo]] === | + | === {get,put} bool [[CAEngine::Photo|Photo]] === <!--T:30--> |
+ | <!--T:31--> | ||
When '''Photo''' is True, ADE records all typescript commands and results into the [[CAEngine::Log|Log]] property. | When '''Photo''' is True, ADE records all typescript commands and results into the [[CAEngine::Log|Log]] property. | ||
− | =Methods= | + | =Methods= <!--T:32--> |
− | === string [[CAEngine::AddModule|AddModule]](string filePath,bool Merge) === | + | === string [[CAEngine::AddModule|AddModule]](string filePath,bool Merge) === <!--T:33--> |
+ | <!--T:34--> | ||
Adds a module from file fileName into the CurrentModule. The merge parameter currently has | Adds a module from file fileName into the CurrentModule. The merge parameter currently has | ||
no effect and should be set to True. | no effect and should be set to True. | ||
− | === bool [[CAEngine::CloseModel|CloseModel]]() === | + | === bool [[CAEngine::CloseModel|CloseModel]]() === <!--T:35--> |
+ | <!--T:36--> | ||
Closes the model. | Closes the model. | ||
− | === [[CAObject]] [[CAEngine::CreateObject|CreateObject]](string objName, string objType) === | + | === [[CAObject]] [[CAEngine::CreateObject|CreateObject]](string objName, string objType) === <!--T:37--> |
+ | <!--T:38--> | ||
Creates a new Analytica object with identifier objName and class objClass in the CurrentModule | Creates a new Analytica object with identifier objName and class objClass in the CurrentModule | ||
and returns it as a CAObject. | and returns it as a CAObject. | ||
− | === bool [[CAEngine::CreateModel|CreateModel]](string newModelName) === | + | === bool [[CAEngine::CreateModel|CreateModel]](string newModelName) === <!--T:39--> |
+ | <!--T:40--> | ||
Creates a new Analytica model with identifier modelName. | Creates a new Analytica model with identifier modelName. | ||
− | === bool [[CAEngine::DeleteObject|DeleteObject]]( [[CAObject]] aObject ) === | + | === bool [[CAEngine::DeleteObject|DeleteObject]]( [[CAObject]] aObject ) === <!--T:41--> |
+ | <!--T:42--> | ||
Deletes CAObject obj from the current model. | Deletes CAObject obj from the current model. | ||
− | === [[CAObject]] [[CAEngine::Get|Get]](string objName) === | + | === [[CAObject]] [[CAEngine::Get|Get]](string objName) === <!--T:43--> |
+ | <!--T:44--> | ||
Synonymous with [[CAEngine::GetObjectByName|GetObjectByName]]. | Synonymous with [[CAEngine::GetObjectByName|GetObjectByName]]. | ||
− | === [[CAObject]] [[CAEngine::GetObjectByName|GetObjectByName]](string objName) === | + | === [[CAObject]] [[CAEngine::GetObjectByName|GetObjectByName]](string objName) === <!--T:45--> |
+ | <!--T:46--> | ||
Returns an object of type [[CAObject]] for an existing Analytica object with identifier objName. | Returns an object of type [[CAObject]] for an existing Analytica object with identifier objName. | ||
− | === | + | === bool [[CAEngine::MonitorProcess|MonitorProcess]](long pid) === <!--T:47--> |
+ | <!--T:48--> | ||
+ | ''(requires ADE 4.3 or greater)'' Instructs ADE to terminate (kill itself) if the indicated process terminates before it. Useful when debugging code that uses ADE to prevent zombie ADE processes when your code is terminated prematurely without having a chance to correctly release its objects. | ||
+ | |||
+ | === string [[CAEngine::OpenModel|OpenModel]](string filepath) === <!--T:49--> | ||
+ | |||
+ | <!--T:50--> | ||
Reads a model from a disk file and opens it as the current model. | Reads a model from a disk file and opens it as the current model. | ||
− | === bool [[CAEngine::ReadScript|ReadScript]](string filePath) === | + | === bool [[CAEngine::ReadScript|ReadScript]](string filePath) === <!--T:51--> |
+ | <!--T:52--> | ||
Reads and executes an Analytica script file. | Reads and executes an Analytica script file. | ||
− | === void [[CAEngine::ResetError|ResetError]]() === | + | === void [[CAEngine::ResetError|ResetError]]() === <!--T:53--> |
+ | <!--T:54--> | ||
Resets the error code, error text string associated with the error code, and the output buffer to | Resets the error code, error text string associated with the error code, and the output buffer to | ||
default values. This function is normally used internally, but could be useful in other circumstances | default values. This function is normally used internally, but could be useful in other circumstances | ||
as well. | as well. | ||
− | === bool [[CAEngine::SaveModel|SaveModel]](string filePath) === | + | === bool [[CAEngine::SaveModel|SaveModel]](string filePath) === <!--T:55--> |
+ | <!--T:56--> | ||
Saves the model to file «filePath». | Saves the model to file «filePath». | ||
− | === bool [[CAEngine::SaveModuleFile|SaveModuleFile]](string moduleName, string filePath) === | + | === bool [[CAEngine::SaveModuleFile|SaveModuleFile]](string moduleName, string filePath) === <!--T:57--> |
+ | <!--T:58--> | ||
Saves module with identifier «moduleName» into file «filePath». | Saves module with identifier «moduleName» into file «filePath». | ||
− | === bool [[CAEngine::Send|Send]]() === | + | === bool [[CAEngine::Send|Send]]() === <!--T:59--> |
+ | <!--T:60--> | ||
Sends the string contained in the Command property as a command to be executed by ADE. | Sends the string contained in the Command property as a command to be executed by ADE. | ||
See the Analytica Scripting Guide for details of commands and syntax. | See the Analytica Scripting Guide for details of commands and syntax. | ||
− | === bool [[CAEngine::SendCommand|SendCommand]](string command) === | + | === bool [[CAEngine::SendCommand|SendCommand]](string command) === <!--T:61--> |
+ | <!--T:62--> | ||
Sends the string command property as a typescript command to be executed by ADE. See the | Sends the string command property as a typescript command to be executed by ADE. See the | ||
Analytica Scripting Guide for details of commands and syntax. | Analytica Scripting Guide for details of commands and syntax. | ||
+ | |||
+ | === bool [[CAEngine::SetCallbackObject|SetCallbackObject]](IUnknown* pCallbackObj) === <!--T:63--> | ||
+ | |||
+ | <!--T:64--> | ||
+ | ''New to [[Analytica 4.6|ADE 4.6]]'' | ||
+ | |||
+ | <!--T:65--> | ||
+ | You call this to provide an object that implements various callback interfaces, such as [[IAdeUICallbacks]], to enable interaction with end-users while evaluation is in-progress. | ||
+ | |||
+ | |||
+ | =See Also= <!--T:66--> | ||
+ | {| style="margin: 1em auto 1em auto;width: 100%;border:0;table-layout: fixed;" cellpadding=5 | ||
+ | |- style="text-align: center" | ||
+ | | [[ADE Server Class Reference]] <- || [[CAEngine]] || -> [[CAObject]] | ||
+ | </translate> |
Latest revision as of 07:52, 12 December 2016
ADE User Guide > ADE Server Class Reference >
class CAEngine (ADE)
In-Process and Out-of-Process Instantiations
Creation
Use of ADE really starts with the creation of a CAEngine object, from which all else flows. If you are using the ADEW.dll in-process server, you can only create and use one CAEngine instance. If you are using the ADE.exe out-of-process server, you may create as many CAEngine instances as you desire, each one running as a separate process. In web-based applications, a separate CAEngine instance is typically created for each user session. Each CAEngine instance can have one model loaded at a time.
You can either create a CAEngine instance directly, or by calling CALicense::NewCAEngine(). The later method requires you to first create a CALicense instance, but has the advantage that you can obtain further information about the cause of failure when creation fails. Direct creation of CAEngine will fail if the license to use ADE on the given computer is invalid, expired, etc.
C#
Visual Basic.NET
C++
VBScript
Properties
{get,put} string Command
Holds a typescript command that gets executed when the Send() method is called.
{get,put} CAObject CurrentModule
Newly created objects are placed into CurrentModule; so, you should set CurrentModule before
creating any new objects. Setting CurrentModule = Nothing
means that no module is open,
so all new objects are created in the top-level Module or Model of the currently opened model.
{get,put} CARenderingStyle DefaultDefTableRenderingStyle
The default rendering style controlling how definition table values are transferred to and from ADE. All definition tables returned from CAObject::DefTable inherits these settings when they are first created.
{get,put} long DefaultEvaluationTimeLimit
The maximum time limit in milliseconds imposed on evaluations from methods in CAEngine, i.e., SendCommand, Send, OpenModel, and AddModule, as well as the default value for CAObject::MethodEvaluationTimeLimit for any CAObjects instantiated. A value of zero indicates no time limit.
{get,put} CARenderingStyle DefaultRenderingStyle
The default rendering style controlling how result values are returned from ADE. All CAObject instances inherit this rendering style when they are created.
{get} short int ErrorCode
Returns the error code generated by the last communication with the Analytica Decision Engine Server. The property ErrorCode should be checked after setting and retrieving critical CAEngine properties and calling CAEngine methods. An ErrorCode of zero indicates the last action was successful.
{get} string ErrorText
Short text explanation of error from ErrorCode.
{get,put} unsigned long Flags
A bit field of flags that control certain behaviors within ADE.
{get} string Log
A record of all commands sent to the ADE typescript and the results received from those commands, when the Photo property is true.
{get,put} CAEngine::MaxMemoryLimit
A limit on the amount of total memory usage, in MegaBytes, that the ADE process is allowed to use during computations, or 0 when not set. When exceeded, the computation aborts.
{get} string OutputBuffer
A text string buffer that contains the result of the last typescript (i.e., using the Command property and Send method) interaction with the ADE.
{get,put} bool Photo
When Photo is True, ADE records all typescript commands and results into the Log property.
Methods
string AddModule(string filePath,bool Merge)
Adds a module from file fileName into the CurrentModule. The merge parameter currently has no effect and should be set to True.
bool CloseModel()
Closes the model.
CAObject CreateObject(string objName, string objType)
Creates a new Analytica object with identifier objName and class objClass in the CurrentModule and returns it as a CAObject.
bool CreateModel(string newModelName)
Creates a new Analytica model with identifier modelName.
bool DeleteObject( CAObject aObject )
Deletes CAObject obj from the current model.
CAObject Get(string objName)
Synonymous with GetObjectByName.
CAObject GetObjectByName(string objName)
Returns an object of type CAObject for an existing Analytica object with identifier objName.
bool MonitorProcess(long pid)
(requires ADE 4.3 or greater) Instructs ADE to terminate (kill itself) if the indicated process terminates before it. Useful when debugging code that uses ADE to prevent zombie ADE processes when your code is terminated prematurely without having a chance to correctly release its objects.
string OpenModel(string filepath)
Reads a model from a disk file and opens it as the current model.
bool ReadScript(string filePath)
Reads and executes an Analytica script file.
void ResetError()
Resets the error code, error text string associated with the error code, and the output buffer to default values. This function is normally used internally, but could be useful in other circumstances as well.
bool SaveModel(string filePath)
Saves the model to file «filePath».
bool SaveModuleFile(string moduleName, string filePath)
Saves module with identifier «moduleName» into file «filePath».
bool Send()
Sends the string contained in the Command property as a command to be executed by ADE. See the Analytica Scripting Guide for details of commands and syntax.
bool SendCommand(string command)
Sends the string command property as a typescript command to be executed by ADE. See the Analytica Scripting Guide for details of commands and syntax.
bool SetCallbackObject(IUnknown* pCallbackObj)
New to ADE 4.6
You call this to provide an object that implements various callback interfaces, such as IAdeUICallbacks, to enable interaction with end-users while evaluation is in-progress.
See Also
ADE Server Class Reference <- | CAEngine | -> CAObject |
Enable comment auto-refresher