www.pudn.com > apdb2ndb.rar > atn_conv_to_comp.cc
#ifndef lint
static char copyright[] = "Copyright (C) FUJITSU LIMITED 2000" ;
static char id[] = "$Id: atn_conv_to_comp.cc,v 1.5 2001/06/12 15:51:45 JST rad1 Exp $" ;
#endif
/*
* $Log: atn_conv_to_comp.cc,v $
* Revision 1.5 2001/06/12 15:51:45 JST rad1
* 阪本(TSL)
* 名前の先頭の\追加機能
*
* Revision 1.4 2001/02/07 15:54:27 JST rad1
* 阪本(TSL)
* ・一部処理を別ファイルとする
*
* Revision 1.3 2000/12/26 15:19:10 JST rad1
* 阪元(TSL)
* ・サフィックスの変換処理を修正
*
* Revision 1.2 2000/12/19 16:42:01 JST rad1
* 阪元(TSL)
* ・ポートのIO属性の設定の不具合を修正
* ・サフィックスの変換処理を修正
*
* $Com: 阪本(TSL)
* $Com: 名前の先頭の\追加機能
*/
//
// Convert Io Component and component to NDB component
//
//
#include "atn_inc.h"
static int atn_conv_to_cport(atn_com &,NDB_COMPID,AirComponentInfo &);
static NDB_COMPID atn_entry_comp(atn_com &com, AirComponentInfo &ComponentInfo);
// MSG OK
ATN_FDEF int atn_conv_to_comp(atn_com &com)
{
int rcode =0;
int rc = 0;
int rc_get_component;
NDB_COMPID ndb_compid;
AirComponentInfo ComponentInfo;
AirSeq *seq_comp = NULL_PTR;
//
// Initializatations of seq. read
//
atn_init_seq_read(com,&seq_comp);
for(;;)
{
rc_get_component = seq_comp->component_in_arch(ComponentInfo);
if(rc_get_component == AIR_R_NOEXIST)
{
// Error Message : User Error
// No io-component in archtecture
com.afm->message("atn0420",
AIR_MSG_CHR,"func","no compent in part",
AIR_MSG_CHR,"file",__FILE__,
AIR_MSG_INT,"line",__LINE__,AIR_MSG_END);
rcode = -1;
goto exit_func;
}
if(rc_get_component == 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;
goto exit_func;
}
const char *componentname = ComponentInfo.get_componentname();
int componentid = ComponentInfo.get_componentid();
int compid = ComponentInfo.get_componentid();
atn_debug(__FILE__,__LINE__,"=== INTERNAL COMPONENT ===\n");
atn_debug(__FILE__,__LINE__,
" componentid(%d) componentname<%s>\n",
(int)componentid,componentname);
if(strcmp(componentname,com.module_name)==0)
{
atn_debug(__FILE__,__LINE__," skip top component (%s)\n",
componentname);
goto end_of_1item;
}
ndb_compid = atn_entry_comp(com,ComponentInfo);
if(ndb_compid <= 0)
{
// message is issued in avobe function
rcode -1;
goto exit_func;
}
rc = atn_conv_to_cport(com,ndb_compid,ComponentInfo);
if(rc < 0)
{
// message is issued in avobe function
rcode -1;
goto exit_func;
}
ComponentInfo.clear();
end_of_1item:
if(rc_get_component == AIR_R_FINISH)
{
// end of icomponent
break;
}
}
exit_func:
if(seq_comp)
{
delete seq_comp;
seq_comp = NULL_PTR;
}
return rcode;
}
//
// convert apdb componetport to ndb cport
//
static int atn_conv_to_cport(atn_com &com,
NDB_COMPID ndb_compid,
AirComponentInfo &CompInfo)
{
int rcode =0;
int rc = 0;
int rc_get_componentport;
int go = 0;
const char *componentname = CompInfo.get_componentname();
int64_t compid = CompInfo.get_componentid();
NDB_CPORTID ndb_cportid;
int ndb_io_mode = 0;
AirComponentPortInfo *CompPortInfoPtr = NULL;
int num_array;
AirSeq *seq_cport = NULL_PTR;
atn_init_seq_read(com,&seq_cport);
for(;;)
{
int num_ports = 0;
rc_get_componentport =
seq_cport->componentports_in_component(
&CompPortInfoPtr,num_ports,
CompInfo);
AirComponentPortInfo &ComponentportInfo = *CompPortInfoPtr;
// check return code of sequential read of component
if(rc_get_componentport == AIR_R_NOEXIST)
{
// Error Message : User Error
// No io-componentport in archtecture
com.afm->message("atn0420",
AIR_MSG_CHR,"msg","no compent in part",
AIR_MSG_CHR,"file",__FILE__,
AIR_MSG_INT,"line",__LINE__,AIR_MSG_END);
rcode = -1;
goto exit_func;
}
if(rc_get_componentport == 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;
goto exit_func;
}
// get name etc. of port
const char *componentportname =
ComponentportInfo.get_componentportname();
int componentportid = ComponentportInfo.get_componentportid();
int compid = ComponentportInfo.get_componentid();
const char *sfx = ComponentportInfo.get_suffixname();
// get apdb io mode
int64_t io=-1;
rc = com.arch->componentport_get_info(ComponentportInfo,AIR_KEY_IO,io);
if(componentportname == NULL_PTR)
{
atn_debug(__FILE__,__LINE__,"internal error");
com.afm->message("atn0420",
AIR_MSG_CHR,"msg",__FILE__,
AIR_MSG_CHR,"file",__FILE__,
AIR_MSG_INT,"line",__LINE__,AIR_MSG_END);
rcode = -1;
return -1;
}
atn_debug(__FILE__,__LINE__,"=== COMPONENTPORT ===\n");
atn_debug(__FILE__,__LINE__,
" componentportid(%d) componentportname<%s> sfx(%s)\n",
(int)componentportid,componentportname,sfx?sfx:"");
NDB_RANGEINFO *rangeinfo=NULL_PTR;
// if sufix is spacified, create range info
if(sfx != NULL_PTR || num_ports > 1)
{
int left = 0;
int right = 0;
int dim = 1;
rc = atn_get_range_of_cport(com,CompPortInfoPtr,num_ports,left,right);
/* create range */
rangeinfo = ndb_create_range(com.part_cntl,com.mid,dim,
&left,&right);
if(rangeinfo == NULL_PTR)
{
{
atn_debug(__FILE__,__LINE__,"faulure to add component\n");
rcode = -1;
goto exit_func;
}
}
}
else
{
// port is not array
rangeinfo = NULL_PTR;
}
// convert apdb io mode to ndb io mode
ndb_io_mode = atn_conv_iomode(io);
// add component pote
/* 2001.5.23 */
char *ndb_name = atn_conv_to_ndb_name((char *)componentportname);
ndb_cportid = ndb_add_cport(com.part_cntl,com.mid,ndb_compid,
ndb_name,rangeinfo,ndb_io_mode);
/* 2001.5.23 */
if(ndb_name != componentportname) free(ndb_name);
atn_debug(__FILE__,__LINE__,
" result of ndb_add_component (%s) is (%d)\n",
componentportname,ndb_compid);
if(ndb_cportid <= 0)
{
atn_debug(__FILE__,__LINE__,"faulure to add component\n");
rcode = -1;
goto exit_func;
}
if(rangeinfo)
{
ndb_clear_range(com.part_cntl,com.mid,rangeinfo);
}
if(CompPortInfoPtr)
{
for(int i=0;imessage("atn0410",
AIR_MSG_CHR,"func","ndb_add_comp",
AIR_MSG_CHR,"file",__FILE__,
AIR_MSG_INT,"line",__LINE__,AIR_MSG_END);/* error */
}
if(name) free(name);
return compid;
}
//
//
//
static atn_get_left_and_right(atn_com &com,int num,int &left,int &right);
struct atn_s2i
{
bool digit;
char *sfx_name;
bool unused;
int val;
bool used;
};