tsc_Rs232PortLocker

This static class allows a plugin to reserve exclusive use of a COM port with regards to the Survey Core system.  Other programs outside the SurveyCore environment (including other Trimble Access programs, or plugin code directly accessing the API) will not be affected and may compete for access.

Use this class by locking a specified port, if successful SurveyCore will refrain from using the port.  Once you are finished, release the port.  Locks and releases are counted so nesting is possible.

Static Methods

static bool Exists (tsc_Rs232ComPorts whichPort);
Is the port available for use on this operating system, note that the S Series foot connector availability may change during a SurveyCore session.

static bool IsLocked(tsc_Rs232ComPorts whichPort);
Does this plugin currently have the lock for this port?

static tsc_PortLockerResult Lock(tsc_Rs232ComPorts whichPort);
Attempt to lock this port for your plugin's exclusive use.  If the port is in use or you already have a lock for this port it will return immediately.  If the port is in use by the SurveyCore autoconnect system then the calling thread will be blocked while autoconnect gives way.

static tsc_PortLockerResult TryLock (tsc_Rs232ComPorts whichPort);
Similar to Lock but this will always return immediately, it will not ask autoconnect to relinquish a port that is in use.

static void Unlock(tsc_Rs232ComPorts whichPort);
Release a lock for the specified port.  If your lock count reaches zero then other code may attempt to use the port.

static void UnlockAll ();
Release all port locks for all ports.

Enumerations

For more information on tsc_Rs232ComPorts, see tsc_Rs232Stream.

enum tsc_PortLockerResult
{
    tspl_Success            // Operation was successful.
    tspl_PortNotInstalled   // This port is not available, it may not be present.
    tspl_InUse              // Port is already in use and cannot be locked.
}