Professional Documents
Culture Documents
ACEReference ElkSP4
ACEReference ElkSP4
ACE Reference
www.schneider-electric.com
Legal Information
The Schneider Electric brand is the sole property of Schneider Electric Industries SAS. Any
trademarks of Telvent Canada Ltd. or Telvent USA, LLC referred to in this guide are the sole
property of Telvent Canada Ltd. or Telvent USA, LLC. The Schneider Electric brand and
trademarks may not be used for any purpose without the owner's permission, given in writing. This
guide and its content are protected, within the meaning of the applicable copyright and trademark
laws and international conventions. Unless otherwise agreed in writing, you may not reproduce all
or part of this guide on any medium whatsoever without the permission of Telvent Canada Ltd. You
also agree not to establish any hypertext links to this guide or its content. All other rights are
reserved.
© 2016 Telvent Canada Ltd. All rights reserved.
ACE Reference Table of Contents
Table of Contents
1 ACE Introduction.....................................................................................................................................5
1.1 Product Description........................................................................................................................6
1.2 Product Pieces...............................................................................................................................8
1.3 Execution Model.............................................................................................................................9
1.4 Security.........................................................................................................................................11
1.5 Registry Variables.........................................................................................................................11
1.6 Error Messages............................................................................................................................12
1.7 Arbitration States of Multithreaded ACE.......................................................................................16
2 Aceconfig Table.....................................................................................................................................19
2.1 Aceconfig Row Edit: Main Tab......................................................................................................19
2.2 Aceconfig Row Edit: Trigger Configuration Tab............................................................................21
2.3 Aceconfig Row Edit: Input Tab......................................................................................................22
2.4 Job Scheduler Records................................................................................................................25
2.5 Record Fields and Flags...............................................................................................................25
2.6 Output Record Flags....................................................................................................................28
2.7 Types of Execution.......................................................................................................................30
2.8 Disabling and enabling an ACE record.........................................................................................31
2.9 Records Not Executing.................................................................................................................32
3 Using the ACE Summary Window.........................................................................................................33
3.1 Using the ACE Control dialog box................................................................................................34
4 Code Editor............................................................................................................................................36
4.1 Menu Bar......................................................................................................................................37
4.2 Code Editor Toolbar......................................................................................................................42
4.3 Output Grid...................................................................................................................................42
4.4 Using the Project Explorer............................................................................................................43
4.5 Tab Control...................................................................................................................................44
4.6 Intellisense....................................................................................................................................45
4.7 Using Simple/Complex Code View...............................................................................................46
4.8 Launching a debugger from the Code Editor................................................................................47
4.9 ACE Methods...............................................................................................................................48
4.10 ACE Code...................................................................................................................................53
5 Assemblies............................................................................................................................................69
5.1 Compiling from the ACE Editor with added assemblies...............................................................69
5.2 Referencing External Assemblies.................................................................................................69
5.3 Available Assemblies....................................................................................................................70
6 Examples...............................................................................................................................................73
6.1 Dual Inputs...................................................................................................................................73
6.2 Variable Parameters.....................................................................................................................74
6.3 Launching an executable..............................................................................................................77
6.4 Calculating a volume....................................................................................................................77
6.5 try-catch........................................................................................................................................77
6.6 fldget and fldput............................................................................................................................78
6.7 Changing a status point................................................................................................................78
7 Troubleshooting.....................................................................................................................................80
7.1 ACE disabled on failover..............................................................................................................80
7.2 BLT ACE crashes.........................................................................................................................80
3
Table of Contents ACE Reference
4
ACE Reference ACE Introduction
1 ACE Introduction
What’s in This Chapter?
1.1 Product Description............................................................................................................................6
1.4 Security.............................................................................................................................................11
The Application Calculation Engine (ACE) is used to create custom calculations and controls for the
RealTime Service using .NET languages such as Visual Basic (VB).
ACE is run as part of the RealTime service and starts up automatically when the RealTime service starts
up and shuts down when the RealTime service shuts down.
ACE is designed to perform calculations given a set of input parameters. The input parameters can be
any numeric RealTime field, PubSub topic, or constant value. The results, or output, of an ACE
procedure can be written to any RealTime numeric field. When given a RealTime path as input, the
procedure results can automatically set the fresh/stale state of the output field based on the fresh/stale
state of the input parameters.
• Periodically.
• Manually.
ACE is designed to work well with simple calculations that can be done quickly and easily by the server.
ACE optimizes access to the inputs and outputs associated with an aceconfig record, so using the input
and output configuration facilities is recommended. ACE can also support Fldget and Fldput inside
of the ACE routine, but these operations are more expensive.
In general, any operation that is likely to take more than a few milliseconds is not a good candidate for
ACE. ACE is designed to execute 1000’s of aceconfig records per second, thereby averaging less than
1 millisecond per routine. It is easy to see that any operation consuming a lot of time, anything more
than 0.1 milliseconds, has the potential to significantly impact ACE performance. For the most part
database operations are safe. However, something like Thread.Sleep is not safe because it takes a
minimum of 10 milliseconds. File operations should generally be avoided, as well.
It should be noted that these are only guidelines. In general, if you are trying to execute 1000s of
records per second, you do not want any long operations to be performed. However, if these operations
are only performed in rare cases, then it may be acceptable.
5
ACE Introduction ACE Reference
With the new capabilities of ACE, longer operations can be spun off into a different thread if needed.
Unless the user code is careful to manage the threads it is creating, it is possible that ACE will continue
to spawn threads until the ACE Engine has to shut down or the RealTime server fails.
NOTE: All thread management must be done by the user code as the ACE Engine is not aware of any
thread that is executing in user code.
CAUTION: Extreme caution should be used when spawning threads from ACE as the ACE Engine
does not monitor them and therefore it will not know which aceconfig record to disable if
there are problems.
ACE can be used to launch external executables or scripts for large operations. Simply launch them
asynchronously so that other ACE procedures are not affected.
NOTE: It is not possible to run more than one instance of an aceconfig routine at any given time.
Running an instance of an aceconfig routine refers to running both the user code and the
parameters fed into it from the aceconfig record at the same time.
NOTE: The ACE code and aceconfig tables should NEVER be locked or manipulated with the user
code. This will cause ACE to become unresponsive, as it will not be able to update records.
For example, if you added a lock to an aceconfig table in the user code and never removed it, the ACE
engine would be unable to lock this aceconfig table itself, and it would indefinitely wait for the lock to be
removed. The routine that is currently running would then time out and attempt to disable the aceconfig
record, but it would not be able to due to the lock that you had placed on the table. The ACE engine
would then restart, but with the aceconfig record still enabled, the same issue would occur. In this way,
using the user code to add locks to ACE tables will cause ACE to freeze.
ACE is not intended to be used as a soft PLC engine for software routines that are better run in a station
environment. Indiscriminate use of ACE will significantly impact OASyS SCADA performance and may
require additional hardware to improve operating performance.
Equations
ACE allows the user to specify equations and logical expressions for database calculation and control
purposes.
The output point for an aceconfig record can be any database point where the table contains at least
one writable field.
6
ACE Reference ACE Introduction
Language
ACE supports equations and expressions written in:
• Visual Basic
• .NET
• C#
ACE VB is VB.Net, not a restricted form of VB.Net. You can use either VB.Net or C#.
Equation Operators
ACE supports the following mathematical operators and logical operations:
• equal
• less than
• addition
• subtraction
• multiplication
• division
• exponential
• logarithm
• minimum
• maximum
• boolean AND
• boolean OR
• boolean NOT
• logical AND
• logical OR
• logical NOT
Triggering Methods
ACE executes an equation under the following conditions:
• When any of the equation’s input variables has changed value numerically.
7
ACE Introduction ACE Reference
• On startup.
NOTE: If the value of a PubSub topic is non-numeric it cannot trigger an ACE routine. Only use PubSub
topics that have associated numeric values.
Code Validation
ACE validates any equation for syntactical correctness and refuses to execute it unless it has passed
the syntax tests.
RunTime Errors
Any exception thrown by an ACE procedure is trapped by the ACE Engine process. After trapping the
error, the ACE procedure is disabled to prevent further errors from occurring and an alarm is issued.
Security
ACE Configuration and code tables are protected such that only DBconfig or higher authorities are
allowed to modify either ACE code or ACE Configuration.
• ACE Engine
• ACE Configuration
• ACE Editor
• ACE Databases
The ACE Engine runs on the RealTime server as part of the RealTime service and is responsible for
executing the code configured in the ACE Databases. The ACE Engine process is not a critical process
and does not cause a failover if it fails. ACE Engine is designed to always be running and automatically
restarts if it fails. There are only three instances in which ACE Engine can fail:
8
ACE Reference ACE Introduction
• Startup failure - any problem affecting ACE startup causes RealTime to fail.
• Controlled shutdown due to ACE procedure errors - this is an expected shutdown and is used by
ACE to clean up runaway ACE procedures.
• PubSub engine failure - ACE Engine shuts down and restarts thereby trying to re-establish the
connection. If PubSub continues having problems, the RealTime service will shut down.
The ACE Editor no longer supports assigning security to acecode points, this is now done through ADE.
The ACE Editor is a windows form that is installed on ezXOS stations. The ACE Editor allows you to
input ACE code into the system. This editor provides the ability to type in the code, compile it, save it to
the database, load it from the database, and assign security.
The ACE ezXOS displays are used to support configuration of ACE equations. These displays include a
summary display, a database point and field selector and a configuration display.
• The acecode database contains information about the ACE code that runs in ACE Engine and is
shown in the ACE Editor.
• The aceconfig database stores configuration related to execution ACE code. This configuration
includes an output point (if any), frequency of execution, group, dataset, name and the ACE code
record that contains the runtime code.
The ACE BLT components contain functionality that runs on the RealTime server but is meant to support
activities in the ACE Editor. These functions include saving, loading and compiling ACE code.
9
ACE Introduction ACE Reference
The ACE engine operates using two databases: ACE configuration (aceconfig) and ACE code
(acecode). The ACE engine loads the information from the ACE configuration and ACE code databases
into its internal cache on startup. Any further updates are delivered through PubSub. Because of this,
changes to the ACE databases are always quickly reflected in the ACE engine. In addition to the
information storage, there are several threads that perform various functions inside the ACE engine.
The queueing thread reads the ACE configuration records from the internal cache and queues up any
that are ready to be run. This thread iterates through the array of ACE configuration records in the cache
once per execution cycle. The execution cycle is 5 seconds by default but can be configured using the
registry override, EXECUTION_CYCLE.
There are several execution threads, and this varies depending on the number of processing cores
contained on the hardware. These threads run in parallel allowing ACE to scale with hardware
upgrades. The execution threads read from the queue of runnable ACE procedures populated by the
queueing thread. When the execution thread retrieves an ACE procedure from the queue, it runs the
user code associated with that aceconfig record using the configuration retrieved from the queue. If an
output point is defined, the results are written when the code has finished executing.
10
ACE Reference ACE Introduction
Various statistics are kept by the execution threads which are monitored by a monitor thread. The
monitor thread tracks runtimes and thread health and determines when it is time to start or stop threads
or even restart the process. The ACE engine process will restart if an ACE procedure exceeds a
configured runtime timeout. This timeout can be overridden using the registry override,
RUNTIME_TIMEOUT. If an error is encountered during the execution of an ACE record, that ACE record
is marked as disabled. This prevents execution of this record until it is manually re-enabled. ACE
records should only be disabled if they show an exception during execution or if they exceed the
runaway timeout.
The checkin thread simply checks into the process monitor periodically and monitors status updates
from the monitor thread.
1.4 Security
Various security measures are used to ensure that only authorized users are allowed to configure and
modify ACE records.
Security risks are reduced by having group fields in the aceconfig and acecode tables to enforce
SCADA AOR security. To control access, group permissions can be assigned manually to the acecode
records at any time in their life cycle. Aceconfig records inherit their group permissions from their
associated output points. AOR security is also used during configuration to ensure that the user is only
presented with points that they are allowed to view, given their permission groups.
NOTE: A user cannot configure ACE outputs for a point that they do not have permission to view.
Operator AOR is used to filter the ACE points available in the ACE Summary. It is also used to manage
whether or not a user has control permissions for an ACE Configuration point.
Table continued…
11
ACE Introduction ACE Reference
When ACE points are automatically disabled, this file should be reviewed to determine the reasons why.
12
ACE Reference ACE Introduction
Procedure
<OASYSDNARegistry>
<Product Name="ACE">
<Value Name="PROCEDURE_TIMEOUT">1600</Value>
</Product>
</OASYSDNARegistry>
• Run timeout value (WARNING: total ACE execution time for this run (<#> milliseconds) has
exceeded specified limits (<#>)):
<OASYSDNARegistry>
<Product Name="ACE">
<Value Name="RUN_TIMEOUT">1600</Value>
</Product>
</OASYSDNARegistry>
13
ACE Introduction ACE Reference
Procedure
1. To reduce/increase the frequency of the following message, modify the value for
PROCEDURE_TIMEOUT : WARNING: ACE config <AceconfigName> procedure
<AcecodeName> execution time (<#> milliseconds) exceeds maximum (<#>)
2. To reduce/increase the frequency of the following message, modify the value for RUN_TIMEOUT:
WARNING: total ACE execution time for this run (<#> milliseconds) has
exceeded specified limits (<#>)
3. Restart the RealTime service.
The following example uses the toggledebug executable to elevate ACEEngine debug messages to
allow the writing of warning, informational and verbose messages to the ACEEngine log file. In this
example, the Process ID for ACEEngine is 1234. In practice, you will have to use the task manager or
the process list in NMC to determine the Process ID.
NOTE: As indicated in Logging debug levels (Table1‑2), the first toggle enables warning messages,
then info messages, and finally verbose messages. To turn off extra debugging, toggle back to
the default from verbose using the same command.
14
ACE Reference ACE Introduction
If problematic code exists in the user code, ACE may take longer than usual to run a set of ACE
procedure records. If the ACE engine detects a delay (i.e., the user code has run longer than the time
value configured in the RUNAWAY_TIMEOUT registry variable), it will shut itself down and disable the
aceconfig record that is running the user code that is causing the delay. If several aceconfig records are
using the same ACE code, only the first one detected will be disabled. Subsequent iterations may result
in additional aceconfig records being disabled. An alarm and an event are generated every time a
record is disabled.
NOTE: Stopping ACE procedures before they have finished executing may cause problems as the code
will not have fully completed its processing.
ACE will wait up to the time value configured in the SHUTDOWN_TIMEOUT registry variable for ACE
procedures to exit on their own before terminating them. In the event of termination, some database
locks may not be removed from the terminated procedures. ACE handles this bad application state by
restarting the entire process. The database locks held by the ACE engine process are cleared out by the
periodic unlock process when it detects that the ACE engine has shut down. After the database locks
have been removed, the process monitor will restart ACE.
NOTE: When the ACE engine shuts itself down and an alarm is generated, it is recommended to check
the oasErrLog to see which routines have been disabled or prematurely terminated due to the
suspect code that caused the shutdown.
Exceptions that do not disable aceconfig, but log a Warning level message
These errors are logged but do not cause alarms and do not disable aceconfig as they may occur as
part of normal system operations, and they will likely be cleared upon a future aceconfig execution.
Frequent messages that are logged at a Warning level in the ACEEngine.log file:
OASySDNA.RealTime.HighPerformanceDB.VDBException.NOT_MANUAL
OASySDNA.RealTime.HighPerformanceDB.VDBException.OFFSCAN
These errors are logged but do not cause alarms and do not disable aceconfig as they may occur as
part of normal system operations and they will likely be cleared upon a future aceconfig execution.
15
ACE Introduction ACE Reference
OASySDNA.RealTime.HighPerformanceDB.VDBException.DB_LOCKED
OASySDNA.RealTime.HighPerformanceDB.VDBException.OWNING_SYS_NOT_AVAIL
OASySDNA.RealTime.HighPerformanceDB.VDBException.PNT_PRGM_COM_INH
OASySDNA.RealTime.HighPerformanceDB.VDBException.PNT_MMI_COM_INH
OASySDNA.RealTime.HighPerformanceDB.VDBException.PNT_TAG_CLS_INH
OASySDNA.RealTime.HighPerformanceDB.VDBException.PNT_TAG_INH
OASySDNA.RealTime.HighPerformanceDB.VDBException.PNT_TAG_OPN_INH
OASySDNA.RealTime.HighPerformanceDB.VDBException.REC_LOCKED
OASySDNA.RealTime.HighPerformanceDB.VDBException.REMOTE_SEND_FAIL
OASySDNA.RealTime.HighPerformanceDB.VDBException.RTU_LOCAL
OASySDNA.RealTime.HighPerformanceDB.VDBException.TAG_WARNING
OASySDNA.RealTime.ACE.ACEPubSubNoDataException
All exceptions not covered in the previous two sections will disable the aceconfig record and cause an
alarm to be raised.
Exception workaround
ACE will assume that several types of the above exceptions are errors associated with updating the
output point, and it will not disable the aceconfig record when these errors are found. This may be
misleading if the code is directly manipulating database records as through fldput.
In this case, an exception can be thrown and the output point will not be updated, but the aceconfig
record will not be alarmed or disabled. In general, when doing these types of operations, a try-catch
block is needed so that errors can be handled appropriately in the user code. If the error should disable
the aceconfig record, a generic exception object can be used in a throw statement.
16
ACE Reference ACE Introduction
handle running in these two modes and switching between them during failovers, cold starts and
shutdowns. This section discusses how ACE handles arbitration states.
When RealTime starts up it will run the ACEengine process. During the ACE engine startup, PubSub
subscriptions are obtained for the acecode and aceconfig databases as well as for several other
RealTime tables. These subscriptions are used to inform ACE of configuration changes to ACE records
and to keep the input data consistent with the database. A checkin thread runs continuously and
monitors the arbitration state of RealTime. When RealTime has fully started up and has become HOT,
the ACE engine detects this and proceeds with starting up three groups of threads. One of these
threads is a scan thread that checks for ACE procedures that can be run and queues them up. Another
is a group of execution threads that read from this queue and execute the procedures. Monitoring
threads are also started to check for timeouts and deadlocks. While RealTime is HOT, ACE continuously
executes ACE procedures.
In general, enterprise systems have a dual-hosted service that contains a second server running in
STANDBY mode. As such, ACE must recognize when RealTime is running in STANDBY mode and act
accordingly. While operating in STANDBY mode, the ACE engine has most of its threads shut down.
ACE does not execute any ACE procedures while in STANDBY mode. While RealTime is in STANDBY
mode, only the checkin thread runs, which also monitors the arbitration state of RealTime. The ACE
engine sits idle, signalling to the process monitor that it is waiting for the system to become HOT. The
PubSub subscriptions are still active however, so the STANDBY ACE engine still remains up-to-date
with changes to the RealTime aceconfig and acecode databases.
When standing down, ACE checks the arbitration state periodically, at a frequency controlled by the
IDLE_SLEEP timeout. When it detects that the RealTime service is no longer HOT, the ACE engine will
request a shutdown of all threads and stops queuing procedures for execution. The shutdown waits for a
period of time (configured in the SHUTDOWN_TIMEOUT variable) for any running ACE procedures to
complete. Any procedures that are not completed are aborted and the following error message is logged
in the oasErrLog, where <name> is the name of the interrupted record:
Table continued…
17
ACE Introduction ACE Reference
18
ACE Reference Aceconfig Table
2 Aceconfig Table
What’s in This Chapter?
2.1 Aceconfig Row Edit: Main Tab..........................................................................................................19
ACE configuration is done through the Advanced Database Editor (ADE). The ACE Records option is
used to configure ACE procedures for execution on a RealTime database point.
19
Aceconfig Table ACE Reference
20
ACE Reference Aceconfig Table
21
Aceconfig Table ACE Reference
Aceconfig records have three types of input: constant values, PubSub topic strings, and RealTime value
paths. The Value field is used for entering either constants or PubSub topic strings.
The figure below shows the three different input types in an aceconfig record. Each row represents a
different input, which can result in a calculation or issue an event if the input's value changes. Row 1
uses a Path to a point in RealTime; the value of that point in RealTime can trigger an acecode routine or
be used in a calculation. Row 2 uses a PubSub topic string in its calculation; by subscribing to the
PubSub topic, the aceconfig record is re-run whenever the topic string is published to. Row 3 uses a
constant value in its calculation.
22
ACE Reference Aceconfig Table
23
Aceconfig Table ACE Reference
When a PubSub input is used, the record is Enabled. However, even though records are enabled, they
may not be ready to run. Some reasons the PubSub input can be missing information are:
Although an aceconfig record with a PubSub input could currently be missing data, the topic can be
published to at any time. The record is left enabled, and ACE Engine waits for the topic to be published
to. ACE code will not execute if there is not sufficient information, but aceconfig records resume
execution whenever the information for the PubSub input arrives.
When you are looking at the ACE Summary, the default color of the record will remain green because
the record is enabled. However, you will know if the aceconfig record is waiting to execute because a
PubSub input is missing data because:
• The aceconfig record will have the Stale icon on the left side of the display, and the colors will be
inverted (green writing on black).
24
ACE Reference Aceconfig Table
NOTE: The Stale icon overrides the Error icon. If the aceconfig record has been configured to Update
Fresh, the output point will show up as stale.
Alarms are not generated because of missing PubSub input data. However, events are generated for
the following circumstances:
• A publisher that previously existed has been lost for at least one PubSub input.
• All inputs now have publishers when previously this data was missing for at least one PubSub input.
To configure a PubSub input to run on a specific system, you can identify the system name in the
PubSub topic as shown below:
es.realtime.ace.singleruntime
In this case, regardless of the system that ACE is running on, it will subscribe to the PubSub topic on the
specified system, which is es in this case. The value associated with the topic string will be obtained
locally if ACE is running on es, or through ISPS if it is running on a different system.
You can configure a PubSub input so that it runs on whichever system ACE is running by using the
%system% flag. This flag works as a prefix to the PubSub topic string, and causes ACE to subscribe to
the local system. Here is an example:
%system%.realtime.db.analog.ana1.curval
If the system that ACE is running on is main, the string above, will cause a subscription to be made to
the topic main.realtime.db.analog.ana1.curval. When a mode switch occurs, the subscription
will change to the owning system because the system flag has been used.
JSH execution is independent of the trigger types. Thus, to strictly execute based on JSH, all triggers
should be unchecked. However, it is possible to use jsh and other triggers in combination.
To trigger ACE records through JSH, configure a JSH script record that toggles the doRun flag on the
aceconfig record. This can be accomplished by using the code below:
This section describes these fields and how they are modified. All methods for affecting the updates to
these values through ACE code are also discussed. Most of these fields correspond directly to
configuration items contained on the ACE Configuration display.
25
Aceconfig Table ACE Reference
Table continued…
26
ACE Reference Aceconfig Table
Table continued…
27
Aceconfig Table ACE Reference
If the calculation fails, the record is put into error. If the ACE record is flagged to update the fresh status,
the output is set to stale when a calculation fails.
Flags can similarly be changed if a PubSub input has no publisher; the error flag is set to "yes" and the
fresh flag is set to "no". The ACE record needs to be flagged to update the fresh status.
28
ACE Reference Aceconfig Table
When updatefresh is active, ACE examines all of the inputs and calculates the fresh flag for the output
record. The algorithm for each parameter is as follows:
Else
End If
End If
End If
Output.fresh = ANDFresh
Else
Output.fresh = ORFresh
End If
The most significant field that can be modified is the output field itself. Since any numeric field in the
RealTime database can be written to with ACE, there are multiple scenarios that can exist. An output
field may be the RealTime krunch field for a record or it may some other numeric field on such a record
or it may be a numeric field on a non-telemetered record. If ACE is not updating the telemetered field on
29
Aceconfig Table ACE Reference
a record, then only the field written to is modified. As an example, if ACE writes to analog.1.tolerance,
then it is only the field that is updated, even ifupdateFresh is configured to be true. If, however, ACE
instead writes to analog.1.curval, then other fields may be affected.
• input triggered
• alarm triggered
• startup triggered
• interval
• JSH
• manual
These are not independent of each other and a single aceconfig record can exhibit all four types of
execution without reconfiguring.
Input, alarm and startup triggered execution are mutually inclusive tests. Any test that is satisfied and for
which the record is configured causes execution to proceed. In addition, this triggering is independent of
other ACE scheduling and can be combined with any other scheduling mechanism.
Interval execution occurs when ACE is configured with a time interval. As an example, if an aceconfig
record is set to execute every 15 seconds, then it executes every 15 second independent of inputs
changing. The 15 second intervals are set up so that they correspond with top-of-minute boundaries.
Assuming a 5 second execution cycle, every 5 seconds the ACE Engine checks this record to see if the
15 seconds have expired. If not, then the record is ignored. If the time has expired, then the record is
executed and any flag processing needed is performed.
JSH execution is scheduled through the job scheduler in an indirect fashion. The Job Scheduler is used
to schedule C programs of dataBASIC scripts to run at specified moments in time or at specific intervals.
To use JSH for ACE, you simply need to schedule the fnput command passing in the desired aceconfig
record name and the DoRun command string. This causes the DoRun field to get set at that time and
the ACE record will run on the next execution cycle.
Manual execution occurs when the ACE record executes only on user command. This is accomplished
by setting the interval to 0 seconds and clearing the inputTriggered flag. When a record is configured in
this manner, the aceconfig record is never executed. To get it to execute, you must manually set the do
Run flag to true. Whenever the doRun flag on record is set to true, that record will run if it is enabled.
The following chart shows the circumstances that will result in an ACE record being triggered. Note that
points that are triggered on input changes get executed in many different circumstances.
The purpose of an input triggered point is to ensure that the output state always corresponds to the input
state. Therefore, whenever the inputs change, the output must change as well, and any programmed
side-effects must also happen. When the actual code is being run is changed, the routine must be
30
ACE Reference Aceconfig Table
executed to ensure that the current output state matches the inputs. A simple example is a procedure
that adds 2 onto an input. If this code is changed to instead add 4, then the output values for affected
aceconfig records are wrong until they are executed. A similar argument holds for changes to the
aceconfig records themselves.
Input triggered routines are also executed when a server goes HOT. This happens because the past
values are not recorded when a server is not HOT and therefore we have to assume that they might
have changed.
An argument is passed to each ACE procedure when it is run to flag startup situations rather than input
changes. This flag is the runBecauseGoingHot parameter. The chart makes note of when this flag is set.
If you do not want processing to occur in startup scenarios, then this flag can be cleared.
ACE records are automatically disabled when an error occurs during their execution. Thre are three
types of errors: a thrown exception, a configuration error, or a runaway timeout. When the point is
disabled due to a thrown exception an alarm is raised indicating why the point was disabled. A log entry
is also produced for all disabled points.
ACE disables a record if an exception is thrown. Any exception causes the ACE record to fail. This is
usually indicative of a coding error. A prime example would be a division by 0 error.
A configuration error causes the ACE routine to be disabled as well. A configuration error is usually
something wrong with the parameter list. A database point that does not exist, a database point or
31
Aceconfig Table ACE Reference
PubSub topic that is not numeric, or a constant value that is not numeric are examples of configuration
errors that can disable a point. Another error that can disable the ACE routine is using a PubSub topic
that exceeds 200-characters or contains |*|.
NOTE: Records that use a PubSub input that is not currently available are not disabled, but even
though the record remains enabled, it is not executed until new data is published.
When the execution time for an aceconfig record exceeds the runaway timeout, it is assumed that the
routine is stuck in an infinite loop or is doing some operation that has blocked. In this case, ACE takes a
very aggressive action to ensure RealTime calculations continue. First, the ACE record is disabled so
that it does not run again until someone manually intervenes hopefully fixing the problem. Next, the ACE
Engine logs an informative massage indicating that the routine has been disabled. Finally, ACE performs
a fatal error, stopping the process and causing it to restart. Since ACE is so aggressive, the runaway
timeout is quite large (set to 60 seconds by default.)
A record can be manually enabled or disabled by selecting or clearing the Enable Run check box on the
Main Configuration tab of the aceconfig row detail dialog box. It can also be done through SQL.
• The aceconfig record is disabled. Check the Enable column on the ACE Summary display in ezXOS
to determine if this is the cause.
• The aceconfig record is not being triggered. Check the Trigger Configuration tab on the aceconfig
Row Edit form in ADE.
• A PubSub input has no publishers. Check to see a Stale icon on the ACE Summary display in
ezXOS. Use multisubscriber to verify whether or not the topic has a value by subscribing to it.
• A Path input is not available. ACE Engine retries twenty times in case the ACE routine is running
before the RealTime Database points are available.
NOTE: When you create the aceconfig record with an output point, the record will inherit its dataset
from the output point. However, it is important to remember that you will have to set the
aceconfig record's dataset manually, if you create an aceconfig record without an output point.
Refer to "ACE Code aborts without warning" for another potential cause.
32
ACE Reference Using the ACE Summary Window
The ACE Summary window provides information in a tabular format about the system’s points and their
associated ACE procedures.
The points displayed are determined by the current operator’s view area selections. The summary also
allows you to filter point information by code or group.
Procedure
1. Open ezXOS.
2. Expand the System Displays panel on the Navigation Menu.
3. Click ACE.
33
Using the ACE Summary Window ACE Reference
Procedure
Result
The ACE Control dialog box opens.
NOTE: The Stale icon can show in the ACE Control dialog box for two reasons: the record is disabled
or one of the PubSub inputs is missing a publisher. The output point's data quality is displayed.
The freshness of the output point can be affected by the execution of the aceconfig record if
34
ACE Reference Using the ACE Summary Window
UpdateFresh is selected for it. If there is a problem executing the ACE routine, or if PubSub
inputs are not available, the Error icon could also be shown.
35
Code Editor ACE Reference
4 Code Editor
What’s in This Chapter?
4.1 Menu Bar..........................................................................................................................................37
4.6 Intellisense........................................................................................................................................45
The ACE editor is an IDE that provides editing capabilities for the ACE code in the RealTime system.
The Code Editor dialog box displays a Visual Basic (VB) file that has been compiled with errors. There is
a popup hovering over the error that describe the error. The Code Editor is an intelligent editor with
syntax help, intellisense, and color coding. There are five control areas on the editor:
Menu Bar, Tool Bar, Project Explorer, Output Grid, and the Tabbed Control containing the files being
edited.�
36
ACE Reference Code Editor
37
Code Editor ACE Reference
38
ACE Reference Code Editor
Procedure
1. �Select File -> New to access the New File dialog box.
2. Use the File Types drop-down arrow to access all available file types in the editor. Choose a file type
and then enter a file name in the File Name field.
3. Click OK to open an editor tab with the code on it.
For either language a class and namespace is provided for the user code.�
Procedure
1. Select File -> Open to open the Open File dialog box. The dialog box displays all of the ACE
procedures that are available in the system.
2. Click to select a file, or drag to select multiple files.
• To open a block of files, select a file and then hold the shift key down and select another file down
the list. This should highlight a block of files to open.
• To open a variety of files, select a file and then hold the ctrl key and select as many files as
required.
3. Click the Open button to load the files in the ACE Editor.
39
Code Editor ACE Reference
Saving a file will upload it to the RealTime server. The RealTime server hosts the ACE code source as
files on its file system. Likewise, loading a file means the local machine will download it from the
RealTime server. The saving and loading of ACE code requires a HOT RealTime server that ACE can
connect to.
Exporting and importing can be done with any file system. Importing a file means reading the contents of
a file and then loading those contents into an editor panel. Exporting does the opposite; it takes the
contents of the current editor panel and condenses them into a file. The RealTime server is not involved
in exporting and importing. Thus, an imported file will not be integrated into the RealTime system until it
has been saved.
A file does not need to be exported in order to import it. Any file can be imported as any type, but better
results occur if the types match. For instance, a word document would not work well as a VB ACE
40
ACE Reference Code Editor
procedure, but one could be loaded into the editor if desired. Likewise, the editor can export any type of
file.
Importing a file
Importing a file means selecting a file from the file system, then determining how that file will be
interpreted by the editor. The contents of the file are then loaded into the editor, displaying syntax
highlighting and syntax errors.�
By choosing the file type, the syntax checker and compiler are also chosen for the editor panel.
Additionally, the database is checked for any existing files with the assigned name. If one is found, an
error message will appear, denying the file import. In the example shown in the File Import dialog box
and the New File dialog box, the readme file is being imported as a CSharp file.
The first time this procedure is completed, an editor panel is created with the contents of the imported
file (readme.cs would be created in the example). If the import command is repeated, the contents of the
file are simply reloaded into the panel. If you have saved the file between imports, an error message will
appear stating that the file already exists.�
Procedure
2. Select the file you wish to import. If required, use the Files of type drop-down arrow to filter any
known file types.
3. Click OK.
Procedure
41
Code Editor ACE Reference
2. Use the File Types drop-down arrow to select the type of the file that will be imported as a template.
3. Click the From Template button. A file selection dialog box will appear whose file types are limited to
the one that was selected in the popup from the Import As a Template dialog box. Select the desired
file to be used as a template.
4. After the file is selected, a new dialog box will appear that does not have the From Template button.
This dialog box allows the user to set the file name before the editor panel is loaded with the text
from the file.
The file type can be changed in this dialog box, but that is generally not recommended or useful.�
Exporting a file
Exporting a file saves a file to the file system without updating the RealTime database or causing ACE
engine to do any code compiling. This is useful for saving versions of the code or saving templates that
can be used for future development.
Procedure
1. Select File > Export from the menu. This opens the Save As dialog box.
2. Either choose an existing file to overwrite or provide a unique file name.
42
ACE Reference Code Editor
If there is no VB or C# code in the system these buttons disappear and the project explorer appears
blank.
Procedure
1. Click either the ACE C# or ACE VB buttons to view the files contained under either one.
2. Double-click on the desired name to load an ACE code record into the editor.
43
Code Editor ACE Reference
44
ACE Reference Code Editor
4.6 Intellisense
Intellisense is Microsoft’s version of autocompletion, which allows a Code Editor to display a list of
methods and attributes for a class whenever it is followed by a period.
Intellisense provides both autocompletion and documentation when working within a code editor. Within
OASyS DNA, Intellisense functionality exists for the XE VB Code View and for the ACE Code Editor. For
commonly used objects, it will suggest matching variables or functions after you enter a period (.) as a
marker character. It will also offer a short description of the function in a pop-up window.
45
Code Editor ACE Reference
By selecting the Simple View mode from the view menu the user can choose to only see the user code.
This only works if the code in the source file, that the editor relies on to identify the user code, has not
been modified. If the required tags are modified, then the editor displays the complex code, even if
simple mode has been selected.
Procedure
Result
The Code Editor will switch to the Simple View.
46
ACE Reference Code Editor
The ACE editor will not attach the debugger to any process. This must be done manually using
whatever interface is provided by the chosen debugger. By default, the editor will simply launch Visual
Studio, but it can be customized to use alternative debuggers on a per-type basis. For instance, VB
could use Visual Studio for debugging while C# used something else.
The type of debugger launched for a file type can be specified in the language manager XML
configuration files. These are located in:
<InstallDirectory>\ACE\config\EditorTypes
47
Code Editor ACE Reference
An example is shown below where a path to a VIsual studio debugger is provided, this path may or may
not work on your system. Note that the debugger is identified by the tag DebuggerPath, and it is defined
in the EditorDefinition section of the file.
<EditorDefinition>
</EditorDefinition>
Procedure
WARNING: Debugging is very dangerous on a live RealTime system as debugging the ACEengine
causes the processing of all aceconfig records to stop while in the debugger. Normally the
ACEengine can execute thousands of procedures every 5 seconds. Debugging should only
be done on an engineering station.
The ACEengine will be restarted if left in the debugger for longer than the runaway timeout period. The
user configures the runaway timeout in the registry, as follows:
�RUNAWAY_TIMEOUT default = 60000
The monitoring code thinks that there is an infinite loop, and therefore restarts the ACEengine. As a
result, in-depth debugging can sometimes only be done on one execution cycle of an ACE procedure,
after which the ACEengine process has to be reattached, as is will likely shut down. This can be
eliminated by setting the runaway timeout to a very large value on the engineering station machine, but
this effectively disables runaway detection on that machine.
The ACE source files can be loaded into the debugger and breakpoints can be set in the code. The ACE
procedures by default are stored in Realtime\database\ACE\source. Once a breakpoint is set the
debugger can be used to step through the ACE code.
NOTE: The call stack, watch windows and other useful debugging tools are available while stepping
through the code.
48
ACE Reference Code Editor
An extensive list of methods can be found on any machine running OASyS DNA 7.6 or OASyS DNA 7.5
under the filepath: <InstallDirectory>\DNA\Documentation\HelpFiles\Realtime.chm.
The Code Editor methods table below contains only some of the commonly used methods. This table
does not include all methods that can be used with the code editor.
NOTE: When running an overload method, use the arrow keys to navigate the display instead of the on-
screen arrow buttons.
Table continued…
49
Code Editor ACE Reference
Table continued…
50
ACE Reference Code Editor
Table continued…
51
Code Editor ACE Reference
Table continued…
52
ACE Reference Code Editor
This section contains information on variables, subroutines, classes, execution, libraries and basic
syntax.
4.10.1 Variables
53
Code Editor ACE Reference
Examples
Simple calculation:
Complex Procedure:
End If
54
ACE Reference Code Editor
4.10.2 Subroutines
New subroutines can be defined in the ACE procedure class.
This syntax shows how new subroutines can be defined in the ACE procedure class in VB.NET.
NOTE: The ACE Editor must be taken out of simple mode to define subroutines.
Public Sub LogMessage(message As String)
DNALog.WriteLog(DNALog.LogLevel.Always, message)
End Sub
4.10.3 Classes
New subroutines can be defined in the ACE procedure.
This syntax shows how new subroutines can be defined in the ACE procedure class in VB.NET.
NOTE: Classes must be defined at the Namespace scope.
NOTE: The ACE Editor must be taken out of simple mode to define classes.
Public Class EnergyClass
return m * v * v / 2
End Function
End Class
aceconfig records with a dataset only execute on the HOT server owning that data.
aceconfig records without a dataset will execute, if triggered, on all HOT servers they are replicated to.
aceconfig records never begin execution on a non-HOT server, but they may complete execution on a
non-HOT server if it began while the server was HOT.
55
Code Editor ACE Reference
4.10.5 Libraries
This is a list of libraries specific to OASyS DNA.
• "Interop.OASySDNA.CommonVB"
• "Interop.OASySDNA.Config"
• "Interop.OASySDNA.CPULib"
• "Interop.OASySDNA.FlagPackQual"
• "Interop.OASySDNA.ProcMon"
• "Interop.OASySDNA.RawCommonBase"
• "Interop.OASySDNA.RawCoreBase"
• "Interop.OASySDNA.Registry"
• "Interop.OASySDNA.UtilLib"
• "OASySDNA.Common"
• "OASySDNA.Common.Arbitration"
• "OASySDNA.Common.Config"
• "OASySDNA.Common.ProcessMonitor"
• "OASySDNA.Common.PubSub"
• "OASySDNA.Common.ServiceControl"
• "OASySDNA.Common.SQLEngineControl"
• "System"
• "OASySDNA.Common"
• "OASySDNA.Common.Config"
• "OASySDNA.Common.PubSub"
• "System.Runtime.InteropServices"
• "System.Collections"
• "System.Globalization"
• "System.Text"
All ACE user code, whether it C# or VB, is embedded in a procedure inside a class. When editing in
™
simple mode, or on a OASyS DNA 7.4 system, this wrapping code is never seen. As a result, certain
™ ™
statements do not make sense in the user code. In OASyS DNA 7.6 and OASyS DNA 7.5 , simple
56
ACE Reference Code Editor
mode can be unchecked in the View Menu of the editor, allowing the full code to be viewed and all
keywords made available for use.
57
Code Editor ACE Reference
The wrapping code (shown below) is there so that the ACE programmer does not have to be concerned
about namespaces, classes, and so on.
Imports System
Imports OASySDNA.Realtime.HighPerformanceDB
Imports OASySDNA.Realtime.HighPerformanceSetDB
Imports OASySDNA.Realtime.ACE
Imports OASySDNA.Realtime
Imports OASySDNA.Common
Imports OASySDNA.Common.Config
Imports OASySDNA.Common.PubSub
Imports System.Runtime.InteropServices
Imports System.Collections
Imports System.Globalization
Imports System.Text
namespace OASySDNA.Realtime.ACE
As a result of how the code is wrapped, the following keywords are not allowed:
• Module
• Class
• Function
• Sub
• Private
• Public
• namespace
• Imports
• End
• return
NOTE: Any keywords that are illegal result in a syntax error when compiled. ACE also does not allow
the use of theword “Static” as it causes strange behaviour when compiled in-memory.
Declaring Variables
This is the syntax for several declarations.
As shown by the wrapper code there are several input and output variables already declared in the ACE
procedure, but if more are needed, the syntax for several declarations is as follows:
59
Code Editor ACE Reference
If-Then-Else
This is the basic syntax for if-then-else statements.
A multiline if statement is shown below. This also shows the ElseIf construct.
input1 = input2
input2 = input1
Else
input1 = input2
End If
Looping
This is the syntax for several variations of looping.
The do loop is the most complex in that it has multiple forms. The first form is the Do While loop. This
loop is a typical while loop in that the condition is checked at the start of the loop and the loop
executes until the condition is false. The parentheses around the conditions are optional but aid
readability.
NOTE: This example also shows how to exit the do loop if desired.
Dim Check As Boolean
End If
Loop
60
ACE Reference Code Editor
To ensure that the loop is run at least once, do the check at the end. This also applies to the Until
keyword which is discussed later.
Dim Check As Boolean
Do
End If
To loop until a particular condition is true, instead of while it is true, use the Until statement as follows:
Dim Check As Boolean
End If
Loop
The for loop is another standard looping structure. With the for loop the variables are set forth at the
beginning of the loop and the loop auto-increments the variant until it reaches its goal. Most of the time
the loop variant is a numeric value, but this works for anything that support comparison operations and
the + operation.
Dim J As System.Int32
For J = 2 To 10 Step 2
Total = Total + J
If (J < 0) Then
Exit For
End If
Next J
61
Code Editor ACE Reference
For J = 2 To 10 Step 2
Total = Total + J
End If
Loop
Exit For
End If
Next J
62
ACE Reference Code Editor
Math Functions
The standard math functions are contained in the System.Math class.
63
Code Editor ACE Reference
The following commonly used operations are implemented as static methods of this class. They can be
accessed as shown and the double versions are shown by default.:
System.Double d = System.Math.Abs(value)
System.Double d = System.Math.Acos(value)
0 d
System.Double d = System.Math.Asin(value)
- /2 d /2
System.Double d = System.Math.Atan(value)
-/2 d /2
Returns the angle measured in radians whose tangent is the quotient of the
two numbers value_x and value_y where value_x and value_y are co-ordinates
on the cartesian plane.
- d
System.Double d = System.Math.Ceiling(value)
System.Double d = System.Math.Cos(value)
System.Double d = System.Math.Cosh(value)
System.Double d = Exp(value)
System.Double d = Sign(value)
System.Double d = Sin(value)
System.Double d = Sinh(value)
System.Double d = Sqrt(value)
System.Double d = Tan(value)
System.Double d = Tanh(value)
Collections
Microsoft provides the collections namespace. This namespace is packed with useful collection classes.
�System.Collections.ArrayList
System.Collections.BitArray
System.Collcetions.Stack
System.Collections.Queue
System.Collections.Hashtable
65
Code Editor ACE Reference
Arrays
Arrays are a special type of primitive collection. Array methods can be accessed from the array class
and from an array object.
The following methods on the array object are useful for the ACE argument arrays.
66
ACE Reference Code Editor
Executing processes
It is possible to execute scripts and other executable processes from the ACE code.
This is accomplished using the OASySDNA.Common.ProcessUtilities class for which the following
static methods are defined:
67
Code Editor ACE Reference
double[] values
This boolean value is true if the ACE Engine has just become hot. Otherwise, it is false. Routines that
are executed on exception are always executed when the ACE Engine goes hot because it is impossible
to detect whether a change has occurred during a failover.
The following methods are used by ACE internally and should not be called from within an ACE
procedure:
SetUpDBAccess()
GetDBData()
PutDBData()
UpdateFlags()
Dispose()
The following members are defined for the ACE procedure and can be accessed by the ACE routine.
DoRun As Boolean
The DoRun flag from the database. If true then this routine was triggered
by setting this flag in the database record.
CodeVersion As System.Int16
ExecutingTime As Integer
IsOutputFresh As Boolean
The fresh flag for the output point that will be written to the database.
This flag can be changed to manually set the fresh value from within a
routine.
UseAndForFresh As Boolean
By default this is set to true meaning that an output record is marked as fresh if ALL of the inputs are
fresh. Changing this to false means that the output record will be marked as fresh if any of the inputs are
fresh.
68
ACE Reference Assemblies
5 Assemblies
What’s in This Chapter?
5.1 Compiling from the ACE Editor with added assemblies...................................................................69
ACE scripting, like scripting in other OASyS DNA products such as XE, relies on .Net assemblies to
provide the classes and the methods required for use by your scripting code. Some of the necessary
assemblies are loaded in automatically for the code to reference.
A list of the default assemblies available to ACE code can be found in Available Assemblies. In addition
to the default assemblies, ACEEditor and ACEEngine each have their own Assembly List files.You can
add new assemblies into either file to extend scripting support available to ACE code. Additional
assemblies are integrated into the system and all of the default assemblies and the assemblies that
appear in both files get loaded into the ACEServer and ACEClient, which provides Intellisense for a
greater number of assemblies.
Any assemblies used by ACE code must be installed on all RealTime servers running or compiling that
ACE code. Extending scripting in this way can give you access to assemblies that are not included by
default, in addition to access to third party assemblies. Modifying the available assemblies affects both
the RealTime operation of the ACE Engine as well as compiling and intellisense in the ACE Editor.
Related Information
Intellisense on page 45
This means that the ACE code is not necessarily compiled on the same machine that the ACE Editor is
running on, but rather it is compiled on the RealTime host that the ACE Editor is connected to. In OASyS
™ ™
DNA 7.6 and OASyS DNA 7.5 this is determined through the DAL connection screen. In OASyS DNA
™
7.4 it is the local RealTime server associated with the ACE Editor host.
After an assembly has been added to the assembly list, ensure that the updated assembly list is on the
RealTime server where the ACE compile is to take place.
Attaching to a RealTime server other than the Engineering Station itself requires that the assembly list is
updated on the other server, otherwise the compile will fail if the new assemblies are used.
69
Assemblies ACE Reference
The ACEEditor assembly file is called EditorAssemblyList.xml and provides assemblies that can be
used for Intellisense. It should only contain assemblies that will be available on the editing station and is
installed with an ACEEditor installation.
The ACEEngine assembly file is called AssemblyList.xml and provides assemblies that can be used to
affect the way ACE compiles code. It is installed with an ACEServer installation.
NOTE: RealTime has to be restarted in order to make the new assemblies available to code.
The XML file should be edited at the Engineering Station and then distributed to all RealTime computers
in order to keep available assemblies consistent.
NOTE: The assemblies can only be found in two places; either in the Global Assembly Cache (most
third party assemblies are located here ) or the .dll file that is located under telvent\bin (any
custom assemblies are compiled here). Before an assembly list can be used by the ACE Engine
it must be distributed to all RealTime servers.
70
ACE Reference Assemblies
Interop.OASySDNA.Adodb
Interop.OASySDNA.CommonVB
Interop.OASySDNA.Config
Interop.OASySDNA.CPULib
Interop.OASySDNA.FlagPackQual
Interop.OASySDNA.ProcMon
Interop.OASySDNA.RawCommonBase
Interop.OASySDNA.RawCoreBase
Interop.OASySDNA.RawDB
Interop.OASySDNA.RawSecurity
Interop.OASySDNA.RawVDB
Interop.OASySDNA.Registry
Interop.OASySDNA.FlagPackQual
Interop.OASySDNA.Security
Interop.OASySDNA.SQLSchemaChange
Interop.OASySDNA.UtilLib
OASySDNA.Common
OASySDNA.Common.Arbitration
OASySDNA.Common.Config
OASySDNA.Common.ProcessMonitor
OASySDNA.Common.PubSub
71
Assemblies ACE Reference
OASySDNA.Common.ServiceControl
OASySDNA.Common.SQLEngineControl
OASySDNA.Realtime.ACE
OASySDNA.Realtime.Alarm
OASySDNA.Realtime.DistribuSys
OASySDNA.Realtime.HighPerformanceDB
OASySDNA.Realtime.HighPerformanceSetDB
OASySDNA.Realtime.Security
OASySDNA.Realtime.Spooler
OASySDNA.SQLEngine.DataStore
OASySDNA.SQLEngine.Security
System
System.Data
System.XML
System.Drawing
System.Windows.Forms
72
ACE Reference Examples
6 Examples
What’s in This Chapter?
6.1 Dual Inputs........................................................................................................................................73
6.5 try-catch............................................................................................................................................77
A list of common code examples that can be used with the Code Editor.
It is also recommended that you selectively update the fresh flag based on the fresh values of the
inputs. This code defines two variables, Primary and Secondary, to represent the inputs that can be
73
Examples ACE Reference
selected. The fresh flag is used to determine which value is the active one. In this example, the
argument array is used rather than the input shortcut variables like input1 and input2:
If (Primary.IsFresh) Then
output = Primary.CurrentValue
IsOutputFresh = True
output = Secondary.CurrentValue
IsOutputFresh = True
Else
IsOutputFresh = False
DNALog.WriteLog(DNALog.LogLevel.Always,
End If
74
ACE Reference Examples
75
Examples ACE Reference
This example shows how to determine which inputs are used and which are not. This routine performs
an addition between any number of inputs up to 9.
output = 0
output += input1
End If
output += input2
End If
output += input3
End If
output += input4
End If
output += input5
End If
output += input6
End If
output += input7
76
ACE Reference Examples
End If
output += input8
End If
output += input9
End If
�OASySDNA.Common.ProcessUtilities.ExecuteBinaryAsynchronously
("HelloACE.exe", "")
6.5 try-catch
If an error is expected, one that is not critical to the aceconfig record, then try-catch is used to trap it.
This is only to be used for expected errors, ones that should not cause the aceconfig record to be
disabled. All other errors are ignored so that ACE can effectively manage the execution of ACE points
and alarms when things go wrong. To catch a specific error, substitute the type of error to be caught for
77
Examples ACE Reference
the word “Exception”. For example “catch DNAException” catchs all OASySDNA exceptions that are
thrown.
Try
Dim i As Integer
Dim j As Integer = 0
i = 1 / j
Catch ex As Exception
End Try
78
ACE Reference Examples
setting the status point. The GetStatusByName is needed here so that the status string value can be
mapped to a numeric status value that ACE understands.
output = GetStatusByName(args(1).KeyName,"CLOSE")
End If
79
Troubleshooting ACE Reference
7 Troubleshooting
What’s in This Chapter?
7.1 ACE disabled on failover..................................................................................................................80
By default, ACE catches DNAExceptions related to execution on the standby machine and does not
disable the ACE routine. However, if you are using these routines with non-baseline tables such as LMS
tables these exceptions may not be caught and you may need to add try-catch statements to your code.
80
ACE Reference Troubleshooting
To guarantee that code will always execute to completion, despite exceptions thrown by temporary
conditions, it is recommended that you place try-catch code around methods that throw exceptions. This
includes methods:
fnput
fldput
Related Information
fldget and fldput on page 78
81
Schneider Electric
49 Quarry Park Blvd SE
Calgary, AB T2J 6V8 - Canada
Phone: 1 (403) 253-8848
www.schneider-electric.com