Esempio n. 1
0
 public void Dispose()
 {
     if (_id != 0)
     {
         CheckErrorCode(CdioSdk.DioExit(_id));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initialize Cdio device
        /// </summary>
        /// <returns></returns>
        public void Init()
        {
            var pnt = Marshal.AllocHGlobal(Marshal.SizeOf(sizeof(short)));

            CheckErrorCode(CdioSdk.DioInit("DIO000", pnt));

            _id = Marshal.ReadInt16(pnt);
        }
Esempio n. 3
0
        public void GetMaxPorts(out short inputPorts, out short outputPorts)
        {
            var inPnt  = Marshal.AllocHGlobal(Marshal.SizeOf(sizeof(short)));
            var outPnt = Marshal.AllocHGlobal(Marshal.SizeOf(sizeof(short)));

            CheckErrorCode(CdioSdk.DioGetMaxPorts(_id, inPnt, outPnt));

            inputPorts  = Marshal.ReadInt16(inPnt);
            outputPorts = Marshal.ReadInt16(outPnt);
        }
Esempio n. 4
0
        private void CheckErrorCode(long errorCode)
        {
            if (errorCode != 0)
            {
                var errorString = new StringBuilder(256);

                CdioSdk.DioGetErrorString(errorCode, errorString);

                throw new CdioDeviceException(errorCode, errorString.ToString());
            }
        }
Esempio n. 5
0
 public void SetTrigger(short bitNo, CdioTriggerTypeEnum triggerType, int pollingInterval)
 {
     CheckErrorCode(CdioSdk.DioSetTrgEvent(_id, bitNo, (short)triggerType, pollingInterval));
 }
Esempio n. 6
0
 public void SetTriggerCallback(TriggerCallback callback)
 {
     CheckErrorCode(CdioSdk.DioSetTrgCallBackProc(_id, new CdioSdk.TrgCallBack((short id, short message, long wParam, long lParam, IntPtr userData1) => {
         callback((short)wParam, (CdioTriggerTypeEnum)lParam);
     }), IntPtr.Zero));
 }