IFlyAD.cs 14.2 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.ComponentModel;
using FObjBase;
using Misc;
using System.Collections.ObjectModel;
namespace FlyADBase
{
12 13 14
    /// <summary>
    /// AD盒提供的功能
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
15 16
    public interface IFlyAD : INotifyPropertyChanged
    {
17 18 19
        /// <summary>
        /// AD盒地址
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
20
        IPEndPoint LocalEP { get; set; }
21
        
潘栩锋's avatar
潘栩锋 committed
22 23 24 25 26
        /// <summary>
        /// 从flyad7 获取 的systick 转换的时间
        /// </summary>
        DateTime Now { get; }

27 28 29 30
        /// <summary>
        /// AD盒版本号 版本1 没有systick;版本2 有systick;
        /// </summary>
        int Version { get; }
潘栩锋's avatar
潘栩锋 committed
31

32 33 34
        /// <summary>
        /// 脉冲
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
35
        int Position { get; }
36 37 38
        /// <summary>
        /// 速度 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
39
        int Speed { get; }
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
        /// <summary>
        /// 1000ms从AD卡获取(或推送)1个AD值。此AD值只用于调试,定点
        /// </summary>
        int AD { get; }
        /// <summary>
        /// AD值最大值 ,恒定返回65535
        /// </summary>
        int ADMax { get; }
        
        /// <summary>
        /// 输入口状态,只有12位有效
        /// </summary>
        UInt16 IStatus { get; }

        /// <summary>
        /// 输出口状态,只有4位有效
        /// </summary>
        UInt16 OStatus { get; }

潘栩锋's avatar
潘栩锋 committed
59 60 61 62 63 64 65 66 67 68 69 70 71
        /// <summary>
        /// Out0 = 0, SetOutput(0x0001,0x0000);
        /// Out0 = 1, Out1 = 0, SetOutput(0x0003,0x0001);
        /// </summary>
        /// <param name="mask"></param>
        /// <param name="enable"></param>
        void SetOutput(UInt16 mask, UInt16 enable); 

        /// <summary>
        /// 读取参数, 全部!!!!
        /// </summary>
        void UpdateParam();

72 73 74 75 76 77 78 79
        #region 运动参数
        /// <summary>
        /// 设置 运动参数
        /// </summary>
        /// <param name="posOfGrid">脉冲/grid</param>
        /// <param name="motortype">电机类型</param>
        /// <param name="ratio01">脉冲比例 分母(电机脉冲)</param>
        /// <param name="ratio02">脉冲比例 分子(编码器脉冲)</param>
潘栩锋's avatar
潘栩锋 committed
80
        void SetSysParam(UInt16 posOfGrid, MOTORTYPE motortype, UInt16 ratio01, UInt16 ratio02);
81 82 83
        /// <summary>
        /// 电机类型
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
84
        MOTORTYPE MotorType { set; get; }
85 86 87 88 89 90 91
        /// <summary>
        /// 脉冲/grid, 最大1000个grid
        /// </summary>
        UInt16 PosOfGrid { set; get; }
        /// <summary>
        /// 脉冲比例 分母(电机脉冲)
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
92
        UInt16 Ratio01 { get; set; }
93 94 95
        /// <summary>
        /// 脉冲比例 分子(编码器脉冲)
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
96 97 98 99
        UInt16 Ratio02 { get; set; }

        #endregion

100 101 102 103 104 105 106
        /// <summary>
        /// 脉冲平移(0位处脉冲值)
        /// </summary>
        Int16 PosOffset { set; get; }
        /// <summary>
        /// 手动速度 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
107 108
        UInt32 JogVelocity { set; get; }

109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
        #region 速度参数
        /// <summary>
        /// 设置速度参数
        /// </summary>
        /// <param name="velocity">runto 速度 pps</param>
        /// <param name="sv">开始速度 pps</param>
        /// <param name="atime">加速时间 ms</param>
        /// <param name="dtime">减速时间 ms</param>
        /// <param name="hspeed1">归0 第1段速 pps</param>
        /// <param name="hspeed2">归0 第2段速 pps</param>
        void SetPosParam(UInt32 velocity, UInt32 sv, UInt32 atime, UInt32 dtime, UInt32 hspeed1, UInt32 hspeed2);
        /// <summary>
        /// 设置速度
        /// </summary>
        /// <param name="velocity"></param>
        void SetVelocity(UInt32 velocity);
        /// <summary>
        /// runto 速度 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
128
        UInt32 Velocity { set; get; }
129 130 131
        /// <summary>
        /// 开始速度 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
132
        UInt32 SVelocity { set; get; }
133 134 135
        /// <summary>
        /// 加速时间 ms
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
136
        UInt32 ATime { set; get; }
137 138 139
        /// <summary>
        /// 减速时间 ms
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
140
        UInt32 DTime { set; get; }
141 142 143
        /// <summary>
        /// 归0 第1段速 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
144
        UInt32 HVelocity1 { set; get; }
145 146 147
        /// <summary>
        /// 归0 第2段速 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
148
        UInt32 HVelocity2 { set; get; }
149
        
潘栩锋's avatar
潘栩锋 committed
150 151 152
        #endregion

        #region 密码
153 154 155
        /// <summary>
        /// 使用码区状态
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
156
        AREA_STATUS AreaStatus { get; }
157 158 159
        /// <summary>
        /// 使用码区出错码
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
        AREA_ERR AreaRet { get; }
        /// <summary>
        /// 序列码byte[6]
        /// </summary>
        byte[] Code { get; }
        /// <summary>
        /// 系统剩余时间
        /// </summary>
        int Surplus { get; }
        /// <summary>
        /// 系统授权码access[8]
        /// </summary>
        byte[] Access { get; }
        /// <summary>
        /// 输入系统授权码
        /// </summary>
176
        /// <param name="access">系统授权码access[8]</param>
潘栩锋's avatar
潘栩锋 committed
177 178 179 180 181 182 183 184 185
        void SetAccess(byte[] access);
        /// <summary>
        /// 初始化系统信息区
        /// </summary>
        void InitArea();

        #endregion


186 187 188
        /// <summary>
        /// timegrid 事件; 版本1: 1.28s 一次; 版本2: 0.2s一次, 
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
189
        event TimeGridEventHandler TimeGridEvent;
190 191 192
        /// <summary>
        /// runto 中,每经过1个grid 推送数据
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
193
        event MiniGridEventHandler MiniGridEvent;
194 195 196
        /// <summary>
        /// runto 的 grid事件
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
197
        event MiniGridEventHandler GridEvent;
198 199 200 201
        /// <summary>
        /// 输入状态改变事件
        /// </summary>
        event IStatusChangedEventHandler IStatusChangedEvent;
潘栩锋's avatar
潘栩锋 committed
202 203 204



205 206 207 208 209 210

        #region 运行动作
        /// <summary>
        /// 运行至指定位置
        /// </summary>
        /// <param name="to">脉冲</param>
潘栩锋's avatar
潘栩锋 committed
211
        void Runto(int to);
212 213 214
        /// <summary>
        /// 归原点
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
215
        void Origin();
216 217 218
        /// <summary>
        /// 停止
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
219
        void Stop();
220 221 222
        /// <summary>
        /// 反向,直到撞了限位
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
223
        void Backward();
224 225 226
        /// <summary>
        /// 正行,直到撞了限位
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
227 228
        void Forward();

229 230 231
        /// <summary>
        /// 当前运行指令
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
232
        DRIVE_MAN_ORDER DriveOrder { get; }
233 234 235
        /// <summary>
        /// 之前运行动作的状态
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
236
        DRIVE_MAN_STATUS DriveStatus { get; }
237 238
        #endregion

潘栩锋's avatar
潘栩锋 committed
239 240 241 242 243 244 245 246 247 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 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

        #region 同步
        /// <summary>
        /// 同步用标示
        /// </summary>
        Int32 Marker { get; }
        #region 横向脉冲
        /// <summary>
        /// 逻辑横向脉冲偏移  Pos1 + Pos1LCShift = Pos1LC
        /// </summary>
        int Pos1LCShift { get; set; }
        #endregion
        #region 主轴脉冲
        /// <summary>
        /// 纵向脉冲,也叫主轴脉冲
        /// </summary>
        int Position2 { get; set; }
        /// <summary>
        /// 纵向速度
        /// </summary>
        int Speed2 { get; }
        /// <summary>
        /// 纵向偏移,这个是相对量
        /// </summary>
        void SetPos2Offset(int offset);
        /// <summary>
        /// 纵向值补偿系数,补偿时,先乘除后加减
        /// </summary>
        float Pos2Comp { get; set; }
        /// <summary>
        /// 纵向同步事件,0-1事件
        /// </summary>
        /// <param name="pos2"></param>
        /// <param name="immediately">只要是 01,就立刻修正</param>
        void SetPos2At01(int pos2, bool immediately);
     
        #endregion
        #region 同步控制 同步状态转换规则
        /// <summary>
        /// 进入同步状态
        /// </summary>
        /// <param name="pos2"></param>
        void SyncBegin(int pos2);
        /// <summary>
        /// 进入同步状态
        /// </summary>
        void SyncBegin();
        /// <summary>
        /// 退出同步状态
        /// </summary>
        void SyncEnd();
        /// <summary>
        /// 清空同步指令
        /// </summary>
        void SyncClear();
        /// <summary>
        /// 清空POS2同步列表
        /// </summary>
        void SyncPos2Clear();
        #endregion
        #region 同步扫描 脚本指令

        /// <summary>
302 303
        /// 同步扫描至;
        /// D+0xE0+开始主轴位置+结束主轴位置+结束横向脉冲位置(逻辑位置)+脉冲开关(1B)+命令识标号(4B)
潘栩锋's avatar
潘栩锋 committed
304
        /// </summary>
305 306 307 308 309 310
        /// <param name="pos2_begin"></param>
        /// <param name="pos2_end"></param>
        /// <param name="pos1lc"></param>
        /// <param name="hasDataGrid"></param>
        /// <param name="marker"></param>
        void SyncRunAtLC(int pos2_begin, int pos2_end, int pos1lc, bool hasDataGrid, Int32 marker);
潘栩锋's avatar
潘栩锋 committed
311

312 313

        /// <summary>
314 315
        /// 位于队列头时运行,归零;
        /// D+0xE1+命令识标号(4B)
316
        /// </summary>
317 318
        /// <param name="marker"></param>
        void SyncOrigin(Int32 marker);
319

潘栩锋's avatar
潘栩锋 committed
320

潘栩锋's avatar
潘栩锋 committed
321
        /// <summary>
322 323
        /// 位于队列头时运行,以速度运行至物理位置;
        /// D+0xE2+横向脉冲位置(4B:int32,物理位置)+速度(4B:int32)+脉冲开关(1B)+命令识标号(4B)
潘栩锋's avatar
潘栩锋 committed
324
        /// </summary>
325 326 327 328 329 330 331
        /// <param name="pos1"></param>
        /// <param name="velocity"></param>
        /// <param name="hasDataGrid"></param>
        /// <param name="marker"></param>
        void SyncRunTo(int pos1, UInt32 velocity, bool hasDataGrid, Int32 marker);


潘栩锋's avatar
潘栩锋 committed
332
        /// <summary>
333 334
        /// 位于队列头时运行,以速度运行至逻辑位置;
        /// D+0xE3+横向脉冲位置(4B:int32,逻辑位置)+速度(4B:int32)+脉冲开关(1B)+命令识标号(4B)
潘栩锋's avatar
潘栩锋 committed
335
        /// </summary>
336 337 338 339 340 341
        /// <param name="pos1lc"></param>
        /// <param name="velocity"></param>
        /// <param name="hasDataGrid"></param>
        /// <param name="marker"></param>
        void SyncRunToLC(int pos1lc, UInt32 velocity, bool hasDataGrid, Int32 marker);

342

潘栩锋's avatar
潘栩锋 committed
343
        /// <summary>
344 345
        /// 等待,ms;
        /// D+0xE4+毫秒数(4B:int32)+命令识标号(4B)
潘栩锋's avatar
潘栩锋 committed
346
        /// </summary>
347 348 349
        /// <param name="ms"></param>
        /// <param name="marker"></param>
        void SyncWait(int ms, Int32 marker);
潘栩锋's avatar
潘栩锋 committed
350

351 352
        #endregion
        #endregion
潘栩锋's avatar
潘栩锋 committed
353 354 355 356
    }



357 358 359
    /// <summary>
    /// 电机类型
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
360 361
    public enum MOTORTYPE
    {
362 363 364
        /// <summary>
        /// 没电机
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
365
        NULL = 0,
366 367 368
        /// <summary>
        /// 异步电机,通过I1~I3控制 正反转
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
369
        VF0 = 1,
370 371 372
        /// <summary>
        /// 伺服 或 步进电机,通过 S,P, 控制驱动器
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
373 374
        SERVO = 2
    }
375 376 377
    /// <summary>
    /// 使用码区状态
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
    public enum AREA_STATUS
    {
        /// <summary>
        /// 没有读过密码区
        /// </summary>
        NOTLOAD = 0,
        /// <summary>
        /// 读出错
        /// </summary>
        RDERR = 1,
        /// <summary>
        /// 非有效密码区 没有0xAA55 或 0x5A5A 标志
        /// </summary>
        NOTVALID = 2,
        /// <summary>
        /// 写出错
        /// </summary>
        WRERR = 3,
        /// <summary>
        /// 有效密码区
        /// </summary>
        VALID = 4,
        /// <summary>
        /// 有效密码区,应回写EEPROM
        /// </summary>
        VALID_DIRTY = 5,
        /// <summary>
        /// 有效密码区,但回写EEPROM失败
        /// </summary>
        VALID_WRERR = 6
    }
409 410 411
    /// <summary>
    /// 使用码区操作结果
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
412 413 414

    public enum AREA_ERR
    {
415 416 417 418 419 420 421 422 423 424 425 426
        /// <summary>
        /// 没有错误
        /// </summary>
        NO_ERR = 0,
        /// <summary>
        /// 重复使用码
        /// </summary>
        DUP_ACCESS = 1,
        /// <summary>
        /// 无效使用码
        /// </summary>
        ERR_ACCESS = 2
潘栩锋's avatar
潘栩锋 committed
427
    }
428 429 430
    /// <summary>
    /// 运行状态
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
    public enum DRIVE_MAN_STATUS
    {
        /// <summary>
        /// 正常运行结束
        /// </summary>
        STOP = 0,
        /// <summary>
        /// 正在运行
        /// </summary>
        RUNNING = 1,
        /// <summary>
        /// 指令结束(收到停止指令)
        /// </summary>
        STOP_MANUAL = 2,
        /// <summary>
        /// 运行结束,限位开关闭合
        /// </summary>
        LIMIT = 3
    }
450 451 452
    /// <summary>
    /// 运行动作
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
453 454
    public enum DRIVE_MAN_ORDER
    {
455 456 457
        /// <summary>
        /// 闲置
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
        IDLE = 'I',
        /// <summary>
        /// 运行到
        /// </summary>
        RUNTO = 'R',
        /// <summary>
        /// 归原点
        /// </summary>
        ORIGIN = 'O',
        /// <summary>
        /// 后退
        /// </summary>
        BACKWORD = 'B',
        /// <summary>
        /// 前进
        /// </summary>
        FORWORD = 'F',
        /// <summary>
        /// 停止
        /// </summary>
        STOP = 'S',
        /// <summary>
        /// 同步
        /// </summary>
        SYNC = 'D',

        /// <summary>
        /// 未知状态
        /// </summary>
        SYNC2 = 'P'
    }

490 491 492 493 494
    /// <summary>
    /// 同步状态
    /// </summary>
    public enum SYNC_STATUS
    {
495 496 497
        /// <summary>
        /// 
        /// </summary>
498
        SYNCST_NO = 0,
499 500 501
        /// <summary>
        /// 
        /// </summary>
502
        SYNCST_PENDING1 = 1,
503 504 505
        /// <summary>
        /// 
        /// </summary>
506
        SYNCST_PENDING2 = 2,
507 508 509
        /// <summary>
        /// 
        /// </summary>
510
        SYNCST_PENDING3 = 3,
511 512 513
        /// <summary>
        /// 
        /// </summary>
514
        SYNCST_TEMP_OUT = 4,
515 516 517
        /// <summary>
        /// 
        /// </summary>
518
        SYNCST_WAIT_TO_PENDING = 5,
519 520 521
        /// <summary>
        /// 
        /// </summary>
522
        SYNCST_RESUME = 6,
523 524 525
        /// <summary>
        /// 
        /// </summary>
526
        SYNCST_YES = 10,
潘栩锋's avatar
潘栩锋 committed
527

528
    }
潘栩锋's avatar
潘栩锋 committed
529 530 531 532




533 534


潘栩锋's avatar
潘栩锋 committed
535 536


537

潘栩锋's avatar
潘栩锋 committed
538 539

}