How can I create tags in DataHub and force a data type?
When my tags are coming in the DataHub they do not have the correct data type. Is there a way for the DataHub to force a data type I specify?
Here is how you can use the DataHub to force a data type for any tag. In this example, we create a tag of type floating point. All you need to do is create a custom configuration file (.cfg) that will put the float type points in a separate DataHub domain.
1. Using a text editor such as Notepad, create a custom configuration file (.cfg) that contains the following DataHub commands for each point that you need to convert:
(create "FloatDomain:floatpoint1" 1)
(create "FloatDomain:floatpoint2" 1)
(set_canonical "FloatDomain:floatpoint1" R8)
(set_canonical "FloatDomain:floatpoint2" R8)
The DataHub data domain in this example is "FloatDomain" and the actual point names are "floatpoint1", "floatpoint2", etc. The names are separated by a colon ":".
The type R8 is a floating point. The other data types are supported: I1, I2, I4, UI1, UI2, UI4, CY, DATE, BOOL, BSTR, R4, R8, EMPTY, I1 ARRAY, I2 ARRAY, I4 ARRAY, UI1 ARRAY, UI2 ARRAY, UI4 ARRAY, CY ARRAY, DATE ARRAY, BOOL ARRAY, BSTR ARRAY, R4 ARRAY, R8 ARRAY.
2. Save the .cfg file you have created in this directory:
2. Save the .cfg file you have created in this directory:
For Windows XP and 2003:
C:\Documents and Settings\User Name\Application Data\Cogent DataHub\
For Windows Vista, 7, 10 and Server 2008, 2012, and 2016:
C:\Users\UserName\AppData\Roaming\Cogent DataHub\
3. In the DataHub Properties window, select the "Scripting" option, and in the "Load these additional configuration files when starting" area, add your .cfg file to the list. Click Apply.
This will cause the DataHub to load your floating point domain and points whenever it starts up. Once you have the .cfg file in the list, go ahead and restart the DataHub. Choose View Data to open the Data Browser and confirm that the points are there.