Examples
Source Code Main Page
RDK Online Help Files
BDK Online Help Files
Home > Palisade Products > Developer Kits > RDK > Examples > Maintenance Policy > Code



Source Code

Determine the Optimal Maintenance Policy

Overview
The maintenance policy example has two main parts.

First, using Visual Basic, we wrote an ActiveX DLL and installed it on our server. This DLL references the @RISK Developer's Kit ActiveX library, and contains all the model logic for simulating the average profit for the different maintenance policies. It also contains code for generating progress and output graphs, and the formatted table of statistics that you see in the example's result window.

Second, we wrote a sequence of web pages to retrieve the model's input parameters from the user, to dynamically show the progress of the simulation, and to display the output results. One of the web pages in the sequence uses VBScript to call our DLL, passing it the model parameters specified by the user. When the simulation is complete, the results page combines together the statistics and graphs generated by the DLL into a nicely formatted page, suitable for display.

RDKX_MaintenancePolicy.DLL
This DLL contains only a single publicly accessible method, called Simulate. The function takes as arguments all the input model parameters, as well as an output directory to which it will write graphs and results.

The Simulate method performs the following five steps:
     1. Initializes the RDK
     2. Sets up the Model
     3. Runs the Simulation
     4. Generates the Results
     5. Shuts Down the RDK

The function generates two files in the output directory specified, "\GRAPH.JPG" and "\STATISTICS.HTML". The files are combined together by the calling .ASP page to make the final page that is displayed to the user.

There are three code modules that make up the RDKX_MaintenancePolicy.DLL

1. Application Class Module - this is the main, publicly accessible module of the .DLL, which contains the Simulate method.
2. RDKEvents Class Module - this module contains the code that actually calculates the model's outputs each iteration of a simulation. In addition, it also contains code for making dynamic progress graphs during the simulation.
3. Constants Class Module - this module contains constants and functions used by the other modules.
In the code listings, items in blue are an object, method or property from the RDKX.

Maintenance_Policy_Results.ASP
This .ASP page uses VBScript to call the RDKX_MaintenancePolicy.DLL which is installed on the server and running in COM+. It then writes the results generated by the DLL (the \GRAPH.JPG and \STATISTICS.HTML files) into a nicely formatted web page. A previous web page passes in the model parameters defined by the user using an HTML form.