public Sensor() //For Protobuf-net { UndoStack = new Stack <SensorState>(); RedoStack = new Stack <SensorState>(); Calibrations = new List <Calibration>(); _metaData = new ObservableCollection <SensorMetaData>(); CurrentMetaData = new SensorMetaData(""); }
//For Protobuf-net public Sensor() { UndoStack = new Stack<SensorState>(); RedoStack = new Stack<SensorState>(); Calibrations = new List<Calibration>(); _metaData = new ObservableCollection<SensorMetaData>(); CurrentMetaData = new SensorMetaData(""); }
/// <summary> /// Creates a new sensor. /// </summary> /// <param name="name">The name of the sensor.</param> /// <param name="description">A description of the sensor's function or purpose.</param> /// <param name="upperLimit">The upper limit for values reported by this sensor.</param> /// <param name="lowerLimit">The lower limit for values reported by this sensor.</param> /// <param name="unit">The unit used to report values given by this sensor.</param> /// <param name="maxRateOfChange">The maximum rate of change allowed by this sensor.</param> /// <param name="manufacturer">The manufacturer of this sensor.</param> /// <param name="serial">The serial number associated with this sensor.</param> /// <param name="undoStack">A stack containing previous sensor states.</param> /// <param name="redoStack">A stack containing sensor states created after the modifications of the current state.</param> /// <param name="calibrations">A list of dates, on which calibration was performed.</param> /// <param name="errorThreshold">The number of times a failure-indicating value can occur before this sensor is flagged as failing.</param> /// <param name="owner">The dataset that owns the sensor</param> /// <param name="sType">Indicates whether the sensor's values should be averaged or summed when summarised</param> public Sensor(string name, string description, float upperLimit, float lowerLimit, string unit, float maxRateOfChange, Stack <SensorState> undoStack, Stack <SensorState> redoStack, List <Calibration> calibrations, int errorThreshold, Dataset owner, SummaryType sType) { if (name == "") { throw new ArgumentNullException("Name"); } if (unit == "") { throw new ArgumentNullException("Unit"); } if (calibrations == null) { throw new ArgumentNullException("Calibrations"); } if (undoStack == null) { throw new ArgumentNullException("UndoStack"); } if (redoStack == null) { throw new ArgumentNullException("RedoStack"); } if (upperLimit <= lowerLimit) { throw new ArgumentOutOfRangeException("UpperLimit"); } _name = name; RawName = name; Description = description; UpperLimit = upperLimit; LowerLimit = lowerLimit; _unit = unit; MaxRateOfChange = maxRateOfChange; _undoStack = undoStack; _redoStack = redoStack; _calibrations = calibrations; ErrorThreshold = errorThreshold; Owner = owner; _summaryType = sType; _metaData = new ObservableCollection <SensorMetaData>(); CurrentMetaData = new SensorMetaData(""); Colour = Color.FromRgb((byte)(Common.Generator.Next()), (byte)(Common.Generator.Next()), (byte)(Common.Generator.Next())); }
/// <summary> /// Creates a new sensor. /// </summary> /// <param name="name">The name of the sensor.</param> /// <param name="description">A description of the sensor's function or purpose.</param> /// <param name="upperLimit">The upper limit for values reported by this sensor.</param> /// <param name="lowerLimit">The lower limit for values reported by this sensor.</param> /// <param name="unit">The unit used to report values given by this sensor.</param> /// <param name="maxRateOfChange">The maximum rate of change allowed by this sensor.</param> /// <param name="manufacturer">The manufacturer of this sensor.</param> /// <param name="serial">The serial number associated with this sensor.</param> /// <param name="undoStack">A stack containing previous sensor states.</param> /// <param name="redoStack">A stack containing sensor states created after the modifications of the current state.</param> /// <param name="calibrations">A list of dates, on which calibration was performed.</param> /// <param name="errorThreshold">The number of times a failure-indicating value can occur before this sensor is flagged as failing.</param> /// <param name="owner">The dataset that owns the sensor</param> /// <param name="sType">Indicates whether the sensor's values should be averaged or summed when summarised</param> public Sensor(string name, string description, float upperLimit, float lowerLimit, string unit, float maxRateOfChange, Stack<SensorState> undoStack, Stack<SensorState> redoStack, List<Calibration> calibrations, int errorThreshold, Dataset owner, SummaryType sType) { if (name == "") throw new ArgumentNullException("Name"); // if (unit == "") // throw new ArgumentNullException("Unit"); if (calibrations == null) throw new ArgumentNullException("Calibrations"); if (undoStack == null) throw new ArgumentNullException("UndoStack"); if (redoStack == null) throw new ArgumentNullException("RedoStack"); if (upperLimit <= lowerLimit) throw new ArgumentOutOfRangeException("UpperLimit"); _name = name; RawName = name; Description = description; UpperLimit = upperLimit; LowerLimit = lowerLimit; _unit = unit; MaxRateOfChange = maxRateOfChange; _undoStack = undoStack; _redoStack = redoStack; _calibrations = calibrations; ErrorThreshold = errorThreshold; Owner = owner; _summaryType = sType; _metaData = new ObservableCollection<SensorMetaData>(); CurrentMetaData = new SensorMetaData(""); Colour = Color.FromRgb((byte)(Common.Generator.Next()), (byte)(Common.Generator.Next()), (byte)(Common.Generator.Next())); }
/// <summary> /// Adds a new meta data object to the sensor /// </summary> /// <param name="sensor">The sensor to recieve a new meta data object</param> /// <param name="keyPressEvent">The key press used to fire the method</param> /// <param name="sender">The origin of the event</param> public void AddNewMetaData(GraphableSensor sensor, KeyEventArgs keyPressEvent, ComboBox sender) { if (keyPressEvent.Key != Key.Enter) return; Debug.Print("Enter key pressed creating new meta data"); Debug.Print("Sender {0} Sensor {1}", sender, sensor); var newMetaData = new SensorMetaData(sender.Text); sensor.Sensor.MetaData.Add(newMetaData); sensor.Sensor.CurrentMetaData = newMetaData; }