A 15-Minute Snapshot Report

This example shows how to create a new type of report, and how to add a new module to an existing VTScada program. The result will be a snapshot report that works on a fifteen-minute basis rather than hourly or daily.

This is a minimalist example that works by making a small adjustment to existing code. As such, the range of options is limited. For a complete overview of how to create this report from scratch see: Script Custom Reports

  1. Select an existing application, or create a new one.

Do not select or create a script application.

Use great care if attempting this within a running production application. Better to experiment within a test application or a clone.

  1. Using a text editor, create a new file in that application's folder.
  2. Name the file 15MinSnap.SRC
  3. Copy the code following step 10 into that file and save it.
  4. Using a text editor, open the application's AppRoot.SRC file.
  5. Declare the module within the (PLUGINS) section.

The result should appear as follows.

[ (PLUGINS) {===== Modules added to other base system modules =====}
   15MinSnap Module "15MinSnap.SRC";
]

(There will already be a (PLUGINS) section - do not add a second one.

  1. Save the file and click the application's Import File Changes button.
  1. Click OK to import the new module.
  2. Start the application if it is not already running. (It was not necessary to stop it to do the preceding steps.)
  3. Open the Reports page. Your new report should be available in the list of report types.
{============================ 15MinReport ===========================}
{ This plugin modifies the hourly snapshot report to be every        }
{ 15 minutes                                                         }
{ Groups : Loggers                                                   }
{ Areas : All                                                        }
{====================================================================}
(
   Reporter { Object value for call-backs };
   Start { Starting time };
   End { Ending time };
   Tags { List of tag names to report on };
   Vars { List of vars within tags };
)
[
  { Set up this module to become a plug-in for the reports }
   [(POINTS)
      Shared Report;
   ]

   Constant TypeFilter = "Loggers" {type of tags to use in the report};
   Constant ReportName = "15 Minute Snap" {title for the report };
   TimeStamp { Time of last value returned };
   Obj { Instance of report };
]

Init [
   If 1 Wait;
   [                                       { 15 minutes = 900 seconds }
      Obj = \SnapshotReport(Reporter, Start, End, Tags, Vars, 900, ReportName, 4 );
   ]
]
Wait [
   TimeStamp = Obj\TimeStamp; {ensures that the report object was created before this module ends }
   If !Valid(Obj);
   [
      Slay(Self, 0);
   ]
]