/*! \brief ECU specific plugin handler for combo boxes \param widget is the pointer to the combo box \param data is unused \returns TRUE */ G_MODULE_EXPORT gboolean ecu_combo_handler(GtkWidget *widget, gpointer data) { gint canID = 0; gint page = 0; gint offset = 0; gint bitval = 0; gint bitmask = 0; gint bitshift = 0; gint dl_type = 0; gint last_rpm = 0; gint dload_val = 0; DataSize size = MTX_U08; GtkTreeIter iter; GtkTreeModel *model = NULL; gchar *tmpbuf = NULL; GtkWidget *partner = NULL; gboolean state = FALSE; MSCommonStdHandler handler = 0; get_essential_bits_f(widget, &canID, &page, &offset, &bitval, &bitmask, &bitshift); dl_type = (GINT) OBJ_GET(widget,"dl_type"); handler = (GINT) OBJ_GET(widget,"handler"); size = (DataSize)OBJ_GET(widget,"size"); state = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget),&iter); model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); if (!state) { /* Not selected by combo popdown button, thus is being edited. * Do a model scan to see if we actually hit the jackpot or * not, and get the iter for it... */ if (!search_model_f(model,widget,&iter)) return FALSE; } gtk_tree_model_get(model,&iter,BITVAL_COL,&bitval,-1); switch ((JimStimStdHandler)handler) { case RPM_MODE: partner = lookup_widget_f((const gchar *)OBJ_GET(widget,"special")); g_return_val_if_fail(partner,FALSE); tmpbuf = (gchar *)gtk_entry_get_text(GTK_ENTRY(partner)); last_rpm = (GINT)g_strtod(tmpbuf,NULL); if (bitval == 255) /* manual mode */ { gtk_widget_set_sensitive(lookup_widget_f("JS_manual_rpm_frame"),FALSE); dload_val = 65535; } else { gtk_widget_set_sensitive(lookup_widget_f("JS_manual_rpm_frame"),TRUE); dload_val = last_rpm; } break; default: printf("ERROR, case not handled, jimstim ecu combo button handler!\n"); break; } ms_send_to_ecu_f(canID, page, offset, MTX_U16, dload_val, FALSE); return TRUE; }
/*! \brief ECU specific combo box handler \param widget is a pointer to the widget the user modified \param data is unused \returns TRUE */ G_MODULE_EXPORT gboolean ecu_combo_handler(GtkWidget *widget, gpointer data) { GtkTreeIter iter; GtkTreeModel *model = NULL; gint handler = 0; gint bitmask = 0; gint bitshift = 0; gint total = 0; guchar bitval = 0; gchar * set_labels = NULL; gchar * swap_list = NULL; gchar * tmpbuf = NULL; gchar * table_2_update = NULL; gchar * group_2_update = NULL; gchar * lower = NULL; gchar * upper = NULL; gfloat * multiplier = NULL; gfloat * adder = NULL; gint precision = 0; gchar ** vector = NULL; guint i = 0; gint tmpi = 0; gint page = 0; gint offset = 0; gint canID = 0; gint table_num = 0; gchar * range = NULL; gchar * tempc_range = NULL; gchar * tempf_range = NULL; gchar * tempk_range = NULL; DataSize size = MTX_U08; guint8 tmp = 0; gint dload_val = 0; gint dl_type = 0; gfloat real_lower = 0.0; gfloat real_upper = 0.0; gboolean temp_dep = FALSE; gfloat tmpf = 0.0; gfloat tmpf2 = 0.0; gboolean state = FALSE; Deferred_Data *d_data = NULL; GtkWidget *tmpwidget = NULL; void *eval = NULL; void (*check_limits)(gint) = NULL; ENTER(); handler = (GINT)OBJ_GET(widget,"handler"); dl_type = (GINT)OBJ_GET(widget,"dl_type"); page = (GINT)OBJ_GET(widget,"page"); offset = (GINT)OBJ_GET(widget,"offset"); canID = (GINT)OBJ_GET(widget,"canID"); if (!OBJ_GET(widget,"size")) size = MTX_U08 ; /* default! */ else size = (DataSize)(GINT)OBJ_GET(widget,"size"); bitval = (GINT)OBJ_GET(widget,"bitval"); bitmask = (GINT)OBJ_GET(widget,"bitmask"); bitshift = get_bitshift_f(bitmask); state = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget),&iter); model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); if (state == 0) { /* Not selected by combo popdown button, thus is being edited. * Do a model scan to see if we actually hit the jackpot or * not, and get the iter for it... */ if (!search_model_f(model,widget,&iter)) { EXIT(); return FALSE; } } gtk_tree_model_get(model,&iter,BITVAL_COL,&bitval,-1); switch (handler) { case MS2_USER_OUTPUTS: /* Send the offset */ tmp = ms_get_ecu_data_f(canID,page,offset,size); tmp = tmp & ~bitmask; /*clears bits */ tmp = tmp | (bitval << bitshift); ms_send_to_ecu_f(canID, page, offset, size, tmp, TRUE); /* Get the rest of the data from the combo */ gtk_tree_model_get(model,&iter,UO_SIZE_COL,&size,-1); /* Send the "size" of the offset to the ecu */ if (OBJ_GET(widget,"size_offset")) { offset = (GINT)strtol((gchar *)OBJ_GET(widget,"size_offset"),NULL,10); ms_send_to_ecu_f(canID, page, offset, MTX_U08, size, TRUE); } else printf("size_offset NOT FOUND on widget %s\n",(gchar *)glade_get_widget_name(widget)); EXIT(); return TRUE; break; default: MTXDBG(CRITICAL,_("Default case reached, i.e. handler not found in global, common or ECU plugins for widget %s, BUG!\n"),glade_get_widget_name(widget)); EXIT(); return TRUE; break; } if (dl_type == IMMEDIATE) { dload_val = convert_before_download_f(widget,dload_val); ms_send_to_ecu_f(canID, page, offset, size, dload_val, TRUE); } EXIT(); return TRUE; }