internal string get_funcHardwareId()
        {
            if (_func == null)
            {
                return("");
            }
            string s = "";

            try
            {
                s = _func.get_hardwareId();
            }
            catch (Exception) { return(""); }

            return(s);
        }
        /**
         * <summary>
         *   Enumère toutes les fonctions de type Function.
         * <para>
         *   Returns an array of strings representing hardware identifiers for all Function functions presently connected.
         * </para>
         * </summary>
         */
        public static string[] GetSimilarFunctions()
        {
            List <string> res = new List <string>();
            YFunction     it  = YFunction.FirstFunction();

            while (it != null)
            {
                res.Add(it.get_hardwareId());
                it = it.nextFunction();
            }
            return(res.ToArray());
        }
        public static YFunctionProxy FindFunction(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YFunction      func = null;
            YFunctionProxy res  = (YFunctionProxy)YFunctionProxy.FindSimilarUnknownFunction("YFunctionProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YFunctionProxy)YFunctionProxy.FindSimilarKnownFunction("YFunctionProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YFunction.FirstFunction();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YFunctionProxy)func.get_userData());
                    }
                }
            }
            else
            {
                func = YFunction.FindFunction(name);
                if (func.get_userData() != null)
                {
                    return((YFunctionProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YFunctionProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
        // perform the initial setup that may be done without a YoctoAPI object (hwd can be null)
        internal virtual void base_init(YFunction hwd, string instantiationName)
        {
            string errmsg = "";

            _func = hwd;
            _instantiationName = instantiationName;
            InternalStuff.initYoctopuceLibrary(ref errmsg, true);
            if (_func != null)
            {
                try
                {
                    _func.set_userData(this);
                    _hwdid = _func.get_hardwareId();
                    //InternalStuff.log(" hwdID = " + _hwdid);
                }
                catch (Exception)
                {
                    //InternalStuff.log("Failed to find out HwdID, device is probably offline ");
                }
            }
        }
Ejemplo n.º 5
0
#pragma warning restore 1998


        async Task anButtonValueChangeCallBack(YFunction fct, string value)
        {
            Output.Text += await fct.get_hardwareId() + ": " + value + " (new value)\n";
        }
Ejemplo n.º 6
0
 static void anButtonValueChangeCallBack(YFunction fct, string value)
 {
     Console.WriteLine(fct.get_hardwareId() + ": " + value + " (new value)");
 }