Example #1
0
        public List <TDIO_ChannelInfo> DIOQueryChannelList(uint loginid, string devname = "")
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGetChlInfo loginid:" + loginid + ",devname:" + devname);
            IntPtr ptr    = Marshal.AllocHGlobal(1000);
            uint   ChlNum = 0;

            IVXStreamIOSDKProtocol.StrmGetChlNum(loginid, out ChlNum);
            IntPtr pchlinfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CHLSINFO)) * (int)ChlNum);
            uint   retVal   = IVXStreamIOSDKProtocol.StrmGetChlInfo(loginid, ChlNum, pchlinfo);

            if (retVal > 0)
            {
                DIO_GetError(retVal);
            }
            List <TDIO_ChannelInfo> ret = new List <TDIO_ChannelInfo>();
            StringBuilder           sb  = new StringBuilder();

            for (int i = 0; i < ChlNum; i++)
            {
                CHLSINFO         temp = (CHLSINFO)Marshal.PtrToStructure(pchlinfo + Marshal.SizeOf(typeof(CHLSINFO)) * i, typeof(CHLSINFO));
                TDIO_ChannelInfo info = new TDIO_ChannelInfo();
                info.szChannelId   = string.IsNullOrEmpty(devname) ? temp.ChlId : devname + " " + temp.ChlId;
                info.szChannelName = temp.ChlName;
                //info.szRest = temp.Rest;
                info.szRest = loginid.ToString();
                //if (temp.Status == 1)
                ret.Add(info);
                sb.AppendLine("szChannelId:" + info.szChannelId + ",szChannelName:" + info.szChannelName + ",szRest:" + info.szRest);
            }

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGetChlInfo ret:" + 0 + ",list:" + sb.ToString());
            return(ret);
        }