Esempio n. 1
0
        public static YRelayProxy FindRelay(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YRelay      func = null;
            YRelayProxy res  = (YRelayProxy)YFunctionProxy.FindSimilarUnknownFunction("YRelayProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YRelayProxy)YFunctionProxy.FindSimilarKnownFunction("YRelayProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YRelay.FirstRelay();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YRelayProxy)func.get_userData());
                    }
                }
            }
            else
            {
                func = YRelay.FindRelay(name);
                if (func.get_userData() != null)
                {
                    return((YRelayProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YRelayProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }