protected void MigrateLog(DbContext context, DateTime timestamp, float value, float depth, SensorType sensorType) { int siteId = SiteService.ResolveSite(context, Number); Sensor sensor = SensorService.ResolveSensor(context, siteId, depth, sensorType); LogService.MigrateLog(context, sensor.Id, timestamp, value); }
public void IsCollectionList_Of_ModelsSensorAggregation() { SensorService sensorService = CreateSensorService(); var result = sensorService.GetSensorAggregation(); Assert.That(result, Is.InstanceOf <System.Collections.Generic.List <Models.SensorAggregation> >()); }
protected void OnPointSelectedChanged(SamplePointViewModel point) { if (point is ISelectable selectable) { // Ensure only one selected item if (selectable.Selected) { Helper.RunOnMainThreadIfRequired(async() => { // TODO: Show message when result is false bool result = await SensorService.SubscribeToTargetPositionEventsAsync(this, new TargetPositionObserverOptions(new Position() { Longitude = point.Longitude, Latitude = point.Latitude, })); SelectedPoint = point; }); foreach (ISelectable otherPoint in SamplePointsViewModel.Points) { if (otherPoint == point) { continue; } otherPoint.Selected = false; } } } }
public async Task ReturnPublicSensors_WhenCollectionIsNotEmpty() { var contextOptions = new DbContextOptionsBuilder <DormitorySystemContext>() .UseInMemoryDatabase("ReturnPublicSensors_WhenCollectionIsNotEmpty") .Options; var seedUsersMock = new Mock <ISeedUsers>(); var seedApiDataMock = new Mock <ISeedApiData>(); var measure = new Measure { Id = 1, MeasureType = "test" }; var sensorType = new SensorType { Id = 1, Name = "Test" }; var sampleSensor = new SampleSensor { Id = Guid.Parse("00000000-0000-0000-0000-000000000002"), Tag = "Test Sensor", Description = "Test Sensor", MinPollingInterval = 20, MeasureId = measure.Id, ValueCurrent = 50, SensorTypeId = sensorType.Id, IsOnline = true }; var userSensor = new UserSensor { Id = Guid.Parse("00000000-0000-0000-0000-000000000001"), CreatedOn = DateTime.Now, isDeleted = false, SampleSensorId = sampleSensor.Id, PollingInterval = 100, SendNotification = true, IsPrivate = false }; //Act using (var actContext = new DormitorySystemContext(contextOptions, seedUsersMock.Object, seedApiDataMock.Object)) { actContext.Measures.Add(measure); actContext.SensorTypes.Add(sensorType); actContext.SampleSensors.Add(sampleSensor); actContext.UserSensors.Add(userSensor); actContext.SaveChanges(); } //Assert using (var assertContext = new DormitorySystemContext(contextOptions, seedUsersMock.Object, seedApiDataMock.Object)) { var service = new SensorService(assertContext); var result = await service.GetPublicSensorsAsync(); Assert.AreEqual(1, result.Count()); } }
public void ReturnAllSensorTypes_When_Invoked() { //Arrange var contextOptions = new DbContextOptionsBuilder <SmartDormitoryDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; using (var arrangeContext = new SmartDormitoryDbContext(contextOptions)) { var sensorType = new SensorTypes { IsDeleted = false, Type = "testType", CreatedOn = DateTime.Now, }; arrangeContext.SensorTypes.Add(sensorType); arrangeContext.SaveChanges(); } // Act && Asert using (var assertContext = new SmartDormitoryDbContext(contextOptions)) { var sensorService = new SensorService(assertContext); var allSensorTypes = sensorService.GetAllTypes().ToList(); Assert.AreEqual(1, allSensorTypes.Count); } }
public void SetEnabledTest() { SensorService sensor = new SensorService(service); sensor.SetEnabled(true); var onBytes = new byte[] { 0x01 }; var offBytes = new byte[] { 0x00 }; Assert.IsTrue(switchChar.IsWritten); Assert.AreEqual(onBytes[0], switchChar.Written[0]); switchChar.IsWritten = false; sensor.SetEnabled(true); Assert.IsFalse(switchChar.IsWritten); sensor.SetEnabled(false); Assert.IsTrue(switchChar.IsWritten); Assert.AreEqual(offBytes[0], switchChar.Written[0]); switchChar.IsWritten = false; sensor.SetEnabled(false); Assert.IsFalse(switchChar.IsWritten); }
public static void Register(HttpConfiguration config) { // Json settings config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Formatting = Newtonsoft.Json.Formatting.Indented, NullValueHandling = NullValueHandling.Ignore, }; // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); SensorService.Init(); }
public PublicoController(SensorHistoricoService sensorHistoricoService, RegiaoService regiaoService, CadastroService cadastroService, SensorService sensorService) { this._sensorHistoricoService = sensorHistoricoService; this._regiaoService = regiaoService; this._cadastroService = cadastroService; this._sensorService = sensorService; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); // Add framework services. services.AddOptions(); services.Configure <MeasurementOptions>(Configuration); services.AddTransient <ISensorService, SensorService>(); var csv = SensorService.Create(Configuration["sensorDatabase"]); var task = csv.GetAll(); Task.WhenAny(task); var dict = task.Result.ToDictionary(x => x.DeviceId, x => new Device(x) { Status = DeviceStatus.Initializing }); services.AddSingleton(dict); services.AddTransient <ICurrentSensorValues, CurrentSensorValues>(); services.AddMvc(); }
public LabFarmController(LabFarmService labfarmService, PlantService plantService, SensorService sensorService, SensorDataService sensorDataService, PictureService pictureService) { _labfarmService = labfarmService; _plantService = plantService; _sensorService = sensorService; _sensorDataService = sensorDataService; _pictureService = pictureService; }
public ButterworthFilterService(double frequency, EExamType type) { int order = 4; double cutoff = SensorService.GetCuttoffFrequency(type); double Wd = cutoff / frequency * 2; Coeff = ButterworthLowPassFilter(order, Wd); }
private void GetCargoList() { ICargoService cargoService = new CargoService(employee.Username, employee.Password); ISensorService sensorService = new SensorService(employee.Username, employee.Password); List <Cargo> cargos = cargoService.All(); List <Sensor> sensors = sensorService.All(); Sensor sensor = sensors.Single(s => s.Sensor_name == SelectedDevice.ID.ToString()); CargoList = new ObservableCollection <Cargo>(cargos.Where(c => c.Sensor_id == sensor.Sensor_id)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IsLoggedIn(); IsPersonalAuxiliar(); _SensorService = new SensorService(); BindGridSensores(); } }
/// <summary> /// Este método inicia el servicio que corre en segundo plano /// si es que no está corriendo. /// </summary> private void IniciarServicioSegundoPlano() { contexto = this; servicioSegundoPlano = new SensorService(this.obtenerContexto()); intentSegundoPlano = new Intent(this.obtenerContexto(), typeof(SensorService)); if (!servicioCorriendo(servicioSegundoPlano)) { StartService(intentSegundoPlano); } }
public ActionResult <SensoresTableDto> GetTotais( [FromServices] SensorService sensorService, [FromQuery] int pagina, [FromQuery] int paginaTamanho, [FromQuery] string busca, [FromQuery] string buscaCorrente) { SensoresTableDto lista = sensorService.GetSensoresPaginado(buscaCorrente, busca, paginaTamanho, pagina); return(Ok(lista)); }
public ActionResult <SensorDto> Post([FromServices] SensorService service, [FromBody] SensorInputDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SensorDto dtoResultado = service.SaveSensorAsync(model); return(Ok(dtoResultado)); }
public void OnResume() { if (SelectedPoint != null) { SensorService.SubscribeToTargetPositionEventsAsync(this, new TargetPositionObserverOptions(new Position() { Longitude = SelectedPoint.Longitude, Latitude = SelectedPoint.Latitude, })); } }
public async void MapClickAsync() { foreach (ISelectable point in SamplePointsViewModel.Points) { point.Selected = false; } await SensorService.UnsubscribeToTargetPositionEventsAsync(this); SelectedPoint = null; NavigationDistance = null; }
public AqualogicController(ILogger <AqualogicController> logger, AquaLogicProtocolService service, SwitchService switchService, SensorService sensorService, SettingService settingService, PoolStatusStore store) { _logger = logger; _service = service; _switchService = switchService; _sensorService = sensorService; _settingService = settingService; _store = store; }
public void CreateInstance_WhenParametersAreCorrect() { //Arrange var context = new Mock <ApplicationDbContext>(); var provider = new Mock <ISensorDataProvider>(); //Act var service = new SensorService(context.Object, provider.Object); //Assert Assert.IsNotNull(service); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IsLoggedIn(); _PlantacionService = new PlantacionService(); _FrutoService = new FrutoService(); _MedicionService = new MedicionService(); _SensorService = new SensorService(); BindPlantaciones(); BindFrutos(); } }
public async Task ReturnProperSensor_WhenValidValueIsPassed() { //Arrange var contextOptions = new DbContextOptionsBuilder <DormitorySystemContext>() .UseInMemoryDatabase("ReturnProperSensor_WhenValidValueIsPassed") .Options; var seedUsersMock = new Mock <ISeedUsers>(); var seedApiDataMock = new Mock <ISeedApiData>(); var measure = new Measure { Id = 1, MeasureType = "test" }; var sensorType = new SensorType { Id = 1, Name = "Test" }; var sampleSensor = new SampleSensor { Id = Guid.Parse("00000000-0000-0000-0000-000000000001"), Tag = "Test Sensor", Description = "Test Sensor", MinPollingInterval = 20, MeasureId = measure.Id, ValueCurrent = 50, SensorTypeId = sensorType.Id, IsOnline = true }; //Act using (var actContext = new DormitorySystemContext(contextOptions, seedUsersMock.Object, seedApiDataMock.Object)) { actContext.Measures.Add(measure); actContext.SensorTypes.Add(sensorType); actContext.SampleSensors.Add(sampleSensor); actContext.SaveChanges(); } //Assert using (var assertContext = new DormitorySystemContext(contextOptions, seedUsersMock.Object, seedApiDataMock.Object)) { var service = new SensorService(assertContext); var result = await service.GetSampleSensorAsync(sampleSensor.Id); Assert.AreEqual(sampleSensor.Tag, result.Tag); } }
public void TestUIDDifferent() { SensorService ss = new SensorService(); ISensor Sensor1 = ss.CreateSensor(0); ISensor Sensor2 = ss.CreateSensor(0); ISensor Sensor3 = ss.CreateSensor(1); ISensor Sensor4 = ss.CreateSensor(1); ISensor Sensor5 = ss.CreateSensor(2); ISensor Sensor6 = ss.CreateSensor(2); Assert.AreNotEqual(Sensor1.getSensorUID(), Sensor2.getSensorUID()); Assert.AreNotEqual(Sensor3.getSensorUID(), Sensor4.getSensorUID()); Assert.AreNotEqual(Sensor5.getSensorUID(), Sensor6.getSensorUID()); }
public async Task ListSensors_ShouldReturnCollectionOfSensors() { // Arrange var contextOptions = new DbContextOptionsBuilder <DataContext>() .UseInMemoryDatabase(databaseName: "ListSensors_ShouldReturnCollectionOfSensors") .Options; string validId = Guid.NewGuid().ToString(); string validTag = "testTag"; string validLastValue = 10.ToString(); string validSensorId = "81a2e1b1-ea5d-4356-8266-b6b42471653e"; Sensor validSensor = new Sensor { Id = validId, Tag = validTag, LastValue = validLastValue, SensorId = validSensorId }; IEnumerable <Sensor> result = new List <Sensor>(); // Act using (DataContext actContext = new DataContext(contextOptions)) { Mock <IApiClient> apiClientMock = new Mock <IApiClient>(); await actContext.Sensors.AddAsync(validSensor); await actContext.SaveChangesAsync(); SensorService SUT = new SensorService( apiClientMock.Object, actContext); result = await SUT.ListSensorsAsync(); } // Assert using (DataContext assertContext = new DataContext(contextOptions)) { var sensor = result.ToArray()[0]; Assert.IsTrue(assertContext.Sensors.Count().Equals(result.Count())); Assert.IsTrue(assertContext.Sensors.Any(s => s.Tag.Equals(sensor.Tag))); Assert.IsTrue(assertContext.Sensors.Any(s => s.LastValue.Equals(sensor.LastValue))); Assert.IsTrue(assertContext.Sensors.Any(s => s.SensorId.Equals(sensor.SensorId))); } }
/// <summary> /// Este método verifica si el servicio en segundo plano está corriendo /// para no iniciarlo dos veces. /// </summary> /// <param name="servicioBackground">La instancia del tipo de servicio a verificar</param> /// <returns>Un booleano que indica si el servicio está corriendo o no.</returns> private Boolean servicioCorriendo(SensorService servicioBackground) { ActivityManager manager = (ActivityManager)GetSystemService(Context.ActivityService); foreach (ActivityManager.RunningServiceInfo servicio in manager.GetRunningServices(int.MaxValue)) { if (servicio.Class.Equals(servicio.Service.Class)) { Console.WriteLine("El servicio está corriendo!"); return(true); } } Console.WriteLine("El servicio no está corriendo"); return(false); }
public SensorController(SensorContext context) { _context = context; _service = new SensorService(); /* * if (_context.SensorItems.Count() == 0) * { * _context.SensorItems.Add(new SensorItem {Timestamp = 1539112021301, * Tag = "brasil.sudeste.sensor01", * Valor = "1"}); * _context.SaveChanges(); * } */ }
public WorldSimulation() { WorldSize = Convert.ToInt32(Settings.Default.WorldSize); generator = new Generate(WorldSize); AddAllAgents(generator.GenerateAgents()); // ініціалізація сервісів filterService = new FilterService(); locationBuilder = new LocationServiceBuilder(); turnService = new TurnService(); sensorService = new SensorService(); statistic = new StatisticService(); rand = new Random(); }
public async Task RebaseSensorsAsync_ShouldRepopulateSensorsTable() { // Arrange var contextOptions = new DbContextOptionsBuilder <DataContext>() .UseInMemoryDatabase(databaseName: "RebaseSensorsAsync_ShouldRepopulateSensorsTable") .Options; string validSensorId = "81a2e1b1-ea5d-4356-8266-b6b42471653e"; string validTarget = "all"; Sensor validSensor = new Sensor { Id = Guid.NewGuid().ToString(), SensorId = validSensorId, Tag = "testTag", Description = "testDescription", DeletedOn = DateTime.UtcNow.AddHours(2), IsDeleted = true }; IEnumerable <Sensor> validSensorList = new List <Sensor>() { validSensor }; // Act using (DataContext actContext = new DataContext(contextOptions)) { Mock <IApiClient> apiClientMock = new Mock <IApiClient>(); apiClientMock .Setup(mock => mock.GetApiSensors(validTarget)) .Returns(Task.FromResult(validSensorList)); SensorService SUT = new SensorService( apiClientMock.Object, actContext); await SUT.RebaseSensorsAsync(); } // Assert using (DataContext assertContext = new DataContext(contextOptions)) { Assert.IsTrue(assertContext.Sensors.Count() == 1); Assert.IsTrue(assertContext.Sensors.Contains(validSensor)); } }
private void GetSensor() { ISensorService sensorService = new SensorService(employee.Username, employee.Password); dataSensor = new SensorData() { Sensor = sensorService.All().Single(s => s.Sensor_name == device.ID.ToString()), Temperature = 0, Gyroscope = 0, Acceleration = 0, Humidity = 0, Light = 0, Magnetism = 0, Pressure = 0 }; }
public void ReturnEmptyCollection_When_SensorTypesDB_IsEmpty() { //Arrange var contextOptions = new DbContextOptionsBuilder <SmartDormitoryDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; // Act && Asert using (var assertContext = new SmartDormitoryDbContext(contextOptions)) { var sensorService = new SensorService(assertContext); var allSensorTypes = sensorService.GetAllTypes().ToList(); Assert.AreEqual(0, allSensorTypes.Count); } }