Commit bb71da80 authored by Sebastien Timmermans's avatar Sebastien Timmermans 🎹

[MBsysPy] [usrmodel] fix some comments

parent 334ee704
......@@ -17,14 +17,14 @@
* [New] functions to set outputs (value, vector...) are available from `MbsData` class
* [New] functions to set outputs accept numpy derivated types (`numpy.float64`, `numpy.int32`)
* [New] Setting user models accept derivated types and do conversion:
* Scalar/Vector: accept `int, float, numpy.float64, numpy.int64`, warn then try to cast to `float` otherwhise.
* State: accept list/numpy.array of `int, numpy.int64`, warn then try to cast to `int` otherwhise.
* Scalar/Vector: accept `int, float, numpy.float64, numpy.int64`, warn then try to cast to `float` otherwise.
* State: accept list/numpy.array of `int, numpy.int64`, warn then try to cast to `int` otherwise.
* Integer:
* With Python user functions: integers user model are float (accept `int, float`...) as they are loaded as float in loadxml MBsysC function.
* [New] Changing user state ids is now forbidden.
* [Template] user_ExtForces documentation improved.
* [DEV] files updated to respect pep8 (except for E116, E126, E127, E402, E501, E722, E743, W503, W504)
* [DOC] files updated to respect numpydoc style (with spyder 4 linting)
* [DOC] files updated to respect numpydoc style (with spyder 4 lining)
* [useful functions] two added :
* `pick_and_place_dvec_1 : dest[index[i]] = src[i];` (also exist for vec_0)
......
......@@ -246,20 +246,20 @@ typedef struct MbsInfoParameter
int type; //!< Type of the parameter between 1 and 7.
//!< Valid values are:
//!< - 1: scalar (one value);
//!< - 2: vector (one or multiple values);
//!< - 3: 1D Look-Up-Table;
//!< - 4: 2D Look-Up-Table;
//!< - 5: user state (one or multiple values);
//!< - 6: structure;
//!< - 7: integer (one value).
//!< 1: scalar (one value);
//!< 2: vector (one or multiple values);
//!< 3: 1D Look-Up-Table;
//!< 4: 2D Look-Up-Table;
//!< 5: user state (one or multiple values);
//!< 6: structure;
//!< 7: integer (one value).
//!<
//!< Each parameter may have zero, one or more values.
int n_value; //!< Number of value in the parameter.
int n_value; //!< Number of values in the parameter.
double *value_list; //!< Vector (index starting at 1) containing the values
//!< retrieved from the multibody file.
//!< Intergers are interpreted as double during loading.
//!< Intergers are interpreted as double during loading.
void* val_ptr; //!< Pointer to the memory storing the value.
//!< The destination of the pointer differs according to parameter type:
......@@ -274,7 +274,7 @@ typedef struct MbsInfoParameter
//!< - 2D LUT: points the MbsLut2D structure in MbsData.user_model.
//!< - structure: points the structure in MbsData.user_model.
/* probably members only used in the past fo optimization purpose */
/* probably members only used in the past for optimization purpose */
MbsInfoDData **d_value; //!< d_data for the value.
// d_value seems to be unused in MBsysC (structure only initialized).
// According to the MbsInfoDData contents, it seems to be used for optimization purpose.
......@@ -296,7 +296,7 @@ typedef struct MbsInfoParameter
int flag_PRJPATH; //!< Flag to indicate that the path to the data file start
//!< from the project path (stored as "PRJPATH" in mbs file).
char* structure_lutfile; //!< File and path (relative or absolute) to the file
//!< containing the Look-up-Table datas.
//!< containing the Look-up-Table dats.
//!< NULL if the parameter is not a 1D or 2D Look-up-Table.
} MbsInfoParameter;
......
......@@ -943,10 +943,10 @@ class MbsData(object):
"""
infos_c_ptr = self.mbs_infos_ptr.contents
# Unlock modification in dictionnary.
# Unlock modification in dictionary.
self.user_model._locked = False
# Counter for generation of user state id, used if user function are in Python.
# Counter for generation of user state id, used if user functions are in Python.
next_user_state = 1
# Shortcut to know if we are using Python user function
......@@ -956,7 +956,7 @@ class MbsData(object):
for i in range(infos_c_ptr.user_models.contents.n_user_model):
# Retrieve the user model c structure (MbsInfoUserModel)
user_model_list = infos_c_ptr.user_models.contents.user_model_list[i].contents
# Retrieve its name and create subdictionnary for the parameters
# Retrieve its name and create subdictionary for the parameters
name = bytes_to_str(user_model_list.name)
self.user_model[name] = _UserModelDict()
self.user_model[name]._parent_key = name
......@@ -970,10 +970,10 @@ class MbsData(object):
# And parameter name
name2 = bytes_to_str(parameter_list.name)
# Retrive pointer to values, as ctypes.POINTER(ctypes.c_double)
# Retrieve pointer to values, as ctypes.POINTER(ctypes.c_double)
val_ptr = parameter_list.val_ptr # Currently set in memory
# Retrive number of value in the parameter
# Retrieve number of value in the parameter
size = parameter_list.n_value
# Type of the parameter
......@@ -992,14 +992,14 @@ class MbsData(object):
state[0][0] = size
next_user_state += size
else:
# The indices of the user state have been create by the c UserModel.
# The indices of the user state have been created by the c UserModel.
state = np.ctypeslib.as_array(ctypes.cast(val_ptr, ctypes.POINTER(ctypes.c_int)), (1, size + 1))
# Preventing the user to modify the user state ids.
state.flags["WRITEABLE"] = False
self.user_model[name][name2] = state
elif um_type == 7:
if UmPy:
# The values loaded from files are stored as double. The convertion
# The values loaded from files are stored as double. The conversion
# to integer will be done for the user when asking for the parameter.
self.user_model[name][name2] = np.ctypeslib.as_array(val_ptr, (1, 1))
else:
......@@ -1007,7 +1007,7 @@ class MbsData(object):
# Casting the pointer to a pointer to int is required
self.user_model[name][name2] = np.ctypeslib.as_array(ctypes.cast(val_ptr, ctypes.POINTER(ctypes.c_int)), (1, 1))
else:
# Other parameter type are either nunaccessible or unknown.
# Other parameter types are either non accessible or unknown.
type_convertor = ['Invalid Value', 'a scalar', 'a vector',
'a 1D Look-Up-Table', 'a 2D Look-Up-Table',
'an user state', 'a structure', 'an integer']
......@@ -1021,9 +1021,9 @@ class MbsData(object):
message += "This user model will not be accessible from Python side."
mbs_warning(message)
# Lock the current user model (additionnal parameters not possible)
# Lock the current user model (additional parameters not possible)
self.user_model[name]._locked = True
# Lock the user models (additionnal user model not possible)
# Lock the user models (additional user model not possible)
self.user_model._locked = True
def set_nb_userc(self, nb):
......@@ -1895,7 +1895,7 @@ class _UserModelDict(dict):
tab[0][0] = type_conversion(value)
else:
mbs_error("The user model ['{:}']['{:}'] has an unknow type."
mbs_error("The user model ['{:}']['{:}'] has an unknown type."
.format(self._parent_key, key))
else:
mbs_error("The user model ['{:}']['{:}'] does not exists."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment