Beispiel #1
0
        public int SetTrigLiner(int encChn, JFCompareTrigLinerParam linerParam)
        {
            if (!IsOpen)
            {
                return((int)ErrorDef.NotOpen);
            }

            if (encChn < 0 || encChn >= EncoderChannels)
            {
                throw new ArgumentOutOfRangeException("SetTrigMode(encChn ,...) fialed By:encChn = " + encChn + " is outof range:0~" + (EncoderChannels - 1));
            }

            if (trigLiners[encChn] == linerParam)
            {
                return((int)ErrorDef.Success);
            }

            if (linerParam.repeats < 0)
            {
                return((int)ErrorDef.ParamError);
            }

            HTM.TRIG_LINEAR tl = new HTM.TRIG_LINEAR();
            tl.startPos = linerParam.start;
            tl.interval = linerParam.interval;
            if (linerParam.repeats == 0)
            {
                tl.endPos = tl.startPos;
            }
            else
            {
                if (linerParam.interval >= 0)
                {
                    tl.endPos = tl.startPos + (linerParam.repeats + 0.5) * linerParam.interval;
                }
                else
                {
                    tl.endPos = tl.startPos + (linerParam.repeats - 0.5) * linerParam.interval;
                }
            }
            int err = HTM.SetLinTrigPos(devIndexes[encChn], ref tl);

            if (0 != err)
            {
                return((int)ErrorDef.InvokeFailed);
            }
            trigLiners[encChn] = linerParam;
            return((int)ErrorDef.Success);
        }
Beispiel #2
0
        internal void Open()
        {
            if (IsOpen)
            {
                return;
            }
            //devIndexes.Clear();
            trigTables.Clear();
            trigLiners.Clear();
            trigModes.Clear();
            //trigEnables.Clear();
            int err, i, j;

            //int devCount = HTM.GetDeviceNum();
            //for (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)
            //        {
            //            devIndexes.Add(i);
            //        }
            //}
            //if (devIndexes.Count == 0)
            //    return;


            for (i = 0; i < TrigChannels; i++)
            {
                trigTables.Add(new double[2] {
                    0, 0
                });
                if (trigType == TriggerType.PosTrig) //目前只有位置触发板卡支持点表模式
                {
                    for (j = 0; j < 2; j++)
                    {
                        err = HTM.SetPtTrigPos(devIndexes[i], j, trigTables[i][j]);
                        if (err != 0)
                        {
                            throw new Exception(string.Format("HtmCompareTrigger.Open() failed By HTM.SetPtTrigPos(devIndexes = {0},ptIndex = {1},0) return Errorcode = {2}", devIndexes[i], j, err));
                        }
                    }
                    for (j = 0; j < 2; j++)
                    {
                        err = HTM.SetPtTrigEnable(devIndexes[i], j, 0);
                        if (0 != err)
                        {
                            throw new Exception(string.Format("HtmCompareTrigger.Open() failed By HTM.SetPtTrigEnable(devIndexes = {0},j = {1},0) return Errorcode = {2}", devIndexes[i], j, err));
                        }
                    }
                }

                HTM.TRIG_LINEAR tl = new HTM.TRIG_LINEAR()
                {
                    startPos = 0, endPos = 0, interval = 1
                };
                err = HTM.SetLinTrigPos(devIndexes[i], ref tl);
                //if (0 != err)
                // throw new Exception(string.Format("HtmCompareTrigger.Open() failed By HTM.SetLinTrigPos(devIndexes = {0},TRIG_LINEAR =\"0,0,0\") return Errorcode = {1}", devIndexes[i], err));


                err = HTM.SetLinTrigEnable(devIndexes[i], 0);
                //if (0 != err)
                // throw new Exception(string.Format("HtmCompareTrigger.Open() failed By HTM.SetLinTrigEnable(devIndexes = {0},0) return Errorcode = {1}", devIndexes[i], err));


                trigModes.Add(JFCompareTrigMode.disable);

                trigLiners.Add(new JFCompareTrigLinerParam()
                {
                    start = 0, interval = 0, repeats = 0
                });
                //trigEnables.Add(false);
            }
            IsOpen = true;
        }