Browse Source

PrintWarningToMainLog method that gives access to Java printWarning method.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4073 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Vojtech Forejt 14 years ago
parent
commit
dc6037d047
  1. 1
      prism/include/PrismHybridGlob.h
  2. 1
      prism/include/PrismMTBDDGlob.h
  3. 1
      prism/include/PrismSparseGlob.h
  4. 19
      prism/src/hybrid/PrismHybrid.cc
  5. 19
      prism/src/mtbdd/PrismMTBDD.cc
  6. 4
      prism/src/sparse/PS_NondetReachReward.cc
  7. 4
      prism/src/sparse/PS_NondetUntil.cc
  8. 19
      prism/src/sparse/PrismSparse.cc

1
prism/include/PrismHybridGlob.h

@ -85,6 +85,7 @@ extern double last_unif;
#define logtwo(X) log((double)X)/log(2.0) #define logtwo(X) log((double)X)/log(2.0)
void PH_PrintToMainLog(JNIEnv *env, const char *str, ...); void PH_PrintToMainLog(JNIEnv *env, const char *str, ...);
void PH_PrintWarningToMainLog(JNIEnv *env, const char *str, ...);
void PH_PrintToTechLog(JNIEnv *env, const char *str, ...); void PH_PrintToTechLog(JNIEnv *env, const char *str, ...);
void PH_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after); void PH_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after);
void PH_SetErrorMessage(const char *str, ...); void PH_SetErrorMessage(const char *str, ...);

1
prism/include/PrismMTBDDGlob.h

@ -80,6 +80,7 @@ extern JNIEnv *export_env;
// function prototypes // function prototypes
void PM_PrintToMainLog(JNIEnv *env, const char *str, ...); void PM_PrintToMainLog(JNIEnv *env, const char *str, ...);
void PM_PrintWarningToMainLog(JNIEnv *env, const char *str, ...);
void PM_PrintToTechLog(JNIEnv *env, const char *str, ...); void PM_PrintToTechLog(JNIEnv *env, const char *str, ...);
void PM_SetErrorMessage(const char *str, ...); void PM_SetErrorMessage(const char *str, ...);
char *PM_GetErrorMessage(); char *PM_GetErrorMessage();

1
prism/include/PrismSparseGlob.h

@ -84,6 +84,7 @@ extern JNIEnv *export_env;
#define logtwo(X) log((double)X)/log(2.0) #define logtwo(X) log((double)X)/log(2.0)
void PS_PrintToMainLog(JNIEnv *env, const char *str, ...); void PS_PrintToMainLog(JNIEnv *env, const char *str, ...);
void PS_PrintWarningToMainLog(JNIEnv *env, const char *str, ...);
void PS_PrintToTechLog(JNIEnv *env, const char *str, ...); void PS_PrintToTechLog(JNIEnv *env, const char *str, ...);
void PS_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after); void PS_PrintMemoryToMainLog(JNIEnv *env, const char *before, double mem, const char *after);
void PS_SetErrorMessage(const char *str, ...); void PS_SetErrorMessage(const char *str, ...);

19
prism/src/hybrid/PrismHybrid.cc

@ -54,6 +54,7 @@ static jobject main_log_obj = NULL;
static jobject tech_log_obj = NULL; static jobject tech_log_obj = NULL;
// method ids for print method in logs // method ids for print method in logs
static jmethodID main_log_mid = NULL; static jmethodID main_log_mid = NULL;
static jmethodID main_log_warn = NULL;
static jmethodID tech_log_mid = NULL; static jmethodID tech_log_mid = NULL;
// numerical method stuff // numerical method stuff
@ -112,6 +113,7 @@ JNIEXPORT void JNICALL Java_hybrid_PrismHybrid_PH_1SetMainLog(JNIEnv *env, jclas
main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj)); main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj));
// get the method id for the print method // get the method id for the print method
main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V"); main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V");
main_log_warn = env->GetMethodID(main_log_cls, "printWarning", "(Ljava/lang/String;)V");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -153,6 +155,23 @@ void PH_PrintToMainLog(JNIEnv *env, const char *str, ...)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void PH_PrintWarningToMainLog(JNIEnv *env, const char *str, ...)
{
va_list argptr;
char full_string[MAX_LOG_STRING_LEN];
va_start(argptr, str);
vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr);
va_end(argptr);
if (env)
env->CallVoidMethod(main_log_obj, main_log_warn, env->NewStringUTF(full_string));
else
printf("Warning: %s", full_string);
}
//------------------------------------------------------------------------------
void PH_PrintToTechLog(JNIEnv *env, const char *str, ...) void PH_PrintToTechLog(JNIEnv *env, const char *str, ...)
{ {
va_list argptr; va_list argptr;

19
prism/src/mtbdd/PrismMTBDD.cc

@ -54,6 +54,7 @@ static jobject main_log_obj = NULL;
static jobject tech_log_obj = NULL; static jobject tech_log_obj = NULL;
// method ids for print method in logs // method ids for print method in logs
static jmethodID main_log_mid = NULL; static jmethodID main_log_mid = NULL;
static jmethodID main_log_warn = NULL;
static jmethodID tech_log_mid = NULL; static jmethodID tech_log_mid = NULL;
// numerical method stuff // numerical method stuff
@ -103,6 +104,7 @@ JNIEXPORT void JNICALL Java_mtbdd_PrismMTBDD_PM_1SetMainLog(JNIEnv *env, jclass
main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj)); main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj));
// get the method id for the print method // get the method id for the print method
main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V"); main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V");
main_log_warn = env->GetMethodID(main_log_cls, "printWarning", "(Ljava/lang/String;)V");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -144,6 +146,23 @@ void PM_PrintToMainLog(JNIEnv *env, const char *str, ...)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void PM_PrintWarningToMainLog(JNIEnv *env, const char *str, ...)
{
va_list argptr;
char full_string[MAX_LOG_STRING_LEN];
va_start(argptr, str);
vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr);
va_end(argptr);
if (env)
env->CallVoidMethod(main_log_obj, main_log_warn, env->NewStringUTF(full_string));
else
printf("Warning: %s", full_string);
}
//------------------------------------------------------------------------------
void PM_PrintToTechLog(JNIEnv *env, const char *str, ...) void PM_PrintToTechLog(JNIEnv *env, const char *str, ...)
{ {
va_list argptr; va_list argptr;

4
prism/src/sparse/PS_NondetReachReward.cc

@ -159,7 +159,7 @@ jboolean min // min or max probabilities (true = min, false = max)
// also extract list of action names from 'synchs' // also extract list of action names from 'synchs'
get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions);
} else { } else {
PS_PrintToMainLog(env, "Warning: Action labels are not available for adversary generation.\n", export_adv_filename);
PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation.\n", export_adv_filename);
} }
} }
@ -234,7 +234,7 @@ jboolean min // min or max probabilities (true = min, false = max)
if (fp_adv) { if (fp_adv) {
fprintf(fp_adv, "%d ?\n", n); fprintf(fp_adv, "%d ?\n", n);
} else { } else {
PS_PrintToMainLog(env, "\nWarning: Adversary generation cancelled (could not open file \"%s\").\n", export_adv_filename);
PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").\n", export_adv_filename);
export_adv_enabled = EXPORT_ADV_NONE; export_adv_enabled = EXPORT_ADV_NONE;
} }
} }

4
prism/src/sparse/PS_NondetUntil.cc

@ -155,7 +155,7 @@ jboolean min // min or max probabilities (true = min, false = max)
// also extract list of action names from 'synchs' // also extract list of action names from 'synchs'
get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions); get_string_array_from_java(env, synchs, action_names_jstrings, action_names, num_actions);
} else { } else {
PS_PrintToMainLog(env, "Warning: Action labels are not available for adversary generation.\n", export_adv_filename);
PS_PrintWarningToMainLog(env, "Action labels are not available for adversary generation.\n", export_adv_filename);
} }
} }
@ -212,7 +212,7 @@ jboolean min // min or max probabilities (true = min, false = max)
if (fp_adv) { if (fp_adv) {
fprintf(fp_adv, "%d ?\n", n); fprintf(fp_adv, "%d ?\n", n);
} else { } else {
PS_PrintToMainLog(env, "\nWarning: Adversary generation cancelled (could not open file \"%s\").\n", export_adv_filename);
PS_PrintWarningToMainLog(env, "Adversary generation cancelled (could not open file \"%s\").\n", export_adv_filename);
export_adv_enabled = EXPORT_ADV_NONE; export_adv_enabled = EXPORT_ADV_NONE;
} }
} }

19
prism/src/sparse/PrismSparse.cc

@ -53,6 +53,7 @@ static jobject main_log_obj = NULL;
static jobject tech_log_obj = NULL; static jobject tech_log_obj = NULL;
// method ids for print method in logs // method ids for print method in logs
static jmethodID main_log_mid = NULL; static jmethodID main_log_mid = NULL;
static jmethodID main_log_warn = NULL;
static jmethodID tech_log_mid = NULL; static jmethodID tech_log_mid = NULL;
// numerical method stuff // numerical method stuff
@ -105,6 +106,7 @@ JNIEXPORT void JNICALL Java_sparse_PrismSparse_PS_1SetMainLog(JNIEnv *env, jclas
main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj)); main_log_cls = (jclass)env->NewGlobalRef(env->GetObjectClass(main_log_obj));
// get the method id for the print method // get the method id for the print method
main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V"); main_log_mid = env->GetMethodID(main_log_cls, "print", "(Ljava/lang/String;)V");
main_log_warn = env->GetMethodID(main_log_cls, "printWarning", "(Ljava/lang/String;)V");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -146,6 +148,23 @@ void PS_PrintToMainLog(JNIEnv *env, const char *str, ...)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void PS_PrintWarningToMainLog(JNIEnv *env, const char *str, ...)
{
va_list argptr;
char full_string[MAX_LOG_STRING_LEN];
va_start(argptr, str);
vsnprintf(full_string, MAX_LOG_STRING_LEN, str, argptr);
va_end(argptr);
if (env)
env->CallVoidMethod(main_log_obj, main_log_warn, env->NewStringUTF(full_string));
else
printf("Warning: %s", full_string);
}
//------------------------------------------------------------------------------
void PS_PrintToTechLog(JNIEnv *env, const char *str, ...) void PS_PrintToTechLog(JNIEnv *env, const char *str, ...)
{ {
va_list argptr; va_list argptr;

Loading…
Cancel
Save