Пример #1
0
        /// <summary>
        /// 获取设备列表
        /// </summary>
        public List <List <IOdevice> > GetDevice()
        {
            BuildConnection();
            int slaveNum = ConnectionContext.deviceNum;

            List <List <IOdevice> > deviceContiner = new List <List <IOdevice> >(); //全部device
            List <IOdevice>         devGroup       = null;                          //一个device组
            IOdevice tmpDevice = null;

            for (int i = 1; i < slaveNum + 2; i++)
            {
                HtEcEntity    tmpSlave     = new HtEcEntity();
                StringBuilder tmpSlaveName = new StringBuilder();
                tmpSlaveName.Capacity = 128;

                int err = HtEcConnector.getSlaveInfo(tmpSlaveName, ref tmpSlave, i);

                if (tmpSlave.type == 10 || tmpSlave.type == 20) //耦合器或驱动器
                {
                    if (devGroup != null)
                    {
                        deviceContiner.Add(devGroup);
                    }
                    devGroup = new List <IOdevice>();
                }

                tmpDevice = new IOdevice(tmpSlave.id, DeviceType.NULL, tmpSlaveName.ToString(), tmpSlave.channelNum);
                //type
                switch (tmpSlave.type)
                {
                case 1:
                    tmpDevice.type = DeviceType.DI;
                    break;

                case 2:
                    tmpDevice.type = DeviceType.DO;
                    break;

                case 3:
                    tmpDevice.type = DeviceType.AI;
                    break;

                case 4:
                    tmpDevice.type = DeviceType.AO;
                    break;

                case 10:
                    tmpDevice.type = DeviceType.COUPLER;
                    break;

                case 20:
                    tmpDevice.type = DeviceType.SOLVER;
                    break;

                default:
                    break;
                }

                devGroup.Add(tmpDevice);
                tmpSlaveName.Clear();
            }
            deviceContiner.Add(devGroup);
            return(deviceContiner);
        }
Пример #2
0
 public static extern int getSlaveInfo(StringBuilder slaveName, ref HtEcEntity slaveInfo, int id);