/*----------------------------------------------------------------------------*\ Check if class is an IO-type. \*----------------------------------------------------------------------------*/ int io_CheckClassIoType( io_eType type, pwr_tCid cid ) { pwr_tStatus sts; pwr_sClassDef cdef; pwr_sAttrRef aref; aref = cdh_ObjidToAref( cdh_ClassIdToObjid( cid)); sts = gdh_GetObjectInfoAttrref( &aref, &cdef, sizeof(cdef)); if ( EVEN(sts)) return 0; switch ( type) { case io_eType_Agent: if ( cdef.Flags.b.IOAgent) return 1; break; case io_eType_Rack: if ( cdef.Flags.b.IORack) return 1; break; case io_eType_Card: if ( cdef.Flags.b.IOCard) return 1; break; default: ; } return 0; }
pwr_tStatus EvEve::set_view(pwr_tOid view) { pwr_tStatus sts; sts = ala->set_view( view); if ( ODD(sts)) { pwr_tString80 name; if ( cdh_ObjidIsNull( view)) { strcpy( name, "Event List"); } else { pwr_tAttrRef name_ar, ar; ar = cdh_ObjidToAref( view); sts = gdh_ArefANameToAref( &ar, "Name", &name_ar); if (EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &name_ar, name, sizeof(name)); if (EVEN(sts)) return sts; } set_title_ala( name); } return sts; }
void StoIpPtr_init( pwr_sClass_StoIpPtr *o) { pwr_tUInt32 p; pwr_tAttrRef aref = o->IpPtrObject; /* Reset the indirect bit to fetch the pointer, not the value */ aref.Flags.b.Indirect = 0; if ( ODD( gdh_GetObjectInfoAttrref( &aref, &p, sizeof(p)))) o->Ptr = gdh_TranslateRtdbPointer( p); }
JNIEXPORT jobject JNICALL Java_jpwr_rt_RtSecurity_checkUser (JNIEnv *env , jclass object, jstring jsystemgroup, jstring juser, jstring jpassword) { int sts; const char *systemgroup; char *csystemgroup; const char *user; char *cuser; const char *password; char *cpassword; jclass cdhrInt_id; jmethodID cdhrInt_cid; jobject return_obj; unsigned int priv; jint jsts; jint jpriv; pwr_tObjid oid; pwr_sSecurity sec; pwr_tAttrRef aref; cdhrInt_id = (*env)->FindClass( env, "jpwr/rt/CdhrInt"); cdhrInt_cid = (*env)->GetMethodID( env, cdhrInt_id, "<init>", "(II)V"); systemgroup = (*env)->GetStringUTFChars( env, jsystemgroup, 0); csystemgroup = (char *)systemgroup; user = (*env)->GetStringUTFChars( env, juser, 0); cuser = (char *)user; password = (*env)->GetStringUTFChars( env, jpassword, 0); cpassword = (char *)password; sts = gdh_GetClassList ( pwr_eClass_Security, &oid); if (ODD(sts)) { aref = cdh_ObjidToAref( oid); sts = gdh_GetObjectInfoAttrref( &aref, &sec, sizeof(sec)); if ( ODD(sts)){ sts = user_CheckUser( sec.WebSystemGroup, cuser, cpassword, &priv); } } (*env)->ReleaseStringUTFChars( env, jsystemgroup, csystemgroup); (*env)->ReleaseStringUTFChars( env, juser, cuser); (*env)->ReleaseStringUTFChars( env, jpassword, cpassword); jsts = (jint) sts; if ( sts % 2 == 0) priv = pwr_mPrv_RtRead; jpriv = priv; return_obj = (*env)->NewObject( env, cdhrInt_id, cdhrInt_cid, jpriv, jsts); return return_obj; }
/*----------------------------------------------------------------------------*\ Find classes belonging to an specific IO-type. \*----------------------------------------------------------------------------*/ pwr_tStatus io_GetIoTypeClasses( io_eType type, pwr_tClassId **classes, int *size ) { pwr_tStatus sts; pwr_sClassDef cdef; pwr_tOid oid; int add_class; pwr_sAttrRef aref; *size = 0; *classes = calloc( IO_CLASSES_SIZE, sizeof(pwr_tCid)); for ( sts = gdh_GetClassList( pwr_eClass_ClassDef, &oid); ODD(sts); sts = gdh_GetNextObject( oid, &oid)) { aref = cdh_ObjidToAref( oid); sts = gdh_GetObjectInfoAttrref( &aref, &cdef, sizeof(cdef)); if ( EVEN(sts)) return sts; add_class = 0; switch ( type) { case io_eType_Agent: if ( cdef.Flags.b.IOAgent) add_class = 1; break; case io_eType_Rack: if ( cdef.Flags.b.IORack) add_class = 1; break; case io_eType_Card: if ( cdef.Flags.b.IOCard) add_class = 1; break; default: return IO__NOMETHOD; } if ( add_class) { if ( *size >= IO_CLASSES_SIZE) return IO__CLASSEXCEED; (*classes)[ *size] = cdh_ClassObjidToId( oid); (*size)++; } } return IO__SUCCESS; }
int XttMultiView::name_to_idx( const char *name) { pwr_sClass_XttMultiView mv; pwr_tStatus sts; sts = gdh_GetObjectInfoAttrref( &aref, &mv, sizeof(mv)); if ( EVEN(sts)) return sts; for ( int i = 0; i < cols; i++) { for ( int j = 0; j < rows; j++) { if ( cdh_NoCaseStrcmp( name, mv.Action[i*rows+j].Name) == 0) return i*rows+j; } } return -1; }
int XAttOneGtk::change_value(int set_focus) { int sts; GtkWidget* text_w; char* value = 0; int input_size; char aval[1024]; char buf[1024]; int len; sts = gdh_GetAttributeCharAttrref(&aref, &atype, &asize, &aoffs, &aelem); if (EVEN(sts)) return sts; switch (atype) { case pwr_eType_String: case pwr_eType_Text: input_size = asize; break; default: input_size = 80; } sts = gdh_GetObjectInfoAttrref(&aref, aval, sizeof(aval)); if (EVEN(sts)) return sts; if (atype == pwr_eType_Text) value = aval; else { XNav::attrvalue_to_string( atype, atype, &aval, buf, sizeof(buf), &len, NULL, 0); value = buf; } if (!access_rw) { gtk_label_set_text(GTK_LABEL(cmd_label), buf); } else { if (atype == pwr_eType_Text) { text_w = cmd_scrolledinput; g_object_set(cmd_input, "visible", FALSE, NULL); g_object_set(cmd_scrolledinput, "visible", TRUE, NULL); // int w, h; // gdk_drawable_get_size( pane->window, &w, &h); // gtk_paned_set_position( GTK_PANED(pane), h - 170); if (set_focus) gtk_widget_grab_focus(cmd_scrolledtextview); input_multiline = 1; if (value) { GtkTextIter start_iter, end_iter; gtk_text_buffer_get_start_iter(cmd_scrolled_buffer, &start_iter); gtk_text_buffer_get_end_iter(cmd_scrolled_buffer, &end_iter); gtk_text_buffer_delete(cmd_scrolled_buffer, &start_iter, &end_iter); gtk_text_buffer_get_start_iter(cmd_scrolled_buffer, &start_iter); gtk_text_buffer_insert(cmd_scrolled_buffer, &start_iter, value, -1); } else { GtkTextIter start_iter, end_iter; gtk_text_buffer_get_start_iter(cmd_scrolled_buffer, &start_iter); gtk_text_buffer_get_end_iter(cmd_scrolled_buffer, &end_iter); gtk_text_buffer_delete(cmd_scrolled_buffer, &start_iter, &end_iter); } } else { text_w = cmd_input; g_object_set(cmd_input, "visible", TRUE, NULL); g_object_set(cmd_scrolledinput, "visible", FALSE, NULL); if (set_focus) gtk_widget_grab_focus(cmd_input); input_multiline = 0; gtk_entry_set_max_length(GTK_ENTRY(text_w), input_size - 1); gint pos = 0; gtk_editable_delete_text(GTK_EDITABLE(cmd_input), 0, -1); if (value) { gtk_editable_insert_text( GTK_EDITABLE(text_w), value, strlen(value), &pos); // Select the text gtk_editable_set_position(GTK_EDITABLE(cmd_input), -1); gtk_editable_select_region(GTK_EDITABLE(cmd_input), 0, -1); } } message(' ', ""); set_prompt(Lng::translate("value >")); input_open = 1; } return XATT__SUCCESS; }
int main (int argc, char **argv) { pwr_tStatus sts; char *c; int cidopt = 0; pwr_tObjName cidstr; pwr_tAName astr; int i; if ( argc <= 1) { usage(); exit(1); } sts = gdh_Init("rt_gdhget"); if ( EVEN(sts)) { exit(sts); } for ( i = 1; i < argc; i++) { c = argv[i]; if ( *c == '-') { c++; switch ( *c) { case 'h': usage(); exit(0); case 'c': if ( argc <= i+1) { usage(); exit(1); } strncpy( cidstr, argv[i+1], sizeof(cidstr)); cidopt = 1; i++; break; } } else strcpy( astr, argv[i]); } if ( cidopt) { // Get the first object of class cidstr, and print the value of attribute // astr in this object pwr_tCid cid; pwr_tOid oid; pwr_tAttrRef aref, aaref; pwr_tTid a_tid; unsigned int a_size, a_offs, a_dim; void *a_valp; char str[256]; sts = gdh_ClassNameToId( cidstr, &cid); if ( EVEN(sts)) { exit(sts); } sts = gdh_GetClassList( cid, &oid); if ( EVEN(sts)) { exit(sts); } aref = cdh_ObjidToAref( oid); sts = gdh_ArefANameToAref( &aref, astr, &aaref); if ( EVEN(sts)) { exit(sts); } sts = gdh_GetAttributeCharAttrref( &aaref, &a_tid, &a_size, &a_offs, &a_dim); if ( EVEN(sts)) { exit(sts); } a_valp = calloc( 1, a_size); sts = gdh_GetObjectInfoAttrref( &aaref, a_valp, a_size); if ( EVEN(sts)) { free( a_valp); exit(sts); } sts = cdh_AttrValueToString( a_tid, a_valp, str, sizeof(str)); if ( EVEN(sts)) { free( a_valp); exit(sts); } printf( "%s\n", str); free( a_valp); exit(0); } else { // Print the value of the attriute in astr pwr_tTypeId a_tid; pwr_tUInt32 a_size, a_offs, a_elem; void *a_valp; char str[256]; sts = gdh_GetAttributeCharacteristics( astr, &a_tid, &a_size, &a_offs, &a_elem); if ( EVEN(sts)) { exit(sts); } a_valp = calloc( 1, a_size); sts = gdh_GetObjectInfo( astr, a_valp, a_size); if ( EVEN(sts)) { free( a_valp); exit(sts); } sts = cdh_AttrValueToString( a_tid, a_valp, str, sizeof(str)); if ( EVEN(sts)) { free( a_valp); exit(sts); } printf( "%s\n", str); free( a_valp); exit(0); } exit(1); }
static pwr_tStatus xtt_pb_dp_slave_load_modules( xtt_slave_sCtx *ctx) { pwr_tOid oid; pwr_tCid cid; int found; pwr_tObjName name; pwr_tString40 module_name; int sts; pwr_tAttrRef maref, aaref; for ( sts = gdh_GetChild( ctx->aref.Objid, &oid); ODD(sts); sts = gdh_GetNextSibling( oid, &oid)) { // Check that this is a module sts = gdh_GetObjectClass( oid, &cid); if ( EVEN(sts)) return sts; found = 0; for ( int i = 0; ; i++) { if ( ctx->gsd->module_classlist[i].cid == 0) break; if ( ctx->gsd->module_classlist[i].cid == cid) { found = 1; break; } } if ( !found) // This is not a known module object continue; // Get name sts = gdh_ObjidToName( oid, name, sizeof(name), cdh_mName_object); if ( EVEN(sts)) return sts; maref = cdh_ObjidToAref( oid); // Get ModuleName attribute sts = gdh_ArefANameToAref( &maref, "ModuleName", &aaref); if ( EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &aaref, module_name, sizeof(module_name)); if ( EVEN(sts)) return sts; ctx->gsd->add_module_conf( cid, oid, name, module_name); } // Set address pwr_tUInt16 address; sts = gdh_ArefANameToAref( &ctx->aref, "SlaveAddress", &aaref); if ( EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &aaref, &address, sizeof(address)); if ( EVEN(sts)) return sts; ctx->gsd->address = address; // Set byte order pwr_tByteOrderingEnum byte_order; sts = gdh_ArefANameToAref( &ctx->aref, "ByteOrdering", &aaref); if ( EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &aaref, &byte_order, sizeof(byte_order)); if ( EVEN(sts)) return sts; ctx->gsd->byte_order = byte_order; // Set Ext_User_Prm_Data pwr_tUInt8 prm_user_data[256]; pwr_tUInt16 prm_user_data_len; int len; sts = gdh_ArefANameToAref( &ctx->aref, "PrmUserData", &aaref); if ( EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &aaref, prm_user_data, sizeof(prm_user_data)); if ( EVEN(sts)) return sts; sts = gdh_ArefANameToAref( &ctx->aref, "PrmUserDataLen", &aaref); if ( EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &aaref, &prm_user_data_len, sizeof(prm_user_data_len)); if ( EVEN(sts)) return sts; len = prm_user_data_len; if ( len != 0) { sts = ctx->gsd->unpack_ext_user_prm_data( (char *)prm_user_data, len); if ( EVEN(sts)) return sts; } return 1; }
pwr_tStatus xtt_pb_dp_slave_create_ctx( pwr_tAttrRef aref, void *editor_ctx, xtt_slave_sCtx **ctxp) { pwr_tAName name; pwr_tString80 gsdfile; int sts; pwr_tFileName fname; pwr_tCid cid; pwr_tOid oid; int found; int mc_cnt; int module_cnt; pwr_tAttrRef aaref; sts = gdh_ObjidToName( aref.Objid, name, sizeof(name), cdh_mName_volumeStrict); if ( EVEN(sts)) return sts; sts = gdh_ArefANameToAref( &aref, "GSDFile", &aaref); if ( EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &aaref, gsdfile, sizeof(gsdfile)); if ( EVEN(sts)) return sts; if ( strcmp( gsdfile, "") == 0) { return PB__GSDATTR; } xtt_slave_sCtx *ctx = (xtt_slave_sCtx *) calloc( 1, sizeof(xtt_slave_sCtx)); ctx->aref = aref; // Count modules module_cnt = 0; for ( sts = gdh_GetChild( aref.Objid, &oid); ODD(sts); sts = gdh_GetNextSibling( oid, &oid)) { module_cnt++; } ctx->mc = (gsd_sModuleClass *) calloc( module_cnt + 2, sizeof(gsd_sModuleClass)); mc_cnt = 0; ctx->editor_ctx = editor_ctx; ctx->mc[0].cid = pwr_cClass_Pb_Module; sts = gdh_ObjidToName( cdh_ClassIdToObjid(ctx->mc[0].cid), ctx->mc[0].name, sizeof(ctx->mc[0].name), cdh_mName_object); if ( EVEN(sts)) return sts; mc_cnt++; for ( sts = gdh_GetChild( aref.Objid, &oid); ODD(sts); sts = gdh_GetNextSibling( oid, &oid)) { sts = gdh_GetObjectClass( oid, &cid); if ( EVEN(sts)) return sts; found = 0; for ( int i = 0; i < mc_cnt; i++) { if ( ctx->mc[i].cid == cid) { found = 1; break; } } if ( found) continue; ctx->mc[mc_cnt].cid = cid; sts = gdh_ObjidToName( cdh_ClassIdToObjid(cid), ctx->mc[mc_cnt].name, sizeof(ctx->mc[0].name), cdh_mName_object); if ( EVEN(sts)) return sts; mc_cnt++; } if ( strchr( gsdfile, '/') == 0) { strcpy( fname, "$pwrp_exe/"); strcat( fname, gsdfile); } else strcpy( fname, gsdfile); ctx->gsd = new pb_gsd(); sts = ctx->gsd->read( fname); if ( EVEN(sts)) return sts; ctx->gsd->set_classes( ctx->mc); sts = xtt_pb_dp_slave_load_modules( ctx); if ( EVEN(sts)) return sts; *ctxp = ctx; return 1; }
int XAttOneMotif::change_value( int set_focus) { int sts; Widget text_w; char *value = 0; Arg args[5]; int input_size = 80; char aval[1024]; char buf[1024]; int len; sts = gdh_GetAttributeCharAttrref( &aref, &atype, &asize, &aoffs, &aelem); if ( EVEN(sts)) return sts; sts = gdh_GetObjectInfoAttrref( &aref, aval, sizeof(aval)); if ( EVEN(sts)) return sts; XNav::attrvalue_to_string( atype, atype, &aval, buf, sizeof(buf), &len, NULL, 0); value = buf; if ( !access_rw) { XmString cstr; cstr=XmStringCreateLtoR( aval, (char*) "ISO8859-1"); XtSetArg(args[0],XmNlabelString, cstr); XtSetValues( cmd_label, args, 1); XmStringFree( cstr); } else { if ( atype == pwr_eType_Text) { input_multiline = 1; text_w = cmd_scrolledinput; XtUnmanageChild( cmd_input); XtManageChild( text_w); XtManageChild( cmd_scrolled_ok); XtManageChild( cmd_scrolled_ca); // XtSetArg(args[0], XmNpaneMaximum, 300); // XtSetValues( xattnav_form, args, 1); XtSetArg(args[0], XmNmaxLength, input_size-1); XtSetValues( text_w, args, 1); if ( value) { XmTextSetString( text_w, value); // XmTextSetInsertionPosition( text_w, strlen(value)); } else XmTextSetString( text_w, (char*) ""); input_multiline = 1; } else { input_multiline = 0; text_w = cmd_input; XtSetArg(args[0],XmNmaxLength, input_size-1); XtSetValues( text_w, args, 1); if ( value) { XmTextSetString( text_w, value); XmTextSetInsertionPosition( text_w, strlen(value)); } else XmTextSetString( text_w, (char*) ""); input_multiline = 0; } message( ' ', ""); if ( set_focus) flow_SetInputFocus( text_w); set_prompt( Lng::translate("value >")); input_open = 1; } return XATT__SUCCESS; }
void XttFast::fast_scan( void *data) { XttFast *fast = (XttFast *)data; int i, j, k; pwr_tStatus sts; int trigg_index, first_index, last_index; // Check if any new value if ( (*fast->new_p && !fast->old_new) || fast->first_scan) { // Update curves if ( fast->fast_function & fast_mFunction_BeforeTrigg) { // Get first, last and trigg index sts = gdh_GetObjectInfoAttrref( &fast->trigg_index_attr, &trigg_index, sizeof(trigg_index)); if ( EVEN(sts)) return; sts = gdh_GetObjectInfoAttrref( &fast->first_index_attr, &first_index, sizeof(first_index)); if ( EVEN(sts)) return; sts = gdh_GetObjectInfoAttrref( &fast->last_index_attr, &last_index, sizeof(last_index)); if ( EVEN(sts)) return; // Read into temporary buffer pwr_tFloat32 *tmp = (pwr_tFloat32 *)calloc( fast->max_points, 4); sts = gdh_GetObjectInfoAttrref( &fast->time_buff, tmp, fast->max_points * 4); if ( EVEN(sts)) return; k = first_index; for ( j = 0; j < fast->max_points; j++) { if ( k >= fast->max_points) k = 0; fast->gcd->x_data[0][j] = tmp[k] - tmp[trigg_index]; if ( k == last_index) break; k++; } // If to few points, fill with dummy data for ( ; j < fast->max_points; j++) { fast->gcd->x_data[0][j] = tmp[k] - tmp[trigg_index]; } free( tmp); } else { pwr_tFloat32 *tmp = (pwr_tFloat32 *)calloc( fast->max_points, 4); sts = gdh_GetObjectInfoAttrref( &fast->time_buff, tmp, fast->max_points * 4); if ( EVEN(sts)) return; for ( j = 0; j < fast->max_points; j++) fast->gcd->x_data[0][j] = tmp[j]; free( tmp); } for ( i = 0; i < fast->fast_cnt; i++) { if ( fast->fast_function & fast_mFunction_BeforeTrigg) { // Read into temporary buffer void *tmp = calloc( fast->max_points, fast->element_size[i]); sts = gdh_GetObjectInfoAttrref( &fast->buff[i], tmp, fast->max_points * fast->element_size[i]); if ( EVEN(sts)) return; k = first_index; for ( j = 0; j < fast->max_points; j++) { if ( k >= fast->max_points) k = 0; switch( fast->type[i]) { case pwr_eType_Float32: fast->gcd->y_data[i][j] = ((pwr_tFloat32 *)tmp)[k]; break; case pwr_eType_Float64: fast->gcd->y_data[i][j] = ((pwr_tFloat64 *)tmp)[k]; break; case pwr_eType_Int64: fast->gcd->y_data[i][j] = ((pwr_tInt64 *)tmp)[k]; break; case pwr_eType_UInt64: fast->gcd->y_data[i][j] = ((pwr_tUInt64 *)tmp)[k]; break; case pwr_eType_Int32: fast->gcd->y_data[i][j] = ((pwr_tInt32 *)tmp)[k]; break; case pwr_eType_UInt32: fast->gcd->y_data[i][j] = ((pwr_tUInt32 *)tmp)[k]; break; case pwr_eType_Int16: fast->gcd->y_data[i][j] = ((pwr_tUInt16 *)tmp)[k]; break; case pwr_eType_UInt16: fast->gcd->y_data[i][j] = ((pwr_tUInt16 *)tmp)[k]; break; case pwr_eType_Int8: fast->gcd->y_data[i][j] = ((pwr_tInt8 *)tmp)[k]; break; case pwr_eType_UInt8: fast->gcd->y_data[i][j] = ((pwr_tUInt8 *)tmp)[k]; break; default: ; } if ( k == last_index) break; k++; } // If to few points, fill with 0 for ( ; j < fast->max_points; j++) { switch( fast->type[i]) { case pwr_eType_Float32: fast->gcd->y_data[i][j] = ((pwr_tFloat32 *)tmp)[k]; break; case pwr_eType_Float64: fast->gcd->y_data[i][j] = ((pwr_tFloat64 *)tmp)[k]; break; case pwr_eType_Int64: fast->gcd->y_data[i][j] = ((pwr_tInt64 *)tmp)[k]; break; case pwr_eType_UInt64: fast->gcd->y_data[i][j] = ((pwr_tUInt64 *)tmp)[k]; break; case pwr_eType_Int32: fast->gcd->y_data[i][j] = ((pwr_tInt32 *)tmp)[k]; break; case pwr_eType_UInt32: fast->gcd->y_data[i][j] = ((pwr_tUInt32 *)tmp)[k]; break; case pwr_eType_Int16: fast->gcd->y_data[i][j] = ((pwr_tInt16 *)tmp)[k]; break; case pwr_eType_UInt16: fast->gcd->y_data[i][j] = ((pwr_tInt16 *)tmp)[k]; break; case pwr_eType_Int8: fast->gcd->y_data[i][j] = ((pwr_tInt8 *)tmp)[k]; break; case pwr_eType_UInt8: fast->gcd->y_data[i][j] = ((pwr_tUInt8 *)tmp)[k]; break; default: ; } } free(tmp); } else { void *tmp = calloc( fast->max_points, fast->element_size[i]); sts = gdh_GetObjectInfoAttrref( &fast->buff[i], tmp, fast->max_points * fast->element_size[i]); if ( EVEN(sts)) return; for ( j = 0; j < fast->max_points; j++) { switch( fast->type[i]) { case pwr_eType_Float32: fast->gcd->y_data[i][j] = ((pwr_tFloat32 *)tmp)[j]; break; case pwr_eType_Float64: fast->gcd->y_data[i][j] = ((pwr_tFloat64 *)tmp)[j]; break; case pwr_eType_Int64: fast->gcd->y_data[i][j] = ((pwr_tInt64 *)tmp)[j]; break; case pwr_eType_UInt64: fast->gcd->y_data[i][j] = ((pwr_tUInt64 *)tmp)[j]; break; case pwr_eType_Int32: fast->gcd->y_data[i][j] = ((pwr_tInt32 *)tmp)[j]; break; case pwr_eType_UInt32: fast->gcd->y_data[i][j] = ((pwr_tUInt32 *)tmp)[j]; break; case pwr_eType_Int16: fast->gcd->y_data[i][j] = ((pwr_tInt16 *)tmp)[j]; break; case pwr_eType_UInt16: fast->gcd->y_data[i][j] = ((pwr_tInt16 *)tmp)[j]; break; case pwr_eType_Int8: fast->gcd->y_data[i][j] = ((pwr_tInt8 *)tmp)[j]; break; case pwr_eType_UInt8: fast->gcd->y_data[i][j] = ((pwr_tUInt8 *)tmp)[j]; break; default: ; } } free(tmp); } } // Get trigg time pwr_tTime trigg_time; sts = gdh_GetObjectInfoAttrref( &fast->trigg_time_attr, &trigg_time, sizeof(trigg_time)); if ( EVEN(sts)) return; if ( !fast->axis_configured) { fast->gcd->get_borders(); fast->gcd->get_default_axis(); if ( !fast->first_scan) { fast->curve->configure_curves(); fast->curve->configure_axes(); fast->curve->set_time( trigg_time); } } else { double axis_width; fast->gcd->get_borders(); // fast->gcd->get_default_axis(); fast->gcd->scale( fast->gcd->x_axis_type[0], fast->gcd->x_value_type[0], fast->gcd->x_min_value[0], fast->gcd->x_max_value[0], &fast->gcd->x_min_value_axis[0], &fast->gcd->x_max_value_axis[0], &fast->gcd->x_trend_lines[0], &fast->gcd->x_axis_lines[0], &fast->gcd->x_axis_linelongq[0], &fast->gcd->x_axis_valueq[0], fast->gcd->x_format[0], &axis_width, 1, 1); if ( !fast->first_scan) { fast->curve->configure_curves(); // fast->curve->configure_axes(); fast->curve->set_time( trigg_time); } } fast->first_scan = 0; } fast->old_new = *fast->new_p; if ( fast->timerid) fast->timerid->add( 1000, fast_scan, fast); }
static int graph_object_PlcThread( Graph *graph, pwr_sAttrRef *arp) { pwr_sAttrRef attrref; int sts; graph_sObjectPlcThread *od; pwr_tClassId classid; pwr_tFloat32 max_limit = 1; pwr_tFloat32 min_limit = 0; pwr_tObjid objid = arp->Objid; od = (graph_sObjectPlcThread *) calloc( 1, sizeof(graph_sObjectPlcThread)); graph->graph_object_data = (void *) od; graph->graph_object_close = graph_object_PlcThread_close; sts = gdh_GetObjectClass( objid, &classid); if ( EVEN(sts)) return sts; // Get value for ScanTime sts = gdh_ClassAttrToAttrref( classid, ".ScanTime", &attrref); if ( EVEN(sts)) return sts; attrref.Objid = objid; sts = gdh_GetObjectInfoAttrref( &attrref, (void *)&max_limit, sizeof(max_limit)); if ( EVEN(sts)) return sts; max_limit = max_limit * 2; od->set_max_show_old = max_limit; od->set_min_show_old = min_limit; // Configure ProcVal and SetVal bar sts = grow_FindObjectByName( graph->grow->ctx, "ActualScanTimeBar", &od->set_bar_object); if ( EVEN(sts)) return sts; if ( min_limit != max_limit) grow_SetBarRange( od->set_bar_object, double(min_limit), double(max_limit)); // Get pointers to max and min value od->set_max_show_p = (float *) graph->localdb_ref_or_create( "MaxShow", pwr_eType_Float32); *od->set_max_show_p = od->set_max_show_old; od->set_min_show_p = (float *) graph->localdb_ref_or_create( "MinShow", pwr_eType_Float32); *od->set_min_show_p = od->set_min_show_old; // Configure SetVal trend sts = grow_FindObjectByName( graph->grow->ctx, "ActualScanTimeTrend", &od->set_trend_object); if ( EVEN(sts)) return sts; if ( min_limit != max_limit) { grow_SetTrendRangeY( od->set_trend_object, 0, double(min_limit), double(max_limit)); grow_SetTrendRangeY( od->set_trend_object, 1, double(min_limit), double(max_limit)); } // Register scan function graph->graph_object_scan = graph_object_PlcThread_scan; return 1; }
int Graph::trend_init( graph_sObjectTrend *td, pwr_sAttrRef *arp) { pwr_tClassId classid; pwr_tFloat32 max_limit = 100; pwr_tFloat32 min_limit = 0; int sts; pwr_sAttrRef attrref; grow_tObject object; int presminlimit_found = 0; int presmaxlimit_found = 0; double scan_time; if ( arp && cdh_ObjidIsNotNull( arp->Objid)) { sts = gdh_GetAttrRefTid( arp, &classid); if ( EVEN(sts)) return sts; // Try to find attributes PresMaxLimit and PresMinLimit sts = gdh_ArefANameToAref( arp, "PresMaxLimit", &attrref); if ( ODD(sts)) { sts = gdh_GetObjectInfoAttrref( &attrref, (void *)&max_limit, sizeof(max_limit)); if ( EVEN(sts)) return sts; presmaxlimit_found = 1; } sts = gdh_ArefANameToAref( arp, "PresMinLimit", &attrref); if ( ODD(sts)) { sts = gdh_GetObjectInfoAttrref( &attrref, (void *)&min_limit, sizeof(min_limit)); if ( EVEN(sts)) return sts; presminlimit_found = 1; } } td->pres_max_limit_old = max_limit; td->pres_min_limit_old = min_limit; // Configure bar sts = grow_FindObjectByName( grow->ctx, "ActualValueBar", &td->bar_object); if ( ODD(sts)) { if ( min_limit != max_limit) grow_SetBarRange( td->bar_object, double(min_limit), double(max_limit)); } // Get pointers to max and min value sts = grow_FindObjectByName( grow->ctx, "PresMaxLimit", &object); if ( ODD(sts)) { GeDyn *dyn; grow_GetUserData( object, (void **)&dyn); td->pres_max_limit_p = (pwr_tFloat32 *) dyn->get_p(); if ( !presmaxlimit_found) // PresMaxLimit in local database, set value *td->pres_max_limit_p = max_limit; } sts = grow_FindObjectByName( grow->ctx, "PresMinLimit", &object); if ( ODD(sts)) { GeDyn *dyn; grow_GetUserData( object, (void **)&dyn); td->pres_min_limit_p = (pwr_tFloat32 *) dyn->get_p(); if ( !presminlimit_found) // PresMinLimit in local database, set value *td->pres_min_limit_p = min_limit; } // Configure trend sts = grow_FindObjectByName( grow->ctx, "ActualValueTrend", &td->trend_object); if ( EVEN(sts)) return sts; if ( td->pres_min_limit_p && td->pres_max_limit_p) { if ( min_limit != max_limit) grow_SetTrendRangeY( td->trend_object, 0, double(min_limit), double(max_limit)); } // Configure slider sts = grow_FindObjectByName( grow->ctx, "ActualValueSlider", &td->slider_object); if ( ODD(sts)) { if ( td->pres_min_limit_p && td->pres_max_limit_p) { if ( min_limit != max_limit) grow_SetSliderRange( td->slider_object, double(min_limit), double(max_limit)); } GeDyn *dyn; grow_GetUserData( td->slider_object, (void **)&dyn); td->slider_disable_p = dyn->ref_slider_disabled(); if ( td->slider_disable_p) *td->slider_disable_p = 1; } // Set scantime variable in local database grow_GetTrendScanTime( td->trend_object, &scan_time); td->scan_time_p = (float *) localdb_ref_or_create( "ScanTime", pwr_eType_Float32); td->old_scan_time = float( scan_time*200); *td->scan_time_p = td->old_scan_time; // Get Hold button sts = grow_FindObjectByName( grow->ctx, "TrendHold", &td->hold_button_object); if ( ODD(sts)) td->hold_button_p = (int *) localdb_ref_or_create( "TrendHold", pwr_eType_Boolean); GeDyn *dyn; grow_GetUserData( td->trend_object, (void **)&dyn); td->data_scan_time_p = dyn->ref_trend_scantime(); td->hold_p = dyn->ref_trend_hold(); sts = grow_FindObjectByName( grow->ctx, "SliderDisable", &td->slider_button_object); if ( ODD(sts)) td->slider_button_p = (int *) localdb_ref_or_create( "SliderDisable", pwr_eType_Boolean); return 1; }
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); 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, ".TestMask2"); graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->test_p, &od->test_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; if ( od->local_conv_p) *od->local_conv_p = 1; break; } default: { pwr_tAName chan_name; sts = gdh_AttrrefToName( &chanaref, chan_name, sizeof(chan_name), cdh_mNName); if ( ODD(sts)) { if ( od->cid == pwr_cClass_Di) { strcpy( aname, chan_name); strcat( aname, ".ConversionOn"); graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->conv_p, &od->conv_subid, sizeof(pwr_tBoolean), 0, true); } strcpy( aname, chan_name); strcat( aname, ".InvertOn"); graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->inv_p, &od->inv_subid, sizeof(pwr_tBoolean), 0, true); if ( od->cid == pwr_cClass_Do) { strcpy( aname, chan_name); strcat( aname, ".TestOn"); graph->ref_object_info( glow_eCycle_Slow, aname, (void **)&od->test_p, &od->test_subid, sizeof(pwr_tBoolean), 0, true); if ( od->local_conv_p) *od->local_conv_p = 1; } } } } // Register scan function graph->graph_object_scan = graph_object_dx_scan; return 1; }