/// <summary> /// Cancel the current sensor type selection and destroy the sensor game object /// </summary> public void CancelTypeSelection() { if (isAddingBeamBreaker) { isAddingBeamBreaker = false; addBeamBreakerButton.GetComponentInChildren <Text>().text = "Add Beam Breaker"; } else if (isAddingUltrasonic) { isAddingUltrasonic = false; addUltrasonicButton.GetComponentInChildren <Text>().text = "Add Ultrasonic"; } else if (isAddingGyro) { isAddingGyro = false; addGyroButton.GetComponentInChildren <Text>().text = "Add Gyro"; } addUltrasonicButton.SetActive(true); addBeamBreakerButton.SetActive(true); addGyroButton.SetActive(true); //Remove the current sensor - can't use this in EndProcesses because of this part if (currentSensor != null) { sensorManager.RemoveSensor(currentSensor.gameObject); //Shift the panel up for the current sensor destroyed ShiftOutputPanels(); Destroy(currentSensor.gameObject); currentSensor = null; } cancelTypeButton.SetActive(false); }
public override void Execute(JSONNode args) { var uid = args["uid"].Value; var api = ApiManager.Instance; SensorBase sensor = null; if (SimulatorManager.InstanceAvailable) { sensor = SimulatorManager.Instance.Sensors.GetSensor(uid); } if (sensor != null) { var tr = sensor.transform; var pos = tr.localPosition; var rot = tr.localRotation.eulerAngles; var result = new JSONObject(); result.Add("position", pos); result.Add("rotation", rot); api.SendResult(this, result); } else { api.SendError(this, $"Sensor '{uid}' not found"); } }
private void VerifyInitialization(SensorBase sensorBase, string exceptionMessage) { if (!sensorBase.IsInitialized) { throw new Exception(exceptionMessage); } }
/// <summary> /// Close all window related to adding/configuring sensor, also called in SimUI /// </summary> public void EndProcesses() { isChoosingOption = false; if (currentSensor != null) { currentSensor.ResetConfigurationState(); currentSensor = null; } sensorOptionPanel.SetActive(false); sensorTypePanel.SetActive(false); CancelOptionSelection(); CancelTypeSelection(); ResetConfigurationWindow(); //HideSensorOutput(); selectedNode = null; //Switch back to the original camera state if (preConfigState != null) { dynamicCamera.SwitchToState(preConfigState); preConfigState = null; } HideInvisibleSensors(); }
public override void Execute(JSONNode args) { var uid = args["uid"].Value; var api = ApiManager.Instance; SensorBase sensor = null; if (SimulatorManager.InstanceAvailable) { sensor = SimulatorManager.Instance.Sensors.GetSensor(uid); } if (sensor != null) { var sensorType = sensor.GetType().GetCustomAttribute <SensorType>(); if (sensorType.Name == "Lidar") { var path = args["path"].Value; var result = (bool)sensor.GetType().GetMethod("Save").Invoke(sensor, new object[] { path }); api.SendResult(this, result); } else { api.SendError(this, $"Sensor '{uid}' is not a lidar sensor"); } } else { api.SendError(this, $"Sensor '{uid}' not found"); } }
/// <summary> /// If the remote IP address is that of a known Acurite Access device, we will sniff whatever data we want from it and proxy the request to Acurite. /// </summary> /// <param name="p"></param> /// <returns></returns> private bool HandleRequestFromAcuriteAccessDevice(HttpProcessor p) { if (Program.settings.GetAcuriteAccessIPs().Contains(p.RemoteIPAddressStr)) { ProxyDataBuffer proxiedDataBuffer = new ProxyDataBuffer(); p.ProxyTo("https://atlasapi.myacurite.com" + p.request_url.PathAndQuery, 30000, true, proxiedDataBuffer); lastAcuriteAccessRequests.Enqueue(proxiedDataBuffer); if (lastAcuriteAccessRequests.Count > 10) { lastAcuriteAccessRequests.TryDequeue(out ProxyDataBuffer removed); } foreach (string str in proxiedDataBuffer.Items.Select(i => i.PayloadAsString)) { Match m = rxGetURL.Match(str); if (m.Success) { SensorBase sensorData = new SensorBase(m.Groups[2].Value); sensorDataCollection[sensorData.UniqueID] = sensorData; List <DataFileTemplate> templates = Program.settings.GetSensorDataTemplates(); foreach (DataFileTemplate template in templates) { if (sensorData.UniqueID == template.UniqueID || sensorData.DeviceName == template.UniqueID) { sensorData.WriteFile(template); } } } } return(true); } return(false); }
public SensorInstanceController(SensorData configuration, SensorBase instance) { this.configuration = configuration; this.instance = instance; if (Loader.Instance.Network.IsClusterSimulation) { var distributedObject = instance.gameObject.AddComponent <DistributedObject>(); distributedObject.ForwardMessages = Loader.Instance.Network.IsMaster; distributedObject.DistributeIsActive = false; distributedObject.CallInitialize(); var distributedTransform = instance.gameObject.AddComponent <DistributedTransform>(); distributedTransform.CallInitialize(); } //Negate current value so proper method can be called //Without negating current status method will not be be executed enabled = !instance.isActiveAndEnabled; if (enabled) { Disable(); } else { Enable(); } }
static string GetSensorType(SensorBase sensor) { var type = sensor.GetType().GetCustomAttributes(typeof(SensorType), false)[0] as SensorType; UnityEngine.Debug.Log($"{type.Name}"); return(type.Name); }
/// <summary> /// Close all window related to adding/configuring sensor, also called in SimUI /// </summary> public void EndProcesses() { isChoosingOption = false; if (currentSensor != null) { currentSensor.ResetConfigurationState(); currentSensor = null; } sensorOptionPanel.SetActive(false); sensorTypePanel.SetActive(false); CancelOptionSelection(); CancelTypeSelection(); ResetConfigurationWindow(); HideSensorOutput(); //configureSensorButton.GetComponentInChildren<Text>().text = "Add/Configure Sensor"; selectedNode = null; if (preConfigState != null) { dynamicCamera.SwitchToState(preConfigState); preConfigState = null; } HideInvisibleSensors(); }
/// <summary> /// Cancel the current sensor type selection and destroy the sensor game object /// </summary> public void CancelSensorTypeSelection() { if (isAddingBeamBreaker) { isAddingBeamBreaker = false; addBeamBreakerButton.GetComponentInChildren <Text>().text = "Add Beam Breaker"; } else if (isAddingUltrasonic) { isAddingUltrasonic = false; addUltrasonicButton.GetComponentInChildren <Text>().text = "Add Ultrasonic"; } else if (isAddingGyro) { isAddingGyro = false; addGyroButton.GetComponentInChildren <Text>().text = "Add Gyro"; } addUltrasonicButton.SetActive(true); addBeamBreakerButton.SetActive(true); addGyroButton.SetActive(true); if (currentSensor != null) { sensorManager.RemoveSensor(currentSensor.gameObject); ShiftOutputPanels(); Destroy(currentSensor.gameObject); currentSensor = null; } cancelTypeButton.SetActive(false); }
public void AddSensor(E_SensorType sensorType, bool activate) { SensorBase s = SensorFactory.Create(sensorType, Owner); s.Active = activate; Sensors[(int)sensorType] = s; }
public bool PlayerIsInSensor(string sensor_name) { SensorBase sensorBase = null; this.m_Sensors.TryGetValue(sensor_name, out sensorBase); return(sensorBase && sensorBase.IsInside()); }
public void ReceiveData(string str) { try { lastRequests.Enqueue(str); if (lastRequests.Count > 10) { lastRequests.TryDequeue(out string removed); } Match m = rxGetURL.Match(str); if (m.Success) { SensorBase sensorData = new SensorBase(m.Groups[2].Value); sensorDataCollection[sensorData.UniqueID] = sensorData; List <DataFileTemplate> templates = Program.settings.GetSensorDataTemplates(); foreach (DataFileTemplate template in templates) { if (sensorData.UniqueID == template.UniqueID) { sensorData.WriteFile(template); } } } } catch (Exception ex) { Logger.Debug(ex); } }
public override void Execute(JSONNode args) { var uid = args["uid"].Value; var api = ApiManager.Instance; SensorBase sensor = null; if (SimulatorManager.InstanceAvailable) { sensor = SimulatorManager.Instance.Sensors.GetSensor(uid); } if (sensor != null) { if (sensor is LidarSensor lidar) { var path = args["path"].Value; var result = lidar.Save(path); api.SendResult(this, result); } else { api.SendError(this, $"Sensor '{uid}' is not a lidar sensor"); } } else { api.SendError(this, $"Sensor '{uid}' not found"); } }
/// <summary> /// Add a beam breaker sensor to the selected node and display its output /// </summary> public void AddBeamBreaker() { if (selectedNode != null) { currentSensor = sensorManager.AddBeamBreaker(selectedNode, Vector3.zero, new Vector3(0, 90, 0)); DisplayOutput(); } }
/// <summary> /// Add an ultrasonic sensor to the selected node and display its output /// </summary> public void AddUltrasonic() { if (selectedNode != null) { currentSensor = sensorManager.AddUltrasonic(selectedNode, new Vector3(0, 0.2f, 0), Vector3.zero); DisplayOutput(); } }
public void SetThreadScopedFeatureName_WithoutFeatureGroupSpecified_SetsFeatureGroupToGlobal() { SensorBase.SetThreadScopedFeatureName("test"); var sensor = new SensorTestDouble("test"); Assert.That(sensor.GetFeatureNameExposed().Group, Is.EqualTo(FeatureStatistics.GlobalGroupName)); }
public bool PlayerIsInSensor(string sensor_name) { int key = Animator.StringToHash(sensor_name); SensorBase sensorBase = null; this.m_Sensors.TryGetValue(key, out sensorBase); return(sensorBase && sensorBase.IsInside()); }
/// <summary> /// Add a gyro to the selected node and display its output /// </summary> public void AddGyro() { if (selectedNode != null) { currentSensor = sensorManager.AddGyro(selectedNode, Vector3.zero, Vector3.zero); DisplayOutput(); } }
/// <summary> /// Delete the current sensor from the robot /// </summary> public void DeleteSensor() { Destroy(currentSensor.gameObject); sensorManager.RemoveSensor(currentSensor.gameObject); ShiftOutputPanels(); currentSensor = null; configureSensorButton.GetComponentInChildren <Text>().text = "Add/Configure Sensor"; EndProcesses(); }
public bool AppendEndPoint(SensorBase sensorBase, IPEndPoint endPoint) { if (!instanceToMetaData.TryGetValue(sensorBase, out var metaData)) { return(false); } metaData.HostEndPoint = endPoint; return(true); }
public void GetFeatureName_WhenFeatureNameIsInThreadContext_ReturnsTheOneFromTheThreadContext() { string featureName = "datapointName"; SensorBase.SetThreadScopedFeatureName(featureName); var sensor = new SensorTestDouble("test"); Assert.That(sensor.GetFeatureNameExposed().Name, Is.EqualTo(featureName)); }
/// <summary> /// Delete the current sensor from the robot /// </summary> public void DeleteSensor() { //Don't change the order of following lines or it won't work Destroy(currentSensor.gameObject); sensorManager.RemoveSensor(currentSensor.gameObject); ShiftOutputPanels(); currentSensor = null; EndProcesses(); }
public void SetThreadScopeFeatureName_WithFeatureGroupSpecified_SetsFeatureGroupAccordingly() { string testGroup = "testGroup"; SensorBase.SetThreadScopedFeatureName("test", testGroup); var sensor = new SensorTestDouble("test"); Assert.That(sensor.GetFeatureNameExposed().Group, Is.EqualTo(testGroup)); }
public void RegisterSensor(SensorBase sensor) { if (!this.m_Sensors.ContainsKey(sensor.name)) { this.m_Sensors.Add(sensor.name, sensor); } else if (this.m_Sensors.ContainsValue(sensor)) { DebugUtils.Assert("[SensorManager:RegisterSensor] ERROR - More than one sensor with name " + sensor.name, true, DebugUtils.AssertType.Info); } }
private void OnZoomInto(SensorBase obj) { Point k = obj.TranslatePoint(new Point(obj.ActualWidth / 2, obj.ActualHeight / 2), PlanGrid); double scale = obj.ActualHeight > obj.ActualWidth ? PlanScrollViewer.ActualHeight / obj.ActualHeight * 0.6 : PlanScrollViewer.ActualWidth / obj.ActualWidth * 0.6; _lastCenterPositionOnTarget = null; ScrollToPosition(k.X * scale - PlanScrollViewer.ActualWidth / 2, k.Y * scale - PlanScrollViewer.ActualHeight / 2, scale); }
public void RegisterSensor(SensorBase sensorBase) { var metaData = new SensorMetaData(sensorBase); sensors.Add(metaData); instanceToMetaData.Add(sensorBase, metaData); if (awaitingPathToUID.Count > 0 && awaitingPathToUID.TryGetValue(metaData.HierarchyPath, out var uid)) { awaitingPathToUID.Remove(metaData.HierarchyPath); uidToMetaData.Add(uid, metaData); } }
public ModbusTCP(string ipAddress, int portNo = 502) { try { _remoteEP = new IPEndPoint(IPAddress.Parse(ipAddress), portNo); _sensorInstance = new StaticElectricityObject(); } catch (Exception ex) { throw new DSF602Exception(ex.Message, ex.InnerException, DSF602ExceptionStatusCode.Initialization); } }
public void ClearThreadScoredFeatureName_AfterSettingFeatureNameToTest_ReturnsApplication() { string featureName = "datapointName"; SensorBase.SetThreadScopedFeatureName(featureName); var sensor = new SensorTestDouble("test"); SensorBase.ClearThreadScopedFeatureName(); Assert.That(sensor.GetFeatureNameExposed().Name, Is.EqualTo("Application")); }
/// <summary> /// Similar function as the SyncNodeFunction /// </summary> public void SyncSensorSelection() { if (sensorManager.SelectedSensor == null) { currentSensor = null; } else { currentSensor = sensorManager.SelectedSensor.GetComponent <SensorBase>(); sensorManager.ClearSelectedSensor(); } }