public void AddResult(IScanResult result, string projectFile) { string fullPath = result.FilePath; if (!Path.IsPathRooted(fullPath)) { fullPath = Utilities.AbsolutePathFromRelative(fullPath, Path.GetDirectoryName(projectFile)); } if (result.Scanned) { foreach (IScanHit hit in result.Results) { if (!string.IsNullOrEmpty(hit.Warning)) { // See if we've warned about this term before; if so, don't warn again. if (null == _termsWithDuplicateWarning.Find( item => string.Compare(item, hit.Term.Text, StringComparison.OrdinalIgnoreCase) == 0)) { _tasks.Add(new Task(hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Warning, string.Empty, string.Empty, -1, -1, string.Empty, string.Empty, this, _serviceProvider, _currentProject)); _termsWithDuplicateWarning.Add(hit.Term.Text); } } _tasks.Add(new Task(hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Term.Comment, hit.Term.RecommendedTerm, fullPath, hit.Line, hit.Column, projectFile, hit.LineText, this, _serviceProvider, _currentProject)); } } else { _tasks.Add(new Task(string.Empty, 1, string.Empty, string.Format(CultureInfo.CurrentUICulture, Resources.FileNotScannedError, fullPath), string.Empty, fullPath, -1, -1, projectFile, string.Empty, this, _serviceProvider, _currentProject)); } Refresh(); }
public void AddResult(IScanResult result, string projectFile) { if (OnAddResult != null) { OnAddResult(this, new AddResultArgs(result, projectFile)); } }
/// <summary> /// See <c>IScanner</c> documentation. /// </summary> public IMultiFileScanResult Scan(IEnumerable <string> filePaths, string searchingWord, FileScanCompleted callback, FileContentGetter contentGetter, ScanStopper stopper) { if (filePaths == null) { throw new ArgumentNullException("filePaths"); } if (string.IsNullOrEmpty(searchingWord)) { throw new ArgumentNullException("termTables"); } MatchFinder finder = new MatchFinder(searchingWord); MultiFileScanResult allResults = new MultiFileScanResult(); foreach (string filePath in filePaths) { if (stopper != null && stopper()) { break; } if (FileShouldBeScanned(filePath)) { IScanResult fileResult = ScanFile(filePath, finder, contentGetter, stopper); allResults.Append(fileResult); if (callback != null) { callback(fileResult); } } } return(allResults); }
public ScanResults(IScanResult result) { IsRunning = false; IsVisible = false; Device = result.Device; Uuid = Device.Uuid; try { Name = Device.Name; Rssi = result.Rssi; IAdvertisementData ad = result.AdvertisementData; ServiceCount = ad.ServiceUuids?.Length ?? 0; IsConnectable = ad.IsConnectable; LocalName = ad.LocalName; TxPower = ad.TxPower; ManufacturerData = ad.ManufacturerData == null ? null : BitConverter.ToString(ad.ManufacturerData); GuiName = Name ?? "Name is not supported"; GuiRssi = Rssi.ToString() ?? "RSSI is not supported"; GuiUuid = Uuid.ToString() ?? "UUID is not supported"; } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
async void OnScanResult(IScanResult result) { // Only interested in Movesense devices if (result.Device.Name != null) { if (result.Device.Name.StartsWith("Movesense")) { StopScanning(); var movesense = Plugin.Movesense.CrossMovesense.Current; movesense.ConnectionListener.DeviceDisconnected += async(s, a) => { await DisplayAlert("Disconnection", $"Device {a.Serial} disconnected", "OK"); }; // Now do the Mds connection var sensor = result.Device; StatusLabel.Text = $"Connecting to device {sensor.Name}"; DeviceName.Text = $"{sensor.Name}"; var movesenseDevice = await movesense.ConnectMdsAsync(sensor.Uuid); // Talk to the device StatusLabel.Text = "Getting device info"; var info = await movesenseDevice.GetDeviceInfoAsync(); DeviceFirmware.Text = $"Firmware Version: {info.DeviceInfo.Sw}"; StatusLabel.Text = "Getting battery level"; var batt = await movesenseDevice.GetBatteryLevelAsync(); DeviceBattery.Text = $"Battery Level: {batt.ChargePercent}"; StatusLabel.Text = "Getting Heart Rate"; var hrData = await movesense.ApiSubscriptionAsync <string>(movesenseDevice : movesenseDevice, $"/Meas/HR", (hr) => { TestData(hr); }); // Turn on the LED //StatusLabel.Text = "Turning on LED"; //await movesenseDevice.SetLedStateAsync(0, true); //await DisplayAlert( // "Success", // $"Communicated with device {sensor.Name}, firmware version is: {info.DeviceInfo.Sw}, battery: {batt.ChargePercent}", // "OK"); // Turn the LED off again //StatusLabel.Text = "Turning off LED"; //await movesenseDevice.SetLedStateAsync(0, false); // Disconnect Mds //StatusLabel.Text = "Disconnecting"; //await movesenseDevice.DisconnectMdsAsync(); //StatusLabel.Text = "Disconnected"; } } }
Task <IScanResult> PlatformScan(MobileBarcodeScanningOptions options) { var task = Task.Factory.StartNew(() => { var waitScanResetEvent = new ManualResetEvent(false); IScanResult result = null; zxingScannerWindow.ScanningOptions = options; zxingScannerWindow.ScanContinuously = false; zxingScannerWindow.UseCustomOverlayView = UseCustomOverlay; zxingScannerWindow.CustomOverlayView = CustomOverlay; zxingScannerWindow.TopText = TopText; zxingScannerWindow.BottomText = BottomText; zxingScannerWindow.ScanCompletedHandler = (IScanResult r) => { result = r; waitScanResetEvent.Set(); }; zxingScannerWindow.Show(); waitScanResetEvent.WaitOne(); return(result); }); return(task); }
private void OutputScanResults(IScanResult result) { if (result.Scanned) { if (!result.Passed) { foreach (IScanHit hit in result.Results) { IIgnoreInstance thisIgnoreInstance = Factory.GetIgnoreInstance(result.FilePath, hit.LineText, hit.Term.Text, hit.Column); if (_ignoreInstancesList.Contains(thisIgnoreInstance)) { continue; } if (hit.Warning != null) { if (!_duplicateTerms.Any( item => string.Compare(item, hit.Term.Text, StringComparison.OrdinalIgnoreCase) == 0)) { Log.LogWarning(hit.Warning); _duplicateTerms.Add(hit.Term.Text); } } string outputText; if (hit.Term.RecommendedTerm != null && hit.Term.RecommendedTerm.Length > 0) { outputText = string.Format(CultureInfo.CurrentUICulture, Resources.HitFormatWithReplacement, result.FilePath, hit.Line + 1, hit.Column + 1, hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Term.Comment, hit.Term.RecommendedTerm); } else { outputText = string.Format(CultureInfo.CurrentUICulture, Resources.HitFormat, result.FilePath, hit.Line + 1, hit.Column + 1, hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Term.Comment); } if (_host != null) { // We're piping the results to the task list, so we don't want to use // LogWarning, which would create an entry in the error list. Log.LogMessage(MessageImportance.High, outputText); } else { Log.LogWarning(outputText); } } // foreach (IScanHit hit in result.Results) } // if (!result.Passed) } // if (result.Scanned) else { Log.LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.FileNotScannedError, result.FilePath)); } if (_host != null) { _host.AddResult(result, Project); } }
private void ScanButton_Clicked(object sender, EventArgs args) { CrossBleAdapter.Current.Scan().Subscribe(sr => { Debug.WriteLine($"found: {sr.Device.Name} - {sr.Device.Uuid}"); scanResult = sr; }); }
void ScanResultRecieved(IScanResult result) { if (!_stopPending) { Factory.GetTaskProvider().AddResult(result, _projectsToScan[_currentProject].ProjectPath); ++_filesProcessed; UpdateStatusBar(true, Resources.AppName, _filesProcessed, _totalFiles); } }
private bool FinishProcessImage(IScanResult result) { if (result != null) { _wasScanned = true; ResultFound?.Invoke(this, result); } return(false); }
/// <summary> /// Appends the results of a single-file scan to this multi-file result. /// </summary> /// <param name="fileResult">The results of the single-file scan.</param> /// <exception cref="System.ArgumentNullException">Thrown if <c>fileResult</c> is null.</exception> /// <remarks> /// As a result of a successfull call to this method: /// * 'Attempted' will be incremented by one. /// * One of 'PassedScan', 'FailedScan', or 'UnableToScan' will be incremented by one. /// * An entry will be added to 'Results'. /// </remarks> public void Append(IScanResult fileResult) { if (fileResult == null) { throw new ArgumentNullException("fileResult"); } _fileResults.Add(fileResult); }
public void Update(IScanResult result) { Name = result.Device.Name; Uuid = result.Device.Uuid.ToString(); Rssi = result.Rssi; this.SetStatus(result.Device.Status); LocalName = result.AdvertisementData.LocalName; this.SetConnectable(result.AdvertisementData.IsConnectable); }
private void AddDeviceNameToFoundList(IScanResult scanResult) { if (!string.IsNullOrEmpty(scanResult.Device.Name)) { if (!(_foundDevices.Any(device => device.Device.Name == scanResult.Device.Name))) { _foundDevices.Add(scanResult); } } }
void ScanResultRecieved(IScanResult result) { if (!_stopPending) { //var taskProvider = Factory.GetTaskProvider() as TaskProvider; //taskProvider.SetCurrentProject(_projectList[_currentProject]); //Factory.GetTaskProvider().AddResult(result, _projectsToScan[_currentProject].ProjectPath); //++_filesProcessed; //UpdateStatusBar(true, Resources.AppName, _filesProcessed, _totalFiles); } }
private void ProcessScan(IScanResult scanResult) { //Debug.WriteLine(scanResult.AdvertisementData.LocalName); //printdebug(scanResult.AdvertisementData.LocalName); if (scanResult.AdvertisementData.LocalName != null && scanResult.AdvertisementData.LocalName.Trim() == serverName) { server = scanResult.Device; scanner.Dispose(); ConnectToServer(); } }
private void FoundDevice(IScanResult scanResult) { var device = scanResult.Device; Log.Info(GetType().Name, $"Found device {device.Name}, Address: {device.Uuid}"); if (_seenDevices.Contains(device.Uuid)) { return; } _seenDevices.Add(device.Uuid); _adapter.Add(new BLEDevice(device, scanResult.Rssi)); _adapter.NotifyDataSetChanged(); }
public byte[] GetServiceDataBytes(IScanResult scanResult) { byte[] serviceData = new byte[scanResult.AdvertisementData.ServiceData[0].Length]; if (scanResult.AdvertisementData.ServiceData[0].Length > 0) { for (int j = 0; j < scanResult.AdvertisementData.ServiceData[0].Length; j++) { serviceData[j] = scanResult.AdvertisementData.ServiceData[0][j]; } } return(serviceData); }
public void ReadSensorData(IScanResult scanResult, Sensor s, double lat, double lon) { if (!IsTimeToReadSensor(s)) { return; } sensorReadings[sensors.IndexOf(s)] = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); if (scanResult.AdvertisementData.ServiceData.Count == 0) { return; } byte[] serviceData = GetServiceDataBytes(scanResult); TSensorData sensorData = TSensorService.ParseSensorData(serviceData); if (sensorData == null) { return; } var date = DateTime.Now.ToString(); Console.WriteLine( string.Format( "Name: {0} - UUID: {1} - Temperature: {2} - Pressure: {3} - Altitude: {4} - Lat: {5} - Lon: {6}", s.Name, s.Uuid, sensorData.Temperature, sensorData.Pressure, sensorData.Altitude, lat, lon ) ); var telemetryDataPoint = new { uuid = s.Uuid, name = s.Name, temperature = sensorData.Temperature, pressure = sensorData.Pressure, altitude = sensorData.Altitude, battery = sensorData.Battery, lat, lon, date, }; UploadSensorDataService.SendDeviceToCloudMessagesAsync(telemetryDataPoint); // Kolla så Object faktiskt fungerar }
private async Task HandleScanning() { _hndl = IawAppApi.RequestScanQr( true, new MatchWidthWithFixedHeightLayoutStrategy( _scannerPopupHeightMm, _scannerPopupMmFromTop)); var ended = false; while (!ended) { var ev = await _hndl.GetNext(); Logger.Debug(GetType(), "got ({0}; {1})", ev.Item1, ev.Item2); switch (ev.Item1) { case ScanResultType.Scanned: try { _errorOrNull = null; ScannedCode = await _getItemByCode(ev.Item2); } catch (Exception ex) { _errorOrNull = ex.Message; } await _errorLbl.DoChange(_errorOrNull, false, this, false); break; case ScanResultType.Paused: if (_errorOrNull == null) { _hndl.CancelScanning(); } else { //TODO extract into stylesheet _view.Unpause.Widget.Style.SetProperty("display", ""); } break; case ScanResultType.Disposed: _hndl = null; ended = true; Ended?.Invoke(this, ScannedCode == null ? CompletedOrCanceled.Canceled : CompletedOrCanceled.Completed); break; } } }
async void OnScanResult(IScanResult result) { // Only interested in Movesense devices if (result.Device.Name != null) { if (result.Device.Name.StartsWith("Movesense")) { StopScanning(); var movesense = Plugin.Movesense.CrossMovesense.Current; movesense.ConnectionListener.DeviceDisconnected += async(s, a) => { await DisplayAlert("Disconnection", $"Device {a.Serial} disconnected", "OK"); }; // Now do the Mds connection var sensor = result.Device; StatusLabel.Text = $"Connecting to device {sensor.Name}"; var movesenseDevice = await movesense.ConnectMdsAsync(sensor.Uuid); // Talk to the device StatusLabel.Text = "Getting device info"; var info = await movesenseDevice.GetDeviceInfoAsync(); StatusLabel.Text = "Getting battery level"; var batt = await movesenseDevice.GetBatteryLevelAsync(); // Turn on the LED StatusLabel.Text = "Turning on LED"; await movesenseDevice.SetLedStateAsync(0, true); await DisplayAlert( "Success", $"Communicated with device {sensor.Name}, firmware version is: {info.DeviceInfo.Sw}, battery: {batt.ChargePercent}", "OK"); // Turn the LED off again StatusLabel.Text = "Turning off LED"; await movesenseDevice.SetLedStateAsync(0, false); // Disconnect Mds StatusLabel.Text = "Disconnecting"; await movesenseDevice.DisconnectMdsAsync(); StatusLabel.Text = "Disconnected"; } } }
void OnScanResult(IScanResult result) { // Only interested in Movesense devices if (result.Device.Name != null) { if (result.Device.Name.StartsWith("Movesense")) { StopScanning(); var sensor = result.Device; bleconnectiontcs?.TrySetResult(sensor); } } }
void OnScanResult(IScanResult result) { var dev = this.Devices.FirstOrDefault(x => x.Uuid.Equals(result.Device.Uuid)); if (dev != null) { dev.TrySet(result); } else { dev = new ScanResultViewModel(); dev.TrySet(result); this.Devices.Add(dev); } }
public static bool IsBeacon(this IScanResult result) { var md = result.AdvertisementData?.ManufacturerData; if (md == null || md.Data == null || md.Data.Length != 23) { return(false); } if (md.CompanyId != 76) { return(false); } return(md.Data.IsBeaconPacket()); }
void OnScanResult(IScanResult result) { // Only interested in Movesense devices Plugin.BluetoothLE.IDevice device = result.Device; if (device.Name != null) { if (device.Name.StartsWith("Movesense")) { if (MovesenseDevices.FirstOrDefault((d) => d.Name == device.Name) == null) { MovesenseDevices.Add(device); Debug.WriteLine($"Discovered device {device.Name}"); } } } }
public ScanResultChoice(IScanResult r) : base() { this.ScanResult = r; IsIgnoreOption = false; switch (r.Result) { case Business.ScanResult.New: IsAddOption = true; break; case Business.ScanResult.Unchanged: default: break; } }
//public ConnectionStatus Status { get; private set; } = ConnectionStatus.Disconnected; public bool TrySet(IScanResult result) { var response = false; if (this.Uuid == Guid.Empty) { this.Device = result.Device; this.Uuid = this.Device.Uuid; //this.nameOb = result // .Device // .WhenNameUpdated() // .Subscribe(x => this.Name = x); response = true; } try { if (this.Uuid == result.Device.Uuid) { response = true; this.Name = result.Device.Name; this.Rssi = result.Rssi; var ad = result.AdvertisementData; this.ServiceCount = ad.ServiceUuids?.Length ?? 0; this.IsConnectable = ad.IsConnectable; this.LocalName = ad.LocalName; this.TxPower = ad.TxPower; this.ManufacturerData = ad.ManufacturerData == null ? null : BitConverter.ToString(ad.ManufacturerData); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } OnPropertyChanged(nameof(IsConnected)); OnPropertyChanged(nameof(ButtonName)); return(response); }
async void OnScanResult(IScanResult result) { // Only interested in Movesense devices if (result.Device.Name != null) { if (result.Device.Name.StartsWith("Movesense")) { // Stop scanning this.scan?.Dispose(); // Now do the Mds connection MovesenseDevice = await Plugin.Movesense.CrossMovesense.Current.ConnectMdsAsync(result.Device.Uuid); connectiontcs?.TrySetResult(MovesenseDevice); } } }
private void FilterWatchdogDevice(IScanResult scanResult) { if (scanResult.Device.Name == dataService.WatchdogDeviceName) { if (watchdogDevice != scanResult.Device) { watchdogDevice = scanResult.Device; watchdogDevice.WhenStatusChanged().Subscribe(x => { log.Debug("{0} device state changed: {1}", watchdogDevice.Name, x); DeviceConnectionStateChanged(x == ConnectionStatus.Connected); }); DeviceDetected(); } } }
public static void Run() { // Run scan and print results to console IScanResult FWScan = Scan(); string WinFWStatus = FWScan.WinFW.Enabled ? "Enabled" : "Disabled"; Console.WriteLine("Windows Firewall:"); Console.WriteLine(" Status: {0}", WinFWStatus); if (FWScan.WinFW.GloballyOpenPorts.Count > 0) { Console.WriteLine(" Open ports detected:"); foreach (int Port in FWScan.WinFW.GloballyOpenPorts) { Console.WriteLine(Port); } } else { Console.WriteLine(" No open ports detected."); } Console.WriteLine("\n\n"); int TPFWCount = FWScan.TPFWs.Count; Console.WriteLine("{0} Third-Party Firewall(s) detected.", TPFWCount); if (TPFWCount > 0) { foreach (ThirdPartyFirewall TPFW in FWScan.TPFWs) { Console.WriteLine("\nThird Party Firewall:\n==============="); foreach (PropertyDescriptor Descriptor in TypeDescriptor.GetProperties(TPFW)) { Console.WriteLine("{0}: {1}", Descriptor.Name, Descriptor.GetValue(TPFW)); } } } //Uncomment next line for debugging in VS -- keeps console open //Console.ReadLine(); }
private async void scanbtn_Clicked(object sender, EventArgs e) { CrossBleAdapter.Current.Scan().Subscribe(scanResult => { ScanResult = scanResult; }); // Once finding the device/scanresult you want ScanResult.Device.Connect(); device = ScanResult.Device; device.WhenAnyCharacteristicDiscovered().Subscribe(characteristic => { // read, write, or subscribe to notifications here var result = characteristic.Read(); // use result.Data to see response characteristic.Write(bytes); characteristic.EnableNotifications(); characteristic.WhenNotificationReceived().Subscribe(r => { Result = r.ToString(); }); }); }
public void AddResult(IScanResult result, string projectFile) { Factory.GetTaskProvider().AddResult(result, projectFile); }
private void OutputScanResults(IScanResult result) { if (result.Scanned) { if (!result.Passed) { foreach (IScanHit hit in result.Results) { IIgnoreInstance thisIgnoreInstance = Factory.GetIgnoreInstance(result.FilePath, hit.LineText, hit.Term.Text, hit.Column); if (_ignoreInstancesList.Contains(thisIgnoreInstance)) continue; if (hit.Warning != null) { if (!_duplicateTerms.Any( item => string.Compare(item, hit.Term.Text, StringComparison.OrdinalIgnoreCase) == 0)) { Log.LogWarning(hit.Warning); _duplicateTerms.Add(hit.Term.Text); } } string outputText; if (hit.Term.RecommendedTerm != null && hit.Term.RecommendedTerm.Length > 0) { outputText = string.Format(CultureInfo.CurrentUICulture, Resources.HitFormatWithReplacement, result.FilePath, hit.Line + 1, hit.Column + 1, hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Term.Comment, hit.Term.RecommendedTerm); } else { outputText = string.Format(CultureInfo.CurrentUICulture, Resources.HitFormat, result.FilePath, hit.Line + 1, hit.Column + 1, hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Term.Comment); } if (_host != null) { // We're piping the results to the task list, so we don't want to use // LogWarning, which would create an entry in the error list. Log.LogMessage(MessageImportance.High, outputText); } else { Log.LogWarning(outputText); } } // foreach (IScanHit hit in result.Results) } // if (!result.Passed) } // if (result.Scanned) else { Log.LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.FileNotScannedError, result.FilePath)); } if (_host != null) { _host.AddResult(result, Project); } }
void ScanResultRecieved(IScanResult result) { if (!_stopPending) { var taskProvider = Factory.GetTaskProvider() as TaskProvider; taskProvider.SetCurrentProject(_projectList[_currentProject]); Factory.GetTaskProvider().AddResult(result, _projectsToScan[_currentProject].ProjectPath); ++_filesProcessed; UpdateStatusBar(true, Resources.AppName, _filesProcessed, _totalFiles); } }