|
楼主 |
发表于 2017-3-1 10:39:07
|
显示全部楼层
#define MAXV 500
#define VERTEX_MAX 800
#define MAXVALUE 32767
#define MAX_VERTAX_NUM 500
#define QUEUE_MAXSIZE 600
#define charLen 20
typedef struct
{
int Vertex[VERTEX_MAX];
double Edges[VERTEX_MAX][VERTEX_MAX];
int isMainLink[VERTEX_MAX][VERTEX_MAX];
int isTrav[VERTEX_MAX];
int VertexNum;
int EdgeNum;
int GraphType;
int isTwoEdges[VERTEX_MAX][VERTEX_MAX];
}MatrixGraph;
typedef struct Station{
char id[255];
char name[255];
char v[255];
struct Station *next;
}Station;
int rx_check(char *dv_name)
{
int ret, i, j;
MatrixGraph G;
struct Station *nSP,*Sp1,*SHead;
nSP = (struct Station*)malloc(sizeof(struct Station));
stationList=nSP;
SHead=nSP;
Sp1=nSP;
setstationCount() ;
struct Line *nLP,*Lp1,*Lhead;
nLP = (struct Line*)malloc(sizeof(struct Line));
lineList=nLP;
Lhead=nLP;
Lp1=nLP;
setLineCount();
for(i=0;i<lv_st_mod;i++)
{
float kvvl = 0.0; //最高电压等级
int hkv = -1;
if(hkv <0) continue;
float st_v = 0.0;
//找最大电压等级的母线
if((hkv > -1)&&(kv_mod[hkv].oo_kv_bus_fa > 0))
{
int _bptr = kv_mod[hkv].oo_kv_bus_fa;
do{
int _bus = oo_r_kv_bus_mod[_bptr].ichild;
//bus_mod.v_pre:母线电压量测值,v:电压估计值
if(bus_mod[_bus].v_pre >= st_v)
{
st_v = bus_mod[_bus].v_pre;
}
_bptr=oo_r_kv_bus_mod[_bptr].bptr;
}while(_bptr > -1);
}
if(st_v < 1.0 )//还有最高电压等级没有母线建模的厂站,added by sxr
{
st_v = bs_mod[kv_mod[hkv].ibs].v * kv_mod[hkv].nomvol;
}
//山东线路两端的厂站
if(st_mod[i].ibsl == 2) //不等于2就不定级了?
{
int st_class = 0;
if(kvvl >= 500) {st_class = 2;}
else if((kvvl < 500)&&(kvvl > 200))
{
st_class = 3;
}
else
{
continue;
}
int _st_x=-1;
int _st_y=-1;
/*
ret = find_st_xy(st_mod[i].name);
if(ret > -1)
{
_st_x = st_xy[ret].st_x;
_st_y = st_xy[ret].st_y;
}
*/
char _id[255];
sprintf(_id,"%ld",st_mod[i].id);
char _v[255];
sprintf(_v,"%.1f", st_v);
//============================================================================================
stationList=insert_StationList(stationList,_id,st_mod[i].name,_v);
stationCount++;
//end
printf("<station_data id=\"%d\" name=\"%s\" v=\"%.1f\"/>\n",
st_mod[i].id, st_mod[i].name, st_v);
st_mod[i].ibsl = 1;
}
}
Station *LHead3=stationList;
for(i=0;i<lv_ln_mod;i++)
{
int ist, zst;
ist = kv_mod[ln_mod[i].ikv].ist;
zst = kv_mod[ln_mod[i].zkv].ist;
if(ist == zst) continue;
int kv_type = find_kvvl(kv_mod[ln_mod[i].ikv].vl);
int ln_class = 0;
if(kv_mod[ln_mod[i].ikv].vl >= 500) {ln_class = 2;}
else if(kv_mod[ln_mod[i].ikv].vl >= 200 && kv_mod[ln_mod[i].ikv].vl < 300) {ln_class = 3;}
else {continue;}
int _st_xi=-1;
int _st_yi=-1;
int _st_xj=-1;
int _st_yj=-1;
if(ln_mod[i].iisland0 == 1)
{
char _id[255];
sprintf(_id,"%ld",ln_mod[i].id);
char i_id[255];
sprintf(i_id,"%ld",st_mod[ist].id);
char j_id[255];
sprintf(j_id,"%ld",st_mod[zst].id);
char vtype[255];
sprintf(vtype,"%d",kv_type);
char _class[255];
sprintf(_class,"%d",ln_class);
char _pi[255];
sprintf(_pi,"%.1f",ln_mod[i].pi_pre);
char _pz[255];
sprintf(_pz,"%.1f",ln_mod[i].pz_pre);
char _x[255];
sprintf(_x,"%f",ln_mod[i].x);
lineList=insert_LineList(lineList,_id,i_id,j_id,ln_mod[i].name,vtype,_class,_pi,_pz,_x);
LineCount++;
}
}
//GJ---------构造邻接矩阵-----------//
int staCount=getstationCount();
G.VertexNum=staCount;
G.EdgeNum =getLineCount();
//边赋值
Line *nP3 =lineList;
int linecount,dLineCount;
double delt_p = 0.0f;
do{
int stri_id=atoi(nP3->sti_id);
int strj_id=atoi(nP3->stj_id);
char* pi=nP3->pi;
if(strcmp(pi,"0.0") )
{
for(i=0;i<staCount;i++)
{
for(j=0;j<staCount;j++)
{
//if(strcmp(G.Vertex[i],stri_id)==0 && strcmp(G.Vertex[j],strj_id)==0)
if((G.Vertex[i]==stri_id)&&(G.Vertex[j]==strj_id))
{
if(G.Edges[i][j]== MAXVALUE)
{
//G.Edges[i][j]=1;
//G.Edges[j][i]=1;
delt_p = fabs(atof(nP3->pi)+atof(nP3->pz));
if(delt_p < 0.01)
{
G.Edges[j][i]=0.01;
G.Edges[i][j]=0.01;
}
else
{
G.Edges[j][i]=delt_p;
G.Edges[i][j]=delt_p;
}
}
else
{
G.isTwoEdges[i][j]=1;
G.isTwoEdges[j][i]=1;
dLineCount++;
}
linecount++;//linecount?
}
}
}
}
nP3=nP3->next;
}while(nP3!=Lhead ); //因为边的信息是反着排的
printf("LineCount is %d, dLineCount is %d. \n",linecount,dLineCount);
dyn_string_t m_LoopCircleStr=dyn_string_new(0);
CreateSpanningTree(&G,m_LoopCircleStr);
printf("环有:%s\n",m_LoopCircleStr->s);
//以先路id形式表示各个环路
//===============================================================================================后面还有很多行,省略了……
//end---------------//
free(nSP);
free(nLP);
free(loopHead);
free(loopTail);
nSP = NULL;
nLP = NULL;
loopHead = NULL;
loopTail = NULL;
return 1;
} |
|