static pwr_tStatus tlog_qual_to_time( char *in_str, pwr_tTime *time) { pwr_tStatus sts; char *s; pwr_tDeltaTime one_day_time; pwr_tTime current_time; char str[64]; char timstr[64]; if ( !strcmp( in_str, "") || !strncmp( in_str, "TODAY", strlen(in_str))) { time_GetTime( ¤t_time); time_AtoAscii( ¤t_time, time_eFormat_DateAndTime, timstr, sizeof(timstr)); timstr[12] = 0; strcat( timstr, " 00:00:00.00"); sts = time_AsciiToA( timstr, time); } else if ( !strncmp( in_str, "YESTERDAY", strlen(in_str))) { time_GetTime( ¤t_time); time_AtoAscii( ¤t_time, time_eFormat_DateAndTime, timstr, sizeof(timstr)); timstr[12] = 0; strcat( timstr, " 00:00:00.00"); sts = time_AsciiToA( timstr, ¤t_time); strcpy( timstr, "1 00:00:00"); sts = time_AsciiToD( timstr, &one_day_time); time_Dneg( &one_day_time, &one_day_time); time_Aadd( time, ¤t_time, &one_day_time); } else { strcpy( str, in_str); if ( s = strchr( str, '-')) { /* Date is supplied, replace ':' to space */ if ( s = strchr( str, ':')) *s = ' '; strcpy( timstr, str); } else { /* No date is supplied, add current date as default */ time_GetTime( ¤t_time); time_AtoAscii( ¤t_time, time_eFormat_DateAndTime, timstr, sizeof(timstr)); timstr[12] = 0; strcat( timstr, " "); strcat( timstr, str); } sts = time_AsciiToA( timstr, time); if (EVEN(sts)) return sts; } return TLOG__SUCCESS; }
JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitAck (JNIEnv *env, jclass obj, jobject id) { int sts = 1; //char *str; char *str_copy; mh_sEventId eventId; jfieldID nix_fid; jfieldID idx_fid; jfieldID birthTime_fid; jclass mhrsEventId_class; pwr_tTime t; jclass pwrtStatus_id = NULL; static jmethodID pwrtStatus_cid = NULL; jint jsts; jobject return_obj; jstring jstr; pwrtStatus_id = (*env)->FindClass( env, "jpwr/rt/PwrtStatus"); if(pwrtStatus_id == NULL) { printf("fel vid PwrtStatus classidhämtning\n"); return NULL; } if(pwrtStatus_cid == NULL) { //hämta upp classid och sedan pekare till konstruktorn för PwrtStatus pwrtStatus_cid = (*env)->GetMethodID( env, pwrtStatus_id, "<init>", "(I)V"); if(pwrtStatus_cid == NULL) { printf("fel vid PwrtStatus methodidhämtning\n"); return NULL; } } //hämta upp classid till MhrsEventId-objektet mhrsEventId_class =(*env)->GetObjectClass(env,id); nix_fid =(*env)->GetFieldID(env,mhrsEventId_class,"nix", "I"); if (nix_fid ==NULL) { printf("hittade inte nix\n"); sts = -2;//lyckades inte hitta fältet } //printf("efter nix hämtning\n"); idx_fid =(*env)->GetFieldID(env,mhrsEventId_class,"idx", "I"); if (idx_fid ==NULL) { printf("hittade inte idx\n"); sts = -2;//lyckades inte hitta fältet } //printf("efter idx hämtning\n"); birthTime_fid =(*env)->GetFieldID(env,mhrsEventId_class,"birthTime", "Ljava/lang/String;"); if (birthTime_fid ==NULL) { printf("hittade inte birthTime\n"); sts = -2;//lyckades inte hitta fältet } eventId.Nix = (pwr_tNodeIndex)(*env)->GetIntField(env,id,nix_fid); eventId.Idx = (pwr_tUInt32)(*env)->GetIntField(env,id,idx_fid); jstr = (*env)->GetObjectField(env,id,birthTime_fid); str_copy = (char *)(*env)->GetStringUTFChars(env,jstr,NULL); if (str_copy ==NULL) { sts = -1;//out of memory } t = net_NetTimeToTime( &eventId.BirthTime); time_AsciiToA(str_copy, &t); sts = mh_OutunitAck(&eventId); (*env)->ReleaseStringUTFChars(env,jstr,str_copy); jsts = (jint) sts; //skapa returobjekt return_obj = (*env)->NewObject( env, pwrtStatus_id, pwrtStatus_cid, jsts); (*env)->DeleteLocalRef(env,pwrtStatus_id); return return_obj; }
void GeCurveGtk::activate_export_ok( GtkWidget *w, gpointer data) { GeCurve *curve = (GeCurve *)data; char *value; pwr_tTime from, to; int rows = 5000; pwr_tFileName filename; pwr_tStatus sts; int nr; int idx = 0; from = pwr_cNTime; time_GetTime( &to); value = gtk_combo_box_get_active_text( GTK_COMBO_BOX(((GeCurveGtk *)curve)->export_attrcombo_widget)); if ( !value) return; if ( strcmp( value, CoWowGtk::translate_utf8("All Attributes")) == 0) idx = -1; else { for ( int i = 0; i < curve->cd->cols; i++) { if ( strcmp( value, CoWowGtk::convert_utf8(curve->cd->y_name[i])) == 0) { idx = i; break; } } } g_free( value); if ( ((GeCurveGtk *)curve)->layout_mask & curve_mEnable_ExportTime) { value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_fromtime_widget), 0, -1); sts = time_AsciiToA( value, &from); g_free( value); if ( EVEN(sts)) { curve->wow->DisplayError( "Syntax Error", "From time syntax error"); return; } value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_totime_widget), 0, -1); sts = time_AsciiToA( value, &to); g_free( value); if ( EVEN(sts)) { curve->wow->DisplayError( "Syntax Error", "To time syntax error"); return; } value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_rows_widget), 0, -1); nr = sscanf( value, "%d", &rows); g_free( value); if ( nr != 1) return; } value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_filename_widget), 0, -1); strcpy( filename, value); g_free( value); g_object_set( ((GeCurveGtk *)curve)->export_widget, "visible", FALSE, NULL); if ( curve->export_cb) { sts = (curve->export_cb)( curve->parent_ctx, &from, &to, rows, idx, filename); if ( EVEN(sts)) { curve->wow->DisplayError( "Export error", "Export error"); return; } } }
int XttLog::play(XNav* xnav, char* filename, double speed, int pid) { std::ifstream fp; pwr_tFileName fname; char line[1000]; int ind; int lpid; char t1[20], t2[20]; char type[40]; char user[40]; char attr[512]; char value[1000]; xttlog_eCategory category; int num; char timstr[40]; pwr_tTime log_time; pwr_tTime prev_time; pwr_tDeltaTime diff_time; float diff_time_f; int first = 1; if (speed < 0.01) speed = 1; dcli_translate_filename(fname, filename); fp.open(fname); if (!fp) return 0; CoWow::SetAutoRemove(1); while (fp.getline(line, sizeof(line))) { num = sscanf(line, "%d %s %s %d %s %s", &ind, t1, t2, &lpid, type, user); if (pid != 0 && pid != lpid) continue; strcpy(timstr, t1); strcat(timstr, " "); strcat(timstr, t2); time_AsciiToA(timstr, &log_time); if (!first) { time_Adiff(&diff_time, &log_time, &prev_time); diff_time_f = time_DToFloat(0, &diff_time); } else diff_time_f = 0; if (diff_time_f / speed > 0.01) { xnav->wow->Wait(diff_time_f / speed); } char* s; int cnt = 0; for (s = line; *s; s++) { if (s > line && (*(s - 1) == ' ' || *(s - 1) == ' ') && (*s != ' ' && *s != ' ')) cnt++; if (cnt == num) break; } string_to_category(type, &category); switch (category) { case xttlog_eCategory_Command: case xttlog_eCategory_OpenGraph: case xttlog_eCategory_CloseGraph: case xttlog_eCategory_ApplNew: case xttlog_eCategory_ApplDelete: { int sts = xnav->command(s); printf("%8.3f %-14s %9d %s\n", diff_time_f, type, sts, s); break; } case xttlog_eCategory_SetObjectInfo: { unsigned char buf[500]; unsigned int size; pwr_tStatus sts = 0; sscanf(s, "%s %s", attr, value); octstring_to_value(value, buf, sizeof(buf), &size); if (size) { sts = gdh_SetObjectInfo(attr, buf, size); if (EVEN(sts)) { printf("gdh_SetObjectInfo error: %s %s\n", attr, value); } } printf("%8.3f %-14s %9d %s %s\n", diff_time_f, type, sts, attr, value); break; } case xttlog_eCategory_Event: { unsigned char buf[500]; unsigned int size; pwr_tStatus sts; char graph[600]; pwr_tAName instance; char* t; sts = 0; sscanf(s, "%s %s", graph, value); octstring_to_value(value, buf, sizeof(buf), &size); t = strchr(graph, ':'); if (!t) break; *t = 0; strcpy(instance, t + 1); xnav->ge_event_exec(xttlog_eCategory_Event, graph, instance, buf, size); printf( "%8.3f %-14s %9d %s %10.10s\n", diff_time_f, type, sts, graph, value); break; } case xttlog_eCategory_GeConfirmOk: case xttlog_eCategory_GeConfirmCancel: { pwr_tStatus sts; char graph[600]; pwr_tAName instance; char* t; sts = 0; strcpy(graph, s); t = strchr(graph, ':'); if (!t) break; *t = 0; strcpy(instance, t + 1); xnav->ge_event_exec(category, graph, instance, 0, 0); printf("%8.3f %-14s %9d %s\n", diff_time_f, type, sts, graph); break; } case xttlog_eCategory_LogStart: printf("%8.3f %-14s\n", diff_time_f, type); break; default:; } prev_time = log_time; if (first) first = 0; } CoWow::SetAutoRemove(0); printf(" %-14s\n", "EndOfFile"); return 1; }