/// <summary> /// 鼠标单击事件,3种情况 /// 1:右键菜单取消 /// 2:添加新传感器 /// 3:打开右键菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PicMask_MouseClick(object sender, MouseEventArgs e) { if (IsEditing) { if (SelectSensor != null) { SelectSensor = null; } else if (e.Button == MouseButtons.Left && MostNearSensor == null) { DectectPointInfo new_sensor = new DectectPointInfo(); new_sensor.Location = new Tuple <int, int>(e.X, e.Y); new_sensor.Position = new Tuple <double, double>((double)e.X / this.Width, (double)e.Y / this.Height); new_sensor.Weight = 0; SensorList.Add(new_sensor); ReSet(); } else if (e.Button == MouseButtons.Right) { if (MostNearSensor != null) { RightClickcontextMenuStrip.Show(MousePosition.X, MousePosition.Y); } } } }
//Actors and Sensors private void LoadData() { simulator = new Simulator(modelItems); //modelItems-Liste wird an Simulator übergeben foreach (var item in simulator.Items) //enthält die generierten Demo-Daten aus dem Simulator { if (item.ItemType.Equals(typeof(ISensor))) { SensorList.Add(item); } else if (item.ItemType.Equals(typeof(IActuator))) { ActorList.Add(item); } } }
private void LoadData() { Simulator sim = new Simulator(modelItems); foreach (var item in sim.Items) { if (item.ItemType.Equals(typeof(ISensor))) { SensorList.Add(item); } else if (item.ItemType.Equals(typeof(IActuator))) { ActorList.Add(item); } } }
public void GenerateData() { sim = new Simulator(ModelList); foreach (var item in sim.Items) { if (item.ItemType.Equals(typeof(ISensor))) { SensorList.Add(item); } else if (item.ItemType.Equals(typeof(IActuator))) { ActorList.Add(item); } } }
//DemoDaten laden private void LoadData() { Simulator sim = new Simulator(modelItems); //ueberpruefen ob Sensor oder Actor und zu Liste hinzufuegen foreach (var item in sim.Items) { if (item.ItemType.Equals(typeof(ISensor))) { SensorList.Add(item); } else if (item.ItemType.Equals(typeof(IActuator))) { ActorList.Add(item); } } }
public bool LoadSensorInfo(string logname) { logfilename = logname; SensorList.Clear(); if (File.Exists(string.Format("{0}\\{1}.log", LogPath, logfilename))) { using (StreamReader sr = new StreamReader(string.Format("{0}\\{1}.log", LogPath, logfilename), Encoding.UTF8)) { String line; double x; double y; Random ra = new Random(); while ((line = sr.ReadLine()) != null) { var onesensor = new DectectPointInfo(); x = double.Parse(line.Substring(1, 6)); y = double.Parse(line.Substring(8, 6)); onesensor.Position = new Tuple <double, double>(x, y); onesensor.Location = new Tuple <int, int>(Convert.ToInt32(x * this.Width), Convert.ToInt32(y * this.Height)); //onesensor.Weight = ra.NextDouble(); onesensor.Weight = 0d; // 查询该点是否绑定检测信号 if (line.Length > 16) { onesensor.SignalName = line.Substring(15, line.Length - 15); // 获取之前绑定的信号名称 // 检测该信号名称是否已经加载,若无则清空该监测点绑定的信号名称 var onelistsignal = CardSettingManager.Settings.Find(onesetting => onesetting.SignalName == onesensor.SignalName); if (onelistsignal == null) { onesensor.SignalName = null; } } else { onesensor.SignalName = null; } SensorList.Add(onesensor); } } ReSet(); return(true); } ReSet(); return(false); }
/// <summary> /// Constructor /// </summary> /// <param name="gattService">Gatt Service found for this sensor</param> /// <param name="sensorIndex">SensorIndex</param> public CC2650SensorTag(GattDeviceService gattService, SensorIndexes sensorIndex, SensorDataDelegate callMeBack) { Debug.WriteLine("Begin sensor constructor: " + sensorIndex.ToString()); try { NotificationState = NotificationStates.off; SensorList.Add(this); GattService = gattService; HasSetCallBacks = false; SensorIndex = sensorIndex; Guid guidNull = Guid.Empty; Guid guidData = guidNull; Guid guidNotification = guidNull; Guid guidConfiguraton = guidNull; Guid guidPeriod = guidNull; Guid guidAddress = guidNull; Guid guidDevId = guidNull; CallMeBack = callMeBack; IO_IsOn = false; switch (SensorIndex) { case SensorIndexes.KEYS: guidNotification = BUTTONS_NOTIFICATION_GUID; break; case SensorIndexes.IO_SENSOR: guidData = IO_SENSOR_DATA_GUID; guidConfiguraton = IO_SENSOR_CONFIGURATION_GUID; break; case SensorIndexes.REGISTERS: guidData = REGISTERS_DATA_GUID; guidAddress = REGISTERS_ADDRESS_GUID; guidDevId = REGISTERS_DEVICE_ID_GUID; break; default: guidData = new Guid(UUIDBase[(int)SensorIndex] + SENSOR_GUID_SUFFFIX); guidNotification = new Guid(UUIDBase[(int)SensorIndex] + SENSOR_NOTIFICATION_GUID_SUFFFIX); guidConfiguraton = new Guid(UUIDBase[(int)SensorIndex] + SENSOR_ENABLE_GUID_SUFFFIX); guidPeriod = new Guid(UUIDBase[(int)SensorIndex] + SENSOR_PERIOD_GUID_SUFFFIX); break; } IReadOnlyList <GattCharacteristic> characteristicList_Data = null; IReadOnlyList <GattCharacteristic> characteristicList_Notification = null; IReadOnlyList <GattCharacteristic> characteristicList_Configuration = null; IReadOnlyList <GattCharacteristic> characteristicList_Period = null; IReadOnlyList <GattCharacteristic> characteristicList_Address = null; IReadOnlyList <GattCharacteristic> characteristicList_Device_Id = null; if (guidData != guidNull) { characteristicList_Data = gattService.GetCharacteristics(guidData); } if (guidNotification != guidNull) { characteristicList_Notification = gattService.GetCharacteristics(guidNotification); } if (guidConfiguraton != guidNull) { characteristicList_Configuration = gattService.GetCharacteristics(guidConfiguraton); } if (guidPeriod != guidNull) { characteristicList_Period = gattService.GetCharacteristics(guidPeriod); } if (guidAddress != guidNull) { characteristicList_Address = gattService.GetCharacteristics(guidAddress); } if (guidDevId != guidNull) { characteristicList_Device_Id = gattService.GetCharacteristics(guidDevId); } if (characteristicList_Data != null) { if (characteristicList_Data.Count > 0) { Data = characteristicList_Data[0]; } } if (characteristicList_Notification != null) { if (characteristicList_Notification.Count > 0) { Notification = characteristicList_Notification[0]; } } if (characteristicList_Configuration != null) { if (characteristicList_Configuration.Count > 0) { Configuration = characteristicList_Configuration[0]; } } if (characteristicList_Period != null) { if (characteristicList_Period.Count > 0) { Data = characteristicList_Period[0]; } } if (characteristicList_Address != null) { if (characteristicList_Address.Count > 0) { Address = characteristicList_Address[0]; } } if (characteristicList_Device_Id != null) { if (characteristicList_Device_Id.Count > 0) { Device_Id = characteristicList_Device_Id[0]; } } SensorsCharacteristicsList[(int)sensorIndex] = this; if (SensorIndex >= 0 && SensorIndex != SensorIndexes.IO_SENSOR && SensorIndex != SensorIndexes.REGISTERS) { ActiveCharacteristicNotifications[(int)SensorIndex] = Notification; Task.Run(() => this.SetChangedNotifactionHandler()).Wait(); //Could leave out Wait but potentially could action this instance too soon Task.Run(() => this.TurnOnSensor()).Wait(); //This launches a new thread for this action but stalls the constructor thread. } } catch (Exception ex) { Debug.WriteLine("Error: CC2650SensorTag() Constructor: " + SensorIndex.ToString() + " " + ex.Message); } IncProgressCounter(); Debug.WriteLine("End sensor constructor: " + SensorIndex.ToString()); }