Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

DTL_DRIVER_CLOSE (dtl)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("dtl.dll", SetLastError=true)]
static extern public int DTL_DRIVER_CLOSE(int driver_id, int timeout);

VB Signature:

Declare Function DTL_DRIVER_CLOSE Lib "dtl.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

namespace MyNamespace

{

    /// <summary>
    /// Class dtl has all the p/invoke routines and
    /// error constants for the Rockwell DTL C sdk
    /// interface.
    /// </summary>
    public static class Dtl
    {
    /// <summary>
    /// Close Dtl driver
    /// </summary>
    /// <param name="driverId">specifies driver to close</param>
    /// <param name="timeOut">time out in milliseconds</param>
    /// <returns>dtl status</returns>
    public static int DtlDriverClose(int driverId, int timeOut)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_DRIVER_CLOSE(driverId, timeOut));
    }

    /// <summary>
    /// Uninitialize Dtl driver
    /// </summary>
    /// <param name="driverId">driver to uninitialize</param>
    public static void DtlUninit(int driverId)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        UnsafeNativeMethods.DTL_UNINIT(driverId);
    }

    /// <summary>
    /// Initialize Dtl driver
    /// </summary>
    /// <param name="tableSize">number of entries in the definition table</param>
    /// <returns>dtl status</returns>
    public static int DtlInit(int tableSize)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_INIT(tableSize));
    }

    /// <summary>
    /// Returns message associated dtl status
    /// </summary>
    /// <param name="dtlSts">dtl status to lookup</param>
    /// <param name="msg">message corresponding to dtl status </param>
    /// <param name="buffSize">size of buffer that will hold message</param>
    public static void DtlErrorS(int dtlSts, StringBuilder msg, int buffSize)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        UnsafeNativeMethods.DTL_ERROR_S(dtlSts, msg, buffSize);
    }

    /// <summary>
    /// Open Dtl Driver
    /// </summary>
    /// <param name="driverId">driver id to assign to this driver</param>
    /// <param name="driverName">name of the driver </param>
    /// <param name="timeOut">timeout in milliseconds</param>
    /// <returns>dtl status</returns>
    public static int DtlDriverOpen(int driverId, string driverName, int timeOut)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_DRIVER_OPEN(driverId, driverName, timeOut));
    }

    /// <summary>
    /// Get version of dtl dll
    /// </summary>
    /// <param name="versionText">string to hold returned text</param>
    /// <param name="maxCharsToReturn">size of string to hold version text</param>
    /// <returns>dtl status</returns>
    public static int DtlVersion(StringBuilder versionText, int maxCharsToReturn)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_VERSION(versionText, maxCharsToReturn));
    }

    /// <summary>
    /// Define a tag
    /// </summary>
    /// <param name="nameId">name id assigned to the tag</param>
    /// <param name="defString">string the defines the tag and its data</param>
    /// <returns>dtl status</returns>
    public static int DtlCDefine(ref int nameId, StringBuilder defString)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_C_DEFINE(ref nameId, defString));
    }

    /// <summary>
    /// Undefine a dtl tag
    /// </summary>
    /// <param name="nameId">name id of the tag</param>
    /// <returns>dtl status</returns>
    public static int DtlUndef(int nameId)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_UNDEF(nameId));
    }

    /// <summary>
    /// Read data from a dtl tag
    /// </summary>
    /// <param name="nameId">name id of the tag</param>
    /// <param name="readData">byte buffer to hold the data</param>
    /// <param name="ioStat">io status of the read operation</param>
    /// <param name="timeOut">timeout in milliseconds</param>
    /// <returns>dtl status</returns>
    public static int DtlReadW(int nameId, byte[] readData, ref uint ioStat, int timeOut)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_READ_W(nameId, readData, ref ioStat, timeOut));
    }

    /// <summary>
    /// Write to a dtl tag
    /// </summary>
    /// <param name="nameId">name id of the tag</param>
    /// <param name="writeData">data buffer to write from</param>
    /// <param name="ioStat">io status of the write operation</param>
    /// <param name="timeOut">timeout in milliseconds</param>
    /// <returns>dtl status</returns>
    public static int DtlWriteW(int nameId, byte[] writeData, ref uint ioStat, int timeOut)
    {
        new UIPermission(UIPermissionWindow.AllWindows).Demand();
        return (UnsafeNativeMethods.DTL_WRITE_W(nameId, writeData, ref ioStat, timeOut));
    }

    /// <summary>
    /// Contains unsafe dtl dll calls
    /// </summary>
    [SuppressUnmanagedCodeSecurityAttribute]
    internal static class UnsafeNativeMethods
    {
        [DllImport("Dtl32.dll")]
        static extern public int DTL_DRIVER_CLOSE(int driver_id, int timeout);

        [DllImport("Dtl32.dll")]
        static extern public void DTL_UNINIT(int driver_id);

        [DllImport("Dtl32.dll")]
        static extern public int DTL_INIT(int table_size);

        [DllImport("Dtl32.dll")]
        static extern public void DTL_ERROR_S(int iostat, StringBuilder msg, int buffsz);

        [DllImport("Dtl32.dll")]
        static extern public int DTL_DRIVER_OPEN(int driver_id, string szDriverName, int timeout);

        [DllImport("DTL32.DLL")]
        static extern public int DTL_VERSION(StringBuilder sb, int maxChars);

        [DllImport("DTL32.DLL")]
        static extern public int DTL_C_DEFINE(ref int name_id, StringBuilder def);

        [DllImport("DTL32.DLL")]
        static extern public int DTL_UNDEF(int name_id);

        [DllImport("DTL32.DLL")]
        static extern public int DTL_READ_W(int name_id, byte[] data, ref uint iostat, int timeout);

        [DllImport("DTL32.DLL")]
        static extern public int DTL_WRITE_W(int name_id, byte[] data, ref uint iostat, int timeout);
    }
    }

}

    public void CloseDriver()
    {
        Dtl.DtlDriverClose(_driverId, TimeoutInMs);
        _driverLookupList.TryRemove(_driverName, out _driverId);

        if (_driverLookupList.IsEmpty)
        {
        Uninitialize();
        }
    }

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions