AddFile
Associated with: DNP3 SCADAPack E outstations and DNP3 SCADAPack Remote E outstations
Security permission required to access this method: Configure
Use this method to add a file to the Geo SCADA Expert database, ready for downloading to a SCADAPack E outstation. Once added, the file becomes available to ViewX users via the Configuration Setup window (see Working with DNP3 SCADAPack E Outstation Configuration Files).
This method is the equivalent of importing a file by using the Add button on the Configuration Setup window (see Add a File to a SCADAPack E Outstation’s Configuration).
Arguments:
- SrcFileName—Use to specify details about the source of the file that you want to add to the Geo SCADA Expert database. The form that this argument takes differs, depending on the source file’s location:
If the source file is on disk on the main server, the SrcFileName argument can comprise a string. Use the argument to specify the full path of the relevant file on the main server.
If the source of the file is the client that is calling the method (for instance, if the source is read from a file on the client’s hard disk or from a memory stick) use the SrcFileName argument to specify one of the following:
- A three-element one-dimensional array comprising:
- first element: a byte array containing the file’s content
- second element: a string with the name of the source file (do not include the path)
- third element: the last modified time of the file.
For an example that demonstrates such an array, see below.
- A single byte array containing the content of the file that is to be added to the database. This option is deprecated and retained for backwards compatibility.
With a single byte array, the server will time stamp the file with the current time when it adds the file to the database (as the server will not be able to ascertain the last modified time of the file).
- A three-element one-dimensional array comprising:
- DstFileName (String)—Specify the destination file name - the name by which the file will be downloaded to the outstation. This is also the name under which the file will be stored in the Geo SCADA Expert database.
Take care to ensure that the name complies with the naming restrictions that apply to the outstation’s filing system (see File Restrictions).
- ManDownload (Boolean)—This argument is optional and defaults to FALSE. Use the argument to indicate whether the file is to be available for manual download. Specify TRUE or FALSE.
- AutoDownload (Boolean)—This argument is optional and defaults to FALSE. Use the argument to indicate whether the file is to be automatically downloaded, in response to the outstation setting its DNP3 Configuration Corrupt IIN bit. Specify TRUE or FALSE.
- FileType (Byte)—This argument is optional and defaults to 5 (generic binary file). Use the File Type argument to specify the type of file.
The FileType argument must be included if the SrcFileName argument is used to specify a single byte array containing only the file’s content (as per the SrcFileName argument’s last bullet point, above).
Supported file types are:
- 0 - Configuration file (*.rtu)
- 1 - ISaGRAF file (*.X8M)
- 2 - Configuration file (for example, NTP configuration file (*.conf))
- 3 - License file (*.lic)
- 4 - Profile file (PROFILE_xxx_y)
- 5 - Generic binary file
- 6 - Generic ASCII file.
If the SrcFileName argument contains the name of the file, you can omit the FileType argument to trigger Geo SCADA Expert’s automatic file type detection. When omitted, Geo SCADA Expert will attempt to determine the actual file type based on the value of the SrcFileName argument.
Example 1:
With the following line of code, the AddFile method’s SrcFileName argument (C:\myfile.rtu) includes the source file’s extension. As such, the FileType argument is omitted, as Geo SCADA Expert will automatically set the file type to 0 (configuration file) based on the source file’s ‘.rtu’ extension.
AddFile("C:\myfile.rtu", "config.rtu")
Example 2:
With this line of code, the FileType argument is omitted, as Geo SCADA Expert will automatically set the file type to 4 (Profile file) based on the ‘PROFILE’ prefix to the source file’s name:
AddFile("C:\My Profiles\PROFILE_001_1", "PROFILE_001_1", TRUE)
- ConcatType (Byte)—This argument is optional and defaults to 0 (None).
If the FileType is 0 (indicating a Configuration file), use this argument to specify whether the file is appended to the beginning or end of the configuration that is automatically generated by Geo SCADA Expert.
For files other than configuration files, (that is, when the FileType is not 0) this argument is ignored and should be set to 0 (None).
The ConcatType argument can have one of the following values:
- 0—None. Use this value for all non-RTU configuration file types.
- 1—Beginning. This option indicates that the file will be appended to the front of the generated RTU configuration file.
- 2—End. This option indicates that the file will be appended to the end of the generated RTU configuration file.
For rules regarding adding configuration files to the SCADAPack E outstation’s configuration, see File Restrictions.
Example:
With this example, a Microsoft® JScript program is used to add a file (located on a ViewX client’s D: drive) to the Geo SCADA Expert database. The program uses the AddFile method to add the file to the database.
In this particular case, the method’s SrcFileName argument comprises a three-element one-dimensional array (‘FileInfo’), in order to pass the relevant file details to the server. For more information about the format that this type of array has to take, see the SrcFileName entry above. The second element of the array is used to specify the file’s name (the ‘Name’ property of the ‘File’ object, specified in line 11 below). In this particular case, the same value is also used for the DstFileName (line 15).
Be aware that this example only comprises a brief outline of the type of content that might be included in program that uses the AddFile method. For a more robust application, the program code should also include, for example, any error handling that is deemed to be required.
function AddFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var File = fso.GetFile("D:\\myfile.rtu");
var BinaryStream = new ActiveXObject("ADODB.Stream");
BinaryStream.Type = 1;// Binary
BinaryStream.Open();
BinaryStream.LoadFromFile(File.Path);
var FileInfo = new Array(3);
FileInfo[0] = BinaryStream.Read();
FileInfo[1] = File.Name;
FileInfo[2] = File.DateLastModified;
BinaryStream.Close();
var Outstation = Server.FindObject("My Outstation");
Outstation.Interface.AddFile(FileInfo, File.Name);
}