/*_* CompOnOffZoneFo @aref componoffzone @aref componoffzonefo CompOnOffZoneFo */ void CompOnOffZoneFo_init( pwr_sClass_CompOnOffZoneFo *o) { pwr_tDlid dlid; pwr_tStatus sts; sts = gdh_DLRefObjectInfoAttrref( &o->PlcConnect, (void **)&o->PlcConnectP, &dlid); if ( EVEN(sts)) o->PlcConnectP = 0; }
/*_* RunTimeCounterFo @aref runtimecounter @aref runtimecounterfo RunTimeCounterFo */ void RunTimeCounterFo_init( pwr_sClass_RunTimeCounterFo *o) { pwr_tDlid dlid; pwr_tStatus sts; sts = gdh_DLRefObjectInfoAttrref( &o->PlcConnect, (void **)&o->PlcConnectP, &dlid); if ( EVEN(sts)) o->PlcConnectP = 0; if ( o->PlcConnectP && o->ResetP == &o->Reset) ((pwr_sClass_RunTimeCounter *)o->PlcConnectP)->AccTripReset = 1; }
/*_* @aref cyclesup CycleSup */ lst_sEntry * csup_Init ( pwr_tStatus *status, pwr_tObjid tid, float scanTime ) { lst_sEntry *lh; pwr_tObjid cid; pwr_tObjid pid; csup_sObject *cp; int tv_sec; pwr_tFloat32 max_delay; pwr_dStatus(sts, status, CSUP__SUCCESS); lh = calloc(1, sizeof(*lh)); if (lh == NULL) pwr_Return(NULL, sts, CSUP__INSVIRMEM); lst_Init(NULL, lh, NULL); for ( *sts = gdh_GetClassList(pwr_cClass_CycleSup, &cid); ODD(*sts); *sts = gdh_GetNextObject(cid, &cid) ) { cp = calloc(1, sizeof(*cp)); cp->aref.Objid = cid; *sts = gdh_DLRefObjectInfoAttrref(&cp->aref, (void**)&cp->o, &cp->dlid); if (EVEN(*sts)) goto error; if ( ODD(gdh_GetParent( cid, &pid)) && cdh_ObjidIsEqual( pid, tid)) cp->is_owner = 1; lst_InsertSucc(NULL, lh, &cp->le, cp); max_delay = cp->o->MaxDelay; cp->o->DelayLimit.tv_sec = tv_sec = (int)max_delay; cp->o->DelayLimit.tv_nsec = (int)((max_delay - (float)tv_sec + FLT_EPSILON) * 1.0e9); // printf("maxdelay: %f, tv_sec: %d, tv_nsec: %d\n", cp->o->MaxDelay, cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec); errh_Info("maxdelay: %f, tv_sec: %d, tv_nsec: %d", cp->o->MaxDelay, cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec); } if (lst_IsEmpty(NULL, lh)) goto error; return lh; error: csup_Exit(NULL, lh); return NULL; }
void ra_result::setPointer(int resultNo, const char *pointer) // Set pointer to result { pwr_sAttrRef attrref; pwr_tDlid refid; pwr_tStatus sts; resultNo_ = resultNo; sts = gdh_NameToAttrref( pwr_cNObjid, pointer, &attrref); if ( EVEN(sts)) throw co_error(sts); sts = gdh_DLRefObjectInfoAttrref( &attrref, (void**)&pointer_, &refid); if ( EVEN(sts)) throw co_error(sts); dlid_ = &refid; }
void rt_sysmon::open() { pwr_tStatus sts; pwr_sAttrRef aref; pwr_tObjid oid; // Open server configuration object SysMonConfig sts = gdh_GetClassList( pwr_cClass_SysMonConfig, &oid); if ( ODD(sts)) { aref = cdh_ObjidToAref( oid); sts = gdh_DLRefObjectInfoAttrref( &aref, (void **)&conf, &conf_dlid); if ( EVEN(sts)) throw co_error(sts); } if ( ODD(sts)) { scan_time = 1.0 / conf->ScanTime; } else { scan_time = 1; errh_Info( "No sysmon configuration, using base frequency 1 Hz"); oid = pwr_cNObjid; conf = 0; } aproc_RegisterObject( oid); // Open DiskSup objects for ( sts = gdh_GetClassListAttrRef( pwr_cClass_DiskSup, &aref); ODD(sts); sts = gdh_GetNextAttrRef( pwr_cClass_DiskSup, &aref, &aref)) { disksup_object *o = new disksup_object( &aref); objects.push_back( o); try { o->open( scan_time); if ( conf) conf->DiskSupObjects[sysmon_cnt] = aref.Objid; sysmon_cnt++; } catch ( co_error& e) { delete o; objects.pop_back(); errh_Error( "DiskSup configuration error: &s", (char *)e.what().c_str()); } } }
/*_* @aref plcthread PlcThread */ pwr_sClass_PlcThread * pwrb_PlcThread_Init ( pwr_tStatus *sts, plc_sThread *tp ) { pwr_sClass_PlcThread *o; *sts = gdh_DLRefObjectInfoAttrref(&tp->aref, (void *)&tp->PlcThread, &tp->dlid); if (EVEN(*sts)) return NULL; o = tp->PlcThread; tp->f_scan_time = o->ScanTime; tp->prio = o->Prio; o->Dlid = tp->dlid; return o; }
void sysmon_object::open( double base_scantime) { pwr_tStatus sts; // Link to object sts = gdh_DLRefObjectInfoAttrref( &aref, (void **)&p, &p_dlid); if ( EVEN(sts)) throw co_error(sts); sts = gdh_GetAttrRefTid( &aref, &cid); if ( EVEN(sts)) throw co_error(sts); switch ( cid) { case pwr_cClass_DiskSup: if ( ((pwr_sClass_DiskSup *)p)->ScanTime) scan_div = int( ((pwr_sClass_DiskSup *)p)->ScanTime / base_scantime + 0.5); else scan_div = 1; break; default: ; } }
static pwr_tStatus InitTrendList( trend_tCtx ctx) { pwr_tStatus sts; pwr_tUInt32 dummy; pwr_tTypeId type; int tix; pwr_tAttrRef aref; pwr_tAttrRef oaref; pwr_tAName name; pwr_tDisableAttr disabled; /* Init DsTrend objects */ /* Scan through typelist and insert valid objects in list and initiate */ /* the DsTrend objects. */ for ( sts = gdh_GetClassListAttrRef(pwr_cClass_DsTrend, &aref); ODD(sts); sts = gdh_GetNextAttrRef( pwr_cClass_DsTrend, &aref, &aref) ) { trend_sListEntry *ep; pwr_sClass_DsTrend *o; sts = gdh_AttrrefToName( &aref, name, sizeof(name), cdh_mNName); if (EVEN(sts)) continue; /* Check if parent object is disabled */ sts = gdh_AttrArefToObjectAref( &aref, &oaref); if ( ODD(sts)) { sts = gdh_ArefDisabled( &oaref, &disabled); if ( ODD(sts) && disabled) continue; } ep = calloc(1, sizeof(*ep)); if (ep == NULL) { errh_CErrLog(DS__ERRALLOC, NULL); errh_SetStatus( PWR__SRVTERM); exit(DS__ERRALLOC); } sts = gdh_RefObjectInfo(name, (pwr_tAddress *)&ep->o, &ep->o_subid, sizeof(*ep->o)); if (EVEN(sts)) { errh_Error("Couldn't get subscription for '%s'\n%m", name, sts); free(ep); continue; } o = ep->o; /* Set init values */ o->BufferStatus[0] = 1; o->BufferStatus[1] = 1; o->NoOfBuffers = 2; o->NoOfBufElement = 239; /* Initiate DsTrend object, sampled attribute must be on local node */ sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->DataName, (pwr_tAddress *)&o->DataPointer, &o->DataSubId); if (EVEN(sts)) { if ( sts == GDH__RTDBNULL && IsDisabled( &o->DataName)) continue; errh_Error("Couldn't get direct link to %s's attribute DataName\n%m", name, sts); gdh_UnrefObjectInfo(ep->o_subid); free(ep); continue; } sts = gdh_GetAttributeCharAttrref((pwr_sAttrRef *)&o->DataName, &type, &dummy, &dummy, &dummy); if (EVEN(sts)) { errh_Error("Couldn't get datatype for %s's attribute DataName\n%m", name, sts); gdh_UnrefObjectInfo(ep->o_subid); free(ep); continue; } tix = cdh_TypeIdToIndex(type); if (!IsValidType(tix)) { errh_Error("No valid datatype for %s's attribute DataName\n%m", name, DS__ERRTYPE); gdh_UnrefObjectInfo(ep->o_subid); free(ep); continue; } o->DataType = tix; if ( o->Multiple == 0) o->Multiple = 1; o->NoOfSample = (o->StorageTime * ctx->scantime) / o->Multiple; if(o->NoOfSample > o->NoOfBufElement) o->NoOfSample = o->NoOfBufElement; o->ScanTime = ctx->scantime; ep->next = ctx->o_list; ctx->o_list = ep; } /* Init DsTrendCurve objects */ /* Scan through typelist and insert valid objects in list and initiate the DsTrend objects. */ for (sts = gdh_GetClassListAttrRef(pwr_cClass_DsTrendCurve, &aref); ODD(sts); sts = gdh_GetNextAttrRef( pwr_cClass_DsTrendCurve, &aref, &aref) ) { trend_sListEntryTC *ep; pwr_sClass_DsTrendCurve *o; int i; int found; sts = gdh_AttrrefToName( &aref, name, sizeof(name), cdh_mNName); if (EVEN(sts)) continue; /* Check if parent object is disabled */ sts = gdh_AttrArefToObjectAref( &aref, &oaref); if ( ODD(sts)) { sts = gdh_ArefDisabled( &oaref, &disabled); if ( ODD(sts) && disabled) continue; } ep = calloc(1, sizeof(*ep)); if (ep == NULL) { errh_CErrLog(DS__ERRALLOC, NULL); errh_SetStatus( PWR__SRVTERM); exit(DS__ERRALLOC); } ep->first_scan = 1; sts = gdh_RefObjectInfo(name, (pwr_tAddress *)&ep->o, &ep->o_subid, sizeof(*ep->o)); if (EVEN(sts)) { errh_Error("Couldn't get subscription for '%s'\n%m", name, sts); free(ep); continue; } o = ep->o; if ( o->Function & 1) { /* Data stored by user */ gdh_UnrefObjectInfo(ep->o_subid); free(ep); continue; } ep->multiple = (int) (o->ScanTime / ctx->scantime_tc + 0.5); o->NoOfSample = (int) (o->StorageTime / ctx->scantime_tc * ep->multiple + 0.5); /* Initiate DsTrendCuve object, sampled attribute must be on local node */ found = 0; for ( i = 0; i < 10; i++) { if ( cdh_ObjidIsNull( o->Attribute[i].Objid)) continue; /* Link to attribute */ sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->Attribute[i], (pwr_tAddress *)&ep->datap[i], &ep->data_subid[i]); if (EVEN(sts)) { if ( sts == GDH__RTDBNULL && IsDisabled( &o->Attribute[i])) continue; errh_Error("Couldn't get direct link to %s's attribute %d, %m", name, i+1, sts); ep->datap[i] = 0; continue; } sts = gdh_GetAttributeCharAttrref((pwr_sAttrRef *)&o->Attribute[i], &type, &dummy, &dummy, &dummy); if (EVEN(sts)) { errh_Error("Couldn't get datatype for %s's attribute DataName\n%m", name, sts); gdh_UnrefObjectInfo(ep->data_subid[i]); ep->datap[i] = 0; continue; } tix = cdh_TypeIdToIndex(type); ep->data_size[i] = cdh_TypeToSize( type); if (!IsValidType(tix)) { errh_Error("No valid datatype for %s's attribute DataName\n%m", name, DS__ERRTYPE); gdh_UnrefObjectInfo(ep->data_subid[i]); ep->datap[i] = 0; continue; } o->AttributeType[i] = type; /* Link to buffer */ sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->Buffers[i], (pwr_tAddress *)&ep->buffheadp[i], &ep->buff_subid[i]); if (EVEN(sts)) { errh_Error("Couldn't get direct link to %s's buffer %d, %m", name, i+1, sts); gdh_UnrefObjectInfo(ep->data_subid[i]); ep->datap[i] = 0; continue; } ep->buffp[i] = (char *)ep->buffheadp[i] + pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader)); /* Get buffer size */ sts = gdh_GetAttributeCharAttrref( &o->Buffers[i], 0, &ep->buff_size[i], 0, 0); if ( EVEN(sts)) return sts; ep->buff_size[i] -= pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader)); found = 1; } if ( !found) { errh_Error("No valid attributes for %s", name); gdh_UnrefObjectInfo(ep->o_subid); free(ep); continue; } /* Link to time buffer */ if ( cdh_ObjidIsNotNull( o->TimeBuffer.Objid)) { sts = gdh_DLRefObjectInfoAttrref((pwr_sAttrRef *)&o->TimeBuffer, (pwr_tAddress *)&ep->timeheadp, &ep->timebuff_subid); if (EVEN(sts)) { errh_Error("Couldn't get direct link to %s's time buffer, %m", name, sts); ep->timeheadp = 0; ep->timebuffp = 0; } else ep->timebuffp = (char *)ep->timeheadp + pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader)); if ( o->TimeResolution == pwr_eTimeResolutionEnum_Nanosecond) ep->time_size = 8; else ep->time_size = 4; /* Get buffer size */ sts = gdh_GetAttributeCharAttrref( &o->TimeBuffer, 0, &ep->timebuff_size, 0, 0); if ( EVEN(sts)) return sts; ep->timebuff_size -= pwr_AlignLW(sizeof(pwr_sClass_CircBuffHeader)); } /* Calculate number of samples */ for ( i = 0; i < 10; i++) { if ( !ep->datap[i]) continue; if ( o->NoOfSample > ep->buff_size[i] / ep->data_size[i]) o->NoOfSample = ep->buff_size[i] / ep->data_size[i]; } if ( ep->timebuffp) { if ( o->NoOfSample > ep->timebuff_size / ep->time_size) o->NoOfSample = ep->timebuff_size / ep->time_size; } for ( i = 0; i < 10; i++) { if ( !ep->datap[i]) continue; ep->buffheadp[i]->Size = o->NoOfSample; ep->buffheadp[i]->ElementSize = ep->data_size[i]; } if ( ep->timebuffp) { ep->timeheadp->Size = o->NoOfSample; ep->timeheadp->ElementSize = ep->time_size; } ep->next = ctx->o_list_tc; ctx->o_list_tc = ep; } if ( ctx->o_list == NULL && ctx->o_list_tc == NULL) return DS__NOOBJECT; else return DS__SUCCESS; }
pwr_tStatus sev_db::tree_update() { int new_item = 0; int num; pwr_tAName hname; pwr_tStatus sts; pwr_tOid oid; pwr_tCid cid = 0; char* s; pwr_sClass_SevItem ritem; char oname_array[20][pwr_cSizObjName + 1]; pwr_tObjName itemname; char root[] = "pwrNode-sev"; // Check root object sts = gdh_NameToObjid(root, &oid); if (EVEN(sts)) { sts = gdh_CreateObject( root, pwr_eClass_NodeHier, 0, &oid, pwr_cNObjid, 0, pwr_cNObjid); if (EVEN(sts)) return sts; } for (unsigned int i = 0; i < m_items.size(); i++) { if (m_items[i].deleted) continue; printf("Tree update item %s\n", m_items[i].oname); switch (m_items[i].attr[0].type) { case pwr_eType_Float32: case pwr_eType_Float64: case pwr_eType_Int8: case pwr_eType_Int16: case pwr_eType_Int32: case pwr_eType_Int64: case pwr_eType_UInt8: case pwr_eType_UInt16: case pwr_eType_UInt32: case pwr_eType_UInt64: case pwr_eType_Boolean: break; default: continue; } new_item = 0; if ((s = strchr(m_items[i].oname, ':'))) s++; else s = m_items[i].oname; num = dcli_parse(s, "-", "", (char*)oname_array, sizeof(oname_array) / sizeof(oname_array[0]), sizeof(oname_array[0]), 0); strcpy(hname, root); for (int j = 0; j < num; j++) { strcat(hname, "-"); strcat(hname, oname_array[j]); if (!new_item) sts = gdh_NameToObjid(hname, &oid); if (new_item || EVEN(sts)) { // Create object sts = gdh_CreateObject( hname, pwr_eClass_NodeHier, 0, &oid, pwr_cNObjid, 0, pwr_cNObjid); if (EVEN(sts)) return sts; new_item = 1; } } sprintf(itemname, "%sItem", m_items[i].attrnum > 1 ? "O" : ""); strcat(hname, "-"); strcat(hname, itemname); if (!new_item) sts = gdh_NameToObjid(hname, &oid); if (new_item || EVEN(sts)) { switch (m_items[i].attr[0].type) { case pwr_eType_Float32: case pwr_eType_Float64: cid = pwr_cClass_SevItemFloat; break; case pwr_eType_Int8: case pwr_eType_Int16: case pwr_eType_Int32: case pwr_eType_Int64: case pwr_eType_UInt8: case pwr_eType_UInt16: case pwr_eType_UInt32: case pwr_eType_UInt64: cid = pwr_cClass_SevItemInt; break; case pwr_eType_Boolean: cid = pwr_cClass_SevItemBoolean; break; default:; } sts = gdh_CreateObject(hname, cid, 0, &oid, pwr_cNObjid, 0, pwr_cNObjid); if (EVEN(sts)) return sts; memset(&ritem, 0, sizeof(ritem)); strncpy(ritem.TableName, m_items[i].tablename, sizeof(ritem.TableName)); strncpy(ritem.ObjectName, m_items[i].oname, sizeof(ritem.ObjectName)); strncpy(ritem.Attr, m_items[i].attr[0].aname, sizeof(ritem.Attr)); ritem.AttrType = m_items[i].attr[0].type; ritem.NoOfAttr = m_items[i].attrnum; ritem.Oid = m_items[i].oid; ritem.Id = m_items[i].id; ritem.Options = m_items[i].options; ritem.Deadband = m_items[i].deadband; ritem.ScanTime = m_items[i].scantime; ritem.StorageTime = m_items[i].storagetime; strncpy( ritem.Description, m_items[i].description, sizeof(ritem.Description)); sts = gdh_SetObjectInfo(hname, &ritem, sizeof(ritem)); if (EVEN(sts)) return sts; } if (!m_items[i].ip) { // Get pointer to object pwr_tAttrRef aref = cdh_ObjidToAref(oid); sts = gdh_DLRefObjectInfoAttrref( &aref, (void**)&m_items[i].ip, &m_items[i].refid); if (EVEN(sts)) return sts; } } return SEV__SUCCESS; }
static sNode * init_node ( pwr_tObjid oid, sNode *np, pwr_tBoolean new_sub ) { pwr_tStatus sts; pwr_sAttrRef aref; pwr_sClass_NodeLinkSup *o; gdh_tDlid dlid = pwr_cNDlid; pwr_tBoolean is_alias = 0; cdh_uTypeId tid; sts = gdh_IsAlias(oid, &is_alias); if (is_alias) return NULL; /* Allocate and initiate NodeLink control block */ if (np == NULL) { tid.pwr = pwr_cClass_NodeLinkSup; tid.c.bix = 1; aref.Objid = oid; aref.Offset = 0; aref.Size = sizeof(pwr_sClass_NodeLinkSup); aref.Body = tid.pwr; aref.Flags.m = 0; sts = gdh_DLRefObjectInfoAttrref(&aref, (pwr_tAddress *)&o, &dlid); if (EVEN(sts)) { errh_Error("Couldn't get direct link to NodeLink object, %m", sts); return NULL; } np = (sNode*) calloc(1, sizeof(sNode)); if (np == NULL) { if (cdh_DlidIsNotNull (dlid)) gdh_DLUnrefObjectInfo (dlid); errh_Error("Error calloc, sNode"); return NULL; } memcpy (&np->node, o, sizeof (np->node)); np->dlid = dlid; np->o = o; np->oid = oid; np->timer = (void *)&o->TimerFlag; } /* Setup subscription to supervised Node object's attribute CurVersion. */ if (new_sub) { int dt; int tmo; dt = MAX(1, (int)(o->SubscriptionInterval * 1000)); tmo = MAX(2 * dt/100, 100); /* 10 s */ sts = gdh_SetSubscriptionDefaults (dt, tmo); tid.pwr = pwr_eClass_Node; tid.c.bix = 1; aref.Objid = o->Node; sts = gdh_ClassAttrToAttrref(pwr_eClass_Node, ".SystemStatus", &aref); sts = gdh_SubRefObjectInfoAttrref(&aref, &o->SubId); if ( EVEN(sts)) { errh_Error("Couldn't get link to Node object, %m", sts); o->SystemStatus = PWR__NETTIMEOUT; } else gdh_SubAssociateBuffer(o->SubId, (void **)&np->subvalue, sizeof(pwr_tStatus)); } return np; }
/**************************************************************************** * Name: logg_loggconflist_add() * * Type pwr_tStatus * * Type Parameter IOGF Description * * Description: * Add a conversion config object to the list. * **************************************************************************/ static pwr_tStatus logg_loggconflist_add( logg_ctx loggctx, pwr_tObjid objid, logg_t_loggconf_list **loggconflist, int *loggconflist_count) { logg_t_loggconf_list *loggconflist_ptr; logg_t_loggconf_list *new_loggconflist; pwr_sAttrRef attrref; int i; pwr_tStatus sts; pwr_sClass_LoggConfig *loggconf; /* Syntax check */ sts = gdh_ObjidToPointer ( objid, (pwr_tAddress *) &loggconf); if ( EVEN(sts)) return sts; /* Check that there is some filename */ if ( !strcmp( loggconf->LoggFile, "")) return REM__LOGGFILE; /* Check that identity is unique */ loggconflist_ptr = *loggconflist; for ( i = 0; i < *loggconflist_count; i++) { if ( loggconflist_ptr->loggconf->Identity == loggconf->Identity) return REM__DUPLIDENT; loggconflist_ptr++; } if ( *loggconflist_count == 0) { *loggconflist = calloc( 1 , sizeof(logg_t_loggconf_list)); if ( *loggconflist == 0) return REM__NOMEMORY; } else { new_loggconflist = calloc( *loggconflist_count + 1, sizeof(logg_t_loggconf_list)); if ( new_loggconflist == 0) return REM__NOMEMORY; memcpy( new_loggconflist, *loggconflist, *loggconflist_count * sizeof(logg_t_loggconf_list)); free( *loggconflist); *loggconflist = new_loggconflist; } loggconflist_ptr = *loggconflist + *loggconflist_count; loggconflist_ptr->objid = objid; /* Direct link to the cell */ memset( &attrref, 0, sizeof(attrref)); attrref.Objid = objid; sts = gdh_DLRefObjectInfoAttrref ( &attrref, (pwr_tAddress *) &loggconflist_ptr->loggconf, &loggconflist_ptr->subid); if ( EVEN(sts)) return sts; (*loggconflist_count)++; return REM__SUCCESS; }
void fastobject::open( double base_scantime) { pwr_tStatus sts; pwr_tUInt32 size, offs, elem; pwr_tTypeId type_id; pwr_tAName name; // Link to object sts = gdh_DLRefObjectInfoAttrref( &aref, (void **)&p, &p_dlid); if ( EVEN(sts)) throw co_error(sts); // Link to trigg object if ( cdh_ObjidIsNotNull( p->TriggObject.Objid)) { sts = gdh_DLRefObjectInfoAttrref( &p->TriggObject, (void **)&trigg, &trigg_dlid); if ( EVEN(sts)) { if ( p->Function & fast_mFunction_ManTrigg || p->Function & fast_mFunction_LevelTrigg) trigg = 0; else throw co_error(sts); } } // Link to attributes for ( int i = 0; i < FAST_CURVES; i++) { if ( cdh_ObjidIsNotNull( p->Attribute[i].Objid)) { sts = gdh_DLRefObjectInfoAttrref( &p->Attribute[i], (void **)&attributes[i], &attributes_dlid[i]); if ( EVEN(sts)) throw co_error(sts); // Get attribute type sts = gdh_AttrrefToName( &p->Attribute[i], name, sizeof( name), cdh_mName_volumeStrict); if ( EVEN(sts)) throw co_error(sts); sts = gdh_GetAttributeCharacteristics( name, &p->AttributeType[i], &attributes_size[i], &offs, &elem); if ( EVEN(sts)) throw co_error(sts); p->CurveValid[i] = true; } } // Link to time buffer if ( cdh_ObjidIsNotNull( p->TimeBuffer.Objid)) { sts = gdh_DLRefObjectInfoAttrref( &p->TimeBuffer, (void **)&time_buffer, &time_buffer_dlid); if ( EVEN(sts)) throw co_error(sts); // Get buffer size sts = gdh_AttrrefToName( &p->TimeBuffer, name, sizeof( name), cdh_mName_volumeStrict); if ( EVEN(sts)) throw co_error(sts); sts = gdh_GetAttributeCharacteristics( name, &type_id, &size, &offs, &elem); if ( EVEN(sts)) throw co_error(sts); if ( size < p->NoOfPoints * sizeof(pwr_tFloat32)) p->NoOfPoints = size / sizeof(pwr_tFloat32); } // Link to attribute buffers for ( int i = 0; i < FAST_CURVES; i++) { if ( cdh_ObjidIsNotNull( p->Buffers[i].Objid) && p->CurveValid[i]) { p->CurveValid[i] = false; sts = gdh_DLRefObjectInfoAttrref( &p->Buffers[i], (void **)&buffers[i], &buffers_dlid[i]); if ( EVEN(sts)) throw co_error(sts); p->CurveValid[i] = true; // Get buffer size sts = gdh_AttrrefToName( &p->Buffers[i], name, sizeof( name), cdh_mName_volumeStrict); if ( EVEN(sts)) throw co_error(sts); sts = gdh_GetAttributeCharacteristics( name, &type_id, &size, &offs, &elem); if ( EVEN(sts)) throw co_error(sts); if ( size < p->NoOfPoints * attributes_size[i]) p->NoOfPoints = size / attributes_size[i]; } } p->TriggMan = 0; p->Active = 0; p->Prepare = 0; p->TriggIndex = 0; if ( trigg) *trigg = 0; if ( p->ScanTime) scan_div = int( p->ScanTime / base_scantime + 0.5); else scan_div = 1; scan_base = base_scantime; }
void Init () { pwr_tUInt32 sts; pwr_tInt32 ret; char msg[80]; pwr_tObjid MHObjId; pwr_sAttrRef AttrRef; pwr_tDlid DLId; pwr_sClass_MessageHandler *MH; char fname[200]; dcli_translate_filename( fname, DATABASE); dcli_translate_filename( info_fname, DATABASE_INFO); sts = gdh_GetNodeIndex(&lHelCB.Nid); If_Error_Log_Exit(sts, "gdh_GetNodeIndex"); sts = gdh_GetClassList(pwr_cClass_MessageHandler, &MHObjId); If_Error_Log_Exit(sts, "Couldn't find message handler object"); AttrRef.Objid = MHObjId; AttrRef.Body = 0; AttrRef.Offset = 0; AttrRef.Size = sizeof(pwr_sClass_MessageHandler); AttrRef.Flags.m = 0; sts = gdh_DLRefObjectInfoAttrref(&AttrRef, (pwr_tAddress *)&MH, &DLId); If_Error_Log_Exit(sts,"Couldn't get direct link to message handler object"); if (MH->EventLogSize == 0) { Log("EventLogSize = 0, no event logger will run on this node."); errh_SetStatus( pwr_cNStatus); exit(1); } lHelCB.MaxCardinality = MH->EventLogSize; lHelCB.MaxStoreLSize = 1000; /*not used*/ lHelCB.ScanTime = 2000; /* 5 seconds */ /*create the database if it's not already created*/ if((ret = db_create(&dataBaseP, NULL, 0)) != 0) { /*error creating db-handle send the mess to errh, then exit*/ sprintf(msg, "db_create: %s, no eventlogger will run", db_strerror(ret)); errh_Error(msg); exit(1); } /*open the database*/ #if (DB_VERSION_MAJOR > 3) && (DB_VERSION_MINOR > 0) ret = dataBaseP->open(dataBaseP, NULL, fname, NULL, DATABASETYPE, DB_CREATE, 0664); #else ret = dataBaseP->open(dataBaseP, fname, NULL, DATABASETYPE, DB_CREATE, 0664); #endif if(ret != 0) { /*error opening/creating db send the mess to errh, then exit*/ sprintf(msg, "db_open: %s, no eventlogger will run", db_strerror(ret)); Log(msg); exit(1); } newhead(&listhead); }