ClearSCADA: convert group to instance and retain history
Is there a way to convert a group to an instance of a template and retain the historic data of the points from the group object?
It is possible to do this but it requires a few a few steps. Here is how historic files work:
When you create an object in the CleraSCADA database (i.e. an analog point) an object ID is created for that point. With 'historic' enabled on that point a corresponding folder is created in the Database\History\Historic folder. The folder name is derived from the object ID number of the point divided by 256. For example, if you have an analog point with an object ID of 22004 then you would see a folder created with the name HdI00085. This is because 22004 / 256 = 85.95.
Inside folder HdI00085 will be a folder with the name of the object ID (for the example above you would see a folder named 22004). Inside the 22004 folder will be the historic files which pertain to this point.
In order to retain history for objects in a group (that is converted to a template) you would need to do the following:
1) Note the object IDs for each of the objects in the group you wish to retain history for. Here I've created an analog point and selected 'view status' from the database tree in order to determine that its object ID is 3882.
2) Open Windows Explorer (File Explorer) and browse to the ClearSCADA\Database\History\Historic folder. Since the object ID is 3882, the folder we want to look for is 3882 / 256 = 15.164. Therefore we want folder HdI00015.
3) Once the folder name(s) have been found, locate the sub folders named with the object IDs. In this case we are looking for a folder named 3882.
Inside this folder will be files named with a .hrd extension. The name of the file corresponds to the number of weeks that have passed since Jan 1, 1601. One file per object (point) per week is created to store historic data.
4) Shut down the ClearSCADA server and copy the sub folders (i.e. 003882) to another location. Shutting down the CS server ensures that the files will not be written to as you are copying them.
5) Convert the group to a template and then create an instance of the template.
6) Locate the corresponding objects (points) in the instance (from the Database tree) and note the object IDs for each of these.
7) Use the method mentioned above to find the folder names where the historic files for the instance objects reside.
8) Once the new folder names have been found, locate the sub folders named with the new object IDs.
9) Rename the saved 'original' folders (from step 4) with the new object ID names (from step 7). In this example you would rename folder 3882 with the corresponding object ID number from the instance.
10) Shut down the ClearSCADA server and delete the sub folder from step 8).
11) Copy the folders from step 9) into the locations where you deleted the folders in step 10).
12) Restart the ClearSCADA server. (Note: the ClearSCADA server must be shut down prior to moving the folders (in step 11) as the server requires a restart in order to recognize the newly added historic files).
The instance should now contain the historic values that were previously seen in the original group.