Datasets Files (Reference) enable reading and writing text-based data files for recipe management, configuration settings, and data exchange with external applications. DatasetFile provides:
Files support ASCII, Unicode, and XML forma
Table of Contents maxLevel 2 minLevel 2 indent 10px exclude Steps style none
Property | Description | Required |
---|---|---|
Name | Unique file identifier (no spaces) | Yes |
FileName | Full file path (supports tag embedding) | Yes |
FileType | Format: ASCII, Unicode, XML | Yes |
Objects | Tags to read/write | Yes |
XMLSchemaType | XML structure type | For XML only |
Description | Documentation text | No |
Plain text, single-byte encoding:
Tag1=100
Tag2=200.5
Tag3=Active
Multi-byte character support:
??=25.5
??=101.3
??=???
Structured data with schemas:
xml
<Tags>
<Tag Name="Temperature" Value="25.5"/>
<Tag Name="Pressure" Value="101.3"/>
<Tag Name="Status" Value="Running"/>
</Tags>
C:\Recipes\Recipe001.txt
\\Server\Share\Config.xml
C:\Recipes\Recipe{{Tag.RecipeNumber}}.txt
C:\Data\{{Tag.Year}}\{{Tag.Month}}\Data.csv
\\Server\{{Tag.Department}}\Settings.xml
{{ExecutionPath}}\Recipes\Current.txt
{{SolutionPath}}\Data\Config.xml
Simple name-value pairs:
xml
<TagList>
<Tag Name="Tank1_Level" Value="75.5"/>
<Tag Name="Tank1_Temp" Value="22.3"/>
<Tag Name="Pump1_Status" Value="1"/>
</TagList>
Complete tag hierarchy:
xml
<TagTree>
<Folder Name="TankFarm">
<Folder Name="Tank1">
<Tag Name="Level" Value="75.5" Type="Double"/>
<Tag Name="Temp" Value="22.3" Type="Double"/>
</Folder>
</Folder>
</TagTree>
csharp
// Load recipe file
@Dataset.File.Recipe001.Load();
// Check if successful
if (@Dataset.File.Recipe001.Status == "OK")
{
// Tags now contain file values
double temp = @Tag.Temperature;
}
csharp
// Set tag values
@Tag.Temperature = 25.5;
@Tag.Pressure = 101.3;
@Tag.Status = "Running";
// Save to file
@Dataset.File.Recipe001.Save();
csharp
// Change filename at runtime
@Tag.RecipeNumber = 5;
@Dataset.File.RecipeFile.FileName =
string.Format(@"C:\Recipes\Recipe{0}.txt", @Tag.RecipeNumber);
// Load specific recipe
@Dataset.File.RecipeFile.Load();
# Recipe_001.txt
ProductCode=WIDGET-A
Temperature=185.5
Pressure=25.0
MixTime=300
Speed=1500
csharp
public void LoadRecipe(int recipeNumber)
{
// Set dynamic filename
@Tag.CurrentRecipe = recipeNumber;
// Load file
@Dataset.File.RecipeFile.Load();
// Verify loading
if (@Dataset.File.RecipeFile.Status == "OK")
{
@Tag.RecipeLoaded = true;
@Display.MessageBox("Recipe loaded successfully");
}
}
csharp
public void SaveRecipe()
{
// Current values saved to file
@Dataset.File.RecipeFile.Save();
// Create backup
string backup = string.Format(
@"C:\Recipes\Backup\Recipe_{0}.txt",
DateTime.Now.ToString("yyyyMMdd_HHmmss")
);
File.Copy(@Dataset.File.RecipeFile.FileName, backup);
}
csharp
// Export current configuration
@Dataset.File.ConfigExport.FileType = "XML";
@Dataset.File.ConfigExport.XMLSchemaType = "TagObject";
@Dataset.File.ConfigExport.Save();
csharp
// Import from external system
@Dataset.File.ConfigImport.Load();
// Apply imported values
if (@Dataset.File.ConfigImport.Status == "OK")
{
// Values automatically mapped to tags
ApplyConfiguration();
}
If Dataset Files menu is not visible:
Alternative:
csharp
try
{
@Dataset.File.MyFile.Load();
if (@Dataset.File.MyFile.Status != "OK")
{
string error = @Dataset.File.MyFile.ErrorMessage;
LogError(error);
}
}
catch (Exception ex)
{
// Handle file system errors
@Tag.FileError = ex.Message;
}
File not found:
Load/Save fails:
Data corruption:
Missing menu option:
The DatasetFile configuration and properties in the Dataset module allows you to manage and customize configurations to read and write text files containing values of Tags. Those files can be used as recipes, or configuration settings to the solution, or to exchange data with other applications.
On this page:
Table of Contents | ||||
---|---|---|---|---|
|
To create and configure a DatabaseFile follow these steps:
Enter a Name and Description for the new File.
Click Ok.
The new DatasetFile object will show up in the DataGrid. To edit any property of the new DatasetFile, double-click the property you wish to edit on the corresponding row. The table below describes each available property you can configure for your DatasetFiles.
Column
Description
Name
The DatasetFile object's name. The system will warn you in case you choose an invalid name.
FileName
Specify the full path to the File. The file path can have Tag values embedded using curly bracket syntax. For example ExampleFile{{tag.Test}}.txt.
When executing, the area in curly brackets is replaced by the Tag's value.
FileType
Specify the file type. The following options are available:
Objects
Click the button with three dots (...) to select the tags that you want to populate with data from the file with data from specific columns.
Description
The description for the File. Provide a meaningful description to make it easier to execute maintenance in the future.
XMLSchemaType
Represents the schema type of an XML file, which can be:
You do not need to worry if you do not find the menu Dataset Files option under Dataset. The DatasetFile option may not appear due to a Filter option in the platform, which shows only the mostly commonly used features.
To change, follow the steps below:
Page Tree | |||
---|---|---|---|
|