private MeteredValue GetSummaryMeteredValue(ISODataLogValue dlv) { if (dlv.ProcessDataDDI == null) { return(null); } int ddi = dlv.ProcessDataDDI.AsInt32DDI(); int dataValue = 0; if (dlv.ProcessDataValue.HasValue) { dataValue = dlv.ProcessDataValue.Value; } var unitOfMeasure = RepresentationMapper.GetUnitForDdi(ddi); if (!DDIs.ContainsKey(ddi) || unitOfMeasure == null) { return(null); } DdiDefinition ddiDefintion = DDIs[ddi]; return(new MeteredValue { Value = new NumericRepresentationValue(RepresentationMapper.Map(ddi) as NumericRepresentation, unitOfMeasure, new NumericValue(unitOfMeasure, dataValue * ddiDefintion.Resolution)) }); }
private MeteredValue GetSummaryMeteredValue(ISODataLogValue dlv) { if (dlv.ProcessDataDDI == null) { return(null); } int ddi = dlv.ProcessDataDDI.AsInt32DDI(); int dataValue = 0; if (dlv.ProcessDataValue.HasValue) { dataValue = dlv.ProcessDataValue.Value; } var unitOfMeasure = RepresentationMapper.GetUnitForDdi(ddi); if (!DDIs.ContainsKey(ddi) || unitOfMeasure == null) { return(null); } DdiDefinition ddiDefintion = DDIs[ddi]; int?deviceConfigurationID = null; int?deviceElementID = TaskDataMapper.InstanceIDMap.GetADAPTID(dlv.DeviceElementIdRef); if (deviceElementID.HasValue) { //Since Device creation is on-demand, we need to call GetDeviceElementConfiguration here to ensure the relevant device is created if it hasn't been yet. var hierarchy = TaskDataMapper?.DeviceElementHierarchies?.GetRelevantHierarchy(dlv.DeviceElementIdRef); var adaptDeviceElement = DataModel?.Catalog?.DeviceElements?.FirstOrDefault(d => d?.Id?.ReferenceId == deviceElementID.Value); if (hierarchy != null && adaptDeviceElement != null) { DeviceElementConfiguration config = DeviceElementMapper.GetDeviceElementConfiguration(adaptDeviceElement, hierarchy, DataModel.Catalog); if (config != null) { deviceConfigurationID = config.Id.ReferenceId; } } } return(new MeteredValue { Value = new NumericRepresentationValue(RepresentationMapper.Map(ddi) as NumericRepresentation, unitOfMeasure, new NumericValue(unitOfMeasure, dataValue * ddiDefintion.Resolution)), DeviceConfigurationId = deviceConfigurationID }); }
private MeteredValue GetSummaryMeteredValue(ISODataLogValue dlv) { if (dlv.ProcessDataDDI == null) { return(null); } int ddi = dlv.ProcessDataDDI.AsInt32DDI(); int dataValue = 0; if (dlv.ProcessDataValue.HasValue) { dataValue = dlv.ProcessDataValue.Value; } var unitOfMeasure = RepresentationMapper.GetUnitForDdi(ddi); if (!DDIs.ContainsKey(ddi) || unitOfMeasure == null) { return(null); } DdiDefinition ddiDefintion = DDIs[ddi]; int?deviceConfigurationID = null; int?deviceElementID = TaskDataMapper.InstanceIDMap.GetADAPTID(dlv.DeviceElementIdRef); if (deviceElementID.HasValue) { DeviceElementConfiguration config = DataModel.Catalog.DeviceElementConfigurations.FirstOrDefault(c => c.DeviceElementId == deviceElementID.Value); if (config != null) { deviceConfigurationID = config.Id.ReferenceId; } } return(new MeteredValue { Value = new NumericRepresentationValue(RepresentationMapper.Map(ddi) as NumericRepresentation, unitOfMeasure, new NumericValue(unitOfMeasure, dataValue * ddiDefintion.Resolution)), DeviceConfigurationId = deviceConfigurationID }); }