iOS AILinkBleSDK - 蓝牙SDK
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ELEightScaleAlgorithmTool.m 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. //
  2. // ELEightScaleAlgorithmTool.m
  3. // Elink
  4. //
  5. // Created by iot_user on 2020/6/18.
  6. // Copyright © 2020 iot_iMac. All rights reserved.
  7. //
  8. #import "ELEightScaleAlgorithmTool.h"
  9. #import "ELEightScaleRecordModel.h"
  10. #import <AILinkBleSDK/ELEightScaleBleDataModel.h>
  11. #import <AILinkBleSDK/ELEightScaleSDKHeader.h>
  12. #import "HTBodyfat_SDK.h"
  13. #import <AILinkBleSDK/ELHeightAlgorithmusModel.h>
  14. #import <AILinkBleSDK/ELWeightAlgorithmusModel.h>
  15. #import <AILinkBleSDK/ELBodyIndexAlgorithmModel.h>
  16. #import "BhBodyCompositionAllBody50KHz.h"
  17. @implementation ELEightScaleAlgorithmTool
  18. /// 根据秤测量的阻抗数据调用算法解析出其他体脂数据
  19. /// @param dataModel 八电极秤测量的数据
  20. /// @param sex 女性传0,男性传1
  21. /// @param height 身高,单位cm
  22. /// @param age 年龄
  23. +(ELEightScaleRecordModel *)getRecordModelWithBleDataModel:(ELEightScaleBleDataModel *)dataModel withUserSex:(NSInteger)sex height:(NSInteger)height age:(NSInteger)age {
  24. CGFloat kgWeight = [ELWeightAlgorithmusModel getKgWithWeightShowStr:dataModel.weight weightUnit:dataModel.weightUnit weightPoint:dataModel.weightPoint].floatValue;
  25. HTBodyBasicInfo *bodyBasicInfo = [[HTBodyBasicInfo alloc] initWithSex:sex height:height weight:kgWeight age:age];
  26. bodyBasicInfo.htZAllBodyImpedance = dataModel.RWholeBodyAdc;
  27. bodyBasicInfo.htZLeftLegImpedance = dataModel.leftFootAdc;
  28. bodyBasicInfo.htZRightLegImpedance = dataModel.rightFootAdc;
  29. bodyBasicInfo.htZLeftArmImpedance = dataModel.leftHandAdc;
  30. bodyBasicInfo.htZRightArmImpedance = dataModel.rightHandAdc;
  31. bodyBasicInfo.htTwoArmsImpedance = dataModel.handsAdc;
  32. bodyBasicInfo.htTwoLegsImpedance = dataModel.feetAdc;
  33. //计算体脂参数
  34. HTBodyResultAllBody *bodyResultTwoLegs = [[HTBodyResultAllBody alloc] init];
  35. HTBodyfatErrorType errorType = [bodyResultTwoLegs getBodyfatWithBasicInfo:bodyBasicInfo];
  36. NSLog(@"HTBodyfatErrorType = %lu",errorType);
  37. if(errorType != HTBodyfatErrorTypeNone){
  38. NSMutableString *errorStr = [[NSMutableString alloc]initWithString:@""];
  39. if((errorType & HTBodyfatErrorTypeAge) == HTBodyfatErrorTypeAge){
  40. [errorStr appendString:@"年龄 "];
  41. }
  42. if((errorType & HTBodyfatErrorTypeWeight) == HTBodyfatErrorTypeWeight){
  43. [errorStr appendString:@"体重 "];
  44. }
  45. if((errorType & HTBodyfatErrorTypeHeight) == HTBodyfatErrorTypeHeight){
  46. [errorStr appendString:@"身高 "];
  47. }
  48. if((errorType & HTBodyfatErrorTypeSex) == HTBodyfatErrorTypeSex){
  49. [errorStr appendString:@"性别 "];
  50. }
  51. if((errorType & HTBodyfatErrorTypeImpedance) == HTBodyfatErrorTypeImpedance){
  52. [errorStr appendString:@"阻抗 "];
  53. }
  54. if((errorType & HTBodyfatErrorTypeImpedanceLeftLeg) == HTBodyfatErrorTypeImpedanceLeftLeg){
  55. [errorStr appendString:@"左脚阻抗 "];
  56. }
  57. if((errorType & HTBodyfatErrorTypeImpedanceRightLeg) == HTBodyfatErrorTypeImpedanceRightLeg){
  58. [errorStr appendString:@"右脚阻抗 "];
  59. }
  60. if((errorType & HTBodyfatErrorTypeImpedanceLeftArm) == HTBodyfatErrorTypeImpedanceLeftArm){
  61. [errorStr appendString:@"左手阻抗 "];
  62. }
  63. if((errorType & HTBodyfatErrorTypeImpedanceRightArm) == HTBodyfatErrorTypeImpedanceRightArm){
  64. [errorStr appendString:@"右手阻抗 "];
  65. }
  66. [errorStr appendString:@"参数有误!"];
  67. NSLog(@"errorType = %@",errorStr);
  68. }
  69. ELEightScaleRecordModel *recordModel = [[ELEightScaleRecordModel alloc] init];
  70. recordModel.bmi = [NSString stringWithFormat:@"%.1f",bodyResultTwoLegs.htBMI];
  71. recordModel.bfr = [NSString stringWithFormat:@"%.1f",bodyResultTwoLegs.htBodyfatPercentage];
  72. recordModel.sfr = [NSString stringWithFormat:@"%.1f",bodyResultTwoLegs.htBodyfatSubcut];
  73. recordModel.uvi = [NSString stringWithFormat:@"%ld",bodyResultTwoLegs.htVFAL];
  74. recordModel.rom = [NSString stringWithFormat:@"%.1f",bodyResultTwoLegs.htMusclePercentage];
  75. recordModel.bmr = [NSString stringWithFormat:@"%ld",bodyResultTwoLegs.htBMR];
  76. recordModel.vwc = [NSString stringWithFormat:@"%.1f",bodyResultTwoLegs.htWaterPercentage];
  77. recordModel.bodyAge = [NSString stringWithFormat:@"%ld",bodyResultTwoLegs.htBodyAge];
  78. recordModel.pp = [NSString stringWithFormat:@"%.1f",bodyResultTwoLegs.htProteinPercentage];
  79. recordModel.adc = [NSString stringWithFormat:@"%d",dataModel.trunkAdc];//记录躯干adc
  80. recordModel.heartRate = dataModel.heartRate>0?[NSString stringWithFormat:@"%d",dataModel.heartRate]:@"";
  81. recordModel.createTime = dataModel.createTime;
  82. recordModel.deviceAlgorithm = [NSString stringWithFormat:@"%d",dataModel.algorithmID];
  83. //新算法
  84. if (dataModel.algorithmID == 0x20) { //MCU计算体脂率,算法ID就应该是0; 但是精衡秤MCU算法秤例外,有个0x20的算法ID
  85. [self new_algorithmOfHTWithDataModel:dataModel sex:sex height:height kgWeight:kgWeight age:age updateRecordModel:recordModel];
  86. return recordModel;
  87. }
  88. //骨量
  89. if (bodyResultTwoLegs.htBoneKg>0) {
  90. NSUInteger boneMass = roundf(bodyResultTwoLegs.htBoneKg*pow(10, dataModel.weightPoint));
  91. recordModel.bm = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:boneMass bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  92. }else{
  93. recordModel.bm = @"";
  94. }
  95. //标准体重
  96. if (bodyResultTwoLegs.htIdealWeightKg >0) {
  97. //说明有值
  98. NSUInteger standard = roundf(bodyResultTwoLegs.htIdealWeightKg*pow(10, dataModel.weightPoint));
  99. recordModel.standardWeight = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:standard bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  100. //体重控制量
  101. CGFloat weightControl = kgWeight - bodyResultTwoLegs.htIdealWeightKg;
  102. NSUInteger weightContrlABS = roundf(fabs(weightControl*pow(10, dataModel.weightPoint)));
  103. NSString *weightContrlStr = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:weightContrlABS bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  104. if (weightControl<0) {
  105. recordModel.weightControl = [NSString stringWithFormat:@"-%@",weightContrlStr];
  106. }else{
  107. recordModel.weightControl = weightContrlStr;
  108. }
  109. recordModel.fatLevel = [NSString stringWithFormat:@"%lu",(unsigned long)[ELBodyIndexAlgorithmModel getfatLevelWithweight:kgWeight andStandardWeight:bodyResultTwoLegs.htIdealWeightKg]];
  110. }else{
  111. recordModel.standardWeight = @"";
  112. recordModel.weightControl = @"";
  113. recordModel.fatLevel = @"";
  114. }
  115. //脂肪量
  116. if (bodyResultTwoLegs.htBodyfatKg>0) {
  117. NSUInteger fatMass = roundf(bodyResultTwoLegs.htBodyfatKg*pow(10, dataModel.weightPoint));
  118. recordModel.fatMass = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:fatMass bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  119. }else{
  120. recordModel.fatMass = @"";
  121. }
  122. //去脂体重
  123. if (bodyResultTwoLegs.htBodyfatFreeMass>0) {
  124. NSUInteger withoutFatW = roundf(bodyResultTwoLegs.htBodyfatFreeMass*pow(10, dataModel.weightPoint));
  125. recordModel.weightWithoutFat = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:withoutFatW bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  126. }else{
  127. recordModel.weightWithoutFat = @"";
  128. }
  129. //肌肉量
  130. if (bodyResultTwoLegs.htMuscleKg>0) {
  131. NSInteger musleMass = round(bodyResultTwoLegs.htMuscleKg*pow(10, dataModel.weightPoint));
  132. recordModel.musleMass = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:musleMass bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  133. }else{
  134. recordModel.musleMass = @"";
  135. }
  136. //蛋白量
  137. if (bodyResultTwoLegs.htProteinPercentage>0) {
  138. NSUInteger proteinMassInt = roundf((bodyResultTwoLegs.htProteinPercentage/100.0)*kgWeight* pow(10, dataModel.weightPoint));
  139. recordModel.proteinMass = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:proteinMassInt bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  140. }else{
  141. recordModel.proteinMass = @"";
  142. }
  143. //体脂-右手
  144. if (bodyResultTwoLegs.htBodyfatKgRightArm >0) {
  145. NSUInteger rightHand = roundf(bodyResultTwoLegs.htBodyfatKgRightArm*pow(10, dataModel.weightPoint));
  146. recordModel.fatMassRightTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  147. }else{
  148. recordModel.fatMassRightTop = @"";
  149. }
  150. //体脂-右脚
  151. if (bodyResultTwoLegs.htBodyfatKgRightLeg >0) {
  152. NSUInteger rightFoot = roundf(bodyResultTwoLegs.htBodyfatKgRightLeg*pow(10, dataModel.weightPoint));
  153. recordModel.fatMassRightBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  154. }else{
  155. recordModel.fatMassRightBottom = @"";
  156. }
  157. //体脂-左手
  158. if (bodyResultTwoLegs.htBodyfatKgLeftArm >0) {
  159. NSUInteger leftHand = roundf(bodyResultTwoLegs.htBodyfatKgLeftArm*pow(10, dataModel.weightPoint));
  160. recordModel.fatMassLeftTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  161. }else{
  162. recordModel.fatMassLeftTop = @"";
  163. }
  164. //体脂-左脚
  165. if (bodyResultTwoLegs.htBodyfatKgLeftLeg >0) {
  166. NSUInteger leftFoot = roundf(bodyResultTwoLegs.htBodyfatKgLeftLeg*pow(10, dataModel.weightPoint));
  167. recordModel.fatMassLeftBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  168. }else{
  169. recordModel.fatMassLeftBottom = @"";
  170. }
  171. //体脂-躯干
  172. if (bodyResultTwoLegs.htBodyfatKgTrunk >0) {
  173. NSUInteger fatMassBody = roundf(bodyResultTwoLegs.htBodyfatKgTrunk*pow(10, dataModel.weightPoint));
  174. recordModel.fatMassBody = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:fatMassBody bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  175. }else{
  176. recordModel.fatMassBody = @"";
  177. }
  178. //肌肉-右手
  179. if (bodyResultTwoLegs.htMuscleKgRightArm >0) {
  180. NSUInteger rightHand = roundf(bodyResultTwoLegs.htMuscleKgRightArm*pow(10, dataModel.weightPoint));
  181. recordModel.musleMassRightTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  182. }else{
  183. recordModel.musleMassRightTop = @"";
  184. }
  185. //肌肉-右脚
  186. if (bodyResultTwoLegs.htMuscleKgRightLeg >0) {
  187. NSUInteger rightFoot = roundf(bodyResultTwoLegs.htMuscleKgRightLeg*pow(10, dataModel.weightPoint));
  188. recordModel.musleMassRightBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  189. }else{
  190. recordModel.musleMassRightBottom = @"";
  191. }
  192. //肌肉-左手
  193. if (bodyResultTwoLegs.htMuscleKgLeftArm >0) {
  194. NSUInteger leftHand = roundf(bodyResultTwoLegs.htMuscleKgLeftArm*pow(10, dataModel.weightPoint));
  195. recordModel.musleMassLeftTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  196. }else{
  197. recordModel.musleMassLeftTop = @"";
  198. }
  199. //肌肉-左脚
  200. if (bodyResultTwoLegs.htMuscleKgeLeftLeg >0) {
  201. NSUInteger leftFoot = roundf(bodyResultTwoLegs.htMuscleKgeLeftLeg*pow(10, dataModel.weightPoint));
  202. recordModel.musleMassLeftBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  203. }else{
  204. recordModel.musleMassLeftBottom = @"";
  205. }
  206. //肌肉-躯干
  207. if (bodyResultTwoLegs.htMuscleKgTrunk >0) {
  208. NSUInteger muscleMassBody = roundf(bodyResultTwoLegs.htMuscleKgTrunk*pow(10, dataModel.weightPoint));
  209. recordModel.musleMassBody = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:muscleMassBody bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  210. }else{
  211. recordModel.musleMassBody = @"";
  212. }
  213. //四肢肌肉指数 = 四肢肌肉量(kg)/身高的平方(m)
  214. CGFloat heightM = (height/100.0);
  215. CGFloat index = (bodyResultTwoLegs.htMuscleKgLeftArm+bodyResultTwoLegs.htMuscleKgeLeftLeg+bodyResultTwoLegs.htMuscleKgRightArm+bodyResultTwoLegs.htMuscleKgRightLeg)/(heightM*heightM);
  216. recordModel.musleMassLimbs = [NSString stringWithFormat:@"%.1f",index];
  217. return recordModel;
  218. }
  219. #pragma mark - 新算法
  220. +(void)new_algorithmOfHTWithDataModel:(ELEightScaleBleDataModel *)dataModel sex:(BhSexType)sex height:(CGFloat)height kgWeight:(CGFloat)kgWeight age:(NSInteger)age updateRecordModel:(ELEightScaleRecordModel *)recordModel {
  221. #if TARGET_IPHONE_SIMULATOR == 0
  222. //HT算法
  223. BhSexType htSex = sex;
  224. BhBodyCompositionAllBody50KHz *bodyCompositon = [[BhBodyCompositionAllBody50KHz alloc] init];
  225. bodyCompositon.bhSex = htSex;
  226. bodyCompositon.bhPeopleType = BH_PEOPLE_TYPE_NORMAL;
  227. bodyCompositon.bhHeightCm = height;
  228. bodyCompositon.bhWeightKg = kgWeight;
  229. bodyCompositon.bhAge = (int)age;
  230. bodyCompositon.bhZLeftArmEnCode = dataModel.leftHandAdc;
  231. bodyCompositon.bhZRightArmEnCode = dataModel.rightHandAdc;
  232. bodyCompositon.bhZLeftLegEnCode = dataModel.leftFootAdc;
  233. bodyCompositon.bhZRightLegEnCode = dataModel.rightFootAdc;
  234. bodyCompositon.bhZLeftBodyEnCode = dataModel.RWholeBodyAdc;
  235. BhErrorType errType = [bodyCompositon getBhBodyCompositionAllBody50KHz];
  236. NSLog(@"errType(不为0就有问题) = %zd",errType);
  237. //显示体脂参数
  238. recordModel.bmi = [NSString stringWithFormat:@"%.1f",bodyCompositon.bhBMI];
  239. recordModel.bfr = [NSString stringWithFormat:@"%.1f",bodyCompositon.bhBodyFatRate];
  240. recordModel.sfr = [NSString stringWithFormat:@"%.1f",bodyCompositon.bhBodyFatSubCutRate];
  241. recordModel.uvi = [NSString stringWithFormat:@"%u",bodyCompositon.bhVFAL];
  242. recordModel.rom = [NSString stringWithFormat:@"%.1f",bodyCompositon.bhMuscleRate];
  243. recordModel.bmr = [NSString stringWithFormat:@"%u",bodyCompositon.bhBMR];
  244. recordModel.vwc = [NSString stringWithFormat:@"%.1f",bodyCompositon.bhWaterRate];
  245. recordModel.bodyAge = [NSString stringWithFormat:@"%u",bodyCompositon.bhBodyAge];
  246. recordModel.pp = [NSString stringWithFormat:@"%.1f",bodyCompositon.bhProteinRate];
  247. recordModel.adc = [NSString stringWithFormat:@"%d",dataModel.trunkAdc];//记录躯干adc
  248. recordModel.heartRate = dataModel.heartRate>0?[NSString stringWithFormat:@"%d",dataModel.heartRate]:@"";
  249. recordModel.createTime = dataModel.createTime;
  250. recordModel.deviceAlgorithm = [NSString stringWithFormat:@"%d",dataModel.algorithmID];
  251. //骨量
  252. if (bodyCompositon.bhBoneKg>0) {
  253. NSUInteger boneMass = roundf(bodyCompositon.bhBoneKg*pow(10, dataModel.weightPoint));
  254. recordModel.bm = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:boneMass bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  255. }else{
  256. recordModel.bm = @"";
  257. }
  258. //标准体重
  259. if (bodyCompositon.bhIdealWeightKg >0) {
  260. //说明有值
  261. NSUInteger standard = roundf(bodyCompositon.bhIdealWeightKg*pow(10, dataModel.weightPoint));
  262. recordModel.standardWeight = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:standard bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  263. //体重控制量
  264. CGFloat weightControl = kgWeight - bodyCompositon.bhIdealWeightKg;
  265. NSUInteger weightContrlABS = roundf(fabs(weightControl*pow(10, dataModel.weightPoint)));
  266. NSString *weightContrlStr = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:weightContrlABS bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  267. if (weightControl<0) {
  268. recordModel.weightControl = [NSString stringWithFormat:@"-%@",weightContrlStr];
  269. }else{
  270. recordModel.weightControl = weightContrlStr;
  271. }
  272. recordModel.fatLevel = [NSString stringWithFormat:@"%lu",(unsigned long)[ELBodyIndexAlgorithmModel getfatLevelWithweight:kgWeight andStandardWeight:bodyCompositon.bhIdealWeightKg]];
  273. }else{
  274. recordModel.standardWeight = @"";
  275. recordModel.weightControl = @"";
  276. recordModel.fatLevel = @"";
  277. }
  278. //脂肪量
  279. if (bodyCompositon.bhBodyFatKg>0) {
  280. NSLog(@"---和泰脂肪量:%f",bodyCompositon.bhBodyFatKg);
  281. NSUInteger fatMass = roundf(bodyCompositon.bhBodyFatKg*pow(10, dataModel.weightPoint));
  282. recordModel.fatMass = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:fatMass bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  283. }else{
  284. recordModel.fatMass = @"";
  285. }
  286. //去脂体重
  287. if (bodyCompositon.bhBodyFatFreeMassKg>0) {
  288. NSUInteger withoutFatW = roundf(bodyCompositon.bhBodyFatFreeMassKg*pow(10, dataModel.weightPoint));
  289. recordModel.weightWithoutFat = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:withoutFatW bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  290. }else{
  291. recordModel.weightWithoutFat = @"";
  292. }
  293. //肌肉量
  294. if (bodyCompositon.bhMuscleKg>0) {
  295. NSLog(@"---和泰脂肪量:%f",bodyCompositon.bhMuscleKg);
  296. NSInteger musleMass = round(bodyCompositon.bhMuscleKg*pow(10, dataModel.weightPoint));
  297. recordModel.musleMass = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:musleMass bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  298. }else{
  299. recordModel.musleMass = @"";
  300. }
  301. //蛋白量
  302. if (bodyCompositon.bhProteinRate>0) {
  303. NSUInteger proteinMassInt = roundf((bodyCompositon.bhProteinRate/100.0)*kgWeight* pow(10, dataModel.weightPoint));
  304. recordModel.proteinMass = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:proteinMassInt bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  305. }else{
  306. recordModel.proteinMass = @"";
  307. }
  308. //体脂-右手
  309. if (bodyCompositon.bhBodyFatKgRightArm >0) {
  310. NSUInteger rightHand = roundf(bodyCompositon.bhBodyFatKgRightArm*pow(10, dataModel.weightPoint));
  311. recordModel.fatMassRightTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  312. }else{
  313. recordModel.fatMassRightTop = @"";
  314. }
  315. //体脂-右脚
  316. if (bodyCompositon.bhBodyFatKgRightLeg >0) {
  317. NSUInteger rightFoot = roundf(bodyCompositon.bhBodyFatKgRightLeg*pow(10, dataModel.weightPoint));
  318. recordModel.fatMassRightBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  319. }else{
  320. recordModel.fatMassRightBottom = @"";
  321. }
  322. //体脂-左手
  323. if (bodyCompositon.bhBodyFatKgLeftArm >0) {
  324. NSUInteger leftHand = roundf(bodyCompositon.bhBodyFatKgLeftArm*pow(10, dataModel.weightPoint));
  325. recordModel.fatMassLeftTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  326. }else{
  327. recordModel.fatMassLeftTop = @"";
  328. }
  329. //体脂-左脚
  330. if (bodyCompositon.bhBodyFatKgLeftLeg >0) {
  331. NSUInteger leftFoot = roundf(bodyCompositon.bhBodyFatKgLeftLeg*pow(10, dataModel.weightPoint));
  332. recordModel.fatMassLeftBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  333. }else{
  334. recordModel.fatMassLeftBottom = @"";
  335. }
  336. //体脂-躯干
  337. if (bodyCompositon.bhBodyFatKgTrunk >0) {
  338. NSUInteger fatMassBody = roundf(bodyCompositon.bhBodyFatKgTrunk*pow(10, dataModel.weightPoint));
  339. recordModel.fatMassBody = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:fatMassBody bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  340. }else{
  341. recordModel.fatMassBody = @"";
  342. }
  343. //肌肉-右手
  344. if (bodyCompositon.bhMuscleKgRightArm >0) {
  345. NSUInteger rightHand = roundf(bodyCompositon.bhMuscleKgRightArm*pow(10, dataModel.weightPoint));
  346. recordModel.musleMassRightTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  347. }else{
  348. recordModel.musleMassRightTop = @"";
  349. }
  350. //肌肉-右脚
  351. if (bodyCompositon.bhMuscleKgRightLeg >0) {
  352. NSUInteger rightFoot = roundf(bodyCompositon.bhMuscleKgRightLeg*pow(10, dataModel.weightPoint));
  353. recordModel.musleMassRightBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:rightFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  354. }else{
  355. recordModel.musleMassRightBottom = @"";
  356. }
  357. //肌肉-左手
  358. if (bodyCompositon.bhMuscleKgLeftArm >0) {
  359. NSUInteger leftHand = roundf(bodyCompositon.bhMuscleKgLeftArm*pow(10, dataModel.weightPoint));
  360. recordModel.musleMassLeftTop = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftHand bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  361. }else{
  362. recordModel.musleMassLeftTop = @"";
  363. }
  364. //肌肉-左脚
  365. if (bodyCompositon.bhMuscleKgLeftLeg >0) {
  366. NSUInteger leftFoot = roundf(bodyCompositon.bhMuscleKgLeftLeg*pow(10, dataModel.weightPoint));
  367. recordModel.musleMassLeftBottom = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:leftFoot bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  368. }else{
  369. recordModel.musleMassLeftBottom = @"";
  370. }
  371. //肌肉-躯干
  372. if (bodyCompositon.bhMuscleKgTrunk >0) {
  373. NSUInteger muscleMassBody = roundf(bodyCompositon.bhMuscleKgTrunk*pow(10, dataModel.weightPoint));
  374. recordModel.musleMassBody = [ELWeightAlgorithmusModel getWeightShowStrWithTargetUnit:dataModel.weightUnit bleWeightInt:muscleMassBody bleWeightUnit:(ELDeviceWeightUnit_KG) bleWeightPoint:dataModel.weightPoint];
  375. }else{
  376. recordModel.musleMassBody = @"";
  377. }
  378. //四肢肌肉指数 = 四肢肌肉量(kg)/身高的平方(m)
  379. CGFloat heightM = (height/100.0);
  380. CGFloat index = (bodyCompositon.bhMuscleKgLeftArm+bodyCompositon.bhMuscleKgLeftLeg+bodyCompositon.bhMuscleKgRightArm+bodyCompositon.bhMuscleKgRightLeg)/(heightM*heightM);
  381. recordModel.musleMassLimbs = [NSString stringWithFormat:@"%.1f",index];
  382. NSLog(@"八电极体脂:\n%@",recordModel);
  383. #endif
  384. }
  385. @end