/// <summary>
        /// Reads all values from all Relay of a card up to a size of 64 DO channels
        /// </summary>
        /// <param name="cardHandle">
        /// The handle of the opened card
        /// </param>
        /// <returns>
        /// The values of all DO channels of a card
        /// </returns>
        private static ulong ReadbackAll(uint cardHandle)
        {
            // due to problems with the DOReadback64 method only the 32 bit variant of this method will be used
            // also the card size needs to be checked at first
            // card DO <= 32 -> only readback 32 channels once
            // card DO > 32 -> readback32 two times and combine the two uints to a ulong (by bitshifting the high value by 32 bits to the left)
            ulong result   = 0;
            uint  cardSize = GetCardDigitalOutputSize(cardHandle);

            if (cardSize <= 32)
            {
                uint readback = DeLibNET.DapiDOReadback32(cardHandle, 0x0);
                result = Convert.ToUInt64(readback);
            }
            else if (cardSize > 32)
            {
                uint high = DeLibNET.DapiDOReadback32(cardHandle, 0);
                uint low  = DeLibNET.DapiDOReadback32(cardHandle, 32);

                result  = (ulong)high << 32;
                result += low;
            }

            return(result);
        }
        /// <summary>
        /// Gets the card handle from a RO_ETH module on a specific card address
        /// </summary>
        /// <param name="cardAddress">
        /// The address where the card is configured
        /// </param>
        /// <returns>
        /// The handle from the opened card
        /// </returns>
        private static uint GetCardHandle(uint cardAddress)
        {
            uint handle = (uint)DeLibNET.ModuleID.RO_ETH;

            handle = DeLibNET.DapiOpenModule(handle, cardAddress);

            // GetDigitalOutputSize(handle, cardAddress);
            return(handle);
        }
        /// <summary>
        /// The do set 8.
        /// </summary>
        /// <param name="cardHandle">
        /// The card handle.
        /// </param>
        /// <param name="bitValue">
        /// The bit value.
        /// </param>
        private static void DigitalOutputSet8(uint cardHandle, uint bitValue)
        {
            uint channel = 0;

            if (bitValue == 0)
            {
                channel = 0x00;
            }
            else if (bitValue == 1)
            {
                channel = 0xff;
            }

            uint fromFirst = 0;

            DeLibNET.DapiDOSet8(cardHandle, fromFirst, channel);
        }
        /// <summary>
        /// The do set 64.
        /// </summary>
        /// <param name="cardHandle">
        /// The card handle.
        /// </param>
        /// <param name="bitValue">
        /// The bit value.
        /// </param>
        private static void DOSet64(uint cardHandle, ulong bitValue)
        {
            ulong channel = 0;

            if (bitValue == 0)
            {
                channel = 0x0000000000000000;
            }
            else if (bitValue == 1)
            {
                channel = 0xffffffffffffffff;
            }

            uint fromFirst = 0;

            DeLibNET.DapiDOSet64(cardHandle, fromFirst, channel);
        }
 /// <summary>
 /// Sets a value to a specific DO channel
 /// </summary>
 /// <param name="cardHandle">
 /// The handle of the opened card
 /// </param>
 /// <param name="relay">
 /// The Relay to set
 /// </param>
 /// <param name="bitValue">
 /// The value to set (0 or 1)
 /// </param>
 /// <returns>
 /// True if the Relay was correctly set
 /// </returns>
 private static bool SetValueToRelay(uint cardHandle, uint relay, uint bitValue)
 {
     DeLibNET.DapiDOSet1(cardHandle, Convert.ToUInt32(relay), bitValue);
     return(ValidateRelayState(cardHandle, relay, bitValue));
 }
 /// <summary>
 /// Gets the size out the digital outputs from the card
 /// </summary>
 /// <param name="handle">
 /// The handle of the opened card
 /// </param>
 /// <returns>
 /// The digital output size of the card
 /// </returns>
 private static uint GetCardDigitalOutputSize(uint handle)
 {
     return(DeLibNET.DapiSpecialCommand(handle, DeLibNET.DAPI_SPECIAL_CMD_GET_MODULE_CONFIG, DeLibNET.DAPI_SPECIAL_GET_MODULE_CONFIG_PAR_DO, 0, 0));
 }
 /// <summary>
 /// Closes a module
 /// </summary>
 /// <param name="handle">
 /// The handle of the opened card
 /// </param>
 private static void CloseModule(uint handle)
 {
     DeLibNET.DapiCloseModule(handle);
 }