📄 global.~cp
字号:
{
if(bd.hq_mode==HQ_CPZ24){
if(which_j<1||which_j>16) {
char str[30];
sprintf(str,"find_kg_up_new():j=%d",which_j);
err(str);return false;
}
}else if(which_j<1||which_j>2) { err("find_kg_up_new()");return false; }
short ab_cnt=0;
for(int i=from;i<to;i++){
if(get_kk(which_j,i)>0) ab_cnt++;
else{
int tmp=get_high_bt(which_j,i-1,i-ab_cnt); // is i-1 not i,避免剪力为负而称不出
if( ab_cnt>14 && tmp>800 && tmp/ab_cnt>40 ){ //8,2000
dlt=ab_cnt;
retp=i;
return true;
}
ab_cnt=0;
}//else
}//for
return false;
}
bool __fastcall find_kg_down_new(int which_j,int from,int to,short& dlt,long& retp)
{
if(bd.hq_mode==HQ_CPZ24){
if(which_j<1||which_j>16) {
char str[30];
sprintf(str,"find_kg_down_new():j=%d",which_j);
err(str);return false;
}
}else if(which_j<1||which_j>2) { err("find_kg_down_new()");return false; }
short bl_cnt=0;
for(int i=from;i<to;i++){
if(get_kk(which_j,i)<0) bl_cnt++;
else{
int tmp=get_high_bt(which_j,i-bl_cnt,i-1); //is i-1 not i,避免剪力为负而称不出
if( bl_cnt>14 && tmp>800 && tmp/bl_cnt>40 ){ //8,2000
dlt=bl_cnt;
retp=i-bl_cnt;
return true;
}
bl_cnt=0;
}//else
}//for
return false;
}
int __fastcall find_kg_up(int which_j,int *ofst,int high_bt)
{
if(which_j<1||which_j>2) { err("find_kg_up()");return 0; }
int ret=0,ab_cnt=0;
for(int i=0;i<offset_buf;i++){
if(get_kk(which_j,i)>0) ab_cnt++;
else{
int tmp=get_high_bt(which_j,i-1,i-ab_cnt); //is i-1 not i,避免剪力为负而称不出
if( ab_cnt>KK_XX && tmp>high_bt ){ //data_jz(0,i)>ref &&
/* char msg[100];
sprintf(msg,"ab_cnt=%d tmp=%d",ab_cnt,tmp);
err(msg);*/
ret++;
ofst[ret]=i;
ab_cnt=0;
continue;
}
ab_cnt=0;
}//else
}//for
return ret;
}
int __fastcall find_kg_down(int which_j,int *ofst,int high_bt)
{
if(which_j<1||which_j>2) { err("find_kg_down()");return 0; }
int ret=0,bl_cnt=0;
for(int i=0;i<offset_buf;i++){
if(get_kk(which_j,i)<0) bl_cnt++;
else{
int tmp=get_high_bt(which_j,i-bl_cnt,i-1);// is i-1 not i,避免剪力为负而称不出
if( bl_cnt>KK_XX && tmp>high_bt ){ //data_jz(0,i)>ref &&
/*
char msg[100];
sprintf(msg,"bl_cnt=%d tmp=%d",bl_cnt,tmp);
err(msg);*/
ret++;
ofst[ret]=i-bl_cnt;
bl_cnt=0;
continue;
}
bl_cnt=0;
}//else
}//for
return ret;
}
void err(char *msg)
{
if(bd.use_status==USE_TS){
Application->MessageBox( msg, " ", MB_OK);
}
}
int __fastcall findminy(int total_ce,int total_tan, int ce,int yn,mm_cpz* m)
{
int min=0; // 第几趟 is miny
for(int i=0;i<total_tan;i++){
if(m[i*total_ce+ce].y[yn]<m[min*total_ce+ce].y[yn]) min=i;
}
return min*total_ce+ce;
}
int __fastcall findmaxy(int total_ce,int total_tan, int ce,int yn,mm_cpz* m)
{
int max=0; // 第几趟 is maxy
for(int i=0;i<total_tan;i++){
if(m[i*total_ce+ce].y[yn]>m[max*total_ce+ce].y[yn]) max=i;
}
return max*total_ce+ce;
}
int __fastcall findminpzc(int total_ce,int total_tan, int ce,mm_cpz* m)
{
int min=0; // 第几趟 is minpzc
for(int i=0;i<total_tan;i++){
if(m[i*total_ce+ce].pzc<m[min*total_ce+ce].pzc) min=i;
}
return min*total_ce+ce;
}
int __fastcall findmaxpzc(int total_ce,int total_tan, int ce,mm_cpz* m)
{
int max=0; // 第几趟 is maxpzc
for(int i=0;i<total_tan;i++){
if(m[i*total_ce+ce].pzc>m[max*total_ce+ce].pzc) max=i;
}
return max*total_ce+ce;
}
int __fastcall findminwei(int total_ce,int total_tan, int ce,mm_cpz* m)
{
int min=0; // 第几趟 is minwei
for(int i=0;i<total_tan;i++){
if(m[i*total_ce+ce].wei<m[min*total_ce+ce].wei) min=i;
}
return min*total_ce+ce;
}
int __fastcall findmaxwei(int total_ce,int total_tan, int ce,mm_cpz* m)
{
int max=0; // 第几趟 is maxwei
for(int i=0;i<total_tan;i++){
if(m[i*total_ce+ce].wei>m[max*total_ce+ce].wei) max=i;
}
return max*total_ce+ce;
}
void __fastcall get_date(int year,int month,int day,int dlt,char *y,char *m,char *d)
{
TDateTime datetime=TDateTime((unsigned short)year,(unsigned short)month,(unsigned short)day)+dlt;
unsigned short yy, mm, dd;
datetime.DecodeDate(&yy,&mm,&dd);
if(y!=NULL) sprintf(y,"%04d",yy);
if(m!=NULL) sprintf(m,"%02d",mm);
if(d!=NULL) sprintf(d,"%02d",dd);
}
long __fastcall filesize(char *filename)
{
long length;
FILE *fp;
if((fp=fopen(filename,"rb"))==NULL){return 0;}
fseek(fp, 0L, SEEK_END);
length = ftell(fp);
fclose(fp);
return length;
}
bool __fastcall read_cpz_data(char *file,int cnt,long* cnt_lr,long* cnt_rl,_cpz_data *cpz_data)
{
FILE *fp;
if(filesize(file)==0 ){
//err("read_cpz_data:filesize=0");
return false;
}
if((fp=fopen(file,"rb"))==NULL){err("read_cpz_data:open failed");return false;}
fread(cnt_lr,sizeof(long),5,fp);
fread(cnt_rl,sizeof(long),5,fp);
for(int i=0;i<cnt;i++){
fread(cpz_data+i,sizeof(_cpz_data),1,fp);
}
fclose(fp);
return true;
}
void __fastcall write_cpz_data(int cnt,long* cnt_lr,long* cnt_rl,_cpz_data *cpz_data)
{
FILE *fp;
if((fp=fopen(CPZDATA,"wb"))==NULL){err("write_cpz_data:open file failed");return;}
fwrite(cnt_lr,sizeof(long),5,fp);
fwrite(cnt_rl,sizeof(long),5,fp);
for(int i=0;i<cnt;i++){
fwrite(cpz_data+i,sizeof(_cpz_data),1,fp);
}
fclose(fp);
}
void __fastcall copyfile(char *from,char *to)
{
if(!FileExists(from))return;
ifstream infile(from,ios_base::binary);
ofstream outfile(to, ios_base::binary);
if(!infile){ err("copyfile:infile failed");return;}
if(!outfile){ err("copyfile:outfile failed");return;}
char ch;
while(infile.get(ch)) outfile.put(ch);
}
void __fastcall create_file(const char* filename)
{
ofstream outfile(filename, ios_base::binary);
}
String __fastcall ftos(Extended value, int precision, int digits)
{
return FloatToStrF(value,ffFixed,precision,digits);
}
void __fastcall set_port_address()
{
// YH_PW,YH_WG129,YH_WG132 与众不同,为与dos兼容
if(bd.yh_mode==YH_PW || bd.yh_mode==YH_WG129 || bd.yh_mode==YH_WG132){
struct_port.port_w1=0x273;
struct_port.port_w2=0;
struct_port.port_s1=0x270;
struct_port.port_s2=0;
struct_port.port_st=0x275;
struct_port.port_kg=0x278;
return;
}
if(bd.hq_mode==HQ_2J1Z){
struct_port.port_w1=0x270; struct_port.port_s1=0x274;
struct_port.port_w2=0; struct_port.port_s2=0x276;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_DG){ //断轨
struct_port.port_w1=0x270;
if(bd.fx) struct_port.port_w2=0x272;// 重力两个通道判方向
else struct_port.port_w2=0;
struct_port.port_s1=0;
struct_port.port_s2=0;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_BDG){ //不断轨
struct_port.port_w1=0x270;
if(bd.fx) struct_port.port_w2=0x272;
else struct_port.port_w2=0;
struct_port.port_s1=0x274;
struct_port.port_s2=0;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_CPZ){ //超偏载不断轨
struct_port.port_w1=0x270; struct_port.port_s1=0x274;
struct_port.port_w2=0x272; struct_port.port_s2=0x276;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_STMDG){ //双台面断轨
struct_port.port_w1=0x270; struct_port.port_s1=0;
struct_port.port_w2=0x272; struct_port.port_s2=0;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_STMBDG){ //双台面不断轨
struct_port.port_w1=0x270; struct_port.port_s1=0x274;
struct_port.port_w2=0x272; struct_port.port_s2=0x276;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_NEWCPZ){ //新超偏载不断轨
struct_port.port_w1=0x270; struct_port.port_s1=0x272;
struct_port.port_w2=0x310; struct_port.port_s2=0x312;
struct_port.port_w3=0x274; struct_port.port_s3=0x276;
struct_port.port_w4=0x314; struct_port.port_s4=0x316;
struct_port.port_s5=0x27a;
struct_port.port_s6=0x27c;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_BDG3){ //云南3台面
struct_port.port_w1=0x27a; struct_port.port_s1=0x274;
struct_port.port_w2=0x27c; struct_port.port_s2=0x276;
struct_port.port_w3=0x270; struct_port.port_s3=0x272;
struct_port.port_st=0x279;
struct_port.port_kg=0x278;
}else if(bd.hq_mode == HQ_CPZ24){ //超偏载不断轨24
struct_port.port_w1=0x7f4;
struct_port.port_w2=0x7c4;
struct_port.port_w3=0x7f0;
struct_port.port_w4=0x7c0;
struct_port.port_w5=0x7e4;
struct_port.port_w6=0x7d4;
struct_port.port_w7=0x7e0;
struct_port.port_w8=0x7d0;
struct_port.port_s1=0x7f8;
struct_port.port_s2=0x7c8;
struct_port.port_s3=0x7f6;
struct_port.port_s4=0x7c6;
struct_port.port_s5=0x7f2;
struct_port.port_s6=0x7c2;
struct_port.port_s7=0x7e6;
struct_port.port_s8=0x7d6;
struct_port.port_s9=0x7e2;
struct_port.port_s10=0x7d2;
/*
wb4(w2) wb3(w4) wb2(w6) wb1(w8)
7c4 7c0 7d4 7d0
----0-----------0-----------0-----------0-----------0------
sb5(s2) sb4(s4) sb3(s6) sb2(s8) sb1(s10)
7c8 7c6 7c2 7d6 7d2
wa4(w1) wa3(w3) wa2(w5) wa1(w7)
7f4 7f0 7e4 7e0
----0-----------0-----------0-----------0-----------0------
sa5(s1) sa4(s3) sa3(s5) sa2(s7) sa1(s9)
7f8 7f6 7f2 7e6 7e2
---------
| 控制死 |
---------
*/
struct_port.port_st=0x7fb;
struct_port.port_st2=0x7eb;
struct_port.port_st3=0x7cb;
struct_port.port_st4=0x7db;
}else if(bd.hq_mode == HQ_NEWBDG){
struct_port.port_w1=0x270;
struct_port.port_w2=0x272;
struct_port.port_s1=0x274;
struct_port.port_s2=0x276;
struct_port.port_s3=0x27A;
struct_port.port_st=0x279;
/*
----0------------------0------------------0------
S1 W1 S2 W2 S3
274 270 276 272 27A
----0------------------0------------------0------
---------
| 控制死 |
---------
*/
}else if(bd.hq_mode == HQ_CPZGZ){
struct_port.port_w2=0x7d0;
struct_port.port_w1=0x7e0;
struct_port.port_s3=0x7d6;
struct_port.port_s4=0x7d2;
struct_port.port_s1=0x7e6;
struct_port.port_s2=0x7e2;
struct_port.port_st=0x7db;
struct_port.port_st2=0x7eb;
/*
7d6 7d0 7d2
S1 W1 S2
----0------------------------------------0------
----0------------------------------------0------
S3 W2 S4
7e6 7e0 7e2
---------
| 控制死 |
---------
*/
}else{
err("set_port_address():error hq_mode");
}
}
int __fastcall get_version()
{
OSVERSIONINFO v; // version information
v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
GetVersionEx(&v);
return v.dwMajorVersion ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -