// MediaFrameReader public static async Task <MediaFrameReader> CreateMediaFrameReader(SensorConfig cfg, IReadOnlyList <MediaFrameSourceGroup> sourceGroups) { // Step 1. Find correct sourceInfo var sourceInfos = sourceGroups .SelectMany(group => group.SourceInfos) .Where(cfg.Selector); Debug.Assert(sourceInfos.Count() == 1); var sourceInfo = sourceInfos.First(); // Step 2. Create MediaCapture var mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { SourceGroup = sourceInfo.SourceGroup, SharingMode = MediaCaptureSharingMode.SharedReadOnly, StreamingCaptureMode = StreamingCaptureMode.Video, MemoryPreference = MediaCaptureMemoryPreference.Cpu }); // Step 3. Create MediaFrameReader var mediaFrameReader = await mediaCapture.CreateFrameReaderAsync( mediaCapture.FrameSources[sourceInfo.Id], cfg.MediaEncodingSubtype); // Step 4. Return MediaFrameReader, add callbacks then call StartAsync Debug.Log($"{cfg.Name} acquired"); return(mediaFrameReader); }
/// <summary> /// Change the config of an existing sensor. /// </summary> /// <param name="id">ID of the sensor.</param> /// <param name="newConfig">New sensor config of the sensor.</param> /// <returns>The new sensor config.</returns> public MessageCollection ChangeSensorConfig(string id, SensorConfig newConfig) { CommResult comres = Communication.SendRequest(new Uri(BridgeUrl + "/sensors/" + id.ToString() + "/config"), WebRequestType.PUT, Serializer.SerializeToJson <SensorConfig>(newConfig)); switch (comres.status) { case WebExceptionStatus.Success: List <Message> lstmsg = Serializer.DeserializeToObject <List <Message> >(comres.data); if (lstmsg == null) { goto default; } else { lastMessages = new MessageCollection(lstmsg); } break; case WebExceptionStatus.Timeout: lastMessages = new MessageCollection { _bridgeNotResponding }; BridgeNotResponding?.Invoke(this, _e); break; default: lastMessages = new MessageCollection { new UnkownError(comres) }; break; } return(lastMessages); }
/// <summary> /// Changes the Sensor configuration /// </summary> /// <param name="id"></param> /// <param name="config"></param> /// <returns></returns> public async Task <HueResults> ChangeSensorConfigAsync(string id, SensorConfig config) { CheckInitialized(); if (id == null) { throw new ArgumentNullException("id"); } if (id.Trim() == String.Empty) { throw new ArgumentException("id must not be empty", "id"); } if (config == null) { throw new ArgumentNullException("config"); } string jsonString = JsonConvert.SerializeObject(config, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); HttpClient client = HueClient.GetHttpClient(); //Create schedule var result = await client.PutAsync(new Uri(string.Format("{0}sensors/{1}/config", ApiBase, id)), new StringContent(jsonString)).ConfigureAwait(false); var jsonResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false); return(DeserializeDefaultHueResult(jsonResult)); }
/// <summary> /// Is this kind of bluetooth device currently supported by the Android app /// </summary> /// <returns><c>true</c>, if supported was ised, <c>false</c> otherwise.</returns> /// <param name="dev">Dev.</param> public static bool isSupported(BluetoothDevice dev) { string name = ""; foreach (char x in dev.Name) { if (Char.IsLetter(x)) { name = name + x; } else { break; } } // parse for letters of name if (SensorConfig.getSupportedDevices().Contains(name)) { Log.Debug(TAG + "-isSupported", string.Format("Device with name {0} is supported", name)); return(true); } Log.Debug(TAG + "-isSupported", string.Format("Device with name {0} is not supported", name)); return(false); }
/// <summary> /// 计算物理量 /// </summary> /// <param name="orignalConfig"></param> /// <param name="wave"></param> /// <param name="calculator"></param> /// <param name="extensionConfig"></param> /// <param name="exWave"></param> /// <returns></returns> public static decimal CalcPhysicalValue(SensorConfig orignalConfig, decimal?wave, IPhysicalCalculator calculator, SensorConfig extensionConfig = null, decimal?exWave = null) { var midPoint = 2; // 小数点几位 var result = decimal.Zero; if (orignalConfig != null && orignalConfig.SensorType.HasValue) { switch (orignalConfig.SensorType.Value) { case 1: midPoint = 2; var tempEx = calculator.CalculateTemperature(extensionConfig, exWave); var val = calculator.CalculateStructuralStrain(orignalConfig, wave, tempEx); result = val ?? decimal.Zero; break; case 2: midPoint = 1; var temp = calculator.CalculateTemperature(orignalConfig, wave); result = temp ?? decimal.Zero; break; } } return(Math.Round(result, midPoint, MidpointRounding.AwayFromZero)); }
public void OnSaved(WpfConfiguration configurationControl) { SensorConfig sensor = configurationControl as SensorConfig; ConfigDigitalInput config = sensor.Sensor as ConfigDigitalInput; index = sensor.Index; onWhenOn = config.OnWhenOn; }
public void OnSaved(WpfConfiguration configurationControl) { SensorConfig sensor = configurationControl as SensorConfig; Config1129Touch config = sensor.Sensor as Config1129Touch; Index = sensor.Index; OnTurnOn = config.OnTurnOn; }
public void OnSaved(WpfConfiguration configurationControl) { SensorConfig sensor = configurationControl as SensorConfig; Config1101IrDistance config = sensor.Sensor as Config1101IrDistance; Index = sensor.Index; TopValue = config.TopValue; BottomValue = config.BottomValue; }
public void OnSaved(WpfConfiguration configurationControl) { SensorConfig sensor = configurationControl as SensorConfig; Config1133Sound config = sensor.Sensor as Config1133Sound; Index = sensor.Index; TopValue = config.TopValue; Increasing = config.Increasing; }
public void OnSaved(WpfConfiguration configurationControl) { SensorConfig sensor = configurationControl as SensorConfig; Config1103IrReflective config = sensor.Sensor as Config1103IrReflective; Index = sensor.Index; // The reason we negate here is explained above. OnTurnOn = config.OnTurnOn; }
public async Task <IActionResult> Post([FromBody] SensorConfig config) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SensorConfig result = await storage.SaveSensorAsync(config); return(CreatedAtAction("Get", new { sensorId = result.SensorId }, result)); }
void LoadConfig(Object sender) { DependencyObject item = VisualTreeHelper.GetParent((DependencyObject)sender); while (item.GetType() != typeof(TreeViewItem)) { if (item == null) { return; } item = VisualTreeHelper.GetParent(item); } ItemsControl itemParent = ItemsControl.ItemsControlFromItemContainer(item); object SourceItem; if (itemParent == null) { TreeViewItem tv = (TreeViewItem)item; SourceItem = tv.DataContext; } else { SourceItem = itemParent.ItemContainerGenerator.ItemFromContainer(item); } if (SourceItem is SessionColumn) { //if the user has selected wsavg as the column type then create a windspeed sensor config //other wise create a regular sensor config SessionColumn col = (SessionColumn)SourceItem; if (col.ColumnType == SessionColumnType.WSAvg) { WindSpeedConfig config = new WindSpeedConfig(); config.StartDate = DataSetStartDate; config.EndDate = DataSetEndDate; _sessionColumnCollection [col.ColName].ColumnType = col.ColumnType; _sessionColumnCollection [col.ColName].addConfig(config); } else { SensorConfig config = new SensorConfig(); config.StartDate = DataSetStartDate; config.EndDate = DataSetEndDate; _sessionColumnCollection [col.ColName].ColumnType = col.ColumnType; _sessionColumnCollection [col.ColName].addConfig(config); } } else { throw new ApplicationException("Type passed in must be a SessionColumn. ViewModel1.LoadConfig"); } }
/// <summary> /// Iterate through each sensor to poll data /// </summary> static async Task Start(object userContext) { var userContextValues = userContext as Tuple <DeviceClient, Sensors.ModuleConfig>; if (userContextValues == null) { throw new InvalidOperationException("UserContext doesn't contain " + "expected values"); } DeviceClient ioTHubModuleClient = userContextValues.Item1; Sensors.ModuleConfig moduleConfig = userContextValues.Item2; while (m_run) { foreach (string s in moduleConfig.SensorConfigs.Keys) { SensorConfig sc = moduleConfig.SensorConfigs[s]; if (moduleConfig.VerboseLogging) { Console.WriteLine("Attempting to read sensor: " + sc); } SensorReading sensorReading = moduleConfig.ReadSensor(sc.SensorId); if (moduleConfig.VerboseLogging) { Console.WriteLine("SensorReading:" + sensorReading); } Message message = null; message = new Message(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(sensorReading))); message.Properties.Add("content-type", "application/edge-pids18b20-json"); message.ContentEncoding = "utf-8"; if (moduleConfig.VerboseLogging) { Console.Write("Sending message: " + message.BodyStream); } if (message != null) { await ioTHubModuleClient.SendEventAsync("pds18b20Output", message); } if (!m_run) { break; } } await Task.Delay(1000 *moduleConfig.PublishIntervalSeconds); } }
public IActionResult SensorConfig([FromBody] SensorConfig model) { try { appConfigRepo.LoadJSON(); appConfigRepo.AppConfig.Sensor = model; appConfigRepo.SaveJSON(); return(Ok(appConfigRepo.AppConfig.Sensor)); } catch (Exception ex) { logger.LogError(ex.GetExceptionMessages()); return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.UpdateError)); } }
public async Task TestSensorValidation(int sensorNumber, DateTime sensorDateTime, StartList?currentSkier, DateTime?startTime, int average, List <TimeData> currentSkierTimes, int diffToAverage, TimeData?ret, List <int> averageAssumption, int lastSensor, Sensor sensor, bool result) { var mockClockProvider = new Mock <IRaceClockProvider>(); var mockClock = new MockClock(); var mockActiveRaceService = new Mock <IActiveRaceService>(); var mockTimeDataDao = new Mock <ITimeDataDao>(); var mockSensorConfig = new SensorConfig(diffToAverage, averageAssumption); var mockSensorDao = new Mock <ISensorDao>(); var mockRaceData = new Mock <IRaceDataDao>(); var mockRaceEventDao = new Mock <IRaceEventDao>(); var mockSkierEventDao = new Mock <ISkierEventDao>(); var mockStartListDao = new Mock <IStartListDao>(); mockSensorDao.Setup(sd => sd.GetLastSensorNumber(It.IsAny <int>())).ReturnsAsync(lastSensor); mockSensorDao.Setup(sd => sd.GetSensorForSensorNumber(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(sensor); mockActiveRaceService.Setup(rc => rc.GetCurrentSkier(It.IsAny <int>())).ReturnsAsync(currentSkier); mockRaceData.Setup(rd => rd.InsertGetIdAsync(It.IsAny <RaceData>())).ReturnsAsync(1); mockClockProvider.Setup(provider => provider.GetRaceClock()).ReturnsAsync(mockClock); mockSkierEventDao.Setup(skd => skd.InsertGetIdAsync(It.IsAny <SkierEvent>())).ReturnsAsync(1); mockTimeDataDao.Setup(tdd => tdd.FindByIdAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(ret); mockTimeDataDao.Setup(tdd => tdd.GetStartTimeForStartList(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(startTime); mockTimeDataDao.Setup(dd => dd.GetTimeDataForStartList(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(currentSkierTimes); var service = new ActiveRaceControlService(1, null, mockStartListDao.Object, mockRaceEventDao.Object, mockRaceData.Object, mockSkierEventDao.Object, mockTimeDataDao.Object, mockSensorDao.Object, mockClockProvider.Object, mockSensorConfig, mockActiveRaceService.Object); await service.InitializeAsync(); var res = false; service.OnSplitTime += _ => res = true; mockClock.Trigger(sensorNumber, sensorDateTime); Assert.AreEqual(result, res); }
private int GetDecodedBaseValue(byte[] data, SensorConfig sensorConfig) { if (sensorConfig.ByteCount == 1) { return(data[sensorConfig.ByteIndex]); } else if (sensorConfig.ByteCount == 2) { return(BitConverter.ToInt16(data, sensorConfig.ByteIndex)); } else if (sensorConfig.ByteCount == 4) { return(BitConverter.ToInt32(data, sensorConfig.ByteIndex)); } return(0); }
protected override void InitializeDriver() { var sensors = SensorDevices.GetDevices(); var i = 0; foreach (var sensor in sensors) { var sensorConfig = new SensorConfig { Sensor = sensor, Index = i }; Sensors.Add(sensorConfig); SetSensorState(sensorConfig); sensor.Tare(); i++; } }
public DecodedMessage Decode(RawBusMessage reading, SensorConfig sensorConfig, int decodeCounter) { var baseValue = GetDecodedBaseValue(reading.Data, sensorConfig); var finalValue = baseValue * sensorConfig.Precision; Console.WriteLine($" Decoded Message: {reading.Counter} Sensor: {sensorConfig.SensorCode} {finalValue} {sensorConfig.Unit}"); return(new DecodedMessage() { Label = sensorConfig.SensorCode, ReadingTime = reading.ReadingTime, Source = sensorConfig.ComponentCode, MachineId = reading.MachineId, Unit = sensorConfig.Unit, Value = finalValue, Counter = (double)reading.Counter + ((double)decodeCounter / 100.0) }); }
private void CaptureSensorState(SensorConfig sensorConfig) { var sensor = sensorConfig.Sensor; if (sensorConfig.RotationEnabled) { sensor.GetEulerAngles(); } if (sensorConfig.CompassEnabled || sensorConfig.GravityEnabled || sensorConfig.GyroEnabled) { sensor.GetNormalizedSensorData(); } var name = sensorConfig.Index + "."; //TODO: Reduce noise from sensor to reduce network send traffic? if (sensorConfig.GravityEnabled) { AddSliderValue(name + Constants.AccelX, (int)(sensor.Accelerometer.X * 1000.0)); AddSliderValue(name + Constants.AccelY, (int)(sensor.Accelerometer.Y * 1000.0)); AddSliderValue(name + Constants.AccelZ, (int)(sensor.Accelerometer.Z * 1000.0)); } if (sensorConfig.GyroEnabled) { AddSliderValue(name + Constants.GyroX, (int)(sensor.Gyro.X * 1000.0)); AddSliderValue(name + Constants.GyroY, (int)(sensor.Gyro.Y * 1000.0)); AddSliderValue(name + Constants.GyroZ, (int)(sensor.Gyro.Z * 1000.0)); } if (sensorConfig.CompassEnabled) { AddSliderValue(name + Constants.CompassX, (int)(sensor.Compass.X * 1000.0)); AddSliderValue(name + Constants.CompassY, (int)(sensor.Compass.Y * 1000.0)); AddSliderValue(name + Constants.CompassZ, (int)(sensor.Compass.Z * 1000.0)); } if (sensorConfig.RotationEnabled) { AddSliderValue(name + Constants.DegreesX, (int)((sensor.Euler.X / 3.14159) * 180 * 1000.0)); AddSliderValue(name + Constants.DegreesY, (int)((sensor.Euler.Y / 3.14159) * 180 * 1000.0)); AddSliderValue(name + Constants.DegreesZ, (int)((sensor.Euler.Z / 3.14159) * 180 * 1000.0)); } }
/// <summary> /// Changes the Sensor configuration /// </summary> /// <param name="id"></param> /// <param name="config"></param> /// <returns></returns> public async Task <HueResults> ChangeSensorConfigAsync(string id, SensorConfig config) { CheckInitialized(); if (id == null) { throw new ArgumentNullException(nameof(id)); } if (id.Trim() == String.Empty) { throw new ArgumentException("id must not be empty", nameof(id)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } var updateJson = JObject.FromObject(config, new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore }); //Remove properties from json that are readonly updateJson.Remove("battery"); updateJson.Remove("reachable"); updateJson.Remove("configured"); updateJson.Remove("pending"); updateJson.Remove("sensitivitymax"); string jsonString = JsonConvert.SerializeObject(updateJson, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); HttpClient client = await GetHttpClient().ConfigureAwait(false); //Change sensor config var result = await client.PutAsync(new Uri(string.Format("{0}sensors/{1}/config", ApiBase, id)), new JsonContent(jsonString)).ConfigureAwait(false); var jsonResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false); return(DeserializeDefaultHueResult(jsonResult)); }
protected void SetSensorState(SensorConfig sensorConfig) { var name = sensorConfig.Index + "."; AddDeviceStateValue(name + Constants.AccelX, sensorConfig.IsEnabled & sensorConfig.GravityEnabled); AddDeviceStateValue(name + Constants.AccelY, sensorConfig.IsEnabled & sensorConfig.GravityEnabled); AddDeviceStateValue(name + Constants.AccelZ, sensorConfig.IsEnabled & sensorConfig.GravityEnabled); AddDeviceStateValue(name + Constants.GyroX, sensorConfig.IsEnabled & sensorConfig.GyroEnabled); AddDeviceStateValue(name + Constants.GyroY, sensorConfig.IsEnabled & sensorConfig.GyroEnabled); AddDeviceStateValue(name + Constants.GyroZ, sensorConfig.IsEnabled & sensorConfig.GyroEnabled); AddDeviceStateValue(name + Constants.CompassX, sensorConfig.IsEnabled & sensorConfig.CompassEnabled); AddDeviceStateValue(name + Constants.CompassY, sensorConfig.IsEnabled & sensorConfig.CompassEnabled); AddDeviceStateValue(name + Constants.CompassZ, sensorConfig.IsEnabled & sensorConfig.CompassEnabled); AddDeviceStateValue(name + Constants.DegreesX, sensorConfig.IsEnabled & sensorConfig.RotationEnabled); AddDeviceStateValue(name + Constants.DegreesY, sensorConfig.IsEnabled & sensorConfig.RotationEnabled); AddDeviceStateValue(name + Constants.DegreesZ, sensorConfig.IsEnabled & sensorConfig.RotationEnabled); }
public SystemTraverser(SensorConfig config = null) { computer = new Computer(); computer.HardwareAdded += HardwareAdded; computer.HardwareRemoved += HardwareRemoved; computer.IsControllerEnabled = true; computer.IsCpuEnabled = true; computer.IsGpuEnabled = true; computer.IsMemoryEnabled = false; computer.IsMotherboardEnabled = true; computer.IsStorageEnabled = false; computer.IsNetworkEnabled = false; computer.Open(); computer.Traverse(this); thread = new Thread(PollStatus); thread.Start(); }
public DecodedMessage Decode(RawBusMessage reading, SensorConfig sensorConfig) { var baseValue = GetDecodedBaseValue(reading.Data, sensorConfig); var finalValue = baseValue * sensorConfig.Precision; if (ShowMessages.PrintDecoder) { Console.WriteLine($" Decoded Message: {reading.Counter} Sensor: {sensorConfig.SensorCode} {finalValue} {sensorConfig.Unit}"); } return(new DecodedMessage() { Label = sensorConfig.SensorCode, ReadingTime = reading.ReadingTime, Source = sensorConfig.ComponentCode, Unit = sensorConfig.Unit, Value = finalValue, Counter = reading.Counter }); }
public async Task <SensorConfig> SaveSensorAsync(SensorConfig model) { Sensor dbSensor = null; if (!model.SensorId.HasValue) { dbSensor = new Sensor { Name = model.Name, Uom = model.Uom }; await context.Sensor.AddAsync(dbSensor); } else { dbSensor = await context.Sensor.FirstOrDefaultAsync(s => s.SensorId == model.SensorId.Value); if (dbSensor == null) { throw new ApplicationException($"Sensor with id {model.SensorId.ToString()} was not found."); } dbSensor.Name = model.Name; dbSensor.Uom = model.Uom; context.Sensor.Update(dbSensor); } try { await context.SaveChangesAsync(); } catch (Exception) { //logger.LogError(new EventId(5001), ex, string.Empty); throw; } return(await GetSensorAsync(dbSensor.SensorId)); }
public void Initialize() { // Setting default if the value was empty, otherwise it's set to it's current value AppConfig.Initialize(); // Getting the init shared prefernces for the sensor SensorConfig.Initialize(); initFragment(); initUI(); initReceiver(); // Bluetooth _adpt = BluetoothAdapter.DefaultAdapter; // Init Dictionary for sensors _connectedDeviceMap = new Dictionary <string, bool>(); // Setting up Map Timer mapTimer = new Timer(5000); mapTimer.Elapsed += new ElapsedEventHandler(OnTick); // Setting up LocationService Events App.Current.LocationServiceConnected += (object sender, Services.ServiceConnectedEventArgs e) => { Log.Debug(LOC_TAG, "ServiceConnected Event Raised"); // notifies us of location changes from the system App.Current.LocationService.LocationChanged += HandleLocationChanged; //notifies us of user changes to the location provider (ie the user disables or enables GPS) App.Current.LocationService.ProviderDisabled += HandleProviderDisabled; App.Current.LocationService.ProviderEnabled += HandleProviderEnabled; // notifies us of the changing status of a provider (ie GPS no longer available) App.Current.LocationService.StatusChanged += HandleStatusChanged; }; // Initialize Google API InitializeGoogleLocationServicesAsync(); initService(); }
void OutPutSummary() { BackgroundWorker worker = new BackgroundWorker(); string filename = string.Empty; SaveFileDialog sf = new SaveFileDialog(); sf.Title = "save data"; sf.Filter = "Excel|*.xlsx"; sf.DefaultExt = ".xlsx"; sf.FileName = "Unified" + "_StnSummary_" + DateTime.Now.ToShortDateString().Replace(@"/", ""); DialogResult result = sf.ShowDialog(); if (result == DialogResult.Cancel) { return; } if (sf.FileName != "") { filename = sf.FileName; } else { return; } worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { SummaryIsProcessing = false; }; worker.DoWork += delegate(object s, DoWorkEventArgs args) { XbyYShearStationSummary summary = null; try { SummaryIsProcessing = true; //create the DataTable if (_unifiedData != null) { _unifiedData.Clear(); } BuildDataTable(); //create column collection ColumnCollection = new SessionColumnCollection(_unifiedData); //add column def and add configs ISessionColumn hubws = ColumnCollection[HubHeight.ToString() + "m"]; hubws.ColumnType = SessionColumnType.WSAvgShear; hubws.IsCalculated = true; hubws.IsComposite = true; SensorConfig config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate, Height = HubHeight }; hubws.Configs.Add(config); ISessionColumn upperws = ColumnCollection[UpperHeight.ToString().Replace(".", "_") + "m"]; upperws.ColumnType = SessionColumnType.WSAvg; upperws.IsComposite = true; config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate, Height = UpperHeight }; upperws.Configs.Add(config); ISessionColumn lowerws = ColumnCollection[LowerHeight.ToString().Replace(".", "_") + "m"]; lowerws.ColumnType = SessionColumnType.WSAvg; lowerws.IsComposite = true; config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate, Height = LowerHeight }; lowerws.Configs.Add(config); ISessionColumn wd = ColumnCollection["WD"]; wd.ColumnType = SessionColumnType.WDAvg; wd.IsComposite = true; config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate }; wd.Configs.Add(config); //get axis selections from UI IAxis Xaxis = GetAxis(_xShearAxis, _xBinWidth); IAxis Yaxis = GetAxis(_yShearAxis, _yBinWidth); //calculate alpha AlphaFactory afactory = new AlphaFactory(); Alpha alpha = (Alpha)afactory.CreateAlpha(_unifiedData, AlphaFilterMethod.Coincident, upperws, lowerws, Xaxis, Yaxis); alpha.SourceDataSet = this.DisplayName; alpha.CalculateAlpha(); string xBin = string.Empty; string yBin = string.Empty; if (Xaxis.AxisType == AxisType.WD) { var wdaxis = (WindDirectionAxis)Xaxis; xBin = " " + wdaxis.BinWidth.ToString() + " deg"; } if (Xaxis.AxisType == AxisType.WS) { var wsaxis = (WindSpeedAxis)Xaxis; xBin = " " + wsaxis.BinWidth.ToString() + " m/s"; } if (Yaxis.AxisType == AxisType.WD) { var wdaxis = (WindDirectionAxis)Yaxis; yBin = " " + wdaxis.BinWidth.ToString() + " deg"; } if (Yaxis.AxisType == AxisType.WS) { var wsaxis = (WindSpeedAxis)Yaxis; yBin = " " + wsaxis.BinWidth.ToString() + " m/s"; } //Set up column metadata for the summary run summary = new XbyYShearStationSummary(ColumnCollection, _unifiedData.AsDataView(), 30, 10, 2, alpha); summary.CreateReport(filename); SummaryIsProcessing = false; } catch (ApplicationException e) { MessageBox.Show("Error calculating station summary: " + e.Message + " " + e.Source); StreamWriter fs = new StreamWriter(Path.GetDirectoryName(filename) + @"\LOG_" + Path.GetFileNameWithoutExtension(filename) + ".txt", false); summary.log.ForEach(c => fs.WriteLine(c)); fs.Close(); } finally { SummaryIsProcessing = false; } }; worker.RunWorkerAsync(); }
public void StoreSensorConfig(Identifier sensor, SensorConfig config) => _sensorConfigCache[sensor] = config;
public HardwareController(SystemTraverser traverser, SensorConfig sensorConfig) { this.traverser = traverser; this.sensorConfig = sensorConfig; }
public SystemTreeBuilder(SensorConfig sensorConfig) { this.sensorConfig = sensorConfig; }
public static void LoadSensorPlugin(Manifest manifest, VfsEntry dir) { #if UNITY_EDITOR //if (SensorDebugModeEnabled == true) // TODO Why is this not working? if (EditorPrefs.GetBool("Simulator/Sensor Debug Mode", false) == true) { if (File.Exists(Path.Combine(BundleConfig.ExternalBase, "Sensors", manifest.assetName, $"{manifest.assetName}.prefab"))) { Debug.Log($"Loading {manifest.assetName} in Sensor Debug Mode. If you wish to use this sensor plugin from WISE, disable Sensor Debug Mode in Simulator->Sensor Debug Mode or remove the sensor from Assets/External/Sensors"); var prefab = (GameObject)AssetDatabase.LoadAssetAtPath(Path.Combine(BundleConfig.ExternalBase, "Sensors", manifest.assetName, $"{manifest.assetName}.prefab"), typeof(GameObject)); SensorPrefabs.Add(prefab.GetComponent <SensorBase>()); Sensors.Add(SensorTypes.GetConfig(prefab.GetComponent <SensorBase>())); if (!SensorTypeLookup.ContainsKey(manifest.assetGuid)) { SensorTypeLookup.Add(manifest.assetGuid, prefab.GetComponent <SensorBase>()); } var pluginType = prefab.GetComponent <SensorBase>().GetDataBridgePlugin(); if (pluginType != null) { var sensorBridgePlugin = Activator.CreateInstance(pluginType) as ISensorBridgePlugin; foreach (var kv in BridgePlugins.All) { sensorBridgePlugin.Register(kv.Value); } } return; } } #endif if (SensorTypeLookup.ContainsKey(manifest.assetGuid)) { return; } if (manifest.assetFormat != BundleConfig.Versions[BundleConfig.BundleTypes.Sensor]) { throw new Exception($"Manifest version mismatch, expected {BundleConfig.Versions[BundleConfig.BundleTypes.Sensor]}, got {manifest.assetFormat}"); } if (Sensors.FirstOrDefault(s => s.Guid == manifest.assetGuid) != null) { return; } Assembly pluginSource = LoadAssembly(dir, $"{manifest.assetName}.dll"); foreach (Type ty in pluginSource.GetTypes()) { if (typeof(ISensorBridgePlugin).IsAssignableFrom(ty)) { var sensorBridgePlugin = Activator.CreateInstance(ty) as ISensorBridgePlugin; foreach (var kv in BridgePlugins.All) { sensorBridgePlugin.Register(kv.Value); } } } string platform = SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows ? "windows" : "linux"; var pluginStream = dir.Find($"{manifest.assetGuid}_sensor_main_{platform}").SeekableStream(); AssetBundle pluginBundle = AssetBundle.LoadFromStream(pluginStream); var pluginAssets = pluginBundle.GetAllAssetNames(); var texDir = dir.Find($"{manifest.assetGuid}_sensor_textures"); if (texDir != null) { var texStream = dir.Find($"{manifest.assetGuid}_sensor_textures").SeekableStream(); var textureBundle = AssetBundle.LoadFromStream(texStream, 0, 1 << 20); if (!AssetBundle.GetAllLoadedAssetBundles().Contains(textureBundle)) { textureBundle.LoadAllAssets(); } } SensorBase pluginBase = pluginBundle.LoadAsset <GameObject>(pluginAssets[0]).GetComponent <SensorBase>(); SensorConfig config = SensorTypes.GetConfig(pluginBase); config.Guid = manifest.assetGuid; Sensors.Add(config); SensorPrefabs.Add(pluginBase); if (!SensorTypeLookup.ContainsKey(manifest.assetGuid)) { SensorTypeLookup.Add(manifest.assetGuid, pluginBase); } }