コード例 #1
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
static ret_code_t del_inventory_field(SaHpiSessionIdT sessionId,
	SaHpiResourceIdT rptid, SaHpiIdrIdT rdrnum)
{
	SaErrorT	rv;
	SaHpiEntryIdT	areaId, fieldId;
	int		res, i;

	i = get_int_param("Area Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Area Id\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	areaId = res;

	i = get_int_param("Field Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Field Id\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	fieldId = res;

	rv = saHpiIdrFieldDelete(sessionId, rptid, rdrnum, areaId, fieldId);
	if (rv != SA_OK) {
		printf("ERROR!!! saHpiIdrFieldDelete: %s\n", oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	return(HPI_SHELL_OK);
}
コード例 #2
0
ファイル: cmd_retrospect.c プロジェクト: ktabata/suika2
/* サムネイルごとの情報をロードする */
static bool load_thumbnail_params(void)
{
	int32_t flag_val;
	int i;

	/* 各サムネイルの情報を取得する */
	thumbnail_count = 0;
	for(i = 0; i < THUMBNAIL_SIZE; i++) {
		/* ラベルを取得する */
		thumbnail[i].label = get_string_param(PARAM_LABEL(i));
		if (strcmp(thumbnail[i].label, "") == 0)
			break;	/* すべてのサムネイルを処理した*/

		/* 変数の値を求める */
		if (!get_variable_by_string(get_string_param(PARAM_FLAG(i)),
					    &flag_val))
			return false;

		/* サムネイルを有効にするかを求める */
		thumbnail[i].enabled = flag_val != 0;

		/* 表示位置を取得する */
		thumbnail[i].x = get_int_param(PARAM_X(i));
		thumbnail[i].y = get_int_param(PARAM_Y(i));

		thumbnail_count++;
	}

	for(i = thumbnail_count; i < THUMBNAIL_SIZE; i++)
		thumbnail[i].enabled = false;

	return true;
}
コード例 #3
0
ファイル: cmd_retrospect.c プロジェクト: ktabata/suika2
/* サムネイルを隠す色をロードする */
static bool load_hide_color(void)
{
	int r, g, b;

	r = get_int_param(RETROSPECT_PARAM_HIDE_R);
	if (r < 0) {
		log_script_rgb_negative(r);
		log_script_exec_footer();
		return false;
	}

	g = get_int_param(RETROSPECT_PARAM_HIDE_G);
	if (g < 0) {
		log_script_rgb_negative(g);
		log_script_exec_footer();
		return false;
	}

	b = get_int_param(RETROSPECT_PARAM_HIDE_B);
	if (b < 0) {
		log_script_rgb_negative(b);
		log_script_exec_footer();
		return false;
	}

	hide_color = make_pixel(0xff, (uint8_t)r, (uint8_t)g, (uint8_t)b);

	return true;
}
コード例 #4
0
ファイル: vecmat-test.c プロジェクト: dgu123/dc-lib
// ---------------------------------------------------------------------
// make_test
// ---------------------------------------------------------------------
test_t* make_test(size_t input_size, 
                  int seed, 
                  char* input_family, 
                  char* update_family, 
                  int check_correctness) {

    test_t* test = (test_t*)malloc(sizeof(test_t));
    if (test == NULL) return NULL;

    test->seed = seed;
    test->num_updates = 0;
    test->input_family = input_family;
    test->update_family = update_family;
    test->check = check_correctness;

    if (cmp_param(input_family, "_", 0, "square")) {
        if (!get_int_param(input_family, "_", 1, &test->R)) 
            return NULL;
        test->C = test->R;
    }
    else return NULL;

    test->Block = input_size;

    #if CONV || CHECK
    #endif

    return test;
}
コード例 #5
0
/*
 * Helper function for finding the normalisation constant. Extracts parameters from the
 * parameter file and then calls the sub-function to do the actual calculation.
 */
double find_normaliser(paramlist* params, void* f1, double_arr* events, char* type)
{

    if (!has_required_params(params, normaliser_params,
			     sizeof(normaliser_params)/sizeof(char*))) {
	printf("Some parameters required to find a normalisation constant are missing."\
	       " Ensure you have them in your parameter file.\n");
	exit(1);
    }

    double combine_start = get_double_param(params, "delta_est_combine_start");
    // Length of the interval when combining functions
    double combine_interval = get_double_param(params, "delta_est_combine_interval");
    double combine_end = combine_start + combine_interval;
    // Start value for finding the normalisation constant
    double normaliser_start = get_double_param(params, "normaliser_est_initial");
    // Maximum value to allow the normalisation function to look at
    double normaliser_end = get_double_param(params, "normaliser_est_max");
    // Increase the normalisation constant value by this each iteration
    double normaliser_step = get_double_param(params, "normaliser_est_step");
    // Number of subintervals to use when checking normalisation
    int normaliser_subintervals = get_int_param(params, "normaliser_est_subintervals");

    // Find a normalisation constant. This is needed to make the estimated function
    // correctly line up with the original. For baseline estimates, this is usually 1.
    return _find_normaliser(f1, events, combine_start, combine_end,
				 normaliser_start, normaliser_end,
				 normaliser_step, normaliser_subintervals,
				 type);
}
コード例 #6
0
/*
 * Helper function for baseline estimator. Extracts parameters from the parameter list and
 * passes them to the estimator.
 */
est_arr* estimate_baseline(paramlist* params, char *event_file, char *output_file)
{
    int subint = get_int_param(params, "base_iwls_subintervals");
    int iterations = get_int_param(params, "base_iwls_iterations");
    int breakpoints = get_int_param(params, "base_max_breakpoints");
    double max_extension = get_double_param(params, "base_max_extension");
    double start = get_double_param(params, "est_start_time");
    double end = get_double_param(params, "est_interval_time") + start;
    double min_interval_proportion = get_double_param(params, "base_min_interval_proportion");
    double pmf_threshold = get_double_param(params, "base_pmf_threshold");
    double pmf_sum_threshold = get_double_param(params, "base_pmf_sum_threshold");

    return _estimate_baseline(event_file, output_file, start, end, iterations, 
			      subint, breakpoints, max_extension, min_interval_proportion,
			      pmf_threshold, pmf_sum_threshold);
}
コード例 #7
0
ファイル: vecmat-test.c プロジェクト: dgu123/dc-lib
// ---------------------------------------------------------------------
// do_updates
// ---------------------------------------------------------------------
char* do_updates(test_t* test) {

    // perform update sequence on matrix M
    int i, j, num_updates;

    srand(test->seed);

    // updates of individual random cells of the matrix
    if (cmp_param(test->update_family, "_", 0, "mrnd")) {
        if (!get_int_param(test->update_family, "_", 1, &num_updates)) 
            return "wrong update parameter";

        // perform random updates
        for (j=0; j<num_updates; j++) {
            int r = rand()%test->R;
            int c = rand()%test->C;
            test->M[r][c]++;
            test->num_updates++;
        }    
    }

    // updates of entire random columns of the matrix
    else if (cmp_param(test->update_family, "_", 0, "crnd")) {
        if (!get_int_param(test->update_family, "_", 1, &num_updates)) 
            return "wrong update parameter";

        // perform random updates
        for (j=0; j<num_updates; j++) {

            int c = rand()%test->C;

            dc_begin_at();
            for (i=0; i<test->R; i++) test->M[i][c]++;
            dc_end_at();
            test->num_updates++;
        }    
    }
    else return "unknown update family";
   
    // make correctness checks
    #if CHECK
    if (test->check) {
    }
    #endif
    
    return NULL;
}
コード例 #8
0
ファイル: lab2_train.C プロジェクト: CarpLY/e6870
Lab2TrainMain::Lab2TrainMain(const map<string, string>& params) :
    m_params(params), m_frontEnd(m_params),
    m_gmmSet(get_required_string_param(m_params, "in_gmm")),
    m_outGmmFile(get_required_string_param(m_params, "out_gmm")),
    m_iterCnt(get_int_param(m_params, "iters", 1)), m_iterIdx(1),
    m_totFrmCnt(0), m_totLogProb(0.0)
    {
    }
コード例 #9
0
ファイル: config.cpp プロジェクト: NLincoln/IGVC
/**
 * @brief Initilizes the configs.
 *
 * Loads the config values from the parameter server.
 *
 */
ConfigValues initConfigs()
{
    ros::NodeHandle nh;
    ConfigValues config;
    if(!nh.getParam("/robot_base", config.robot_base))
    {
    	ROS_ERROR("robot_base is not defined on parameter server");
    }
    if(!nh.getParam("/wheel_rad", config.wheel_rad))
    {
    	ROS_ERROR("wheel_rad is not defined on the parameter server");
    }
    if(!nh.getParam("/max_speed", config.max_speed))
    {
    	ROS_ERROR("max_speed is not defined on the parameter server");
    }
    if(!nh.getParam("/max_lin_vel", config.max_lin_vel))
    {
    	ROS_ERROR("max_lin_vel is not defined on the parameter server");
    }
    if(!nh.getParam("/max_ang_vel", config.max_ang_vel))
    {
    	ROS_ERROR("max_ang_vel is not defined on the parameter server");
    }
    //controller mapping
    get_int_param("/lin_vel_axis", config.lin_vel_axis);
    get_int_param("/ang_vel_axis", config.ang_vel_axis);
    get_int_param("/teleop_btn", config.teleop_btn);
    get_int_param("/standby_btn", config.standby_btn);
    get_int_param("/autonomous_btn", config.autonomous_btn);
    get_int_param("/speed_inc_btn", config.speed_inc_btn);
    get_int_param("/speed_dec_btn", config.speed_dec_btn);
    return config;
}
コード例 #10
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
static int set_inventory_field(SaHpiSessionIdT sessionId, SaHpiResourceIdT rptid, SaHpiIdrIdT rdrnum)
{
	SaErrorT	rv;
	SaHpiIdrFieldT	field;
	char		buf[256];
	int		res, i;

	memset(&field, 0, sizeof(SaHpiIdrFieldT));
	i = get_int_param("Area Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Area Id\n");
		return(-1);
	};
	field.AreaId = res;

	i = get_int_param("Field Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Field Id\n");
		return(-1);
	};
	field.FieldId = res;

	i = get_string_param("Field type(chass,time,manuf,prodname,prodver,"
		"snum,pnum,file,tag,custom): ", buf, 9);
	if (i == 0) {
		for (i = 0; Field_types[i].name != (char *)NULL; i++)
			if (strcmp(Field_types[i].name, buf) == 0) break;
		if (Field_types[i].name == (char *)NULL) {
			printf("Error!!! Unknown Field type: %s\n", buf);
			return(-1);
		};
		field.Type = Field_types[i].val;
	};
	i = set_text_buffer(&(field.Field));
	if (i != 0) {
		printf("Invalid text\n");
		return(HPI_SHELL_CMD_ERROR);
	};
	rv = saHpiIdrFieldSet(sessionId, rptid, rdrnum, &field);
	if (rv != SA_OK) {
		printf("ERROR!!! saHpiIdrFieldSet: %s\n", oh_lookup_error(rv));
		return(rv);
	};
	return(SA_OK);
}
コード例 #11
0
ファイル: cmd_retrospect.c プロジェクト: ktabata/suika2
/* サムネイルのサイズをロードする */
static bool load_thumbnail_size(void)
{
	thumbnail_width = get_int_param(RETROSPECT_PARAM_WIDTH);
	if (thumbnail_width <= 0) {
		log_script_non_positive_size(thumbnail_width);
		log_script_exec_footer();
		return false;
	}

	thumbnail_height = get_int_param(RETROSPECT_PARAM_HEIGHT);
	if (thumbnail_width <= 0) {
		log_script_non_positive_size(thumbnail_width);
		log_script_exec_footer();
		return false;
	}

	return true;
}
コード例 #12
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
static ret_code_t set_inventory_field(SaHpiSessionIdT sessionId,
	SaHpiResourceIdT rptid, SaHpiIdrIdT rdrnum)
{
	SaErrorT	rv;
	SaHpiIdrFieldT	field, read_field;
	SaHpiEntryIdT	next;
	int		res, i;

	memset(&field, 0, sizeof(SaHpiIdrFieldT));
	i = get_int_param("Area Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Area Id\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	field.AreaId = res;

	i = get_int_param("Field Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Field Id\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	field.FieldId = res;
	
	rv = saHpiIdrFieldGet(sessionId, rptid, rdrnum, field.AreaId,
		SAHPI_IDR_FIELDTYPE_UNSPECIFIED, field.FieldId, &next, &read_field);
	if (rv != SA_OK) {
		printf("ERROR!!! saHpiIdrFieldGet: %s\n", oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	field.Type = read_field.Type;

	i = set_text_buffer(&(field.Field));
	if (i != 0) {
		printf("Invalid text\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	rv = saHpiIdrFieldSet(sessionId, rptid, rdrnum, &field);
	if (rv != SA_OK) {
		printf("ERROR!!! saHpiIdrFieldSet: %s\n", oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	return(HPI_SHELL_OK);
}
コード例 #13
0
ファイル: postal-http.c プロジェクト: catch/postal
static void
postal_http_handle_v1_users_user_devices (UrlRouter         *router,
                                          SoupServer        *server,
                                          SoupMessage       *message,
                                          const gchar       *path,
                                          GHashTable        *params,
                                          GHashTable        *query,
                                          SoupClientContext *client,
                                          gpointer           user_data)
{
   const gchar *user;
   PostalHttp *http = user_data;

   ENTRY;

   g_assert(router);
   g_assert(SOUP_IS_SERVER(server));
   g_assert(SOUP_IS_MESSAGE(message));
   g_assert(path);
   g_assert(params);
   g_assert(g_hash_table_contains(params, "user"));
   g_assert(client);
   g_assert(POSTAL_IS_HTTP(http));

   user = g_hash_table_lookup(params, "user");
   soup_server_pause_message(server, message);

   if (message->method == SOUP_METHOD_GET) {
      postal_service_find_devices(http->priv->service,
                                  user,
                                  get_int_param(query, "offset"),
                                  get_int_param(query, "limit"),
                                  NULL, /* TODO */
                                  devices_get_cb,
                                  g_object_ref(message));
      EXIT;
   }

   soup_message_set_status(message, SOUP_STATUS_METHOD_NOT_ALLOWED);
   soup_server_unpause_message(server, message);

   EXIT;
}
コード例 #14
0
ファイル: fumi.c プロジェクト: openhpi1/testrepo
static ret_code_t get_position( SaHpiUint32T * position )
{
    int i, res;

    i = get_int_param( "Position of the bank in boot order: ", &res );
    if ( i != 1 ) {
        printf( "Error!!! Invalid position\n" );
        return HPI_SHELL_PARM_ERROR ;
    }
    *position = (SaHpiUint32T)res;
    return HPI_SHELL_OK;
}
コード例 #15
0
ファイル: fumi.c プロジェクト: openhpi1/testrepo
static ret_code_t get_banknum_prompt( char * prompt, SaHpiBankNumT * banknum )
{
    int i, res;

    i = get_int_param( prompt, &res );
    if ( i != 1 ) {
        printf( "Error!!! Invalid Bank Num\n" );
        return HPI_SHELL_PARM_ERROR ;
    }
    *banknum = (SaHpiBankNumT)res;
    return HPI_SHELL_OK;
}
コード例 #16
0
 AxisCamPolled() : ROS_Slave(), cam(NULL), frame_id(0)
 {
   register_source(image = new FlowImage("image"));
   register_sink(shutter = new FlowEmpty("shutter"), 
     ROS_CALLBACK(AxisCamPolled, shutter_cb));
   if (!get_string_param(".host", axis_host))
   {
     printf("axis_host parameter not specified; defaulting to 192.168.0.90\n");
     axis_host = "192.168.0.90";
   }
   printf("axis host set to [%s]\n", axis_host.c_str());
   get_int_param(".frame_id", &frame_id);
   cam = new AxisCam(axis_host);
 }
コード例 #17
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
ret_code_t ann_block_show(void)
{
	term_def_t		*term;
	int			res, val;

	term = get_next_term();
	if (term == NULL) {
		show_rdr_attrs(&(ann_block_env.rdr_entry));
		return(HPI_SHELL_OK);
	};
	unget_term();
	res = get_int_param(" ", &val);
	if (res != 1) unget_term();
	else show_cond(ann_block_env.rptid, ann_block_env.rdrnum, val);
	return(HPI_SHELL_OK);
}
コード例 #18
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
static int delete_inventory_area(SaHpiSessionIdT sessionId, SaHpiResourceIdT rptid, SaHpiIdrIdT rdrnum)
{
	SaErrorT	rv;
	int		res, i;

	i = get_int_param("Area Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Area Id\n");
		return(-1);
	};
	rv = saHpiIdrAreaDelete(sessionId, rptid, rdrnum, res);
	if (rv != SA_OK) {
		printf("ERROR!!! saHpiIdrAreaDelete: %s\n", oh_lookup_error(rv));
		return(rv);
	};
	return(SA_OK);
}
コード例 #19
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
static int add_inventory_field(SaHpiSessionIdT sessionId, SaHpiResourceIdT rptid, SaHpiIdrIdT rdrnum)
{
	SaErrorT	rv;
	SaHpiIdrFieldT	field;
	char		buf[256];
	int		res, i;

	i = get_int_param("Area Id: ", &res);
	if (i != 1) {
		printf("Error!!! Invalid Area Id\n");
		return(-1);
	};
	field.AreaId = res;

	i = get_string_param("Field type(chass,time,manuf,prodname,prodver,"
		"snum,pnum,file,tag,custom): ", buf, 9);
	if (i != 0) {
		printf("Error!!! Invalid Field type: %s\n", buf);
		return(-1);
	};
	for (i = 0; Field_types[i].name != (char *)NULL; i++)
		if (strcmp(Field_types[i].name, buf) == 0) break;
	if (Field_types[i].name == (char *)NULL) {
		printf("Error!!! Unknown Field type: %s\n", buf);
		return(-1);
	};
	field.Type = Field_types[i].val;
	field.ReadOnly = SAHPI_FALSE;
	i = get_string_param("Field value: ", buf, 256);
	if (i != 0) {
		printf("Error!!! Invalid Field value: %s\n", buf);
		return(-1);
	};
	i = strlen(buf);
	field.Field.DataType = SAHPI_TL_TYPE_TEXT;
	field.Field.Language = SAHPI_LANG_ENGLISH;
	field.Field.DataLength = i;
	if (i > 0)
		strcpy(field.Field.Data, buf);
	rv = saHpiIdrFieldAdd(sessionId, rptid, rdrnum, &field);
	if (rv != SA_OK) {
		printf("ERROR!!! saHpiIdrFieldAdd: %s\n", oh_lookup_error(rv));
		return(rv);
	};
	return(SA_OK);
}
コード例 #20
0
ファイル: hpi_cmd.c プロジェクト: openhpi1/testrepo
ret_code_t ask_rpt(SaHpiResourceIdT *ret)
{
	term_def_t	*term;
	int		i, res;

	term = get_next_term();
	if (term == NULL) {
		if (read_file) return(HPI_SHELL_PARM_ERROR);
		i = show_rpt_list(Domain, SHOW_ALL_RPT, 0, ui_print);
		if (i == 0) {
			printf("NO rpts!\n");
			return(HPI_SHELL_CMD_ERROR);
		};
		i = get_int_param("RPT ID ==> ", &res);
		if (i == 1) *ret = (SaHpiResourceIdT)res;
		else return(HPI_SHELL_PARM_ERROR);
	} else {
		*ret = (SaHpiResourceIdT)atoi(term->term);
	};
	return(HPI_SHELL_OK);
}
コード例 #21
0
ファイル: hpi_cmd.c プロジェクト: openhpi1/testrepo
ret_code_t ask_rdr(SaHpiResourceIdT rptid, SaHpiRdrTypeT type, SaHpiInstrumentIdT *ret)
{
	term_def_t	*term;
	int		i, res;

	term = get_next_term();
	if (term == NULL) {
		if (read_file) return(HPI_SHELL_CMD_ERROR);
		i = show_rdr_list(Domain, rptid, type, ui_print);
		if (i == 0) {
			printf("No rdrs for rpt: %d\n", rptid);
			return(HPI_SHELL_CMD_ERROR);
		};
		i = get_int_param("RDR NUM ==> ", &res);
		if (i != 1) return(HPI_SHELL_PARM_ERROR);
		*ret = (SaHpiInstrumentIdT)res;
	} else {
		*ret = (SaHpiInstrumentIdT)atoi(term->term);
	};
	return(HPI_SHELL_OK);
}
コード例 #22
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
ret_code_t show_inv(void)
{
	SaHpiResourceIdT	resid = 0;
	int			i, res;
	term_def_t		*term;

	term = get_next_term();
	if (term == NULL) {
		i = show_rpt_list(Domain, SHOW_ALL_RPT, resid, ui_print);
		if (i == 0) {
			printf("NO rpt!\n");
			return(SA_OK);
		};
		i = get_int_param("RPT ID ==> ", &res);
		if (i == 1) resid = (SaHpiResourceIdT)res;
		else return SA_OK;
	} else {
		resid = (SaHpiResourceIdT)atoi(term->term);
	};
			
	return sa_show_inv(resid);
}
コード例 #23
0
ファイル: commands.c プロジェクト: openhpi1/testrepo
static ret_code_t wtd_set(void)
{
	SaHpiResourceIdT	rptid;
	SaHpiWatchdogNumT	wtdnum;
	SaHpiWatchdogT		watchdog;
	SaHpiWatchdogExpFlagsT	flags;
	SaErrorT		rv;
	ret_code_t		ret;
	int			i, res;
	char			*str, *str1;
	char			tmp[256];

	ret = ask_rpt(&rptid);
	if (ret != HPI_SHELL_OK) return(ret);
	ret = ask_rdr(rptid, SAHPI_WATCHDOG_RDR, &wtdnum);
	if (ret != HPI_SHELL_OK) return(ret);

	i = get_string_param("Log(0 | 1): ", tmp, 255);
	if (i != 0) {
		printf("Invalid Log value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};
	if (tmp[0] == '1') watchdog.Log = SAHPI_TRUE;
	else watchdog.Log = SAHPI_FALSE;

	i = get_string_param("Running(0 | 1): ", tmp, 255);
	if (i != 0) {
		printf("Invalid Running value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};
	if (tmp[0] == '1') watchdog.Running = SAHPI_TRUE;
	else watchdog.Running = SAHPI_FALSE;

	i = get_string_param(
		"TimerUse(none|bios_frb2|bios_post|os_load|sms_os|oem): ",
		tmp, 255);
	if (i != 0) {
		printf("Invalid TimerUse value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};
	if (strcmp(tmp, "none") == 0)
		watchdog.TimerUse = SAHPI_WTU_NONE;
	else if (strcmp(tmp, "bios_frb2") == 0)
		watchdog.TimerUse = SAHPI_WTU_BIOS_FRB2;
	else if (strcmp(tmp, "bios_post") == 0)
		watchdog.TimerUse = SAHPI_WTU_BIOS_POST;
	else if (strcmp(tmp, "os_load") == 0)
		watchdog.TimerUse = SAHPI_WTU_OS_LOAD;
	else if (strcmp(tmp, "sms_os") == 0)
		watchdog.TimerUse = SAHPI_WTU_SMS_OS;
	else if (strcmp(tmp, "oem") == 0)
		watchdog.TimerUse = SAHPI_WTU_OEM;
	else {
		printf("Invalid TimerUse value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};

	i = get_string_param(
		"TimerAction(no|reset|pwr_down|pwr_cycle|int): ",
		tmp, 255);
	if (i != 0) {
		printf("Invalid TimerAction value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};
	if (strcmp(tmp, "no") == 0)
		watchdog.TimerAction = SAHPI_WAE_NO_ACTION;
	else if (strcmp(tmp, "reset") == 0)
		watchdog.TimerAction = SAHPI_WAE_RESET;
	else if (strcmp(tmp, "pwr_down") == 0)
		watchdog.TimerAction = SAHPI_WAE_POWER_DOWN;
	else if (strcmp(tmp, "pwr_cycle") == 0)
		watchdog.TimerAction = SAHPI_WAE_POWER_CYCLE;
	else if (strcmp(tmp, "int") == 0)
		watchdog.TimerAction = SAHPI_WAE_TIMER_INT;
	else {
		printf("Invalid TimerAction value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};

	i = get_string_param("PretimerInterrupt(no|smi|nmi|mess|oem): ",
		tmp, 255);
	if (i != 0) {
		printf("Invalid PretimerInterrupt value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};
	if (strcmp(tmp, "no") == 0)
		watchdog.PretimerInterrupt = SAHPI_WPI_NONE;
	else if (strcmp(tmp, "smi") == 0)
		watchdog.PretimerInterrupt = SAHPI_WPI_SMI;
	else if (strcmp(tmp, "nmi") == 0)
		watchdog.PretimerInterrupt = SAHPI_WPI_NMI;
	else if (strcmp(tmp, "mess") == 0)
		watchdog.PretimerInterrupt = SAHPI_WPI_MESSAGE_INTERRUPT;
	else if (strcmp(tmp, "oem") == 0)
		watchdog.PretimerInterrupt = SAHPI_WPI_OEM;
	else {
		printf("Invalid TimerAction value: %s\n", tmp);
		return(HPI_SHELL_PARM_ERROR);
	};

	i = get_int_param("TimeOut: ", &res);
	if (i != 1) {
		printf("Invalid TimeOut value\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	watchdog.PreTimeoutInterval = res;

	i = get_string_param("Flags(\"bios_frb2|bios_post|os_load|sms_os|oem\"): ",
		tmp, 255);
	if (i != 0) *tmp = 0;
	flags = 0;
	str = tmp;
	while (strlen(str) != 0) {
		while (isspace(*str)) str++;
		str1 = str;
		while ((*str1 != ' ') && (*str1 != 0) && (*str1 != '|')) str1++;
		if (*str1 != 0) *str1++ = 0;
		else *str1 = 0;
		if (strcmp(str, "bios_frb2") == 0)
			flags |= SAHPI_WATCHDOG_EXP_BIOS_FRB2;
		if (strcmp(str, "bios_post") == 0)
			flags |= SAHPI_WATCHDOG_EXP_BIOS_POST;
		if (strcmp(str, "os_load") == 0)
			flags |= SAHPI_WATCHDOG_EXP_OS_LOAD;
		if (strcmp(str, "sms_os") == 0)
			flags |= SAHPI_WATCHDOG_EXP_SMS_OS;
		if (strcmp(str, "oem") == 0)
			flags |= SAHPI_WATCHDOG_EXP_OEM;
		str = str1;
	};

	watchdog.TimerUseExpFlags = flags;
	i = get_int_param("InitialCount: ", &res);
	if (i != 1) {
		printf("Invalid InitialCount value\n");
		return(HPI_SHELL_PARM_ERROR);
	};
	watchdog.InitialCount = res;

	rv = saHpiWatchdogTimerSet(Domain->sessionId, rptid, wtdnum, &watchdog);
	if (rv != SA_OK) {
		printf("ERROR!!! Set Watchdog: ResourceId=%d WatchdogNum=%d: %s\n",
			rptid, wtdnum, oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	return HPI_SHELL_OK;
}
コード例 #24
0
/*
 * Helper function for pmf delay estimator. Extracts parameters from the paramfile provided and 
 * passes them on to another function to do the actual computation. Also performs hierarchical
 * estimates of the delay if the hierarchical parameter is set to yes. This will perform two passes
 * over the data and attempt to improve an initial coarse estimate with a finer search in a smaller
 * range.
 */
double estimate_delay_pmf(paramlist* params, char* outfile, double_arr* base_events, double_arr* f2_events,
			  void* f1, void* f2, double normaliser, char* hierarchical, char* type, int output_switch)
{
    if (!has_required_params(params, pmf_params, sizeof(pmf_params)/sizeof(char*))) {
	printf("Some parameters required to perform a PMF estimate" \
	       " of delay are missing. Ensure you have them in your parameter" \
	       " file.\n");
	exit(1);
    }
    int hc = strcmp(hierarchical, "yes") == 0;
    // Resolution when combining functions
    double combine_step = get_double_param(params, "delta_est_pmf_resolution");
    // Start of the interval used when combining the functions
    double combine_start = get_double_param(params, "delta_est_combine_start");
    // Length of the interval when combining functions
    double combine_interval = get_double_param(params, "delta_est_combine_interval");
    // Number of bins into which we split the event data
    int num_bins = get_int_param(params, "delta_est_num_bins");
    double max_delay = get_double_param(params, "delta_est_max_delta");

    double delta_step_coarse = get_double_param(params, "delta_est_step_coarse");
    double delta_step_fine = 0;
    double fine_range = 0;

    if (hc){
	if (!has_required_params(params, hierarchical_params,
				 sizeof(hierarchical_params)/sizeof(char*))){
	    printf("Some parameters required to perform a hierarchical estimate"\
		   " of delay are missing. Ensure you have them in your parameter"\
		   " file.\n");
	    exit(1);
	}
	delta_step_fine = get_double_param(params, "delta_est_step_fine");
	fine_range = get_double_param(params, "delta_est_fine_range");
    }

    if (max_delay >= combine_interval){
	printf("The maximum delay (%lf) cannot exceed the length of the"\
	       " interval (%lf).\n", max_delay, combine_interval);
	exit(1);
    }

#ifdef VERBOSE
    printf("Estimating delay with pmf method.\n Combine step %lf, Combine interval"\
    	   " [%lf %lf], Bins %d, Max delay %lf, Step %lf, normaliser %lf\n",
    	   combine_step, combine_start, combine_interval + combine_start, num_bins, max_delay, delta_step_coarse, normaliser);
#endif

    double result = _estimate_delay_pmf(outfile, base_events, f2_events, f1, f2,
					combine_start, combine_interval, combine_step,
					num_bins, -max_delay, max_delay, max_delay,
					delta_step_coarse, normaliser, type, output_switch);

    if (hc){
#ifdef VERBOSE
	printf("Initial result is %lf. Improving estimate using finer step of %lf"\
	       " in range [%lf, %lf].\n", result, delta_step_fine, result - fine_range,
	       result + fine_range);
#endif
	char* hout = malloc(strlen(outfile) + strlen("_hier") + 5);
	sprintf(hout, "%s_hier", outfile);
	double hres = _estimate_delay_pmf(hout, base_events, f2_events, f1, f2,
					  combine_start, combine_interval, combine_step,
					  num_bins, result - fine_range,
					  result + fine_range, max_delay, delta_step_fine,
					  normaliser, type, output_switch);
	printf("Estimate revised to %lf from %lf.\n", hres, result);
	result = hres;
	free(hout);
    }
    
    return result;
}
コード例 #25
0
ファイル: net_groupmap.c プロジェクト: srimalik/samba
static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
{
	struct dom_sid sid;
	fstring ntgroup = "";
	fstring unixgrp = "";
	fstring string_sid = "";
	fstring type = "";
	fstring ntcomment = "";
	enum lsa_SidType sid_type = SID_NAME_DOM_GRP;
	uint32 rid = 0;
	gid_t gid;
	int i;
	GROUP_MAP *map;

	const char *name_type;
	const char add_usage_str[] = N_("net groupmap add "
					"{rid=<int>|sid=<string>}"
					" unixgroup=<string> "
					"[type=<domain|local|builtin>] "
					"[ntgroup=<string>] "
					"[comment=<string>]");

	name_type = "domain group";

	if (c->display_usage) {
		d_printf("%s\n%s\n", _("Usage:\n"), add_usage_str);
		return 0;
	}

	/* get the options */
	for ( i=0; i<argc; i++ ) {
		if ( !strncasecmp_m(argv[i], "rid", strlen("rid")) ) {
			rid = get_int_param(argv[i]);
			if ( rid < DOMAIN_RID_ADMINS ) {
				d_fprintf(stderr,
					  _("RID must be greater than %d\n"),
					  (uint32)DOMAIN_RID_ADMINS-1);
				return -1;
			}
		}
		else if ( !strncasecmp_m(argv[i], "unixgroup", strlen("unixgroup")) ) {
			fstrcpy( unixgrp, get_string_param( argv[i] ) );
			if ( !unixgrp[0] ) {
				d_fprintf(stderr,_( "must supply a name\n"));
				return -1;
			}
		}
		else if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
			fstrcpy( ntgroup, get_string_param( argv[i] ) );
			if ( !ntgroup[0] ) {
				d_fprintf(stderr, _("must supply a name\n"));
				return -1;
			}
		}
		else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
			fstrcpy( string_sid, get_string_param( argv[i] ) );
			if ( !string_sid[0] ) {
				d_fprintf(stderr, _("must supply a SID\n"));
				return -1;
			}
		}
		else if ( !strncasecmp_m(argv[i], "comment", strlen("comment")) ) {
			fstrcpy( ntcomment, get_string_param( argv[i] ) );
			if ( !ntcomment[0] ) {
				d_fprintf(stderr,
					  _("must supply a comment string\n"));
				return -1;
			}
		}
		else if ( !strncasecmp_m(argv[i], "type", strlen("type")) )  {
			fstrcpy( type, get_string_param( argv[i] ) );
			switch ( type[0] ) {
				case 'b':
				case 'B':
					sid_type = SID_NAME_WKN_GRP;
					name_type = "wellknown group";
					break;
				case 'd':
				case 'D':
					sid_type = SID_NAME_DOM_GRP;
					name_type = "domain group";
					break;
				case 'l':
				case 'L':
					sid_type = SID_NAME_ALIAS;
					name_type = "alias (local) group";
					break;
				default:
					d_fprintf(stderr,
						  _("unknown group type %s\n"),
						  type);
					return -1;
			}
		}
		else {
			d_fprintf(stderr, _("Bad option: %s\n"), argv[i]);
			return -1;
		}
	}

	if ( !unixgrp[0] ) {
		d_printf("%s\n%s\n", _("Usage:\n"), add_usage_str);
		return -1;
	}

	if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) {
		d_fprintf(stderr, _("Can't lookup UNIX group %s\n"), unixgrp);
		return -1;
	}

	map = talloc_zero(NULL, GROUP_MAP);
	if (!map) {
		return -1;
	}
	/* Default is domain group. */
	map->sid_name_use = SID_NAME_DOM_GRP;
	if (pdb_getgrgid(map, gid)) {
		d_printf(_("Unix group %s already mapped to SID %s\n"),
			 unixgrp, sid_string_tos(&map->sid));
		TALLOC_FREE(map);
		return -1;
	}
	TALLOC_FREE(map);

	if ( (rid == 0) && (string_sid[0] == '\0') ) {
		d_printf(_("No rid or sid specified, choosing a RID\n"));
		if (pdb_capabilities() & PDB_CAP_STORE_RIDS) {
			if (!pdb_new_rid(&rid)) {
				d_printf(_("Could not get new RID\n"));
			}
		} else {
			rid = algorithmic_pdb_gid_to_group_rid(gid);
		}
		d_printf(_("Got RID %d\n"), rid);
	}

	/* append the rid to our own domain/machine SID if we don't have a full SID */
	if ( !string_sid[0] ) {
		sid_compose(&sid, get_global_sam_sid(), rid);
		sid_to_fstring(string_sid, &sid);
	}

	if (!ntcomment[0]) {
		switch (sid_type) {
		case SID_NAME_WKN_GRP:
			fstrcpy(ntcomment, "Wellknown Unix group");
			break;
		case SID_NAME_DOM_GRP:
			fstrcpy(ntcomment, "Domain Unix group");
			break;
		case SID_NAME_ALIAS:
			fstrcpy(ntcomment, "Local Unix group");
			break;
		default:
			fstrcpy(ntcomment, "Unix group");
			break;
		}
	}

	if (!ntgroup[0] )
		strlcpy(ntgroup, unixgrp, sizeof(ntgroup));

	if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
		d_fprintf(stderr, _("adding entry for group %s failed!\n"), ntgroup);
		return -1;
	}

	d_printf(_("Successfully added group %s to the mapping db as a %s\n"),
		 ntgroup, name_type);
	return 0;
}
コード例 #26
0
ファイル: net_rpc_samsync.c プロジェクト: gojdic/samba
static void parse_samsync_partial_replication_objects(TALLOC_CTX *mem_ctx,
						      int argc,
						      const char **argv,
						      bool *do_single_object_replication,
						      struct samsync_object **objects,
						      uint32_t *num_objects)
{
	int i;

	if (argc > 0) {
		*do_single_object_replication = true;
	}

	for (i=0; i<argc; i++) {

		struct samsync_object o;

		ZERO_STRUCT(o);

		if (!StrnCaseCmp(argv[i], "user_rid=", strlen("user_rid="))) {
			o.object_identifier.rid		= get_int_param(argv[i]);
			o.object_type			= NETR_DELTA_USER;
			o.database_id			= SAM_DATABASE_DOMAIN;
		}
		if (!StrnCaseCmp(argv[i], "group_rid=", strlen("group_rid="))) {
			o.object_identifier.rid		= get_int_param(argv[i]);
			o.object_type			= NETR_DELTA_GROUP;
			o.database_id			= SAM_DATABASE_DOMAIN;
		}
		if (!StrnCaseCmp(argv[i], "group_member_rid=", strlen("group_member_rid="))) {
			o.object_identifier.rid		= get_int_param(argv[i]);
			o.object_type			= NETR_DELTA_GROUP_MEMBER;
			o.database_id			= SAM_DATABASE_DOMAIN;
		}
		if (!StrnCaseCmp(argv[i], "alias_rid=", strlen("alias_rid="))) {
			o.object_identifier.rid		= get_int_param(argv[i]);
			o.object_type			= NETR_DELTA_ALIAS;
			o.database_id			= SAM_DATABASE_BUILTIN;
		}
		if (!StrnCaseCmp(argv[i], "alias_member_rid=", strlen("alias_member_rid="))) {
			o.object_identifier.rid		= get_int_param(argv[i]);
			o.object_type			= NETR_DELTA_ALIAS_MEMBER;
			o.database_id			= SAM_DATABASE_BUILTIN;
		}
		if (!StrnCaseCmp(argv[i], "account_sid=", strlen("account_sid="))) {
			const char *sid_str = get_string_param(argv[i]);
			string_to_sid(&o.object_identifier.sid, sid_str);
			o.object_type			= NETR_DELTA_ACCOUNT;
			o.database_id			= SAM_DATABASE_PRIVS;
		}
		if (!StrnCaseCmp(argv[i], "policy_sid=", strlen("policy_sid="))) {
			const char *sid_str = get_string_param(argv[i]);
			string_to_sid(&o.object_identifier.sid, sid_str);
			o.object_type			= NETR_DELTA_POLICY;
			o.database_id			= SAM_DATABASE_PRIVS;
		}
		if (!StrnCaseCmp(argv[i], "trustdom_sid=", strlen("trustdom_sid="))) {
			const char *sid_str = get_string_param(argv[i]);
			string_to_sid(&o.object_identifier.sid, sid_str);
			o.object_type			= NETR_DELTA_TRUSTED_DOMAIN;
			o.database_id			= SAM_DATABASE_PRIVS;
		}
		if (!StrnCaseCmp(argv[i], "secret_name=", strlen("secret_name="))) {
			o.object_identifier.name	= get_string_param(argv[i]);
			o.object_type			= NETR_DELTA_SECRET;
			o.database_id			= SAM_DATABASE_PRIVS;
		}

		if (o.object_type > 0) {
			ADD_TO_ARRAY(mem_ctx, struct samsync_object, o,
				     objects, num_objects);
		}
	}
}
コード例 #27
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
static ret_code_t add_announ(SaHpiResourceIdT rptid, SaHpiInstrumentIdT rdrnum)
{
	SaErrorT		rv;
	char			str[32];
	int			i;
	SaHpiSeverityT		sev = SAHPI_OK;
	SaHpiAnnouncementT	announ;
	SaHpiStatusCondTypeT	type = SAHPI_STATUS_COND_TYPE_SENSOR;
	SaHpiDomainIdT		did;
	SaHpiResourceIdT	resId;
	SaHpiSensorNumT		sennum = 0;

	memset(&announ, 0, sizeof(SaHpiAnnouncementT));
	i = get_string_param("Severity(crit|maj|min|info|ok): ",
		str, 10);
	if (i != 0) return(HPI_SHELL_PARM_ERROR);
	if (strcmp(str, "crit") == 0) sev = SAHPI_CRITICAL;
	else if (strcmp(str, "maj") == 0) sev = SAHPI_MAJOR;
	else if (strcmp(str, "min") == 0) sev = SAHPI_MINOR;
	else if (strcmp(str, "info") == 0) sev = SAHPI_INFORMATIONAL;
	else if (strcmp(str, "ok") == 0) sev = SAHPI_OK;
	else {
		printf("Invalid severity %s\n", str);
		return(HPI_SHELL_PARM_ERROR);
	};
	announ.Severity = sev;

	memset(&announ, 0, sizeof(SaHpiAnnouncementT));
	i = get_string_param("Condition Type(sensor|res|oem|user): ",
		str, 10);
	if (i != 0) return(-1);
	if (strcmp(str, "sensor") == 0) type = SAHPI_STATUS_COND_TYPE_SENSOR;
	else if (strcmp(str, "res") == 0) type = SAHPI_STATUS_COND_TYPE_RESOURCE;
	else if (strcmp(str, "oem") == 0) type = SAHPI_STATUS_COND_TYPE_OEM;
	else if (strcmp(str, "user") == 0) type = SAHPI_STATUS_COND_TYPE_USER;
	else {
		printf("Invalid Condition Type %s\n", str);
		return(HPI_SHELL_PARM_ERROR);
	};
	announ.StatusCond.Type = type;
	// EntityPath:  is needed ???
	// oh_encode_entitypath(char *str, SaHpiEntityPathT *ep);   convert string into ep.

	i = get_int_param("DomainId: ", (int *)&did);
	if (i != 1) did = SAHPI_UNSPECIFIED_DOMAIN_ID;
	announ.StatusCond.DomainId = did;

	i = get_int_param("ResourceId: ", (int *)&resId);
	if (i != 1) resId = SAHPI_UNSPECIFIED_RESOURCE_ID;
	announ.StatusCond.ResourceId = resId;

	i = get_int_param("Sensor number: ", (int *)&sennum);
	announ.StatusCond.SensorNum = sennum;

	rv = saHpiAnnunciatorAdd(Domain->sessionId, rptid, rdrnum, &announ);
	if (rv != SA_OK) {
		printf("saHpiAnnunciatorAdd error %s\n", oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	return HPI_SHELL_OK;
}
コード例 #28
0
ファイル: ctrl_inv.c プロジェクト: openhpi1/testrepo
static ret_code_t set_control_state(SaHpiSessionIdT sessionid,
	SaHpiResourceIdT resourceid, SaHpiCtrlNumT num)
{
        SaErrorT		rv;
	SaHpiRdrT		rdr;
	SaHpiCtrlRecT		*ctrl;
	SaHpiCtrlTypeT		type;
	SaHpiCtrlStateDigitalT	state_val = 0;
	SaHpiCtrlModeT		mode;
	SaHpiCtrlStateT		state;
	char			buf[SAHPI_MAX_TEXT_BUFFER_LENGTH];
	char			*str;
	int			i, res;

	rv = saHpiRdrGetByInstrumentId(sessionid, resourceid, SAHPI_CTRL_RDR,
		num, &rdr);
	if (rv != SA_OK) {
		printf("saHpiRdrGetByInstrumentId: error: %s\n", oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	memset(&state, 0, sizeof(SaHpiCtrlStateT));
	i = get_string_param("Mode(auto|manual): ", buf, 7);
	if (i != 0) return(HPI_SHELL_CMD_ERROR);
	if (strcmp(buf, "auto") == 0) mode = SAHPI_CTRL_MODE_AUTO;
	else if (strcmp(buf, "manual") == 0) mode = SAHPI_CTRL_MODE_MANUAL;
	else return(HPI_SHELL_CMD_ERROR);
	if (mode == SAHPI_CTRL_MODE_AUTO) {
		rv = saHpiControlSet(sessionid, resourceid, num,
			mode, (SaHpiCtrlStateT *)NULL);
		if (rv != SA_OK) {
			printf("saHpiControlSet: error: %s\n",
				oh_lookup_error(rv));
			return(HPI_SHELL_CMD_ERROR);
		};
		return(HPI_SHELL_OK);
	};
	ctrl = &(rdr.RdrTypeUnion.CtrlRec);
	type = ctrl->Type;
	state.Type = type;
	switch (type) {
		case SAHPI_CTRL_TYPE_DIGITAL:
			i = get_string_param(
				"New state(on|off|pulseon|pulseoff): ", buf, 9);
			if (i != 0) return(HPI_SHELL_CMD_ERROR);
			if (strcmp(buf, "on") == 0) state_val = SAHPI_CTRL_STATE_ON;
			if (strcmp(buf, "off") == 0) state_val = SAHPI_CTRL_STATE_OFF;
			if (strcmp(buf, "pulseon") == 0)
				state_val = SAHPI_CTRL_STATE_PULSE_ON;
			if (strcmp(buf, "pulseoff") == 0)
				state_val = SAHPI_CTRL_STATE_PULSE_OFF;
			state.StateUnion.Digital = state_val;
			break;
		case SAHPI_CTRL_TYPE_DISCRETE:
			i = get_int_param("Value ==> ", &res);
			if (i != 1) {
				printf("Invalid value\n");
				return HPI_SHELL_CMD_ERROR;
			};
			state.StateUnion.Discrete = res;
			break;
		case SAHPI_CTRL_TYPE_ANALOG:
			i = get_int_param("Value ==> ", &res);
			if (i != 1) {
				printf("Invalid value\n");
				return HPI_SHELL_CMD_ERROR;
			};
			state.StateUnion.Analog = res;
			break;
		case SAHPI_CTRL_TYPE_STREAM:
			i = get_string_param("Repeat(yes|no): ", buf, 4);
			if (i != 0) return(HPI_SHELL_CMD_ERROR);
			str = buf;
			while (*str == ' ') str++;
			if (strncmp(str, "yes", 3) == 0)
				state.StateUnion.Stream.Repeat = 1;
			i = get_string_param("Stream: ", buf, 4);
			i = strlen(buf);
			if (i > 4) i = 4;
			state.StateUnion.Stream.StreamLength = i;
			strncpy((char *)(state.StateUnion.Stream.Stream), buf, i);
			break;
		case SAHPI_CTRL_TYPE_TEXT:
			i = get_int_param("Line #: ", &res);
			if (i != 1) {
				printf("Invalid value\n");
				return HPI_SHELL_CMD_ERROR;
			};
			state.StateUnion.Text.Line = res;
			printf("Text: ");
			i = set_text_buffer(&(state.StateUnion.Text.Text));
			if (i != 0) {
				printf("Invalid text\n");
				return(HPI_SHELL_CMD_ERROR);
			};
			break;
		case SAHPI_CTRL_TYPE_OEM:
			i = get_int_param("Manufacturer Id: ", &res);
			if (i != 1) {
				printf("Invalid value\n");
				return HPI_SHELL_CMD_ERROR;
			};
			state.StateUnion.Oem.MId = res;
			memset(state.StateUnion.Oem.Body, 0,
				SAHPI_CTRL_MAX_OEM_BODY_LENGTH);
			i = get_hex_string_param("Oem body: ",
				(char *)(state.StateUnion.Oem.Body),
				SAHPI_CTRL_MAX_OEM_BODY_LENGTH);
			state.StateUnion.Oem.BodyLength = i;
			break;
		default:
			strcpy(buf, "Unknown control type\n");
			return(HPI_SHELL_CMD_ERROR);
	};
	rv = saHpiControlSet(sessionid, resourceid, num,
		SAHPI_CTRL_MODE_MANUAL, &state);
	if (rv != SA_OK) {
		printf("saHpiControlSet: error: %s\n",
			oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	return(HPI_SHELL_OK);
}
コード例 #29
0
int s2e_web_configure(char buf[], int app_state, int connection_state)
{
    int err;
    int val;
    uart_config_data_t data;
    int telnet_port;
    chanend c_uart_config = (chanend) ((app_state_t *) app_state)->c_uart_config;
    chanend c_flash_data = (chanend) ((app_state_t *) app_state)->c_flash;
    char *err_msg;
    char *web_form_req;
    int flash_result;

    if (!web_server_is_post(connection_state))
        return 0;

    web_form_req = web_server_get_param("form_action", connection_state);

    if (strcmp(web_form_req, "Get") == 0)
    {
        return output_msg(buf, success_msg);
    }
    else if (strcmp(web_form_req, "Set") == 0)
    {
        val = get_int_param("id", connection_state, &err);
        if (err)
            return output_msg(buf, s2e_validation_bad_channel_id);

        data.channel_id = val;

        // Received Set request from web page
        val = get_int_param("pc", connection_state, &err);
        if (err)
            return output_msg(buf, s2e_validation_bad_parity_msg);
        data.parity = val;

        val = get_int_param("sb", connection_state, &err);
        if (err)
            return output_msg(buf, s2e_validation_bad_stop_bits_msg);
        data.stop_bits = val;

        val = get_int_param("br", connection_state, &err);
        if (err)
            return output_msg(buf, s2e_validation_bad_baudrate_msg);
        data.baud = val;

        val = get_int_param("cl", connection_state, &err);
        if (err)
            return output_msg(buf, s2e_validation_bad_char_len_msg);
        data.char_len = val;

        val = get_int_param("tp", connection_state, &err);
        if (err)
            return output_msg(buf, s2e_validation_bad_telnet_port_msg);

        telnet_port = val;

        data.polarity = 0;

        err_msg = s2e_validate_uart_config(&data);

        if (err_msg)
            return output_msg(buf, err_msg);

        err_msg = s2e_validate_telnet_port(data.channel_id, telnet_port);

        if (err_msg)
            return output_msg(buf, err_msg);

        // Do the setting

        uart_config_data_t *config = uart_get_config(data.channel_id);
        *config = data;
        uart_set_config(c_uart_config, &data);

        // We have to delay the changing of the telnet port until after the
        // page is rendered so we can use the tcp channel
        pending_telnet_port_change_id = data.channel_id;
        pending_telnet_port_change_port = telnet_port;

        return output_msg(buf, success_msg);

    } // Set
    else if (strcmp(web_form_req, "Save") == 0)
    {
        // Received Save request from web page
        send_cmd_to_flash_thread(c_flash_data, UART_CONFIG, FLASH_CMD_SAVE);

        for(int i = 0; i < NUM_UART_CHANNELS; i++)
        {
            uart_config_data_t *data1 = uart_get_config(i);
            send_data_to_flash_thread(c_flash_data, data1);
        }

        flash_result = get_flash_access_result(c_flash_data);

        if (flash_result == S2E_FLASH_OK)
        {
            return output_msg(buf, success_msg);
        }
        else
        {
            return output_msg(buf, error_msg);
        }

    } // Save
    else if (strcmp(web_form_req, "Restore") == 0)
    {
        uart_config_data_t data1;
        int telnet_port1;

        // Received Restore request from web page
        send_cmd_to_flash_thread(c_flash_data, UART_CONFIG, FLASH_CMD_RESTORE);

        flash_result = get_flash_access_result(c_flash_data);

        if (flash_result == S2E_FLASH_OK)
        {
            for (int i = 0; i < NUM_UART_CHANNELS; i++)
            {
                get_data_from_flash_thread(c_flash_data, &data1, &telnet_port1);

                uart_config_data_t *config = uart_get_config(data1.channel_id);
                *config = data1;
                uart_set_config(c_uart_config, &data1);

                // We have to delay the changing of the telnet port until after the
                // page is rendered so we can use the tcp channel
                pending_telnet_port_change_id = data1.channel_id;
                pending_telnet_port_change_port = telnet_port1;
            }
            return output_msg(buf, success_msg);
        }
        else
        {
            return output_msg(buf, error_msg);
        }

    } // Restore
    else
    {
        // invalid request
        return output_msg(buf, error_msg);
    }

    return 0;
}
コード例 #30
0
const String CHighLife::getParameterText (int index)
{
    char text [256];
    zeromem (text, 256);

    HIGHLIFE_PROGRAM* pprog=&highlife_program[user_program];

    // display enviroment parameters
    if(index==1)format_db(user_master_volume,text);

    // display program parameters
    if(index==16)sprintf(text,"%.1f Ms",(pprog->efx_chr_del*float(MAX_CHO_SIZE)*500.0f)/getSampleRate());
    if(index==17)sprintf(text,"%d%%",int(pprog->efx_chr_fdb*100.0f));
    if(index==18)sprintf(text,"%.2f Hz",get_lfo_hz(pprog->efx_chr_rat));
    if(index==19)sprintf(text,"%d%%",int(pprog->efx_chr_mod*100.0f));
    if(index==20) {
        if(get_int_param(pprog->efx_del_syn,2)) {
            sprintf(text,"%.2f Ticks",pprog->efx_del_del*4.0f);
        }
        else {
            sprintf(text,"%.1f Ms",pprog->efx_del_del*1000.0f);
        }
    }
    if(index==21)sprintf(text,"%d%%",int(pprog->efx_del_fdb*100.0f));
    if(index==22)sprintf(text,"%d%%",int(pprog->efx_rev_roo*100.0f));
    if(index==23)sprintf(text,"%d%%",int(pprog->efx_rev_wid*100.0f));
    if(index==24)sprintf(text,"%d%%",int(pprog->efx_rev_dam*100.0f));
    if(index==25)sprintf(text,"%.2f Hz",get_lfo_hz(pprog->efx_dft_frq));

    // display wave parameters
    if(user_sed_zone>=0 && user_sed_zone<pprog->num_zones)
    {
        // get zone pointer
        HIGHLIFE_ZONE* pz=&pprog->pzones[user_sed_zone];

        if(index==128)sprintf(text,pz->name);
        if(index==129)sprintf(text,"%d",pz->loop_start);
        if(index==130)sprintf(text,"%d",pz->loop_end);
        if(index==131)sprintf(text,"%d",pz->cue_pos[0]);
        if(index==132)sprintf(text,"%d",get_int_param(pz->glide_auto,NUM_GLIDE_MODES));
        if(index==133)sprintf(text,"%d%%",int(pz->vel_amp*100.0f));
        if(index==134)sprintf(text,"%d%%",int(pz->vel_mod*100.0f));
        if(index==135)sprintf(text,"-");
        if(index==136)sprintf(text,"%d",get_int_param(pz->flt_type,NUM_FILTER_MODES));
        if(index==137)sprintf(text,"%d Cents",int(pz->sys_pit_rng*2400.0f));
        if(index==138)sprintf(text,"%d%%",int(pz->flt_kbd_trk*100.0f));
        if(index==139)sprintf(text,"%d%%",int(pz->flt_vel_trk*100.0f));
        if(index==140)sprintf(text,"%d Hz",int(pz->flt_cut_frq.value*pz->flt_cut_frq.value*getSampleRate()*0.5f));
        if(index==141)sprintf(text,"%f",pz->flt_cut_frq.sense);
        if(index==142)sprintf(text,"%d%%",int(pz->flt_res_amt.value*100.0f));
        if(index==143)sprintf(text,"%f",pz->flt_res_amt.sense);
        if(index==144)sprintf(text,"%d%%",int(pz->glide.value*100.0f));
        if(index==145)sprintf(text,"%f",pz->glide.sense);
        if(index==146)format_env_ms(text,pz->amp_env_att.value);
        if(index==147)sprintf(text,"%f",pz->amp_env_att.sense);
        if(index==148)format_env_ms(text,pz->amp_env_dec.value);
        if(index==149)sprintf(text,"%f",pz->amp_env_dec.sense);
        if(index==150)sprintf(text,"%d%%",int(pz->amp_env_sus.value*100.0f));
        if(index==151)sprintf(text,"%f",pz->amp_env_sus.sense);
        if(index==152)format_env_ms(text,pz->amp_env_rel.value);
        if(index==153)sprintf(text,"%f",pz->amp_env_rel.sense);
        if(index==154)sprintf(text,"%d%%",int(pz->amp_env_amt.value*100.0f));
        if(index==155)sprintf(text,"%f",pz->amp_env_amt.sense);
        if(index==156)format_env_ms(text,pz->mod_env_att.value);
        if(index==157)sprintf(text,"%f",pz->mod_env_att.sense);
        if(index==158)format_env_ms(text,pz->mod_env_dec.value);
        if(index==159)sprintf(text,"%f",pz->mod_env_dec.sense);
        if(index==160)sprintf(text,"%d%%",int(pz->mod_env_sus.value*100.0f));
        if(index==161)sprintf(text,"%f",pz->mod_env_sus.sense);
        if(index==162)format_env_ms(text,pz->mod_env_rel.value);
        if(index==163)sprintf(text,"%f",pz->mod_env_rel.sense);
        if(index==164)sprintf(text,"%.1f%%",(pz->mod_env_cut.value*200.0f)-100.0f);
        if(index==165)sprintf(text,"%f",pz->mod_env_cut.sense);
        if(index==166)sprintf(text,"%.1f%%",(pz->mod_env_pit.value*200.0f)-100.0f);
        if(index==167)sprintf(text,"%f",pz->mod_env_pit.sense);
        if(index==168)fmt_phs(text,pz->mod_lfo_phs.value);
        if(index==169)sprintf(text,"%f",pz->mod_lfo_phs.sense);
        if(index==170) {
            if(pz->mod_lfo_syn) {
                sprintf(text,"%d Tick(s)",int(1.0f+(1.0f-pz->mod_lfo_rat.value)*255.0f));
            }
            else {
                sprintf(text,"%.2f Hz",get_lfo_hz(pz->mod_lfo_rat.value));
            }
        }
        if(index==171)sprintf(text,"%f",pz->mod_lfo_rat.sense);
        if(index==172)sprintf(text,"%.1f%%",pz->mod_lfo_amp.value*100.0f);
        if(index==173)sprintf(text,"%f",pz->mod_lfo_amp.sense);
        if(index==174)sprintf(text,"%.1f%%",(pz->mod_lfo_cut.value*200.0f)-100.0f);
        if(index==175)sprintf(text,"%f",pz->mod_lfo_cut.sense);
        if(index==176)sprintf(text,"%.1f%%",(pz->mod_lfo_res.value*200.0f)-100.0f);
        if(index==177)sprintf(text,"%f",pz->mod_lfo_res.sense);
        if(index==178)sprintf(text,"%.1f%%",(pz->mod_lfo_pit.value*200.0f)-100.0f);
        if(index==179)sprintf(text,"%f",pz->mod_lfo_pit.sense);
        if(index==180)format_db(pz->efx_chr_lev.value,text);
        if(index==181)sprintf(text,"%f",pz->efx_chr_lev.sense);
        if(index==182)format_db(pz->efx_del_lev.value,text);
        if(index==183)sprintf(text,"%f",pz->efx_del_lev.sense);
        if(index==184)format_db(pz->efx_rev_lev.value,text);
        if(index==185)sprintf(text,"%f",pz->efx_rev_lev.sense);
    }
    else
    {
        if(index==128)sprintf(text,"Not Available");
    }

    return String (text);
}