Link to a Driver

If the purpose for your custom tag is to connect to hardware to read or write values then you must link it to a driver. A parameter must be added to create this link:

DeviceTag  <:TagField("SQL_VARCHAR(255)"):> = "*Driver"
             { Driver tag to communicate through                 };

When a user configures an instance of this tag, the name of the associated I/O device driver will be stored in this parameter.

Rather than using this parameter directly within the tag code, it is common to use the tag's Variables section to specify a location where the object value of the I/O device will be stored. Also, the raw value from the I/O tag will not be used directly as the tag's value - rather, it will be stored in a local variable. When the raw I/O value changes, scaling or other operations can be applied to find the tag's new value.

Updating the example code, the Variables section will now look like the following, where the last line refers to the driver:

    { Variables }
  Value (5)          { Scaled value for this point.                 }; 
  RawValue           { Data value read from the IO                  };
  Root               { Set to individual instance of this module    };
  SitePoint          { Object value of DeviceTag parameter          };

The Main state will be responsible for linking the variable to the object value of the I/O device tag:

CustomTagMain [
   SitePoint = Scope(Root, DeviceTag);
]

The code examples just shown will suffice to link your tag to a I/O device driver. It will be the job of your tag's Refresh module to add or remove reads for the addresses in the device driver in response to any change in parameters. Other modules will take care of handling data sent from the driver.

PAddressEntry

You must provide a way for the developer to specify the address to use on the I/O device driver. The PAddressEntry function serves this purpose. This will display a standard edit field, or if the driver includes an AddressAssist module, will display the user-interface elements coded there. (see: Provide an AddressAssist Module in the Communication Drivers chapter.)

ScanInterval

A ScanInterval parameter should be provided to allow control over frequency of driver reads.