// Use this for initialization void Start() { // for distance calculation --> its much easier to make adjusments in the editor, just put // your camera where you want it to be if (target == null) { Debug.LogWarning("Warning! Target for TurntableSensorCamera is null."); return; } // if distance is set to zero, use current camera position --> easier setup if (distance == 0) { distance = (transform.position - target.position).magnitude; } // if you start the app, you will be viewing in the same direction your unity camera looks right now if (useRelativeCameraRotation) { initialCameraRotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0); } else { initialCameraRotation = Quaternion.identity; } // direct call // Sensor.Activate(Sensor.Type.RotationVector); // SensorHelper call with fallback SensorHelper.ActivateRotation(); // SensorHelper.TryForceRotationFallback(RotationFallbackType.OrientationAndAcceleration); StartCoroutine(Calibration()); }
private SensorStatusDTO GetStatusData(SensorDataHeadEntity eHead) { SensorStatusDTO dtoStatus = new SensorStatusDTO(); dtoStatus.SensorCaption = mSensor.SensorName; dtoStatus.SensorStatus = mSensor.PositionMark; StatusItemDTO item = null; SensorHelper <object> helper = new SensorHelper <object>(); SensorDataLineEntity eLine = helper.SelectSingle <SensorDataLineEntity>(string.Format("SensorDataHeadID = '{0}'", eHead.SensorDataHeadID.ToString().ToUpper()), "ReceivedDate DESC"); if (eLine != null) { dtoStatus.SensorDate = eLine.SensorDate; dtoStatus.ReceivedDate = eLine.ReceivedDate; // Temperature AddValueNumberToStatus(dtoStatus, eLine.ValueNumber1, Properties.Resource.TemperatureSeries); AddValueNumberToStatus(dtoStatus, eLine.ValueNumber2, Properties.Resource.PressureSeries); AddValueNumberToStatus(dtoStatus, eLine.ValueNumber3, Properties.Resource.HumiditySeries); AddValueNumberToStatus(dtoStatus, eLine.ValueNumber4, Properties.Resource.VoltageSeries); // 确定更新时间 if (eLine.SensorDate != null && eLine.SensorDate.HasValue) { item = new StatusItemDTO(Properties.Resource.UpdatedTime, StatusItemDTO.StatusItemType.DateTimeValue, eLine.SensorDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); dtoStatus.StatusData.Add(item); } } return(dtoStatus); }
private string Connect(BrickUnit item) { item.EV3 = new Brick <Sensor, Sensor, Sensor, Sensor>("COM" + item.ComPort); try { item.EV3.Connection.Open(); Sensor newSensor = null; if (SensorHelper.SensorDictionary.TryGetValue(SensorHelper.TypeToKey(item.EV3.Sensor1.GetSensorType()), out newSensor)) { item.EV3.Sensor1 = newSensor; } if (SensorHelper.SensorDictionary.TryGetValue(SensorHelper.TypeToKey(item.EV3.Sensor2.GetSensorType()), out newSensor)) { item.EV3.Sensor2 = newSensor; } if (SensorHelper.SensorDictionary.TryGetValue(SensorHelper.TypeToKey(item.EV3.Sensor3.GetSensorType()), out newSensor)) { item.EV3.Sensor3 = newSensor; } if (SensorHelper.SensorDictionary.TryGetValue(SensorHelper.TypeToKey(item.EV3.Sensor4.GetSensorType()), out newSensor)) { item.EV3.Sensor4 = newSensor; } } catch (Exception ex) { return(ex.Message); } return(null); }
public PageHighSpeed() { this.InitializeComponent(); _sensor = new SensorHelper(); this.viewModel.Dispatcher = this.Dispatcher; this.Unloaded += MainPage_Unloaded; }
public async Task <double> ReadTemperature() { #region bits explained // To line everything up for ease of reading back (on byte boundary) we // will pad the command start bit with 7 leading "0" bits // Write 0000000S GDDDxxxx xxxxxxxx // Read ???????? ?????N98 76543210 // S = start bit // G = Single / Differential // D = Chanel data // ? = undefined, ignore // N = 0 "Null bit" // 9-0 = 10 data bits // 0000 01 = 7 pad bits, start bit // 1000 0000 = single ended, channel bit 2, channel bit 1, channel bit 0, 4 clocking bits // 0000 0000 = 8 clocking bits #endregion var writeBuffer = new byte[3] { 0b00000001, 0b10000000, 0b00000000 }; /* we will hold the command to send to the chipbuild this in the constructor for the chip we are using */ var readBuffer = new byte[3] { 0b00000000, 0b00000000, 0b00000000 }; /* this is defined to hold the output data*/ Pi.Spi.Channel0Frequency = SpiChannel.MinFrequency; readBuffer = await Pi.Spi.Channel0.SendReceiveAsync(writeBuffer); return(SensorHelper.ToTemperature(readBuffer)); }
public static string GetProgramNameCaption(SensorEntity sensor, string programName) { int idParent = 0; if (Convert.ToInt32(sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Sterilizer))) { // 灭菌 idParent = 13; } else if (Convert.ToInt32(sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Washer))) { // 清洗 idParent = 14; } else { return(string.Empty); } SensorHelper <object> helper = new SensorHelper <object>(); AssistDataEntity entity = helper.SelectSingle <AssistDataEntity>("FParentID = " + idParent.ToString() + " and fkey = '" + programName + "'", string.Empty); if (entity == null) { return(programName); } else { return(entity.FCaption); } }
public ChartDTO GetChartData(string sdhID) { //mSyncLast = null; IsNew = true; mShowPropertyDic = GetShowPropertyData(); // 刷新状态 SensorHelper <object> helper = new SensorHelper <object>(); mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty); SensorDataHeadBll bllHead = new SensorDataHeadBll(); SensorDataHeadEntity eHead = bllHead.GetEntity(new Guid(sdhID)); if (eHead == null) { return(null); } else { if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value) { // 已压缩 mIsCompressed = true; mSensorCompressedData = new SensorCompressedDataHelper(eHead); } return(GetChartDataByHead(eHead)); } }
public Page1() { this.InitializeComponent(); ((DataSourceAdapter)chart.Series[0].Data).DataSource = data; rangeY.StartValue = 18.0; // minData - minData * 0.0002; rangeY.EndValue = 25.0; // MaxData + MaxData * 0.0002; data.Clear(); try { _sensor = new SensorHelper(); StatusText.Text = _sensor.Message; //StartProcess(); // Start(); } catch (Exception ex) { StatusText.Text = ex.Message; } // periodicTimer = new Timer(this.Timer_Tick, null, 0, 1000); timer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 0, 0, 1000) }; timer.Tick += OnTimerTick; // receiveTimer = new Timer(this.Receive_Timer_Tick, null, 0, System.Threading.Timeout.Infinite); Loaded += OnLoaded; Unloaded += MainPage_Unloaded; }
public static void CompareObservation(ISensor sensor, float[,,] expected) { string errorMessage; bool isOk = SensorHelper.CompareObservation(sensor, expected, out errorMessage); Assert.IsTrue(isOk, errorMessage); }
internal static Sensor InvocationRateAndCountAndAvgAndMaxLatencySensor(string threadId, string metricName, string metricDescription, string descriptionOfRate, string descriptionOfCount, string descriptionOfAvg, string descriptionOfMax, MetricsRecordingLevel recordingLevel, StreamMetricsRegistry streamsMetrics) { Sensor sensor = streamsMetrics.ThreadLevelSensor(threadId, metricName, metricDescription, recordingLevel); var tags = streamsMetrics.ThreadLevelTags(threadId); SensorHelper.AddAvgAndMaxToSensor(sensor, StreamMetricsRegistry.THREAD_LEVEL_GROUP, tags, metricName + StreamMetricsRegistry.LATENCY_SUFFIX, descriptionOfAvg, descriptionOfMax); SensorHelper.AddInvocationRateAndCountToSensor(sensor, StreamMetricsRegistry.THREAD_LEVEL_GROUP, tags, metricName, descriptionOfRate, descriptionOfCount); return(sensor); }
void Start() { // Used to enable standalone client to run beside server on same machine Screen.fullScreen = false; SensorHelper.ActivateRotation(); //StartCoroutine(Calibration()); }
void Start() { SensorHelper.ActivateRotation(); initialSensorValue = SensorHelper.rotation; gotFirstValue = false; StartCoroutine(Calibration()); }
void Start() { SensorHelper.ActivateRotation(); PrimeraPersona = UIUtils.Find("/Vista1erPersona").camera; TerceraPersona = UIUtils.Find("/Vista3erPersona").camera; CambiarCamaraTerceraPersona(); }
// Use this for initialization void Start() { // you can use the API directly: // Sensor.Activate(Sensor.Type.RotationVector); // or you can use the SensorHelper, which has built-in fallback to less accurate but more common sensors: SensorHelper.ActivateRotation(); useGUILayout = false; }
private void GetSeriesShowProperty(Dictionary <string, IList <SensorShowPropertyEntity> > dicShowProperty, string showName) { SensorHelper <object> helper = new SensorHelper <object>(); string strWhere = string.Format("SensorGroup = '{0}' AND SensorType = '{1}' AND ShowName = '{2}'", mSensor.SensorGroup, mSensor.SensorType, showName); IList <SensorShowPropertyEntity> lstShowProperty = helper.SelectList <SensorShowPropertyEntity>(strWhere, string.Empty); if (lstShowProperty != null && lstShowProperty.Count > 0) { dicShowProperty.Add(showName, lstShowProperty); } }
public MainWindowViewModel(ICacheService cacheService, ISensorServer sensorServer) { SensorCollection = new ObservableCollection <SensorCollection>(); SelectSensorCommand = new DelegateCommand <object>(SelectSensorExecute); RemoveSensorCommand = new DelegateCommand <object>(RemoveSensorExecute); sensorHelper = new SensorHelper(SensorCollection, cacheService, sensorServer); sensorHelper.DeleteSensorEvent += SensorHelper_DeleteSensorEvent; }
public LightController(ILogger <HeatSystemController> logger, LightHelper lightHelper, SensorHelper sensorHelper, IHostedService hostedService, IHostedService hostedService1) { _logger = logger; _listener = hostedService as SwitchListener; _sensorlistener = hostedService1 as SensorListener; _helper = lightHelper; _sensorHelper = sensorHelper; }
public async Task ProcessBytes(byte[] data, WebSocketReceiveResult result) { var reservedBytes = 12; var soundChars = data .Take(result.Count) .Skip(reservedBytes) .Select(d => (char)d) .ToArray(); var soundData = new string(soundChars) .Trim() .Split(' ') .Select(s => double.Parse(s)); var normalizedSoundData = soundData .Select(d => d > 542 || d < 538 ? d : 0) .Select(d => d / 1024d) .ToArray(); var firstBlock = normalizedSoundData.Take(normalizedSoundData.Length / 2).ToArray(); var matches = _soundRecognitionService.Recognize(firstBlock).ToList(); var secondBlock = normalizedSoundData.Skip(normalizedSoundData.Length / 2).ToArray(); matches.AddRange(_soundRecognitionService.Recognize(secondBlock).ToList()); var mostSimilar = matches.OrderByDescending(m => m.Match).First(); if (mostSimilar.Match >= 0.6 && mostSimilar.Match <= 0.85) { return; } var sensorId = SensorHelper.IdFromBytes(data); var sensorInfo = await _sensorRepository.FindAsync(sensorId); var soundLabel = await _soundLabelRepository.GetByLabelNumberAsync(mostSimilar.LabelNumber); await _pushNotificationService.SendAsync(new PushNotificationModel { Notification = new NotificationContentModel { Body = soundLabel?.LabelDescription, Payload = sensorInfo.RoomTag, Title = sensorInfo.PlaceAlias }, RegistrationIds = sensorInfo.ObservingDevices?.Select(o => o.Device.Token).ToArray() }); await _soundLogRepository.CreateAsync(sensorId, soundLabel.LabelNumber, mostSimilar.Match); }
public ChartDTO GetChartDataInc(DateTime?lastReceivedDate, bool canChangeHead) { //mSyncLast = null; IsNew = false; // 刷新状态 SensorHelper <object> helper = new SensorHelper <object>(); mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty); SensorDataHeadBll bllHead = new SensorDataHeadBll(); SensorDataHeadEntity eHead = bllHead.GetNewestSensorDataHeadBySensorID(Sensor.SensorID.ToString().ToUpper()); if (eHead == null) { return(null); } else { if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value) { ChartDTO chartData = new ChartDTO(); chartData.IsAxisXCustomLabels = false; chartData.ChartTitle = GetChartTitle(); chartData.IsReset = true; return(chartData); } if (mHeadEntity != null && eHead.SensorDataHeadID == mHeadEntity.SensorDataHeadID && lastReceivedDate != null && lastReceivedDate.HasValue) { return(GetChartDataInc(eHead, lastReceivedDate.Value)); } else { if (canChangeHead) { mSensorData = null; ChartDTO dtoChart = GetChartDataByHead(eHead); dtoChart.IsReset = true; IsNew = true; return(dtoChart); } else { return(null); } } } }
public async Task <double> ReadInfrared() { var writeBuffer = new byte[3] { 0b00000001, 0b10100000, 0b00000000 }; var readBuffer = new byte[3] { 0b00000000, 0b00000000, 0b00000000 }; Pi.Spi.Channel0Frequency = SpiChannel.MinFrequency; readBuffer = await Pi.Spi.Channel0.SendReceiveAsync(writeBuffer); return(SensorHelper.ToInfrared(readBuffer)); }
public string AddSensor(int key) { string result = "TRUE"; try { SensorHelper.Add(key); } catch (Exception ex) { result = ex.Message; } return(result); }
public static Sensor CommitRatioSensor(string threadId, StreamMetricsRegistry metricsRegistry) { var sensor = metricsRegistry.ThreadLevelSensor(threadId, COMMIT + StreamMetricsRegistry.RATIO_SUFFIX, COMMIT_RATIO_DESCRIPTION, MetricsRecordingLevel.INFO); var tags = metricsRegistry.ThreadLevelTags(threadId); SensorHelper.AddValueMetricToSensor( sensor, StreamMetricsRegistry.THREAD_LEVEL_GROUP, tags, COMMIT + StreamMetricsRegistry.RATIO_SUFFIX, COMMIT_RATIO_DESCRIPTION); return(sensor); }
private void StopListeners() { try { LocationHelper.StopTracking(); SensorHelper.StopTracking(); BatteryHelper.StopTracking(); GTalkHelper.StopTracking(); SkypeHelper.StopTracking(); OutlookHelper.StopTracking(); DropboxHelper.StopTracking(); } catch (Exception exception) { Log.Error(exception); } }
IEnumerator Calibration() { while (!SensorHelper.gotFirstValue) { SensorHelper.FetchValue(); yield return(null); } // wait some frames yield return(new WaitForSeconds(0.1f)); // set initial rotation initialSensorValue = SensorHelper.rotation; // allow updates gotFirstValue = true; }
public static Sensor ProcessRecordsSensor(string threadId, StreamMetricsRegistry metricsRegistry) { var sensor = metricsRegistry.ThreadLevelSensor( threadId, PROCESS + StreamMetricsRegistry.RECORDS_SUFFIX, PROCESS_DESCRIPTION, MetricsRecordingLevel.INFO); var tags = metricsRegistry.ThreadLevelTags(threadId); SensorHelper.AddAvgAndMaxToSensor( sensor, StreamMetricsRegistry.THREAD_LEVEL_GROUP, tags, PROCESS + StreamMetricsRegistry.RECORDS_SUFFIX, PROCESS_AVG_RECORDS_DESCRIPTION, PROCESS_MAX_RECORDS_DESCRIPTION); return(sensor); }
public static Sensor ProcessRateSensor(string threadId, StreamMetricsRegistry metricsRegistry) { var sensor = metricsRegistry.ThreadLevelSensor( threadId, PROCESS + StreamMetricsRegistry.RATE_SUFFIX, PROCESS_RATE_DESCRIPTION, MetricsRecordingLevel.INFO); var tags = metricsRegistry.ThreadLevelTags(threadId); SensorHelper.AddRateOfSumAndSumMetricsToSensor( sensor, StreamMetricsRegistry.THREAD_LEVEL_GROUP, tags, PROCESS + StreamMetricsRegistry.RATE_SUFFIX, PROCESS_RATE_DESCRIPTION, PROCESS_TOTAL_DESCRIPTION); return(sensor); }
void OnGUI() { GUI.Label(new Rect(10, 115, 180, 20), "Different modes:"); if (GUI.Button(new Rect(10, 140, 180, 20), "Rotation Vector")) { SensorHelper.TryForceRotationFallback(RotationFallbackType.RotationQuaternion); } if (GUI.Button(new Rect(10, 165, 180, 20), "Orientation/Acceleration")) { SensorHelper.TryForceRotationFallback(RotationFallbackType.OrientationAndAcceleration); } if (GUI.Button(new Rect(10, 190, 180, 20), "Magnetic Field")) { SensorHelper.TryForceRotationFallback(RotationFallbackType.MagneticField); } }
public SensorStatusDTO GetStatusData() { // 刷新状态 SensorHelper <object> helper = new SensorHelper <object>(); mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty); SensorDataHeadBll bllHead = new SensorDataHeadBll(); SensorDataHeadEntity eHead = bllHead.GetNewestSensorDataHeadBySensorID(Sensor.SensorID.ToString().ToUpper()); if (eHead == null) { SensorStatusDTO dtoStatus = new SensorStatusDTO(); dtoStatus.SensorCaption = mSensor.SensorName; dtoStatus.SensorStatus = mSensor.PositionMark; return(dtoStatus); } if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value) { SensorStatusDTO dtoStatus = new SensorStatusDTO(); dtoStatus.SensorCaption = mSensor.SensorName; dtoStatus.SensorStatus = mSensor.PositionMark; return(dtoStatus); } if (Convert.ToInt32(Sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Sterilizer))) { // 灭菌 return(GetStatusData(eHead)); } else if (Convert.ToInt32(Sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Washer))) { // 清洗 return(GetStatusData(eHead)); } else { logger.WarnFormat("未处理的设备类型([传感器:{0},设备类型:{1}])", Sensor.SensorKey, Sensor.SensorType); return(null); } }
internal static Sensor InvocationRateAndCountSensor(string threadId, string metricName, string metricDescription, string descriptionOfRate, string descriptionOfCount, MetricsRecordingLevel recordingLevel, StreamMetricsRegistry streamsMetrics) { Sensor sensor = streamsMetrics.ThreadLevelSensor(threadId, metricName, metricDescription, recordingLevel); SensorHelper.AddInvocationRateAndCountToSensor( sensor, StreamMetricsRegistry.THREAD_LEVEL_GROUP, streamsMetrics.ThreadLevelTags(threadId), metricName, descriptionOfRate, descriptionOfCount ); return(sensor); }
void OnGUI() { GUITools.SetFontSizes(); GUILayout.BeginArea(GUITools.Scale(new Rect(10, 150 * GUITools.DpiScaling, 240, 500))); GUI.color = Color.black; GUILayout.Label("Different modes:"); GUI.color = Color.white; if (GUILayout.Button("Rotation Vector", GUILayout.Height(GUITools.DpiScaling * 40))) { // if(GUI.Button(GUITools.Scale (new Rect(10,140,180,20)), "Rotation Vector")) SensorHelper.TryForceRotationFallback(RotationFallbackType.RotationQuaternion); } if (GUILayout.Button("Orientation/Acceleration", GUILayout.Height(GUITools.DpiScaling * 40))) { // if(GUI.Button(GUITools.Scale (new Rect(10,165,180,20)), "Orientation/Acceleration")) SensorHelper.TryForceRotationFallback(RotationFallbackType.OrientationAndAcceleration); } if (GUILayout.Button("Magnetic Field", GUILayout.Height(GUITools.DpiScaling * 40))) { // if(GUI.Button(GUITools.Scale (new Rect(10,190,180,20)), "Magnetic Field")) SensorHelper.TryForceRotationFallback(RotationFallbackType.MagneticField); } GUI.color = Color.black; // GUILayout.Label("orientation: " + Sensor.orientation); // GUILayout.Label("sum: " + (Sensor.orientation.x + Sensor.orientation.y + Sensor.orientation.z)); // GUILayout.Label("quat: " + Quaternion.Euler(Sensor.orientation).eulerAngles); // GUILayout.Space(20 * GUITools.DpiScaling); // GUI.color = Color.white; // if(GUILayout.Button("Orientation: LandscapeLeft", GUILayout.Height (GUITools.DpiScaling * 40))) Screen.orientation = ScreenOrientation.LandscapeLeft; // if(GUILayout.Button("Orientation: LandscapeRight", GUILayout.Height (GUITools.DpiScaling * 40))) Screen.orientation = ScreenOrientation.LandscapeRight; // if(GUILayout.Button("Orientation: Portrait", GUILayout.Height (GUITools.DpiScaling * 40))) Screen.orientation = ScreenOrientation.Portrait; // if(GUILayout.Button("Orientation: PortraitUpsideDown", GUILayout.Height (GUITools.DpiScaling * 40))) Screen.orientation = ScreenOrientation.PortraitUpsideDown; GUILayout.EndArea(); }