1 /* 2 * Copyright 2018 Oticon A/S 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 /** 7 * Typical options used in most devices 8 */ 9 10 #ifndef _BS_CMD_TYPICAL_H 11 #define _BS_CMD_TYPICAL_H 12 13 #include <stdbool.h> 14 #include "bs_oswrap.h" 15 #include "bs_cmd_line.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 //Typical parameters: 22 #define ARG_S_ID char* s_id; /*String identifying the simulation */ 23 #define ARG_P_ID char* p_id; /*String identifying the phy inside the simulation*/ 24 #define ARG_DEV_NBR unsigned int device_nbr; /*Number of this device in this phy*/ 25 #define ARG_GDEV_NBR unsigned int global_device_nbr; /*Overall device number in the simulation*/ 26 #define ARG_VERB unsigned int verb; /*Level of verbosity when tracing*/ 27 #define ARG_STARTO double start_offset;/*Offset in time (at the start of the simulation) of this device*/ 28 #define ARG_SEED unsigned int rseed; /*Seed/initialization for the random numbers generators*/ 29 30 //These basic arguments apply to almost all devices: 31 #define BS_BASIC_DEVICE_OPTIONS_FIELDS \ 32 ARG_S_ID \ 33 ARG_P_ID \ 34 ARG_DEV_NBR \ 35 ARG_GDEV_NBR \ 36 ARG_VERB \ 37 ARG_STARTO \ 38 ARG_SEED 39 40 typedef struct{ 41 BS_BASIC_DEVICE_OPTIONS_FIELDS 42 } bs_basic_dev_args_t; 43 44 /*manual,mandatory,switch,option, name , type, destination, callback, , description*/ 45 #define ARG_TABLE_S_ID \ 46 { false, false , false, "s", "s_id", 's', (void*)&args->s_id, NULL, "String which uniquely identifies the simulation"} 47 #define ARG_TABLE_P_ID_2G4 \ 48 { false, false , false, "p", "p_id", 's', (void*)&args->p_id, NULL, "(2G4) String which uniquely identifies the phy inside the simulation"} 49 #define ARG_TABLE_DEV_NBR \ 50 { false, true , false, "d", "device_number", 'u', (void*)&args->device_nbr,NULL, "Device number (for this phy)"} 51 #define ARG_TABLE_GDEV_NBR \ 52 { false, false , false, "gd", "global_device_number", 'u', (void*)&args->global_device_nbr, cmd_gdev_nbr_found, "(<device_number>) global device number (for tracing and so forth)"} 53 #define ARG_TABLE_VERB \ 54 { false, false , false, "v", "trace_level", 'u', (void*)&args->verb, cmd_trace_lvl_found, "Set the verbosity/tracing/logging level to <trace_level> [0: almost nothing,..(2)..,9: everything]",}, \ 55 { false, false , false, "verbose", "trace_level", 'u', (void*)&args->verb, cmd_trace_lvl_found, "Alias for -v"} 56 #define ARG_TABLE_STARTO \ 57 { false, false , false, "start_offset","start_of", 'f', (void*)&args->start_offset,NULL, "Offset in time (at the start of the simulation) of this device. At time 0 for the device, the phy will be at <start_of>"} 58 #define ARG_TABLE_STARTO_FAKE \ 59 { false, false , false, "start_offset","start_of", 'f', NULL, NULL, "Not used in this device"} 60 #define ARG_TABLE_SEED \ 61 { false, false , false, "rs", "rand_seed", 'u', (void*)&args->rseed, NULL, "Seed/initialization for the random numbers generators" },\ 62 { false, false , false, "random_seed","rand_seed", 'u', (void*)&args->rseed, NULL, "Alias for -rs" } 63 #define ARG_TABLE_SEED_FAKE \ 64 { false, false , false, "rs", "rand_seed", 'u', NULL, NULL, "Not used in this device" },\ 65 { false, false , false, "random_seed","rand_seed", 'u', NULL, NULL, "Not used in this device" } 66 #define ARG_TABLE_COLOR \ 67 { false, false , true, "color", "color", 'b', NULL, bs_trace_enable_color, "(default) Enable color in traces if printing to console"} 68 #define ARG_TABLE_NOCOLOR \ 69 { false, false , true, "no-color", "no-color", 'b', NULL, bs_trace_disable_color, "Disable color in traces even if printing to console"} 70 #define ARG_TABLE_FORCECOLOR \ 71 { false, false , true, "force-color", "force-color", 'b', NULL, bs_trace_force_color, "Enable color in traces even if printing to files/pipes"} 72 73 #define BS_BASIC_DEVICE_2G4_TYPICAL_OPTIONS_ARG_STRUCT \ 74 ARG_TABLE_S_ID, \ 75 ARG_TABLE_P_ID_2G4, \ 76 ARG_TABLE_DEV_NBR, \ 77 ARG_TABLE_GDEV_NBR, \ 78 ARG_TABLE_VERB, \ 79 ARG_TABLE_STARTO, \ 80 ARG_TABLE_SEED, \ 81 ARG_TABLE_COLOR, \ 82 ARG_TABLE_NOCOLOR, \ 83 ARG_TABLE_FORCECOLOR 84 85 #define BS_BASIC_DEVICE_2G4_FAKE_OPTIONS_ARG_STRUCT \ 86 ARG_TABLE_S_ID, \ 87 ARG_TABLE_P_ID_2G4, \ 88 ARG_TABLE_DEV_NBR, \ 89 ARG_TABLE_GDEV_NBR, \ 90 ARG_TABLE_VERB, \ 91 ARG_TABLE_STARTO_FAKE, \ 92 ARG_TABLE_SEED_FAKE, \ 93 ARG_TABLE_COLOR, \ 94 ARG_TABLE_NOCOLOR, \ 95 ARG_TABLE_FORCECOLOR 96 97 void bs_args_typical_dev_post_check(bs_basic_dev_args_t *args, bs_args_struct_t args_struct[], char *default_phy); 98 void bs_args_typical_dev_set_defaults(bs_basic_dev_args_t *args, bs_args_struct_t args_struct[]); 99 100 #ifdef __cplusplus 101 } 102 #endif 103 104 #endif 105