/// <summary> /// Initializes a new instance of the <see cref="CustomParameter" /> class. /// </summary> /// <param name="command">The command for this parameter.</param> /// <param name="description">The description of this parameter.</param> /// <param name="deviceDefault">The default value of this parameter in device unit.</param> /// <param name="deviceMin">The minimum value of this parameter in device unit.</param> /// <param name="deviceMax">The maximum value of this parameter in device unit.</param> /// <param name="toDeviceValue">A function which converts value to device value.</param> /// <param name="toValue">A function which converts device value to value.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="toDeviceValue" /> or <paramref name="toValue" /> is null. /// </exception> public CustomParameter([NotNull] string command, [NotNull] string description, long deviceDefault, long deviceMin, long deviceMax, [NotNull] ToDeviceValueDelegate toDeviceValue, [NotNull] ToValueDelegate toValue) : base(command, description, deviceDefault, deviceMin, deviceMax) { if (toDeviceValue == null) throw new ArgumentNullException("toDeviceValue"); if (toValue == null) throw new ArgumentNullException("toValue"); this.toDeviceValue = toDeviceValue; this.toValue = toValue; }
protected override void OnLoad() { _load = GetMethod <LoadDelegate>("hcp_Load", true); _unload = GetMethod <UnloadDelegate>("hcp_Unload", false); _toValue = GetMethod <ToValueDelegate>("hcp_tovalue", false); _getArgumentHandle = GetMethod <GetArgumentHandleDelegate>("hcp_argat", false); _getMessage = GetMethod <GetMessageDelegate>("hcp_GetMessage", false); _encode = GetMethod <EncodeDelegate>("hcp_Encode", false); _decode = GetMethod <DecodeDelegate>("hcp_Decode", false); _newCodec = GetMethod <NewCodecDelegate>("hcp_NewCodec", false); _closeCodec = GetMethod <CloseCodecDelegate>("hcp_CloseCodec", false); _loadCodec = GetMethod <LoadCodecDelegate>("hcp_LoadCodec", false); _loadModel = GetMethod <LoadModelDelegate>("hcp_LoadModel", false); try { _state = _load(); } catch (Exception x) { throw new Exception("Error occured while calling 'hcp_Load': " + x.Message); } }