www.pudn.com > apdb2ndb.rar > atn_get_port.cc
#ifndef lint
static char copyright[] = "Copyright (C) FUJITSU LIMITED 2000" ;
static char id[] = "$Id: atn_get_port.cc,v 1.1 2001/02/13 11:47:35 JST rad1 Exp $" ;
#endif
/*
* $Log: atn_get_port.cc,v $
* Revision 1.1 2001/02/13 11:47:35 JST rad1
* *** empty log message ***
*
* Revision 1.2 2000/12/19 16:42:03 JST rad1
* 阪元(TSL)
* ・サフィックスの変換処理を修正
*
* $Com: 阪元(TSL)
* $Com: ・サフィックスの変換処理を修正
*/
// Convert Io Block and IO component to NDB-inst
//
//
#include "atn_inc.h"
ATN_FDEF atn_get_port(atn_com &com,
AirBlockInfo &BlockInfo,
AirPortInfo * &PortInfo,int &num_cports)
{
int rcode = 0;
int rc = 0;
// get component id and name
int64_t blockid = BlockInfo.get_blockid();
AirComponentInfo CompInfo;
// Get compInfo and ndb_compid from BlockInfo
CompInfo.clear();
int64_t compid = BlockInfo.get_componentid();
CompInfo.set_componentid(compid);
com.arch->component_search(CompInfo);
const char *compname = CompInfo.get_componentname();
#ifdef DEBUG
bool my_debug = false;
const char *tmp_blockname = BlockInfo.get_blockname();
if(strcmp(tmp_blockname,"Q063B")==0)
{
my_debug = true;
atn_global::atn_debug = true;
}
#endif
atn_debug(__FILE__,__LINE__,"=== enter atn_conv_to_iport\n");
atn_debug(__FILE__,__LINE__," componanr name (%s)\n",compname);
//
// Fase 1 : count # of compent port usig seq. read
//
AirSeq *seq_cport = NULL_PTR;
atn_init_seq_read(com,&seq_cport);
for(num_cports=0;;)
{
int num_array = 0;
AirComponentPortInfo *CompPortInfo = NULL_PTR;
int rc_get_cport =
seq_cport->
componentports_in_component(&CompPortInfo,num_array,
CompInfo);
if(rc_get_cport == AIR_R_NOEXIST)
{
#if 0
com.afm->message("atn0012",
AIR_MSG_CHR,"table","component",
AIR_MSG_END);
#endif
break;
}
if(rc_get_cport == AIR_R_NOMEM)
{
// Error Message : Program Error
// No Enough Memory
com.afm->message("atn0800",
AIR_MSG_CHR,"file",__FILE__,
AIR_MSG_INT,"line",__LINE__,AIR_MSG_END);
rcode = -1;
return rcode;
//goto exit_func;
}
#ifdef DEBUG
if(my_debug) {
cout << "1st !stage before sort\n";
cout << "FILE " << " " __FILE__ << " LINE = " <<__LINE__ << "\n";
cout << " cnum_ports = " << num_cports << " num_array = "
<< num_array << "\n";
}
#endif
if(num_array == 1)
{
num_cports++;
}
else
{
atn_sfx *sfx = new atn_sfx;
sfx->sort(CompPortInfo,num_array);
int num_of_sorted_rec = sfx->num_of_sorted_rec;
num_cports += num_of_sorted_rec;
#ifdef DEBUG
if(my_debug) {
cout << "1st !stage after sort\n";
cout << " FILE = " << " " __FILE__ << "LINE = " <<__LINE__ << "\n";
cout << " num_of_sorted_rec2 = " << num_of_sorted_rec;
cout << "\n";
}
#endif
delete sfx;
}
if(rc_get_cport == AIR_R_FINISH)
{
// end of io-componentport
break;
}
}
atn_debug(__FILE__,__LINE__," # of cports(%d)\n",num_cports);
// ninish of 1st fase ( count up coprt process )
if(seq_cport)
{
delete seq_cport;
seq_cport = NULL;
}
#ifdef DEBUG
if(my_debug) {
cout << __FILE__ " " << __LINE__ << '\n';
cout<< " blockname = "<< BlockInfo.get_blockname();
cout << "cum_cports " << num_cports;
cout << '\n';
}
#endif
//
// 2nd fase : Make up array of PortInfo
//
// Remark : PortInfo not to be delete bacause they will refered in
// atn_conv_to_net
try {
PortInfo = new AirPortInfo[num_cports];
}
catch(...) {
cout << "error\n";
}
for(int k=0;k
componentports_in_component(&CompPortInfo,num_array,
CompInfo);
if(rc_get_cport == AIR_R_NOEXIST)
{
#if 0
com.afm->message("atn0012",
AIR_MSG_CHR,"table","component",
AIR_MSG_END);
#endif
break;
}
if(rc_get_cport == AIR_R_NOMEM)
{
// Error Message : Program Error
// No Enough Memory
com.afm->message("atn0800",
AIR_MSG_CHR,"file",__FILE__,
AIR_MSG_INT,"line",__LINE__,AIR_MSG_END);
rcode = -1;
return rcode;
// goto exit_func;
}
#ifdef DEBUG
if(my_debug) {
cout << "2nd stage before sort\n";
cout <<" FILE = "<< " " __FILE__ << "LINE = " <<__LINE__ << "\n";
cout << " cnum_ports = " << num_cports << " num_array = "
<< num_array << "\n";
}
#endif
if(num_array == 1)
{
const char *cportname = CompPortInfo[0].get_componentportname();
const char *sfx = CompPortInfo[0].get_suffixname();
PortInfo[i].clear();
PortInfo[i].set_blockid(blockid);
PortInfo[i].set_blockname(blockname);
PortInfo[i].set_portname(cportname);
if(sfx) PortInfo[i].set_suffixname(sfx);
rc=com.arch->port_search(PortInfo[i]);
#ifdef DEBUG
if(my_debug) {
cout << __FILE__ << " " << __LINE__ << '\n';
cout << " i= " << i << "\n";
cout << "num_cports = " << num_cports << '\n' ;
cout << "blockname = " << blockname << "\n";
cout << "cportname = " << cportname << "\n";
}
#endif
i++;
}
else
{
atn_sfx *asfx = new atn_sfx;
asfx->sort(CompPortInfo,num_array);
int num_of_sorted_rec = asfx->num_of_sorted_rec;
#ifdef DEBUG
if(my_debug) {
cout << __FILE__ << " " << __LINE__ << '\n';
asfx->dump();
asfx->dump_after_sort();
cout << "\n";
}
#endif
for(int j = 0; j sorted_sfx_rec[j]==NULL_PTR) continue;
int idx = asfx->sorted_sfx_rec[j]->idx;
if(idx < 0) continue;
if(i+idx >= num_cports)
{
#ifdef DEBUG
if(my_debug) {
cout << __FILE__ << " " << __LINE__ << '\n';
cout << " idx = " << idx << "\n";
cout << " i= " << i << "\n";
cout << "j = " << j << "\n";
cout << "num_array = " << num_array << '\n' ;
cout << "num_cports = " << num_cports << '\n' ;
cout << "blockname = " << blockname << "\n";
}
#endif
cout << __FILE__ << " " << __LINE__ << "\n";
cout << "Program Error\n";
fflush(stdout);
exit(-1);
}
const char *cportname =
CompPortInfo[idx].get_componentportname();
const char *sfx = CompPortInfo[idx].get_suffixname();
PortInfo[i+idx].set_blockid(blockid);
PortInfo[i+idx].set_blockname(blockname);
PortInfo[i+idx].set_portname(cportname);
if(sfx) PortInfo[i+idx].set_suffixname(sfx);
rc=com.arch->port_search(PortInfo[i+idx]);
}
delete asfx;
i += num_of_sorted_rec;
}
if(rc_get_cport == AIR_R_FINISH)
// end of io-componentport
break;
}
if(seq_cport)
{
delete seq_cport;
seq_cport = NULL;
}
exit_func:
return rcode;
}