예제 #1
0
 /// <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];
            }
        }
예제 #3
0
 internal AppiRsPort(AppiDev Device, String Name)
     : base(Name)
 {
     this.Device = Device;
     this.inBuffer = new Queue<byte>();
 }
예제 #4
0
 protected AppiSendBuffer(AppiDev Device, AppiLine Line)
 {
     this.Device = Device;
     this.Line = Line;
     Locker = new object();
 }
예제 #5
0
 public AppiTimeoutSendBuffer(AppiDev Device, AppiLine Line)
     : base(Device, Line)
 {
 }
예제 #6
0
 public AppiFeedbackSendBuffer(AppiDev Device, AppiLine Line)
     : base(Device, Line)
 {
     Device.BufferRead += DeviceOnBufferRead;
 }
예제 #7
0
 internal AppiRsPort(AppiDev Device, String Name)
     : base(Name)
 {
     this.Device   = Device;
     this.inBuffer = new Queue <byte>();
 }
예제 #8
0
 internal AppiCanPort(AppiDev Device, AppiLine Line)
     : base(Line.ToString())
 {
     this.Device = Device;
     this.Line   = Line;
 }
예제 #9
0
 public AppiTimeoutSendBuffer(AppiDev Device, AppiLine Line) : base(Device, Line)
 {
 }
예제 #10
0
 protected AppiSendBuffer(AppiDev Device, AppiLine Line)
 {
     this.Device = Device;
     this.Line   = Line;
     Locker      = new object();
 }
예제 #11
0
 public AppiFeedbackSendBuffer(AppiDev Device, AppiLine Line) : base(Device, Line)
 {
     Device.BufferRead += DeviceOnBufferRead;
 }
예제 #12
0
 internal AppiCanPort(AppiDev Device, AppiLine Line)
     : base(Line.ToString())
 {
     this.Device = Device;
     this.Line = Line;
 }
예제 #13
0
 private void AppiOnDisconnected(object Sender, EventArgs EventArgs)
 {
     lock (AppiLocker)
     {
         _appi.Dispose();
         _appi = null;
     }
 }