Ejemplo n.º 1
0
        /// <summary>
        /// 根据轴信息和设备信息
        /// </summary>
        void GenCompareTrigs()
        {
            //int err = 0;
            cmpTrigs.Clear();
            ////先生成轴对应的触发模块  //轴的对应触发器,也是通过在HTM——BSM配置软件中添加其他设备完成
            //List<int> axesIDs = new List<int>();
            //int axisNum = HTM.GetAxisNum();
            //for(int i = 0; i < axisNum;i++)
            //{
            //    HTM.AXIS_INFO ai;
            //    HTM.GetAxisInfo(i, out ai);
            //    if(ai.driveType == (byte)HTM.DeviceType.HTDHVD) //伺服轴
            //    //if(ai.axisType == (byte)HTM.AxisType.LINE || ai.axisType == (byte)HTM.AxisType.SERVO)   //上面一行代码无法确定轴是否有触发功能,暂时使用直线电机代替
            //        axesIDs.Add(i);
            //}
            //if (axesIDs.Count > 0)
            //{
            //    HtmCompareTrigger trig = new HtmCompareTrigger(HtmCompareTrigger.TriggerType.AxisSlave, axesIDs.ToArray());
            //    cmpTrigs.Add(trig);
            //    trig.Open();
            //}
            //生成位置触发板对应的
            int        devNum         = HTM.GetDeviceNum(); //所有其他设备的数量,包括光源驱动板/位置触发板/虚拟位置触发板/串口设备等
            List <int> axisTrigDevIDs = new List <int>();   //int trigBoardCount = 0;

            for (int i = 0; i < devNum; i++)
            {
                HTM.DEVICE_INFO di;
                HTM.GetDeviceInfo(i, out di);
                if (di.devType == (byte)HTM.DeviceType.HTDHVD)//轴自带位置比较触发器(虚拟位置触发板)
                //|| di.devType ==(byte)HTM.DeviceType.POSTRIG)//位置触发板
                {
                    axisTrigDevIDs.Add(i);
                    //trigBoardCount ++;
                }
            }
            if (axisTrigDevIDs.Count > 0)
            {
                HtmCompareTrigger cmpTrigger = new HtmCompareTrigger(HtmCompareTrigger.TriggerType.AxisSlave, axisTrigDevIDs.ToArray());
                cmpTrigs.Add(cmpTrigger);
                cmpTrigger.Open();
            }
        }
Ejemplo n.º 2
0
        bool HasCompareTrigger()
        {
            int  devCount = HTM.GetDeviceNum();
            bool ret      = false;

            for (int i = 0; i < devCount; i++)
            {
                HTM.DEVICE_INFO devInfo;
                if (0 == HTM.GetDeviceInfo(i, out devInfo))
                {
                    if (devInfo.devType == (byte)HTM.DeviceType.POSTRIG || devInfo.devType == (int)HTM.DeviceType.HTDHVD)
                    {
                        ret = true;
                        break;
                    }
                }
            }
            return(ret);
        }