示例#1
0
        /**
         * <summary>
         *   Defines a auxiliary function by means of a table of reference points.
         * <para>
         *   Intermediate values
         *   will be interpolated between specified reference points. The reference points are given
         *   as pairs of floating point numbers.
         *   The auxiliary function will be available for use by all ArithmeticSensor objects of the
         *   device. Up to nine auxiliary function can be defined in a device, each containing up to
         *   96 reference points.
         * </para>
         * </summary>
         * <param name="name">
         *   auxiliary function name, up to 16 characters.
         * </param>
         * <param name="inputValues">
         *   array of floating point numbers, corresponding to the function input value.
         * </param>
         * <param name="outputValues">
         *   array of floating point numbers, corresponding to the output value
         *   desired for each of the input value, index by index.
         * </param>
         * <returns>
         *   <c>YAPI.SUCCESS</c> if the call succeeds.
         * </returns>
         * <para>
         *   On failure, throws an exception or returns a negative error code.
         * </para>
         */
        public virtual async Task <int> defineAuxiliaryFunction(string name, List <double> inputValues, List <double> outputValues)
        {
            int    siz;
            string defstr;
            int    idx;
            double inputVal;
            double outputVal;
            string fname;

            siz = inputValues.Count;
            if (!(siz > 1))
            {
                this._throw(YAPI.INVALID_ARGUMENT, "auxiliary function must be defined by at least two points"); return(YAPI.INVALID_ARGUMENT);
            }
            if (!(siz == outputValues.Count))
            {
                this._throw(YAPI.INVALID_ARGUMENT, "table sizes mismatch"); return(YAPI.INVALID_ARGUMENT);
            }
            defstr = "";
            idx    = 0;
            while (idx < siz)
            {
                inputVal  = inputValues[idx];
                outputVal = outputValues[idx];
                defstr    = "" + defstr + "" + YAPIContext.imm_floatToStr(inputVal) + ":" + YAPIContext.imm_floatToStr(outputVal) + "\n";
                idx       = idx + 1;
            }
            fname = "userMap" + name + ".txt";

            return(await this._upload(fname, YAPI.DefaultEncoding.GetBytes(defstr)));
        }
示例#2
0
        /**
         * <summary>
         *   Performs a smooth transition toward a specified value of the phase shift between this channel
         *   and the other channel.
         * <para>
         *   The phase shift is executed by slightly changing the frequency
         *   temporarily during the specified duration. This function only makes sense when both channels
         *   are running, either at the same frequency, or at a multiple of the channel frequency.
         *   Any period, frequency, duty cycle or pulse width change will cancel any ongoing transition process.
         * </para>
         * </summary>
         * <param name="target">
         *   phase shift at the end of the transition, in milliseconds (floating-point number)
         * </param>
         * <param name="ms_duration">
         *   total duration of the transition, in milliseconds
         * </param>
         * <returns>
         *   <c>YAPI.SUCCESS</c> when the call succeeds.
         * </returns>
         * <para>
         *   On failure, throws an exception or returns a negative error code.
         * </para>
         */
        public virtual async Task <int> phaseMove(double target, int ms_duration)
        {
            string newval;

            newval = "" + YAPIContext.imm_floatToStr(target) + "ps:" + Convert.ToString(ms_duration);
            return(await this.set_pwmTransition(newval));
        }
示例#3
0
        /**
         * <summary>
         *   Performs a smooth frequency change toward a given value.
         * <para>
         *   Any period, frequency, duty cycle or pulse width change will cancel any ongoing transition process.
         * </para>
         * </summary>
         * <param name="target">
         *   new frequency at the end of the transition (floating-point number)
         * </param>
         * <param name="ms_duration">
         *   total duration of the transition, in milliseconds
         * </param>
         * <returns>
         *   <c>YAPI.SUCCESS</c> when the call succeeds.
         * </returns>
         * <para>
         *   On failure, throws an exception or returns a negative error code.
         * </para>
         */
        public virtual async Task <int> frequencyMove(double target, int ms_duration)
        {
            string newval;

            if (target < 0.001)
            {
                target = 0.001;
            }
            newval = "" + YAPIContext.imm_floatToStr(target) + "Hz:" + Convert.ToString(ms_duration);
            return(await this.set_pwmTransition(newval));
        }
示例#4
0
        /**
         * <summary>
         *   Trigger a given number of pulses at the specified frequency, using current duty cycle.
         * <para>
         *   At the end of the pulse train, revert to the original state of the PWM generator.
         * </para>
         * </summary>
         * <param name="target">
         *   desired frequency for the generated pulses (floating-point number)
         * </param>
         * <param name="n_pulses">
         *   desired pulse count
         * </param>
         * <returns>
         *   <c>YAPI.SUCCESS</c> when the call succeeds.
         * </returns>
         * <para>
         *   On failure, throws an exception or returns a negative error code.
         * </para>
         */
        public virtual async Task <int> triggerPulsesByFrequency(double target, int n_pulses)
        {
            string newval;

            if (target < 0.001)
            {
                target = 0.001;
            }
            newval = "" + YAPIContext.imm_floatToStr(target) + "Hz*" + Convert.ToString(n_pulses);
            return(await this.set_pwmTransition(newval));
        }