PDComm.Modbus.License
Class
Installs and inspects the PDComm license of the Modbus native library.
public static class LicenseThe connect command needs a license for the modbus module, plus modbus-security when the configuration enables Modbus/TCP Security. Without it Endpoint.Call throws ModbusCommandException with ModbusCommandException.LicenseRequired set; connections that are already open keep working, and every other command works without a license.
The library merges the text installed here with the PDCOMM_LICENSE (text) and PDCOMM_LICENSE_FILE (path) environment variables and pdcomm.license files next to the application or the native library and in the user and system configuration directories. The installation applies to every endpoint of the Modbus library only. These methods run the license_install, license_status and host_id commands on a temporary endpoint and are thread-safe.
License.Install(File.ReadAllText("pdcomm.license"));
Console.WriteLine(License.Status().GetProperty("modules").GetProperty("modbus").GetProperty("state"));Members
HostId
Method
Gets the host id of this machine, which host-bound licenses (SECS/GEM runtime licenses) name.
public static string HostId()Returns
The host id, PDH1-XXXX-XXXX-XXXX-XXXX.
Notes
- Throws
ModbusCommandException: The machine id cannot be read (ModbusCommandException.Codehost_id_unavailable). - Throws
DllNotFoundException: The native library cannot be found or loaded.
Install
Method
Installs license text, replacing text installed earlier.
public static int Install(string text)Parameters
| Name | Description |
|---|---|
text | Text with one or more -----BEGIN PDCOMM LICENSE----- blocks; text outside the blocks is ignored. An empty string removes the installed text. |
Returns
The number of license blocks whose signature verified.
Notes
- Throws
ArgumentNullException:textisnull. - Throws
ModbusCommandException: The text contains no block whose signature verifies (ModbusCommandException.Codelicense_invalid); the previous text stays installed. - Throws
DllNotFoundException: The native library cannot be found or loaded.
Status
Method
Gets the license status of the Modbus library.
public static JsonElement Status()Returns
A JSON object with host_id, build_date, the found sources, every license block in licenses with its verification, and modules, which maps each module id to its state (licensed, evaluation, missing, expired, not-yet-valid, updates-expired, program-mismatch or host-mismatch), granted and days_left.
Notes
- Throws
DllNotFoundException: The native library cannot be found or loaded. - Throws
ModbusCommandException: The library has no license support (it predates licensing).