| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 969 人关注过本帖
标题:怎样将下面的VC++程序转化成C++程序?
只看楼主 加入收藏
lanselixiang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-4-16
收藏
 问题点数:0 回复次数:0 
怎样将下面的VC++程序转化成C++程序?
PID控制算法程序:float CPidCtrl::Fuzzy(float e, float de, float d, float dd, float e0, float de0)
{
float nel,e1,e2,ndel, del,de2;
int ez=0, es=0, em=0, eb=0;
int dez=0,des=0,dem=0,deb=0;
float uez=0.,ues=0.,uem=0.,ueb=0.;
float udez=0.,udes=0.,udem=0.,udeb=0.;
float  suml=0.,sum2=0.,sum3=0.,sum4=0.,sum5=0.,sum6=0.,sum7=0.,sum8=0.,sum9=0.,Sum10=0.,sumll=0.,sum12=0.,sum13=0.,sum14=0.,suml5=0.,sum16=0.,sum=0.,c=0.,u=0. 0;
 ne1=(e0-d);
el=(e0+d) ;
e2= (e0+2*d);
ndel=(de0-dd);
del= (de0+dd);
de2= (de0+2*dd);
if (e<nel){ez=1;uez=1,;}
if (e>=nel&&e<e0){ez=1;es=1;uez=-1./d* (e-e0);ues=1./d*(e-nel);}
if (e>=e0&&e<el){es=1;em=1;ues=-1./d* (e-el);uem=1./d*(e-e0);}
if (e>=el&&e<e2){em=1;eb=1;uem=-1./d* (e-e2);ueb=1./d*(e-el);}
if (e>=e2) {eb=1;ueb=1.;}
if (de<ndel){dez=1;udez=1.;}
if(de>=ndel&&de<de0){dez=1;des=1;udez=-1./d*(de-de0);udes=1./d*(de-nde1);}
if(de>=de0&&de<de1){des=1;dem=1;udes=-1./d*(de-del);udem=1./d*(de-de0);}
if(de>=del&&de<de2){dem=1;deb=1;udem=-1./d*(de-de2);udeb=1./d*(de-del);}
if(de>=de2){deb=1;udeb=1.;}
if (ez&&dez) suml=(uez<udez?uez:udez)*B;
if (ez&&des) sum2=(uez<udes?uez:udes)*B;
if (ez&&dem) sum3=(uez<udem?uez:udem)*B;
if (ez&&deb) sum4=(uez<udeb?uez:udeb)*B;
if (em&&dez) sum5=(uem<udez?uem:udez)*B;
if (em&&des) sum6=(uem<udes?uem:udes)*B;
if (em&&dem) sum7=(uem<udem?uem:udem)*M;
if (em&&deb) sum8=(uem<udeb?uem:udeb)*M;
if (es&&dez) sum9=(ues<udez?ues:udez)*B;
if (es&&des) sum10=(ues<udes?ues:udes)*M;
if (es&&dem) sum11=(ues<udem?ues:udem)*M;
if (es&&deb) sum12=(ues<udeb?ues:udeb)*S;
if (eb&&dez) sum13=(ueb<udez?ueb:udez)*B;
if (eb&&des) sum14=(ueb<udes?ueb:udes)*B;
if (eb&&dem) sum15=(ueb<udem?ueb:udem)*M;
if (eb&&deb) sum16=(ueb<udeb?ueb:udeb)*M;
sum=suml+sum2+sum3+sum4+sum5+sum6+sum7+sum8+sum9+sum10+sumll+suml2+sum13+sum14+sum15+sum16;
u=(uez<udez?uez:udez)+
(uez<udes?uez:udes)+
(uez<udem?uez:udem)+
(uez<udeb?uez:udeb)+
(uem<udez?uem:udez)+
(uem<udes?uem:udes)+
(uem<udem?uem:udem)+
(uem<udeb?uem:udeb)+
(ues<udez?ues:udez)+
(ues<udes?ues:udes)+
(ues<udem?ues:udem)+
(ues<udeb?ues:udeb)+
(ueb<udez?ueb:udez)+
(ueb<udes?ueb:udes)+
(ueb<udem?ueb:udem)+
(ueb<udeb?ueb:udeb);
c=sum/u;
return (c);
}
void CPidCtrl::adapt()
{
dOldErrorl=dOldBrror;
dOldError=dError;
dError=m_sheding-m_input;
kp=FuzzyP(dError,dOldError-dError, 0.5,0.2,0.5,0.2);
ti=FuzzyI(dError,dOldError-dError, 0.5.0.2,0.5 0.2);
td=FuzzyD(dError,dOldError-dError, 0.5,0.2.0.5,0.2);
K=Fuzzy(dError,dOldError-dError, 1,1,0,0);
Wkp=wkp+kp*dError*ul*(2*dError-dOldError);
wki=wki+ti*dError*ul*(2*dError-dOldError);
wkd=wkd+td*dError*ul*(2*dError-dOldError);
uk=ul+K*(wkp*(dError-dOldError)+wki*dError+wkd*(dError-2*dOldError+dOldError1))/(abs(wki)+abs(wkp)+abs(wkd));
if(uk>100) uk=I00;
ul=uk;
m_output=uk;
if (m_output>=m_outsx)m_output=m_outsx;
if (m_output<=m_outxx)m_output=m_outxx;
}
{
if (COleControl::OnCreate(1pCreateStruct)==-1)
return-1
m_Button.Create(”参数“,WS_VISIBLE,rrctB,this,IDC_BUTTON);
m_szbutton.Create(”自动”,WS_VISIBLE,rrctC,this,IDC_BUTTON1);
m_zbutton.Create(”+“, WS_VISIBLE ,rectD,this,IDC_ BUTTON2);
m_fbutton.Create(“-“,WS_VISIBLE,rectE,this,IDC_BUTTON3);
m_zbutton.EnableWindow (false);
  m fbutton.EnableWindow(false);
return 0
}
if (COleControl::OnCreate(lpCreateStruct) == -1)
        return -1;
    // TODO: Add your specialized creation code here
    return 0;

请高手帮一下,感激不尽
搜索更多相关主题的帖子: float int nel deb 
2008-04-16 10:21
快速回复:怎样将下面的VC++程序转化成C++程序?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021411 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved