Вы находитесь на странице: 1из 4

Scheduling a Petro-SIM/Monitor Task

Depending on the complexity of the model, network latency in communicating with


historians or Petro-SIM databases, and various other factors, performing a Petro-
SIM/Monitor run can be a time-consuming process. Using a simple script and the
Windows Task Scheduler, this process can be scheduled to run during off-peak hours
such as overnight or on weekends.

The PetroSIMMonitorTask script

Petro-SIM ships with a script named PetroSIMMonitorTask.vbs located in the UMT-


Scripts directory where the program is installed. By default, this location is C:\Program
Files\KBC\SIM Suite 4.1\Petro-SIM\Support\UMT-Scripts.

The script accepts several arguments, allowing you to customize its behaviour. To see
all options, you can run the script from a command prompt using:
cscript PetroSIMMonitorTask.vbs

At minimum you will need to supply the script with the name of a monitoring application
to run and database configuration parameters. To use the existing database
configuration stored in the registry, set the dbuseregistry option to true. For example, if
you have an application called FCC100, and you wish to perform the monitoring run
with the most recent data from the historian, you can run the command:
cscript PetroSIMMonitorTask.vbs /app:FCC100 /dbuseregistry:true

More likely, you will want to perform a run using process data that corresponds to your
most recent lab data. The labdate argument allow you to configure such a run. For
example:
cscript PetroSIMMonitorTask.vbs /app:FCC100 /dbuseregistry:true /labdate:”3-
Mar-2012 9:00:00”

The script will then perform a run for that time. If you would like the Meter Report for
this run to be saved, you can also specify a folder to save it in using the xlsfolder
argument as follows:
cscript PetroSIMMonitorTask.vbs /app:FCC100 /dbuseregistry:true /labdate:”3-
Mar-2012 9:00:00” /xlsfolder:”%MyDocuments%\KBC\Meter Reports”

If the path contains text delimited by % characters, this section will be interpreted as a
special system folder, and the task will attempt to determine the actual location.
Examples include %MyDocuments% and %Desktop%. As well, you can use a specific
location such as “c:\MeterReports”. If the path does not exist, the Meter Report will be
left open, but not saved.
The Windows Task Scheduler

To create a scheduled task, it is easiest to first write a batch file for the application you
wish to monitor. An example might look something like this:
1: @echo off
2: c:
3: cd "\program files\kbc\sim suite 4.1\petro-sim\support\umt-scripts"
4: if not exist PetroSIMMonitorTask.vbs quit
5: cscript PetroSIMMonitorTask.vbs /app:FCC100 /labday:tuesday
/labtime:"10:00" /xlspath:"%%MyDocuments%%\KBC\Meter Reports"

Line numbers are shown to make the file structure clear, even though some of the
longer lines are wrapped. Note the minor change to the special system folder
specification using the %MyDocuments% notation introduced earlier. Batch files interpret
this notation as internal variables, so you must add an extra % at the beginning and the
end to ensure the right location gets passed to the script. You do not need the extra %s
when running directly from a command prompt.

When you have created a batch file, open the Windows Control Panel and click “System
and Security”. Next, click “Schedule Tasks” under the “Administrative Tools” section
which will open the “Task Scheduler” window:
Click “Create Task...” from the Actions menu on the right to get the following screen:

You can now configure your task. Enter the name of your Task as “FCC Monitor”.
Next, click “New...” on the Actions Tab to get the following screen:
Click “Browse…”, select the batch file you created, and click “Open”. Click OK to
confirm your new action. Now you need a trigger for your new action. Click “New...” on
the “Triggers” tab to get the following window:

Suppose you wish to perform monitoring runs overnight on Tuesdays. Select “Weekly”,
choose a start time, and then select “Tuesday”. Click OK to confirm your new trigger,
and another OK to confirm your new Task. You should see your new task listed here:

Your task is now scheduled. To end the task, right-click it and select delete

Вам также может понравиться