Пример #1
0
        public static YModuleProxy FindModule(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YModule      func = null;
            YModuleProxy res  = (YModuleProxy)YFunctionProxy.FindSimilarUnknownFunction("YModuleProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YModuleProxy)YFunctionProxy.FindSimilarKnownFunction("YModuleProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YModule.FirstModule();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YModuleProxy)func.get_userData());
                    }
                }
            }
            else
            {
                // allow to get module from the name of any function
                int p = name.IndexOf(".");
                if (p > 0)
                {
                    name = name.Substring(0, p) + ".module";
                }
                func = YModule.FindModule(name);
                if (func.get_userData() != null)
                {
                    return((YModuleProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YModuleProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
Пример #2
0
        public static YAccelerometerProxy FindAccelerometer(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YAccelerometer      func = null;
            YAccelerometerProxy res  = (YAccelerometerProxy)YFunctionProxy.FindSimilarUnknownFunction("YAccelerometerProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YAccelerometerProxy)YFunctionProxy.FindSimilarKnownFunction("YAccelerometerProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YAccelerometer.FirstAccelerometer();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YAccelerometerProxy)func.get_userData());
                    }
                }
            }
            else
            {
                func = YAccelerometer.FindAccelerometer(name);
                if (func.get_userData() != null)
                {
                    return((YAccelerometerProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YAccelerometerProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
        public static YCurrentLoopOutputProxy FindCurrentLoopOutput(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YCurrentLoopOutput      func = null;
            YCurrentLoopOutputProxy res  = (YCurrentLoopOutputProxy)YFunctionProxy.FindSimilarUnknownFunction("YCurrentLoopOutputProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YCurrentLoopOutputProxy)YFunctionProxy.FindSimilarKnownFunction("YCurrentLoopOutputProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YCurrentLoopOutput.FirstCurrentLoopOutput();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YCurrentLoopOutputProxy)func.get_userData());
                    }
                }
            }
            else
            {
                func = YCurrentLoopOutput.FindCurrentLoopOutput(name);
                if (func.get_userData() != null)
                {
                    return((YCurrentLoopOutputProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YCurrentLoopOutputProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
Пример #4
0
        public static YMultiCellWeighScaleProxy FindMultiCellWeighScale(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YMultiCellWeighScale      func = null;
            YMultiCellWeighScaleProxy res  = (YMultiCellWeighScaleProxy)YFunctionProxy.FindSimilarUnknownFunction("YMultiCellWeighScaleProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YMultiCellWeighScaleProxy)YFunctionProxy.FindSimilarKnownFunction("YMultiCellWeighScaleProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YMultiCellWeighScale.FirstMultiCellWeighScale();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YMultiCellWeighScaleProxy)func.get_userData());
                    }
                }
            }
            else
            {
                func = YMultiCellWeighScale.FindMultiCellWeighScale(name);
                if (func.get_userData() != null)
                {
                    return((YMultiCellWeighScaleProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YMultiCellWeighScaleProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
Пример #5
0
 public static void FreeAPI()
 {
     InternalStuff.log("Freeing API...");
     InternalStuff.FreeLibrary();
     YFunctionProxy.freeall();
 }