Пример #1
0
        public string AddSensor(string sensorName, string manufacturer, string hostDevice, string units)
        {
            SensorConfigInfo sensorConfigInfo = new SensorConfigInfo
            {
                Name = sensorName, Manufacturer = manufacturer, HostDevice = hostDevice, SensorUnits = units
            };

            if (sensorName == "invalid")
                return "sensor name not valid"; // TODO: just for testing

            if (!_sensorConfigManager.TryAdd(sensorConfigInfo))
            {
                return $"Sensor with name '{sensorName}' already exists";
            }

            var sensorConfigUpdate = new SensorConfigUpdate { IsAdd = true, SensorConfig = sensorConfigInfo };
            // Clients.Others
            Clients.All.SendAsync("ConfigUpdated", sensorConfigUpdate);

            return "";
        }
 public bool TryAdd(SensorConfigInfo sensor)
 {
     return(_sensors.TryAdd(sensor.Name, sensor));
 }