温度校准

This commit is contained in:
祝发冬 2022-05-23 18:08:51 +08:00
parent cee511f388
commit 723f284237
3 changed files with 34 additions and 27 deletions

View File

@ -142,7 +142,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
self.view.backgroundColor=COLOR_MIAN;
XuanduoTempratureCorrectView*tempView=[XuanduoTempratureCorrectView viewFromXib];
tempView.frame=CGRectMake(10, 10, 300, 150);
tempView.frame=CGRectMake(10, 100, 300, 150);
tempView.centerX=self.view.centerX;
tempView.layer.cornerRadius=10;
@ -167,7 +167,10 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
[self.view addSubview:label];
[self.tempView.cancelBtn addTarget:self action:@selector(cancelCorrect) forControlEvents:UIControlEventTouchUpInside];
[self.tempView.textField becomeFirstResponder];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [self.tempView.textField becomeFirstResponder];
// });
}
@ -181,7 +184,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
-(void)cancelCorrect
{
[self.tempView.textField resignFirstResponder];
[self correctTempCorrectModel:NO];
[self correctTempCorrectModel:YES];
}
- (void)sure {
[self.tempView.textField resignFirstResponder];
@ -349,24 +352,25 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
readModel.functionCode=@"15";
readModel.massagelegth=@"18";
NSString*deviation=@"01";//
if ([self.tempView.textField.text containsString:@"-"])
{
deviation=@"02";//
}
if (cancelCorrect)
{
deviation=@"00";
}
NSString*pureString=[self.tempView.textField.text stringByReplacingOccurrencesOfString:@"-" withString:@""];
pureString=[pureString stringByReplacingOccurrencesOfString:@"+" withString:@""];
pureString=[pureString stringByReplacingOccurrencesOfString:@"℃" withString:@""];
NSInteger delta= (NSInteger)(pureString.floatValue*10);
float delta= pureString.floatValue;
NSString*hex=[dataContorl leftAddZero:2 andStr:[dataContorl ToHex:delta]];
float mac=[dataContorl hexToTen:self.tempCorrectModel.realTemp];
NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@%@",readModel.description,@"0b",deviation,hex,@"00000000",@"0000"];
//float TPlabel=mac/10+(mac%10)*0.1;
float temp = mac/10.0+delta;
NSString*rightTemp =[dataContorl leftAddZero:4 andStr:[dataContorl ToHex:temp*10]];
if (cancelCorrect)
{
rightTemp=@"0000";
}
NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@",readModel.description,@"0b",rightTemp,@"00000000",@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];

View File

@ -20,7 +20,8 @@
-(void)awakeFromNib
{
[super awakeFromNib];
self.cancelBtn.titleLabel.font=[UIFont systemFontOfSize:15];
self.cancelBtn.layer.masksToBounds=YES;
self.cancelBtn.layer.cornerRadius=8;
self.correectTempLabel.layer.cornerRadius=8;
}

View File

@ -27,22 +27,25 @@
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eZR-Ff-N9f">
<rect key="frame" x="144" y="10" width="90" height="27"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="取消校准">
<backgroundConfiguration key="background" cornerRadius="5">
<color key="backgroundColor" red="0.0" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</backgroundConfiguration>
<color key="baseForegroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</buttonConfiguration>
<color key="backgroundColor" red="0.0" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="取消校准">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="探测温度" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lNj-YX-wf8">
<rect key="frame" x="10" y="160" width="100" height="30"/>
<rect key="frame" x="10" y="170" width="100" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="gqt-b1-bNn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2pv-Tc-pht">
<rect key="frame" x="174" y="160" width="60" height="30"/>
<rect key="frame" x="174" y="170" width="60" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="AGi-MS-Fiy"/>
</constraints>
@ -62,7 +65,7 @@
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="校准后温度" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wKE-qN-OPf">
<rect key="frame" x="74" y="160" width="100" height="30"/>
<rect key="frame" x="74" y="170" width="100" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -101,7 +104,6 @@
<constraint firstItem="Stf-9K-Vtb" firstAttribute="centerY" secondItem="2c8-dl-t76" secondAttribute="centerY" id="5Ir-kf-aph"/>
<constraint firstAttribute="trailing" secondItem="eZR-Ff-N9f" secondAttribute="trailing" constant="10" id="5ab-XC-dFT"/>
<constraint firstItem="lNj-YX-wf8" firstAttribute="leading" secondItem="eTc-I0-xrM" secondAttribute="leading" id="7vR-O8-blu"/>
<constraint firstItem="lNj-YX-wf8" firstAttribute="height" secondItem="eTc-I0-xrM" secondAttribute="height" id="8cN-BY-Je5"/>
<constraint firstItem="lNj-YX-wf8" firstAttribute="width" secondItem="eTc-I0-xrM" secondAttribute="width" id="FCX-r9-RmP"/>
<constraint firstItem="2pv-Tc-pht" firstAttribute="bottom" secondItem="lNj-YX-wf8" secondAttribute="bottom" id="IRp-dE-BfP"/>
<constraint firstItem="2pv-Tc-pht" firstAttribute="trailing" secondItem="eZR-Ff-N9f" secondAttribute="trailing" id="KCi-JG-Lj0"/>