IFlyAD.cs 14.1 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>
20
        string Addr { get; set; }
21
        
潘栩锋's avatar
潘栩锋 committed
22 23 24 25 26
        /// <summary>
        /// 从flyad7 获取 的systick 转换的时间
        /// </summary>
        DateTime Now { get; }

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

33 34 35 36
        /// <summary>
        /// 硬件版本,设置的!!!
        /// </summary>
        int HardwareVersion { get; set; }
潘栩锋's avatar
潘栩锋 committed
37 38 39 40
        /// <summary>
        /// 硬件次级版本,设置的!!!
        /// </summary>
        int HardwareVersionMinor { get; set; }
41 42 43
        /// <summary>
        /// 脉冲
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
44
        int Position { get; }
潘栩锋's avatar
潘栩锋 committed
45

46 47 48
        /// <summary>
        /// 速度 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
49
        int Speed { get; }
潘栩锋's avatar
潘栩锋 committed
50

潘栩锋's avatar
潘栩锋 committed
51 52 53 54 55 56 57 58 59 60
        /// <summary>
        /// 纵向脉冲,也叫主轴脉冲
        /// </summary>
        int Position2 { get; }

        /// <summary>
        /// 纵向速度
        /// </summary>
        int Speed2 { get; }

61 62 63 64
        /// <summary>
        /// 1000ms从AD卡获取(或推送)1个AD值。此AD值只用于调试,定点
        /// </summary>
        int AD { get; }
潘栩锋's avatar
潘栩锋 committed
65

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
        /// <summary>
        /// AD值最大值 ,恒定返回65535
        /// </summary>
        int ADMax { get; }
        
        /// <summary>
        /// 输入口状态,只有12位有效
        /// </summary>
        UInt16 IStatus { get; }

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

潘栩锋's avatar
潘栩锋 committed
81 82 83 84 85 86 87 88
        /// <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); 

89 90 91 92 93 94 95 96
        #region 运动参数
        /// <summary>
        /// 设置 运动参数
        /// </summary>
        /// <param name="posOfGrid">脉冲/grid</param>
        /// <param name="motortype">电机类型</param>
        /// <param name="ratio01">脉冲比例 分母(电机脉冲)</param>
        /// <param name="ratio02">脉冲比例 分子(编码器脉冲)</param>
潘栩锋's avatar
潘栩锋 committed
97
        //void SetSysParam(UInt16 posOfGrid, MOTORTYPE motortype, UInt16 ratio01, UInt16 ratio02);
98 99 100
        /// <summary>
        /// 电机类型
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
101
        MOTORTYPE MotorType { set; get; }
102 103 104 105 106 107 108
        /// <summary>
        /// 脉冲/grid, 最大1000个grid
        /// </summary>
        UInt16 PosOfGrid { set; get; }
        /// <summary>
        /// 脉冲比例 分母(电机脉冲)
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
109
        UInt16 Ratio01 { get; set; }
110 111 112
        /// <summary>
        /// 脉冲比例 分子(编码器脉冲)
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
113 114 115 116
        UInt16 Ratio02 { get; set; }

        #endregion

117 118 119 120 121 122 123
        /// <summary>
        /// 脉冲平移(0位处脉冲值)
        /// </summary>
        Int16 PosOffset { set; get; }
        /// <summary>
        /// 手动速度 pps
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
124 125
        UInt32 JogVelocity { set; get; }

126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
        #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>
145
        UInt32 Velocity { get; }
146 147 148
        /// <summary>
        /// 开始速度 pps
        /// </summary>
149
        UInt32 SVelocity { get; }
150 151 152
        /// <summary>
        /// 加速时间 ms
        /// </summary>
153
        UInt32 ATime { get; }
154 155 156
        /// <summary>
        /// 减速时间 ms
        /// </summary>
157
        UInt32 DTime { get; }
158 159 160
        /// <summary>
        /// 归0 第1段速 pps
        /// </summary>
161
        UInt32 HVelocity1 { get; }
162 163 164
        /// <summary>
        /// 归0 第2段速 pps
        /// </summary>
165
        UInt32 HVelocity2 { get; }
166
        
潘栩锋's avatar
潘栩锋 committed
167 168 169
        #endregion

        #region 密码
170 171 172
        /// <summary>
        /// 使用码区状态
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
173
        AREA_STATUS AreaStatus { get; }
174 175 176
        /// <summary>
        /// 使用码区出错码
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
        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>
193
        /// <param name="access">系统授权码access[8]</param>
潘栩锋's avatar
潘栩锋 committed
194 195 196 197 198 199 200 201 202
        void SetAccess(byte[] access);
        /// <summary>
        /// 初始化系统信息区
        /// </summary>
        void InitArea();

        #endregion


203 204 205
        /// <summary>
        /// timegrid 事件; 版本1: 1.28s 一次; 版本2: 0.2s一次, 
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
206
        event TimeGridEventHandler TimeGridEvent;
207

208 209 210
        /// <summary>
        /// runto 中,每经过1个grid 推送数据
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
211
        event MiniGridEventHandler MiniGridEvent;
212

213 214 215
        /// <summary>
        /// runto 的 grid事件
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
216
        event MiniGridEventHandler GridEvent;
217

218 219 220 221
        /// <summary>
        /// 输入状态改变事件
        /// </summary>
        event IStatusChangedEventHandler IStatusChangedEvent;
潘栩锋's avatar
潘栩锋 committed
222

223 224 225 226
        /// <summary>
        /// 指令状态改变事件
        /// </summary>
        event DriveStatusChangedEventHandler DriveStatusChangedEvent;
潘栩锋's avatar
潘栩锋 committed
227

228 229 230 231 232 233 234 235 236
        /// <summary>
        /// 脉冲1改变事件
        /// </summary>
        event PositionChangedEventHandler PositionChangedEvent;

        /// <summary>
        /// 脉冲2改变事件
        /// </summary>
        event PositionChangedEventHandler Position2ChangedEvent;
潘栩锋's avatar
潘栩锋 committed
237

238 239 240 241 242 243

        #region 运行动作
        /// <summary>
        /// 运行至指定位置
        /// </summary>
        /// <param name="to">脉冲</param>
潘栩锋's avatar
潘栩锋 committed
244
        void Runto(int to);
245 246 247
        /// <summary>
        /// 归原点
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
248
        void Origin();
249 250 251
        /// <summary>
        /// 停止
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
252
        void Stop();
253 254 255
        /// <summary>
        /// 反向,直到撞了限位
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
256
        void Backward();
257 258 259
        /// <summary>
        /// 正行,直到撞了限位
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
260 261
        void Forward();

262 263 264
        /// <summary>
        /// 当前运行指令
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
265
        DRIVE_MAN_ORDER DriveOrder { get; }
266 267 268
        /// <summary>
        /// 之前运行动作的状态
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
269
        DRIVE_MAN_STATUS DriveStatus { get; }
270 271
        #endregion

潘栩锋's avatar
潘栩锋 committed
272 273 274 275 276 277

        #region 同步
        /// <summary>
        /// 同步用标示
        /// </summary>
        Int32 Marker { get; }
潘栩锋's avatar
潘栩锋 committed
278

潘栩锋's avatar
潘栩锋 committed
279 280 281 282
        /// <summary>
        /// 逻辑横向脉冲偏移  Pos1 + Pos1LCShift = Pos1LC
        /// </summary>
        int Pos1LCShift { get; set; }
283 284

        /// <summary>
潘栩锋's avatar
潘栩锋 committed
285
        /// 逻辑纵向脉冲偏移  Pos2 + Pos2LCShift = Pos2LC
286
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
287
        int Pos2LCShift { get; set; }
288

潘栩锋's avatar
潘栩锋 committed
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
        #region 同步控制 同步状态转换规则
        /// <summary>
        /// 进入同步状态
        /// </summary>
        void SyncBegin();
        /// <summary>
        /// 退出同步状态
        /// </summary>
        void SyncEnd();
        /// <summary>
        /// 清空同步指令
        /// </summary>
        void SyncClear();
        #endregion
        #region 同步扫描 脚本指令

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

316 317

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

潘栩锋's avatar
潘栩锋 committed
324

潘栩锋's avatar
潘栩锋 committed
325
        /// <summary>
326 327
        /// 位于队列头时运行,以速度运行至物理位置;
        /// D+0xE2+横向脉冲位置(4B:int32,物理位置)+速度(4B:int32)+脉冲开关(1B)+命令识标号(4B)
潘栩锋's avatar
潘栩锋 committed
328
        /// </summary>
329 330 331 332 333 334 335
        /// <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
336
        /// <summary>
337 338
        /// 位于队列头时运行,以速度运行至逻辑位置;
        /// D+0xE3+横向脉冲位置(4B:int32,逻辑位置)+速度(4B:int32)+脉冲开关(1B)+命令识标号(4B)
潘栩锋's avatar
潘栩锋 committed
339
        /// </summary>
340 341 342 343 344 345
        /// <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);

346

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

355 356
        #endregion
        #endregion
潘栩锋's avatar
潘栩锋 committed
357 358 359 360
    }



361 362 363
    /// <summary>
    /// 电机类型
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
364 365
    public enum MOTORTYPE
    {
366 367 368
        /// <summary>
        /// 没电机
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
369
        NULL = 0,
370 371 372
        /// <summary>
        /// 异步电机,通过I1~I3控制 正反转
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
373
        VF0 = 1,
374 375 376
        /// <summary>
        /// 伺服 或 步进电机,通过 S,P, 控制驱动器
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
377 378
        SERVO = 2
    }
379 380 381
    /// <summary>
    /// 使用码区状态
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
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 409 410 411 412
    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
    }
413 414 415
    /// <summary>
    /// 使用码区操作结果
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
416 417 418

    public enum AREA_ERR
    {
419 420 421 422 423 424 425 426 427 428 429 430
        /// <summary>
        /// 没有错误
        /// </summary>
        NO_ERR = 0,
        /// <summary>
        /// 重复使用码
        /// </summary>
        DUP_ACCESS = 1,
        /// <summary>
        /// 无效使用码
        /// </summary>
        ERR_ACCESS = 2
潘栩锋's avatar
潘栩锋 committed
431
    }
432 433 434
    /// <summary>
    /// 运行状态
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
    public enum DRIVE_MAN_STATUS
    {
        /// <summary>
        /// 正常运行结束
        /// </summary>
        STOP = 0,
        /// <summary>
        /// 正在运行
        /// </summary>
        RUNNING = 1,
        /// <summary>
        /// 指令结束(收到停止指令)
        /// </summary>
        STOP_MANUAL = 2,
        /// <summary>
        /// 运行结束,限位开关闭合
        /// </summary>
        LIMIT = 3
    }
454 455 456
    /// <summary>
    /// 运行动作
    /// </summary>
潘栩锋's avatar
潘栩锋 committed
457 458
    public enum DRIVE_MAN_ORDER
    {
459 460 461
        /// <summary>
        /// 闲置
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
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 490 491 492 493
        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'
    }

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

532
    }
潘栩锋's avatar
潘栩锋 committed
533 534 535 536




537 538


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


541

潘栩锋's avatar
潘栩锋 committed
542 543

}