明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1981|回复: 3

请各位高手帮菜鸟看看这段小程序

[复制链接]
发表于 2006-5-16 20:51:00 | 显示全部楼层 |阅读模式
这段小程序是用来画图的一部分,运行的时候没有错误,但就是没有正确结果
发表于 2006-5-16 22:47:00 | 显示全部楼层
程序呢?
 楼主| 发表于 2006-5-17 10:29:00 | 显示全部楼层

// bc2Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "bc1Dlg.h"
#include "bc2Dlg.h"
#include "bc3Dlg.h"

#include <string.h>
#include <aced.h>
#include <dbents.h>
#include <dbsymtb.h>
#include <dbgroup.h>
#include <dbapserv.h>
#include <math.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

double C,d,d0,d1,d2,h,D1,D2,t0,K,Fmax,Fmin,Flim,n,n1,n2,Lmax,Lmin,Llim,
       G,H,H0,A,t,L0;
char Fmaxs[20],Fmins[20],hs[20],D1s[20];
extern char a[20],b[20],c[20];

/////////////////////////////////////////////////////////////////////////////
// bc2Dlg dialog


bc2Dlg::bc2Dlg(CWnd* pParent /*=NULL*/)
 : CDialog(bc2Dlg::IDD, pParent)
{
 //{{AFX_DATA_INIT(bc2Dlg)
  // NOTE: the ClassWizard will add member initialization here
 //}}AFX_DATA_INIT
}


void bc2Dlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 //{{AFX_DATA_MAP(bc2Dlg)
 DDX_Control(pDX, IDC_EDIT4, m_D1);
 DDX_Control(pDX, IDC_EDIT3, m_h);
 DDX_Control(pDX, IDC_EDIT2, m_Fmin);
 DDX_Control(pDX, IDC_EDIT1, m_Fmax);
 //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(bc2Dlg, CDialog)
 //{{AFX_MSG_MAP(bc2Dlg)
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// bc2Dlg message handlers

BOOL bc2Dlg::OnInitDialog()
{
 CDialog::OnInitDialog();
 
 // TODO: Add extra initialization here
 
 return TRUE;  // return TRUE unless you set the focus to a control
               // EXCEPTION: OCX Property Pages should return FALSE
}

void bc2Dlg::OnOK()
{
 m_Fmax.GetWindowText(Fmaxs,20);
    m_Fmin.GetWindowText(Fmins,20);
 m_h.GetWindowText(hs,20);
 m_D1.GetWindowText(D1s,20);
   
 Fmax=atof((LPCTSTR)Fmaxs);
 Fmin=atof((LPCTSTR)Fmins);
 h=atof((LPCTSTR)hs);
 D1=atof((LPCTSTR)D1s);
 // TODO: Add extra validation here
 
 CDialog::OnOK();
//_______________________*************_______________________第一步确定D2和d;
C=6;
d1=D1/(C+1);
K=(4*C-1)/(4*C-4)+(0.615/C);
//_______*****________计算【t】许用切应力
if (b=="I类")
{if (c=="碳素弹簧钢丝GB4357") t0=570;/就是在这里把t0的值提不出来
   else if (c=="琴钢丝YB/Y5101") t0=740;
   else if (c=="弹簧用不锈钢丝YBD(T)11") t0=740;
   else if (c=="阀门有油淬火回火碳素弹簧钢丝YB/T5102") t0=740;
   else if (c=="油淬火回火碳素弹簧钢丝YB/T5103") t0=740;
   else if (c=="油淬火回火硅锰弹簧钢丝YB/T5104") t0=740;
   else if (c=="阀门有油淬火回火碳素硌硅弹簧钢丝YB/T5105") t0=710;
   else if (c=="阀门有油淬火回火硌钒弹簧钢丝YD/T5108") t0=710;}

if (b=="II类")
{  if(c=="碳素弹簧钢丝GB4357")  t0=455;
   if(c=="琴钢丝YB/Y5101")  t0=590;
   if(c=="弹簧用不锈钢丝YBD(T)11")  t0=590;
   if (c=="阀门有油淬火回火碳素弹簧钢丝YB/T5102")  t0=590;
   if (c=="油淬火回火碳素弹簧钢丝YB/T5103")  t0=590;
   if (c=="油淬火回火硅锰弹簧钢丝YB/T5104")  t0=590;
   if (c=="阀门有油淬火回火碳素硌硅弹簧钢丝YB/T5105")  t0=570;
   if (c=="阀门有油淬火回火硌钒弹簧钢丝YD/T5108")  t0=570;
}

if (b=="III类")
{if(c=="碳素弹簧钢丝GB4357")  t0=340;
   else if (c=="琴钢丝YB/Y5101")  t0=455;
   else if (c=="弹簧用不锈钢丝YBD(T)11")  t0=455;
   else if (c=="阀门有油淬火回火碳素弹簧钢丝YB/T5102")  t0=455;
   else if (c=="油淬火回火碳素弹簧钢丝YB/T5103")  t0=455;
   else if (c=="油淬火回火硅锰弹簧钢丝YB/T5104")  t0=455;
   else if (c=="阀门有油淬火回火碳素硌硅弹簧钢丝YB/T5105")  t0=430;
   else if (c=="阀门有油淬火回火硌钒弹簧钢丝YD/T5108")  t0=430;}
d2=1.6*sqrt(K*Fmax*C/t0);

for (C=6;d1-d2>0.5||d1-d2<(-0.5);C++)
{d1=D1/(C+1);d2=1.6*sqrt(K*Fmax*C/t0);}
d=d2;

    if( 0.10<d&&d<=0.12) d=0.12;
    else if  (0.12<d2&&d2<=0.14) d=0.14;
    else if  (0.14<d2&&d2<=0.16) d=0.16;
 else if  (0.16<d2&&d2<=0.20) d=0.20;
 else if  (0.20<d2&&d2<=0.25) d=0.25;

 else if  (0.25<d2&&d2<=0.30)d=0.30;
 else if  (0.30<d2&&d2<=0.35)d=0.35;
 else if  (0.35<d2&&d2<=0.40)d=0.40;
 else if  (0.40<d2&&d2<=0.45)d=0.45;
 else if  (0.45<d2&&d2<=0.50)d=0.50;
 else if  (0.50<d2&&d2<=0.60)d=0.60;
 else if  (0.60<d2&&d2<=0.70)d=0.70;
 else if  (0.70<d2&&d2<=0.80)d=0.80;
 else if  (0.80<d2&&d2<=0.90)d=0.90;
 else if  (0.90<d2&&d2<=1.00)d=1.00;
 else if  (1.00<d2&&d2<=1.20)d=1.20;
 else if  (1.20<d2&&d2<=1.60)d=1.60;

 else if  (1.60<d2&&d2<=2.00)d=2.00;
 else if  (2.00<d2&&d2<=2.50)d=2.50;
 else if  (2.50<d2&&d2<=3.00)d=3.00;
 else if  (3.00<d2&&d2<=3.50)d=3.50;
 else if  (3.50<d2&&d2<=4.00)d=4.00;

 else if  (4.00<d2&&d2<=4.50)d=4.50;
 else if  (4.50<d2&&d2<=5.00)d=5.00;
 else if  (5.00<d2&&d2<=6.00)d=6.00;
 else if  (6.00<d2&&d2<=8.00)d=8.00;
 else if  (8.00<d2&&d2<=10.0)d=10.0;
 else if  (10.0<d2&&d2<=12.0)d=12.0;
 else if  (12.0<d2&&d2<=16.0)d=16.0;

 else if  (16.0<d2&&d2<=20.0)d=20.0;
 else if  (20.0<d2&&d2<=25.0)d=25.0;
 else if  (25.0<d2&&d2<=30.0)d=30.0;
 else if  (30.0<d2&&d2<=35.0)d=35.0;
 else if  (35.0<d2&&d2<=40.0)d=40.0;
 else if  (40.0<d2&&d2<=45.0)d=45.0;

 else if (45.0<d2&&d2<=50.0) d=50.0;
 else if (50.0<d2&&d2<=60.0) d=60.0;
 else if (60.0<d2&&d2<=70.0) d=70.0;
 else if (70.0<d2&&d2<=80.0) d=80.0;
    else if (80.0<d2||d2<0.10)
  acedAlert("\n      错 误!\nd的值计算存在错误!!!\n请从新选择参数!");

 //____________**********___________ 确定有效工作圈数n
Lmax=Fmax*h/(Fmax-Fmin);
if (c=="碳素弹簧钢丝GB4357") G=79000;
if (c=="琴钢丝YB/Y5101") G=79000;
if (c=="弹簧用不锈钢丝YBD(T)11") G=71000;
if (c=="阀门有油淬火回火碳素弹簧钢丝YB/T5102") G=79000;

if (c=="油淬火回火碳素弹簧钢丝YB/T5103") G=79000;//就是在这里把G的值提不出if (c=="油淬火回火硅锰弹簧钢丝YB/T5104") G=79000;
if (c=="阀门有油淬火回火碳素硌硅弹簧钢丝YB/T5105") G=79000;
if (c=="阀门有油淬火回火硌钒弹簧钢丝YD/T5108") G=79000;

n1=(G*Lmax*d)/(8*Fmax*C*C*C);
if      (2<n1&&n1<=2.25) n=2.25;
else if (2.25<n1&&n1<=2.5) n=2.5;
else if (2.5<n1&&n1<=2.75) n=2.75;
else if (2.75<n1&&n1<=3) n=3;
else if (3<n1&&n1<=3.25) n=3.25;
else if (3.25<n1&&n1<=3.5) n=3.5;
else if (3.5<n1&&n1<=3.75) n=3.75;
else if (3.75<n1&&n1<=4) n=4;
else if (4<n1&&n1<=4.25) n=4.25;
else if (4.25<n1&&n1<=4.5) n=4.5;
else if (4.5<n1&&n1<=4.75) n=4.75;
else if (4.75<n1&&n1<=5) n=5;
else if (5<n1&&n1<=5.5) n=5.5;
else if (5.5<n1&&n1<=6) n=6;
else if (6<n1&&n1<=6.5) n=6.5;
else if (6.5<n1&&n1<=7) n=7;
else if (7<n1&&n1<=7.5) n=7.5;
else if (7.5<n1&&n1<=8) n=8;
else if (8<n1&&n1<=8.5) n=8.5;
else if (8.5<n1&&n1<=9) n=9;
else if (9<n1&&n1<=9.5) n=9.5;
else if (9.5<n1&&n1<=10) n=10;
else if (10<n1&&n1<=10.5) n=10.5;
else if (10.5<n1&&n1<=11.5) n=11.5;
else if (11.5<n1&&n1<=12.5) n=12.5;
else if (12.5<n1&&n1<=13.5) n=13.5;
else if (13.5<n1&&n1<=14.5) n=14.5;
else if (14.5<n1&&n1<=15) n=15;
else if (15<n1&&n1<=16) n=16;
else if (16<n1&&n1<=18) n=18;
else if (18<n1&&n1<=20) n=20;
else if (20<n1&&n1<=22) n=22;
else if (22<n1&&n1<=25) n=25;
else if (25<n1&&n1<=28) n=28;
else if (28<n1&&n1<=30) n=30;
else if (30<n1||n1<2)
  acedAlert("\n      错 误!\n弹簧圈数n的值计算存在错误!\n请从新选择参数!");

n2=n+2;//总圈数为n2,

//____________**********___________ 确定变形量Llin,Lmax,Lmin,和实际最小载荷Fmin

Flim=Fmax/0.8;
Llim=8*n*Flim*C*C*C/(G*d);

Lmax=8*n*Fmax*C*C*C/(G*d);
Lmin=Lmax-h;
Fmin=G*Lmin*d/(8*n*C*C*C);

//____________**********___________ 确定弹簧节距t,自由高度H,螺旋升角和簧丝展开长度L0
d0=0.1*d;//在F作用下相连两圈的间距
t=(d+Lmax)/(n+d0);//节距t
H=n*t+1.5*d;//自由高度
if (4<H&&H<=5) H=5;
else if (5<H&&H<=6) H0=6;
else if (6<H&&H<=7) H0=7;
else if (7<H&&H<=8) H0=8;
else if (8<H&&H<=9) H0=9;
else if (9<H&&H<=10) H0=10;
else if (10<H&&H<=11) H0=11;
else if (11<H&&H<=12) H0=12;
else if (12<H&&H<=13) H0=13;
else if (13<H&&H<=14) H0=14;
else if (14<H&&H<=15) H0=15;
else if (15<H&&H<=16) H0=16;
else if (16<H&&H<=17) H0=17;
else if (17<H&&H<=18) H0=18;
else if (18<H&&H<=19) H0=19;
else if (19<H&&H<=20) H0=20;
else if (20<H&&H<=22) H0=22;
else if (22<H&&H<=24) H0=24;
else if (24<H&&H<=26) H0=26;
else if (26<H&&H<=28) H0=28;
else if (28<H&&H<=30) H0=30;
else if (30<H&&H<=35) H0=35;
else if (32<H&&H<=35) H0=35;
else if (35<H&&H<=38) H0=38;
else if (38<H&&H<=40) H0=40;
else if (40<H&&H<=42) H0=42;
else if (42<H&&H<=45) H0=45;
else if (45<H&&H<=48) H0=48;
else if (48<H&&H<=50) H0=50;
else if (50<H&&H<=52) H0=52;
else if (52<H&&H<=55) H0=55;
else if (55<H&&H<=58) H0=58;
else if (58<H&&H<=60) H0=60;
else if (60<H&&H<=65) H0=65;
else if (65<H&&H<=70) H0=70;
else if (70<H&&H<=75) H0=75;
else if (75<H&&H<=80) H0=80;
else if (80<H&&H<=85) H0=85;
else if (85<H&&H<=90) H0=90;
else if (90<H&&H<=95) H0=95;
else if (95<H&&H<=100) H0=100;
else if (100<H&&H<=105) H0=105;
else if (105<H&&H<=110) H0=110;

else if (110<H&&H<=115) H0=115;
else if (115<H&&H<=120) H0=120;
else if (120<H&&H<=130) H0=130;
else if (130<H&&H<=140) H0=140;
else if (140<H&&H<=150) H0=150;
else if (150<H&&H<=160) H0=160;
else if (160<H&&H<=170) H0=170;
else if (170<H&&H<=180) H0=180;
else if (180<H&&H<=190) H0=190;
else if (190<H&&H<=200) H0=200;
else if (200<H&&H<=220) H0=220;
else if (220<H&&H<=240) H0=240;
else if (240<H&&H<=260) H0=260;
else if (260<H&&H<=280) H0=280;
else if (280<H&&H<=300) H0=300;
else if (300<H&&H<=320) H0=320;
else if (320<H&&H<=340) H0=340;
else if (340<H&&H<=360) H0=360;
else if (360<H&&H<=380) H0=380;
else if (380<H&&H<=400) H0=400;
else if (400<H&&H<=420) H0=420;
else if (420<H&&H<=450) H0=450;
else if (450<H&&H<=480) H0=480;
else if (480<H&&H<=500) H0=500;
else if (500<H&&H<=520) H0=520;
else if (520<H&&H<=550) H0=550;
else if (550<H&&H<=580) H0=580;
else if (580<H&&H<=600) H0=600;
else if (600<H&&H<=620) H0=620;
else if (620<H&&H<=650) H0=650;
else if (650<H&&H<=680) H0=680;
else if (680<H&&H<=700) H0=700;
else if (700<H&&H<=720) H0=720;
else if (720<H&&H<=750) H0=750;
else if (750<H&&H<=780) H0=780;
else if (780<H&&H<=800) H0=800;
else if (800<H&&H<=850) H0=850;

else if (850<H&&H<=900) H0=900;
else if (900<H&&H<=1000) H0=1000;
else if (1000<H||H<4)
  acedAlert("\n      错 误!\n弹簧自由高度的值计算存在错误!\n请从新选择参数!");

A=atan(t/(3.141592*D2));
L0=3.141592*D2*n2/cos(A);
//____________**********___________ 稳定性计算

 

 楼主| 发表于 2006-5-17 10:32:00 | 显示全部楼层

这是个做二维弹簧工作图的设计部分

画图部分已经做了,就等设计完成了

小菜鸟很急,请各位朋友帮忙

我的email:wangqingm@eyou.com

QQ:43556244

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-4-19 19:50 , Processed in 0.158569 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表