示例#1
0
 public void Dispose()
 {
     if (_id != 0)
     {
         CheckErrorCode(CdioSdk.DioExit(_id));
     }
 }
示例#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);
        }
示例#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);
        }
示例#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());
            }
        }
示例#5
0
 public void SetTrigger(short bitNo, CdioTriggerTypeEnum triggerType, int pollingInterval)
 {
     CheckErrorCode(CdioSdk.DioSetTrgEvent(_id, bitNo, (short)triggerType, pollingInterval));
 }
示例#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));
 }