예제 #1
0
 protected override void OnDisposing()
 {
     base.OnDisposing();
     _tcpDeviceConnection?.Dispose();
     _timerInterrigationService.Dispose();
     _tcpDeviceConnection = null;
 }
예제 #2
0
        public override async Task UpdateSignature()
        {
            if (!TcpDeviceConnection.LastTransactionSucceed)
            {
                return;
            }
            if (ConnectionModuleId == 0)
            {
                return;
            }
            var signBytes = await TcpDeviceConnection.ExecuteFunction12Async((byte)ConnectionModuleId, "Get Picon Signature", 0xF0);

            if (signBytes == null)
            {
                signBytes = await TcpDeviceConnection.ExecuteFunction12Async((byte)ConnectionModuleId, "Get Picon Signature", 0xF0);
            }
            string signature = Encoding.UTF8.GetString(signBytes);

            DeviceSignature = signature;
            DeviceValuesUpdated?.Invoke();
        }
예제 #3
0
        public override async Task UpdateSignal()
        {
            if (!TcpDeviceConnection.LastTransactionSucceed)
            {
                return;
            }
            if (ConnectionModuleId == 0)
            {
                return;
            }
            var signalLevelBytes = await TcpDeviceConnection.ExecuteFunction12Async((byte)ConnectionModuleId, "Get Picon SignalLevel", 0x60);

            if (signalLevelBytes == null)
            {
                signalLevelBytes = await TcpDeviceConnection.ExecuteFunction12Async((byte)ConnectionModuleId, "Get Picon SignalLevel", 0x60);
            }
            if (signalLevelBytes != null)
            {
                AnalogData.SignalLevel = signalLevelBytes[0];
                AnalogData.AnalogDataUpdated?.Invoke();
                DeviceValuesUpdated?.Invoke();
            }
        }
예제 #4
0
        private async void InitializeDriver()
        {
            var driver = await _runtimeModeDriversService
                         .GetDriverById(Guid.Parse(this.DeviceMomento.State.RelatedDriverId));

            _applicationSettingsService.Load();
            DriverMomento = driver.CreateMomento();
            InitFormatters();
            _tcpDeviceConnection = _applicationConnectionService.CreateTcpDeviceConnection(
                DriverMomento.State.GetTcpAddress(), DriverMomento.State.GetTcpPort(),
                _applicationSettingsService.QueryTimeoutPeriod * 1000);
            _tcpDeviceConnection.ConnectionRestoredAction += async() =>
            {
                try
                {
                    _isOnline = true;
                    if (_isConnectionWasOnline)
                    {
                        _connectionLogger.ConnectionResroted(_logger);
                    }
                    _isConnectionWasOnline = true;
                }
                catch
                {
                }
            };

            _tcpDeviceConnection.ConnectionLostAction += () =>
            {
                if (_isOnline)
                {
                    _isDeviceInitialized = false;
                    _connectionLogger.ConnectionLost(_logger);
                    _isOnline = false;
                }
            };
        }