/// <summary> /// Initializes runtime measurement. /// </summary> /// <param name="index">The index.</param> /// <param name="item">The item.</param> /// <param name="measurement">The measurement.</param> private static void InitializeRuntimeMeasurement(long index, ConfiguredMeasurement item, RuntimeMeasurement measurement) { // Initializes the request index. measurement.RequestIndex = index; // Initializes the fields. // The device id is always a static value, the mapping is ignored here. measurement.DeviceId = item.DeviceId.Value; // The sensor id is always a static value, the mapping is ignored here. measurement.SensorId = item.SensorId.Value; // Sets the unit. measurement.Unit = InitializeValue(item.Unit); // The data type of the configured item is an enumerated value. measurement.DataType = new DataTypeDisplayNames()[(int)item.DataType]; // Sets the timestamp. measurement.Timestamp = InitializeValue(item.Timestamp); // Sets the quality. measurement.Quality = InitializeValue(item.Quality); // Sets the value. measurement.Value = InitializeValue(item.Value); }
/// <summary> /// Buttons the test start monitor request. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void ButtonTestStartMonitorRequest(object sender, RoutedEventArgs e) { try { var client = new CommServerClient(); var measurements = new ConfiguredMeasurements(); for (int i = 0; i < 5; i++) { Random rnd = new Random(); var randomNumber = rnd.Next(100); var measurement = new ConfiguredMeasurement(true); measurement.DeviceId = new ConfiguredMeasurementItem(true) { Value = "DeviceId_" + randomNumber.ToString(CultureInfo.InvariantCulture), MappingType = MappingTypes.StaticType }; measurement.SensorId = new ConfiguredMeasurementItem(true) { Value = "SensorId_" + randomNumber.ToString(CultureInfo.InvariantCulture), MappingType = MappingTypes.StaticType }; measurement.Unit = new ConfiguredMeasurementItem(true) { Value = "m3", MappingType = MappingTypes.StaticType }; measurement.DataType = CommonFormatDataTypes.FloatType; measurement.Timestamp = new ConfiguredMeasurementItem(true) { Value = "Some_Opc_ItemId", MappingType = MappingTypes.OpcTimestampType }; measurement.Quality = new ConfiguredMeasurementItem(true) { Value = "Some_Opc_ItemId", MappingType = MappingTypes.OpcQualityType }; measurement.Value = new ConfiguredMeasurementItem(true) { Value = "Some_Opc_ItemId", MappingType = MappingTypes.OpcValueType }; measurement.Active = true; measurements.Add(measurement); } client.StartMonitorRequest(ClientUri, Guid.NewGuid(), measurements); client.Close(); } catch (Exception exception) { MessageBox.Show("Exception in client call: " + exception.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="ConfiguredMeasurementItemData"/> class. /// </summary> /// <param name="configuredMeasurement">The configured measurement.</param> /// <param name="measurementItemValue">The measurement item value.</param> /// <param name="measurementItemMappingMode">The measurement item mapping mode.</param> /// <param name="measurementItemType">Type of the measurement item.</param> public ConfiguredMeasurementItemData(ref ConfiguredMeasurement configuredMeasurement, string measurementItemValue, string measurementItemMappingMode, MeasurementItemTypes measurementItemType) { this.MeasurementItemType = measurementItemType; this.configuredMeasurement = configuredMeasurement; this.Value = this.MeasurementItemType == MeasurementItemTypes.DataType ? measurementItemValue.Replace(@"Type", string.Empty) : measurementItemValue; this.MappingMode = measurementItemMappingMode.Replace(@"Type", string.Empty); this.MappingModeTypes = new ObservableCollection <string>(); this.MappingModeTypes.Clear(); this.DataTypes = new ObservableCollection <string>(); this.DataTypes.Clear(); this.InitializeViewControls(); }
/// <summary> /// Initializes a new instance of the <see cref="ConfiguredMeasurementData"/> class. /// </summary> /// <param name="configuredMeasurement">The configured measurement.</param> public ConfiguredMeasurementData(ref ConfiguredMeasurement configuredMeasurement) { this.configuredMeasurement = configuredMeasurement; this.setComboBoxSelectionChanged = new DelegateCommand(this.OnComboBoxSelectionChanged); this.DeviceId = configuredMeasurement.DeviceId.Value; this.SensorId = configuredMeasurement.SensorId.Value; if (configuredMeasurement.Active) { this.Active = Resources.Active; } else { this.Active = Resources.NotActive; } this.ActiveStates = new ObservableCollection <string>(); this.ActiveStates.Clear(); this.ActiveStates.Add(Resources.Active); this.ActiveStates.Add(Resources.NotActive); }