本文整理汇总了C++中EVEN函数的典型用法代码示例。如果您正苦于以下问题:C++ EVEN函数的具体用法?C++ EVEN怎么用?C++ EVEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EVEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
pwr_tStatus sts;
char remote_address[40];
char remote_host_name[40];
rpvd_sMsg *msg;
rpvd_sMsgAny umsg;
rpvd_sMsgAny *rmsg;
int udp_port;
/* Read arguments */
if ( argc < 3) {
usage();
exit(0);
}
strcpy( remote_address, argv[1]);
strcpy( remote_host_name, argv[2]);
if ( argc >= 4) {
sts = sscanf( argv[3], "%d", &udp_port);
if ( sts != 1) {
usage();
exit(0);
}
}
else
udp_port = 3051;
sts = udp_Init( remote_address, remote_host_name, udp_port);
if ( EVEN(sts)) {
exit(0);
}
sts = gdh_Init( "remote_pvd_pwrsrv");
if ( EVEN(sts)) return sts;
umsg.Type = rpvd_eMsg_NodeUp;
umsg.Id = 0;
sts = udp_Request( (char *)&umsg, sizeof(umsg), (char **)&rmsg);
if ( ODD(sts) && sts != REM__TIMEOUT && ODD(rmsg->Status))
printf( "Link up\n");
for (;;) {
sts = udp_Receive( (char **)&msg, 5000);
if ( sts == REM__TIMEOUT) {
printf( "Alive\n");
}
else if ( ODD(sts)) {
switch ( msg->Any.Type) {
case rpvd_eMsg_Oid:
pwrsrv_Oid( &msg->Oid);
break;
case rpvd_eMsg_ObjectName:
pwrsrv_ObjectName( &msg->ObjectName);
break;
case rpvd_eMsg_ReadAttribute:
pwrsrv_ReadAttribute( &msg->ReadAttribute);
break;
case rpvd_eMsg_WriteAttribute:
pwrsrv_WriteAttribute( &msg->WriteAttribute);
break;
case rpvd_eMsg_SubAdd:
pwrsrv_SubAdd( &msg->SubAdd);
break;
case rpvd_eMsg_SubRemove:
pwrsrv_SubRemove( &msg->SubRemove);
break;
case rpvd_eMsg_SubRequest:
pwrsrv_SubSend( &msg->Any);
break;
case rpvd_eMsg_NodeUp:
pwrsrv_NodeUp( &msg->Any);
break;
}
}
}
}
示例2: goen_create_nodetype_m15
int goen_create_nodetype_m15(
pwr_sGraphPlcNode *graphbody,
pwr_tClassId cid,
ldh_tSesContext ldhses,
flow_tCtx ctx,
unsigned int *mask,
unsigned long subwindowmark,
unsigned long node_width,
flow_tNodeClass *node_class,
vldh_t_node node)
{
int i;
int inputpoints, outputpoints;
unsigned long pointmask;
unsigned int *inmask_pointer;
unsigned int *outmask_pointer;
unsigned int *invertmask_pointer;
int inputs;
int interns;
int outputs;
int sts, size;
int first_input, second_input;
ldh_sParDef *bodydef;
int rows;
int inputcount;
char annot_str[3][80];
int annot_nr[3];
int annot_count;
double annot_width[3];
double annot_height;
float f_width_left;
float annot2_width;
float annot3_width;
char annot3_found;
flow_tNodeClass nc_pid;
char name[80];
int conpoint_nr;
int annot_rows;
static int idx = 0;
flow_tObject cp;
sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
if ( EVEN(sts) ) return sts;
sprintf( &name[strlen(name)], "%d", idx++);
/* Get the runtime paramteers for this class */
sts = ldh_GetObjectBodyDef(ldhses, cid, "RtBody", 1,
&bodydef, &rows);
if ( EVEN(sts) ) return sts;
/* Get number of annotations and the width of the annotations */
sts = WGre::get_annotations( node,
(char *)annot_str, annot_nr, &annot_count,
sizeof( annot_str)/sizeof(annot_str[0]), sizeof( annot_str[0]));
if ( EVEN(sts)) return sts;
if ( annot_count > 0)
{
flow_MeasureAnnotText( ctx, annot_str[0],
flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
&annot_width[0], &annot_height, &annot_rows);
}
if ( annot_count > 1)
{
flow_MeasureAnnotText( ctx, annot_str[1],
flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
&annot_width[1], &annot_height, &annot_rows);
}
if ( annot_count > 2)
{
flow_MeasureAnnotText( ctx, annot_str[2],
flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE, flow_eAnnotType_OneLine,
&annot_width[2], &annot_height, &annot_rows);
}
/* Find the widths for annotation 2 and 3 */
annot3_found = 0;
annot2_width = 0;
for ( i = 1; i < annot_count; i++)
{
if ( annot_nr[i] == 2)
annot2_width = annot_width[i];
if ( annot_nr[i] == 3)
{
annot3_width = annot_width[i];
annot3_found = 1;
}
}
/* Get how many parameters there are */
inputs = graphbody->parameters[PAR_INPUT];
interns = graphbody->parameters[PAR_INTERN];
outputs = graphbody->parameters[PAR_OUTPUT];
inmask_pointer = mask++;
outmask_pointer = mask++;
invertmask_pointer = mask;
/* Check if first input in mask (first bit) */
pointmask = 1;
//.........这里部分代码省略.........
示例3: DecodePreviews
//.........这里部分代码省略.........
title->rate = vid_info.rate;
title->rate_base = vid_info.rate_base;
if( vid_info.rate_base == 900900 )
{
if( npreviews >= 4 && pulldown_count >= npreviews / 4 )
{
title->rate_base = 1126125;
hb_deep_log( 2, "Pulldown detected, setting fps to 23.976" );
}
if( npreviews >= 2 && progressive_count >= npreviews / 2 )
{
// We've already deduced that the frame rate is 23.976,
// so set it back again.
title->rate_base = 1126125;
hb_deep_log( 2, "Title's mostly NTSC Film, setting fps to 23.976" );
}
}
if( npreviews >= 2 && doubled_frame_count >= 3 * npreviews / 4 )
{
// We've detected that a significant number of the frames
// have been doubled in duration by repeat flags.
title->rate_base = 2 * vid_info.rate_base;
hb_deep_log( 2, "Repeat frames detected, setting fps to %.3f", (float)title->rate / title->rate_base );
}
}
title->video_bitrate = vid_info.bitrate;
if( vid_info.pixel_aspect_width && vid_info.pixel_aspect_height )
{
title->pixel_aspect_width = vid_info.pixel_aspect_width;
title->pixel_aspect_height = vid_info.pixel_aspect_height;
}
title->color_prim = vid_info.color_prim;
title->color_transfer = vid_info.color_transfer;
title->color_matrix = vid_info.color_matrix;
title->video_decode_support = vid_info.video_decode_support;
// TODO: check video dimensions
title->opencl_support = !!hb_opencl_available();
// compute the aspect ratio based on the storage dimensions and the
// pixel aspect ratio (if supplied) or just storage dimensions if no PAR.
title->aspect = (double)title->width / (double)title->height;
title->aspect *= (double)title->pixel_aspect_width /
(double)title->pixel_aspect_height;
// For unknown reasons some French PAL DVDs put the original
// content's aspect ratio into the mpeg PAR even though it's
// the wrong PAR for the DVD. Apparently they rely on the fact
// that DVD players ignore the content PAR and just use the
// aspect ratio from the DVD metadata. So, if the aspect computed
// from the PAR is different from the container's aspect we use
// the container's aspect & recompute the PAR from it.
if( title->container_aspect && (int)(title->aspect * 9) != (int)(title->container_aspect * 9) )
{
hb_log("scan: content PAR gives wrong aspect %.2f; "
"using container aspect %.2f", title->aspect,
title->container_aspect );
title->aspect = title->container_aspect;
hb_reduce( &title->pixel_aspect_width, &title->pixel_aspect_height,
(int)(title->aspect * title->height + 0.5), title->width );
}
// don't try to crop unless we got at least 3 previews
if ( crops->n > 2 )
{
sort_crops( crops );
// The next line selects median cropping - at least
// 50% of the frames will have their borders removed.
// Other possible choices are loose cropping (i = 0) where
// no non-black pixels will be cropped from any frame and a
// tight cropping (i = crops->n - (crops->n >> 2)) where at
// least 75% of the frames will have their borders removed.
i = crops->n >> 1;
title->crop[0] = EVEN( crops->t[i] );
title->crop[1] = EVEN( crops->b[i] );
title->crop[2] = EVEN( crops->l[i] );
title->crop[3] = EVEN( crops->r[i] );
}
hb_log( "scan: %d previews, %dx%d, %.3f fps, autocrop = %d/%d/%d/%d, "
"aspect %s, PAR %d:%d",
npreviews, title->width, title->height, (float) title->rate /
(float) title->rate_base,
title->crop[0], title->crop[1], title->crop[2], title->crop[3],
aspect_to_string( title->aspect ), title->pixel_aspect_width,
title->pixel_aspect_height );
if( interlaced_preview_count >= ( npreviews / 2 ) )
{
hb_log("Title is likely interlaced or telecined (%i out of %i previews). You should do something about that.",
interlaced_preview_count, npreviews);
title->detected_interlacing = 1;
}
else
{
title->detected_interlacing = 0;
}
}
示例4: main
int
main ()
{
pwr_tStatus sts;
pwr_tObjid oid;
qcom_sQid my_q = qcom_cNQid;
qcom_sGet get;
pwr_tBoolean firstTime = TRUE;
pwr_tUInt32 nrOfEvents = 0;
pwr_tUInt32 nrOfKeys = 0;
errh_Init("pwr_elog", errh_eAnix_elog);
errh_SetStatus( PWR__SRVSTARTUP);
memset(&lHelCB, 0, sizeof(lHelCB));
/* Declare process */
sts = gdh_Init("pwr_elog");
If_Error_Log_Exit(sts, "gdh_Init");
Init();
/* Create queue for receival of events */
if (!qcom_CreateQ(&sts, &my_q, NULL, "events")) {
errh_Fatal("qcom_CreateQ, %m", sts);
errh_SetStatus( PWR__APPLTERM);
exit(sts);
}
if (!qcom_Bind(&sts, &my_q, &qcom_cQini)) {
errh_Fatal("qcom_Bind(Qini), %m", sts);
errh_SetStatus( PWR__APPLTERM);
exit(-1);
}
oid.vid = lHelCB.Nid;
oid.oix = pwr_cNVolumeId;
sts = mh_OutunitConnect(
oid,
mh_eOutunitType_Logger,
mh_mOutunitFlags_ReadWait,
(mh_cbOutunitAck)Insert,
(mh_cbOutunitAlarm)Insert,
(mh_cbOutunitBlock)Insert,
(mh_cbOutunitCancel)Insert,
NULL,
NULL,
(mh_cbOutunitInfo)Insert,
(mh_cbOutunitReturn)Insert,
NULL
);
If_Error_Log_Exit(sts, "mh_OutunitConnect");
sts = mh_OutunitSetTimeout(lHelCB.ScanTime);
errh_SetStatus( PWR__SRUN);
for (;;) {
sts = mh_OutunitReceive();
if (EVEN(sts) && sts != MH__TMO)
Log_Error(sts, "mh_OutunitReceive");
Store(&firstTime, &nrOfEvents, &nrOfKeys);
get.data = NULL;
qcom_Get(&sts, &my_q, &get, 0);
if (sts != QCOM__TMO && sts != QCOM__QEMPTY) {
if (get.type.b == qcom_eBtype_event) {
qcom_sEvent *ep = (qcom_sEvent*) get.data;
ini_mEvent new_event;
if (get.type.s == qcom_cIini) {
new_event.m = ep->mask;
if (new_event.b.terminate) {
errh_SetStatus( PWR__APPLTERM);
exit(0);
}
}
}
qcom_Free(&sts, get.data);
}
aproc_TimeStamp( lHelCB.ScanTime/1000, 5.0);
}
}
示例5: graph_object_collect_build
static int graph_object_collect_build( Graph *graph, pwr_sAttrRef *attrref)
{
pwr_sAttrRef *alist, *ap;
int *is_attrp, *is_attr;
int sts;
char name[120];
double x1, y1;
grow_sAttrInfo *grow_info, *grow_info_p;
int grow_info_cnt;
int i;
grow_tObject scantime_button;
grow_tObject hold_button;
grow_tObject t1, l1;
double z_width, z_height, z_descent;
double name_width = 0;
double trend_width = 48;
double trend_height = 1.2;
double y0 = 2.2;
double x0 = 2;
pwr_tTypeId attr_type;
unsigned int attr_size, attr_offset, attr_dimension;
GeDyn *dyn;
char attr_name[120];
grow_sAttributes grow_attr;
unsigned long mask;
int trend_cnt = 0;
if ( ! graph->get_current_objects_cb)
return 0;
sts = (graph->get_current_objects_cb) (graph->parent_ctx, &alist, &is_attr);
if ( EVEN(sts)) return sts;
if ( cdh_ObjidIsNull( alist->Objid))
return 0;
graph->graph_object_data = 0;
graph->graph_object_close = 0;
grow_SetPath( graph->grow->ctx, 1, "pwr_exe:");
// Set graph attributes
// Default color theme
mask = grow_eAttr_color_theme;
strcpy( grow_attr.color_theme, "$default");
grow_SetAttributes( graph->grow->ctx, &grow_attr, mask);
grow_ReadCustomColorFile( graph->grow->ctx, 0);
grow_SetBackgroundColor( graph->grow->ctx, glow_eDrawType_CustomColor1);
// Scantime input field
graph->create_node( NULL, "pwrct_valueinputsmallbg", x0, y0 - 1.3, 4, y0 - 1.3 + 1.2,
&scantime_button);
dyn = new GeDyn( graph);
grow_SetUserData( scantime_button, (void *)dyn);
dyn->set_dyn( ge_mDynType1_Value, ge_mDynType2_No, ge_mActionType1_ValueInput, ge_mActionType2_No);
dyn->update_elements();
dyn->set_access( (glow_mAccess) 65535);
dyn->set_attribute( scantime_button, "$local.ScanTime##Float32", 0);
dyn->set_value_input( "%3.0f", 2, 10000000);
// Hold button
graph->create_node( "TrendHold", "pwrct_buttonsmalltoggle", x0 + trend_width/2 - 3./2,
y0 - 1.4 , x0 + trend_width/2 + 3./2, y0 - 1.4 + 1.2,
&hold_button);
grow_SetAnnotation( hold_button, 1, "Hold", 4);
dyn = new GeDyn( graph);
grow_SetUserData( hold_button, (void *)dyn);
dyn->set_access( (glow_mAccess) 65535);
dyn->set_attribute( hold_button, "$local.TrendHold##Boolean", 0);
// Zero text
grow_CreateGrowText( graph->grow->ctx, "", "0",
x0 + trend_width - 0.2, y0 - 0.3,
glow_eDrawType_TextHelvetica, glow_eDrawType_CustomColor5, 3,
glow_eFont_LucidaSans, glow_mDisplayLevel_1,
NULL, &t1);
ap = alist;
is_attrp = is_attr;
x1 = x0;
y1 = y0;
while( cdh_ObjidIsNotNull( ap->Objid)) {
if ( *is_attrp) {
sts = gdh_AttrrefToName( ap, name, sizeof(name), cdh_mNName);
if ( EVEN(sts)) return sts;
sts = gdh_GetAttributeCharacteristics( name, &attr_type, &attr_size,
&attr_offset, &attr_dimension);
if ( EVEN(sts)) return sts;
switch ( attr_type) {
case pwr_eType_Boolean: {
grow_tObject trend;
//.........这里部分代码省略.........
示例6: testClient
static gdb_sNode *
testClient (
pwr_tStatus *sts,
sub_sClient *cp
)
{
pwr_tStatus lsts = GDH__SUCCESS;
pwr_tSubid sid = cp->sid;
cdh_sParseName parseName;
cdh_sParseName *pn;
gdb_sObject *op = NULL;
sub_sClient *rcp;
gdb_sVolume *vp;
gdb_sNode *np = NULL;
mvol_sAttribute attribute;
mvol_sAttribute *ap;
pwr_sAttrRef *arp;
pwr_sAttrRef *rarp;
gdb_sCclass *ccp;
gdb_sCclass *ccpLocked;
pool_tRef ccr;
pwr_tUInt32 ridx;
pwr_tBoolean equal;
pwr_tBoolean fetched;
gdb_AssumeLocked;
do {
if (cp->sub_by_name) { /* Lookup by name. */
pn = cdh_ParseName(&lsts, &parseName, pwr_cNObjid, cp->name, 0);
if (pn == NULL) break;
do {
ap = vol_NameToAttribute(&lsts, &attribute, pn, gdb_mLo_global, vol_mTrans_all);
if (ap == NULL) break;
rcp = hash_Search(sts, gdbroot->subc_ht, &sid);
if (rcp != cp) break; /* Subscription client no longer exists! */
arp = mvol_AttributeToAref(&lsts, ap, &cp->aref);
if (arp == NULL) break;
op = ap->op;
/* */
vp = pool_Address(NULL, gdbroot->pool, op->l.vr);
np = hash_Search(&lsts, gdbroot->nid_ht, &vp->g.nid);
if (np == NULL) {
op = NULL;
break;
}
ccp = NULL;
equal = 1;
/* Get cached class if needed */
if (!op->u.c.flags.b.classChecked || !op->u.c.flags.b.classEqual) {
ccp = cmvolc_GetCachedClass(&lsts, np, vp, ap, &equal, &fetched, NULL);
if (EVEN(lsts)) {
np = NULL;
op = NULL;
break;
}
if (fetched) {
rcp = hash_Search(sts, gdbroot->subc_ht, &sid);
if (rcp != cp) break; /* Subscription client no longer exists! */
}
if (equal) {
if (cp->cclass != pool_cNRef) {
ccp = pool_Address(NULL, gdbroot->pool, cp->cclass);
if (ccp == NULL) errh_Bugcheck(GDH__WEIRD, "cached class address");
cmvolc_UnlockClass(NULL, ccp);
cp->cclass = pool_cNRef;
}
ccp = NULL;
} else {
ccr = pool_ItemReference(NULL, gdbroot->pool, ccp);
if (ccr == pool_cNRef) errh_Bugcheck(GDH__WEIRD, "cache class address to reference");
if (ccr != cp->cclass) {
if (cp->cclass != pool_cNRef) {
gdb_sCclass *cc2p = pool_Address(NULL, gdbroot->pool, cp->cclass);
cmvolc_UnlockClass(NULL, cc2p);
}
cmvolc_LockClass(NULL, ccp);
cp->cclass = ccr;
}
}
/* If gdb has been unlocked, refresh pointers */
/** @todo Check if we can do it more efficient, eg. vol_ArefToAttribute */
if (fetched) {
np = NULL;
op = NULL;
//.........这里部分代码省略.........
示例7: importUpdateSubClass
bool wb_treeimport::importUpdateSubClass( wb_adrep *subattr, char *body, wb_vrep *vrep,
bool *modified)
{
pwr_tStatus sts;
pwr_tOix oix;
pwr_tCid cid = subattr->subClass();
wb_cdrep *cdrep = vrep->merep()->cdrep( &sts, cid);
if ( EVEN(sts)) throw wb_error(sts);
wb_bdrep *bdrep = cdrep->bdrep( &sts, pwr_eBix_rt);
if ( EVEN(sts)) throw wb_error(sts);
int subattr_elements = subattr->isArray() ? subattr->nElement() : 1;
for ( int i = 0; i < subattr_elements; i++) {
wb_adrep *adrep = bdrep->adrep( &sts);
while ( ODD(sts)) {
int elements = adrep->isArray() ? adrep->nElement() : 1;
if ( adrep->isClass()) {
importUpdateSubClass( adrep, body + i * subattr->size() / subattr_elements + adrep->offset(),
vrep, modified);
}
else {
switch ( adrep->type()) {
case pwr_eType_Objid: {
pwr_tOid *oidp = (pwr_tOid *)(body + i * subattr->size() / subattr_elements +
adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( oidp->vid == m_import_source_vid && (oix = importTranslate( oidp->oix))) {
oidp->vid = vrep->vid();
oidp->oix = oix;
*modified = true;
}
else if ( ldh_isSymbolicVid( oidp->vid) &&
(oix = importTranslateCid(oidp->oix))) {
oidp->oix = oix;
*modified = true;
}
oidp++;
}
break;
}
case pwr_eType_AttrRef: {
pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + i * subattr->size() / subattr_elements +
adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( arp->Objid.vid == m_import_source_vid && (oix = importTranslate( arp->Objid.oix))) {
arp->Objid.vid = vrep->vid();
arp->Objid.oix = oix;
*modified = true;
}
else if ( ldh_isSymbolicVid( arp->Objid.vid) &&
(oix = importTranslateCid(arp->Objid.oix))) {
arp->Objid.oix = oix;
*modified = true;
}
arp++;
}
break;
}
case pwr_eType_DataRef: {
pwr_tDataRef *drp = (pwr_tDataRef *)(body + i * subattr->size() / subattr_elements +
adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( drp->Aref.Objid.vid == m_import_source_vid &&
(oix = importTranslate( drp->Aref.Objid.oix))) {
drp->Aref.Objid.vid = vrep->vid();
drp->Aref.Objid.oix = oix;
*modified = true;
}
drp++;
}
break;
}
default:
;
}
}
wb_adrep *prev = adrep;
adrep = adrep->next( &sts);
delete prev;
}
}
delete bdrep;
delete cdrep;
return true;
}
示例8: while
bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
{
pwr_tOix oix;
pwr_tStatus sts;
wb_cdrep *cdrep = vrep->merep()->cdrep( &sts, o->cid());
if ( EVEN(sts)) throw wb_error(sts);
pwr_mClassDef flags = cdrep->flags();
for ( int i = 0; i < 2; i++) {
pwr_eBix bix = i ? pwr_eBix_rt : pwr_eBix_dev;
wb_bdrep *bdrep = cdrep->bdrep( &sts, bix);
if ( EVEN(sts)) continue;
int size = bdrep->size();
char *body = (char *)malloc( bdrep->size());
vrep->readBody( &sts, o, bix, body);
if ( EVEN(sts)) throw wb_error(sts);
bool modified = false;
wb_adrep *adrep = bdrep->adrep( &sts);
while ( ODD(sts)) {
int elements = adrep->isArray() ? adrep->nElement() : 1;
if (adrep->offset() < 0 || ((int)(adrep->offset() + adrep->size()) > size))
printf("(adrep->offset() < 0 || (adrep->offset() + adrep->size() > size))\n");
if ( adrep->isClass()) {
importUpdateSubClass( adrep, body + adrep->offset(), vrep, &modified);
}
else {
switch ( adrep->type()) {
case pwr_eType_Objid: {
pwr_tOid *oidp = (pwr_tOid *)(body + adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( oidp->vid == m_import_source_vid && (oix = importTranslate( oidp->oix))) {
oidp->vid = vrep->vid();
oidp->oix = oix;
modified = true;
}
else if ( ldh_isSymbolicVid( oidp->vid) &&
(oix = importTranslateCid(oidp->oix))) {
oidp->oix = oix;
modified = true;
}
oidp++;
}
break;
}
case pwr_eType_AttrRef: {
pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( arp->Objid.vid == m_import_source_vid && (oix = importTranslate( arp->Objid.oix))) {
arp->Objid.vid = vrep->vid();
arp->Objid.oix = oix;
modified = true;
}
else if ( ldh_isSymbolicVid( arp->Objid.vid) &&
(oix = importTranslateCid(arp->Objid.oix))) {
arp->Objid.oix = oix;
modified = true;
}
arp++;
}
break;
}
case pwr_eType_DataRef: {
pwr_tDataRef *drp = (pwr_tDataRef *)(body + adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( drp->Aref.Objid.vid == m_import_source_vid &&
(oix = importTranslate( drp->Aref.Objid.oix))) {
drp->Aref.Objid.vid = vrep->vid();
drp->Aref.Objid.oix = oix;
modified = true;
}
drp++;
}
break;
}
default:
;
}
}
wb_adrep *prev = adrep;
adrep = adrep->next( &sts);
delete prev;
}
if ( modified) {
vrep->writeBody( &sts, o, bix, body);
if ( EVEN(sts)) throw wb_error(sts);
}
free( body);
delete bdrep;
}
delete cdrep;
return true;
}
示例9: G77_ef1asc_0
int
G77_ef1asc_0 (ftnint * a, ftnlen * la, ftnint * b, ftnlen * lb)
{
s_copy ((char *) a, (char *) b, EVEN (*la), *lb);
return 0; /* ignored return value */
}
示例10: n
wb_adrep *wb_bdrep::adrep( pwr_tStatus *sts, const char *aname)
{
#if 0
wb_attrname n(aname);
if ( n.evenSts()) {
*sts = n.sts();
return 0;
}
char fullname[120];
wb_bdrep *bd = this;
wb_adrep *adrep = 0;
int offset;
for ( int i = 0; i < n.attributes(); i++) {
wb_name an(n.attribute(i));
wb_orep *orep = bd->m_orep->vrep()->child( sts, bd->m_orep, an);
if ( EVEN(*sts)) return 0;
if ( adrep)
delete adrep;
adrep = new wb_adrep( *orep);
if ( i == 0) {
offset = adrep->offset();
strcpy( fullname, adrep->name());
}
else {
offset += adrep->offset();
strcat( fullname, ".");
strcat( fullname, adrep->name());
}
if ( n.hasAttrIndex(i)) {
sprintf( &fullname[strlen(fullname)], "[%d]", n.attrIndex(i));
if ( n.attrIndex(i) >= adrep->nElement() || n.attrIndex(i) < 0) {
*sts = LDH__ATTRINDEX;
return 0;
}
offset += n.attrIndex(i) * adrep->size() / adrep->nElement();
}
if ( (i != n.attributes() - 1) && adrep->isClass()) {
wb_cdrep *cd = m_orep->vrep()->merep()->cdrep( sts, adrep->subClass());
if ( EVEN(*sts)) return 0;
if ( bd != this)
delete bd;
bd = cd->bdrep( sts, pwr_eBix_rt);
if ( EVEN(*sts)) { delete cd; return 0;}
delete cd;
}
}
adrep->setSubattr( offset, fullname);
#endif
wb_attrname n(aname);
if ( n.evenSts()) {
*sts = n.sts();
return 0;
}
wb_bdrep *bd = this;
wb_adrep *adrep = 0;
wb_adrep *old = 0;
for ( int i = 0; i < n.attributes(); i++) {
bool next_attr = false;
wb_name an(n.attribute(i));
wb_orep *orep = bd->m_orep->vrep()->child( sts, bd->m_orep, an);
while ( EVEN(*sts)) {
// Try Super attribute
orep = bd->m_orep->vrep()->first( sts, bd->m_orep);
if ( EVEN(*sts)) {
if ( bd != this) delete bd;
if ( adrep) delete adrep;
return 0;
}
if ( cdh_NoCaseStrcmp( orep->name(), "Super") == 0) {
if ( adrep)
old = adrep;
adrep = new wb_adrep( *orep);
if ( old)
adrep->add( old);
delete old;
wb_cdrep *cd = m_orep->vrep()->merep()->cdrep( sts, adrep->subClass());
if ( EVEN(*sts)) return 0;
if ( bd != this)
delete bd;
bd = cd->bdrep( sts, pwr_eBix_rt);
if ( EVEN(*sts)) { delete cd; return 0;}
delete cd;
orep = bd->m_orep->vrep()->child( sts, bd->m_orep, an);
//.........这里部分代码省略.........
示例11: brow_GetUserData
//
// Callbacks from brow
//
int CoLogWNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
{
CoLogWNav *logwnav;
ItemLog *item;
if ( event->event == flow_eEvent_ObjectDeleted)
{
brow_GetUserData( event->object.object, (void **)&item);
delete item;
return 1;
}
brow_GetCtxUserData( (BrowCtx *)ctx, (void **) &logwnav);
switch ( event->event)
{
case flow_eEvent_Key_Up:
{
brow_tNode *node_list;
int node_count;
brow_tObject object;
int sts;
brow_GetSelectedNodes( logwnav->brow->ctx, &node_list, &node_count);
if ( !node_count) {
sts = brow_GetLastVisible( logwnav->brow->ctx, &object);
if ( EVEN(sts)) return 1;
}
else {
if ( !brow_IsVisible( logwnav->brow->ctx, node_list[0], flow_eVisible_Partial)) {
sts = brow_GetLastVisible( logwnav->brow->ctx, &object);
if ( EVEN(sts)) return 1;
}
else {
sts = brow_GetPrevious( logwnav->brow->ctx, node_list[0], &object);
if ( EVEN(sts)) {
if ( node_count)
free( node_list);
return 1;
}
}
}
brow_SelectClear( logwnav->brow->ctx);
brow_SetInverse( object, 1);
brow_SelectInsert( logwnav->brow->ctx, object);
if ( !brow_IsVisible( logwnav->brow->ctx, object, flow_eVisible_Full))
brow_CenterObject( logwnav->brow->ctx, object, 0.25);
if ( node_count)
free( node_list);
break;
}
case flow_eEvent_Key_Down:
{
brow_tNode *node_list;
int node_count;
brow_tObject object;
int sts;
brow_GetSelectedNodes( logwnav->brow->ctx, &node_list, &node_count);
if ( !node_count) {
sts = brow_GetFirstVisible( logwnav->brow->ctx, &object);
if ( EVEN(sts)) return 1;
}
else {
if ( !brow_IsVisible( logwnav->brow->ctx, node_list[0], flow_eVisible_Partial)) {
sts = brow_GetFirstVisible( logwnav->brow->ctx, &object);
if ( EVEN(sts)) return 1;
}
else {
sts = brow_GetNext( logwnav->brow->ctx, node_list[0], &object);
if ( EVEN(sts)) {
if ( node_count)
free( node_list);
return 1;
}
}
}
brow_SelectClear( logwnav->brow->ctx);
brow_SetInverse( object, 1);
brow_SelectInsert( logwnav->brow->ctx, object);
if ( !brow_IsVisible( logwnav->brow->ctx, object, flow_eVisible_Full))
brow_CenterObject( logwnav->brow->ctx, object, 0.75);
if ( node_count)
free( node_list);
break;
}
case flow_eEvent_SelectClear:
brow_ResetSelectInverse( logwnav->brow->ctx);
break;
case flow_eEvent_MB1Click:
// Select
double ll_x, ll_y, ur_x, ur_y;
int sts;
switch ( event->object.object_type)
{
case flow_eObjectType_Node:
brow_MeasureNode( event->object.object, &ll_x, &ll_y,
//.........这里部分代码省略.........
示例12: vipc616_GetAddress
pwr_tStatus vipc616_GetAddress(
pwr_tObjid ipObjid, /* Objid of IP-module */
pwr_tUInt32 slot,
char **ioAddress,
char **idAddress,
char **memoryAddress
)
{
pwr_tStatus sts;
pwr_tObjid parent;
pwr_tClassId cid;
pwr_sClass_VIPC616* vipc;
unsigned int memSize;
int slotNo;
unsigned int ioAdrs;
unsigned int memAdrs;
sts = gdh_GetParent(ipObjid, &parent);
if (EVEN(sts))
return IO__NOTIPCARRIER;
sts = gdh_GetObjectClass(parent, &cid);
if (EVEN(sts))
return IO__NOTIPCARRIER;
if (pwr_cClass_VIPC616 != cid)
return IO__NOTIPCARRIER;
sts = gdh_ObjidToPointer(parent, (pwr_tAddress *)&vipc);
if (EVEN(sts))
return IO__NOTIPCARRIER;
switch (toupper(slot)) {
case 'A':
case 'B':
case 'C':
case 'D':
slotNo = toupper(slot) - 'A';
break;
default:
return IO__INVIPSLOT;
break;
}
if (vipc->MemoryBase == 32)
memSize = 0x800000; /* 8 MB */
else if (vipc->MemorySlotSize <= 128)
memSize = 0x20000; /* 128 kB */
else if (vipc->MemorySlotSize <= 256)
memSize = 0x40000; /* 256 kB */
else if (vipc->MemorySlotSize <= 512)
memSize = 0x80000; /* 512 kB */
else if (vipc->MemorySlotSize <= 1024)
memSize = 0x100000; /* 1 MB */
else
memSize = 0x200000; /* 2 MB */
ioAdrs = io_GetShortIoAddress();
/* Each slot have 128 bytes IO space */
if (ioAddress != NULL)
*ioAddress = (char *) (ioAdrs + vipc->IoAddress +
(unsigned int)(slotNo * 0x100));
/* After the IO space each slot have 128 ID bytes */
if (idAddress != NULL)
*idAddress = (char *) (ioAdrs + vipc->IoAddress +
(unsigned int) 0x80 + (unsigned int)(slotNo * 0x100));
if (memoryAddress != NULL) {
if (vipc->MemoryBase == 32)
memAdrs = io_GetA32D16Address();
else
memAdrs = io_GetA24Address();
*memoryAddress = (char *)(memAdrs + (unsigned int)(slotNo * memSize) + vipc->MemoryAddress);
}
return IO__SUCCESS;
}
示例13: message
//
// Callbackfunctions from menu entries
//
void WPkg::activate_distribute()
{
WItemPkg **itemlist;
int item_count;
int sts;
message( ' ', "");
sts = wpkgnav->get_select( &itemlist, &item_count);
if ( EVEN(sts)) {
message( 'E', "Select a node or package");
return;
}
if ( item_count > 1) {
for ( int i = 0; i < item_count; i++) {
if ( typeid( *itemlist[i]) != typeid( WItemPkgNode)) {
message( 'E', "All selected items are not nodes");
free( itemlist);
return;
}
}
set_clock_cursor();
for ( int i = 0; i < item_count; i++) {
try {
wb_pkg *pkg = new wb_pkg( ((WItemPkgNode *)itemlist[i])->nodename);
delete pkg;
}
catch ( wb_error &e) {
message(' ', (char *)e.what().c_str());
reset_cursor();
free( itemlist);
return;
}
wpkgnav->refresh_node( itemlist[i]);
char msg[80];
sprintf( msg, "Distribution successful to %s", ((WItemPkgNode *)itemlist[i])->nodename);
message('I', msg);
flush();
}
reset_cursor();
free( itemlist);
}
else {
// One is selected
if ( typeid( *itemlist[0]) == typeid( WItemPkgNode)) {
set_clock_cursor();
try {
wb_pkg *pkg = new wb_pkg( ((WItemPkgNode *)itemlist[0])->nodename);
delete pkg;
}
catch ( wb_error &e) {
message(' ', (char *)e.what().c_str());
}
wpkgnav->refresh_node( itemlist[0]);
char msg[80];
sprintf( msg, "Distribution successful to %s", ((WItemPkgNode *)itemlist[0])->nodename);
message('I', msg);
reset_cursor();
}
else if ( typeid( *itemlist[0]) == typeid( WItemPkgPackage)) {
set_clock_cursor();
wb_pkg::copyPackage( ((WItemPkgPackage *)itemlist[0])->packagename);
char msg[80];
sprintf( msg, "Distribution successful of %s", ((WItemPkgPackage *)itemlist[0])->packagename);
message('I', msg);
reset_cursor();
}
else {
message( 'E', "Select a node or package");
}
}
}
示例14: graph_object_dx
static int graph_object_dx( Graph *graph, pwr_sAttrRef *arp)
{
int sts;
graph_sObjectDx *od;
pwr_tAttrRef aref, chanaref;
pwr_tAName aname;
pwr_tCid card_cid;
od = (graph_sObjectDx *) calloc( 1, sizeof(graph_sObjectDx));
graph->graph_object_data = (void *) od;
graph->graph_object_close = graph_object_dx_close;
sts = gdh_GetAttrRefTid( arp, &od->cid);
if ( EVEN(sts)) return sts;
// Get channel object
sts = gdh_ArefANameToAref( arp, "SigChanCon", &aref);
if ( EVEN(sts)) {
// Dv object, register scan function and return with success
graph->graph_object_scan = graph_object_dx_scan;
return 1;
}
sts = gdh_GetObjectInfoAttrref( &aref, &chanaref, sizeof(chanaref));
if ( EVEN(sts)) return sts;
od->local_conv_p = (pwr_tBoolean *) graph->localdb_ref_or_create( "ConversionOn",
pwr_eType_Boolean);
od->local_inv_p = (pwr_tBoolean *) graph->localdb_ref_or_create( "InvertOn",
pwr_eType_Boolean);
od->local_test_p = (pwr_tBoolean *) graph->localdb_ref_or_create( "TestOn",
pwr_eType_Boolean);
// Get card object
if ( chanaref.Flags.b.ObjectAttr) {
sts = gdh_GetObjectClass( chanaref.Objid, &card_cid);
if ( EVEN(sts)) return sts;
}
else
card_cid = 0;
switch ( card_cid) {
case pwr_cClass_Ssab_DI32D: {
pwr_tAName card_name;
unsigned int chan_idx = (chanaref.Offset - pwr_AlignLW(sizeof(pwr_sClass_Ssab_BaseDiCard))) / pwr_AlignLW(sizeof(pwr_sClass_ChanDi));
sts = gdh_ObjidToName( chanaref.Objid, card_name, sizeof(card_name), cdh_mNName);
if ( EVEN(sts)) return sts;
if ( chan_idx < 16) {
strcpy( aname, card_name);
strcat( aname, ".ConvMask1");
graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->conv_p, &od->conv_subid,
sizeof(pwr_tBoolean), 0, true);
strcpy( aname, card_name);
strcat( aname, ".InvMask1");
graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid,
sizeof(pwr_tBoolean), 0, true);
od->mask = 1 << chan_idx;
}
else if ( chan_idx < 32) {
strcpy( aname, card_name);
strcat( aname, ".ConvMask2");
graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->conv_p, &od->conv_subid,
sizeof(pwr_tBoolean), 0, true);
strcpy( aname, card_name);
strcat( aname, ".InvMask2");
graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid,
sizeof(pwr_tBoolean), 0, true);
od->mask = 1 << (chan_idx - 16);
}
else
return 0;
break;
}
case pwr_cClass_Ssab_DO32DKS:
case pwr_cClass_Ssab_DO32DKS_Stall: {
pwr_tAName card_name;
unsigned int chan_idx = (chanaref.Offset - pwr_AlignLW(sizeof(pwr_sClass_Ssab_BaseDoCard))) / pwr_AlignLW(sizeof(pwr_sClass_ChanDo));
sts = gdh_ObjidToName( chanaref.Objid, card_name, sizeof(card_name), cdh_mNName);
if ( EVEN(sts)) return sts;
if ( chan_idx < 16) {
strcpy( aname, card_name);
strcat( aname, ".TestMask1");
graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->test_p, &od->test_subid,
sizeof(pwr_tBoolean), 0, true);
strcpy( aname, card_name);
//.........这里部分代码省略.........
示例15: mb_connect
static void* mb_connect(void* arg)
{
io_sRack* rp = (io_sRack*)arg;
io_sServerLocal* local = rp->Local;
int sts;
pwr_sClass_Modbus_TCP_Server* op;
struct sockaddr_in r_addr;
socklen_t r_addr_len;
int c_socket;
mb_sCondata* condata;
int idx;
int found;
int i;
op = (pwr_sClass_Modbus_TCP_Server*)rp->op;
while (1) {
/* Wait for client connect request */
r_addr_len = sizeof(r_addr);
c_socket = accept(local->s, (struct sockaddr*)&r_addr, &r_addr_len);
if (c_socket < 0) {
errh_Error(
"Error accept IO modbus tcp server %s, %d", rp->Name, local->s);
continue;
}
if (op->DisableServer)
continue;
errh_Info("Connection accepted for IO modbus tcp server %s, %d", rp->Name,
c_socket);
/* Close other connections to this address */
for (i = 0; i < MB_MAX_CONNECTIONS; i++) {
if (local->connections[i].occupied
&& r_addr_len == local->connections[i].addrlen
&& r_addr.sin_family == local->connections[i].addr.sin_family
&& memcmp(&r_addr.sin_addr, &local->connections[i].addr.sin_addr,
sizeof(r_addr.sin_addr))
== 0) {
mb_close_connection(rp, i);
}
}
/* Find next empty in connection list */
found = 0;
for (i = 0; i < MB_MAX_CONNECTIONS; i++) {
if (!local->connections[i].occupied) {
found = 1;
idx = i;
break;
}
}
if (!found) {
/* Remove the oldest connection */
int oldest_idx = 0;
for (i = 1; i < MB_MAX_CONNECTIONS; i++) {
if (time_Acomp(&local->connections[i].last_req_time,
&local->connections[oldest_idx].last_req_time)
< 0)
oldest_idx = i;
}
mb_close_connection(rp, oldest_idx);
errh_Info(
"Connection closed, IO modbus tcp server %s, %d", rp->Name, local->s);
idx = oldest_idx;
}
local->connections[idx].c_socket = c_socket;
local->connections[idx].occupied = 1;
time_GetTime(&local->connections[idx].last_req_time);
local->connections[idx].addrlen = r_addr_len;
memcpy(&local->connections[idx].addr, &r_addr, r_addr_len);
/* Create a thread for this connection */
condata = (mb_sCondata*)malloc(sizeof(mb_sCondata));
condata->rp = rp;
condata->idx = idx;
sts = thread_Create(
&local->connections[idx].t, 0, mb_receive, (void*)condata);
if (EVEN(sts)) {
local->connections[idx].occupied = 0;
errh_Error("Error creating thread IO modbus tcp server %s, %d", rp->Name,
local->s);
free(condata);
continue;
}
}
return 0;
}