From 411c3d2e661c57334f83e6f86771bebb8ea08969 Mon Sep 17 00:00:00 2001 From: kyz Date: Tue, 27 Jan 2026 14:00:18 +0800 Subject: [PATCH] =?utf8?q?=E5=8E=8B=E5=8A=9B=E5=92=8C=E6=89=AD=E7=9F=A9?= =?utf8?q?=E6=8D=A2=E7=AE=97=EF=BC=8C=E5=90=AF=E7=94=A8=E4=B8=8A=E4=BD=8D?= =?utf8?q?=E6=9C=BA=E5=AF=BC=E5=85=A55=E6=AE=B5=E5=8F=82=E6=95=B0=E9=85=8D?= =?utf8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- QiDong/APP/src/model.c | 65 ++++++++++++++++++++++++++++++--------- QiDong/BSP/src/bsp_host.c | 16 +++++----- 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/QiDong/APP/src/model.c b/QiDong/APP/src/model.c index a12c581..24de236 100644 --- a/QiDong/APP/src/model.c +++ b/QiDong/APP/src/model.c @@ -148,30 +148,40 @@ float pressure_threshold( float pressure ) } #endif //TOR_RANGE_DEBUG -//Ť¾Ø»»Ëã³ÉѹÁ¦£¬°´²ÎÊý±í²éÕÒ×îСŤ¾Ø/ѹÁ¦ºÍ×î´óŤ¾ØÑ¹Á¦£¬½«ÊäÈë²ÎÊýŤ¾Ø»»Ëã³ÉѹÁ¦·µ»Ø -float tor_to_pressure(uint32_t tor) +// ÆøÑ¹µ½Å¤¾ØµÄת»»º¯Êý£¬ÓÃÓÚ±£´æÊý¾Ý¼Ç¼ʱ£¬½«µçÁ÷ת»»ÎªÅ¤¾Ø +int pressure_to_torque( float pressure ) { -#if TOR_RANGE_DEBUG - //Æô¶¯³å»÷µ÷ÊÔ¹¦ÄÜ - //¸ù¾ÝÊäÈëµÄŤ¾ØÖµ£¬²éÕÒ¶ÔӦѹÁ¦Öµ + SpannerType_t *spanner; + int torque = 0; int i; - float pressure = 0; + uint32_t pressure_mb = pressure * 1000; - if( tor < debg_tor_para[0].torque ) - return debg_tor_para[0].press; - else if( tor >= debg_tor_para[TORQUE_PARA_MUN-1].torque ) - return debg_tor_para[TORQUE_PARA_MUN-1].press; + spanner = &SpannerType[ModifyVarStructVar.fabricName-1]; - for( i = 1; i < TORQUE_PARA_MUN; i++) + //°´5µã²ÎÊý±í»»ËãµçÁ÷µ½Å¤¾Ø£¬ 2026/1/26 + //δ¿¼ÂǵµÎ»£¬»úеµµÎ»µÈÆäËüÒòËØ£¬ºóÃæ°´Êµ¼ÊÒªÇó¾ö¶¨ÈçºÎ´¦Àí + for(i=0; iWorkingMedium[i+1] || i == TORQUE_POINT_MUN-2) { - pressure = debg_tor_para[i-1].press + (debg_tor_para[i].press - debg_tor_para[i-1].press) * (tor - debg_tor_para[i-1].torque) / (debg_tor_para[i].torque - debg_tor_para[i-1].torque); + int wm_0, wm_1, tor_0, tor_1; + + wm_0 = spanner->WorkingMedium[i]; + wm_1 = spanner->WorkingMedium[i+1]; + tor_0 = spanner->TorqueDate[i]; + tor_1 = spanner->TorqueDate[i+1]; + + torque = tor_0 + (tor_1 - tor_0) * (pressure_mb - wm_0) / (wm_1 - wm_0); break; } } - return pressure; -#else + return torque; +} + +//Ť¾Ø»»Ëã³ÉѹÁ¦£¬°´²ÎÊý±í²éÕÒ×îСŤ¾Ø/ѹÁ¦ºÍ×î´óŤ¾ØÑ¹Á¦£¬½«ÊäÈë²ÎÊýŤ¾Ø»»Ëã³ÉѹÁ¦·µ»Ø +float tor_to_pressure(uint32_t tor) +{ +#if 0 //TOR_RANGE_DEBUG //ÊäÈëtor²ÎÊýÊÇN.m£¬·µ»ØÖµµ¥Î»ÊÇBar uint32_t tor_min, tor_max; @@ -208,7 +218,32 @@ float tor_to_pressure(uint32_t tor) return 0; return press_min + (press_max - press_min) * (tor - tor_min) / (tor_max - tor_min); +#else + float pressure = 0; + uint32_t WorkingMedium_value; + SpannerType_t *spanner; + int i; + + spanner = &SpannerType[ModifyVarStructVar.fabricName-1]; + //°´5µã²ÎÊý±í»»ËãŤ¾Øµ½ÆøÑ¹ + for(i=0; iTorqueDate[i+1] || i == TORQUE_POINT_MUN-2) + { + int wm_0, wm_1, tor_0, tor_1; + + wm_0 = spanner->WorkingMedium[i]; + wm_1 = spanner->WorkingMedium[i+1]; + tor_0 = spanner->TorqueDate[i]; + tor_1 = spanner->TorqueDate[i+1]; + + WorkingMedium_value = wm_0 + (wm_1 - wm_0) * (tor - tor_0) / (tor_1 - tor_0); + pressure = WorkingMedium_value / 1000.0; + break; + } + } + return pressure; #endif } /* diff --git a/QiDong/BSP/src/bsp_host.c b/QiDong/BSP/src/bsp_host.c index 6b4f43a..a94ccb8 100644 --- a/QiDong/BSP/src/bsp_host.c +++ b/QiDong/BSP/src/bsp_host.c @@ -1344,7 +1344,7 @@ void sendBasic_information() { buff[6] = 0x04; //Êý¾ÝÄÚÈÝ buff[7] = 0x00; //Ãû³Æ - buff[8] = 0x01; + buff[8] = 0x03; buff[9] = Version1; buff[10] = Version2; crc = GetCRC16(buff, 11); @@ -1699,14 +1699,16 @@ int handle_host_cmd( pkt_t *pkt ) n+=4; SpannerType[i].TorqueMinDate = PTR2U32(&pkt->data[n]); n+=4; + for (j = 0; j < TORQUE_POINT_MUN; j++) { - // ÉèÖÃÎåµã¶ÔӦŤ¾ØÖµ - SpannerType[i].TorqueDate[j] = PTR2U32(&pkt->data[n]); - n+=4; - // ÉèÖÃÎåµãŤ¾ØÖµ¶ÔÓ¦µÄµçÁ÷,ÆøÑ¹,ÓÍѹ - SpannerType[i].WorkingMedium[j] = PTR2U32(&pkt->data[n]); - n+=4; + //ÉÏλ»úµ¼ÈëµÄ²ÎÊý±íÐèÒª½«Å¤¾ØÖµ´ÓСµ½´ó°´Ë³ÐòÅÅÁУ¬ÕâÀï²»ÔÙ¼ì²éºÍÅÅÐò + // ÉèÖÃÎåµã¶ÔӦŤ¾ØÖµ + SpannerType[i].TorqueDate[j] = PTR2U32(&pkt->data[n]); + n+=4; + // ÉèÖÃÎåµãŤ¾ØÖµ¶ÔÓ¦µÄµçÁ÷,ÆøÑ¹,ÓÍѹ + SpannerType[i].WorkingMedium[j] = PTR2U32(&pkt->data[n]); + n+=4; } } SaveFlag[GearMem] = 1; //GearMem -- 2.34.1