BlowingDetect360Core.cs 19.4 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5
using FLY.Thick.Blowing;
using FLY.Thick.Blowing.IService;
using Misc;
using System;
using System.Collections.Generic;
潘栩锋's avatar
潘栩锋 committed
6
using System.ComponentModel;
潘栩锋's avatar
潘栩锋 committed
7 8 9 10 11 12 13 14 15 16 17 18 19
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.Thick.Blowing360.UI
{

    public class BlowingDetect360Core
    {
        /// <summary>
        /// 辊周长,单位mm
        /// </summary>
        public double RollPerimeter;
潘栩锋's avatar
潘栩锋 committed
20 21 22 23 24 25

        /// <summary>
        /// 辊周长,单位m
        /// </summary>
        double MofR => RollPerimeter / 1000.0;

潘栩锋's avatar
潘栩锋 committed
26 27 28 29
        /// <summary>
        /// 离开限位 到 撞下一个限位  的 旋转架转动时间, 需要初始值,以后测量出来的
        /// </summary>
        public TimeSpan RenZiJiaPeriod;
潘栩锋's avatar
潘栩锋 committed
30

潘栩锋's avatar
潘栩锋 committed
31 32 33 34
        /// <summary>
        /// 人字架到测厚仪膜长 单位m
        /// </summary>
        public double FilmLength;
潘栩锋's avatar
潘栩锋 committed
35

潘栩锋's avatar
潘栩锋 committed
36 37 38 39 40
        /// <summary>
        /// 累计旋转次数
        /// </summary>
        public int RotationCnt;

潘栩锋's avatar
潘栩锋 committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
        /// <summary>
        /// 使用编码器检测旋转架旋转位置模式
        /// </summary>
        public bool IsRPosMode;

        /// <summary>
        /// 人字架 离开限位 到 撞下一个限位 的 旋转架转动总脉冲 单位 脉冲
        /// </summary>
        public int RPosOfR;

        /// <summary>
        /// 原点旋转脉冲 上一次撞限位开关0时, 旋转架脉冲
        /// </summary>
        public int OrgRPos;

        /// <summary>
        /// 刚开机,信号列表一个信号都没有,创造一个时间点,作为信号点
        /// </summary>
        public DateTime DefaultTime;

        /// <summary>
        /// 旋转脉冲列表
        /// </summary>
        public List<RPosData> mRPosList;

潘栩锋's avatar
潘栩锋 committed
66 67 68
        /// <summary>
        /// 辊信号列表
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
69
        public List<RollCell2> mRollList;
潘栩锋's avatar
潘栩锋 committed
70 71 72 73 74 75

        /// <summary>
        /// 转向信号列表
        /// </summary>
        public List<LimitCell> mLimitList;

潘栩锋's avatar
潘栩锋 committed
76 77
        public Misc.DIRECTION Direction;

潘栩锋's avatar
潘栩锋 committed
78 79 80 81 82 83 84 85 86
        /// <summary>
        /// 
        /// </summary>
        public BlowingDetect360Core()
        {

        }

        public void Init(
潘栩锋's avatar
潘栩锋 committed
87 88 89 90 91 92 93 94 95 96 97
            double rollPerimeter,
            TimeSpan renZiJiaPeriod,
            double filmLength,
            List<RollCell> rollList,
            List<LimitCell> limitList,
            DateTime defaultTime,
            bool isRPosMode,
            int orgRPos,
            int rPosOfR,
            List<RPosData> rPosList,
            Misc.DIRECTION direction
潘栩锋's avatar
潘栩锋 committed
98 99
            )
        {
潘栩锋's avatar
潘栩锋 committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
            Direction = direction;
            RollPerimeter = rollPerimeter;
            RenZiJiaPeriod = renZiJiaPeriod;
            FilmLength = filmLength;

            IsRPosMode = isRPosMode;
            RPosOfR = rPosOfR;
            DefaultTime = defaultTime;
            OrgRPos = orgRPos;

            mRPosList = rPosList;

            mLimitList = limitList;

            RotationCnt = limitList.Count();

            //组装 rPosList 与 rollList
            mRollList = rollList.Select(r => new RollCell2() { Time = r.Time, SysTime = r.SysTime }).ToList();
潘栩锋's avatar
潘栩锋 committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
        }

        int RotationCntToLimitIndex(int rotationcnt)
        {
            if (RotationCnt == 0)
                return -1;
            else
                return rotationcnt - 1 - (RotationCnt - mLimitList.Count);
        }
        /// <summary>
        /// 正反转信号列表中的序号,转旋转次数
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        int LimitIndexToRotationCnt(int index)
        {
            if (RotationCnt == 0)
                return 0;
            else
                return RotationCnt - mLimitList.Count + index + 1;
        }

潘栩锋's avatar
潘栩锋 committed
140 141


潘栩锋's avatar
潘栩锋 committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162

        /// <summary>
        /// 获取当前在膜上的测量点,对应于膜泡的角度信息, 当时间点,比LimitList.Last.dt+RenZiJiaPeriod还要后,更新RenZiJiaPeriod
        /// 返回 -1, 当前的时间点在列表以前;
        /// 返回 0, 当前的时间点在列表中;
        /// 返回 1, 当前的时间点在列表的未来;
        /// </summary>
        /// <param name="filmWidth">被压扁后的膜宽度</param>
        /// <param name="filmPosH">探头所在膜的横向位置</param>
        /// <param name="dt">测量的时间点</param>
        /// <returns></returns>
        public int GetFilmInfo(out FilmInfo filminfo, DateTime dt)
        {
            double filmLen = FilmLength;


            filminfo = null;



            Misc.DIRECTION direction = Direction;
潘栩锋's avatar
潘栩锋 committed
163

潘栩锋's avatar
潘栩锋 committed
164 165 166 167 168 169
            if (dt == DateTime.MinValue)
            {
                //TODO, BUG
                return -1;//不在膜的范围内
            }

潘栩锋's avatar
潘栩锋 committed
170
            int ret = GetAgo(dt, out DateTime ago_dt, out int ago_index);
潘栩锋's avatar
潘栩锋 committed
171 172 173 174 175
            if (ret == 1)
                return ret;//发生在未来不处理!!!

            GetAngle(
                ago_dt, 
潘栩锋's avatar
潘栩锋 committed
176 177 178
                out double angle0, out int rotationcnt);

            double velocity = RollList_GetVelocity(ago_index);
潘栩锋's avatar
潘栩锋 committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201

            filminfo = new FilmInfo()
            {
                angle1 = angle0,
                angle2 = angle0,
                filmVelocity = velocity,
                direction = direction,
                rotationCnt = rotationcnt,
                inCV = true
            };
            return ret;
        }

        #region 人字架时间点<-->24m后膜时间点
        /// <summary>
        /// 输入当前时间点,找到 刚出人字架时的时间点, 及那时候的线速度;
        /// 返回 -1, 当前的时间点在列表以前;
        /// 返回 0, 当前的时间点在列表中;
        /// 返回 1, 当前的时间点在列表的未来;
        /// </summary>
        /// <param name="dt">当前时间</param>
        /// <param name="ago_dt">24米真实长度</param>
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
202 203 204 205 206 207 208 209 210 211 212 213
        int GetAgo(DateTime dt, out DateTime ago_dt, out int ago_index)
        {
            return GetAgoFix(dt, out ago_dt, out ago_index);
        }
        /// <summary>
        /// 膜距离固定 获取膜距离前的时间点
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="ago_dt"></param>
        /// <param name="ago_index"></param>
        /// <returns></returns>
        int GetAgoFix(DateTime dt, out DateTime ago_dt, out int ago_index)
潘栩锋's avatar
潘栩锋 committed
214 215
        {
            ago_dt = DateTime.MinValue;
潘栩锋's avatar
潘栩锋 committed
216 217 218 219
            ago_index = -1;
            int index;
            int ret = RollList_FindIndex(dt, out index);
            if (ret == 1)//发生在未来,什么都不干
潘栩锋's avatar
潘栩锋 committed
220 221
                return ret;

潘栩锋's avatar
潘栩锋 committed
222 223 224 225 226 227 228
            //纵向位置
            double filmPosition = RollList_GetPosition(index, dt);


            double filmPos0 = filmPosition - FilmLength;
            ret = RollList_GetDateTime(filmPos0, out index, out ago_dt);
            ago_index = index;
潘栩锋's avatar
潘栩锋 committed
229 230
            return ret;

潘栩锋's avatar
潘栩锋 committed
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245

        }
        /// <summary>
        /// 输入过去时间,让它再加上膜长时间,得到未来时间;
        /// 返回 -1, 未来的时间在列表以前;
        /// 返回 0, 未来的时间在列表中;
        /// 返回 1, 未来的时间在列表的未来;
        /// </summary>
        /// <param name="dt">过去时间</param>
        /// <param name="dt_future">未来时间</param>
        /// <returns></returns>
        int GetFuture(DateTime dt, out DateTime dt_future)
        {
            return GetFuture(dt, FilmLength, out dt_future);
        }
潘栩锋's avatar
潘栩锋 committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
        /// <summary>
        /// 输入过去时间,让它再加上膜长时间,得到未来时间;
        /// 返回 -1, 未来的时间在列表以前;
        /// 返回 0, 未来的时间在列表中;
        /// 返回 1, 未来的时间在列表的未来;
        /// </summary>
        /// <param name="dt">过去时间</param>
        /// <param name="filmlength">膜长</param>
        /// <param name="dt_future">未来时间</param>
        /// <returns></returns>
        int GetFuture(DateTime dt, double filmlength, out DateTime dt_future)
        {
            dt_future = DateTime.MinValue;
            double position;
            int i;
            int ret = RollList_FindIndex(dt, out i);
            if (ret == -1)
                position = RollList_GetPosition(0, dt);
            else if (ret == 0)
                position = RollList_GetPosition(i, dt);
            else
                return ret;

潘栩锋's avatar
潘栩锋 committed
269
            position += filmlength;
潘栩锋's avatar
潘栩锋 committed
270

潘栩锋's avatar
潘栩锋 committed
271
            return RollList_GetDateTime(position, out i, out dt_future);
潘栩锋's avatar
潘栩锋 committed
272 273 274

        }
        #endregion
潘栩锋's avatar
潘栩锋 committed
275

潘栩锋's avatar
潘栩锋 committed
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
        /// <summary>
        /// 计算出角度 0~360° 恒速阶段
        /// </summary>
        /// <param name="dtEnd">旋转结束时间点</param>
        /// <param name="dtStart">旋转开始时间点</param>
        /// <param name="dt">用于转换为角度的时间</param>
        /// <param name="angle">输出: 角度</param>
        void LimitListCal_ConstantVelocity(DateTime dtEnd, DateTime dtStart, DateTime dt, out double angle)
        {
            TimeSpan ts1 = dt - dtStart;
            TimeSpan ts2 = dtEnd - dtStart;

            angle = 360 * ts1.Ticks / ts2.Ticks;
        }

        /// <summary>
潘栩锋's avatar
潘栩锋 committed
292
        /// 时间点查找旋转角度 0~360°
潘栩锋's avatar
潘栩锋 committed
293 294 295 296 297 298 299
        /// </summary>
        /// <param name="dt">时间</param>
        /// <param name="modifyparam">当dt 发生在限位列表的未来,是否修改参数,如RenZiJiaPeriod</param>
        /// <param name="angle">角度</param>
        /// <param name="direction">旋转的方向</param>
        /// <param name="rotationCnt">旋转的次数</param>
        /// <param name="inCV">在恒速区</param>
潘栩锋's avatar
潘栩锋 committed
300
        void GetAngle(DateTime dt, bool modifyparam, out double angle, out int rotationCnt)
潘栩锋's avatar
潘栩锋 committed
301 302 303 304 305 306 307 308 309 310 311
        {
            int index;
            ListFindIndexResult ret = LimitList_FindIndex(dt, out index);

            DateTime dt_start;
            DateTime dt_end;

            switch (ret)
            {
                case ListFindIndexResult.Future://发生在未来 
                    {
潘栩锋's avatar
潘栩锋 committed
312 313 314
                        if (dt < DefaultTime)
                            DefaultTime = dt - TimeSpan.FromSeconds(10);

潘栩锋's avatar
潘栩锋 committed
315
                        //检测是否需要修正 RenZiJiaPeriod
潘栩锋's avatar
潘栩锋 committed
316
                        if (mLimitList.Count == 0)
潘栩锋's avatar
潘栩锋 committed
317
                        {
潘栩锋's avatar
潘栩锋 committed
318
                            dt_start = DefaultTime;
潘栩锋's avatar
潘栩锋 committed
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
                        }
                        else
                        {
                            dt_start = mLimitList[index].dt_begin;
                        }
                        rotationCnt = LimitIndexToRotationCnt(index);

                        if (dt > (dt_start + RenZiJiaPeriod))
                        {
                            if (modifyparam)
                            {
                                //修正!!!!
                                RenZiJiaPeriod = dt - dt_start + TimeSpan.FromSeconds(10);
                            }
                            else
                            {
                                dt = dt_start + RenZiJiaPeriod;//只是为了看,随便了。 时间停止下来
                            }
                        }

                        dt_end = dt_start + RenZiJiaPeriod;
                        LimitListCal_ConstantVelocity(dt_end, dt_start, dt, out angle);
                    }
                    break;
                case ListFindIndexResult.BetweenCells:
                    {
                        dt_start = mLimitList[index].dt_begin;
                        dt_end = mLimitList[index + 1].dt_begin;
                        rotationCnt = LimitIndexToRotationCnt(index);
                        LimitListCal_ConstantVelocity(dt_end, dt_start, dt, out angle);
                    }
                    break;
                //case ListFindIndexResult.Past://过去 
                default:
                    {

潘栩锋's avatar
潘栩锋 committed
355
                        dt_start = DefaultTime;
潘栩锋's avatar
潘栩锋 committed
356 357 358 359 360 361
                        dt_end = mLimitList[0].dt_begin;
                        rotationCnt = LimitIndexToRotationCnt(-1);
                        LimitListCal_ConstantVelocity(dt_end, dt_start, dt, out angle);
                    }
                    break;
            }
潘栩锋's avatar
潘栩锋 committed
362

潘栩锋's avatar
潘栩锋 committed
363 364 365 366
            if (Direction == DIRECTION.BACKWARD)
                angle = 360 - angle;
        }

潘栩锋's avatar
潘栩锋 committed
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
        public double GetAngleByGlobalRPos(int globalRPos)
        {
            //OrgRPos 为 -RAngle/2 

            int rPos = globalRPos - OrgRPos;

            //360°对应的旋转脉冲
            int rPosOf360 = RPosOfR;

            while (rPos < 0)
                rPos += rPosOf360;
            while (rPos > rPosOf360)
                rPos -= rPosOf360;

            double angle = 360 * rPos / RPosOfR;



            //角度范围是 0°~ 360°
            return angle;
        }


潘栩锋's avatar
潘栩锋 committed
390 391
        #region RollList 查找
        /// <summary>
潘栩锋's avatar
潘栩锋 committed
392
        /// 获取 [idx,idx+1] 之间 的 位置, 单位m
潘栩锋's avatar
潘栩锋 committed
393 394 395 396 397 398
        /// </summary>
        /// <param name="idx"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        double RollList_GetPosition(int idx, DateTime dt)
        {
潘栩锋's avatar
潘栩锋 committed
399
            DateTime dt1 = mRollList[idx + 1].Time;
潘栩锋's avatar
潘栩锋 committed
400 401 402
            double filmPos1 = (idx + 1) * MofR;
            DateTime dt0 = mRollList[idx].Time;
            double filmPos0 = (idx) * MofR;
潘栩锋's avatar
潘栩锋 committed
403

潘栩锋's avatar
潘栩锋 committed
404
            return (filmPos1 - filmPos0) * (dt - dt0).Ticks / (dt1 - dt0).Ticks + filmPos0;
潘栩锋's avatar
潘栩锋 committed
405 406
        }
        /// <summary>
潘栩锋's avatar
潘栩锋 committed
407
        /// 获取 [idx,idx+1] 之间 的 速度 m/min
潘栩锋's avatar
潘栩锋 committed
408 409 410 411 412
        /// </summary>
        /// <param name="idx"></param>
        /// <returns></returns>
        double RollList_GetVelocity(int idx)
        {
潘栩锋's avatar
潘栩锋 committed
413 414
            DateTime dt1 = mRollList[idx + 1].SysTime;
            DateTime dt2 = mRollList[idx].SysTime;
潘栩锋's avatar
潘栩锋 committed
415

潘栩锋's avatar
潘栩锋 committed
416
            return MofR / dt1.Subtract(dt2).TotalMinutes;
潘栩锋's avatar
潘栩锋 committed
417 418 419 420 421
        }
        /// <summary>
        /// 获取 [idx,idx+1] 之间 的 时间
        /// </summary>
        /// <param name="idx"></param>
潘栩锋's avatar
潘栩锋 committed
422
        /// <param name="filmPosition">纵向位置m</param>
潘栩锋's avatar
潘栩锋 committed
423
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
424
        DateTime RollList_GetDateTime(int idx, double filmPosition)
潘栩锋's avatar
潘栩锋 committed
425 426
        {
            //TODO 经常出错,position 无限小,idx=0
潘栩锋's avatar
潘栩锋 committed
427
            DateTime dt1 = mRollList[idx + 1].Time;
潘栩锋's avatar
潘栩锋 committed
428
            double filmPos1 = (idx + 1) * MofR;
潘栩锋's avatar
潘栩锋 committed
429
            DateTime dt2 = mRollList[idx].Time;
潘栩锋's avatar
潘栩锋 committed
430
            double filmPos2 = (idx) * MofR;
潘栩锋's avatar
潘栩锋 committed
431

潘栩锋's avatar
潘栩锋 committed
432
            return dt2.Add(new TimeSpan((long)((dt1 - dt2).Ticks * (filmPosition - filmPos2) / (filmPos1 - filmPos2))));
潘栩锋's avatar
潘栩锋 committed
433 434
        }
        /// <summary>
潘栩锋's avatar
潘栩锋 committed
435
        /// 通过 filmPosition 查找时间
潘栩锋's avatar
潘栩锋 committed
436 437 438 439
        /// 返回 -1,这个过去的时间;
        /// 返回 0,在列表中;
        /// 返回 1,发生在未来的时间;
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
440
        /// <param name="filmPosition">单位m</param>
潘栩锋's avatar
潘栩锋 committed
441
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
442
        int RollList_GetDateTime(double filmPosition, out int idx, out DateTime dt)
潘栩锋's avatar
潘栩锋 committed
443 444 445
        {
            idx = 0;
            dt = DateTime.MinValue;
潘栩锋's avatar
潘栩锋 committed
446 447
            if (filmPosition < 0)
                return -1;
潘栩锋's avatar
潘栩锋 committed
448 449 450 451

            if (mRollList.Count == 0)
                return 1;

潘栩锋's avatar
潘栩锋 committed
452 453
            idx = (int)(filmPosition / MofR);
            if (idx >= mRollList.Count - 1)
潘栩锋's avatar
潘栩锋 committed
454
            {
潘栩锋's avatar
潘栩锋 committed
455
                return 1;
潘栩锋's avatar
潘栩锋 committed
456
            }
潘栩锋's avatar
潘栩锋 committed
457 458
            dt = RollList_GetDateTime(idx, filmPosition);
            return 0;
潘栩锋's avatar
潘栩锋 committed
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
        }

        /// <summary>
        /// dt 这个时间,在是 index 与 index+1 中间发生的
        /// 返回 -1,这个过去的时间;
        /// 返回 0,在列表中;
        /// 返回 1,发生在未来的时间;
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        int RollList_FindIndex(DateTime dt, out int index)
        {
            index = 0;
            if (mRollList.Count <= 1)//没数据,所以是发生在未来的
                return 1;

            for (int i = mRollList.Count - 1; i >= 0; i--)
            {
潘栩锋's avatar
潘栩锋 committed
477
                if (dt >= mRollList[i].Time)
潘栩锋's avatar
潘栩锋 committed
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
                {
                    //找到了
                    if (i == (mRollList.Count - 1))//这个是未来的时间点,还没发生!!! 
                    {
                        index = i;
                        return 1;
                    }
                    else
                    {
                        index = i;
                        return 0;
                    }
                }
            }

            //这个在过去的时间
            return -1;
        }

        #endregion


        enum ListFindIndexResult
        {
            /// <summary>
            /// 发生在未来, index.dt_end ~ 未来, 可能 index都还没有发生
            /// </summary>
            Future,
            /// <summary>
            /// 发生在index.dt_begin ~ index.dt_end
            /// </summary>
            InCell,
            /// <summary>
            /// 应该发生在index.dt_begin ~ index.dt_end, 但 index.dt_end还没有数据
            /// </summary>
            MaybeInCell,
            /// <summary>
            /// 发生在 index.dt_end ~ (index+1).dt_begin
            /// </summary>
            BetweenCells,
            /// <summary>
            /// 发生在 过去
            /// </summary>
            Past
        }
        /// <summary>
        /// 找到 列表中 (开始时间,结束时间) 小于 dt 的信号点
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        ListFindIndexResult LimitList_FindIndex(DateTime dt, out int index)
        {
            index = 0;
            
            if (mLimitList.Count <= 0)//没数据,所以是发生在未来的
                throw new Exception("参数出错 mLimitList.Count == 0");


            for (int i = mLimitList.Count - 1; i >= 0; i--)
            {
                LimitCell lc = mLimitList[i];
                if (dt >= lc.dt_begin)
                {
                    //找到了
                    index = i;
                    if (lc.dt_end == DateTime.MinValue)
                    {
                        return ListFindIndexResult.MaybeInCell;
                    }
                    else if (dt <= mLimitList[i].dt_end)
                    {
                        return ListFindIndexResult.InCell;
                    }
                    else if (i == (mLimitList.Count - 1))//这个是未来的时间点,还没发生!!! 
                    {
                        return ListFindIndexResult.Future;
                    }
                    else
                    {
                        return ListFindIndexResult.BetweenCells;
                    }
                }
            }

            //这个在过去的时间
            return ListFindIndexResult.Past;
        }



        /// <summary>
        /// 获取膜角度
        /// </summary>
        /// <param name="dt">时间点</param>
        /// <param name="angle">上面的膜对应的膜角度</param>
        /// <param name="direction">人字架正转?反转? FIX, 停止!</param>
        /// <param name="rotationCnt">扫描次数</param>
        /// <param name="inCV">在恒速阶段</param>
        bool GetAngle(
            DateTime dt, 
            out double angle,
            out int rotationCnt)
        {
            //不修改旋转速度!!!!!!!!!!!!
潘栩锋's avatar
潘栩锋 committed
583
            GetAngle( dt, false, out angle, out rotationCnt);
潘栩锋's avatar
潘栩锋 committed
584 585

            double a = 0;
潘栩锋's avatar
潘栩锋 committed
586 587 588 589 590 591 592 593 594 595 596 597 598
            a = GetValidAngle(a + angle);

            angle = a;;
            return true;
        }

        /// <summary>
        /// 限制角度在 [0~360)
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        double GetValidAngle(double a)
        {
潘栩锋's avatar
潘栩锋 committed
599 600 601 602
            if (a >= 360)
                a -= 360;
            else if (a < 0)
                a += 360;
潘栩锋's avatar
潘栩锋 committed
603
            return a;
潘栩锋's avatar
潘栩锋 committed
604 605 606
        }
    }
}