/// <summary> /// Открывает АППИ /// </summary> /// <param name="BeginListening">Начинает прослушивать линию сразу же после открытия устройства</param> /// <returns></returns> public AppiDev OpenDevice(bool BeginListening = true) { lock (openingLocker) { if (IsFree) { var dev = InternalOpenDevice(); if (dev != null) { try { dev.Initialize(); OpenedDevice = dev; return dev; } catch (AppiException) { dev.Dispose(); throw; } } else throw new AppiException("Функция открытия устройства вернула null"); } else throw new DeviceSlotAlreadyOpenedException(this); } }
public CanPort OpenPort(AppiLine Line) { lock (AppiLocker) { if (!CanOpenPort) throw new CannotOpenCanPortException(); if (_appi != null) return _appi.CanPorts[Line]; _appi = WinusbAppiDev.GetDevices().First(d => d.IsFree).OpenDevice(true); if (Debugger.IsAttached) _appi.CanPorts[AppiLine.Can1].Received += OnCanFrameReceived; _appi.Disconnected += AppiOnDisconnected; return _appi.CanPorts[Line]; } }
internal AppiRsPort(AppiDev Device, String Name) : base(Name) { this.Device = Device; this.inBuffer = new Queue<byte>(); }
protected AppiSendBuffer(AppiDev Device, AppiLine Line) { this.Device = Device; this.Line = Line; Locker = new object(); }
public AppiTimeoutSendBuffer(AppiDev Device, AppiLine Line) : base(Device, Line) { }
public AppiFeedbackSendBuffer(AppiDev Device, AppiLine Line) : base(Device, Line) { Device.BufferRead += DeviceOnBufferRead; }
internal AppiRsPort(AppiDev Device, String Name) : base(Name) { this.Device = Device; this.inBuffer = new Queue <byte>(); }
internal AppiCanPort(AppiDev Device, AppiLine Line) : base(Line.ToString()) { this.Device = Device; this.Line = Line; }
private void AppiOnDisconnected(object Sender, EventArgs EventArgs) { lock (AppiLocker) { _appi.Dispose(); _appi = null; } }