IBlowingDetect.cs 9.92 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
using FObjBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace FLY.Thick.Blowing.IService
{
    /// <summary>
    /// 旋转架及膜位置检测模拟
    /// </summary>
    public interface IBlowingDetect:INotifyPropertyChanged
    {
        #region 参数

        /// <summary>
        /// 离开限位 到 撞下一个限位 的 旋转架转动总角度 单位°
        /// </summary>
        double RAngle { get; set; }

        /// <summary>
        /// 人字架 旋转1周 设置 时间。 
        /// 刚开机时,RenZiJiaPeriod = DefaultRPeriod;
        /// 异常时,RenZiJiaPeriod = DefaultRPeriod;
        /// </summary>
        TimeSpan DefaultRPeriod { get; set; }

        /// <summary>
        /// 加速减速时间,  默认1s  加速减速时间 * 2 +正反转冷却时间 = 撞限位 到 离开限位 的时间
        /// </summary>
        TimeSpan AccDecTime { get; set; }

        /// <summary>
        /// 信号0 撞2次。 这个能自动设置。 两个撞同一信号 间隔30秒内,算一个换向信号。 
        /// 当为2次撞时:  StartTime = 第1次撞的StartTime, EndTime = 第2次撞的EndTime
        /// </summary>
        bool IsSign0Double { get; set; }

        /// <summary>
        /// 信号1 撞2次。 这个能自动设置。 两个撞同一信号 间隔30秒内,算一个换向信号。 
        /// 当为2次撞时:  StartTime = 第1次撞的StartTime, EndTime = 第2次撞的EndTime
        /// </summary>
        bool IsSign1Double { get; set; }

        /// <summary>
        /// 信号模式, 短信号模式(只撞一下),长信号模式(只要是转着,信号就长亮,直到换向)
        /// </summary>
        BlowingSignType SignType { get; set; }

        /// <summary>
        /// 撞限位 到 离开限位 的时间, 需要初始值,以后测量出来的
        /// </summary>
        TimeSpan LimitSignTime { get; set; }

        /// <summary>
        /// 人字架到测厚仪膜长 单位m
潘栩锋's avatar
潘栩锋 committed
58
        /// 当旋转架为立式时, 膜长为人字架复位时,的最短膜距离
潘栩锋's avatar
潘栩锋 committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
        /// </summary>
        double FilmLength { get; set; }

        /// <summary>
        /// 辊周长,单位mm
        /// </summary>
        double RollPerimeter { get; set; }

        /// <summary>
        /// 转向信号100ms 滤波
        /// </summary>
        bool IsSignFilter { get; set; }

        /// <summary>
        /// 缺少信号模式
        /// 正反信号线接得不好,有时候会丢失了。 
        /// 当前的旋转时间是上一次的1.1倍时,在以前的位置增加信号!!!!
        /// 当有连续两次相同的信号,且信号差刚好是旋转时间的1.9~2.1倍时,证明真的是缺少信号
        /// </summary>
        bool IsLackSignMode { get; set; }

潘栩锋's avatar
潘栩锋 committed
80 81 82 83 84 85 86
        /// <summary>
        /// 旋转架为立式,测厚仪安装在二牵引前面,膜距离 与 旋转角度 一起变化, 旋转角度越大 膜距离越大
        /// </summary>
        bool Is3D { get; set; }



潘栩锋's avatar
潘栩锋 committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
        #endregion

        #region 状态
        /// <summary>
        /// 当前旋转架旋转角度
        /// </summary>
        double Angle { get; }

        /// <summary>
        /// 当前方向
        /// </summary>
        Misc.DIRECTION Direction { get; }

        /// <summary>
        /// 旋转次数
        /// </summary>
        int RotationCnt { get; }

        /// <summary>
        /// 最新的限位信号序号
        /// </summary>
        int LastLimitNo { get; }

        /// <summary>
        /// 最后一次撞限位,或离开限位信号 到当前已经消耗的时间
        /// </summary>
        TimeSpan PastTime { get; }

        /// <summary>
        /// 当前线速度,单位 m/min
        /// </summary>
        double FilmVelocity { get; }

        /// <summary>
        /// 离开限位 到 撞下一个限位  的 旋转架转动时间, 需要初始值,以后测量出来的
        /// </summary>
        TimeSpan RenZiJiaPeriod { get; }

        /// <summary>
        /// 正反转冷却时间, 加速减速时间 * 2 +正反转冷却时间 = 撞限位 到 离开限位 的时间 
        /// </summary>
        TimeSpan SwapCoolTime { get; }

130 131 132 133
        /// <summary>
        /// 缓冲区拥有数据的时间长度,1s更新一次
        /// </summary>
        TimeSpan BufTotalTime { get; }
潘栩锋's avatar
潘栩锋 committed
134 135
        #endregion

潘栩锋's avatar
潘栩锋 committed
136
        #region 功能
潘栩锋's avatar
潘栩锋 committed
137
        /// <summary>
潘栩锋's avatar
潘栩锋 committed
138
        /// 参数应用
潘栩锋's avatar
潘栩锋 committed
139 140
        /// </summary>
        void Apply();
潘栩锋's avatar
潘栩锋 committed
141

潘栩锋's avatar
潘栩锋 committed
142 143 144 145 146 147 148
        /// <summary>
        /// 获取 信号列表
        /// </summary>
        /// <param name="AsyncDelegate">retdata = GetBufListReponse</param>
        /// <param name="AsyncState"></param>
        void GetSignList(AsyncCBHandler AsyncDelegate, object AsyncState);

潘栩锋's avatar
潘栩锋 committed
149 150 151 152 153 154 155 156 157 158 159
        /// <summary>
        /// 获取 辊信号列表
        /// </summary>
        /// <param name="begin">开始时间</param>
        /// <param name="AsyncDelegate">retdata = GetRollListReponse</param>
        /// <param name="AsyncState"></param>
        void GetRollList(DateTime begin, AsyncCBHandler AsyncDelegate, object AsyncState);

        /// <summary>
        /// 获取 转向信号列表
        /// </summary>
160
        /// <param name="begin">开始时间</param>
潘栩锋's avatar
潘栩锋 committed
161 162
        /// <param name="AsyncDelegate">retdata = GetRollListReponse</param>
        /// <param name="AsyncState"></param>
163
        void GetLimitList(DateTime begin, AsyncCBHandler AsyncDelegate, object AsyncState);
潘栩锋's avatar
潘栩锋 committed
164 165 166 167 168 169 170 171 172 173 174 175 176

        /// <summary>
        /// 获取 立式旋转架 的 膜距离增量
        /// </summary>
        /// <param name="AsyncDelegate">retdata = GetFilmLength3DReponse</param>
        /// <param name="AsyncState"></param>
        void GetFilmLength3D(AsyncCBHandler AsyncDelegate, object AsyncState);

        /// <summary>
        /// 设置 立式旋转架 的 膜距离增量
        /// </summary>
        /// <param name="data"></param>
        void SetFilmLength3D(List<double> data);
潘栩锋's avatar
潘栩锋 committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
        #endregion
    }


    /// <summary>
    /// 正反转信号类型
    /// </summary>
    public enum BlowingSignType
    {
        /// <summary>
        /// 短信号模式, 撞输入口 为0, 离开输入口为1
        /// </summary>
        Short,
        /// <summary>
        /// 长信号模式,撞输入口 为0,直到切换为下一个信号,才恢复为1
        /// </summary>
        Long
    }

    /// <summary>
    /// 信号
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
199
    public class SignData : INotifyPropertyChanged
潘栩锋's avatar
潘栩锋 committed
200
    {
潘栩锋's avatar
潘栩锋 committed
201

潘栩锋's avatar
潘栩锋 committed
202 203 204
        /// <summary>
        /// 信号序号
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
205
        public int No { get; set; }
潘栩锋's avatar
潘栩锋 committed
206 207 208 209 210


        /// <summary>
        /// 时间
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
211
        public DateTime Time { get; set; }
潘栩锋's avatar
潘栩锋 committed
212 213 214 215

        /// <summary>
        /// on? off?
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
216 217
        public bool On { get; set; }

潘栩锋's avatar
潘栩锋 committed
218 219 220 221

        /// <summary>
        /// 与上一次的时间间隔
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
222 223
        public TimeSpan Interval { get; set; }

潘栩锋's avatar
潘栩锋 committed
224

潘栩锋's avatar
潘栩锋 committed
225 226 227 228 229 230 231 232
        public event PropertyChangedEventHandler PropertyChanged;
    }

    /// <summary>
    /// 辊信号时间
    /// </summary>
    public class RollCell
    {
潘栩锋's avatar
潘栩锋 committed
233
        /// <summary>
潘栩锋's avatar
潘栩锋 committed
234
        /// 创建副本
潘栩锋's avatar
潘栩锋 committed
235 236
        /// </summary>
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
237
        public RollCell Clone()
潘栩锋's avatar
潘栩锋 committed
238
        {
潘栩锋's avatar
潘栩锋 committed
239 240 241
            RollCell r = new RollCell();
            r.dt = dt;
            return r;
潘栩锋's avatar
潘栩锋 committed
242
        }
潘栩锋's avatar
潘栩锋 committed
243 244
        public DateTime dt;
        public override string ToString()
潘栩锋's avatar
潘栩锋 committed
245
        {
潘栩锋's avatar
潘栩锋 committed
246
            return dt.ToString();
潘栩锋's avatar
潘栩锋 committed
247
        }
潘栩锋's avatar
潘栩锋 committed
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
    }

    /// <summary>
    /// 撞向信号
    /// </summary>
    public class LimitCell
    {
        /// <summary>
        /// 信号开始
        /// </summary>
        public DateTime dt_begin = DateTime.MinValue;
        /// <summary>
        /// 信号结束
        /// </summary>
        public DateTime dt_end = DateTime.MinValue;
        /// <summary>
        /// 信号序号 0 或 1
        /// </summary>
        public int no = 0;
        /// <summary>
        /// 两次撞转向 = 1次信号
        /// </summary>
        public bool isDouble = false;
        /// <summary>
        /// 当为两次撞转向, 第1次撞结束时间。用于当两次信号发生时间间隔很长,现在肯定就只有一次撞转向而已
        /// </summary>
        public DateTime dt_mid = DateTime.MinValue;

        /// <summary>
        /// 这是一个虚拟的信号
        /// </summary>
        public bool isVirtual = false;

潘栩锋's avatar
潘栩锋 committed
281
        /// <summary>
潘栩锋's avatar
潘栩锋 committed
282
        /// 创建副本
潘栩锋's avatar
潘栩锋 committed
283 284
        /// </summary>
        /// <returns></returns>
潘栩锋's avatar
潘栩锋 committed
285
        public LimitCell Clone()
潘栩锋's avatar
潘栩锋 committed
286
        {
潘栩锋's avatar
潘栩锋 committed
287 288 289 290 291 292 293 294 295
            LimitCell l = new LimitCell();

            l.dt_begin = dt_begin;
            l.dt_end = dt_end;
            l.dt_mid = dt_mid;
            l.isDouble = isDouble;
            l.isVirtual = isVirtual;
            l.no = no;
            return l;
潘栩锋's avatar
潘栩锋 committed
296 297 298 299 300
        }

        /// <summary>
        /// 
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
301 302
        /// <returns></returns>
        public override string ToString()
潘栩锋's avatar
潘栩锋 committed
303
        {
潘栩锋's avatar
潘栩锋 committed
304
            return no.ToString() + " " + ((isDouble) ? "D" : "S") + " (" + dt_begin.ToString() + "-" + dt_end.ToString() + ") " + (isVirtual ? "V" : "");
潘栩锋's avatar
潘栩锋 committed
305
        }
潘栩锋's avatar
潘栩锋 committed
306 307 308 309 310 311 312 313 314 315 316 317 318 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
    }


    /// <summary>
    /// GetSignList 返回
    /// </summary>
    public class GetSignListReponse 
    {
        public List<SignData> datas;
    }

    /// <summary>
    /// GetRollList 参数
    /// </summary>
    public class GetRollListRequest
    {
        public DateTime begin;
    }
    /// <summary>
    /// GetRollList 返回
    /// </summary>
    public class GetRollListReponse
    {
        public List<RollCell> datas;
    }


    /// <summary>
    /// GetFilmLength3D 返回
    /// </summary>
    public class GetFilmLength3DReponse
    {
        public List<double> datas;
    }

    /// <summary>
    /// 
    /// </summary>
    public class GetLimitListRequest
    {
346
        public DateTime begin;
潘栩锋's avatar
潘栩锋 committed
347
    }
潘栩锋's avatar
潘栩锋 committed
348

潘栩锋's avatar
潘栩锋 committed
349
    /// <summary>
潘栩锋's avatar
潘栩锋 committed
350
    /// 
潘栩锋's avatar
潘栩锋 committed
351
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
352
    public class GetLimitListReponse
潘栩锋's avatar
潘栩锋 committed
353
    {
潘栩锋's avatar
潘栩锋 committed
354
        public List<LimitCell> datas;
潘栩锋's avatar
潘栩锋 committed
355
    }
潘栩锋's avatar
潘栩锋 committed
356

潘栩锋's avatar
潘栩锋 committed
357
}