private FieldDescriptorDto GetFieldDescriptor(DeviceDto device, string fieldName, string port) { if (string.IsNullOrEmpty(port)) { return(device.GetField(fieldName)); } // Port has a space in it. // e.g. powerState and powerState-port-1 string fieldAndPortName = string.Format("{0}-{1}", fieldName, port); FieldDescriptorDto field = device.GetField(fieldAndPortName); if (field != null) { return(field); } return(GetFieldDescriptor(device, fieldName, null)); }
protected async Task <FieldValueDto> GetFieldValue(string token, DeviceDto device, string fieldName, string port) { FieldDescriptorDto field = GetFieldDescriptor(device, fieldName, port); if (field == null) { LambdaLogger.Log("Did not find required field '" + fieldName + "' for device: " + device.DisplayName); return(null); } LambdaLogger.Log("Getting field '" + fieldName + "' value from device: " + device.DisplayName); var value = await _measurementsClient.GetFieldValueAsync(token, device.Id, field); if (value == null) { LambdaLogger.Log("Did not find field '" + fieldName + "' value for device: " + device.DisplayName); return(null); } return(value); }
public Task <FieldValueDto> GetFieldValueAsync(string authToken, string deviceId, FieldDescriptorDto field) { throw new System.NotImplementedException(); }
public async Task <FieldValueDto> GetFieldValueAsync(string authToken, string deviceId, FieldDescriptorDto field) { var uri = string.Format(baseUri, deviceId, field.Channel, field.Name); LambdaLogger.Log("Get field from: " + uri); SenMLDto senml = await _restClient.GetAsJsonAsync <SenMLDto>(authToken, uri); return(senml.e.FirstOrDefault()); }